diff options
| author | Daniel Friesel <derf@finalrewind.org> | 2011-09-30 03:16:36 +0200 | 
|---|---|---|
| committer | Daniel Friesel <derf@finalrewind.org> | 2011-09-30 03:16:36 +0200 | 
| commit | 1d5caf587462e4e60e69938d183ba0b2faa1ed0b (patch) | |
| tree | 9979d65e5db37c8db1a3d1b560fc53205cd4c408 | |
| parent | f933dd396cf0f5cbb5b053d5a8f85fbcfc9761fd (diff) | |
get_index_string_dim: Fix dimansion report for file = NULL
| -rw-r--r-- | src/index.c | 14 | 
1 files changed, 12 insertions, 2 deletions
| 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; | 
