mirror of https://github.com/GNOME/gimp.git
plug-ins: fix the thread rendering the thumbnails all the time.
After testing a bit more, I realized that the thread was constantly re-rendering the thumbnails, even though I didn't touch the "white-background" button/argument. This was not just a completely invisible problem, it actually affected the page selection (it was very hard to select pages by clicking on them, it was randomly working, and more often not selecting anything). This is how I realized there was a problem. The reason was simply that I was never actually calling g_cond_wait() because of a first_loop flag I forgot to set. Note that docs of g_cond_wait() explains that it is possible that "spurious wakeup" happen. At first I thought I had this issue, which is why this commit also adds a boolean flag to check after a wakeup, to make sure that I was in the "condition met" case and not the "spurious wakeup" one. Even though I realized afterwards the real reason was much more stupid, I still left this additional check. Fortunately this issue doesn't seem to affect the 2.10 code. Or to be more accurate: the continuous render very likely happens there too, yet it doesn't break page selection interaction with GTK+2 as far as I can see.
This commit is contained in:
parent
179ff7ff4d
commit
1584a9ba50
|
@ -1021,11 +1021,12 @@ typedef struct
|
|||
{
|
||||
PopplerDocument *document;
|
||||
GimpPageSelector *selector;
|
||||
gboolean stop_thumbnailing;
|
||||
gboolean white_background;
|
||||
|
||||
GMutex mutex;
|
||||
GCond render_thumb;
|
||||
gboolean stop_thumbnailing;
|
||||
gboolean render_thumbnails;
|
||||
} ThreadData;
|
||||
|
||||
typedef struct
|
||||
|
@ -1063,17 +1064,33 @@ thumbnail_thread (gpointer data)
|
|||
{
|
||||
gboolean white_background;
|
||||
gboolean stop_thumbnailing;
|
||||
gboolean render_thumbnails;
|
||||
|
||||
g_mutex_lock (&thread_data->mutex);
|
||||
if (! first_loop)
|
||||
if (first_loop)
|
||||
first_loop = FALSE;
|
||||
else
|
||||
g_cond_wait (&thread_data->render_thumb, &thread_data->mutex);
|
||||
white_background = thread_data->white_background;
|
||||
|
||||
stop_thumbnailing = thread_data->stop_thumbnailing;
|
||||
g_mutex_unlock (&thread_data->mutex);
|
||||
|
||||
if (stop_thumbnailing)
|
||||
break;
|
||||
|
||||
g_mutex_lock (&thread_data->mutex);
|
||||
render_thumbnails = thread_data->render_thumbnails;
|
||||
white_background = thread_data->white_background;
|
||||
thread_data->render_thumbnails = FALSE;
|
||||
g_mutex_unlock (&thread_data->mutex);
|
||||
|
||||
/* This handles "spurious wakeup", i.e. cases when g_cond_wait() returned
|
||||
* even though there was no call asking us to re-render the thumbnails.
|
||||
* See docs of g_cond_wait().
|
||||
*/
|
||||
if (! render_thumbnails)
|
||||
continue;
|
||||
|
||||
for (i = 0; i < n_pages; i++)
|
||||
{
|
||||
IdleData *idle_data = g_new0 (IdleData, 1);
|
||||
|
@ -1110,7 +1127,8 @@ white_background_toggled (GtkToggleButton *widget,
|
|||
ThreadData *thread_data)
|
||||
{
|
||||
g_mutex_lock (&thread_data->mutex);
|
||||
thread_data->white_background = gtk_toggle_button_get_active (widget);
|
||||
thread_data->white_background = gtk_toggle_button_get_active (widget);
|
||||
thread_data->render_thumbnails = TRUE;
|
||||
g_cond_signal (&thread_data->render_thumb);
|
||||
g_mutex_unlock (&thread_data->mutex);
|
||||
}
|
||||
|
@ -1210,6 +1228,7 @@ load_dialog (PopplerDocument *doc,
|
|||
|
||||
thread_data.document = doc;
|
||||
thread_data.selector = GIMP_PAGE_SELECTOR (selector);
|
||||
thread_data.render_thumbnails = TRUE;
|
||||
thread_data.stop_thumbnailing = FALSE;
|
||||
thread_data.white_background = white_background;
|
||||
g_mutex_init (&thread_data.mutex);
|
||||
|
|
Loading…
Reference in New Issue