diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2014-10-17 11:22:14 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2014-10-17 11:22:14 +0200 |
commit | 29ec8552826f64bfa8cad01a433306886328c522 (patch) | |
tree | 6ff7c8c958001c23b1ad25920bddb9494410119b | |
parent | c7af1c332447e5fb25f37d4738458a5d7106a6fc (diff) |
Fix GUI crash when running in thread mode and init wasn't done when show was called.
-rw-r--r-- | plugingui/plugingui.cc | 10 | ||||
-rw-r--r-- | plugingui/plugingui.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc index f345660..5408334 100644 --- a/plugingui/plugingui.cc +++ b/plugingui/plugingui.cc @@ -171,6 +171,8 @@ void closeClick(void *ptr) PluginGUI::PluginGUI() : MessageReceiver(MSGRCV_UI), sem("plugingui") { + initialised = false; + windowClosedHandler = NULL; changeMidimapHandler = NULL; @@ -464,10 +466,14 @@ void PluginGUI::init() window->show(); sem.post(); + + initialised = true; } void PluginGUI::show() { + while(!initialised) usleep(10000); + if(!window) init(); window->show(); @@ -475,11 +481,15 @@ void PluginGUI::show() void PluginGUI::hide() { + while(!initialised) usleep(10000); + if(window) window->hide(); } void PluginGUI::processEvents() { + if(!initialised) return; + if(closing) { if(windowClosedHandler) windowClosedHandler(windowClosedPtr); closing = false; diff --git a/plugingui/plugingui.h b/plugingui/plugingui.h index f94a062..39643e1 100644 --- a/plugingui/plugingui.h +++ b/plugingui/plugingui.h @@ -92,6 +92,7 @@ public: private: volatile bool running; volatile bool closing; + volatile bool initialised; Semaphore sem; }; |