From 9bbb68604fc311852515f5bbf196136c5410b005 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 10 Feb 2024 13:18:57 +0100 Subject: [PATCH] Cleanup Signed-off-by: falkTX --- dgl/src/ApplicationPrivateData.cpp | 26 +++++++++++++++++--------- dgl/src/WindowPrivateData.hpp | 10 +++++----- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/dgl/src/ApplicationPrivateData.cpp b/dgl/src/ApplicationPrivateData.cpp index deadd246..ccdcbfb1 100644 --- a/dgl/src/ApplicationPrivateData.cpp +++ b/dgl/src/ApplicationPrivateData.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2023 Filipe Coelho + * Copyright (C) 2012-2024 Filipe Coelho * * 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::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 diff --git a/dgl/src/WindowPrivateData.hpp b/dgl/src/WindowPrivateData.hpp index d5c3cbd8..ea7feb2a 100644 --- a/dgl/src/WindowPrivateData.hpp +++ b/dgl/src/WindowPrivateData.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2022 Filipe Coelho + * Copyright (C) 2012-2024 Filipe Coelho * * 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);