Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: add delay in the Draft_Clone unit test #8363

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/Mod/Draft/drafttests/test_modification.py
Expand Up @@ -568,6 +568,27 @@ def test_clone(self):
_msg(" object: '{0}' ({1})".format(box.Shape.ShapeType, box.TypeId))

obj = Draft.make_clone(box)

# Code below by Chris Hennes.
# https://forum.freecadweb.org/viewtopic.php?p=656362#p656362
# This code is required because of the DiffuseColor workaround which
# reapplies the DiffuseColor with a delay. Without the code below the
# active document may get deleted beforehand resulting in an error.
if App.GuiUp:
from PySide import QtCore
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 timer guarantees the loop below runs at least that long
while not ender.delay_is_done:
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents)

_msg(" clone: '{0}' ({1})".format(obj.Proxy.Type, obj.TypeId))
self.assertTrue(obj, "'{}' failed".format(operation))
self.assertTrue(obj.hasExtension("Part::AttachExtension"),
Expand Down