DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit b9f36d2300111b1e0b500cb2777d58599ac17ce1
parent 3370cdb78d86398953cdb3c6a680db20db487b3e
Author: falkTX <falktx@falktx.com>
Date:   Fri, 27 Aug 2021 22:18:31 +0000

Allow puglRealize to fail

Diffstat:
Mdgl/src/WindowPrivateData.cpp | 15+++++++++++----
Mdgl/src/WindowPrivateData.hpp | 4++--
Mdistrho/src/DistrhoUIPrivateData.hpp | 4++--
3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/dgl/src/WindowPrivateData.cpp b/dgl/src/WindowPrivateData.cpp @@ -225,7 +225,7 @@ void Window::PrivateData::initPre(const uint width, const uint height, const boo if (view == nullptr) { - DGL_DBG("Failed to create Pugl view, everything will fail!\n"); + d_stderr2("Failed to create Pugl view, everything will fail!"); return; } @@ -247,13 +247,18 @@ void Window::PrivateData::initPre(const uint width, const uint height, const boo puglSetEventFunc(view, puglEventCallback); } -void Window::PrivateData::initPost() +bool Window::PrivateData::initPost() { if (view == nullptr) - return; + return false; // create view now, as a few methods we allow devs to use require it - puglRealize(view); + if (puglRealize(view) != PUGL_SUCCESS) + { + view = nullptr; + d_stderr2("Failed to realize Pugl view, everything will fail!"); + return false; + } if (isEmbed) { @@ -264,6 +269,8 @@ void Window::PrivateData::initPost() // give context back to transient parent window if (transientParentView != nullptr) puglBackendEnter(transientParentView); + + return true; } // ----------------------------------------------------------------------- diff --git a/dgl/src/WindowPrivateData.hpp b/dgl/src/WindowPrivateData.hpp @@ -42,7 +42,7 @@ struct Window::PrivateData : IdleCallback { Window* const self; /** Pugl view instance. */ - PuglView* const view; + PuglView* view; /** Pugl view instance of the transient parent window. */ PuglView* const transientParentView; @@ -126,7 +126,7 @@ struct Window::PrivateData : IdleCallback { /** Helper initialization function called at the end of all this class constructors. */ void initPre(uint width, uint height, bool resizable); /** Helper initialization function called on the Window constructor after we are done. */ - void initPost(); + bool initPost(); /** Hide window and notify application of a window close event. * Does nothing if window is embed (that is, not standalone). diff --git a/distrho/src/DistrhoUIPrivateData.hpp b/distrho/src/DistrhoUIPrivateData.hpp @@ -171,8 +171,8 @@ public: if (pData->view == nullptr) return; - pData->initPost(); - puglBackendEnter(pData->view); + if (pData->initPost()) + puglBackendEnter(pData->view); } void leaveContext()