View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001067 | FreeCAD | Patch | public | 2013-03-25 12:20 | 2013-03-30 12:15 |
| Reporter | zappl | Assigned To | |||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | closed | Resolution | no change required | ||
| Product Version | trunk | ||||
| Fixed in Version | 0.14 | ||||
| Summary | 0001067: Workaround patch for deleting 'App::DocumentObjectGroupPython' objects from tree | ||||
| Description | 'App::DocumentObjectGroupPython' objects can't be deleted from object tree, e.g. by pressing the del key. On trying, the log gives me the following: Exception (Mon Mar 25 13:20:25 2013): 'NoneType' object has no attribute 'removeObjectsFromDocument' Stack Trace: Traceback (most recent call last): File "<string>", line 1, in <module> Reproduce it by: 1) >>> obj = App.ActiveDocument.addObject('App::DocumentObjectGroupPython') 2) Select object in tree 3) press del | ||||
| Additional Information | I tracked the problem down to ViewProviderDocumentObjectGroup::onDelete() @ ViewProviderDocumentObjectGroup.cpp. The python command string sent to doCommand() can't handle 'App::DocumentObjectGroupPython' objects. The question WHY is a good one, because "App.getDocument('xxx').getObject('yyy')" SHOULD just return the Python object named 'yyy'. AND, case of an 'App::DocumentObjectGroupPython', the object should well offer a method 'removeObjectsFromDocument' (according to App/DocumentObjectGroupPy.xml, right?) To me, it seems like the problem exists somewhere in the object typing of class DocumentPy. I noticed that 'DocumentPy::staticCallback_getObject()' manages to retrieve the right object, a 'DocumentObjectGroupPy', but down the road, it is treated as just a 'DocumentObjectPy', which doesn't have 'removeObjectsFromDocument'. For me (and my purely Python based project - an upcomming FreeCAD workspace, I guess ;-)) this is quite a blocker, since I need to have groups with custom properties. My problem is that I don't know how to fix it best, because I still don't have the big picture of all the C++ classes in FreeCAD. The best I can do here is to provide you this report and a patch for my hacky workaround. With this, you still face the problem for basic 'App::DocumentObjectGroupPython' objects: you just can't delete them ... However, it seems to works quite well in case you assign it a Proxy class, for which you implement the missing method 'removeObjectsFromDocument()'. I don't think this patch it good enough to get into master, but at least it might offer an interim solution for this problem. | ||||
| Tags | No tags attached. | ||||
| FreeCAD Information | |||||
|
2013-03-25 12:20
|
|
|
|
Have a look to the changes here http://free-cad.git.sourceforge.net/git/gitweb.cgi?p=free-cad/free-cad;a=blobdiff;f=src/App/DocumentObjectGroup.cpp;h=d6781d6be9d55aad32e62740f85d9c89bcf170d4;hp=1c16e0e51309b06085910fd077106bfd334c41a7;hb=ce0e6e5cef1022e9bb9e3e3275d17528b376d33f;hpb=9da66cbb0218f7566d2fd58ca1abddc47289d3b5 (and it the other files affected by this commit). The problem is simple: DocumentObjectGroup has a Python binding DocumentObjectGroupPy which implements the missing methods. And DocumentObjectGroupPython is a subclass of DocumentObjectGroup that provides the methods to add properties at runtime. However, its Python binding before the change was FeaturePythonPy that hasn't implemented the group methods. So, the main purpose of the commit was to make the Python binding also a template class so that we can conveniently make the sub-classes. So, I would say the latest git sources fixes your problem and makes your suggestions obsolete. Can you have a look please and report back? |
|
|
Hi Werner - sorry for the delay. I had some update probs mainly caused by my good old friends, the windows line endings. Is it just me or is there a funny mix within HEAD? - but anyway. Thanks a lot for your message and your changes. After some testing, it looks like they fix the issues mentioned above. So I think you can close this ticket. Thanks for your explainations, too - I guess, I've to dive deeper into python bindings to get a full grasp of these mechanisms. |
|
|
Hi Josef, yes this line ending stuff is slightly annoying. But that's due to the dual programming on Windows and Linux. I don't know of a good possibility to avoid it. So, will close this ticket :) |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2013-03-25 12:20 | zappl | New Issue | |
| 2013-03-25 12:20 | zappl | File Added: 0001-intermediate-fix-for-deleting-App-DocumentObjectGrou.patch | |
| 2013-03-28 12:58 | wmayer | Note Added: 0003011 | |
| 2013-03-29 17:11 | zappl | Note Added: 0003013 | |
| 2013-03-30 12:14 | wmayer | Note Added: 0003014 | |
| 2013-03-30 12:15 | wmayer | Status | new => closed |
| 2013-03-30 12:15 | wmayer | Resolution | open => no change required |
| 2013-03-30 12:15 | wmayer | Fixed in Version | => 0.14 |
FreeCAD