commit 072cc4482b20626b4b5ae46ae7d50e899c7a7924
parent ba7783b0dbd07023646aa5402627443b1b331dc4
Author: falkTX <falktx@falktx.com>
Date: Thu, 27 Jul 2023 11:17:26 +0200
Better handling of pugl world creation failures
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/dgl/src/ApplicationPrivateData.cpp b/dgl/src/ApplicationPrivateData.cpp
@@ -160,17 +160,15 @@ void Application::PrivateData::quit()
double Application::PrivateData::getTime() const
{
- DISTRHO_SAFE_ASSERT_RETURN(world != nullptr, 0.0);
-
- return puglGetTime(world);
+ return world != nullptr ? puglGetTime(world) : 0.0;
}
void Application::PrivateData::setClassName(const char* const name)
{
- DISTRHO_SAFE_ASSERT_RETURN(world != nullptr,);
DISTRHO_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0',);
- puglSetClassName(world, name);
+ if (world != nullptr)
+ puglSetClassName(world, name);
}
// --------------------------------------------------------------------------------------------------------------------
diff --git a/dgl/src/WindowPrivateData.cpp b/dgl/src/WindowPrivateData.cpp
@@ -66,7 +66,8 @@ static double getScaleFactorFromParent(const PuglView* const view)
static PuglView* puglNewViewWithTransientParent(PuglWorld* const world, PuglView* const transientParentView)
{
- DISTRHO_SAFE_ASSERT_RETURN(world != nullptr, nullptr);
+ if (world == nullptr)
+ return nullptr;
if (PuglView* const view = puglNewView(world))
{
@@ -79,7 +80,8 @@ static PuglView* puglNewViewWithTransientParent(PuglWorld* const world, PuglView
static PuglView* puglNewViewWithParentWindow(PuglWorld* const world, const uintptr_t parentWindowHandle)
{
- DISTRHO_SAFE_ASSERT_RETURN(world != nullptr, nullptr);
+ if (world == nullptr)
+ return nullptr;
if (PuglView* const view = puglNewView(world))
{
@@ -433,7 +435,7 @@ void Window::PrivateData::idleCallback()
bool Window::PrivateData::addIdleCallback(IdleCallback* const callback, const uint timerFrequencyInMs)
{
- if (ignoreIdleCallbacks)
+ if (ignoreIdleCallbacks || view == nullptr)
return false;
if (timerFrequencyInMs == 0)
@@ -447,7 +449,7 @@ bool Window::PrivateData::addIdleCallback(IdleCallback* const callback, const ui
bool Window::PrivateData::removeIdleCallback(IdleCallback* const callback)
{
- if (ignoreIdleCallbacks)
+ if (ignoreIdleCallbacks || view == nullptr)
return false;
if (std::find(appData->idleCallbacks.begin(),