Skip to content

Commit

Permalink
fix: [desktop] crash in some case.
Browse files Browse the repository at this point in the history
1. uncheck an organized collection;
2. change the wallpaper;
3. crash.

the event is not unsubscribed when collection removed at step 1, when
the wallpaper event emitted, the event handler executed with nullptr,
cause crash.
unsubscribe signal when collection destroyed.

Log: as above.

Bug: https://pms.uniontech.com/bug-view-271449.html
  • Loading branch information
itsXuSt authored and Johnson-zs committed Sep 3, 2024
1 parent c111f55 commit 35dbae6
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ void NormalizedModePrivate::connectCollectionSignals(CollectionHolderPointer col
});
dpfSignalDispatcher->subscribe("ddplugin_background", "signal_Background_BackgroundSetted",
collection->widget(), &CollectionWidget::cacheSnapshot);
connect(collection->widget(), &QWidget::destroyed, this, [](QObject *obj) {
dpfSignalDispatcher->unsubscribe("ddplugin_background", "signal_Background_BackgroundSetted",
obj, &CollectionWidget::cacheSnapshot);
});
}
}

Expand Down

0 comments on commit 35dbae6

Please sign in to comment.