summarylogtreecommitdiffstats
path: root/gdl-1.0.1-fix-python-wxGetApp.patch
blob: 0dc1f3c8791a4eba401b4412e817ecb5f46f5e5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
From 2a6d346d496cf5d8a3bed2737c8028438e2df99a Mon Sep 17 00:00:00 2001
From: GillesDuvert <gilles.duvert@free.fr>
Date: Tue, 21 Feb 2023 00:35:50 +0100
Subject: [PATCH] displace equivalent of wxIMPLEMENT_APP_NO_MAIN in
 gdlwidget.cpp to enable Python module to use GDL.so

---
 src/gdl.cpp       | 11 ++++++-----
 src/gdlwidget.cpp | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/src/gdl.cpp b/src/gdl.cpp
index 445145331..4b01f9d24 100644
--- a/src/gdl.cpp
+++ b/src/gdl.cpp
@@ -66,11 +66,12 @@
 //initialize wxWidgets system:  create an instance of wxAppGDL
 #ifdef HAVE_LIBWXWIDGETS
 #include "gdlwidget.hpp"
-#ifndef __WXMAC__ 
-wxIMPLEMENT_APP_NO_MAIN( wxAppGDL);
-#else
-wxIMPLEMENT_APP_NO_MAIN( wxApp);
-#endif
+//displaced in gdlwidget.cpp to make wxGetApp() available under Python (in GDL.so)
+//#ifndef __WXMAC__ 
+//wxIMPLEMENT_APP_NO_MAIN( wxAppGDL);
+//#else
+//wxIMPLEMENT_APP_NO_MAIN( wxApp);
+//#endif
 #endif
 
 using namespace std;
diff --git a/src/gdlwidget.cpp b/src/gdlwidget.cpp
index 48abbf23a..b589d4868 100644
--- a/src/gdlwidget.cpp
+++ b/src/gdlwidget.cpp
@@ -196,6 +196,24 @@ bool GDLWidget::handlersOk=false;
 wxFont GDLWidget::defaultFont=wxNullFont; //the font defined by widget_control,default_font.
 wxFont GDLWidget::systemFont=wxNullFont;  //the initial system font. This to behave as IDL
 
+  //initialize wxWidgets system:  create an instance of wxAppGDL here, not at Main (
+#ifndef __WXMAC__ 
+    wxAppGDL& wxGetApp() { return *static_cast<wxAppGDL*>(wxApp::GetInstance()); }   
+    wxAppConsole *wxCreateApp() 
+    { 
+        wxAppConsole::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE,"GDL");
+        return new wxAppGDL;
+    }
+    wxAppInitializer  wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp);
+#else
+    wxApp& wxGetApp() { return *static_cast<wxApp*>(wxApp::GetInstance()); }   
+    wxAppConsole *wxCreateApp() 
+    { 
+        wxAppConsole::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE,"GDL");
+        return new wxApp;
+    }
+    wxAppInitializer  wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp);
+#endif
 
 void GDLEventQueue::Purge()
 {