Skip to content

Commit 8096955

Browse files
jenshannoschwalmTurboGit
authored andcommitted
Pending background jobs
1. Leave a visible note about pending work done in the background for up to five seconds 2. Avoid raising signal if control is not available any longer, avoids rare crashes 3. Some minor formatting
1 parent 7c03add commit 8096955

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

src/control/control.c

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -302,17 +302,27 @@ void dt_control_quit()
302302
if(dt_atomic_exch_int(&dc->quitting, 1) == 1) return;
303303

304304
#ifdef HAVE_PRINT
305-
dt_printers_abort_discovery();
306-
// Cups timeout could be pretty long, at least 30seconds
307-
// but don't rely on cups returning correctly so a timeout
308-
for(int i = 0; i < 40000 && !dc->cups_started; i++)
309-
g_usleep(1000);
305+
dt_printers_abort_discovery();
306+
// Cups timeout could be pretty long, at least 30seconds
307+
// but don't rely on cups returning correctly so a timeout
308+
for(int i = 0; i < 40000 && !dc->cups_started; i++)
309+
g_usleep(1000);
310310
#endif
311311

312-
dt_pthread_mutex_lock(&dc->cond_mutex);
313-
// set the "pending cleanup work" flag to be handled in dt_control_shutdown()
314-
dt_atomic_set_int(&dc->running, DT_CONTROL_STATE_CLEANUP);
315-
dt_pthread_mutex_unlock(&dc->cond_mutex);
312+
if(dt_control_jobs_pending())
313+
dt_control_log(_("<span foreground='#FF0000' background='#000000'>"
314+
"darktable will be locked until background work has been done"
315+
"</span>"));
316+
for(int i = 0; i < 50 && dt_control_jobs_pending(); i++)
317+
{
318+
g_usleep(100000);
319+
dt_gui_process_events();
320+
}
321+
322+
dt_pthread_mutex_lock(&dc->cond_mutex);
323+
// set the "pending cleanup work" flag to be handled in dt_control_shutdown()
324+
dt_atomic_set_int(&dc->running, DT_CONTROL_STATE_CLEANUP);
325+
dt_pthread_mutex_unlock(&dc->cond_mutex);
316326

317327
if(g_atomic_int_get(&darktable.gui_running))
318328
{
@@ -760,12 +770,14 @@ void dt_control_navigation_redraw()
760770

761771
void dt_control_log_redraw()
762772
{
763-
DT_CONTROL_SIGNAL_RAISE(DT_SIGNAL_CONTROL_LOG_REDRAW);
773+
if(dt_control_running())
774+
DT_CONTROL_SIGNAL_RAISE(DT_SIGNAL_CONTROL_LOG_REDRAW);
764775
}
765776

766777
void dt_control_toast_redraw()
767778
{
768-
DT_CONTROL_SIGNAL_RAISE(DT_SIGNAL_CONTROL_TOAST_REDRAW);
779+
if(dt_control_running())
780+
DT_CONTROL_SIGNAL_RAISE(DT_SIGNAL_CONTROL_TOAST_REDRAW);
769781
}
770782

771783
static int _widget_queue_draw(void *widget)
@@ -893,6 +905,8 @@ gboolean dt_control_key_pressed_override(guint key, guint state)
893905

894906
void dt_control_hinter_message(const char *message)
895907
{
908+
if(!dt_control_running())
909+
return;
896910
dt_control_t *s = darktable.control;
897911
if(s && s->proxy.hinter.module)
898912
return s->proxy.hinter.set_message(s->proxy.hinter.module, message);

0 commit comments

Comments
 (0)