summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-10-16 19:14:00 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-10-16 19:14:00 +0200
commitb49dd62df721b2d965c995e69340b085d3489bf6 (patch)
treea5efb61686243dfa72c0c56c3007c8d874e729dd
parent6b1a30cc3d5e00bd210b27344fceb1c863b23ed6 (diff)
Quick and dirty fix for LV2 UI crash.
-rw-r--r--lv2/lv2_gui.cc14
-rw-r--r--plugingui/plugingui.cc22
-rw-r--r--plugingui/plugingui.h2
3 files changed, 35 insertions, 3 deletions
diff --git a/lv2/lv2_gui.cc b/lv2/lv2_gui.cc
index 7b56c5b..625c7f7 100644
--- a/lv2/lv2_gui.cc
+++ b/lv2/lv2_gui.cc
@@ -120,24 +120,31 @@ struct DG_GUI {
static void ui_run(struct lv2_external_ui * _this_)
{
+ //printf("ui_run begin\n"); fflush(stdout);
struct DG_GUI *dggui = (struct DG_GUI *)_this_;
dggui->gui->processEvents();
+ //printf("ui_run end\n"); fflush(stdout);
}
static void ui_show(struct lv2_external_ui * _this_)
{
+ //printf("ui_show begin\n"); fflush(stdout);
struct DG_GUI *dggui = (struct DG_GUI *)_this_;
dggui->gui->show();
+ //printf("ui_show end\n"); fflush(stdout);
}
static void ui_hide(struct lv2_external_ui * _this_)
{
+ //printf("ui_hide begin\n"); fflush(stdout);
struct DG_GUI *dggui = (struct DG_GUI *)_this_;
if(dggui->gui) dggui->gui->hide();
+ //printf("ui_hide end\n"); fflush(stdout);
}
static void closeHandler(void *ptr)
{
+ //printf("closeHandler begin\n"); fflush(stdout);
struct DG_GUI *gui = (struct DG_GUI *)ptr;
if(gui->ui_host_ptr && gui->ui_host_ptr->ui_closed) {
@@ -146,6 +153,7 @@ static void closeHandler(void *ptr)
delete gui->gui;
gui->gui = NULL;
+ //printf("closeHandler end\n"); fflush(stdout);
}
static LV2UI_Handle ui_instantiate(const struct _LV2UI_Descriptor * descriptor,
@@ -156,7 +164,7 @@ static LV2UI_Handle ui_instantiate(const struct _LV2UI_Descriptor * descriptor,
LV2UI_Widget * widget,
const LV2_Feature * const * features)
{
- printf("ui_instantiate\n");
+ //printf("ui_instantiate begin\n"); fflush(stdout);
struct DG_GUI* pt = new struct DG_GUI;
@@ -167,7 +175,7 @@ static LV2UI_Handle ui_instantiate(const struct _LV2UI_Descriptor * descriptor,
std::string uri = (*features)->URI;
void *data = (*features)->data;
- printf("DGUI: feature: %s\n", uri.c_str());
+ //printf("DGUI: feature: %s\n", uri.c_str());
if(uri == LV2_INSTANCE_ACCESS_URI) {
pt->instance_handle = data;
@@ -195,6 +203,8 @@ static LV2UI_Handle ui_instantiate(const struct _LV2UI_Descriptor * descriptor,
*widget = (LV2UI_Widget)pt;
+ //printf("ui_instantiate end\n"); fflush(stdout);
+
return pt;
}
diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc
index f345660..4a2f4fa 100644
--- a/plugingui/plugingui.cc
+++ b/plugingui/plugingui.cc
@@ -171,6 +171,9 @@ void closeClick(void *ptr)
PluginGUI::PluginGUI()
: MessageReceiver(MSGRCV_UI), sem("plugingui")
{
+ initialised = false;
+ //printf("PluginGUI::PluginGUI() begin\n"); fflush(stdout);
+
windowClosedHandler = NULL;
changeMidimapHandler = NULL;
@@ -186,6 +189,8 @@ PluginGUI::PluginGUI()
#endif/*USE_THREAD*/
sem.wait();
+
+ //printf("PluginGUI::PluginGUI() done\n"); fflush(stdout);
}
PluginGUI::~PluginGUI()
@@ -301,6 +306,8 @@ void PluginGUI::init()
{
DEBUG(gui, "init");
+ //printf("init begin\n"); fflush(stdout);
+
config = new Config();
config->load();
@@ -464,10 +471,17 @@ void PluginGUI::init()
window->show();
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);
+ }
if(!window) init();
window->show();
@@ -475,11 +489,19 @@ void PluginGUI::show()
void PluginGUI::hide()
{
+ while(!initialised) {
+ //printf("Waiting for init to finish\n"); fflush(stdout);
+ sleep(1);
+ }
if(window) window->hide();
}
void PluginGUI::processEvents()
{
+ if(!initialised) {
+ //printf("Not yet initialised\n"); fflush(stdout);
+ return;
+ }
if(closing) {
if(windowClosedHandler) windowClosedHandler(windowClosedPtr);
closing = false;
diff --git a/plugingui/plugingui.h b/plugingui/plugingui.h
index f94a062..36e8b1c 100644
--- a/plugingui/plugingui.h
+++ b/plugingui/plugingui.h
@@ -92,7 +92,7 @@ public:
private:
volatile bool running;
volatile bool closing;
-
+ volatile bool initialised;
Semaphore sem;
};