Skip to content

Commit 5b6a188

Browse files
committed
Fix Multiple Drag and drop causing NotReturn Method Call
1 parent ee9c53d commit 5b6a188

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Flow.Launcher/ResultListBox.xaml.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ private void ListBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
9292
private Point start;
9393
private string path;
9494
private string query;
95+
// this method is called by the UI thread, which is single threaded, so we can be sloppy with locking
96+
private bool isDragging;
9597

9698
private void ResultList_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
9799
{
@@ -101,15 +103,16 @@ private void ResultList_PreviewMouseLeftButtonDown(object sender, MouseButtonEve
101103
path = result.Result.CopyText;
102104
query = result.Result.OriginQuery.RawQuery;
103105
start = e.GetPosition(null);
106+
isDragging = true;
104107
}
105-
106108
private void ResultList_MouseMove(object sender, MouseEventArgs e)
107109
{
108-
if (e.LeftButton != MouseButtonState.Pressed)
110+
if (e.LeftButton != MouseButtonState.Pressed|| !isDragging)
109111
{
110112
start = default;
111113
path = string.Empty;
112114
query = string.Empty;
115+
isDragging = false;
113116
return;
114117
}
115118

@@ -123,15 +126,16 @@ private void ResultList_MouseMove(object sender, MouseEventArgs e)
123126
|| Math.Abs(diff.Y) < SystemParameters.MinimumVerticalDragDistance)
124127
return;
125128

129+
isDragging = false;
130+
126131
var data = new DataObject(DataFormats.FileDrop, new[]
127132
{
128133
path
129134
});
130-
DragDrop.DoDragDrop((DependencyObject)sender, data, DragDropEffects.Move | DragDropEffects.Copy);
131-
132-
App.API.ChangeQuery(query, true);
133-
134-
e.Handled = true;
135+
136+
var effect = DragDrop.DoDragDrop((DependencyObject)sender, data, DragDropEffects.Move | DragDropEffects.Copy);
137+
if (effect == DragDropEffects.Move)
138+
App.API.ChangeQuery(query, true);
135139
}
136140
private void ResultListBox_OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
137141
{

0 commit comments

Comments
 (0)