From eb37c9b7bb492d3308db88624c07168cc7c8ec10 Mon Sep 17 00:00:00 2001 From: gfgit Date: Sat, 6 Jan 2024 16:30:15 +0100 Subject: [PATCH] FancyMenu: try fix crash --- plugin-fancymenu/lxqtfancymenuwindow.cpp | 19 +++++++++---------- plugin-fancymenu/lxqtfancymenuwindow.h | 1 - 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/plugin-fancymenu/lxqtfancymenuwindow.cpp b/plugin-fancymenu/lxqtfancymenuwindow.cpp index ca38b2b74..b15e169df 100644 --- a/plugin-fancymenu/lxqtfancymenuwindow.cpp +++ b/plugin-fancymenu/lxqtfancymenuwindow.cpp @@ -329,24 +329,22 @@ void LXQtFancyMenuWindow::runCommandHelper(const QString &cmd) void LXQtFancyMenuWindow::addToFavorites(const QString &desktopFile) { mFavorites.append(desktopFile); + + mAppModel->reloadAppMap(false); mAppMap->addToFavorites(desktopFile); - reloadFavoritesModel(); + mAppModel->reloadAppMap(true); + emit favoritesChanged(); } void LXQtFancyMenuWindow::removeFromFavorites(const QString &desktopFile) { mFavorites.removeOne(desktopFile); - mAppMap->removeFromFavorites(desktopFile); - reloadFavoritesModel(); - emit favoritesChanged(); -} - -void LXQtFancyMenuWindow::reloadFavoritesModel() -{ - // TODO: reload only if showing favorites mAppModel->reloadAppMap(false); + mAppMap->removeFromFavorites(desktopFile); mAppModel->reloadAppMap(true); + + emit favoritesChanged(); } QStringList LXQtFancyMenuWindow::favorites() const @@ -357,6 +355,7 @@ QStringList LXQtFancyMenuWindow::favorites() const void LXQtFancyMenuWindow::setFavorites(const QStringList &newFavorites) { mFavorites = newFavorites; + mAppModel->reloadAppMap(false); mAppMap->setFavorites(mFavorites); - reloadFavoritesModel(); + mAppModel->reloadAppMap(true); } diff --git a/plugin-fancymenu/lxqtfancymenuwindow.h b/plugin-fancymenu/lxqtfancymenuwindow.h index 1fd26d66c..6e6e33985 100644 --- a/plugin-fancymenu/lxqtfancymenuwindow.h +++ b/plugin-fancymenu/lxqtfancymenuwindow.h @@ -62,7 +62,6 @@ private slots: void addToFavorites(const QString& desktopFile); void removeFromFavorites(const QString& desktopFile); - void reloadFavoritesModel(); private: QStringList mFavorites;