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.
This commit is contained in:
@@ -333,7 +333,6 @@ static void help ( G_GNUC_UNUSED int argc, char **argv )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function bound by 'atexit'.
|
|
||||||
* Cleanup globally allocated memory.
|
* Cleanup globally allocated memory.
|
||||||
*/
|
*/
|
||||||
static void cleanup ()
|
static void cleanup ()
|
||||||
@@ -866,7 +865,7 @@ int main ( int argc, char *argv[] )
|
|||||||
#else
|
#else
|
||||||
fprintf ( stdout, "Version: "VERSION "\n" );
|
fprintf ( stdout, "Version: "VERSION "\n" );
|
||||||
#endif
|
#endif
|
||||||
exit ( EXIT_SUCCESS );
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect if we are in dmenu mode.
|
// Detect if we are in dmenu mode.
|
||||||
@@ -916,13 +915,10 @@ int main ( int argc, char *argv[] )
|
|||||||
config_path = rofi_expand_path ( c );
|
config_path = rofi_expand_path ( c );
|
||||||
}
|
}
|
||||||
|
|
||||||
TICK ();
|
|
||||||
// Register cleanup function.
|
|
||||||
atexit ( cleanup );
|
|
||||||
|
|
||||||
TICK ();
|
TICK ();
|
||||||
if ( setlocale ( LC_ALL, "" ) == NULL ) {
|
if ( setlocale ( LC_ALL, "" ) == NULL ) {
|
||||||
fprintf ( stderr, "Failed to set locale.\n" );
|
fprintf ( stderr, "Failed to set locale.\n" );
|
||||||
|
cleanup ();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -934,6 +930,7 @@ int main ( int argc, char *argv[] )
|
|||||||
xcb->connection = xcb_connect ( display_str, &xcb->screen_nbr );
|
xcb->connection = xcb_connect ( display_str, &xcb->screen_nbr );
|
||||||
if ( xcb_connection_has_error ( xcb->connection ) ) {
|
if ( xcb_connection_has_error ( xcb->connection ) ) {
|
||||||
fprintf ( stderr, "Failed to open display: %s", display_str );
|
fprintf ( stderr, "Failed to open display: %s", display_str );
|
||||||
|
cleanup ();
|
||||||
return EXIT_FAILURE;
|
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,
|
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 ) {
|
XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS, NULL, NULL, &xkb.first_event, NULL ) < 0 ) {
|
||||||
fprintf ( stderr, "cannot setup XKB extension!\n" );
|
fprintf ( stderr, "cannot setup XKB extension!\n" );
|
||||||
|
cleanup ();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
xkb.context = xkb_context_new ( XKB_CONTEXT_NO_FLAGS );
|
xkb.context = xkb_context_new ( XKB_CONTEXT_NO_FLAGS );
|
||||||
if ( xkb.context == NULL ) {
|
if ( xkb.context == NULL ) {
|
||||||
fprintf ( stderr, "cannot create XKB context!\n" );
|
fprintf ( stderr, "cannot create XKB context!\n" );
|
||||||
|
cleanup ();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
xkb.xcb_connection = xcb->connection;
|
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 );
|
xkb.keymap = xkb_x11_keymap_new_from_device ( xkb.context, xcb->connection, xkb.device_id, XKB_KEYMAP_COMPILE_NO_FLAGS );
|
||||||
if ( xkb.keymap == NULL ) {
|
if ( xkb.keymap == NULL ) {
|
||||||
fprintf ( stderr, "Failed to get Keymap for current keyboard device.\n" );
|
fprintf ( stderr, "Failed to get Keymap for current keyboard device.\n" );
|
||||||
|
cleanup ();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id );
|
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id );
|
||||||
if ( xkb.state == NULL ) {
|
if ( xkb.state == NULL ) {
|
||||||
fprintf ( stderr, "Failed to get state object for current keyboard device.\n" );
|
fprintf ( stderr, "Failed to get state object for current keyboard device.\n" );
|
||||||
|
cleanup ();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1033,13 +1034,15 @@ int main ( int argc, char *argv[] )
|
|||||||
|
|
||||||
if ( xcb_connection_has_error ( xcb->connection ) ) {
|
if ( xcb_connection_has_error ( xcb->connection ) ) {
|
||||||
fprintf ( stderr, "Connection has error\n" );
|
fprintf ( stderr, "Connection has error\n" );
|
||||||
exit ( EXIT_FAILURE );
|
cleanup ();
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
x11_setup ( &xkb );
|
x11_setup ( &xkb );
|
||||||
TICK_N ( "Setup xkb" );
|
TICK_N ( "Setup xkb" );
|
||||||
if ( xcb_connection_has_error ( xcb->connection ) ) {
|
if ( xcb_connection_has_error ( xcb->connection ) ) {
|
||||||
fprintf ( stderr, "Connection has error\n" );
|
fprintf ( stderr, "Connection has error\n" );
|
||||||
exit ( EXIT_FAILURE );
|
cleanup ();
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
main_loop = g_main_loop_new ( NULL, FALSE );
|
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 );
|
xcb->sndisplay = sn_xcb_display_new ( xcb->connection, error_trap_push, error_trap_pop );
|
||||||
if ( xcb_connection_has_error ( xcb->connection ) ) {
|
if ( xcb_connection_has_error ( xcb->connection ) ) {
|
||||||
fprintf ( stderr, "Connection has error\n" );
|
fprintf ( stderr, "Connection has error\n" );
|
||||||
exit ( EXIT_FAILURE );
|
cleanup ();
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( xcb->sndisplay != NULL ) {
|
if ( xcb->sndisplay != NULL ) {
|
||||||
@@ -1056,7 +1060,8 @@ int main ( int argc, char *argv[] )
|
|||||||
}
|
}
|
||||||
if ( xcb_connection_has_error ( xcb->connection ) ) {
|
if ( xcb_connection_has_error ( xcb->connection ) ) {
|
||||||
fprintf ( stderr, "Connection has error\n" );
|
fprintf ( stderr, "Connection has error\n" );
|
||||||
exit ( EXIT_FAILURE );
|
cleanup ();
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
TICK_N ( "Startup Notification" );
|
TICK_N ( "Startup Notification" );
|
||||||
// Setup keybinding
|
// Setup keybinding
|
||||||
@@ -1110,21 +1115,25 @@ int main ( int argc, char *argv[] )
|
|||||||
|
|
||||||
if ( find_arg ( "-dump-theme" ) >= 0 ) {
|
if ( find_arg ( "-dump-theme" ) >= 0 ) {
|
||||||
rofi_theme_print ( rofi_theme );
|
rofi_theme_print ( rofi_theme );
|
||||||
exit ( EXIT_SUCCESS );
|
cleanup ();
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
// Dump.
|
// Dump.
|
||||||
// catch help request
|
// catch help request
|
||||||
if ( find_arg ( "-h" ) >= 0 || find_arg ( "-help" ) >= 0 || find_arg ( "--help" ) >= 0 ) {
|
if ( find_arg ( "-h" ) >= 0 || find_arg ( "-help" ) >= 0 || find_arg ( "--help" ) >= 0 ) {
|
||||||
help ( argc, argv );
|
help ( argc, argv );
|
||||||
exit ( EXIT_SUCCESS );
|
cleanup ();
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
if ( find_arg ( "-dump-xresources" ) >= 0 ) {
|
if ( find_arg ( "-dump-xresources" ) >= 0 ) {
|
||||||
config_parse_xresource_dump ();
|
config_parse_xresource_dump ();
|
||||||
exit ( EXIT_SUCCESS );
|
cleanup ();
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
if ( find_arg ( "-dump-xresources-theme" ) >= 0 ) {
|
if ( find_arg ( "-dump-xresources-theme" ) >= 0 ) {
|
||||||
config_parse_xresources_theme_dump ();
|
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 );
|
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.
|
// Start mainloop.
|
||||||
g_main_loop_run ( main_loop );
|
g_main_loop_run ( main_loop );
|
||||||
teardown ( pfd );
|
teardown ( pfd );
|
||||||
|
cleanup ();
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
|
@@ -1783,7 +1783,7 @@ void rofi_view_workers_initialize ( void )
|
|||||||
void rofi_view_workers_finalize ( void )
|
void rofi_view_workers_finalize ( void )
|
||||||
{
|
{
|
||||||
if ( tpool ) {
|
if ( tpool ) {
|
||||||
g_thread_pool_free ( tpool, TRUE, FALSE );
|
g_thread_pool_free ( tpool, TRUE, TRUE );
|
||||||
tpool = NULL;
|
tpool = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user