Avoid warnings on null actors for tray icons

Plugging the GtkSocket icon can fail, in which case NaTrayManager emits
tray-icon-removed but the icon has never emitted plug-added, thus the
ShellTrayIcon has not been created. This results in various criticals
and exceptions in the tray-icon-removed handler.

https://bugzilla.gnome.org/show_bug.cgi?id=633028
This commit is contained in:
Giovanni Campagna 2010-10-24 14:26:50 +02:00
parent 17055023db
commit bc22109130
2 changed files with 16 additions and 8 deletions

View File

@ -60,11 +60,13 @@ free_tray_icon (gpointer data)
{
ShellTrayManagerChild *child = data;
gtk_widget_hide (child->window);
gtk_widget_destroy (child->window);
g_signal_handlers_disconnect_matched (child->actor, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, child);
g_object_unref (child->actor);
if (child->actor)
{
g_signal_handlers_disconnect_matched (child->actor, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, child);
g_object_unref (child->actor);
}
g_slice_free (ShellTrayManagerChild, child);
}
@ -314,8 +316,14 @@ na_tray_icon_removed (NaTrayManager *na_manager, GtkWidget *socket,
child = g_hash_table_lookup (manager->priv->icons, socket);
g_return_if_fail (child != NULL);
g_signal_emit (manager,
shell_tray_manager_signals[TRAY_ICON_REMOVED], 0,
child->actor);
if (child->actor != NULL)
{
/* Only emit signal if a corresponding tray-icon-added signal was emitted,
that is, if embedding did not fail and we got a plug-added
*/
g_signal_emit (manager,
shell_tray_manager_signals[TRAY_ICON_REMOVED], 0,
child->actor);
}
g_hash_table_remove (manager->priv->icons, socket);
}

View File

@ -300,8 +300,8 @@ na_tray_manager_handle_dock_request (NaTrayManager *manager,
if (!gtk_socket_get_plug_window (GTK_SOCKET (child)))
{
/* Embedding failed, we won't get a plug-removed signal */
/* This signal destroys the socket */
g_signal_emit (manager, manager_signals[TRAY_ICON_REMOVED], 0, child);
gtk_widget_destroy (child);
return;
}