File: Fix-crash-with-drag-and-drop-in-conversations-view.patch

package info (click to toggle)
geary 46.0-7
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 15,092 kB
  • sloc: javascript: 972; ansic: 722; sql: 247; xml: 183; python: 30; sh: 24; makefile: 23
file content (51 lines) | stat: -rw-r--r-- 2,504 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
From: Tux <tux314159@gmail.com>
Date: Sat, 20 Jul 2024 12:09:34 +0800
Subject: Fix crash with drag-and-drop in conversations view

(cherry picked from commit 1fb4d3b3d61e95275de795b3f4876f9aaa8b961f)
---
 .../conversation-list/conversation-list-view.vala  | 28 ++++++++++++----------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/client/conversation-list/conversation-list-view.vala b/src/client/conversation-list/conversation-list-view.vala
index 2db55d3..499ac99 100644
--- a/src/client/conversation-list/conversation-list-view.vala
+++ b/src/client/conversation-list/conversation-list-view.vala
@@ -658,22 +658,24 @@ public class ConversationList.View : Gtk.ScrolledWindow, Geary.BaseInterface {
 
         this.get_window().get_device_position(ctx.get_device(), out screen_x, out screen_y, out _modifier);
 
-        // If the user has a selection but drags starting from an unselected
-        // row, we need to set the selection to that row
         Row? row = this.list.get_row_at_y(screen_y + (int) this.vadjustment.value) as Row?;
-        if (row != null && !row.is_selected()) {
-            this.list.unselect_all();
-            this.list.select_row(row);
-        }
+        if (row != null) {
+            // If the user has a selection but drags starting from an unselected
+            // row, we need to set the selection to that row
+            if (!row.is_selected()) {
+                this.list.unselect_all();
+                this.list.select_row(row);
+            }
 
-        this.drag_widget = new Row(this.config, row.conversation, false);
-        this.drag_widget.width_request = row.get_allocated_width();
-        this.drag_widget.get_style_context().add_class("drag-n-drop");
-        this.drag_widget.visible = true;
+            this.drag_widget = new Row(this.config, row.conversation, false);
+            this.drag_widget.width_request = row.get_allocated_width();
+            this.drag_widget.get_style_context().add_class("drag-n-drop");
+            this.drag_widget.visible = true;
 
-        int hot_x, hot_y;
-        this.translate_coordinates(row, screen_x, screen_y, out hot_x, out hot_y);
-        Gtk.drag_set_icon_widget(ctx, this.drag_widget, hot_x, hot_y);
+            int hot_x, hot_y;
+            this.translate_coordinates(row, screen_x, screen_y, out hot_x, out hot_y);
+            Gtk.drag_set_icon_widget(ctx, this.drag_widget, hot_x, hot_y);
+        }
     }
 
     private void on_drag_end(Gdk.DragContext ctx) {