[seahorse] search provider: fix segfault when activating a result
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse] search provider: fix segfault when activating a result
- Date: Wed, 19 Feb 2014 19:24:09 +0000 (UTC)
commit 9aa1fb530d2b09ab23cc9dfbe35f67df8cca4aaa
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Wed Feb 19 20:23:23 2014 +0100
search provider: fix segfault when activating a result
SeahorseKeyManager is not a SeahorseWidget anymore, so we can't
use seahorse_widget_find() to obtain the singleton. Instead,
have seahorse_key_manager_show() store and return it.
This also fixes the single-window behavior of GtkApplication.
Reviewed-by: Stef Walter <stefw gnome org>
https://bugzilla.gnome.org/show_bug.cgi?id=724659
libseahorse/seahorse-search-provider.c | 20 ++++----------------
src/seahorse-key-manager.c | 15 ++++++++++++---
src/seahorse-key-manager.h | 2 +-
src/seahorse-main.c | 2 +-
4 files changed, 18 insertions(+), 21 deletions(-)
---
diff --git a/libseahorse/seahorse-search-provider.c b/libseahorse/seahorse-search-provider.c
index 9b0dc7c..b79922c 100644
--- a/libseahorse/seahorse-search-provider.c
+++ b/libseahorse/seahorse-search-provider.c
@@ -29,6 +29,7 @@
#include "seahorse-common.h"
#include "seahorse-widget.h"
#include "seahorse-collection.h"
+#include "src/seahorse-key-manager.h"
#include "seahorse-shell-search-provider-generated.h"
#include "seahorse-search-provider.h"
@@ -260,8 +261,7 @@ handle_activate_result (SeahorseShellSearchProvider2 *skeleton,
{
SeahorseSearchProvider *self = SEAHORSE_SEARCH_PROVIDER (skeleton);
GObject *object;
- SeahorseWidget *key_manager;
- GtkWindow *window;
+ SeahorseKeyManager *key_manager;
sscanf (identifier, "%p", &object);
@@ -271,20 +271,8 @@ handle_activate_result (SeahorseShellSearchProvider2 *skeleton,
return TRUE;
}
- key_manager = seahorse_widget_find ("key-manager");
- if (key_manager == NULL) {
- GtkApplication *app;
-
- app = seahorse_application_get ();
- g_application_activate (G_APPLICATION (app));
-
- key_manager = seahorse_widget_find ("key-manager");
- }
-
- window = GTK_WINDOW (seahorse_widget_get_widget (key_manager, key_manager->name));
- gtk_window_present_with_time (window, timestamp);
-
- seahorse_viewable_view (object, window);
+ key_manager = seahorse_key_manager_show (timestamp);
+ seahorse_viewable_view (object, GTK_WINDOW (key_manager));
seahorse_shell_search_provider2_complete_activate_result (skeleton,
invocation);
diff --git a/src/seahorse-key-manager.c b/src/seahorse-key-manager.c
index 5979a8e..ac8671d 100644
--- a/src/seahorse-key-manager.c
+++ b/src/seahorse-key-manager.c
@@ -841,8 +841,17 @@ seahorse_key_manager_class_init (SeahorseKeyManagerClass *klass)
catalog_class->get_focused_place = seahorse_key_manager_get_focused_place;
}
-void
-seahorse_key_manager_show (void)
+SeahorseKeyManager *
+seahorse_key_manager_show (guint32 timestamp)
{
- g_object_new (SEAHORSE_TYPE_KEY_MANAGER, "ui-name", "key-manager", NULL);
+ static SeahorseKeyManager *singleton;
+
+ if (singleton) {
+ gtk_window_present_with_time (GTK_WINDOW (singleton), timestamp);
+ return singleton;
+ } else {
+ singleton = g_object_new (SEAHORSE_TYPE_KEY_MANAGER, "ui-name", "key-manager", NULL);
+ g_object_add_weak_pointer (G_OBJECT (singleton), (gpointer*) &singleton);
+ return singleton;
+ }
}
diff --git a/src/seahorse-key-manager.h b/src/seahorse-key-manager.h
index 39dff3c..2f13489 100644
--- a/src/seahorse-key-manager.h
+++ b/src/seahorse-key-manager.h
@@ -53,7 +53,7 @@ struct _SeahorseKeyManagerClass {
GType seahorse_key_manager_get_type (void) G_GNUC_CONST;
-void seahorse_key_manager_show (void);
+SeahorseKeyManager * seahorse_key_manager_show (guint32 timestamp);
G_END_DECLS
diff --git a/src/seahorse-main.c b/src/seahorse-main.c
index 444aff8..c83c4c1 100644
--- a/src/seahorse-main.c
+++ b/src/seahorse-main.c
@@ -36,7 +36,7 @@ static void
on_application_activate (GApplication *application,
gpointer user_data)
{
- seahorse_key_manager_show ();
+ seahorse_key_manager_show (GDK_CURRENT_TIME);
}
/* Initializes context and preferences, then loads key manager */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]