DecRef the model, but only if it was created in this instance of the view.

This commit is contained in:
Robin Dunn
2018-03-20 13:43:33 -07:00
parent 0a6b77efe2
commit a283339521

View File

@@ -245,11 +245,18 @@ class TestPanel(wx.Panel):
# Create an instance of our model...
if model is None:
self.model = MyTreeListModel(data, log)
newModel = True # it's a new instance so we need to decref it below
else:
self.model = model
newModel = False
# Tell the DVC to use the model
print("*** ref count: {}".format(self.model.GetRefCount()))
self.dvc.AssociateModel(self.model)
print("*** ref count: {}".format(self.model.GetRefCount()))
if newModel:
self.model.DecRef()
print("*** ref count: {}".format(self.model.GetRefCount()))
# Define the columns that we want in the view. Notice the
# parameter which tells the view which column in the data model to pull