Skip to content

Commit

Permalink
Merge pull request #17298 from zisoft/macos-import
Browse files Browse the repository at this point in the history
fix macOS crash on dt start with import
  • Loading branch information
TurboGit committed Aug 9, 2024
2 parents 4daa753 + be1fec5 commit e84f968
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/common/darktable.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ gboolean dt_supported_image(const gchar *filename)
return supported;
}

#ifndef MAC_INTEGRATION
static gboolean _is_directory(const gchar *input)
{
gboolean is_dir = FALSE;
Expand Down Expand Up @@ -401,6 +402,7 @@ static void _switch_to_new_filmroll(const gchar *input)
free(filename);
}
}
#endif

dt_imgid_t dt_load_from_string(const gchar *input,
const gboolean open_image_in_dr,
Expand Down Expand Up @@ -1699,6 +1701,7 @@ int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load
// into a lua deadlock. having another call later is ok
dt_ctl_switch_mode_to(mode);

#ifndef MAC_INTEGRATION
// load image(s) specified on cmdline. this has to happen after
// lua is initialized as image import can run lua code
if(argc == 2 && !_is_directory(argv[1]))
Expand All @@ -1715,6 +1718,7 @@ int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load
dt_control_add_job(darktable.control,
DT_JOB_QUEUE_USER_BG, dt_pathlist_import_create(argc,argv));
}
#endif

// there might be some info created in dt_configure_runtime_performance() for feedback
gboolean not_again = TRUE;
Expand Down
7 changes: 5 additions & 2 deletions src/gui/gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,10 @@ static gboolean _osx_openfile_callback(GtkosxApplication *OSXapp,
gpointer user_data)
#endif
{
return dt_is_valid_imgid(dt_load_from_string(path, TRUE, NULL));
// when multiple files are dropped on the app icon this callback
// gets called for each file individually so we don't request to
// open the darkroom here.
return dt_is_valid_imgid(dt_load_from_string(path, FALSE, NULL));
}
#endif

Expand Down Expand Up @@ -1267,7 +1270,7 @@ int dt_gui_gtk_init(dt_gui_gtk_t *gui)
G_CALLBACK(_osx_openfile_callback), NULL);
#endif

GtkWidget *widget;
GtkWidget *widget;
gui->ui = g_malloc0(sizeof(dt_ui_t));
gui->surface = NULL;
gui->center_tooltip = 0;
Expand Down

0 comments on commit e84f968

Please sign in to comment.