From 352ecf9aa151e842f5304b8f4dc1fa7c7689b32f Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Wed, 20 Jul 2022 15:00:02 +0200 Subject: [PATCH] [applets/comic] Disable most context menu actions when comic is not ready This can be either because the loading failed or is not done yet In those cases the actions don't make sense and can lead to crashes BUG: 406991 (cherry picked from commit 6a0aec81074135c210a2ed11127ef9cfb138dbca) --- applets/comic/comic.cpp | 3 +++ applets/comic/comicdata.cpp | 1 + applets/comic/comicdata.h | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/applets/comic/comic.cpp b/applets/comic/comic.cpp index 1ad3e83a4..b4f8154fa 100644 --- a/applets/comic/comic.cpp +++ b/applets/comic/comic.cpp @@ -495,6 +495,9 @@ void ComicApplet::updateContextMenu() { if (mCurrent.id().isEmpty()) { mActiveComicModel->clear(); + } + + if (mCurrent.id().isEmpty() || !mCurrent.ready()) { mActionNextNewStripTab->setEnabled(false); mActionGoFirst->setEnabled(false); mActionGoLast->setEnabled(false); diff --git a/applets/comic/comicdata.cpp b/applets/comic/comicdata.cpp index 52cc57e91..60eb475c9 100644 --- a/applets/comic/comicdata.cpp +++ b/applets/comic/comicdata.cpp @@ -62,6 +62,7 @@ void ComicData::setData(const Plasma::DataEngine::Data &data) mPrev = data[QStringLiteral("Previous identifier suffix")].toString(); mNext = data[QStringLiteral("Next identifier suffix")].toString(); mAdditionalText = data[QStringLiteral("Additional text")].toString(); + mReady = true; } mWebsiteUrl = data[QStringLiteral("Website Url")].toUrl(); diff --git a/applets/comic/comicdata.h b/applets/comic/comicdata.h index 9c884a291..b5f5ee3a7 100644 --- a/applets/comic/comicdata.h +++ b/applets/comic/comicdata.h @@ -190,6 +190,11 @@ public: return mMaxStripNum; } + bool ready() const + { + return mReady; + } + void save(); private: @@ -226,6 +231,7 @@ private: bool mScaleComic = false; bool mIsLeftToRight = false; bool mIsTopToBottom = false; + bool mReady = false; KConfigGroup mCfg; }; -- GitLab