diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index d8bf79af53..60dcd3ecd9 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -1562,6 +1562,7 @@ void StdCmdPlacement::activated(int iMsg) plm->setPropertyName(QLatin1String("Placement")); plm->setSelection(selection); plm->bindObject(); + plm->clearSelection(); } } Gui::Control().showDialog(plm); diff --git a/src/Gui/Placement.cpp b/src/Gui/Placement.cpp index 02d7476843..c34be6dd37 100644 --- a/src/Gui/Placement.cpp +++ b/src/Gui/Placement.cpp @@ -195,7 +195,21 @@ std::vector PlacementHandler::getObjects(Gui::Document* do std::vector PlacementHandler::getSelectedObjects(Gui::Document* document) const { - return Gui::Selection().getObjectsOfType(App::DocumentObject::getClassTypeId(), document->getDocument()->getName()); + App::Document* doc = document->getDocument(); + std::vector list; + list.reserve(selectionObjects.size()); + for (const auto& it : selectionObjects) { + const App::DocumentObject* obj = it.getObject(); + if (obj && obj->getDocument() == doc) { + list.push_back(const_cast(obj)); // NOLINT + } + } + + if (!list.empty()) { + return list; + } + + return Gui::Selection().getObjectsOfType(App::DocumentObject::getClassTypeId(), doc->getName()); } void PlacementHandler::revertTransformationOfViewProviders(Gui::Document* document) @@ -1073,6 +1087,15 @@ void TaskPlacement::setSelection(const std::vector& select widget->setSelection(selection); } +/*! + * \brief TaskPlacement::clearSelection + * Clears the array of selection objects. + */ +void TaskPlacement::clearSelection() +{ + widget->setSelection({}); +} + /*! * \brief TaskPlacement::bindObject * Binds the spin boxes to the placement components of the first object of the selection. diff --git a/src/Gui/Placement.h b/src/Gui/Placement.h index 23083c4e7f..c59bd869e1 100644 --- a/src/Gui/Placement.h +++ b/src/Gui/Placement.h @@ -187,6 +187,7 @@ public: void setPropertyName(const QString&); void setPlacement(const Base::Placement&); void setSelection(const std::vector&); + void clearSelection(); void bindObject(); bool accept() override; bool reject() override;