Fix Windows crash when importing folders from the command line
Resolves: #19914.
I think it's better to release darktable that won't display the import progress in the Windows taskbar than to crash during this operation...
So, I have some time to look at the code and check my assumption. The very first lesson: never do one-line compact constructs with passing the result of a function call to another function if there is a possibility of a situation with a NULL return and a crash on that.
The culprit of the crash:
HWND hwnd = GDK_WINDOW_HWND(gtk_widget_get_window(dt_ui_main_window(darktable.gui->ui)));
Here gtk_widget_get_window can return NULL if the widget window is not yet realized. And in fact, it is indeed not yet realized at the time of running this code and importing of the folder and, yes, the GDK_WINDOW_HWND argument will be NULL and this will cause a crash.
This code was written more than 8 years ago in c3a18e97927651655082b5b65c1b080a0f34763e. It is likely that at the time of writing it was tested and at least did not crash. I assume that the root of the problem was in a later rearrangement of the darktable initialization code, which caused the folder import process from the command line to occur before the main window widget is realized.