[Xfce4-commits] [apps/xfdashboard] 01/01: Add weak reference pointers to current selections at view classes to prevent accessing destroyed selections of which we are not notified by "destroy" or "hide" signals.

noreply at xfce.org noreply at xfce.org
Tue Mar 29 10:17:19 CEST 2016


This is an automated email from the git hooks/post-receive script.

nomad pushed a commit to branch master
in repository apps/xfdashboard.

commit a9df0f92dc3b711a39cd47bc4d1030c15eab29df
Author: Stephan Haller <nomad at froevel.de>
Date:   Tue Mar 29 10:15:24 2016 +0200

    Add weak reference pointers to current selections at view classes to prevent accessing destroyed selections of which we are not notified by "destroy" or "hide" signals.
    
    Another fix for GH #123
---
 libxfdashboard/applications-view.c       | 11 ++++++++++-
 libxfdashboard/search-result-container.c | 12 +++++++++---
 libxfdashboard/windows-view.c            | 19 +++++++++++++++++--
 3 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/libxfdashboard/applications-view.c b/libxfdashboard/applications-view.c
index 7d41d76..f52bbb5 100644
--- a/libxfdashboard/applications-view.c
+++ b/libxfdashboard/applications-view.c
@@ -73,7 +73,7 @@ struct _XfdashboardApplicationsViewPrivate
 	XfdashboardApplicationsMenuModel	*apps;
 	GarconMenuElement					*currentRootMenuElement;
 
-	ClutterActor						*selectedItem;
+	gpointer							selectedItem;
 
 	XfconfChannel						*xfconfChannel;
 	gboolean							showAllAppsMenu;
@@ -754,9 +754,18 @@ static gboolean _xfdashboard_applications_view_focusable_set_selection(Xfdashboa
 		return(FALSE);
 	}
 
+	/* Remove weak reference at current selection */
+	if(priv->selectedItem)
+	{
+		g_object_remove_weak_pointer(G_OBJECT(priv->selectedItem), &priv->selectedItem);
+	}
+
 	/* Set new selection */
 	priv->selectedItem=inSelection;
 
+	/* Add weak reference at new selection */
+	g_object_add_weak_pointer(G_OBJECT(priv->selectedItem), &priv->selectedItem);
+
 	/* Ensure new selection is visible */
 	if(inSelection) xfdashboard_view_child_ensure_visible(XFDASHBOARD_VIEW(self), inSelection);
 
diff --git a/libxfdashboard/search-result-container.c b/libxfdashboard/search-result-container.c
index c272fcd..6b361d5 100644
--- a/libxfdashboard/search-result-container.c
+++ b/libxfdashboard/search-result-container.c
@@ -72,7 +72,7 @@ struct _XfdashboardSearchResultContainerPrivate
 	ClutterActor				*titleTextBox;
 	ClutterActor				*itemsContainer;
 
-	ClutterActor				*selectedItem;
+	gpointer					selectedItem;
 	guint						selectedItemDestroySignalID;
 
 	GHashTable					*mapping;
@@ -171,6 +171,9 @@ static void _xfdashboard_search_result_container_update_selection(XfdashboardSea
 	/* Unset current selection and signal handler ID */
 	if(priv->selectedItem)
 	{
+		/* Remove weak reference at current selection */
+		g_object_remove_weak_pointer(G_OBJECT(priv->selectedItem), &priv->selectedItem);
+
 		/* Disconnect signal handler */
 		if(priv->selectedItemDestroySignalID)
 		{
@@ -193,6 +196,9 @@ static void _xfdashboard_search_result_container_update_selection(XfdashboardSea
 	{
 		priv->selectedItem=inNewSelectedItem;
 
+		/* Add weak reference at new selection */
+		g_object_add_weak_pointer(G_OBJECT(inNewSelectedItem), &priv->selectedItem);
+
 		/* Connect signals */
 		g_signal_connect_swapped(inNewSelectedItem,
 									"destroy",
@@ -200,9 +206,9 @@ static void _xfdashboard_search_result_container_update_selection(XfdashboardSea
 									self);
 
 		/* Style new selection */
-		if(XFDASHBOARD_IS_STYLABLE(priv->selectedItem))
+		if(XFDASHBOARD_IS_STYLABLE(inNewSelectedItem))
 		{
-			xfdashboard_stylable_add_pseudo_class(XFDASHBOARD_STYLABLE(priv->selectedItem), "selected");
+			xfdashboard_stylable_add_pseudo_class(XFDASHBOARD_STYLABLE(inNewSelectedItem), "selected");
 		}
 	}
 }
diff --git a/libxfdashboard/windows-view.c b/libxfdashboard/windows-view.c
index 8447e3f..2c7e0ce 100644
--- a/libxfdashboard/windows-view.c
+++ b/libxfdashboard/windows-view.c
@@ -70,7 +70,7 @@ struct _XfdashboardWindowsViewPrivate
 	/* Instance related */
 	XfdashboardWindowTracker			*windowTracker;
 	ClutterLayoutManager				*layout;
-	ClutterActor						*selectedItem;
+	gpointer							selectedItem;
 
 	XfconfChannel						*xfconfChannel;
 	guint								xfconfScrollEventChangingWorkspaceBindingID;
@@ -318,9 +318,15 @@ static void _xfdashboard_windows_view_recreate_window_actors(XfdashboardWindowsV
 
 	priv=self->priv;
 
+	/* Remove weak reference at current selection and unset selection */
+	if(priv->selectedItem)
+	{
+		g_object_remove_weak_pointer(G_OBJECT(priv->selectedItem), &priv->selectedItem);
+	}
+	priv->selectedItem=NULL;
+
 	/* Destroy all actors */
 	clutter_actor_destroy_all_children(CLUTTER_ACTOR(self));
-	priv->selectedItem=NULL;
 
 	/* Create live window actors for new workspace */
 	if(priv->workspace!=NULL)
@@ -1403,9 +1409,18 @@ static gboolean _xfdashboard_windows_view_focusable_set_selection(XfdashboardFoc
 		return(FALSE);
 	}
 
+	/* Remove weak reference at current selection */
+	if(priv->selectedItem)
+	{
+		g_object_remove_weak_pointer(G_OBJECT(priv->selectedItem), &priv->selectedItem);
+	}
+
 	/* Set new selection */
 	priv->selectedItem=inSelection;
 
+	/* Add weak reference at new selection */
+	g_object_add_weak_pointer(G_OBJECT(priv->selectedItem), &priv->selectedItem);
+
 	/* New selection was set successfully */
 	return(TRUE);
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list