From a28333952148f10f2acc51ebd0371ce9cf2a4eca Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 20 Mar 2018 13:43:33 -0700 Subject: [PATCH] DecRef the model, but only if it was created in this instance of the view. --- demo/DVC_DataViewModel.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/demo/DVC_DataViewModel.py b/demo/DVC_DataViewModel.py index 1724ee50..a49305f7 100644 --- a/demo/DVC_DataViewModel.py +++ b/demo/DVC_DataViewModel.py @@ -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