Browse Source

Cleanup

Signed-off-by: falkTX <falktx@falktx.com>
pull/452/head
falkTX 2 years ago
parent
commit
9bbb68604f
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 22 additions and 14 deletions
  1. +17
    -9
      dgl/src/ApplicationPrivateData.cpp
  2. +5
    -5
      dgl/src/WindowPrivateData.hpp

+ 17
- 9
dgl/src/ApplicationPrivateData.cpp View File

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

// --------------------------------------------------------------------------------------------------------------------
@@ -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()
@@ -82,8 +86,12 @@ Application::PrivateData::~PrivateData()
windows.clear();
idleCallbacks.clear();

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

// --------------------------------------------------------------------------------------------------------------------
@@ -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


+ 5
- 5
dgl/src/WindowPrivateData.hpp View File

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



Loading…
Cancel
Save