commit fc96e9fd894df36e45aaacac209ca7078ff0629d
parent ab236b8d7aa345345376265388e127f8e8febcf0
Author: falkTX <falktx@falktx.com>
Date: Tue, 5 Oct 2021 21:25:57 +0100
Fix wrong context on UI deletion, needed for macOS hosts using GL
Diffstat:
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/distrho/src/DistrhoUIInternal.hpp b/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/distrho/src/DistrhoUIPrivateData.hpp b/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
{