Merge lp:~raof/netbook-remix-launcher/fix-bug-467474 into lp:netbook-remix-launcher

Proposed by Chris Halse Rogers
Status: Merged
Merged at revision: not available
Proposed branch: lp:~raof/netbook-remix-launcher/fix-bug-467474
Merge into: lp:netbook-remix-launcher
Diff against target: 97 lines (+37/-7)
3 files modified
src/main.c (+21/-7)
src/nl-window.c (+14/-0)
src/nl-window.h (+2/-0)
To merge this branch: bzr merge lp:~raof/netbook-remix-launcher/fix-bug-467474
Reviewer Review Type Date Requested Status
UNR Developers Pending
Review via email: mp+21349@code.launchpad.net

Description of the change

Check that clutter has successfully initialised the stage in nl-window's constructed method; bail if the stage isn't correctly initialised, as the subsequent calls are guaranteed to fail, and in the case of bug #467474 results in segfaults in libGL.

If this happens, catch the invalid nl-window in main.c, and spawn netbook-launcher-efl.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/main.c'
2--- src/main.c 2010-02-17 16:51:06 +0000
3+++ src/main.c 2010-03-15 05:31:13 +0000
4@@ -241,6 +241,20 @@
5 return TRUE;
6 }
7
8+static gint
9+fallback_to_efl (void)
10+{
11+ GError *error = NULL;
12+
13+ if (!g_spawn_command_line_async ("/usr/bin/netbook-launcher-efl", &error))
14+ {
15+ g_print ("Error in netbook-launcher-efl: %s\n", error->message);
16+ g_error_free (error);
17+ return EXIT_FAILURE;
18+ }
19+ return 0;
20+}
21+
22 gint
23 main (gint argc, gchar *argv[])
24 {
25@@ -269,13 +283,7 @@
26 {
27 g_print ("No rendering avaible for netbook-launcher, try to run netbook-launcher-efl\n");
28
29- if (!g_spawn_command_line_async ("/usr/bin/netbook-launcher-efl", &error))
30- {
31- g_print ("Error in netbook-launcher-efl: %s\n", error->message);
32- g_error_free (error);
33- return EXIT_FAILURE;
34- }
35- return 0;
36+ return fallback_to_efl ();
37 }
38
39 if (!notify_init ("Netbook Launcher"))
40@@ -380,6 +388,12 @@
41 /* Create the nl window */
42 window = nl_window_get_default ();
43
44+ if (!nl_window_is_valid (window))
45+ {
46+ g_print ("Error creating clutter launcher. Trying to run netbook-launcher-efl\n");
47+ return fallback_to_efl ();
48+ }
49+
50 plugin_manager = nl_plugin_manager_new (NL_SHELL (window));
51 folders_source = nl_folders_source_new (NL_SHELL (window));
52 volumes_source = nl_volumes_source_new (NL_SHELL (window));
53
54=== modified file 'src/nl-window.c'
55--- src/nl-window.c 2010-03-11 07:14:00 +0000
56+++ src/nl-window.c 2010-03-15 05:31:13 +0000
57@@ -192,6 +192,12 @@
58 priv->stage = gtk_clutter_embed_get_stage
59 (GTK_CLUTTER_EMBED (priv->gtkclutter));
60
61+ // Given sufficiently poor OpenGL drivers getting the stage
62+ // can fail. In this case, there's a good chance that further
63+ // OpenGL calls will fail, sometimes spectacularly.
64+ // See LP: #467474 for an example.
65+ g_return_if_fail (CLUTTER_IS_STAGE (priv->stage));
66+
67 /* Set NlWidget's direction */
68 direction = gtk_widget_get_default_direction ();
69 ctk_actor_set_default_direction (direction);
70@@ -370,6 +376,14 @@
71 return window;
72 }
73
74+gboolean
75+nl_window_is_valid (GtkWidget *window)
76+{
77+ // This is not all of the state required to declare a window valid, but
78+ // it's enough to LP: #467474
79+ return CLUTTER_IS_STAGE (NL_WINDOW (window)->priv->stage);
80+}
81+
82 /*
83 * Private methods
84 */
85
86=== modified file 'src/nl-window.h'
87--- src/nl-window.h 2009-07-23 13:45:56 +0000
88+++ src/nl-window.h 2010-03-15 05:31:13 +0000
89@@ -61,6 +61,8 @@
90
91 GtkWidget * nl_window_get_default (void);
92
93+gboolean nl_window_is_valid (GtkWidget *window);
94+
95 void nl_window_set_transient (NlWindow *self, GtkWindow *window);
96
97 #endif /* _NL_WINDOW_H_ */

Subscribers

People subscribed via source and target branches