Browse Source

Don't close LV2 UIs during current idle, wait for the next one

Properly fixes closing of rncbc plugins
tags/1.9.6
falkTX 10 years ago
parent
commit
c3aba3919b
1 changed files with 23 additions and 44 deletions
  1. +23
    -44
      source/backend/plugin/CarlaPluginLV2.cpp

+ 23
- 44
source/backend/plugin/CarlaPluginLV2.cpp View File

@@ -507,6 +507,7 @@ public:
fCvOutBuffers(nullptr), fCvOutBuffers(nullptr),
fParamBuffers(nullptr), fParamBuffers(nullptr),
fCanInit2(true), fCanInit2(true),
fNeedsUiClose(false),
fLatencyChanged(false), fLatencyChanged(false),
fLatencyIndex(-1), fLatencyIndex(-1),
fAtomBufferIn(), fAtomBufferIn(),
@@ -1305,7 +1306,7 @@ public:
if (fUI.handle == nullptr) if (fUI.handle == nullptr)
{ {
#ifndef LV2_UIS_ONLY_BRIDGES #ifndef LV2_UIS_ONLY_BRIDGES
if (fUI.type == UI::TYPE_EMBED)
if (fUI.type == UI::TYPE_EMBED && fUI.window == nullptr)
{ {
const char* msg = nullptr; const char* msg = nullptr;


@@ -1353,12 +1354,11 @@ public:
return pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, -1, 0, 0.0f, msg); return pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, -1, 0, 0.0f, msg);


if (fUI.window != nullptr) if (fUI.window != nullptr)
{
fUI.window->setTitle(fLv2Options.windowTitle);
fFeatures[kFeatureIdUiParent]->data = fUI.window->getPtr(); fFeatures[kFeatureIdUiParent]->data = fUI.window->getPtr();
}
} }
#endif #endif
if (fUI.window != nullptr)
fUI.window->setTitle(fLv2Options.windowTitle);


fUI.widget = nullptr; fUI.widget = nullptr;
fUI.handle = fUI.descriptor->instantiate(fUI.descriptor, fRdfDescriptor->URI, fUI.rdfDescriptor->Bundle, fUI.handle = fUI.descriptor->instantiate(fUI.descriptor, fRdfDescriptor->URI, fUI.rdfDescriptor->Bundle,
@@ -1520,7 +1520,13 @@ public:
// TODO - detect if ui-bridge crashed // TODO - detect if ui-bridge crashed
} }


if (fUI.handle != nullptr && fUI.descriptor != nullptr)
if (fNeedsUiClose)
{
fNeedsUiClose = false;
showCustomUI(false);
pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, 0, 0, 0.0f, nullptr);
}
else if (fUI.handle != nullptr && fUI.descriptor != nullptr)
{ {
if (fUI.type == UI::TYPE_EXTERNAL && fUI.widget != nullptr) if (fUI.type == UI::TYPE_EXTERNAL && fUI.widget != nullptr)
LV2_EXTERNAL_UI_RUN((LV2_External_UI_Widget*)fUI.widget); LV2_EXTERNAL_UI_RUN((LV2_External_UI_Widget*)fUI.widget);
@@ -1528,12 +1534,11 @@ public:
else if (fUI.type == UI::TYPE_EMBED && fUI.window != nullptr) else if (fUI.type == UI::TYPE_EMBED && fUI.window != nullptr)
fUI.window->idle(); fUI.window->idle();


// note: UI might have been closed by ext-ui or window idle
if (fUI.type != UI::TYPE_EXTERNAL && fUI.handle != nullptr && fExt.uiidle != nullptr && fExt.uiidle->idle(fUI.handle) != 0)
{
showCustomUI(false);
pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, 0, 0, 0.0f, nullptr);
}
// note: UI might have been closed by window idle
if (fNeedsUiClose)
pass();
else if (fUI.handle != nullptr && fExt.uiidle != nullptr && fExt.uiidle->idle(fUI.handle) != 0)
fNeedsUiClose = true;
#endif #endif
} }


@@ -4458,14 +4463,7 @@ public:
CARLA_SAFE_ASSERT_RETURN(fUI.type == UI::TYPE_EXTERNAL,); CARLA_SAFE_ASSERT_RETURN(fUI.type == UI::TYPE_EXTERNAL,);
carla_debug("CarlaPluginLV2::handleExternalUIClosed()"); carla_debug("CarlaPluginLV2::handleExternalUIClosed()");


pData->transientTryCounter = 0;

if (fUI.handle != nullptr && fUI.descriptor != nullptr && fUI.descriptor->cleanup != nullptr)
fUI.descriptor->cleanup(fUI.handle);

fUI.handle = nullptr;
fUI.widget = nullptr;
pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, 0, 0, 0.0f, nullptr);
fNeedsUiClose = true;
} }


void handlePluginUIClosed() override void handlePluginUIClosed() override
@@ -4474,16 +4472,7 @@ public:
CARLA_SAFE_ASSERT_RETURN(fUI.window != nullptr,); CARLA_SAFE_ASSERT_RETURN(fUI.window != nullptr,);
carla_debug("CarlaPluginLV2::handlePluginUIClosed()"); carla_debug("CarlaPluginLV2::handlePluginUIClosed()");


pData->transientTryCounter = 0;

fUI.window->hide();

if (fUI.handle != nullptr && fUI.descriptor != nullptr && fUI.descriptor->cleanup != nullptr)
fUI.descriptor->cleanup(fUI.handle);

fUI.handle = nullptr;
fUI.widget = nullptr;
pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, 0, 0, 0.0f, nullptr);
fNeedsUiClose = true;
} }


void handlePluginUIResized(const uint width, const uint height) override void handlePluginUIResized(const uint width, const uint height) override
@@ -5109,12 +5098,6 @@ public:
} }
} }


if (fRdfDescriptor->Author != nullptr && std::strcmp(fRdfDescriptor->Author, "rncbc aka. Rui Nuno Capela") == 0)
{
eExt = -1;
iExt = -1;
}

if (eQt4 >= 0) if (eQt4 >= 0)
iFinal = eQt4; iFinal = eQt4;
else if (eQt5 >= 0) else if (eQt5 >= 0)
@@ -5165,15 +5148,6 @@ public:
{ {
LV2_RDF_UI* const ui(&fRdfDescriptor->UIs[i]); LV2_RDF_UI* const ui(&fRdfDescriptor->UIs[i]);


if (std::strcmp(ui->URI, "http://drumkv1.sourceforge.net/lv2#ui") == 0 ||
std::strcmp(ui->URI, "http://samplv1.sourceforge.net/lv2#ui") == 0 ||
std::strcmp(ui->URI, "http://synthv1.sourceforge.net/lv2#ui") == 0 )
{
iFinal = static_cast<int>(i);
hasShowInterface = true;
break;
}

for (uint32_t j=0; j < ui->ExtensionCount; ++j) for (uint32_t j=0; j < ui->ExtensionCount; ++j)
{ {
CARLA_SAFE_ASSERT_CONTINUE(ui->Extensions[j] != nullptr); CARLA_SAFE_ASSERT_CONTINUE(ui->Extensions[j] != nullptr);
@@ -5460,6 +5434,10 @@ public:


if (fExt.uiprograms != nullptr && fExt.uiprograms->select_program == nullptr) if (fExt.uiprograms != nullptr && fExt.uiprograms->select_program == nullptr)
fExt.uiprograms = nullptr; fExt.uiprograms = nullptr;

// don't use uiidle if external
if (fUI.type == UI::TYPE_EXTERNAL)
fExt.uiidle = nullptr;
} }


// ------------------------------------------------------------------- // -------------------------------------------------------------------
@@ -5511,6 +5489,7 @@ private:
float* fParamBuffers; float* fParamBuffers;


bool fCanInit2; // some plugins don't like 2 instances bool fCanInit2; // some plugins don't like 2 instances
bool fNeedsUiClose;
bool fLatencyChanged; bool fLatencyChanged;
int32_t fLatencyIndex; // -1 if invalid int32_t fLatencyIndex; // -1 if invalid




Loading…
Cancel
Save