Skip to content

Commit

Permalink
Core: Avoid cyclic dependencies when dragging an object into a group
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Nov 9, 2024
1 parent 3a7c8ed commit c14ef04
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/Gui/ViewProviderGroupExtension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,27 @@ bool ViewProviderGroupExtension::extensionCanDropObjects() const {
return true;
}

bool ViewProviderGroupExtension::extensionCanDropObject(App::DocumentObject* obj) const {

bool ViewProviderGroupExtension::extensionCanDropObject(App::DocumentObject* obj) const
{
#ifdef FC_DEBUG
Base::Console().Log("Check ViewProviderGroupExtension");
#endif

auto* group = getExtendedViewProvider()->getObject()->getExtensionByType<App::GroupExtension>();
auto extobj = getExtendedViewProvider()->getObject();
auto group = extobj->getExtensionByType<App::GroupExtension>();

//we cannot drop thing of this group into it again if it does not allow reorder
if (group->hasObject(obj) && !getExtendedViewProvider()->acceptReorderingObjects())
if (group->hasObject(obj) && !getExtendedViewProvider()->acceptReorderingObjects()) {
return false;
}

if (group->allowObject(obj))
return true;
// Check for possible cyclic dependencies if we allowed to drop the object
const auto& list = obj->getOutList();
if (std::find(list.begin(), list.end(), extobj) != list.end()) {
return false;
}

return false;
return group->allowObject(obj);
}

void ViewProviderGroupExtension::extensionDropObject(App::DocumentObject* obj) {
Expand Down

0 comments on commit c14ef04

Please sign in to comment.