Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--draw-filename: "x of y": wrong y after file deletion #46

Closed
derf opened this issue May 30, 2011 · 2 comments
Closed

--draw-filename: "x of y": wrong y after file deletion #46

derf opened this issue May 30, 2011 · 2 comments
Assignees
Labels
Milestone

Comments

@derf
Copy link
Owner

derf commented May 30, 2011

After deleting a file, feh will still count it when calculating the total shown in the next image. This is fixed by any action causing the image window to be re-rendered.

Like: "1 of 4" -> delete file -> "2 of 4" -> rerender -> "1 of 3"

@ghost ghost assigned derf May 30, 2011
@livibetter
Copy link
Contributor

diff --git a/src/feh.h b/src/feh.h
index 63aeef6..6da9f5f 100644
--- a/src/feh.h
+++ b/src/feh.h
@@ -118,7 +118,9 @@ void init_unloadables_mode(void);
 void feh_clean_exit(void);
 int feh_load_image(Imlib_Image * im, feh_file * file);
 void show_mini_usage(void);
-void slideshow_change_image(winwidget winwid, int change);
+#define slideshow_change_image(winwid, change) \
+       _slideshow_change_image(winwid, change, 1)
+void _slideshow_change_image(winwidget winwid, int change, int render);
 void slideshow_pause_toggle(winwidget w);
 char *slideshow_create_name(feh_file * file);
 void init_keyevents(void);
diff --git a/src/slideshow.c b/src/slideshow.c
index 6d39d2c..39ae81f 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -170,7 +170,7 @@ void feh_reload_image(winwidget w, int resize, int force_new)
    return;
 }

-void slideshow_change_image(winwidget winwid, int change)
+void _slideshow_change_image(winwidget winwid, int change, int render)
 {
    int success = 0;
    gib_list *last = NULL;
@@ -262,7 +262,8 @@ void slideshow_change_image(winwidget winwid, int change)
            winwidget_reset_image(winwid);
            winwid->im_w = gib_imlib_image_get_width(winwid->im);
            winwid->im_h = gib_imlib_image_get_height(winwid->im);
-           winwidget_render_image(winwid, 1, 0);
+           if (render)
+               winwidget_render_image(winwid, 1, 0);

            s = slideshow_create_name(FEH_FILE(current_file->data));
            winwidget_rename(winwid, s);
@@ -430,7 +431,7 @@ void feh_filelist_image_remove(winwidget winwid, char do_delete)
        gib_list *doomed;

        doomed = current_file;
-       slideshow_change_image(winwid, SLIDE_NEXT);
+       _slideshow_change_image(winwid, SLIDE_NEXT, 0);
        if (do_delete)
            filelist = feh_file_rm_and_free(filelist, doomed);
        else
@@ -440,9 +441,7 @@ void feh_filelist_image_remove(winwidget winwid, char do_delete)
            winwidget_destroy(winwid);
            return;
        }
-       s = slideshow_create_name(FEH_FILE(winwid->file->data));
-       winwidget_rename(winwid, s);
-       free(s);
+       winwidget_render_image(winwid, 1, 0);
    } else if ((winwid->type == WIN_TYPE_SINGLE)
           || (winwid->type == WIN_TYPE_THUMBNAIL_VIEWER)) {
        if (do_delete)

The cause is slideshow_change_image() is called before the image removed from the filelist and that function also makes call to render the image, so it still operates on soon-to-be-old filelist.

I am not sure if it's really need that function to assign a new current image before/after the current image removed. But that function seems to do some work, so I just added render and wrapped it up with a #define.

@derf
Copy link
Owner Author

derf commented Aug 11, 2011

Yeah, that's the best solution. I prefer changing all function calls over building #define mazes, though ;-)

Fixed in 64e9c95

@derf derf closed this as completed Aug 11, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants