mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 21:46:03 +03:00
Merge pull request #2119 from nextcloud/sbeyer-fix-segv-on-exit
Fix SEGV (due to circular ownership) at exit
This commit is contained in:
commit
cbea0e7134
3 changed files with 20 additions and 9 deletions
|
@ -32,6 +32,7 @@
|
|||
#include "cloudproviders/cloudprovidermanager.h"
|
||||
#endif
|
||||
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
|
@ -66,7 +67,7 @@ ownCloudGui::ownCloudGui(Application *parent)
|
|||
, _app(parent)
|
||||
{
|
||||
_tray = Systray::instance();
|
||||
_tray->setParent(this);
|
||||
_tray->setTrayEngine(new QQmlApplicationEngine(this));
|
||||
// for the beginning, set the offline icon until the account was verified
|
||||
_tray->setIcon(Theme::instance()->folderOfflineIcon(/*systray?*/ true));
|
||||
|
||||
|
|
|
@ -49,12 +49,17 @@ Systray *Systray::instance()
|
|||
return _instance;
|
||||
}
|
||||
|
||||
Systray::Systray()
|
||||
: _trayEngine(new QQmlApplicationEngine(this))
|
||||
void Systray::setTrayEngine(QQmlApplicationEngine *trayEngine)
|
||||
{
|
||||
_trayEngine = trayEngine;
|
||||
|
||||
_trayEngine->addImportPath("qrc:/qml/theme");
|
||||
_trayEngine->addImageProvider("avatars", new ImageProvider);
|
||||
}
|
||||
|
||||
Systray::Systray()
|
||||
: QSystemTrayIcon(nullptr)
|
||||
{
|
||||
qmlRegisterSingletonType<UserModel>("com.nextcloud.desktopclient", 1, 0, "UserModel",
|
||||
[](QQmlEngine *, QJSEngine *) -> QObject * {
|
||||
return UserModel::instance();
|
||||
|
@ -82,18 +87,22 @@ Systray::Systray()
|
|||
|
||||
void Systray::create()
|
||||
{
|
||||
if (!AccountManager::instance()->accounts().isEmpty()) {
|
||||
_trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel());
|
||||
if (_trayEngine) {
|
||||
if (!AccountManager::instance()->accounts().isEmpty()) {
|
||||
_trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel());
|
||||
}
|
||||
_trayEngine->load(QStringLiteral("qrc:/qml/src/gui/tray/Window.qml"));
|
||||
}
|
||||
_trayEngine->load(QStringLiteral("qrc:/qml/src/gui/tray/Window.qml"));
|
||||
hideWindow();
|
||||
emit activated(QSystemTrayIcon::ActivationReason::Unknown);
|
||||
}
|
||||
|
||||
void Systray::slotNewUserSelected()
|
||||
{
|
||||
// Change ActivityModel
|
||||
_trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel());
|
||||
if (_trayEngine) {
|
||||
// Change ActivityModel
|
||||
_trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel());
|
||||
}
|
||||
|
||||
// Rebuild App list
|
||||
UserAppsModel::instance()->buildAppList();
|
||||
|
|
|
@ -49,6 +49,7 @@ public:
|
|||
enum class TaskBarPosition { Bottom, Left, Top, Right };
|
||||
Q_ENUM(TaskBarPosition);
|
||||
|
||||
void setTrayEngine(QQmlApplicationEngine *trayEngine);
|
||||
void create();
|
||||
void showMessage(const QString &title, const QString &message, MessageIcon icon = Information);
|
||||
void setToolTip(const QString &tip);
|
||||
|
@ -89,7 +90,7 @@ private:
|
|||
|
||||
bool _isOpen = false;
|
||||
bool _syncIsPaused = false;
|
||||
QQmlApplicationEngine *_trayEngine;
|
||||
QPointer<QQmlApplicationEngine> _trayEngine;
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
|
|
Loading…
Reference in a new issue