From 06d25c0ca2f1788ef1319b2f91ba6303f63f5615 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Thu, 3 Mar 2016 08:21:28 +0100 Subject: [PATCH] Quit on error msg fail. --- include/view.h | 2 +- source/rofi.c | 9 +++++---- source/view.c | 5 +++-- source/x11-helper.c | 3 +++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/view.h b/include/view.h index a266d165..ade6eeb6 100644 --- a/include/view.h +++ b/include/view.h @@ -130,7 +130,7 @@ void rofi_view_set_active ( RofiViewState *state ); * * The error message to show. */ -void rofi_view_error_dialog ( const char *msg, int markup ); +int rofi_view_error_dialog ( const char *msg, int markup ); /** * Queue a redraw. diff --git a/source/rofi.c b/source/rofi.c index 3d9d53d8..0c29f7a8 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -264,10 +264,9 @@ int show_error_message ( const char *msg, int markup ) { int pfd = setup (); if ( pfd < 0 ) { - return EXIT_FAILURE; + return FALSE; } - rofi_view_error_dialog ( msg, markup ); - return EXIT_SUCCESS; + return rofi_view_error_dialog ( msg, markup ); } /** @@ -524,7 +523,9 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data ) if ( find_arg ( "-markup" ) >= 0 ) { markup = TRUE; } - show_error_message ( msg, markup ); + if ( !show_error_message ( msg, markup ) ) { + g_main_loop_quit ( main_loop ); + } } else if ( find_arg_str ( "-show", &sname ) == TRUE ) { int index = switcher_get ( sname ); diff --git a/source/view.c b/source/view.c index 0b7958f4..78a45f9e 100644 --- a/source/view.c +++ b/source/view.c @@ -1703,7 +1703,7 @@ static void __error_dialog_event_loop ( RofiViewState *state, xcb_generic_event_ rofi_view_update ( state ); } void process_result_error ( RofiViewState *state ); -void rofi_view_error_dialog ( const char *msg, int markup ) +int rofi_view_error_dialog ( const char *msg, int markup ) { RofiViewState *state = __rofi_view_state_create (); state->retv = MENU_CANCEL; @@ -1729,7 +1729,7 @@ void rofi_view_error_dialog ( const char *msg, int markup ) int has_keyboard = take_keyboard ( xcb_stuff_get_root_window ( xcb ) ); if ( !has_keyboard ) { fprintf ( stderr, "Failed to grab keyboard, even after %d uS.", 500 * 1000 ); - return; + return FALSE; } rofi_view_calculate_window_and_element_width ( state ); @@ -1757,6 +1757,7 @@ void rofi_view_error_dialog ( const char *msg, int markup ) sn_launchee_context_complete ( xcb->sncontext ); } rofi_view_set_active ( state ); + return TRUE; } void rofi_view_cleanup () diff --git a/source/x11-helper.c b/source/x11-helper.c index 9f95c5e7..98bedb62 100644 --- a/source/x11-helper.c +++ b/source/x11-helper.c @@ -199,6 +199,9 @@ void monitor_dimensions ( int x, int y, workarea *mon ) fprintf ( stderr, "Couldn't query Xinerama\n" ); return; } + if ( is_active == NULL ) { + return; + } if ( !is_active->state ) { free ( is_active ); return;