Hi,
in the application, which I’m currently developing (as part of my work), the nested modal
dialogs are used in order to navigate linked data entries.
We have started using the application in production, and during the usage, the application gets crashes several time per day with following C++ assertion failure:
wx._core.wxAssertionError: C++ assertion ""IsRunning()"" failed at ..\..\src\common\evtloopcmn.cpp(92) in wxEventLoopBase::Exit(): Use ScheduleExit() on not running loop
(Under nested Modal Dialog I mean a modal dialog, which is called from event handler of another modal dialog)
This failure is happening inside on CharHook handler with following code:
def OnHookHandler(evt: wx.KeyEvent, dialog: wx.Dialog) -> None:
if evt.GetKeyCode() == wx.WXK_ESCAPE:
print(f"Trying to close {dialog=}")
dialog.EndModal(wx.ID_CANCEL)
else:
evt.Skip()
which is bind to the handle EVT_CHAR_HOOK inside dialog as follows:
self.Bind(wx.EVT_CHAR_HOOK, partial(OnHookHandler, dialog=self))
I should mention that this exception happens not every time, when dialog get closed, but at least several times per day during intensive usage of the application.
When looking at logs, I’m able to observe, that in case of crashes, OnHookHandler for the modal dialog, which was opened first (which should be in background) is called before hook handler of modal dialog, which is currently active, which, in turn, leads to the described C++ assertion failure.
So, my assumption is, that ESC handler for the “background” modal dialog is getting called, although other modal dialog is currently active
The version of the wxPython is 4.1.1
Is there a way to prevent such failures from happening?
Many thanks in advance
Serhiy Yevtushenko