Skip to content

Commit

Permalink
make history pastes on up to 3 images synchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfbrown authored and TurboGit committed Sep 9, 2024
1 parent 83b4de5 commit e5cafa1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/control/jobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,13 @@ gboolean dt_control_add_job(dt_control_t *control,
dt_job_queue_t queue_id,
_dt_job_t *job)
{
if(((unsigned int)queue_id) >= DT_JOB_QUEUE_MAX || !job)
if((((unsigned int)queue_id) >= DT_JOB_QUEUE_MAX && queue_id != DT_JOB_QUEUE_SYNCHRONOUS) || !job)
{
dt_control_job_dispose(job);
return TRUE;
}

if(!control->running)
if(!control->running || queue_id == DT_JOB_QUEUE_SYNCHRONOUS)
{
// whatever we are adding here won't be scheduled as the system isn't running. execute it synchronous instead.
dt_pthread_mutex_lock(&job->wait_mutex); // is that even needed?
Expand Down
3 changes: 2 additions & 1 deletion src/control/jobs.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ typedef enum dt_job_queue_t
DT_JOB_QUEUE_USER_BG = 2, // imports, ...
DT_JOB_QUEUE_USER_EXPORT = 3, // exports. only one of these jobs will ever be scheduled at a time
DT_JOB_QUEUE_SYSTEM_BG = 4, // some lua stuff that may not be pushed out of the queue, ...
DT_JOB_QUEUE_MAX = 5
DT_JOB_QUEUE_MAX = 5,
DT_JOB_QUEUE_SYNCHRONOUS = 1000 // don't queue, run immeidately and don't return until done
} dt_job_queue_t;

typedef struct _dt_job_t dt_job_t;
Expand Down
6 changes: 4 additions & 2 deletions src/control/jobs/control_jobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2186,7 +2186,8 @@ void dt_control_paste_history(GList *imgs)
g_list_free(imgs);
return;
}
dt_control_add_job(darktable.control, DT_JOB_QUEUE_USER_FG,
dt_job_queue_t queue = g_list_shorter_than(imgs,4) ? DT_JOB_QUEUE_SYNCHRONOUS : DT_JOB_QUEUE_USER_FG;
dt_control_add_job(darktable.control, queue,
dt_control_generic_images_job_create(&_control_paste_history_job_run,
N_("paste history"), 0,
imgs, PROGRESS_BLOCKING, FALSE));
Expand All @@ -2207,7 +2208,8 @@ void dt_control_paste_parts_history(GList *imgs)

if(res == GTK_RESPONSE_OK)
{
dt_control_add_job(darktable.control, DT_JOB_QUEUE_USER_FG,
dt_job_queue_t queue = g_list_shorter_than(imgs,4) ? DT_JOB_QUEUE_SYNCHRONOUS : DT_JOB_QUEUE_USER_FG;
dt_control_add_job(darktable.control, queue,
dt_control_generic_images_job_create(&_control_paste_history_job_run,
N_("paste history"), 0,
imgs, PROGRESS_BLOCKING, FALSE));
Expand Down

0 comments on commit e5cafa1

Please sign in to comment.