Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Better handling of pugl world creation failures
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Jul 27, 2023
1 parent ba7783b commit 072cc44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 3 additions & 5 deletions dgl/src/ApplicationPrivateData.cpp
Expand Up @@ -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);
}

// --------------------------------------------------------------------------------------------------------------------
Expand Down
10 changes: 6 additions & 4 deletions dgl/src/WindowPrivateData.cpp
Expand Up @@ -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))
{
Expand All @@ -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))
{
Expand Down Expand Up @@ -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)
Expand All @@ -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(),
Expand Down

0 comments on commit 072cc44

Please sign in to comment.