diff --git a/src/Mod/Part/Gui/ViewProviderAttachExtension.cpp b/src/Mod/Part/Gui/ViewProviderAttachExtension.cpp index 97004e495fac..fc7b9044bcba 100644 --- a/src/Mod/Part/Gui/ViewProviderAttachExtension.cpp +++ b/src/Mod/Part/Gui/ViewProviderAttachExtension.cpp @@ -45,41 +45,44 @@ QIcon ViewProviderAttachExtension::extensionMergeOverlayIcons(const QIcon & orig { QIcon mergedicon = orig; - auto* attach = getExtendedViewProvider()->getObject()->getExtensionByType(); - - if (attach) { - - bool attached = false; - - try{ - attached = attach->positionBySupport(); - } - catch (...) { // We are just trying to get an icon, if no placement can be calculated, set unattached. - // set unattached - } - - if(!attached) { - QPixmap px; - - static const char * const feature_detached_xpm[]={ - "9 9 3 1", - ". c None", - "# c #cc00cc", - "a c #ffffff", - "...###...", - ".##aaa##.", - "##aaaaa##", - "##aaaaa##", - "#########", - "#########", - "#########", - ".##aaa##.", - ".##aaa##.", - "...###..."}; - - px = QPixmap(feature_detached_xpm); - - mergedicon = Gui::BitmapFactoryInst::mergePixmap(mergedicon, px, Gui::BitmapFactoryInst::BottomLeft); + if (getExtendedViewProvider()->getObject()->hasExtension(Part::AttachExtension::getExtensionClassTypeId())) { + + auto* attach = getExtendedViewProvider()->getObject()->getExtensionByType(); + + if (attach) { + + bool attached = false; + + try{ + attached = attach->positionBySupport(); + } + catch (...) { // We are just trying to get an icon, if no placement can be calculated, set unattached. + // set unattached + } + + if(!attached) { + QPixmap px; + + static const char * const feature_detached_xpm[]={ + "9 9 3 1", + ". c None", + "# c #cc00cc", + "a c #ffffff", + "...###...", + ".##aaa##.", + "##aaaaa##", + "##aaaaa##", + "#########", + "#########", + "#########", + ".##aaa##.", + ".##aaa##.", + "...###..."}; + + px = QPixmap(feature_detached_xpm); + + mergedicon = Gui::BitmapFactoryInst::mergePixmap(mergedicon, px, Gui::BitmapFactoryInst::BottomLeft); + } } } @@ -88,17 +91,19 @@ QIcon ViewProviderAttachExtension::extensionMergeOverlayIcons(const QIcon & orig void ViewProviderAttachExtension::extensionUpdateData(const App::Property* prop) { - auto* attach = getExtendedViewProvider()->getObject()->getExtensionByType(); - - if(attach) { - if( prop == &(attach->Support) || - prop == &(attach->MapMode) || - prop == &(attach->MapPathParameter) || - prop == &(attach->MapReversed) || - prop == &(attach->AttachmentOffset) || - prop == &(attach->AttacherType) ) { - - getExtendedViewProvider()->signalChangeIcon(); // signal icon change + if (getExtendedViewProvider()->getObject()->hasExtension(Part::AttachExtension::getExtensionClassTypeId())) { + auto* attach = getExtendedViewProvider()->getObject()->getExtensionByType(); + + if(attach) { + if( prop == &(attach->Support) || + prop == &(attach->MapMode) || + prop == &(attach->MapPathParameter) || + prop == &(attach->MapReversed) || + prop == &(attach->AttachmentOffset) || + prop == &(attach->AttacherType) ) { + + getExtendedViewProvider()->signalChangeIcon(); // signal icon change + } } }