After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 786121 - Crash when using OLE2 DnD
Crash when using OLE2 DnD
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Backend: Win32
3.22.x
Other Windows
: Normal normal
: ---
Assigned To: gtk-win32 maintainers
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2017-08-10 18:51 UTC by LRN
Modified: 2018-05-02 18:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GDK W32: More flexible modal operation mode (7.92 KB, patch)
2017-08-11 07:05 UTC, LRN
none Details | Review
GDK W32: More flexible modal operation mode v2 (7.96 KB, patch)
2017-10-02 14:41 UTC, LRN
committed Details | Review

Description LRN 2017-08-10 18:51:43 UTC
How to reproduce:
* Run gtk3-demo
* Select IconView->Drag&Drop demo
* Drag and drop iconview elements
* Observe that everything works correctly
* Run * GDK_WIN32_USE_EXPERIMENTAL_OLE2_DND=1 gtk3-demo
* Select IconView->Drag&Drop demo
* Try to drag iconview elements

Expected result:
* Doesn't crash

Actual result:
* Crashes with a message:
Gdk:ERROR:gdkevents-win32.c:1760:_gdk_win32_end_modal_call: assertion failed: (_modal_operation_in_progress)

What happens:
My code for unrelated issue added handling for WM_CAPTURECHANGED. Turns out, this message is also sent during OLE2 DnD loop. My code cancels the modal operation in response to this message...and then the OLE2 DnD code tries to cancel it again, failing an assertion

Proposed fix:
The first thing that comes to my head is to differentiate between different modal operations (say, by changing the _modal_operation_in_progress variable from gboolean to an enum) and don't end DnD op on WM_CAPTURECHANGED.
Comment 1 LRN 2017-08-11 07:05:32 UTC
Created attachment 357378 [details] [review]
GDK W32: More flexible modal operation mode

Instead of using a boolean to indicate a modal operation being in progress,
use a set of flags, and allow these to be set and unset independently.

Specifically, this allows WM_CAPTURECHANGED handler to only act when a drag-move or
drag-resize modal operation is in progress, and ignore DND (which can also cause
WM_CAPTURECHANGED to be posted). This avoids a crash due to assertion failure when
OLE2 DND code tries to end a modal operation that was already ended by the WM_CAPTURECHANGED
handler.

This fixes the crash, but OLE2 DnD still seems to be broken (why - that's another matter
entirely; i'm not sure whether any of the changes i've ever done contributed to that fact).
Comment 2 Ignacio Casal Quinteiro (nacho) 2017-08-11 08:04:40 UTC
Review of attachment 357378 [details] [review]:

Looks good to me. Just fix the comment pointed out.

::: gdk/win32/gdkprivate-win32.h
@@ +345,3 @@
 
+typedef enum {
+  GDK_WIN32_MODAL_OP_NONE = 0x0,

For consistency let's use 0, 0 << 1, 1 << 1 etc
Comment 3 LRN 2017-10-02 14:41:10 UTC
Created attachment 360781 [details] [review]
GDK W32: More flexible modal operation mode v2

v2:
* Use bitshifts to define the op masks
* Added a missing break statement
Comment 4 Ignacio Casal Quinteiro (nacho) 2017-10-04 09:42:22 UTC
Review of attachment 360781 [details] [review]:

Fine for me, see the comment though

::: gdk/win32/gdkprivate-win32.h
@@ +350,3 @@
+  GDK_WIN32_MODAL_OP_MENU = 0x1 << 2,
+  GDK_WIN32_MODAL_OP_DND  = 0x1 << 3
+} GdkWin32ModalOpKind;

I'd call it Flags intead of Kind for consistency, and do not use 0x,
Comment 5 LRN 2017-11-25 15:46:35 UTC
Comment on attachment 360781 [details] [review]
GDK W32: More flexible modal operation mode v2

Attachment 360781 [details] pushed as 87103b9 - GDK W32: More flexible modal operation mode
Comment 6 GNOME Infrastructure Team 2018-05-02 18:50:31 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/876.