Reset theme if parsing fails, so we don't display using 1/2 parsed theme

This commit is contained in:
Dave Davenport 2017-01-09 23:01:09 +01:00
parent 25dff63006
commit cf1940f8cb
2 changed files with 7 additions and 5 deletions

View file

@ -979,8 +979,10 @@ int main ( int argc, char *argv[] )
if ( config.theme ) { if ( config.theme ) {
TICK_N ( "Parse theme" ); TICK_N ( "Parse theme" );
if ( !rofi_theme_parse_file ( config.theme ) ) { if ( rofi_theme_parse_file ( config.theme ) ) {
// TODO: instantiate fallback theme.? // TODO: instantiate fallback theme.?
rofi_theme_free ( rofi_theme );
rofi_theme = NULL;
} }
TICK_N ( "Parsed theme" ); TICK_N ( "Parsed theme" );
} }
@ -991,9 +993,9 @@ int main ( int argc, char *argv[] )
const char ** theme_str = find_arg_strv ( "-theme-str" ); const char ** theme_str = find_arg_strv ( "-theme-str" );
if ( theme_str ) { if ( theme_str ) {
for ( int index = 0; theme_str && theme_str[index]; index++ ) { for ( int index = 0; theme_str && theme_str[index]; index++ ) {
if ( !rofi_theme_parse_string ( theme_str[index] ) ) { if ( rofi_theme_parse_string ( theme_str[index] ) ) {
fprintf ( stderr, "Failed to parse: %s\n", theme_str[index] ); rofi_theme_free ( rofi_theme );
exit ( EXIT_FAILURE ); rofi_theme = NULL;
} }
} }
g_free ( theme_str ); g_free ( theme_str );

View file

@ -4,7 +4,7 @@
#include "theme.h" #include "theme.h"
/** Default padding. */ /** Default padding. */
#define WIDGET_DEFAULT_PADDING 2 #define WIDGET_DEFAULT_PADDING 0
void widget_init ( widget *widget, const char *name ) void widget_init ( widget *widget, const char *name )
{ {