From 1bb38288ca34f47d958592c54f5556c2b085ba70 Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 26 Apr 2013 06:45:20 +0100 Subject: [PATCH] VST: Re-use last known UI size if reopen fails, fixes #28 --- source/backend/plugin/VstPlugin.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/source/backend/plugin/VstPlugin.cpp b/source/backend/plugin/VstPlugin.cpp index 4a188f9b0..06a6749da 100644 --- a/source/backend/plugin/VstPlugin.cpp +++ b/source/backend/plugin/VstPlugin.cpp @@ -412,8 +412,12 @@ public: const int16_t width(vstRect->right - vstRect->left); const int16_t height(vstRect->bottom - vstRect->top); - if (width > 0 && height > 0) + CARLA_SAFE_ASSERT_INT2(width > 1 && height > 1, width, height); + + if (width > 1 && height > 1) kData->gui->setSize(width, height); + else if (fGui.lastWidth > 1 && fGui.lastHeight > 1) + kData->gui->setSize(fGui.lastWidth, fGui.lastHeight); } kData->gui->setWindowTitle(QString("%1 (GUI)").arg((const char*)fName)); @@ -435,6 +439,9 @@ public: } else { + fGui.lastWidth = kData->gui->width(); + fGui.lastHeight = kData->gui->height(); + dispatcher(effEditClose, 0, 0, nullptr, 0.0f); if (kData->gui != nullptr) @@ -1942,7 +1949,9 @@ protected: case audioMasterSizeWindow: if (kData->gui != nullptr) { - kData->gui->setSize(index, value); + CARLA_SAFE_ASSERT(fGui.isVisible); + if (fGui.isVisible) + kData->gui->setSize(index, value); ret = 1; } break; @@ -2312,10 +2321,14 @@ private: struct GuiInfo { bool isOsc; bool isVisible; + int lastWidth; + int lastHeight; GuiInfo() : isOsc(false), - isVisible(false) {} + isVisible(false), + lastWidth(0), + lastHeight(0) {} } fGui; bool fIsProcessing;