diff --git a/src/App/Metadata.cpp b/src/App/Metadata.cpp index 692e9b6c0e..df89913f08 100644 --- a/src/App/Metadata.cpp +++ b/src/App/Metadata.cpp @@ -315,7 +315,7 @@ void App::Metadata::addGenericMetadata(const std::string& tag, const Meta::Gener void App::Metadata::removeContentItem(const std::string& tag, const std::string& itemName) { auto tagRange = _content.equal_range(tag); - auto foundItem = std::find_if(tagRange.first, tagRange.second, [itemName](auto check) -> bool { return itemName == check.second.name(); }); + auto foundItem = std::find_if(tagRange.first, tagRange.second, [&itemName](auto check) -> bool { return itemName == check.second.name(); }); if (foundItem != tagRange.second) _content.erase(foundItem); } @@ -686,6 +686,8 @@ Meta::Url::Url(const XERCES_CPP_NAMESPACE::DOMElement* e) type = UrlType::readme; else if (typeAttribute == "documentation") type = UrlType::documentation; + else + type = UrlType::website; if (type == UrlType::repository) branch = StrXUTF8(e->getAttribute(XUTF8Str("branch").unicodeForm())).str; diff --git a/src/App/PropertyExpressionEngine.h b/src/App/PropertyExpressionEngine.h index ab450e6956..c48549d7df 100644 --- a/src/App/PropertyExpressionEngine.h +++ b/src/App/PropertyExpressionEngine.h @@ -80,7 +80,7 @@ public: typedef boost::function expr)> ValidatorFunc; /** - * @brief The ExpressionInfo struct encapsulates an expression and a comment. + * @brief The ExpressionInfo struct encapsulates an expression. */ struct ExpressionInfo { @@ -94,10 +94,12 @@ public: ExpressionInfo(const ExpressionInfo & other) { expression = other.expression; + busy = other.busy; } ExpressionInfo & operator=(const ExpressionInfo & other) { expression = other.expression; + busy = other.busy; return *this; } }; diff --git a/src/Base/PyObjectBase.cpp b/src/Base/PyObjectBase.cpp index ad28902bbb..7336963e7b 100644 --- a/src/Base/PyObjectBase.cpp +++ b/src/Base/PyObjectBase.cpp @@ -235,7 +235,8 @@ PyObject* createWeakRef(PyObjectBase* ptr) static bool init = false; if (!init) { init = true; - PyType_Ready(&PyBaseProxyType); + if (PyType_Ready(&PyBaseProxyType) < 0) + return nullptr; } PyObject* proxy = ptr->baseProxy; diff --git a/src/Gui/DlgGeneralImp.cpp b/src/Gui/DlgGeneralImp.cpp index 88a3c9f024..09fee84c9d 100644 --- a/src/Gui/DlgGeneralImp.cpp +++ b/src/Gui/DlgGeneralImp.cpp @@ -353,7 +353,7 @@ void DlgGeneralImp::recreatePreferencePackMenu() ui->PreferencePacks->setItem(row, 1, kind); auto button = new QPushButton(icon, tr("Apply")); button->setToolTip(tr("Apply the %1 preference pack").arg(QString::fromStdString(pack.first))); - connect(button, &QPushButton::clicked, this, [this, pack]() { onLoadPreferencePackClicked(pack.first); }); + connect(button, &QPushButton::clicked, this, [this, &pack]() { onLoadPreferencePackClicked(pack.first); }); ui->PreferencePacks->setCellWidget(row, 2, button); ++row; } diff --git a/src/Gui/DlgPropertyLink.cpp b/src/Gui/DlgPropertyLink.cpp index 511aba9878..df97c57c23 100644 --- a/src/Gui/DlgPropertyLink.cpp +++ b/src/Gui/DlgPropertyLink.cpp @@ -473,7 +473,12 @@ void DlgPropertyLink::detachObserver() { auto view = qobject_cast(parentView.data()); if(view && savedSelections.size()) { - Gui::Selection().clearSelection(); + try { + Gui::Selection().clearSelection(); + } + catch (Py::Exception& e) { + e.clear(); + } for(auto &sel : savedSelections) { if(sel.getSubObject()) Gui::Selection().addSelection(sel.getDocumentName().c_str(), diff --git a/src/Gui/GestureNavigationStyle.cpp b/src/Gui/GestureNavigationStyle.cpp index 8bebd5d27a..39295d9da0 100644 --- a/src/Gui/GestureNavigationStyle.cpp +++ b/src/Gui/GestureNavigationStyle.cpp @@ -93,7 +93,7 @@ namespace Gui { class NS::Event : public sc::event { public: - Event():inventor_event(nullptr), flags(new Flags){} + Event():inventor_event(nullptr), modifiers{}, flags(new Flags){} virtual ~Event(){} void log() const { diff --git a/src/Gui/Quarter/EventFilter.cpp b/src/Gui/Quarter/EventFilter.cpp index 0787738b02..789c4d2f09 100644 --- a/src/Gui/Quarter/EventFilter.cpp +++ b/src/Gui/Quarter/EventFilter.cpp @@ -147,10 +147,10 @@ EventFilter::eventFilter(QObject * obj, QEvent * qevent) case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: case QEvent::MouseButtonDblClick: - PRIVATE(this)->trackPointerPosition(dynamic_cast(qevent)); + PRIVATE(this)->trackPointerPosition(static_cast(qevent)); break; case QEvent::Resize: - PRIVATE(this)->trackWindowSize(dynamic_cast(qevent)); + PRIVATE(this)->trackWindowSize(static_cast(qevent)); break; default: break; diff --git a/src/Gui/Quarter/QuarterWidgetP.cpp b/src/Gui/Quarter/QuarterWidgetP.cpp index 37547504c4..ad46e9449f 100644 --- a/src/Gui/Quarter/QuarterWidgetP.cpp +++ b/src/Gui/Quarter/QuarterWidgetP.cpp @@ -83,7 +83,12 @@ QuarterWidgetP::QuarterWidgetP(QuarterWidget * masterptr, const QtGLWidget * sha clearzbuffer(true), clearwindow(true), addactions(true), + processdelayqueue(true), + currentStateMachine(nullptr), device_pixel_ratio(1.0), + transparencytypegroup(nullptr), + stereomodegroup(nullptr), + rendermodegroup(nullptr), contextmenu(nullptr) { this->cachecontext = findCacheContext(masterptr, sharewidget); diff --git a/src/Gui/SoFCSelection.cpp b/src/Gui/SoFCSelection.cpp index 578c646178..47247c93da 100644 --- a/src/Gui/SoFCSelection.cpp +++ b/src/Gui/SoFCSelection.cpp @@ -160,35 +160,42 @@ void SoFCSelection::doAction(SoAction *action) if(useNewSelection.getValue() && action->getCurPathCode()!=SoAction::OFF_PATH) { if (action->getTypeId() == Gui::SoHighlightElementAction::getClassTypeId()) { Gui::SoHighlightElementAction* hlaction = static_cast(action); - if(!hlaction->isHighlighted()) { + if (!hlaction->isHighlighted()) { auto ctx = Gui::SoFCSelectionRoot::getActionContext(action,this,selContext,false); - if(ctx->isHighlighted()) { + if (ctx && ctx->isHighlighted()) { ctx->highlightIndex = -1; touch(); } - }else{ + } + else { auto ctx = Gui::SoFCSelectionRoot::getActionContext(action,this,selContext); - ctx->highlightColor = hlaction->getColor(); - if(!ctx->isHighlighted()) { - ctx->highlightIndex = 0; - touch(); + if (ctx) { + ctx->highlightColor = hlaction->getColor(); + if (!ctx->isHighlighted()) { + ctx->highlightIndex = 0; + touch(); + } } } return; - } else if (action->getTypeId() == Gui::SoSelectionElementAction::getClassTypeId()) { + } + else if (action->getTypeId() == Gui::SoSelectionElementAction::getClassTypeId()) { Gui::SoSelectionElementAction* selaction = static_cast(action); if (selaction->getType() == Gui::SoSelectionElementAction::All || selaction->getType() == Gui::SoSelectionElementAction::Append) { SelContextPtr ctx = Gui::SoFCSelectionRoot::getActionContext(action,this,selContext); - ctx->selectionColor = selaction->getColor(); - if(!ctx->isSelectAll()) { - ctx->selectAll(); - this->touch(); + if (ctx) { + ctx->selectionColor = selaction->getColor(); + if(!ctx->isSelectAll()) { + ctx->selectAll(); + this->touch(); + } } - } else if (selaction->getType() == Gui::SoSelectionElementAction::None || - selaction->getType() == Gui::SoSelectionElementAction::Remove) { + } + else if (selaction->getType() == Gui::SoSelectionElementAction::None || + selaction->getType() == Gui::SoSelectionElementAction::Remove) { SelContextPtr ctx = Gui::SoFCSelectionRoot::getActionContext(action,this,selContext,false); - if(ctx && ctx->isSelected()) { + if (ctx && ctx->isSelected()) { ctx->selectionIndex.clear(); this->touch(); } @@ -965,9 +972,11 @@ SoFCSelection::setOverride(SoGLRenderAction * action, SelContextPtr ctx) Styles mystyle = (Styles) this->style.getValue(); - if(mystyle == SoFCSelection::BOX) { - SoFCSelectionRoot::renderBBox( - action,this,preselected?ctx->highlightColor:ctx->selectionColor); + if (mystyle == SoFCSelection::BOX) { + if (ctx) { + SoFCSelectionRoot::renderBBox( + action, this, preselected ? ctx->highlightColor : ctx->selectionColor); + } this->uniqueId = oldId; return false; } @@ -979,19 +988,19 @@ SoFCSelection::setOverride(SoGLRenderAction * action, SelContextPtr ctx) SoMaterialBindingElement::set(state,SoMaterialBindingElement::OVERALL); SoOverrideElement::setMaterialBindingOverride(state,this,true); - if(!preselected) + if (!preselected && ctx) SoLazyElement::setEmissive(state, &ctx->selectionColor); - else + else if (ctx) SoLazyElement::setEmissive(state, &ctx->highlightColor); SoOverrideElement::setEmissiveColorOverride(state, this, true); if(SoLazyElement::getLightModel(state)==SoLazyElement::BASE_COLOR || mystyle == SoFCSelection::EMISSIVE_DIFFUSE) { - if(!preselected) - SoLazyElement::setDiffuse(state, this,1, &ctx->selectionColor,&colorpacker); - else - SoLazyElement::setDiffuse(state, this,1, &ctx->highlightColor,&colorpacker); + if (!preselected && ctx) + SoLazyElement::setDiffuse(state, this, 1, &ctx->selectionColor,&colorpacker); + else if (ctx) + SoLazyElement::setDiffuse(state, this, 1, &ctx->highlightColor,&colorpacker); SoOverrideElement::setDiffuseColorOverride(state, this, true); } diff --git a/src/Gui/TaskView/TaskDialogPython.cpp b/src/Gui/TaskView/TaskDialogPython.cpp index 16f6be9a25..bf828b2bd9 100644 --- a/src/Gui/TaskView/TaskDialogPython.cpp +++ b/src/Gui/TaskView/TaskDialogPython.cpp @@ -367,14 +367,7 @@ TaskDialogPython::~TaskDialogPython() Content.clear(); Base::PyGILStateLocker lock; - - // The widgets stored in the 'form' attribute will be deleted. - // Thus, set this attribute to None to make sure that when using - // the same dialog instance for a task panel won't segfault. - if (this->dlg.hasAttr(std::string("form"))) { - this->dlg.setAttr(std::string("form"), Py::None()); - } - this->dlg = Py::None(); + clearForm(); // Assigning None to 'dlg' may destroy some of the stored widgets. // By guarding them with QPointer their pointers will be set to null @@ -382,6 +375,22 @@ TaskDialogPython::~TaskDialogPython() Content.insert(Content.begin(), guarded.begin(), guarded.end()); } +void TaskDialogPython::clearForm() +{ + try { + // The widgets stored in the 'form' attribute will be deleted. + // Thus, set this attribute to None to make sure that when using + // the same dialog instance for a task panel won't segfault. + if (this->dlg.hasAttr(std::string("form"))) { + this->dlg.setAttr(std::string("form"), Py::None()); + } + this->dlg = Py::None(); + } + catch (Py::AttributeError& e) { + e.clear(); + } +} + void TaskDialogPython::open() { Base::PyGILStateLocker lock; diff --git a/src/Gui/TaskView/TaskDialogPython.h b/src/Gui/TaskView/TaskDialogPython.h index 4d1861d521..178f562c7e 100644 --- a/src/Gui/TaskView/TaskDialogPython.h +++ b/src/Gui/TaskView/TaskDialogPython.h @@ -104,7 +104,10 @@ public: virtual bool reject(); /// is called by the framework if the user press the help button virtual void helpRequested(); - + +private: + void clearForm(); + private: Py::Object dlg; }; diff --git a/src/Gui/ViewProviderLink.cpp b/src/Gui/ViewProviderLink.cpp index 91214601c1..6d206a46f6 100644 --- a/src/Gui/ViewProviderLink.cpp +++ b/src/Gui/ViewProviderLink.cpp @@ -2744,6 +2744,9 @@ void ViewProviderLink::updateLinks(ViewProvider *vp) { catch (const Base::TypeError &e) { e.ReportException(); } + catch (const Base::ValueError &e) { + e.ReportException(); + } } PyObject *ViewProviderLink::getPyObject() { diff --git a/src/Gui/ViewProviderPythonFeature.cpp b/src/Gui/ViewProviderPythonFeature.cpp index c5e5a83db1..cf77dbf72c 100644 --- a/src/Gui/ViewProviderPythonFeature.cpp +++ b/src/Gui/ViewProviderPythonFeature.cpp @@ -283,7 +283,12 @@ ViewProviderPythonFeatureImp::~ViewProviderPythonFeatureImp() #undef FC_PY_ELEMENT #define FC_PY_ELEMENT(_name) py_##_name = Py::None(); - FC_PY_VIEW_OBJECT + try { + FC_PY_VIEW_OBJECT + } + catch (Py::Exception& e) { + e.clear(); + } } void ViewProviderPythonFeatureImp::init(PyObject *pyobj) { diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 66deba4078..f3efc542a1 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -4028,13 +4028,15 @@ QWidget* PropertyFileItem::createEditor(QWidget* parent, const QObject* receiver void PropertyFileItem::setEditorData(QWidget *editor, const QVariant& data) const { const App::Property* prop = getFirstProperty(); - const App::PropertyFile* propFile = static_cast(prop); - std::string filter = propFile->getFilter(); - Gui::FileChooser *fc = qobject_cast(editor); - if (!filter.empty()) { - fc->setFilter(Base::Tools::fromStdString(filter)); + if (prop) { + const App::PropertyFile* propFile = static_cast(prop); + std::string filter = propFile->getFilter(); + Gui::FileChooser *fc = qobject_cast(editor); + if (!filter.empty()) { + fc->setFilter(Base::Tools::fromStdString(filter)); + } + fc->setFileName(data.toString()); } - fc->setFileName(data.toString()); } QVariant PropertyFileItem::editorData(QWidget *editor) const