From c925b224de4d6fdadb857c862ef3e51f1cc41ada Mon Sep 17 00:00:00 2001 From: Simone Gaiarin Date: Sun, 18 Apr 2021 16:35:48 +0200 Subject: [PATCH] Fix crash when repopulating quick annotations action --- part/annotationactionhandler.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/part/annotationactionhandler.cpp b/part/annotationactionhandler.cpp index d0f2be7a8..95558d226 100644 --- a/part/annotationactionhandler.cpp +++ b/part/annotationactionhandler.cpp @@ -63,6 +63,7 @@ public: , aHideToolBar(nullptr) , aShowToolBar(nullptr) , aToolBarVisibility(nullptr) + , aQuickToolsSeparator(nullptr) , aCustomStamp(nullptr) , aCustomWidth(nullptr) , aCustomOpacity(nullptr) @@ -129,6 +130,7 @@ public: QAction *aHideToolBar; QAction *aShowToolBar; KToggleAction *aToolBarVisibility; + QAction *aQuickToolsSeparator; QAction *aCustomStamp; QAction *aCustomWidth; @@ -360,7 +362,7 @@ void AnnotationActionHandlerPrivate::populateQuickAnnotations() const QList quickToolActions = aQuickTools->menu()->actions(); for (QAction *action : quickToolActions) { aQuickTools->removeAction(action); - if (action != aConfigAnnotation) { + if (isQuickToolAction(action)) { delete action; } } @@ -394,9 +396,9 @@ void AnnotationActionHandlerPrivate::populateQuickAnnotations() } favToolElement = annotator->quickTool(++favToolId); } - QAction *separator = new QAction(); - separator->setSeparator(true); - aQuickTools->addAction(separator); + if (aQuickToolsSeparator) { + aQuickTools->addAction(aQuickToolsSeparator); + } if (aShowToolBar) { aQuickTools->addAction(aShowToolBar); } @@ -666,6 +668,8 @@ AnnotationActionHandler::AnnotationActionHandler(PageViewAnnotator *parent, KAct d->aQuickTools->setDefaultAction(action); } }); + d->aQuickToolsSeparator = new QAction(this); + d->aQuickToolsSeparator->setSeparator(true); d->populateQuickAnnotations(); // Add to quick annotation action