wxWidgets 3.0 - espeakedit fixes
Hi,
I have attached two patches for espeakedit:
0001-*.patch -- This makes espeakedit compile.
0002-*.patch -- This fixes a segfault when constructing the wxFont
objects for SpectFrame. These were being constructed in the global
namespace. With wxWidgets 3.0, it now requires a gtk+ window when
constructing a wxFont. The change moves creation of the fonts to the
SpectFrame constructor, so a SpectFrame object holds them internally.
I have also removed FONT_NORMAL as this was not used in the code.
These are also available on my espeak github repository at
https://github.com/rhdunn/espeak on the master branch.
NOTE: These changes should be backward compatible with wxWidgets 2.8.
Now when I try and run espeakedit I get:
-----
ASSERT INFO:
../src/gtk/font.cpp(337): assert "IsOk()" failed in GetPointSize(): invalid font
BACKTRACE:
[1] wxFont::GetPointSize() const
[2] wxObject::operator=(wxObject const&) /usr/include/wx-3.0/wx/object.
h:374
[3] MyFrame::MyFrame(wxWindow*, int, wxString const&, wxPoint const&,
wxSize const&, long) .../espeak/src/espeakedit.cpp:279
[4] MyApp::OnInit() .../espeak/src/espeakedit.cpp:178
[5] wxEntry(int&, wchar_t**)
[6] main .../espeak/src/espeakedit.cpp:99
[7] __libc_start_main
[8] _start
-----
This is on the src/espeakedit.cpp line:
notebook->AddPage(transldlg,_T("Text"),TRUE);
any ideas?
NOTE: Pressing 'Continue' on the dialog causes espeakedit to open and
display correctly. I haven't done any major testing, just fixed the
compilation and ensured it started correctly.
Thanks,
Reece H. Dunn (Cainteoir Technologies) [http://www.reecedunn.co.uk]
From fdf52edf89303bb25c15a114ed084f4c526a7e2c Mon Sep 17 00:00:00 2001
From: "Reece H. Dunn" <msclrhd@gmail.com>
Date: Sat, 16 Nov 2013 00:49:45 +0000
Subject: [PATCH 1/2] wxwidgets 3.0: make espeakedit compile
---
src/compiledata.cpp | 5 +++++
src/espeakedit.cpp | 7 +++++--
src/extras.cpp | 5 +++++
src/spectdisplay.cpp | 8 ++++++++
src/spectseq.cpp | 5 +++++
src/transldlg.cpp | 6 ++++++
src/vowelchart.cpp | 5 +++++
7 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/src/compiledata.cpp b/src/compiledata.cpp
index 09645c3..4e22e81 100644
--- a/src/compiledata.cpp
+++ b/src/compiledata.cpp
@@ -1,6 +1,7 @@
/***************************************************************************
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
+ * Copyright (C) 2013 by Reece H. Dunn *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -42,6 +43,10 @@
#include <unistd.h>
#endif
+#if wxCHECK_VERSION(3, 0, 0)
+#define wxOPEN wxFD_OPEN
+#endif
+
extern void FindPhonemesUsed(void);
extern void DisplayErrorFile(const char *fname);
extern int utf8_in(int *c, const char *buf);
diff --git a/src/espeakedit.cpp b/src/espeakedit.cpp
index e632c5a..4980e41 100644
--- a/src/espeakedit.cpp
+++ b/src/espeakedit.cpp
@@ -43,7 +43,10 @@
#include "translate.h"
#include "prosodydisplay.h"
-
+#if wxCHECK_VERSION(3, 0, 0)
+#define wxOPEN wxFD_OPEN
+#define wxSAVE wxFD_SAVE
+#endif
static const char *about_string2 = "espeakedit: %s\nAuthor: Jonathan Duddington (c) 2009\n\n"
"Licensed under GNU General Public License version 3\n"
@@ -123,7 +126,7 @@ bool MyApp::OnInit(void)
{//=====================
int j;
-wxChar *p;
+const wxChar *p;
char param[80];
diff --git a/src/extras.cpp b/src/extras.cpp
index fa6ac3b..2141a6e 100644
--- a/src/extras.cpp
+++ b/src/extras.cpp
@@ -1,6 +1,7 @@
/***************************************************************************
* Copyright (C) 2006 to 2011 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
+ * Copyright (C) 2013 by Reece H. Dunn *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -35,6 +36,10 @@
#include "translate.h"
#include "options.h"
+#if wxCHECK_VERSION(3, 0, 0)
+#define wxOPEN wxFD_OPEN
+#endif
+
extern char word_phonemes[N_WORD_PHONEMES]; // a word translated into phoneme codes
extern int __cdecl string_sorter(char **a, char **b);
diff --git a/src/spectdisplay.cpp b/src/spectdisplay.cpp
index efeb897..0904547 100644
--- a/src/spectdisplay.cpp
+++ b/src/spectdisplay.cpp
@@ -1,6 +1,7 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
+ * Copyright (C) 2013 by Reece H. Dunn *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -39,6 +40,13 @@
#include "spect.h"
#include "options.h"
+#if wxCHECK_VERSION(3, 0, 0)
+#define wxOPEN wxFD_OPEN
+#define wxSAVE wxFD_SAVE
+#define WXK_PRIOR WXK_PAGEUP
+#define WXK_NEXT WXK_PAGEDOWN
+#endif
+
extern MyFrame *frame ;
#define SCROLLUNITS 20
diff --git a/src/spectseq.cpp b/src/spectseq.cpp
index c84fab2..88aa12f 100644
--- a/src/spectseq.cpp
+++ b/src/spectseq.cpp
@@ -33,6 +33,11 @@
#include "wx/txtstrm.h"
#include "wx/datstrm.h"
+#if wxCHECK_VERSION(3, 0, 0)
+#define wxOPEN wxFD_OPEN
+#define wxSAVE wxFD_SAVE
+#endif
+
#define MAX_HARMONIC 400 // 400 * 50Hz = 20 kHz, more than enough
diff --git a/src/transldlg.cpp b/src/transldlg.cpp
index 58c7507..959144f 100644
--- a/src/transldlg.cpp
+++ b/src/transldlg.cpp
@@ -1,6 +1,7 @@
/***************************************************************************
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
+ * Copyright (C) 2013 Reece H. Dunn *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -43,6 +44,11 @@
#include "wx/filename.h"
#include "wx/sound.h"
+#if wxCHECK_VERSION(3, 0, 0)
+#define wxOPEN wxFD_OPEN
+#define wxSAVE wxFD_SAVE
+#endif
+
#define T_SOURCE 501
#define T_PHONETIC 502
#define T_TRANSLATE 503
diff --git a/src/vowelchart.cpp b/src/vowelchart.cpp
index aab1f2c..9a87b89 100644
--- a/src/vowelchart.cpp
+++ b/src/vowelchart.cpp
@@ -1,6 +1,7 @@
/***************************************************************************
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
+ * Copyright (C) 2013 Reece H. Dunn *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -37,6 +38,10 @@
#include "translate.h"
#include "options.h"
+#if wxCHECK_VERSION(3, 0, 0)
+#define wxOPEN wxFD_OPEN
+#endif
+
/* Read a file of vowel symbols and f1,f2 formants, and produce a vowel diagram
*/
extern wxString path_phsource;
--
1.8.4.2
From fcaf5d9012d8109f8ee13e79b71d876de4b3aa1b Mon Sep 17 00:00:00 2001
From: "Reece H. Dunn" <msclrhd@gmail.com>
Date: Sat, 16 Nov 2013 00:53:33 +0000
Subject: [PATCH 2/2] wxwidgets 3.0: move FONT_* construction to SpectFrame
When using wxWidgets 3.0, creating a wxFont requires the gtk+
library to be initialized. This is causing espeakedit to segfault.
SpectFrame::Draw is the only place where the FONT_* variables are
used, so move them into the SpectFrame class and create them in
the constructor.
Also, FONT_NORMAL is not used so it has been removed.
---
src/espeakedit.cpp | 4 ----
src/main.h | 4 ----
src/spect.cpp | 3 +++
src/spect.h | 3 +++
4 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/espeakedit.cpp b/src/espeakedit.cpp
index 4980e41..ec261ce 100644
--- a/src/espeakedit.cpp
+++ b/src/espeakedit.cpp
@@ -96,10 +96,6 @@ int frame_x, frame_y, frame_w, frame_h;
int adding_page = 0; // fix for wxWidgets (2,8,7) bug, adding first page to a wxNotebook gives emptystring for GetPageTex() in Notebook_Page_Changed event.
-wxFont FONT_SMALL(8,wxSWISS,wxNORMAL,wxNORMAL);
-wxFont FONT_MEDIUM(9,wxSWISS,wxNORMAL,wxNORMAL);
-wxFont FONT_NORMAL(10,wxSWISS,wxNORMAL,wxNORMAL);
-
IMPLEMENT_APP(MyApp)
wxString AppName = _T("espeakedit");
diff --git a/src/main.h b/src/main.h
index 72542b7..7efb7cb 100644
--- a/src/main.h
+++ b/src/main.h
@@ -111,10 +111,6 @@ extern wchar_t ipa1[256];
-extern wxFont FONT_SMALL;
-extern wxFont FONT_MEDIUM;
-extern wxFont FONT_NORMAL;
-
enum {
MENU_QUIT = 1,
MENU_SPECTRUM,
diff --git a/src/spect.cpp b/src/spect.cpp
index 76afd29..60e2709 100644
--- a/src/spect.cpp
+++ b/src/spect.cpp
@@ -1,6 +1,7 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
+ * Copyright (C) 2013 by Reece H. Dunn *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -92,6 +93,8 @@ float SpectTilt(int value, int freq)
SpectFrame::SpectFrame(SpectFrame *copy)
+ : FONT_SMALL(8,wxSWISS,wxNORMAL,wxNORMAL)
+ , FONT_MEDIUM(9,wxSWISS,wxNORMAL,wxNORMAL)
{//=====================================
int ix;
diff --git a/src/spect.h b/src/spect.h
index ed36586..398455e 100644
--- a/src/spect.h
+++ b/src/spect.h
@@ -1,6 +1,7 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
+ * Copyright (C) 2013 by Reece H. Dunn *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -171,6 +172,8 @@ public:
private:
void DrawPeaks(wxDC *dc, int offy, int frame_width, int seq_amplitude, double scalex);
+ wxFont FONT_SMALL;
+ wxFont FONT_MEDIUM;
};
class SpectSeq
--
1.8.4.2
Reply to: