From 8ff2c24e8bf7433da909051accb9264c28f240ff Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 30 Nov 2022 17:11:52 +0100 Subject: [PATCH] Ensure file provider class is correctly deallocated and cleanup routines are run Signed-off-by: Claudio Cambra --- src/gui/application.cpp | 6 +++++- src/gui/application.h | 10 +++++++++- src/gui/macOS/fileproviderinterface.h | 4 ++++ src/gui/main.cpp | 5 ----- 4 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 src/gui/macOS/fileproviderinterface.h diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 767b5fc34..2ab170c58 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -51,6 +51,8 @@ #if defined(Q_OS_WIN) #include +#elif defined(Q_OS_MACOS) +#include "macOS/fileprovider.h" #endif #if defined(WITH_CRASHREPORTER) @@ -371,8 +373,10 @@ Application::Application(int &argc, char **argv) } _folderManager.reset(new FolderMan); -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) _shellExtensionsServer.reset(new ShellExtensionsServer); +#elif defined(Q_OS_MACOS) + _fileProvider.reset(Mac::FileProvider::instance()); #endif connect(this, &SharedTools::QtSingleApplication::messageReceived, this, &Application::slotParseMessage); diff --git a/src/gui/application.h b/src/gui/application.h index 9b6bad9eb..664dae6a1 100644 --- a/src/gui/application.h +++ b/src/gui/application.h @@ -49,6 +49,12 @@ class Folder; class ShellExtensionsServer; class SslErrorDialog; +#ifdef Q_OS_MACOS +namespace Mac { +class FileProvider; +} +#endif + /** * @brief The Application class * @ingroup gui @@ -152,8 +158,10 @@ private: QScopedPointer _crashHandler; #endif QScopedPointer _folderManager; -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) QScopedPointer _shellExtensionsServer; +#elif defined(Q_OS_MACOS) + QScopedPointer _fileProvider; #endif }; diff --git a/src/gui/macOS/fileproviderinterface.h b/src/gui/macOS/fileproviderinterface.h new file mode 100644 index 000000000..fe722ae04 --- /dev/null +++ b/src/gui/macOS/fileproviderinterface.h @@ -0,0 +1,4 @@ +#ifndef FILEPROVIDERINTERFACE_H +#define FILEPROVIDERINTERFACE_H + +#endif // FILEPROVIDERINTERFACE_H diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 8542993c9..40af80ac0 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -22,10 +22,6 @@ #include #endif -#ifdef Q_OS_MACOS -#include "macOS/fileprovider.h" -#endif - #include "application.h" #include "cocoainitializer.h" #include "theme.h" @@ -78,7 +74,6 @@ int main(int argc, char **argv) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); #ifdef Q_OS_MAC Mac::CocoaInitializer cocoaInit; // RIIA - const auto fileProvider = OCC::Mac::FileProvider::instance(); #endif auto surfaceFormat = QSurfaceFormat::defaultFormat();