summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-03-25 14:23:31 +0100
committerDave Davenport <qball@gmpclient.org>2017-03-25 14:23:31 +0100
commit61e537a05f2bccdf0fa8fd693ef0f1178e29e2bc (patch)
treec997dc85c0db0cc3be64360804da33e267837b86 /source
parent0900b0d925113db76da018f678785340106741f1 (diff)
ISSUE 576: Clutching at straws.
* Don't use atexit anymore. (what happens with g_spawn and atexit? should be fine, but a test). * Even though not needed, force wait on running thread (of which there should be none) when destroy thread pool.
Diffstat (limited to 'source')
-rw-r--r--source/dialogs/drun.c4
-rw-r--r--source/rofi.c42
-rw-r--r--source/theme.c2
-rw-r--r--source/view.c4
4 files changed, 31 insertions, 21 deletions
diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c
index 844bb7ef..1eab9d19 100644
--- a/source/dialogs/drun.c
+++ b/source/dialogs/drun.c
@@ -371,8 +371,8 @@ static void get_apps_history ( DRunModePrivateData *pd )
for ( unsigned int index = 0; index < length; index++ ) {
char **st = g_strsplit ( retv[index], ":::", 2 );
if ( st && st[0] && st[1] ) {
- if ( ! read_desktop_file ( pd, st[0], st[1] ) ) {
- history_remove ( path, retv[index]);
+ if ( !read_desktop_file ( pd, st[0], st[1] ) ) {
+ history_remove ( path, retv[index] );
}
}
g_strfreev ( st );
diff --git a/source/rofi.c b/source/rofi.c
index 56a03608..1392a4b2 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -73,7 +73,7 @@
// TODO: move this check to mode.c
#include "mode-private.h"
-#define LOG_DOMAIN "Rofi"
+#define LOG_DOMAIN "Rofi"
// Pidfile.
char *pidfile = NULL;
@@ -172,7 +172,7 @@ static int setup ()
*/
static void teardown ( int pfd )
{
- g_log ( LOG_DOMAIN , G_LOG_LEVEL_DEBUG, "Teardown");
+ g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Teardown" );
// Cleanup font setup.
textbox_cleanup ( );
@@ -333,7 +333,6 @@ static void help ( G_GNUC_UNUSED int argc, char **argv )
}
/**
- * Function bound by 'atexit'.
* Cleanup globally allocated memory.
*/
static void cleanup ()
@@ -866,7 +865,7 @@ int main ( int argc, char *argv[] )
#else
fprintf ( stdout, "Version: "VERSION "\n" );
#endif
- exit ( EXIT_SUCCESS );
+ return EXIT_SUCCESS;
}
// Detect if we are in dmenu mode.
@@ -917,12 +916,9 @@ int main ( int argc, char *argv[] )
}
TICK ();
- // Register cleanup function.
- atexit ( cleanup );
-
- TICK ();
if ( setlocale ( LC_ALL, "" ) == NULL ) {
fprintf ( stderr, "Failed to set locale.\n" );
+ cleanup ();
return EXIT_FAILURE;
}
@@ -934,6 +930,7 @@ int main ( int argc, char *argv[] )
xcb->connection = xcb_connect ( display_str, &xcb->screen_nbr );
if ( xcb_connection_has_error ( xcb->connection ) ) {
fprintf ( stderr, "Failed to open display: %s", display_str );
+ cleanup ();
return EXIT_FAILURE;
}
@@ -959,12 +956,14 @@ int main ( int argc, char *argv[] )
if ( xkb_x11_setup_xkb_extension ( xcb->connection, XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION,
XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS, NULL, NULL, &xkb.first_event, NULL ) < 0 ) {
fprintf ( stderr, "cannot setup XKB extension!\n" );
+ cleanup ();
return EXIT_FAILURE;
}
xkb.context = xkb_context_new ( XKB_CONTEXT_NO_FLAGS );
if ( xkb.context == NULL ) {
fprintf ( stderr, "cannot create XKB context!\n" );
+ cleanup ();
return EXIT_FAILURE;
}
xkb.xcb_connection = xcb->connection;
@@ -1015,11 +1014,13 @@ int main ( int argc, char *argv[] )
xkb.keymap = xkb_x11_keymap_new_from_device ( xkb.context, xcb->connection, xkb.device_id, XKB_KEYMAP_COMPILE_NO_FLAGS );
if ( xkb.keymap == NULL ) {
fprintf ( stderr, "Failed to get Keymap for current keyboard device.\n" );
+ cleanup ();
return EXIT_FAILURE;
}
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id );
if ( xkb.state == NULL ) {
fprintf ( stderr, "Failed to get state object for current keyboard device.\n" );
+ cleanup ();
return EXIT_FAILURE;
}
@@ -1033,13 +1034,15 @@ int main ( int argc, char *argv[] )
if ( xcb_connection_has_error ( xcb->connection ) ) {
fprintf ( stderr, "Connection has error\n" );
- exit ( EXIT_FAILURE );
+ cleanup ();
+ return EXIT_FAILURE;
}
x11_setup ( &xkb );
TICK_N ( "Setup xkb" );
if ( xcb_connection_has_error ( xcb->connection ) ) {
fprintf ( stderr, "Connection has error\n" );
- exit ( EXIT_FAILURE );
+ cleanup ();
+ return EXIT_FAILURE;
}
main_loop = g_main_loop_new ( NULL, FALSE );
@@ -1048,7 +1051,8 @@ int main ( int argc, char *argv[] )
xcb->sndisplay = sn_xcb_display_new ( xcb->connection, error_trap_push, error_trap_pop );
if ( xcb_connection_has_error ( xcb->connection ) ) {
fprintf ( stderr, "Connection has error\n" );
- exit ( EXIT_FAILURE );
+ cleanup ();
+ return EXIT_FAILURE;
}
if ( xcb->sndisplay != NULL ) {
@@ -1056,7 +1060,8 @@ int main ( int argc, char *argv[] )
}
if ( xcb_connection_has_error ( xcb->connection ) ) {
fprintf ( stderr, "Connection has error\n" );
- exit ( EXIT_FAILURE );
+ cleanup ();
+ return EXIT_FAILURE;
}
TICK_N ( "Startup Notification" );
// Setup keybinding
@@ -1110,21 +1115,25 @@ int main ( int argc, char *argv[] )
if ( find_arg ( "-dump-theme" ) >= 0 ) {
rofi_theme_print ( rofi_theme );
- exit ( EXIT_SUCCESS );
+ cleanup ();
+ return EXIT_SUCCESS;
}
// Dump.
// catch help request
if ( find_arg ( "-h" ) >= 0 || find_arg ( "-help" ) >= 0 || find_arg ( "--help" ) >= 0 ) {
help ( argc, argv );
- exit ( EXIT_SUCCESS );
+ cleanup ();
+ return EXIT_SUCCESS;
}
if ( find_arg ( "-dump-xresources" ) >= 0 ) {
config_parse_xresource_dump ();
- exit ( EXIT_SUCCESS );
+ cleanup ();
+ return EXIT_SUCCESS;
}
if ( find_arg ( "-dump-xresources-theme" ) >= 0 ) {
config_parse_xresources_theme_dump ();
- exit ( EXIT_SUCCESS );
+ cleanup ();
+ return EXIT_SUCCESS;
}
main_loop_source = g_water_xcb_source_new_for_connection ( NULL, xcb->connection, main_loop_x11_event_handler, NULL, NULL );
@@ -1147,5 +1156,6 @@ int main ( int argc, char *argv[] )
// Start mainloop.
g_main_loop_run ( main_loop );
teardown ( pfd );
+ cleanup ();
return return_code;
}
diff --git a/source/theme.c b/source/theme.c
index a99d85f2..ab660315 100644
--- a/source/theme.c
+++ b/source/theme.c
@@ -767,7 +767,7 @@ void rofi_theme_convert_old_theme ( void )
ThemeWidget *walternate = rofi_theme_find_or_create_name ( widget, "alternate" );
rofi_theme_convert_create_property_ht ( widget );
- Property *p= rofi_theme_property_create ( P_INTEGER );
+ Property *p = rofi_theme_property_create ( P_INTEGER );
p->name = g_strdup ( "border" );
p->value.i = 0;
g_hash_table_replace ( widget->properties, p->name, p );
diff --git a/source/view.c b/source/view.c
index 9702de5b..5ea660e3 100644
--- a/source/view.c
+++ b/source/view.c
@@ -1739,7 +1739,7 @@ void rofi_view_cleanup ()
CacheState.edit_surf = NULL;
}
if ( CacheState.main_window != XCB_WINDOW_NONE ) {
- g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Unmapping and free'ing window");
+ g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Unmapping and free'ing window" );
xcb_unmap_window ( xcb->connection, CacheState.main_window );
xcb_free_gc ( xcb->connection, CacheState.gc );
xcb_free_pixmap ( xcb->connection, CacheState.edit_pixmap );
@@ -1783,7 +1783,7 @@ void rofi_view_workers_initialize ( void )
void rofi_view_workers_finalize ( void )
{
if ( tpool ) {
- g_thread_pool_free ( tpool, TRUE, FALSE );
+ g_thread_pool_free ( tpool, TRUE, TRUE );
tpool = NULL;
}
}