Package: megaglest / 3.9.1-3

wxWidgets-assertions.patch Patch series | download
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
From: Markus Koschany <apo@gambaru.de>
Date: Mon, 1 Dec 2014 19:12:28 +0100
Subject: wxWidgets assertions

Fix wxWidgets assertions in megaglest_editor and megaglest_g3dviewer.

Bug: https://bugs.debian.org/768572
Forwarded: not-needed already fixed
---
 source/g3d_viewer/main.cpp                   | 23 +++++++++++++++--------
 source/g3d_viewer/main.h                     |  1 +
 source/glest_map_editor/main.cpp             | 20 +++++++++++++++-----
 source/shared_lib/sources/graphics/model.cpp |  2 +-
 4 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp
index 1276f73..a6cdb4a 100644
--- a/source/g3d_viewer/main.cpp
+++ b/source/g3d_viewer/main.cpp
@@ -480,12 +480,15 @@ void MainWindow::setupTimer() {
 }
 
 void MainWindow::setupStartupSettings() {
-	 GLuint err = glewInit();
-	 if (GLEW_OK != err) {
+
+	glCanvas->setCurrentGLContext();
+
+	GLuint err = glewInit();
+	if (GLEW_OK != err) {
 		fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err));
 		//return 1;
 		throw std::runtime_error((char *)glewGetErrorString(err));
-	 }
+	}
 
 	renderer= Renderer::getInstance();
 
@@ -567,7 +570,7 @@ MainWindow::~MainWindow(){
 void MainWindow::init() {
 
 #if wxCHECK_VERSION(2, 9, 3)
-	glCanvas->setCurrentGLContext();
+	//glCanvas->setCurrentGLContext();
 	//printf("setcurrent #1\n");
 #elif wxCHECK_VERSION(2, 9, 1)
 
@@ -585,7 +588,9 @@ void MainWindow::init() {
 void MainWindow::onPaint(wxPaintEvent &event) {
 	if(!IsShown()) return;
 	
-#if wxCHECK_VERSION(2, 9, 3)
+#if wxCHECK_VERSION(2, 9, 4)
+	//glCanvas->setCurrentGLContext();
+#elif wxCHECK_VERSION(2, 9, 3)
 
 #elif wxCHECK_VERSION(2, 9, 1)
 	glCanvas->setCurrentGLContext();
@@ -756,8 +761,8 @@ void MainWindow::onClose(wxCloseEvent &event){
 	delete timer;
 	timer = NULL;
 
-	delete model;
-	model = NULL;
+	//delete model;
+	//model = NULL;
 
 	delete renderer;
 	renderer = NULL;
@@ -2027,7 +2032,7 @@ GlCanvas::GlCanvas(MainWindow *	mainWindow, int *args)
 }
 
 GlCanvas::~GlCanvas() {
-	delete this->context;
+	if(this->context) delete this->context;
 	this->context = NULL;
 }
 
@@ -2037,11 +2042,13 @@ void GlCanvas::setCurrentGLContext() {
 #if wxCHECK_VERSION(2, 9, 1)
 	if(this->context == NULL) {
 		this->context = new wxGLContext(this);
+		//printf("Set ctx [%p]\n",this->context);
 	}
 #endif
 	//printf("Set ctx [%p]\n",this->context);
 	if(this->context) {
 		wxGLCanvas::SetCurrent(*this->context);
+		//printf("Set ctx2 [%p]\n",this->context);
 	}
 #else
 	this->SetCurrent();
diff --git a/source/g3d_viewer/main.h b/source/g3d_viewer/main.h
index d22020d..e8142b8 100644
--- a/source/g3d_viewer/main.h
+++ b/source/g3d_viewer/main.h
@@ -201,6 +201,7 @@ public:
 	void onKeyDown(wxKeyEvent &event);
 	void setCurrentGLContext();
 
+	wxGLContext * getCtx() { return context; }
 private:
 	MainWindow *mainWindow;
 	wxGLContext *context;
diff --git a/source/glest_map_editor/main.cpp b/source/glest_map_editor/main.cpp
index 9b2dc57..e9c9b7c 100644
--- a/source/glest_map_editor/main.cpp
+++ b/source/glest_map_editor/main.cpp
@@ -138,12 +138,12 @@ END_EVENT_TABLE()
 
 void MainWindow::init(string fname) {
 #if wxCHECK_VERSION(2, 9, 3)
-	glCanvas->setCurrentGLContext();
+	//glCanvas->setCurrentGLContext();
 	//printf("setcurrent #1\n");
 #elif wxCHECK_VERSION(2, 9, 1)
 
 #else
-	glCanvas->SetCurrent();
+	//glCanvas->SetCurrent();
 	//printf("setcurrent #2\n");
 #endif
 
@@ -638,11 +638,17 @@ void MainWindow::onPaint(wxPaintEvent &event) {
 		return;
 	}
 
-#if wxCHECK_VERSION(2, 9, 3)
+//#if wxCHECK_VERSION(2, 9, 3)
 
-#elif wxCHECK_VERSION(2, 9, 1)
+//#elif wxCHECK_VERSION(2, 9, 1)
+//	glCanvas->setCurrentGLContext();
+//#endif
+
+	//static bool contextSet = false;
+	//if(contextSet == false) {
+	//	contextSet = true;
 	glCanvas->setCurrentGLContext();
-#endif
+	//}
 
 	if(lastPaintEvent.getMillis() < 30) {
 		sleep(1);
@@ -1579,6 +1585,10 @@ bool App::OnInit() {
 	SystemFlags::VERBOSE_MODE_ENABLED  = false;
 	SystemFlags::ENABLE_THREADED_LOGGING = false;
 
+#if defined(wxMAJOR_VERSION) && defined(wxMINOR_VERSION) && defined(wxRELEASE_NUMBER) && defined(wxSUBRELEASE_NUMBER)
+	printf("Using wxWidgets version [%d.%d.%d.%d]\n",wxMAJOR_VERSION,wxMINOR_VERSION,wxRELEASE_NUMBER,wxSUBRELEASE_NUMBER);
+#endif
+
 	string fileparam;
 	if(argc==2){
 		if(argv[1][0]=='-') {   // any flag gives help and exits program.
diff --git a/source/shared_lib/sources/graphics/model.cpp b/source/shared_lib/sources/graphics/model.cpp
index e3bf3cf..84becdb 100644
--- a/source/shared_lib/sources/graphics/model.cpp
+++ b/source/shared_lib/sources/graphics/model.cpp
@@ -1099,7 +1099,7 @@ Model::Model() {
 }
 
 Model::~Model() {
-	delete [] meshes;
+	if(meshes) delete [] meshes;
 	meshes = NULL;
 }