View Issue Details

IDProjectCategoryView StatusLast Update
0003564FreeCADBugpublic2018-08-25 14:34
ReporterDeepSOIC Assigned Towmayer  
Status closedResolutionfixed 
Product Version0.18 
Fixed in Version0.18 
Summary0003564: Python objects: updateData calls to proxy instance that should have been deleted
DescriptionWhen coding Lattice, I sometimes got strange viewprovider-related errors. Narrowed down the problem enough to reproduce from console.

forum thread:
Steps To Reproduce1. Create a new project
2. Copy-paste this to Py console:
class AppProxy(object):
    def __init__(self, cpp_app_object):
        cpp_app_object.addProperty('App::PropertyFloat', 'testprop')

class VPProxy(object):
    def __init__(self, cpp_vp):
        cpp_vp.Proxy = self
    def attach(self, cpp_vp):
        self.cpp_app_object = cpp_vp.Object
    def updateData(self, cpp_app_object, propname):
        if propname == 'testprop':
            n = self.cpp_app_object.Name #fails if cpp_app_object was deleted

def make():
    cpp_app_object = App.ActiveDocument.addObject('App::FeaturePython')

doc = App.ActiveDocument
doc.undo(); doc.openTransaction('make'); make(); doc.commitTransaction()
3. Recall and re-execute the last line of the above code. Keep doing it...
and after a few tries, an error pops up in report view:
Traceback (most recent call last):
File "<input>", line 10, in updateData
<type 'exceptions.ReferenceError'>: Cannot access attribute 'Name' of deleted object

Usually, it takes 3-20 attempts before an error pops up.
Additional InformationOS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.13935 (Git) <-- rather old one, I need to update
Build type: Release
Branch: master
Hash: cb133767464337e4b5c8589a1fe33b4d7dad7721
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: Russian/RussianFederation (ru_RU)
Tagsproxy, python feature, transactions, undo, viewprovider
FreeCAD Information

Issue History

Date Modified Username Field Change
2018-08-22 14:14 DeepSOIC New Issue
2018-08-22 14:33 DeepSOIC Tag Attached: python feature
2018-08-22 14:33 DeepSOIC Tag Attached: proxy
2018-08-22 14:33 DeepSOIC Tag Attached: undo
2018-08-22 14:33 DeepSOIC Tag Attached: transactions
2018-08-22 14:33 DeepSOIC Tag Attached: viewprovider
2018-08-22 15:28 wmayer Assigned To => wmayer
2018-08-22 15:28 wmayer Status new => assigned
2018-08-25 14:34 wmayer Status assigned => closed
2018-08-25 14:34 wmayer Resolution open => fixed
2018-08-25 14:34 wmayer Fixed in Version => 0.18
2018-08-25 14:34 wmayer Note Added: 0011650