Skip to content

Commit

Permalink
make sure that action is created when calling updateAction
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jul 2, 2016
1 parent 3b1c9b5 commit 8f0ea20
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 20 deletions.
36 changes: 24 additions & 12 deletions src/Mod/Sketcher/Gui/CommandConstraints.cpp
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down
36 changes: 28 additions & 8 deletions src/Mod/Sketcher/Gui/CommandCreateGeo.cpp
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -1829,6 +1835,9 @@ Gui::Action * CmdSketcherCompCreateArc::createAction(void)
void CmdSketcherCompCreateArc::updateAction(int mode)
{
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(getAction());
if (!pcAction)
return;

QList<QAction*> a = pcAction->actions();
int index = pcAction->property("defaultAction").toInt();
switch (mode) {
Expand Down Expand Up @@ -3402,6 +3411,9 @@ Gui::Action * CmdSketcherCompCreateConic::createAction(void)
void CmdSketcherCompCreateConic::updateAction(int mode)
{
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(getAction());
if (!pcAction)
return;

QList<QAction*> a = pcAction->actions();
int index = pcAction->property("defaultAction").toInt();
switch (mode) {
Expand Down Expand Up @@ -3755,6 +3767,9 @@ Gui::Action * CmdSketcherCompCreateCircle::createAction(void)
void CmdSketcherCompCreateCircle::updateAction(int mode)
{
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(getAction());
if (!pcAction)
return;

QList<QAction*> a = pcAction->actions();
int index = pcAction->property("defaultAction").toInt();
switch (mode) {
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -5395,6 +5412,9 @@ Gui::Action * CmdSketcherCompCreateRegularPolygon::createAction(void)
void CmdSketcherCompCreateRegularPolygon::updateAction(int mode)
{
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(getAction());
if (!pcAction)
return;

QList<QAction*> a = pcAction->actions();
int index = pcAction->property("defaultAction").toInt();
switch (mode) {
Expand Down

0 comments on commit 8f0ea20

Please sign in to comment.