summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Riemann <friemann@gnome.org>2023-04-22 19:04:32 +0200
committerFelix Riemann <friemann@gnome.org>2023-04-22 19:07:41 +0200
commit7ef4de2bb5cc541f1a56870aba177898a054af18 (patch)
treec33a09325e29049ec9848fb9d8252675f57ee87c
parent42737573eeaafd832977496b02ba67a3ac778b7e (diff)
downloadeog-7ef4de2bb5cc541f1a56870aba177898a054af18.tar.gz
EogJobs: Clean up image data if EogJobLoad gets cancelled
If a EogJobLoad gets cancelled it may have actually already completed loading the image data. Instead of leaking the data and possibly hitting an assertion when trying to load the image the next time, do a ref-unref on the image data to release it. See #288.
-rw-r--r--src/eog-jobs.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/eog-jobs.c b/src/eog-jobs.c
index 0d648e80..a63ce79d 100644
--- a/src/eog-jobs.c
+++ b/src/eog-jobs.c
@@ -559,6 +559,7 @@ static void
eog_job_load_run (EogJob *job)
{
EogJobLoad *job_load;
+ gboolean result;
/* initialization */
g_return_if_fail (EOG_IS_JOB_LOAD (job));
@@ -572,14 +573,21 @@ eog_job_load_run (EogJob *job)
}
/* load image from file */
- eog_image_load (job_load->image,
- job_load->data,
- job,
- &job->error);
+ result = eog_image_load (job_load->image,
+ job_load->data,
+ job,
+ &job->error);
/* check if the current job was previously cancelled */
- if (eog_job_is_cancelled (job))
+ if (eog_job_is_cancelled (job)) {
+ if (result) {
+ /* If the load finished successfully we need to make
+ * the image drop the loaded data again. See #288. */
+ eog_image_data_ref (job_load->image);
+ eog_image_data_unref (job_load->image);
+ }
return;
+ }
/* --- enter critical section --- */
g_mutex_lock (job->mutex);