Draft: Improve layer drag-drop fix.

The fix in #16212 only checks the LayerContainer for layers. Since we do not stop users from moving layers out of that container, we should search the whole document instead.

Fixes: #16201.
This commit is contained in:
Roy-043
2024-10-17 09:25:44 +02:00
committed by Yorik van Havre
parent 5744661d02
commit b665fda4df
2 changed files with 10 additions and 0 deletions

View File

@@ -910,9 +910,14 @@ def _get_layer(obj):
finds = obj.Document.findObjects(Name="LayerContainer")
if not finds:
return None
# First look in the LayerContainer:
for layer in finds[0].Group:
if utils.get_type(layer) == "Layer" and obj in layer.Group:
return layer
# If not found, look through all App::FeaturePython objects (not just layers):
for find in obj.Document.findObjects(Type="App::FeaturePython"):
if utils.get_type(find) == "Layer" and obj in find.Group:
return find
return None

View File

@@ -333,9 +333,14 @@ class ViewProviderLayer:
"""Get the layer the object belongs to.
"""
from draftmake.make_layer import get_layer_container
# First look in the LayerContainer:
for layer in get_layer_container().Group:
if utils.get_type(layer) == "Layer" and obj in layer.Group:
return layer
# If not found, look through all App::FeaturePython objects (not just layers):
for find in obj.Document.findObjects(Type="App::FeaturePython"):
if utils.get_type(find) == "Layer" and obj in find.Group:
return find
return None
def canDragObject(self, obj):