Skip to content

Commit cdd9941

Browse files
committed
fix(linux/crash): fix crash in cloud provider integration
when removing a sync folder avoid removing a ref on a GObject instance that we do not own Signed-off-by: Matthieu Gallien <[email protected]>
1 parent 3d9b37a commit cdd9941

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/gui/cloudproviders/cloudproviderwrapper.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
using namespace OCC;
2323

24+
Q_LOGGING_CATEGORY(lcNextcloudCloudProviderIntegration, "nextcloud.cloudprovider.integration", QtInfoMsg)
25+
2426
GSimpleActionGroup *actionGroup = nullptr;
2527

2628
int CloudProviderWrapper::preferredTextWidth = 0;
@@ -55,6 +57,11 @@ CloudProviderWrapper::CloudProviderWrapper(QObject *parent, Folder *folder, int
5557
g_clear_object (&action_group);
5658
}
5759

60+
void mainMenuWasDeleted(gpointer data, GObject *where_the_object_was)
61+
{
62+
qCDebug(lcNextcloudCloudProviderIntegration) << "I was deleted" << data << where_the_object_was;
63+
}
64+
5865
CloudProviderWrapper::~CloudProviderWrapper()
5966
{
6067
g_object_unref(_cloudProviderAccount);
@@ -222,6 +229,8 @@ GMenuModel* CloudProviderWrapper::getMenuModel() {
222229
GMenuItem* item = nullptr;
223230

224231
_mainMenu = g_menu_new();
232+
g_object_ref(_mainMenu);
233+
g_object_weak_ref(reinterpret_cast<GObject*>(_mainMenu), mainMenuWasDeleted, this);
225234

226235
section = g_menu_new();
227236
item = addMenuItem(tr("Open %1 Desktop", "Open Nextcloud main window. Placeholer will be the application name. Please keep it.").arg(APPLICATION_NAME), "cloudprovider.openmaindialog");

0 commit comments

Comments
 (0)