Page 1 of 1

"Show Message Box" action, possible bug ?

PostPosted: Fri Sep 08, 2017 7:44 am
by Snowbird
Hi,

I recently found out that when you have a message box that is currently displayed, and if another instance displays a second message box, both message boxes are displayed correctly but EG freezes and throw this error :

Code: Select all
10:47:26  ERROR: Traceback (most recent call last) (0.5.0-rc4):
10:47:26  ERROR: File "C:\Program Files (x86)\EventGhost\plugins\EventGhost\ShowMessageBox.py", line 521, in onClose
10:47:26  ERROR: self.Destroy()
10:47:26  ERROR: File "wx\_core.pyc", line 9182, in Destroy
10:47:26  ERROR: PyAssertionError: C++ assertion "IsRunning()" failed at ..\..\src\common\evtloopcmn.cpp(83) in wxEventLoopBase::Exit(): Use ScheduleExit() on not running loop


This error is easy to reproduce, just create 2 instances of "show message box" action, manually run the first one with 20 seconds timeout, then run the second one with a trigger while the first one is still running, they will both show but you will see the error.

I know it's not something very common to want to display 2 message boxes at the same time, and most people can live with it, but for the sake of perfectness I'm reporting it :)

Have a good day !

Re: "Show Message Box" action, possible bug ?

PostPosted: Fri Sep 08, 2017 7:06 pm
by topix
Hmm, can't reproduce it. Can you copy and paste your test script here please.

Re: "Show Message Box" action, possible bug ?

PostPosted: Sat Sep 09, 2017 6:58 am
by Snowbird
Hi topix,

here's how I did it :
Image

there is a workaround, if you press on OK on the second message box, the error won't happen, but if you let both message boxes timeout (10 seconds), you will see the error, and EG will freeze.

As I said earlier it's not a big deal, I'm not sure it is a bug, I think it's not supposed to be used the way I'm trying to.

Re: "Show Message Box" action, possible bug ?

PostPosted: Sat Sep 09, 2017 8:06 pm
by topix
Well i'm interested if i can reproduce it, but wasn't able. As said, can you please copy and paste your macros here (put in a Code block), because i want to have the exact same settings for the message boxes and that makes it easier than a screenshot.

Re: "Show Message Box" action, possible bug ?

PostPosted: Sun Sep 10, 2017 7:08 am
by Snowbird
sure, here it is :

Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="0.5.0-rc4">
    <Folder Name="Testing" XML_Guid="{8928B215-3001-44B5-9343-A6633080E732}" Expanded="True">
        <Macro Name="Triggers" XML_Guid="{B3A5D930-27AD-4CAF-9A3C-79ECE7DA80B3}" Expanded="True">
            <Action XML_Guid="{B3DCB770-D161-455D-8F75-D5B360286C17}">
                EventGhost.TriggerEvent(u'box1', 0.0)
            </Action>
            <Action XML_Guid="{B3DCB770-D161-455D-8F75-D5B360286C17}">
                EventGhost.TriggerEvent(u'box2', 3.0)
            </Action>
        </Macro>
        <Macro Name="Display Message Box 1" XML_Guid="{D7C4886C-4682-4466-80A0-F788FA846F7A}" Expanded="True">
            <Event Name="Main.box1" XML_Guid="{D537D24F-0629-496F-8C4D-B020F56E2783}" />
            <Action XML_Guid="{47740D0B-DFF4-48F3-9AC8-2EC9975404FD}">
                EventGhost.ShowMessageBox(u'MESSAGE BOX 1', u'BOX 1', u'msg.box.1', u'{eg.Utils.time.strftime("%d/%m/%Y %H:%M:%S")}', False, 28736, 1, 10)
            </Action>
        </Macro>
        <Macro Name="Display Message Box 2" XML_Guid="{43E533EA-4637-4E45-A8C3-786D2D523044}" Expanded="True">
            <Event Name="Main.box2" XML_Guid="{3F9678E2-26E6-422B-BC5D-9B190DADF7C5}" />
            <Action XML_Guid="{47740D0B-DFF4-48F3-9AC8-2EC9975404FD}">
                EventGhost.ShowMessageBox(u'MESSAGE BOX 2', u'BOX 2', u'msg.box.2', u'{eg.Utils.time.strftime("%d/%m/%Y %H:%M:%S")}', False, 28736, 1, 10)
            </Action>
        </Macro>
    </Folder>
</EventGhost>

Re: "Show Message Box" action, possible bug ?

PostPosted: Sun Sep 10, 2017 5:51 pm
by topix
Thanks. Now i'm able to reproduce it. It has something to do with both MessageBoxes being modal and that the first displayed box should be closed before the second one. If the last one is closed before the previous one, it works.

the wx widgets subsystem works with an EventLoop. A modal dialog creates a new temp eventloop. Only one can be active, so the main eventloop is deactivated. Now the second dialog again creates a new temp eventloop which deactivates the first temp eventloop. If now the first dialog should be closed, the event can't be processed, because the eventloop for this dialog is deactivated.

I've spent some time, but wasn't able to find a solution other then to make the dialog not modal.

Re: "Show Message Box" action, possible bug ?

PostPosted: Sun Sep 10, 2017 6:29 pm
by Snowbird
Thank you for looking into it, but honestly don't waste your time on this, it's not something very disturbing, I just wanted to report it in case there was an "easy" fix.

Re: "Show Message Box" action, possible bug ?

PostPosted: Sun Sep 10, 2017 7:16 pm
by kgschlosser
How you would fix this i think is to make the second modal a child of the first modal. Or you would have to create a new frame that you would set the style so it would not show in the task bar and call Set Transparent(0) and use that "invisible frame" as the parent for the modal.

Or use ctypes to make the dialog.