From 8f0ea2082a5418c181ca6f15b56268c82f8a2ecd Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 2 Jul 2016 13:19:25 +0200 Subject: [PATCH] make sure that action is created when calling updateAction --- src/Mod/Sketcher/Gui/CommandConstraints.cpp | 36 ++++++++++++++------- src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 36 ++++++++++++++++----- 2 files changed, 52 insertions(+), 20 deletions(-) diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index 76ec66d7f..b772baa0b 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -829,10 +829,12 @@ void CmdSketcherConstrainLock::updateAction(int mode) { switch (mode) { case Reference: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_ConstrainLock_Driven")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_ConstrainLock_Driven")); break; case Driving: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_ConstrainLock")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_ConstrainLock")); break; } } @@ -1100,10 +1102,12 @@ void CmdSketcherConstrainDistance::updateAction(int mode) { switch (mode) { case Reference: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_Length_Driven")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_Length_Driven")); break; case Driving: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_Length")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_Length")); break; } } @@ -1342,10 +1346,12 @@ void CmdSketcherConstrainDistanceX::updateAction(int mode) { switch (mode) { case Reference: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_HorizontalDistance_Driven")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_HorizontalDistance_Driven")); break; case Driving: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_HorizontalDistance")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_HorizontalDistance")); break; } } @@ -1497,10 +1503,12 @@ void CmdSketcherConstrainDistanceY::updateAction(int mode) { switch (mode) { case Reference: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_VerticalDistance_Driven")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_VerticalDistance_Driven")); break; case Driving: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_VerticalDistance")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_VerticalDistance")); break; } } @@ -2493,10 +2501,12 @@ void CmdSketcherConstrainRadius::updateAction(int mode) { switch (mode) { case Reference: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_Radius_Driven")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_Radius_Driven")); break; case Driving: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_Radius")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_Radius")); break; } } @@ -2765,10 +2775,12 @@ void CmdSketcherConstrainAngle::updateAction(int mode) { switch (mode) { case Reference: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_InternalAngle_Driven")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_InternalAngle_Driven")); break; case Driving: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_InternalAngle")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Constraint_InternalAngle")); break; } } diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index 11234f41a..bd4c86c55 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -331,10 +331,12 @@ void CmdSketcherCreateLine::updateAction(int mode) { switch (mode) { case Normal: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateLine")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateLine")); break; case Construction: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateLine_Constr")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateLine_Constr")); break; } } @@ -572,10 +574,12 @@ void CmdSketcherCreateRectangle::updateAction(int mode) { switch (mode) { case Normal: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateRectangle")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateRectangle")); break; case Construction: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateRectangle_Constr")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateRectangle_Constr")); break; } } @@ -1187,10 +1191,12 @@ void CmdSketcherCreatePolyline::updateAction(int mode) { switch (mode) { case Normal: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreatePolyline")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreatePolyline")); break; case Construction: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreatePolyline_Constr")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreatePolyline_Constr")); break; } } @@ -1829,6 +1835,9 @@ Gui::Action * CmdSketcherCompCreateArc::createAction(void) void CmdSketcherCompCreateArc::updateAction(int mode) { Gui::ActionGroup* pcAction = qobject_cast(getAction()); + if (!pcAction) + return; + QList a = pcAction->actions(); int index = pcAction->property("defaultAction").toInt(); switch (mode) { @@ -3402,6 +3411,9 @@ Gui::Action * CmdSketcherCompCreateConic::createAction(void) void CmdSketcherCompCreateConic::updateAction(int mode) { Gui::ActionGroup* pcAction = qobject_cast(getAction()); + if (!pcAction) + return; + QList a = pcAction->actions(); int index = pcAction->property("defaultAction").toInt(); switch (mode) { @@ -3755,6 +3767,9 @@ Gui::Action * CmdSketcherCompCreateCircle::createAction(void) void CmdSketcherCompCreateCircle::updateAction(int mode) { Gui::ActionGroup* pcAction = qobject_cast(getAction()); + if (!pcAction) + return; + QList a = pcAction->actions(); int index = pcAction->property("defaultAction").toInt(); switch (mode) { @@ -4955,10 +4970,12 @@ void CmdSketcherCreateSlot::updateAction(int mode) { switch (mode) { case Normal: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateSlot")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateSlot")); break; case Construction: - getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateSlot_Constr")); + if (getAction()) + getAction()->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateSlot_Constr")); break; } } @@ -5395,6 +5412,9 @@ Gui::Action * CmdSketcherCompCreateRegularPolygon::createAction(void) void CmdSketcherCompCreateRegularPolygon::updateAction(int mode) { Gui::ActionGroup* pcAction = qobject_cast(getAction()); + if (!pcAction) + return; + QList a = pcAction->actions(); int index = pcAction->property("defaultAction").toInt(); switch (mode) {