diff --git a/dpf/distrho/src/DistrhoUIInternal.hpp b/dpf/distrho/src/DistrhoUIInternal.hpp index 64148f8..ed67a6c 100644 --- a/dpf/distrho/src/DistrhoUIInternal.hpp +++ b/dpf/distrho/src/DistrhoUIInternal.hpp @@ -108,6 +108,9 @@ public: ~UIExporter() { quit(); +#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI + uiData->window->enterContextForDeletion(); +#endif delete ui; delete uiData; } diff --git a/dpf/distrho/src/DistrhoUIPrivateData.hpp b/dpf/distrho/src/DistrhoUIPrivateData.hpp index 93a8a89..c3be4dc 100644 --- a/dpf/distrho/src/DistrhoUIPrivateData.hpp +++ b/dpf/distrho/src/DistrhoUIPrivateData.hpp @@ -183,10 +183,18 @@ public: if (pData->view == nullptr) return; + // this is called just before creating UI, ensuring proper context to it if (pData->initPost()) puglBackendEnter(pData->view); } + ~PluginWindow() + { + if (pData->view != nullptr) + puglBackendLeave(pData->view); + } + + // called after creating UI, restoring proper context void leaveContext() { if (pData->view == nullptr) @@ -199,11 +207,19 @@ public: puglBackendLeave(pData->view); } + // used for temporary windows (VST2/3 get size without active/visible view) void setIgnoreIdleCallbacks(const bool ignore = true) { pData->ignoreIdleCallbacks = ignore; } + // called right before deleting UI, ensuring correct context + void enterContextForDeletion() + { + if (pData->view != nullptr) + puglBackendEnter(pData->view); + } + protected: void onFocus(const bool focus, const DGL_NAMESPACE::CrossingMode mode) override {