Skip to content

Commit 774c3c6

Browse files
CQ reload fix (#359)
* Try to reproduce the error * Try to fix unrelated failure * Fix reloading
1 parent 56ddbf3 commit 774c3c6

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

cq_editor/cq_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def reload_cq():
118118
reload(cq.types)
119119
reload(cq.occ_impl.geom)
120120
reload(cq.occ_impl.shapes)
121+
reload(cq.occ_impl.shapes)
121122
reload(cq.occ_impl.importers.dxf)
122123
reload(cq.occ_impl.importers)
123124
reload(cq.occ_impl.solver)

tests/test_app.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@
7979
code_nested_bottom = """a=1
8080
"""
8181

82+
code_reload_issue = """wire0 = cq.Workplane().lineTo(5, 5).lineTo(10, 0).close().val()
83+
solid1 = cq.Solid.extrudeLinear(cq.Face.makeFromWires(wire0), cq.Vector(0, 0, 1))
84+
r1 = cq.Workplane(solid1).translate((10, 0, 0))
85+
"""
86+
8287
def _modify_file(code, path="test.py"):
8388
with open(path, "w", 1) as f:
8489
f.write(code)
@@ -237,6 +242,20 @@ def test_render(main):
237242
qtbot.wait(100)
238243
assert(obj_tree_comp.CQ.child(0).text(0) == 'test')
239244
assert('test' in log.toPlainText().splitlines()[-1])
245+
246+
# cq reloading check
247+
obj_tree_comp._toolbar_actions[0].triggered.emit()
248+
assert(obj_tree_comp.CQ.childCount() == 0)
249+
250+
editor.set_text(code_reload_issue)
251+
debugger._actions['Run'][0].triggered.emit()
252+
253+
qtbot.wait(100)
254+
assert(obj_tree_comp.CQ.childCount() == 1)
255+
256+
debugger._actions['Run'][0].triggered.emit()
257+
qtbot.wait(100)
258+
assert(obj_tree_comp.CQ.childCount() == 1)
240259

241260
def test_export(main,mocker):
242261

0 commit comments

Comments
 (0)