Correct cleanup() behaviour

This commit is contained in:
Georg Reinke 2012-07-24 14:12:04 +02:00
parent ab350c86f7
commit ed067579b9
1 changed files with 17 additions and 9 deletions

26
bar.c
View File

@ -360,14 +360,22 @@ init (void)
void void
cleanup (void) cleanup (void)
{ {
xcb_close_font (c, fontset[FONT_MAIN].xcb_ft); if (fontset[FONT_MAIN].xcb_ft)
xcb_close_font (c, fontset[FONT_FALLBACK].xcb_ft); xcb_close_font (c, fontset[FONT_MAIN].xcb_ft);
xcb_free_pixmap (c, canvas); if (fontset[FONT_FALLBACK].xcb_ft)
xcb_destroy_window (c, win); xcb_close_font (c, fontset[FONT_FALLBACK].xcb_ft);
xcb_free_gc (c, draw_gc); if (canvas)
xcb_free_gc (c, clear_gc); xcb_free_pixmap (c, canvas);
xcb_free_gc (c, underl_gc); if (win)
xcb_disconnect (c); xcb_destroy_window (c, win);
if (draw_gc)
xcb_free_gc (c, draw_gc);
if (clear_gc)
xcb_free_gc (c, clear_gc);
if (underl_gc)
xcb_free_gc (c, underl_gc);
if (c)
xcb_disconnect (c);
} }
void void
@ -405,10 +413,10 @@ main (int argc, char **argv)
} }
} }
atexit (cleanup);
signal (SIGINT, sighandle); signal (SIGINT, sighandle);
signal (SIGTERM, sighandle); signal (SIGTERM, sighandle);
init (); init ();
atexit (cleanup);
/* Get the fd to Xserver */ /* Get the fd to Xserver */
pollin[1].fd = xcb_get_file_descriptor (c); pollin[1].fd = xcb_get_file_descriptor (c);