Re: Error closing dialog after editing grid
ioprst <[email protected]>
| Newsgroups | gmane.comp.python.wxpython |
|---|---|
| Message-ID | <[email protected]> |
Yes. Clearing links solves the problem that occurs when closing a dialog.
But it creates other problems when re-editing a cell.
class StatePanel(wx.Panel):
def __init__(self, parent, states):
...
self.grid = CustomGrid(self, size=(-1, 100))
self.grid.Bind(wx.EVT_WINDOW_DESTROY, self.OnGridDestroy)
...
def OnGridDestroy(self, event):
# self.table._updateColAttrs(self.grid)
for row in range(self.table.GetNumberRows()):
for col in range(self.table.GetNumberCols()):
editor = self.grid.GetCellEditor(row, col)
renderer = self.grid.GetCellRenderer(row, col)
print(f'Ref[{row}; {col}] = {editor.RefCount}; '
f'{renderer.RefCount}')
while editor.RefCount != 1:
editor.DecRef()
renderer.DecRef()
print('-----------------------------------------')
event.Skip()
Traceback (most recent call last):
File "D:\project\designer\widgets\StatePanel.py", line 238, in
OnGridDestroy
editor = self.grid.GetCellEditor(row, col)
wx._core.wxAssertionError: C++ assertion "firstHandler != this" failed at
..\..\src\common\wincmn.cpp(1461) in wxWindowBase::PopEventHandler():
cannot pop the wxWindow itself
The only solution that helps is to assign a new editor for each cell before
destroying the grid.
среда, 6 ноября 2019 г., 19:44:16 UTC+3 пользователь Robin Dunn написал:
>
> On Wednesday, November 6, 2019 at 12:13:47 AM UTC-8, ioprst wrote:
>>
>> The program ends with an error
>>
>> Exception ignored in: 'garbage collection'
>> wx._core.wxAssertionError: C++ assertion "firstHandler != this" failed at
>> ..\..\src\common\wincmn.cpp(1461) in wxWindowBase::PopEventHandler():
>> cannot pop the wxWindow itself
>> Fatal Python error: unexpected exception during garbage collection
>>
>
> Does this help? (Especially the 4th bullet point.)
>
>
> https://discuss.wxpython.org/t/howto-deal-with-reference-counts-in-grid-classes/34126
>
>
> --
> Robin
>
>
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/bd2854b7-a79f-475c-8bd3-51bec408b417%40googlegroups.com.