summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-07-24 10:36:14 +0200
committerPřemysl Eric Janouch <p@janouch.name>2021-07-24 10:44:19 +0200
commit3102bc0cb9d84676ed400935883687d8a738c835 (patch)
treea1b2bbbc448dce9fb60b95701b3277c809f82a01
parent7f357cb7c8dde62ff9bea81fdc7060172a2cf75a (diff)
downloadlogdiag-3102bc0cb9d84676ed400935883687d8a738c835.tar.gz
logdiag-3102bc0cb9d84676ed400935883687d8a738c835.tar.xz
logdiag-3102bc0cb9d84676ed400935883687d8a738c835.zip
LdCategorySymbolView: work around a mysterious bug
We sometimes get a deselecting event when toying around with menus and then dragging. There might be a simpler reproducer.
-rw-r--r--liblogdiag/ld-category-symbol-view.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/liblogdiag/ld-category-symbol-view.c b/liblogdiag/ld-category-symbol-view.c
index e4f7e81..2f4e2d9 100644
--- a/liblogdiag/ld-category-symbol-view.c
+++ b/liblogdiag/ld-category-symbol-view.c
@@ -47,6 +47,7 @@ SymbolData;
* @path: path to the category within the library.
* @layout: (element-type SymbolData *): current layout of symbols.
* @preselected: currently preselected symbol.
+ * @dragged: currently dragged symbol.
*/
struct _LdCategorySymbolViewPrivate
{
@@ -54,6 +55,7 @@ struct _LdCategorySymbolViewPrivate
gchar *path;
GSList *layout;
SymbolData *preselected;
+ SymbolData *dragged;
};
enum
@@ -180,6 +182,7 @@ layout_destroy (LdCategorySymbolView *self)
g_slist_free (self->priv->layout);
self->priv->layout = NULL;
self->priv->preselected = NULL;
+ self->priv->dragged = NULL;
}
static GSList *
@@ -457,12 +460,12 @@ on_drag_data_get
LdCategorySymbolView *self;
self = LD_CATEGORY_SYMBOL_VIEW (widget);
- g_return_if_fail (self->priv->preselected != NULL);
+ g_return_if_fail (self->priv->dragged != NULL);
gtk_selection_data_set (selection_data,
gtk_selection_data_get_target (selection_data),
- 8, (guchar *) self->priv->preselected->path,
- strlen (self->priv->preselected->path));
+ 8, (guchar *) self->priv->dragged->path,
+ strlen (self->priv->dragged->path));
}
static void
@@ -474,6 +477,9 @@ on_drag_begin (GtkWidget *widget, GdkDragContext *ctx, gpointer user_data)
self = LD_CATEGORY_SYMBOL_VIEW (widget);
g_return_if_fail (self->priv->preselected != NULL);
+ /* Working around a mysterious bug where we /sometimes/ get deselected. */
+ self->priv->dragged = self->priv->preselected;
+
/* Some of the larger previews didn't work, and we have to get rid of
* the icon later when we're hovering above LdDiagramView anyway. */
pbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 1, 1);
@@ -485,7 +491,11 @@ on_drag_begin (GtkWidget *widget, GdkDragContext *ctx, gpointer user_data)
static void
on_drag_end (GtkWidget *widget, GdkDragContext *ctx, gpointer user_data)
{
- symbol_deselect (LD_CATEGORY_SYMBOL_VIEW (widget));
+ LdCategorySymbolView *self;
+
+ self = LD_CATEGORY_SYMBOL_VIEW (widget);
+ symbol_deselect (self);
+ self->priv->dragged = NULL;
}
static void