Browse Source

Better handling of pugl world creation failures

Signed-off-by: falkTX <falktx@falktx.com>
pull/401/merge
falkTX 1 year ago
parent
commit
072cc4482b
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 9 additions and 9 deletions
  1. +3
    -5
      dgl/src/ApplicationPrivateData.cpp
  2. +6
    -4
      dgl/src/WindowPrivateData.cpp

+ 3
- 5
dgl/src/ApplicationPrivateData.cpp View File

@@ -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);
}

// --------------------------------------------------------------------------------------------------------------------


+ 6
- 4
dgl/src/WindowPrivateData.cpp View File

@@ -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(),


Loading…
Cancel
Save