1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

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:
Dave Davenport 2017-03-25 14:23:31 +01:00
parent 0900b0d925
commit 61e537a05f
4 changed files with 31 additions and 21 deletions

View file

@ -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 );

View file

@ -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.
@ -916,13 +915,10 @@ int main ( int argc, char *argv[] )
config_path = rofi_expand_path ( c );
}
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;
}

View file

@ -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 );

View file

@ -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;
}
}