[Xfce4-commits] [apps/xfdashboard] 10/10: Remove weak pointer with g_object_remove_weak_pointer() from selected item to prevent GObject system setting a variable to NULL which is not available anymore so this memory access will cause a segmentation fault. It shoud not happen that this weak pointer still exists but you never know ....

noreply at xfce.org noreply at xfce.org
Thu Jul 28 16:52:55 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 029207b57163db43254a2315c2f75544f9d4cf5b
Author: Stephan Haller <nomad at froevel.de>
Date:   Thu Jul 28 16:18:03 2016 +0200

    Remove weak pointer with g_object_remove_weak_pointer() from selected item to prevent GObject system setting a variable to NULL which is not available anymore so this memory access will cause a segmentation fault.
    It shoud not happen that this weak pointer still exists but you never know ....
---
 libxfdashboard/applications-view.c       | 28 +++++++++++++++++++++-------
 libxfdashboard/search-result-container.c |  6 ++++++
 libxfdashboard/windows-view.c            | 10 ++++++++--
 3 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/libxfdashboard/applications-view.c b/libxfdashboard/applications-view.c
index bedc070..37d9c1a 100644
--- a/libxfdashboard/applications-view.c
+++ b/libxfdashboard/applications-view.c
@@ -762,12 +762,14 @@ static gboolean _xfdashboard_applications_view_focusable_set_selection(Xfdashboa
 
 	/* Set new selection */
 	priv->selectedItem=inSelection;
+	if(priv->selectedItem)
+	{
+		/* Add weak reference at new selection */
+		g_object_add_weak_pointer(G_OBJECT(priv->selectedItem), &priv->selectedItem);
 
-	/* 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);
+		/* Ensure new selection is visible */
+		xfdashboard_view_child_ensure_visible(XFDASHBOARD_VIEW(self), priv->selectedItem);
+	}
 
 	/* New selection was set successfully */
 	return(TRUE);
@@ -1195,9 +1197,21 @@ static void _xfdashboard_applications_view_dispose(GObject *inObject)
 	XfdashboardApplicationsViewPrivate	*priv=self->priv;
 
 	/* Release allocated resources */
-	if(priv->xfconfChannel) priv->xfconfChannel=NULL;
+	if(priv->selectedItem)
+	{
+		g_object_remove_weak_pointer(G_OBJECT(priv->selectedItem), &priv->selectedItem);
+		priv->selectedItem=NULL;
+	}
+
+	if(priv->xfconfChannel)
+	{
+		priv->xfconfChannel=NULL;
+	}
 
-	if(priv->layout) priv->layout=NULL;
+	if(priv->layout)
+	{
+		priv->layout=NULL;
+	}
 
 	if(priv->xfconfShowAllAppsMenuBindingID)
 	{
diff --git a/libxfdashboard/search-result-container.c b/libxfdashboard/search-result-container.c
index 2161160..884e0fe 100644
--- a/libxfdashboard/search-result-container.c
+++ b/libxfdashboard/search-result-container.c
@@ -1083,6 +1083,12 @@ static void _xfdashboard_search_result_container_dispose(GObject *inObject)
 	/* Release allocated variables */
 	_xfdashboard_search_result_container_update_selection(self, NULL);
 
+	if(priv->selectedItem)
+	{
+		g_object_remove_weak_pointer(G_OBJECT(priv->selectedItem), &priv->selectedItem);
+		priv->selectedItem=NULL;
+	}
+
 	if(priv->provider)
 	{
 		g_object_unref(priv->provider);
diff --git a/libxfdashboard/windows-view.c b/libxfdashboard/windows-view.c
index a9b1938..d14ad4f 100644
--- a/libxfdashboard/windows-view.c
+++ b/libxfdashboard/windows-view.c
@@ -329,8 +329,8 @@ static void _xfdashboard_windows_view_recreate_window_actors(XfdashboardWindowsV
 	if(priv->selectedItem)
 	{
 		g_object_remove_weak_pointer(G_OBJECT(priv->selectedItem), &priv->selectedItem);
+		priv->selectedItem=NULL;
 	}
-	priv->selectedItem=NULL;
 
 	/* Destroy all actors */
 	clutter_actor_destroy_all_children(CLUTTER_ACTOR(self));
@@ -1465,7 +1465,7 @@ static gboolean _xfdashboard_windows_view_focusable_set_selection(XfdashboardFoc
 	priv->selectedItem=inSelection;
 
 	/* Add weak reference at new selection */
-	g_object_add_weak_pointer(G_OBJECT(priv->selectedItem), &priv->selectedItem);
+	if(priv->selectedItem) g_object_add_weak_pointer(G_OBJECT(priv->selectedItem), &priv->selectedItem);
 
 	/* New selection was set successfully */
 	return(TRUE);
@@ -1796,6 +1796,12 @@ static void _xfdashboard_windows_view_dispose(GObject *inObject)
 	XfdashboardWindowsViewPrivate	*priv=XFDASHBOARD_WINDOWS_VIEW(self)->priv;
 
 	/* Release allocated resources */
+	if(priv->selectedItem)
+	{
+		g_object_remove_weak_pointer(G_OBJECT(priv->selectedItem), &priv->selectedItem);
+		priv->selectedItem=NULL;
+	}
+
 	if(priv->scrollEventChangingWorkspaceStage)
 	{
 		if(priv->scrollEventChangingWorkspaceStageSignalID)

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


More information about the Xfce4-commits mailing list