Recapturing the mouse in the same window using wxAuiNotebook

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
tiberiu.chibici
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Nov 16, 2017 2:32 pm

Recapturing the mouse in the same window using wxAuiNotebook

Post by tiberiu.chibici »

Hello,

I am having an issue in GTK with the wxAuiNotebook control; I basically have a window with several nested wxAuiNotebooks. Occasionally, I am getting the following error message:

Code: Select all

ASSERT INFO:
./src/common/wincmn.cpp(3301): assert "!wxMouseCapture::IsInCaptureStack(this)" failed in CaptureMouse(): Recapturing the mouse in the same window?

BACKTRACE:
[1] wxWindowBase::CaptureMouse() /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/common/wincmn.cpp:3300
[2] wxAuiTabCtrl::OnLeftDown(wxMouseEvent&) /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/aui/auibook.cpp:1041
[3] wxAppConsoleBase::HandleEvent(wxEvtHandler*, void (wxEvtHandler::*)(wxEvent&), wxEvent&) const /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/common/appbase.cpp:658
[4] wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/common/appbase.cpp:669
[5] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/common/event.cpp:1381
[6] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/common/event.cpp:989
[7] wxEvtHandler::TryHereOnly(wxEvent&) /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/common/event.cpp:1578
[8] wxEvtHandler::TryBeforeAndHere(wxEvent&) /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./include/wx/event.h:3656
[9] wxEvtHandler::ProcessEventLocally(wxEvent&) /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/common/event.cpp:1511
[10] wxEvtHandler::ProcessEvent(wxEvent&) /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/common/event.cpp:1484
[11] wxEvtHandler::SafelyProcessEvent(wxEvent&) /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/common/event.cpp:1602
[12] wxWindowBase::HandleWindowEvent(wxEvent&) const /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/common/wincmn.cpp:1535
[13] wxWindow::GTKProcessEvent(wxEvent&) const /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/gtk/window.cpp:1419
[14] gtk_window_button_press_callback /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/gtk/window.cpp:1570
[15] g_closure_invoke
[16] g_signal_emit_valist
[17] g_signal_emit
[18] gtk_propagate_event
[19] gtk_main_do_event
[20] g_main_context_dispatch
[21] g_main_loop_run
[22] gtk_main
[23] wxGUIEventLoop::DoRun() /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/gtk/evtloop.cpp:63
[24] wxEventLoopBase::Run() /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/common/evtloopcmn.cpp:76
[25] wxAppConsoleBase::MainLoop() /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/common/appbase.cpp:380
[26] wxAppConsoleBase::OnRun() /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/common/appbase.cpp:302
[27] wxAppBase::OnRun() /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/common/appcmn.cpp:312
[28] wxEntry(int&, char**) /Phenix/branches/Phenix64/src/Base/ExternalTools/wxWidgets-3.1.0.src/./src/common/init.cpp:503
[29] main /Phenix/branches/Phenix64/src/UserInterface/PhenixApp/main.cc:16
[30] __libc_start_main
[31] _start
After the error message, the window freezes completely.

The only information I found related to this issue is this old ticket: https://trac.wxwidgets.org/ticket/16647
Has anyone else had this issue? Could this be a regression of the ticket?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Recapturing the mouse in the same window using wxAuiNotebook

Post by ONEEYEMAN »

Hi,
Are you capturing the mouse anywhere in your code?
What version of GTK+ do you use?
Can you reproduce the issue in auidemo sample?

Thank you.
tiberiu.chibici
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Nov 16, 2017 2:32 pm

Re: Recapturing the mouse in the same window using wxAuiNotebook

Post by tiberiu.chibici »

Thank you for the response.

I forgot to mention I'm running wxWidgets 3.1 on a CentOS 7.4 x64 machine, in a KDE 4 desktop environment.
My wx configuration options are:

Code: Select all

./configure --with-gtk=2 --enable-monolithic --enable-debug --enable-stl --disable-shared --disable-dependency-tracking --disable-precomp-headers --disable-sockets --disable-unicode
The issue appeared after porting the project from wxWidgets 2.8
Are you capturing the mouse anywhere in your code?
I found 2 controls in the project which seem to capture the mouse. They are pretty similar to these two:
https://github.com/wxWidgets/wxWidgets/ ... stctrl.cpp
https://github.com/wxWidgets/wxWidgets/ ... eectlg.cpp
I think they are based on an older version of these controls (first svn entry is from may 2009, the file's header seems to indicate they are from around november 2006). I can't tell how much they are modified from the original or not, as the svn history stops at 2009.

Now that I think about it, these ancient controls might be the causing the problems. I will try to investigate further (I'm thinking of commenting the CaptureMouse() lines, to see if the issue still appears).
What version of GTK+ do you use?
I'm using gtk2-2.24.31-1.el7.x86_64
Can you reproduce the issue in auidemo sample?
The issue appears pretty randomly, so it's pretty hard to reproduce. I haven't managed to reproduce it yet in the demo, but if this changes I will let you know.
tiberiu.chibici
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Nov 16, 2017 2:32 pm

Re: Recapturing the mouse in the same window using wxAuiNotebook

Post by tiberiu.chibici »

I found a way to reproduce the issue (it's still intermittent, but with some trial and error can be reproduced), and after some further investigation, here is what I found:

First thing I did, I tried to trace the CaptureMouse and ReleaseMouse calls. The only place where CaptureMouse and ReleaseMouse are called are in wxAuiNotebook::OnLeftDown and wxAuiNotebook::OnLeftUp handlers. So the other controls which call CaptureMouse don't have anything to do with this (I mentioned these controls in my older posts).

When the issue happens, the left button up handler is not called at all (so ReleaseMouse is not called, which leads to the assertion error). By digging deeper and adding some printf's, I found that not even the gtk_window_button_release_callback function in /src/gtk/window.cpp is called.

What could cause the gtk button release callback to not be called at all? Could this be caused by something in my application? If you have any clue how I can investigate this further, I would really appreciate it.

PS: I still can't reproduce it in the AUI sample application. I tried modifying the sample to add some of the controls contained in that notebook page, but so far, I couldn't reproduce the issue. It would be nice to have a minimum example in which the issue can be reproduced.
tiberiu.chibici
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Nov 16, 2017 2:32 pm

Re: Recapturing the mouse in the same window using wxAuiNotebook

Post by tiberiu.chibici »

I found the culprit! :D

I noticed that there is a progress dialog displayed for a very brief amount of time when some of the tabs are opened.

I tried to reproduce the same thing with the sample app. So I hooked up to the wxEVT_AUINOTEBOOK_PAGE_CHANGED event (in MyFrame::CreateNotebook):

Code: Select all

   ctrl->Connect(wxEVT_AUINOTEBOOK_PAGE_CHANGED, 
            wxAuiNotebookEventHandler(MyFrame::TabsChanged),
            NULL,
            this);
In the handler, I display a progress dialog for a few seconds:

Code: Select all

void MyFrame::TabsChanged(wxAuiNotebookEvent& event)
{
    wxProgressDialog progressDialog(_T("Please Wait"),
                    _T("Loading Test Result List"),
                    100,    // range
                    this,   // parent
                    wxPD_CAN_ABORT | wxPD_APP_MODAL | wxPD_AUTO_HIDE | wxPD_SMOOTH
                    );

    for (int i = 0; i < 5; i++)
    {
        progressDialog.Pulse();
        usleep(1000 * 100);
    }
}
Now the issue reproduces every time.

Here is the complete code.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Recapturing the mouse in the same window using wxAuiNotebook

Post by ONEEYEMAN »

Hi,
Please open a ticket in the trac.wxwidgets.org.
Registration is easy - you will just have to wait for the approval from the wx core dev team (usually Vadim).

In the ticket just mention you GTK+ version and attach the patch to thew auidemo sample which will allow Vadim/Paul to reproduce the problem and hopefully find the solution. Do not attach the whole project - just the diff to the auidemo.

Now for the sake of completeness - can you try to build wx and the modified sample against GTK+3?

Thank you.
tiberiu.chibici
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Nov 16, 2017 2:32 pm

Re: Recapturing the mouse in the same window using wxAuiNotebook

Post by tiberiu.chibici »

Can confirm that issue reproduces with gtk 3 as well.

I'm currently working on creating the patch and submitting the ticket.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Recapturing the mouse in the same window using wxAuiNotebook

Post by ONEEYEMAN »

Hi,
Yes, that is "good" ;-)
Just mention the exact GTK+ version for both 2 and 3 in the ticket.

Thank you.
tiberiu.chibici
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Nov 16, 2017 2:32 pm

Re: Recapturing the mouse in the same window using wxAuiNotebook

Post by tiberiu.chibici »

Thanks for the help. Here is the link to the defect.
Post Reply