mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Improve initialisation of C++ FileProvider class
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
ccad81949a
commit
22fc43e7b0
3 changed files with 17 additions and 4 deletions
|
@ -403,7 +403,7 @@ Application::Application(int &argc, char **argv)
|
|||
}
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
_fileProvider.reset(Mac::FileProvider::instance());
|
||||
_fileProvider.reset(new Mac::FileProvider);
|
||||
#endif
|
||||
|
||||
FolderMan::instance()->setSyncEnabled(true);
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
namespace OCC {
|
||||
|
||||
class Application;
|
||||
|
||||
namespace Mac {
|
||||
|
||||
// NOTE: For the file provider extension to work, the app bundle will
|
||||
|
@ -32,14 +34,18 @@ class FileProvider : public QObject
|
|||
|
||||
public:
|
||||
static FileProvider *instance();
|
||||
~FileProvider() = default;
|
||||
~FileProvider() override;
|
||||
|
||||
static bool fileProviderAvailable();
|
||||
|
||||
private:
|
||||
explicit FileProvider(QObject * const parent = nullptr);
|
||||
std::unique_ptr<FileProviderDomainManager> _domainManager;
|
||||
std::unique_ptr<FileProviderSocketServer> _socketServer;
|
||||
|
||||
static FileProvider *_instance;
|
||||
explicit FileProvider(QObject * const parent = nullptr);
|
||||
|
||||
friend class OCC::Application;
|
||||
};
|
||||
|
||||
} // namespace Mac
|
||||
|
|
|
@ -24,11 +24,13 @@ Q_LOGGING_CATEGORY(lcMacFileProvider, "nextcloud.gui.macfileprovider", QtInfoMsg
|
|||
|
||||
namespace Mac {
|
||||
|
||||
static FileProvider *_instance = nullptr;
|
||||
FileProvider* FileProvider::_instance = nullptr;
|
||||
|
||||
FileProvider::FileProvider(QObject * const parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
Q_ASSERT(!_instance);
|
||||
|
||||
if (!fileProviderAvailable()) {
|
||||
qCDebug(lcMacFileProvider) << "File provider system is not available on this version of macOS.";
|
||||
return;
|
||||
|
@ -61,6 +63,11 @@ FileProvider *FileProvider::instance()
|
|||
return _instance;
|
||||
}
|
||||
|
||||
FileProvider::~FileProvider()
|
||||
{
|
||||
_instance = nullptr;
|
||||
}
|
||||
|
||||
bool FileProvider::fileProviderAvailable()
|
||||
{
|
||||
if (@available(macOS 11.0, *)) {
|
||||
|
|
Loading…
Reference in a new issue