Skip to content

Commit f7837cd

Browse files
committed
Attempt to fix the splash screen issue.
- Rename all routines from darktable_ prefix to dt_ to conform to style. - Never force the splash screen. We are then loosing the crawler messages but this could create a race condition. We create the splash in a different threads than the main one. This is wrong as the creation of the splash screen is not protected against concurrent access. Possibly fixes #19992 #20111
1 parent bf68a24 commit f7837cd

File tree

5 files changed

+57
-57
lines changed

5 files changed

+57
-57
lines changed

src/common/darktable.c

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,7 @@ int dt_init(int argc,
16161616

16171617
if(init_gui)
16181618
{
1619-
darktable_splash_screen_create(NULL, FALSE);
1619+
dt_splash_screen_create(NULL);
16201620
}
16211621

16221622
// detect cpu features and decide which codepaths to enable
@@ -1629,20 +1629,20 @@ int dt_init(int argc,
16291629
dt_datetime_init();
16301630

16311631
// initialize the database
1632-
darktable_splash_screen_set_progress(_("opening image library"));
1632+
dt_splash_screen_set_progress(_("opening image library"));
16331633
darktable.db = dt_database_init(dbfilename_from_command, load_data, init_gui);
16341634
if(darktable.db == NULL)
16351635
{
16361636
dt_print(DT_DEBUG_ALWAYS, "ERROR : cannot open database");
1637-
darktable_splash_screen_destroy();
1637+
dt_splash_screen_destroy();
16381638
return 1;
16391639
}
16401640
else if(!dt_database_get_lock_acquired(darktable.db))
16411641
{
16421642
gboolean image_loaded_elsewhere = FALSE;
16431643
if(init_gui && argc > 1)
16441644
{
1645-
darktable_splash_screen_set_progress(_("forwarding image(s) to running instance"));
1645+
dt_splash_screen_set_progress(_("forwarding image(s) to running instance"));
16461646

16471647
// send the images to the other instance via dbus
16481648
dt_print(DT_DEBUG_ALWAYS,
@@ -1666,22 +1666,22 @@ int dt_init(int argc,
16661666
}
16671667
if(connection) g_object_unref(connection);
16681668
}
1669-
darktable_splash_screen_destroy(); // dismiss splash screen before potentially showing error dialog
1669+
dt_splash_screen_destroy(); // dismiss splash screen before potentially showing error dialog
16701670
if(!image_loaded_elsewhere && init_gui) dt_database_show_error(darktable.db);
16711671

16721672
dt_print(DT_DEBUG_ALWAYS, "ERROR: can't acquire database lock, aborting.");
16731673
return 1;
16741674
}
16751675

1676-
darktable_splash_screen_set_progress(_("preparing database"));
1676+
dt_splash_screen_set_progress(_("preparing database"));
16771677
dt_upgrade_maker_model(darktable.db);
16781678

16791679
// init darktable tags table
1680-
darktable_splash_screen_set_progress(_("setting up tags table"));
1680+
dt_splash_screen_set_progress(_("setting up tags table"));
16811681
dt_set_darktable_tags();
16821682

16831683
// Initialize the signal system
1684-
darktable_splash_screen_set_progress(_("initializing signals and control"));
1684+
dt_splash_screen_set_progress(_("initializing signals and control"));
16851685
darktable.signals = dt_control_signal_init();
16861686

16871687
dt_control_init(init_gui);
@@ -1700,7 +1700,7 @@ int dt_init(int argc,
17001700
if(styledir)
17011701
{
17021702
dt_gui_process_events();
1703-
darktable_splash_screen_set_progress(_("importing default styles"));
1703+
dt_splash_screen_set_progress(_("importing default styles"));
17041704
dt_import_default_styles(styledir);
17051705
g_free(styledir);
17061706
}
@@ -1720,12 +1720,11 @@ int dt_init(int argc,
17201720
{
17211721
if(dt_conf_get_bool("run_crawler_on_start") && !dt_gimpmode())
17221722
{
1723-
darktable_splash_screen_create(NULL, TRUE); // force the splash screen for the crawl even if user-disabled
17241723
// scan for cases where the database and xmp files have different timestamps
17251724
changed_xmp_files = dt_control_crawler_run();
17261725
if(!dt_conf_get_bool("show_splash_screen"))
17271726
{
1728-
darktable_splash_screen_destroy();
1727+
dt_splash_screen_destroy();
17291728
dt_gui_process_events(); // ensure that the splash screen is removed right away
17301729
}
17311730
}
@@ -1800,7 +1799,7 @@ int dt_init(int argc,
18001799
darktable.guides = dt_guides_init();
18011800

18021801
#ifdef HAVE_GRAPHICSMAGICK
1803-
darktable_splash_screen_set_progress(_("initializing GraphicsMagick"));
1802+
dt_splash_screen_set_progress(_("initializing GraphicsMagick"));
18041803
/* GraphicsMagick init */
18051804
#ifndef MAGICK_OPT_NO_SIGNAL_HANDER
18061805
InitializeMagick(darktable.progname);
@@ -1812,16 +1811,16 @@ int dt_init(int argc,
18121811
#endif
18131812
#elif defined HAVE_IMAGEMAGICK
18141813
/* ImageMagick init */
1815-
darktable_splash_screen_set_progress(_("initializing ImageMagick"));
1814+
dt_splash_screen_set_progress(_("initializing ImageMagick"));
18161815
MagickWandGenesis();
18171816
#endif
18181817

18191818
#ifdef HAVE_LIBHEIF
1820-
darktable_splash_screen_set_progress(_("initializing libheif"));
1819+
dt_splash_screen_set_progress(_("initializing libheif"));
18211820
heif_init(NULL);
18221821
#endif
18231822

1824-
darktable_splash_screen_set_progress(_("starting OpenCL"));
1823+
dt_splash_screen_set_progress(_("starting OpenCL"));
18251824
darktable.opencl = (dt_opencl_t *)calloc(1, sizeof(dt_opencl_t));
18261825
if(init_gui)
18271826
dt_control_add_job(DT_JOB_QUEUE_SYSTEM_BG, _detect_opencl_job_create(exclude_opencl));
@@ -1833,7 +1832,7 @@ int dt_init(int argc,
18331832

18341833
dt_wb_presets_init(NULL);
18351834

1836-
darktable_splash_screen_set_progress(_("loading noise profiles"));
1835+
dt_splash_screen_set_progress(_("loading noise profiles"));
18371836
darktable.noiseprofile_parser = dt_noiseprofile_init(noiseprofiles_from_command);
18381837

18391838
// must come before mipmap_cache, because that one will need to access
@@ -1850,14 +1849,14 @@ int dt_init(int argc,
18501849
dt_metadata_init();
18511850
dt_pthread_mutex_unlock(&darktable.metadata_threadsafe);
18521851

1853-
darktable_splash_screen_set_progress(_("synchronizing local copies"));
1852+
dt_splash_screen_set_progress(_("synchronizing local copies"));
18541853
dt_image_local_copy_synch();
18551854

18561855
#ifdef HAVE_GPHOTO2
18571856
// Initialize the camera control. this is done late so that the
18581857
// gui can react to the signal sent but before switching to
18591858
// lighttable!
1860-
darktable_splash_screen_set_progress(_("initializing camera control"));
1859+
dt_splash_screen_set_progress(_("initializing camera control"));
18611860
darktable.camctl = dt_camctl_new();
18621861
#endif
18631862

@@ -1867,11 +1866,11 @@ int dt_init(int argc,
18671866

18681867
if(init_gui)
18691868
{
1870-
darktable_splash_screen_set_progress(_("initializing GUI"));
1869+
dt_splash_screen_set_progress(_("initializing GUI"));
18711870
if(dt_gui_gtk_init(darktable.gui))
18721871
{
18731872
dt_print(DT_DEBUG_ALWAYS, "[dt_init] ERROR: can't init gui, aborting.");
1874-
darktable_splash_screen_destroy();
1873+
dt_splash_screen_destroy();
18751874
return 1;
18761875
}
18771876
dt_bauhaus_init();
@@ -1893,11 +1892,11 @@ int dt_init(int argc,
18931892
if(!darktable.develop)
18941893
{
18951894
dt_print(DT_DEBUG_ALWAYS, "[dt_init] ERROR: can't init develop system, aborting.");
1896-
darktable_splash_screen_destroy();
1895+
dt_splash_screen_destroy();
18971896
return 1;
18981897
}
18991898

1900-
darktable_splash_screen_set_progress(_("loading processing modules"));
1899+
dt_splash_screen_set_progress(_("loading processing modules"));
19011900
darktable.imageio = (dt_imageio_t *)calloc(1, sizeof(dt_imageio_t));
19021901
dt_imageio_init(darktable.imageio);
19031902

@@ -1911,7 +1910,7 @@ int dt_init(int argc,
19111910
if(dt_ioppr_check_so_iop_order(darktable.iop, darktable.iop_order_list))
19121911
{
19131912
dt_print(DT_DEBUG_ALWAYS, "[dt_init] ERROR: iop order looks bad, aborting.");
1914-
darktable_splash_screen_destroy();
1913+
dt_splash_screen_destroy();
19151914
return 1;
19161915
}
19171916

@@ -1932,20 +1931,20 @@ int dt_init(int argc,
19321931

19331932
if(init_gui)
19341933
{
1935-
darktable_splash_screen_set_progress(_("loading utility modules"));
1934+
dt_splash_screen_set_progress(_("loading utility modules"));
19361935
darktable.lib = (dt_lib_t *)calloc(1, sizeof(dt_lib_t));
19371936
dt_lib_init(darktable.lib);
19381937

19391938
// init the gui part of views
1940-
darktable_splash_screen_set_progress(_("loading views"));
1939+
dt_splash_screen_set_progress(_("loading views"));
19411940
dt_view_manager_gui_init(darktable.view_manager);
19421941
}
19431942

19441943
/* init lua last, since it's user made stuff it must be in the real environment */
19451944
#ifdef USE_LUA
1946-
darktable_splash_screen_set_progress(_("initializing Lua"));
1945+
dt_splash_screen_set_progress(_("initializing Lua"));
19471946
// after the following Lua startup call, we can no longer use dt_gui_process_events() or we hang;
1948-
// this also means no more calls to darktable_splash_screen_set_progress()
1947+
// this also means no more calls to dt_splash_screen_set_progress()
19491948
dt_lua_init(darktable.lua_state.state, lua_command);
19501949
#endif
19511950

@@ -1975,7 +1974,7 @@ int dt_init(int argc,
19751974
{
19761975
// If only one image is listed, attempt to load it in darkroom
19771976
#ifndef USE_LUA // may cause UI hang since after LUA init
1978-
darktable_splash_screen_set_progress(_("importing image"));
1977+
dt_splash_screen_set_progress(_("importing image"));
19791978
#endif
19801979
dt_load_from_string(argv[1], TRUE, NULL);
19811980
}
@@ -2034,7 +2033,7 @@ int dt_init(int argc,
20342033
// show the main window and restore its geometry to that saved in the config file
20352034
gtk_widget_show_all(dt_ui_main_window(darktable.gui->ui));
20362035
dt_gui_gtk_load_config();
2037-
darktable_splash_screen_destroy();
2036+
dt_splash_screen_destroy();
20382037

20392038
// finally set the cursor to be the default.
20402039
// for some reason this is needed on some systems to pick up the correctly themed cursor
@@ -2094,7 +2093,7 @@ void dt_cleanup()
20942093
const gboolean init_gui = (darktable.gui != NULL);
20952094

20962095
// if(init_gui)
2097-
// darktable_exit_screen_create(NULL, FALSE);
2096+
// darktable_exit_screen_create(NULL);
20982097

20992098
dt_stop_backthumbs_crawler(TRUE);
21002099

@@ -2275,7 +2274,7 @@ void dt_cleanup()
22752274
dt_exif_cleanup();
22762275

22772276
if(init_gui)
2278-
darktable_exit_screen_destroy();
2277+
dt_exit_screen_destroy();
22792278
}
22802279

22812280
/* The dt_print variations can be used with a combination of DT_DEBUG_ flags.

src/control/crawler.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,15 @@ GList *dt_control_crawler_run(void)
159159
int flags = sqlite3_column_int(stmt, 4);
160160
++image_count;
161161

162-
// update the progress message - five times per second for first four seconds, then once per second
162+
// update the progress message - five times per second for first
163+
// four seconds, then once per second.
163164
const double curr_time = dt_get_wtime();
164165
if(curr_time >= last_time + ((curr_time - start_time > 4.0) ? SLOW_UPDATE : FAST_UPDATE))
165166
{
166167
const double fraction = image_count / (double)total_images;
167-
darktable_splash_screen_set_progress_percent(_("checking for updated sidecar files (%d%%)"),
168-
fraction,
169-
curr_time - start_time);
168+
dt_splash_screen_set_progress_percent(_("checking for updated sidecar files (%d%%)"),
169+
fraction,
170+
curr_time - start_time);
170171
last_time = curr_time;
171172
}
172173

src/gui/gtk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2009-2025 darktable developers.
3+
Copyright (C) 2009-2026 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -3083,7 +3083,7 @@ gboolean dt_gui_show_standalone_yes_no_dialog(const char *title,
30833083
gtk_widget_show_all(window);
30843084

30853085
// to prevent the splash screen from hiding the yes/no dialog
3086-
darktable_splash_screen_destroy();
3086+
dt_splash_screen_destroy();
30873087

30883088
gtk_window_set_keep_above(GTK_WINDOW(window), TRUE);
30893089
gtk_main();

src/gui/splash.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2024-2025 darktable developers.
3+
Copyright (C) 2024-2026 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -126,16 +126,15 @@ static void _set_header_bar(GtkWidget *dialog)
126126
#endif
127127
}
128128

129-
void darktable_splash_screen_create(GtkWindow *parent_window,
130-
const gboolean force)
129+
void dt_splash_screen_create(GtkWindow *parent_window)
131130
{
132131
// no-op if the splash has already been created; if not, only run if
133132
// the splash screen is enabled in the config or we are told to
134133
// create it regardless.
135134
if(splash_screen
136135
|| dt_check_gimpmode("file")
137136
|| dt_check_gimpmode("thumb")
138-
|| (!dt_conf_get_bool("show_splash_screen") && !force))
137+
|| (!dt_conf_get_bool("show_splash_screen")))
139138
{
140139
return;
141140
}
@@ -241,7 +240,7 @@ void darktable_splash_screen_create(GtkWindow *parent_window,
241240
_process_all_gui_events();
242241
}
243242

244-
void darktable_splash_screen_set_progress(const char *msg)
243+
void dt_splash_screen_set_progress(const char *msg)
245244
{
246245
if(splash_screen)
247246
{
@@ -257,9 +256,9 @@ void darktable_splash_screen_set_progress(const char *msg)
257256
}
258257
}
259258

260-
void darktable_splash_screen_set_progress_percent(const char *msg,
261-
const double fraction,
262-
const double elapsed)
259+
void dt_splash_screen_set_progress_percent(const char *msg,
260+
const double fraction,
261+
const double elapsed)
263262
{
264263
if(splash_screen)
265264
{
@@ -289,7 +288,7 @@ void darktable_splash_screen_set_progress_percent(const char *msg,
289288
}
290289
}
291290

292-
void darktable_splash_screen_destroy()
291+
void dt_splash_screen_destroy()
293292
{
294293
if(splash_screen)
295294
{
@@ -300,16 +299,15 @@ void darktable_splash_screen_destroy()
300299
}
301300
}
302301

303-
void darktable_exit_screen_create(GtkWindow *parent_window,
304-
const gboolean force)
302+
void dt_exit_screen_create(GtkWindow *parent_window)
305303
{
306304
// no-op if the exit screen has already been created; if not, only
307305
// run if the splash screen is enabled in the config or we are told
308306
// to create it regardless
309307
if(exit_screen
310308
|| dt_check_gimpmode("file")
311309
|| dt_check_gimpmode("thumb")
312-
|| (!dt_conf_get_bool("show_splash_screen") && !force))
310+
|| (!dt_conf_get_bool("show_splash_screen")))
313311
{
314312
return;
315313
}
@@ -352,7 +350,7 @@ void darktable_exit_screen_create(GtkWindow *parent_window,
352350
dt_gui_process_events();
353351
}
354352

355-
void darktable_exit_screen_destroy()
353+
void dt_exit_screen_destroy()
356354
{
357355
if(exit_screen)
358356
{

src/gui/splash.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2024 darktable developers.
3+
Copyright (C) 2024-2026 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -18,13 +18,15 @@
1818

1919
#include <gtk/gtk.h>
2020

21-
void darktable_splash_screen_create(GtkWindow *parent, gboolean force);
22-
void darktable_splash_screen_set_progress(const char *msg);
23-
void darktable_splash_screen_set_progress_percent(const char *msg, double fraction, double elapsed);
24-
void darktable_splash_screen_destroy();
21+
void dt_splash_screen_create(GtkWindow *parent);
22+
void dt_splash_screen_set_progress(const char *msg);
23+
void dt_splash_screen_set_progress_percent(const char *msg,
24+
const double fraction,
25+
const double elapsed);
26+
void dt_splash_screen_destroy();
2527

26-
void darktable_exit_screen_create(GtkWindow *parent, gboolean force);
27-
void darktable_exit_screen_destroy();
28+
void dt_exit_screen_create(GtkWindow *parent);
29+
void dt_exit_screen_destroy();
2830

2931
// clang-format off
3032
// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py

0 commit comments

Comments
 (0)