Skip to content

Commit 214131e

Browse files
jknockelmtwebster
authored andcommitted
Add !NEMO_IS_DESKTOP_WINDOW() guards to callbacks
Some action callbacks are already guarded with !NEMO_IS_DESKTOP_WINDOW() checks, but not enough unfortunately. Guards are added to these callbacks for the following justifications: CTRL+Q: action_close_all_windows_callback (segfaults) CTRL+L: action_menu_edit_location_callback (does nothing but print nonfatal assertion failures) CTRL+D: action_add_bookmark_callback (adds bogus bookmark) CTRL+B: action_edit_bookmarks_callback (crashes nemo-desktop with fatal assertion failure) ALT+P: action_plugins_callback (fails to load extensions) F9: action_show_hide_sidebar_callback/nemo_window_get_sidebar_id (silently changes global sidebar preference even though desktop has no sidebar) / or ~: nemo_window_prompt_for_location (does nothing but print nonfatal assertion failures)
1 parent 4103e11 commit 214131e

File tree

2 files changed

+35
-18
lines changed

2 files changed

+35
-18
lines changed

src/nemo-window-menus.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,11 @@ action_plugins_callback (GtkAction *action,
307307
{
308308
GtkWindow *window;
309309

310-
window = GTK_WINDOW (user_data);
310+
if (!NEMO_IS_DESKTOP_WINDOW (user_data)) {
311+
window = GTK_WINDOW (user_data);
311312

312-
nemo_file_management_properties_dialog_show (window, "plugins");
313+
nemo_file_management_properties_dialog_show (window, "plugins");
314+
}
313315
}
314316

315317
static void
@@ -525,7 +527,9 @@ static void
525527
action_close_all_windows_callback (GtkAction *action,
526528
gpointer user_data)
527529
{
528-
nemo_application_close_all_windows (nemo_application_get_singleton ());
530+
if (!NEMO_IS_DESKTOP_WINDOW (user_data)) {
531+
nemo_application_close_all_windows (nemo_application_get_singleton ());
532+
}
529533
}
530534

531535
static void
@@ -579,12 +583,14 @@ action_show_hide_sidebar_callback (GtkAction *action,
579583
{
580584
NemoWindow *window;
581585

582-
window = NEMO_WINDOW (user_data);
586+
if (!NEMO_IS_DESKTOP_WINDOW (user_data)) {
587+
window = NEMO_WINDOW (user_data);
583588

584-
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
585-
nemo_window_show_sidebar (window);
586-
} else {
587-
nemo_window_hide_sidebar (window);
589+
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
590+
nemo_window_show_sidebar (window);
591+
} else {
592+
nemo_window_hide_sidebar (window);
593+
}
588594
}
589595
}
590596

@@ -770,14 +776,18 @@ static void
770776
action_add_bookmark_callback (GtkAction *action,
771777
gpointer user_data)
772778
{
779+
if (!NEMO_IS_DESKTOP_WINDOW (user_data)) {
773780
nemo_window_add_bookmark_for_current_location (NEMO_WINDOW (user_data));
781+
}
774782
}
775783

776784
static void
777785
action_edit_bookmarks_callback (GtkAction *action,
778786
gpointer user_data)
779787
{
788+
if (!NEMO_IS_DESKTOP_WINDOW (user_data)) {
780789
nemo_window_edit_bookmarks (NEMO_WINDOW (user_data));
790+
}
781791
}
782792

783793
static void
@@ -935,8 +945,10 @@ action_menu_edit_location_callback (GtkAction *action,
935945
NemoWindow *window = user_data;
936946
NemoWindowPane *pane;
937947

938-
pane = nemo_window_get_active_pane (window);
939-
toggle_location_entry_setting(window, pane, TRUE);
948+
if (!NEMO_IS_DESKTOP_WINDOW (user_data)) {
949+
pane = nemo_window_get_active_pane (window);
950+
toggle_location_entry_setting(window, pane, TRUE);
951+
}
940952
}
941953

942954
static void

src/nemo-window.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "nemo-actions.h"
3535
#include "nemo-application.h"
3636
#include "nemo-bookmarks-window.h"
37+
#include "nemo-desktop-window.h"
3738
#include "nemo-location-bar.h"
3839
#include "nemo-mime-actions.h"
3940
#include "nemo-notebook.h"
@@ -308,11 +309,13 @@ nemo_window_prompt_for_location (NemoWindow *window,
308309

309310
g_return_if_fail (NEMO_IS_WINDOW (window));
310311

311-
if (initial) {
312-
nemo_window_show_location_entry(window);
313-
pane = window->details->active_pane;
314-
nemo_location_bar_set_location (NEMO_LOCATION_BAR (pane->location_bar),
315-
initial);
312+
if (!NEMO_IS_DESKTOP_WINDOW (window)) {
313+
if (initial) {
314+
nemo_window_show_location_entry(window);
315+
pane = window->details->active_pane;
316+
nemo_location_bar_set_location (NEMO_LOCATION_BAR (pane->location_bar),
317+
initial);
318+
}
316319
}
317320
}
318321

@@ -2270,11 +2273,13 @@ void
22702273
nemo_window_set_show_sidebar (NemoWindow *window,
22712274
gboolean show)
22722275
{
2273-
window->details->show_sidebar = show;
2276+
if (!NEMO_IS_DESKTOP_WINDOW (window)) {
2277+
window->details->show_sidebar = show;
22742278

2275-
g_settings_set_boolean (nemo_window_state, NEMO_WINDOW_STATE_START_WITH_SIDEBAR, show);
2279+
g_settings_set_boolean (nemo_window_state, NEMO_WINDOW_STATE_START_WITH_SIDEBAR, show);
22762280

2277-
g_object_notify_by_pspec (G_OBJECT (window), properties[PROP_SHOW_SIDEBAR]);
2281+
g_object_notify_by_pspec (G_OBJECT (window), properties[PROP_SHOW_SIDEBAR]);
2282+
}
22782283
}
22792284

22802285
gboolean

0 commit comments

Comments
 (0)