Discussion:
Resizable modal-dialog with Control having wxGrid-child and focus in cell freezes on close
Peter Böhm
2014-06-04 15:18:30 UTC
Permalink
Hello,

after upgrade from wx-2.9.5 to 3.0.0 I stumbled upon the mentioned issue
in our applications.

To verify that the problem is not related to code of our application I
used a clean wxWidgets installation with no changes to setup.h and a
modified minimal-sample. Unicode and non-unicode builds were tested.

The modification to minimal.cpp (see attachment) consists of one
test-control derived from wxWindow and a test-dialog derived from
wxDialog. The native wxGrid ist created in the control's constructor and
the control is created in the dialog's constructor. The dialog is shown
modal in OnAbout previous to the wxMessageBox() call.

When minimal is started a click on Help->About opens the test-dialog
displaying the grid (just one cell in this case). After closing the
test-dialog the familiar about-box is shown. Well behavior until now.
Open the test-dialog again and now click into the cell. Then trying to
close the dialog will lead in a nonrespondent application.

By tracing through the wxWidgets code I found that within the dialogs
event-loop the call to ::PeekMessage() doesn't return. Here I got lost
and that's why I call the list. I guess this could by a bug within
wxWidgets. This is no weird code, isn't it?

There is no problem in case of showing the dialog non-modal or replacing
the wxGrid by a wxTextCtrl or creating the grid directly in the dialog's
ctor. For verifying this the code offers #if switches.

My system:
Win-7
mingw with gcc-4.7.2
wxWidgets-3.0.0 build using
mingw32-make -j 4 -f makefile.gcc BUILD=release UNICODE=0 SHARED=0
MONOLITHIC=1

I hope someone has any clue...
Peter
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-06-04 23:18:48 UTC
Permalink
On Wed, 04 Jun 2014 17:18:30 +0200 Peter Böhm wrote:

PB> after upgrade from wx-2.9.5 to 3.0.0 I stumbled upon the mentioned issue
PB> in our applications.
PB>
PB> To verify that the problem is not related to code of our application I
PB> used a clean wxWidgets installation with no changes to setup.h and a
PB> modified minimal-sample. Unicode and non-unicode builds were tested.

Thanks for the nice example reproducing the problem, this really helps a
lot!

PB> When minimal is started a click on Help->About opens the test-dialog
PB> displaying the grid (just one cell in this case). After closing the
PB> test-dialog the familiar about-box is shown. Well behavior until now.
PB> Open the test-dialog again and now click into the cell. Then trying to
PB> close the dialog will lead in a nonrespondent application.

Notice that I initially read this as meaning that the bug happened only
when showing the dialog the second time, but actually it happens the first
time too if you click on the cell.

PB> By tracing through the wxWidgets code I found that within the dialogs
PB> event-loop the call to ::PeekMessage() doesn't return. Here I got lost
PB> and that's why I call the list. I guess this could by a bug within
PB> wxWidgets. This is no weird code, isn't it?

Yes, this is a bug inside wxWidgets or even inside Windows itself, because
actually what happens is that default dialog proc hangs in an infinite loop
user32.dll!***@8() + 0x4a bytes
user32.dll!***@24() + 0x15a9 bytes
user32.dll!***@16() + 0x29 bytes
user32.dll!***@20() + 0x23 bytes
user32.dll!***@32() + 0xb7 bytes
user32.dll!***@24() + 0x5e bytes
user32.dll!***@20() + 0x1b bytes
minimal.exe!wxWindow::MSWDefWindowProc(unsigned int nMsg=0x00000018, unsigned int wParam=0x00000000, long lParam=0x00000000) Line 2270 + 0x27 bytes C++
... normal wxDialog::Hide() call in upper frames ...

and it never leaves _xxxRemoveDefaultButton().

The trouble is that I don't know how to fix this :-( It looks like the
existence of the in place edit control in the grid wreaks havoc with the
dialog manager logic somehow. So we need to cancel grid editor before
hiding the dialog but while this provides an idea for workaround in your
code, it can't be really done inside wxWidgets itself. And right now I
don't really see what else to do.

Could you please open a Trac ticket attaching your patch to it? I'll try
to return to it later, hoping I have some new idea about how to fix this.

Thanks,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Peter Böhm
2014-06-10 09:17:05 UTC
Permalink
Thanks a lot for your reply and sorry for not answering right away but I
wasn't able to do so.
Post by Vadim Zeitlin
PB> When minimal is started a click on Help->About opens the test-dialog
PB> displaying the grid (just one cell in this case). After closing the
PB> test-dialog the familiar about-box is shown. Well behavior until now.
PB> Open the test-dialog again and now click into the cell. Then trying to
PB> close the dialog will lead in a nonrespondent application.
Notice that I initially read this as meaning that the bug happened only
when showing the dialog the second time, but actually it happens the first
time too if you click on the cell.
No, no this is not dependent on any open/close/click order, I guess. I
just wanted at first to show an open/close without any problem and than
secondly the way to produce the issue. The first open of the dialog
follows an immediate close without touching the cell. You can repeat
this without any problem. I liked to point out that touching the cell is
the trigger to the problem.
Post by Vadim Zeitlin
and it never leaves _xxxRemoveDefaultButton().
The trouble is that I don't know how to fix this :-( It looks like the
existence of the in place edit control in the grid wreaks havoc with the
dialog manager logic somehow. So we need to cancel grid editor before
hiding the dialog but while this provides an idea for workaround in your
code, it can't be really done inside wxWidgets itself. And right now I
don't really see what else to do.
But there seems to be a difference between wx-2.9.5 and wx-3.0.0
concerning this behavior. So we could find a workaround in wx-2.9.5 code?
Post by Vadim Zeitlin
Could you please open a Trac ticket attaching your patch to it? I'll try
to return to it later, hoping I have some new idea about how to fix this.
Yes, I'm working on submitting a ticket...
Peter
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Loading...