http://bugs.winehq.org/show_bug.cgi?id=27502
Summary: app freezes when WM_KILLFOCUS creates modal dialog Product: Wine Version: unspecified Platform: All OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: user32 AssignedTo: wine-bugs@winehq.org ReportedBy: efrias@syncad.com
Created an attachment (id=35159) --> (http://bugs.winehq.org/attachment.cgi?id=35159) simple example which produces the error
When a program brings up a modal dialog box in response to a WM_KILLFOCUS message, the program will freeze. I've attached a simple test case, all boilerplate except for: case WM_KILLFOCUS: MessageBox(hWnd, _T("Killing Focus"), _T("Note"), MB_OK); in the main event loop. If you run the program and then give focus to another application, the messagebox will pop up and then the program will become unresponsive.
What is happening is: - x11drv gets a FocusOut event and calls the event handler, which ends up SendMessage-ing a WM_KILLFOCUS to the program. - The programs's code creates a modal dialog like the MessageBox above, and enters the dialog's event loop, which winds up calling GetMessage which calls MsgWaitForMultipleObjectsEx to get more X11 events. - X11DRV_MsgWaitForMultipleObjectsEx executes this: if (data->current_event) mask = 0; /* don't process nested events */ where data->current_event is true since we're still handling the FocusOut event. Since we're not processing nested events, we'll never be able to process the usual events like keys or mouse events which could exit this nested event loop.
This type of error occurs in a few places in our application, where a WM_KILLFOCUS message to an edit box triggers some input validation and displays an error on failure. This works correctly in the normal case, where the user tabs out or clicks on another control in the dialog box containing the edit control -- since everything stays in the same top-level window, there is no FocusOut event from X11 and the WM_KILLFOCUS is generated internally by wine in response to, say, a KeyEvent. I think these key or mouse events are just posted to the windows message queue, and the X11 event handler has already exited by the time the application gets around to processing the ensuing WM_KILLFOCUS. But in the case where focus is lost by clicking outside the dialog containing the edit control, the WM_KILLFOCUS is generated by the FocusOut handler which is still executing, and we lock up.
I suspect this is related to bug 11595 "Notepad++ freezes if native application changes a file it has open (dogfood)". My guess is in that case, a FocusIn event triggers something like a WM_ACTIVATE, in which notepad++ notices a file is changed and displays a messagebox asking if you want to reload. Since wine is still processing the FocusIn event, the modal message loop's call to MsgWaitForMultipleObjectsEx will never process any useful events because it's a nested event. Our application's built-in text editor has this same problem.
I don't understand the event handling code well enough to propose a solution. As a test, I allowed nested event processing and it solved the problem without introducing any obvious errors, but I'm sure that check was in there for a reason. It's probably better to keep the application code from being executed from inside the event handler, if that's possible.
Note: this bug was also posted as a message to wine-devel here: http://www.winehq.org/pipermail/wine-devel/2011-June/090652.html
http://bugs.winehq.org/show_bug.cgi?id=27502
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, testcase
http://bugs.winehq.org/show_bug.cgi?id=27502
Alex Bradbury asb@asbradbury.org changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |asb@asbradbury.org
http://bugs.winehq.org/show_bug.cgi?id=27502
Dmitry Timoshkov dmitry@baikal.ru changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|user32 |-unknown Platform|All |Other Version|unspecified |1.3.22
http://bugs.winehq.org/show_bug.cgi?id=27502
Luke Bratch l_bratch@yahoo.co.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |l_bratch@yahoo.co.uk
http://bugs.winehq.org/show_bug.cgi?id=27502
Vincent Povirk madewokherd@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|-unknown |winex11.drv
http://bugs.winehq.org/show_bug.cgi?id=27502
Vincent Povirk madewokherd@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |source
http://bugs.winehq.org/show_bug.cgi?id=27502
Bruno Jesus 00cpxxx@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW CC| |00cpxxx@gmail.com Ever Confirmed|0 |1
--- Comment #1 from Bruno Jesus 00cpxxx@gmail.com 2013-02-24 12:03:53 CST --- Confirmed in wine 1.5.24.
http://bugs.winehq.org/show_bug.cgi?id=27502
Alan Wake stalkerboi@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |stalkerboi@gmail.com
--- Comment #2 from Alan Wake stalkerboi@gmail.com 2013-07-09 00:44:48 CDT --- I can confirmed this bug still exist in wine-1.6-rc4
http://bugs.winehq.org/show_bug.cgi?id=27502
Jerome Leclanche adys.wh@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |adys.wh@gmail.com
https://bugs.winehq.org/show_bug.cgi?id=27502
Marco klasse@partyheld.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |klasse@partyheld.de
https://bugs.winehq.org/show_bug.cgi?id=27502
--- Comment #3 from Marco klasse@partyheld.de --- Just a speculation: This could be also related to bug 33068 "PDF-XChange Viewer 2.5.x (32-bit and 64-bit) crashes when trying to save changes/annotations to PDF file".
PDF-XChange *Viewer* crashes while the saving progress window (showing moving bars) is there. While PDF-XChange *Editor* saves without showing such a window and doesn't crash.
Wine 1.6.2 (Linux Mint 17.1 (Rebecca; based on Ubuntu 14.04 LTS) MATE, 32 bit)
https://bugs.winehq.org/show_bug.cgi?id=27502
Louis Lenders xerox.xerox2000x@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |xerox.xerox2000x@gmail.com
--- Comment #4 from Louis Lenders xerox.xerox2000x@gmail.com --- Created attachment 60938 --> https://bugs.winehq.org/attachment.cgi?id=60938 compiled executable
Still present wine-3,4
Attached compiled executable from source in comment 1
https://bugs.winehq.org/show_bug.cgi?id=27502
Vijay Kamuju infyquest@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |infyquest@gmail.com
--- Comment #5 from Vijay Kamuju infyquest@gmail.com --- Can you please re-check as the test executable does not freeze when 'OK' is clicked in the dialog box in wine 4.x
https://bugs.winehq.org/show_bug.cgi?id=27502
--- Comment #6 from Esme Povirk madewokherd@gmail.com --- Tested in Wine 6.0-rc4, it does hang.