From 14c232b96de2694a8b51c18d8c32e28f0ebeefd9 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Wed, 10 Jul 2024 12:02:47 +0200 Subject: [PATCH] BIM: Added delay to ifc viewprovider drag and drop - fixes #15259 --- src/Mod/BIM/nativeifc/ifc_viewproviders.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Mod/BIM/nativeifc/ifc_viewproviders.py b/src/Mod/BIM/nativeifc/ifc_viewproviders.py index d7aad9645c..1939bef16d 100644 --- a/src/Mod/BIM/nativeifc/ifc_viewproviders.py +++ b/src/Mod/BIM/nativeifc/ifc_viewproviders.py @@ -315,12 +315,20 @@ class ifc_vp_object: def dropObject(self, vobj, incoming_object): """Add an object to the view provider by d&d""" - from nativeifc import ifc_tools # lazy import + from PySide import QtCore # lazy import + self.incoming_object = incoming_object + # delay the action to prevent the object to be deleted + # before the end of the drop + QtCore.QTimer.singleShot(100, self.onDrop) - parent = vobj.Object - ifc_tools.aggregate(incoming_object, parent) - if self.hasChildren(parent): - self.expandChildren(parent) + def onDrop(self): + """Delayed action to be taken when dropping an object""" + + from nativeifc import ifc_tools # lazy import + ifc_tools.aggregate(self.incoming_object, self.Object) + if self.hasChildren(self.Object): + self.expandChildren(self.Object) + del self.incoming_object def activate(self): """Marks this container as active"""