summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-10-17 11:23:01 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-10-17 11:23:01 +0200
commit6299c6ef046ff3d845fc0fdefa96a2496fd4fdb1 (patch)
treeeac25ab242da396722ef579dcf2f291296e8b295
parentb49dd62df721b2d965c995e69340b085d3489bf6 (diff)
Fix GUI crash when running in thread mode and init wasn't done when show was called.
-rw-r--r--plugingui/plugingui.cc24
-rw-r--r--plugingui/plugingui.h1
2 files changed, 7 insertions, 18 deletions
diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc
index 4a2f4fa..5408334 100644
--- a/plugingui/plugingui.cc
+++ b/plugingui/plugingui.cc
@@ -172,7 +172,6 @@ PluginGUI::PluginGUI()
: MessageReceiver(MSGRCV_UI), sem("plugingui")
{
initialised = false;
- //printf("PluginGUI::PluginGUI() begin\n"); fflush(stdout);
windowClosedHandler = NULL;
changeMidimapHandler = NULL;
@@ -189,8 +188,6 @@ PluginGUI::PluginGUI()
#endif/*USE_THREAD*/
sem.wait();
-
- //printf("PluginGUI::PluginGUI() done\n"); fflush(stdout);
}
PluginGUI::~PluginGUI()
@@ -306,8 +303,6 @@ void PluginGUI::init()
{
DEBUG(gui, "init");
- //printf("init begin\n"); fflush(stdout);
-
config = new Config();
config->load();
@@ -472,16 +467,13 @@ void PluginGUI::init()
sem.post();
- //printf("init end\n"); fflush(stdout);
initialised = true;
}
void PluginGUI::show()
{
- while(!initialised) {
- //printf("Waiting for init to finish\n"); fflush(stdout);
- sleep(1);
- }
+ while(!initialised) usleep(10000);
+
if(!window) init();
window->show();
@@ -489,19 +481,15 @@ void PluginGUI::show()
void PluginGUI::hide()
{
- while(!initialised) {
- //printf("Waiting for init to finish\n"); fflush(stdout);
- sleep(1);
- }
+ while(!initialised) usleep(10000);
+
if(window) window->hide();
}
void PluginGUI::processEvents()
{
- if(!initialised) {
- //printf("Not yet initialised\n"); fflush(stdout);
- return;
- }
+ if(!initialised) return;
+
if(closing) {
if(windowClosedHandler) windowClosedHandler(windowClosedPtr);
closing = false;
diff --git a/plugingui/plugingui.h b/plugingui/plugingui.h
index 36e8b1c..39643e1 100644
--- a/plugingui/plugingui.h
+++ b/plugingui/plugingui.h
@@ -93,6 +93,7 @@ private:
volatile bool running;
volatile bool closing;
volatile bool initialised;
+
Semaphore sem;
};