Refactored imlib context handling

This commit is contained in:
Bert
2011-02-25 12:08:12 +01:00
parent 62fb69b328
commit dafe7eac74
5 changed files with 55 additions and 38 deletions

6
main.c
View File

@ -62,6 +62,7 @@ void cleanup() {
static int in = 0;
if (!in++) {
img_close(&img);
img_free(&img);
tns_free(&tns, &win);
win_close(&win);
@ -71,6 +72,8 @@ void cleanup() {
int load_image() {
struct stat fstats;
img_close(&img);
if (!stat(filenames[fileidx], &fstats))
filesize = fstats.st_size;
else
@ -158,7 +161,7 @@ void update_title() {
tns.cnt ? tns.sel + 1 : 0, tns.cnt,
tns.cnt ? filenames[tns.sel] : "");
} else {
if (img.valid) {
if (img.im) {
size = filesize;
size_readable(&size, &unit);
n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] <%d%%> (%.2f%s) %s",
@ -388,6 +391,7 @@ void on_keypress(XKeyEvent *kev) {
case XK_Return:
if (!tns.thumbs)
tns_init(&tns, filecnt);
img_close(&img);
mode = MODE_THUMBS;
win_set_cursor(&win, CURSOR_ARROW);
timo_cursor = 0;