[Fixed] Bug #2532: Draft line not working if document closed while tool is open

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

[Fixed] Bug #2532: Draft line not working if document closed while tool is open

Post by Kunda1 »

issue #2532: Draft line not working if document closed while tool is open
Description
I got this exception:

Code: Select all

Running the Python command 'Draft_Line' failed:
Traceback (most recent call last):
  File "C:\Users\more10.HOLISTICODE\Downloads\FreeCAD_0.17.7447_x64_dev_win\Mod\Draft\DraftTools.py", line 440, in Activated
    Creator.Activated(self,name)
  File "C:\Users\more10.HOLISTICODE\Downloads\FreeCAD_0.17.7447_x64_dev_win\Mod\Draft\DraftTools.py", line 423, in Activated
    DraftTool.Activated(self)
  File "C:\Users\more10.HOLISTICODE\Downloads\FreeCAD_0.17.7447_x64_dev_win\Mod\Draft\DraftTools.py", line 223, in Activated
    FreeCAD.activeDraftCommand.finish()
  File "C:\Users\more10.HOLISTICODE\Downloads\FreeCAD_0.17.7447_x64_dev_win\Mod\Draft\DraftTools.py", line 457, in finish
    old = self.obj.Name
Cannot access attribute 'Name' of deleted object

Steps To Reproduce
Open draft line tool in an unsaved document.
Close the document.
Open another document.
Open the Draft.line tool

Probably goes away with a restart

Additional Information

Code: Select all

OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.7447 (Git)
Build type: Release
Branch: master
Hash: 898bd8bb4cbe2c9b26aa6c1f7362e48752a3e4de
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
@yorik writes:
Indeed the Draft task panel is not closed when closing a document. The same happens with other task panels (for ex. Part Fillet). One that works correctly is the sketcher, not sure what is done differently there...

I think maybe we could always close the task panel when closing a document.
Last edited by Kunda1 on Thu Jun 29, 2017 4:18 pm, edited 1 time in total.
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Bug #2532: Draft line not working if document closed while tool is open

Post by Kunda1 »

Abdullah wrote:ping
Per @yorik this works correctly with Sketcher WB but not other WBs. @abdullah do you mind weighing in?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Bug #2532: Draft line not working if document closed while tool is open

Post by yorik »

Actually having a task panel open should prevent from closing the document. I might have forgotten something there, will have a look...
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Bug #2532: Draft line not working if document closed while tool is open

Post by Kunda1 »

yorik wrote: Thu Jun 15, 2017 1:45 pm Actually having a task panel open should prevent from closing the document. I might have forgotten something there, will have a look...
Ping
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Bug #2532: Draft line not working if document closed while tool is open

Post by yorik »

I just fixed the issue now. Curiously adding a isAllowedAlterDocument() that retuns False in the task dialog should do the same as in the sketcher (prohibit to close the document while the dialog is open) but it doesn't work. Couldn't find out yet why.

In any case, I added stronger tests in Draft's functions, so they can be closed after the document has been changed or closed without causing errors.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: [Fixed] Bug #2532: Draft line not working if document closed while tool is open

Post by Kunda1 »

Thanks for git commit 74e794002464b5230966bae86ce84409b0ee74fc. Marking thread as fixed and closing ticket.
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply