Quellcode durchsuchen

LibGUI: Prevent multiple drag initiations while drag messages are passed

AnotherTest vor 4 Jahren
Ursprung
Commit
a2cfb7eb94
2 geänderte Dateien mit 9 neuen und 0 gelöschten Zeilen
  1. 8 0
      Libraries/LibGUI/AbstractView.cpp
  2. 1 0
      Libraries/LibGUI/AbstractView.h

+ 8 - 0
Libraries/LibGUI/AbstractView.cpp

@@ -288,6 +288,14 @@ void AbstractView::mousemove_event(MouseEvent& event)
 
     ASSERT(!data_type.is_null());
 
+    if (m_is_dragging)
+        return;
+
+    // An event might sneak in between us constructing the drag operation and the
+    // event loop exec at the end of `drag_operation->exec()' if the user is fast enough.
+    // Prevent this by just ignoring later drag initiations (until the current drag operation ends).
+    TemporaryChange dragging { m_is_dragging, true };
+
     dbg() << "Initiate drag!";
     auto drag_operation = DragOperation::construct();
 

+ 1 - 0
Libraries/LibGUI/AbstractView.h

@@ -186,6 +186,7 @@ private:
     bool m_activates_on_selection { false };
     bool m_multi_select { true };
     bool m_tab_key_navigation_enabled { false };
+    bool m_is_dragging { false };
 };
 
 }