Ensure file provider class is correctly deallocated and cleanup routines are run
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Wed, 30 Nov 2022 16:11:52 +0000 (17:11 +0100)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 12 May 2023 05:21:07 +0000 (13:21 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/application.cpp
src/gui/application.h
src/gui/macOS/fileproviderinterface.h [new file with mode: 0644]
src/gui/main.cpp

index 767b5fc340ab82647d78b0c3ab61113d5eb7578e..2ab170c582c389725b926a0d2365b3dfe621f821 100644 (file)
@@ -51,6 +51,8 @@
 
 #if defined(Q_OS_WIN)
 #include <windows.h>
+#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);
index 9b6bad9eb5d63959e90c79f42eadf43c7db6c3c2..664dae6a1b3769624b423bc1f01aa163e29d5e0c 100644 (file)
@@ -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<CrashReporter::Handler> _crashHandler;
 #endif
     QScopedPointer<FolderMan> _folderManager;
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN)
     QScopedPointer<ShellExtensionsServer> _shellExtensionsServer;
+#elif defined(Q_OS_MACOS)
+    QScopedPointer<Mac::FileProvider> _fileProvider;
 #endif
 };
 
diff --git a/src/gui/macOS/fileproviderinterface.h b/src/gui/macOS/fileproviderinterface.h
new file mode 100644 (file)
index 0000000..fe722ae
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef FILEPROVIDERINTERFACE_H
+#define FILEPROVIDERINTERFACE_H
+
+#endif // FILEPROVIDERINTERFACE_H
index 8542993c992bc9a3fe5ef1dbcca51fb8debb79b6..40af80ac019c5f307b2a1713d1e2fd4d82658816 100644 (file)
 #include <sys/resource.h>
 #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();