b30490e
From 3bedba886436fb6cee2d92f446d4674ae431cab0 Mon Sep 17 00:00:00 2001
b30490e
From: Dag Andersen <dag.andersen@kdemail.net>
b30490e
Date: Tue, 30 Jun 2020 09:08:42 +0200
b30490e
Subject: [PATCH 10/54] ChartTool, KoFormulaTool: Guard against crash if
b30490e
 activated without shape
b30490e
b30490e
---
b30490e
 plugins/chartshape/ChartTool.cpp       | 5 ++++-
b30490e
 plugins/formulashape/KoFormulaTool.cpp | 4 ++++
b30490e
 2 files changed, 8 insertions(+), 1 deletion(-)
b30490e
b30490e
diff --git a/plugins/chartshape/ChartTool.cpp b/plugins/chartshape/ChartTool.cpp
b30490e
index 33d9bb6d876..3fbf8c49f11 100644
b30490e
--- a/plugins/chartshape/ChartTool.cpp
b30490e
+++ b/plugins/chartshape/ChartTool.cpp
b30490e
@@ -267,7 +267,10 @@ void ChartTool::activate(ToolActivation, const QSet<KoShape*> &shapes)
b30490e
 void ChartTool::deactivate()
b30490e
 {
b30490e
     debugChartTool<<d->shape;
b30490e
-
b30490e
+    if (!d->shape) {
b30490e
+        // activated without shape
b30490e
+        return;
b30490e
+    }
b30490e
     foreach (QWidget *w, optionWidgets()) {
b30490e
         ConfigWidgetBase *configWidget = dynamic_cast<ConfigWidgetBase*>(w);
b30490e
         if (configWidget)
b30490e
diff --git a/plugins/formulashape/KoFormulaTool.cpp b/plugins/formulashape/KoFormulaTool.cpp
b30490e
index 6db24cad001..070633348ce 100644
b30490e
--- a/plugins/formulashape/KoFormulaTool.cpp
b30490e
+++ b/plugins/formulashape/KoFormulaTool.cpp
b30490e
@@ -128,6 +128,10 @@ void KoFormulaTool::deactivate()
b30490e
     for (const TemplateAction &templateAction : koAsConst(m_templateActions)) {
b30490e
         disconnect(templateAction.action, &QAction::triggered, this, nullptr);
b30490e
     }
b30490e
+    if (!m_formulaShape) {
b30490e
+        // activated without shape
b30490e
+        return;
b30490e
+    }
b30490e
     disconnect(m_formulaShape->formulaData(),0,this,0);
b30490e
     if (canvas()) {
b30490e
         m_cursorList.append(m_formulaEditor);
b30490e
-- 
b30490e
2.31.1
b30490e