From 1d5caf587462e4e60e69938d183ba0b2faa1ed0b Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 30 Sep 2011 03:16:36 +0200 Subject: get_index_string_dim: Fix dimansion report for file = NULL --- src/index.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/index.c b/src/index.c index 466ce21..49efc17 100644 --- a/src/index.c +++ b/src/index.c @@ -436,12 +436,22 @@ void init_index_mode(void) void get_index_string_dim(feh_file *file, Imlib_Font fn, int *fw, int *fh) { int line_w, line_h; + char fake_file = 0; gib_list *line, *lines; static int max_w = 0, total_h = 0; if (!opt.index_info) return; + /* called with file = NULL in the setup phase. + * We need a fake file, otherwise feh_printf will remove format specifiers, + * leading e.g. to a 0x0 report for index_dim = "%n". + */ + if (file == NULL) { + file = feh_file_new("foo"); + file->info = feh_file_info_new(); + } + line = lines = feh_wrap_string(create_index_string(file), opt.thumb_w * 3, fn, NULL); while (line) { @@ -456,8 +466,8 @@ void get_index_string_dim(feh_file *file, Imlib_Font fn, int *fw, int *fh) } gib_list_free_and_data(lines); - - printf("dim is %dx%d\n", max_w, total_h); + if (fake_file) + feh_file_free(file); *fw = max_w; *fh = total_h; -- cgit v1.2.3