Skip to content

Commit

Permalink
Bugfix: Prevent crash in lazy mode if many of the first images fail t…
Browse files Browse the repository at this point in the history
…o load

The actual bugfix is the compare-to-one-instead-of-zero. The usleep() is
a (hopefully temporary) mitigation against a race which I cannot
pinpoint yet that prevents the main window from being shown sometimes in
that case.
  • Loading branch information
phillipberndt committed Apr 14, 2016
1 parent 4ef0b7b commit e67e8c3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ Known bugs
Changelog
---------

pqiv 2.5.1
* Prevent a crash in --lazy-load mode if many images fail to load

pqiv 2.5
* Added a configure option to build the backends as shared libraries
* Added a configure option to remove unneeded/unwanted features
Expand Down
5 changes: 3 additions & 2 deletions pqiv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,7 @@ gboolean image_loader_load_single(BOSNode *node, gboolean called_from_main) {/*{
if(node == current_file_node) {
current_file_node = next_file();
if(current_file_node == node) {
if(bostree_node_count(file_tree) > 0) {
if(bostree_node_count(file_tree) > 1) {
// This can be triggered in shuffle mode if images are deleted and the end of
// a shuffle cycle is reached, such that next_file() starts a new one. Fall
// back to display the first image. See bug #35 in github.
Expand Down Expand Up @@ -1949,6 +1949,7 @@ gpointer image_loader_thread(gpointer user_data) {/*{{{*/
current_image_drawn = FALSE;
gdk_threads_add_idle((GSourceFunc)image_loaded_handler, node);
}

D_LOCK(file_tree);
bostree_node_weak_unref(file_tree, node);
D_UNLOCK(file_tree);
Expand Down Expand Up @@ -1979,7 +1980,7 @@ gboolean initialize_image_loader() {/*{{{*/
}
current_file_node = bostree_node_weak_ref(current_file_node);
D_UNLOCK(file_tree);
while(!image_loader_load_single(current_file_node, TRUE) && bostree_node_count(file_tree) > 0);
while(!image_loader_load_single(current_file_node, TRUE) && bostree_node_count(file_tree) > 0) usleep(10000);
if(bostree_node_count(file_tree) == 0) {
return FALSE;
}
Expand Down
2 changes: 1 addition & 1 deletion pqiv.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "lib/bostree.h"

#ifndef PQIV_VERSION
#define PQIV_VERSION "2.5"
#define PQIV_VERSION "2.5.1"
#endif

#define FILE_FLAGS_ANIMATION (guint)(1)
Expand Down

0 comments on commit e67e8c3

Please sign in to comment.