Draft: fix wrong selection after commands

Fixes #10469

The code of the `end_all_events()` function is by Chris Hennes (chennes).
See https://forum.freecadweb.org/viewtopic.php?p=656362#p656362.
This commit is contained in:
Roy-043
2024-02-04 15:16:49 +01:00
committed by Chris Hennes
parent 4ff2ee43d2
commit 3b3ed05dc8
13 changed files with 73 additions and 27 deletions

View File

@@ -48,6 +48,7 @@ from draftutils.translate import translate
if App.GuiUp:
import FreeCADGui as Gui
from pivy import coin
from PySide import QtCore
from PySide import QtGui
# from PySide import QtSvg # for load_texture
@@ -856,4 +857,22 @@ def get_bbox(obj, debug=False):
return App.BoundBox(xmin, ymin, zmin, xmax, ymax, zmax)
# Code by Chris Hennes (chennes).
# See https://forum.freecadweb.org/viewtopic.php?p=656362#p656362.
# Used to fix https://github.com/FreeCAD/FreeCAD/issues/10469.
def end_all_events():
class DelayEnder:
def __init__(self):
self.delay_is_done = False
def stop(self):
self.delay_is_done = True
ender = DelayEnder()
timer = QtCore.QTimer()
timer.timeout.connect(ender.stop)
timer.setSingleShot(True)
timer.start(100) # 100ms (50ms is too short) timer guarantees the loop below runs at least that long
while not ender.delay_is_done:
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents)
## @}