Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Feb 10, 2024
1 parent c77010d commit 9bbb686
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
26 changes: 17 additions & 9 deletions dgl/src/ApplicationPrivateData.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2023 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
Expand All @@ -27,20 +27,20 @@ typedef std::list<DGL_NAMESPACE::Window*>::reverse_iterator WindowListReverseIte

static d_ThreadHandle getCurrentThreadHandle() noexcept
{
#ifdef DISTRHO_OS_WINDOWS
#ifdef DISTRHO_OS_WINDOWS
return GetCurrentThread();
#else
#else
return pthread_self();
#endif
#endif
}

static bool isThisTheMainThread(const d_ThreadHandle mainThreadHandle) noexcept
{
#ifdef DISTRHO_OS_WINDOWS
#ifdef DISTRHO_OS_WINDOWS
return GetCurrentThread() == mainThreadHandle; // IsGUIThread ?
#else
#else
return pthread_equal(getCurrentThreadHandle(), mainThreadHandle) != 0;
#endif
#endif
}

// --------------------------------------------------------------------------------------------------------------------
Expand All @@ -66,12 +66,16 @@ Application::PrivateData::PrivateData(const bool standalone)
{
DISTRHO_SAFE_ASSERT_RETURN(world != nullptr,);

#ifdef DGL_USING_SDL
SDL_Init(SDL_INIT_EVENTS|SDL_INIT_TIMER|SDL_INIT_VIDEO);
#else
puglSetWorldHandle(world, this);
#ifdef __EMSCRIPTEN__
puglSetWorldString(world, PUGL_CLASS_NAME, "canvas");
#else
puglSetWorldString(world, PUGL_CLASS_NAME, DISTRHO_MACRO_AS_STRING(DGL_NAMESPACE));
#endif
#endif
}

Application::PrivateData::~PrivateData()
Expand All @@ -82,8 +86,12 @@ Application::PrivateData::~PrivateData()
windows.clear();
idleCallbacks.clear();

#ifdef DGL_USING_SDL
SDL_Quit();
#else
if (world != nullptr)
puglFreeWorld(world);
#endif
}

// --------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -149,13 +157,13 @@ void Application::PrivateData::quit()

isQuitting = true;

#ifndef DPF_TEST_APPLICATION_CPP
#ifndef DPF_TEST_APPLICATION_CPP
for (WindowListReverseIterator rit = windows.rbegin(), rite = windows.rend(); rit != rite; ++rit)
{
DGL_NAMESPACE::Window* const window(*rit);
window->close();
}
#endif
#endif
}

double Application::PrivateData::getTime() const
Expand Down
10 changes: 5 additions & 5 deletions dgl/src/WindowPrivateData.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
Expand Down Expand Up @@ -87,10 +87,10 @@ struct Window::PrivateData : IdleCallback {
/** Render to a picture file when non-null, automatically free+unset after saving. */
char* filenameToRenderInto;

#ifndef DGL_FILE_BROWSER_DISABLED
#ifndef DGL_FILE_BROWSER_DISABLED
/** Handle for file browser dialog operations. */
DGL_NAMESPACE::FileBrowserHandle fileBrowserHandle;
#endif
#endif

/** Modal window setup. */
struct Modal {
Expand Down Expand Up @@ -164,10 +164,10 @@ struct Window::PrivateData : IdleCallback {
bool addIdleCallback(IdleCallback* callback, uint timerFrequencyInMs);
bool removeIdleCallback(IdleCallback* callback);

#ifndef DGL_FILE_BROWSER_DISABLED
#ifndef DGL_FILE_BROWSER_DISABLED
// file handling
bool openFileBrowser(const DGL_NAMESPACE::FileBrowserOptions& options);
#endif
#endif

static void renderToPicture(const char* filename, const GraphicsContext& context, uint width, uint height);

Expand Down

0 comments on commit 9bbb686

Please sign in to comment.