summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorFriedrich Beckmann <friedrich.beckmann@gmx.de>2020-06-18 21:08:28 +0200
committerFriedrich Beckmann <friedrich.beckmann@gmx.de>2020-06-18 21:08:28 +0200
commit7d9a939f9957ab089c98d91bdf68ec7b4a577588 (patch)
treedc7123f5465f3bd1929f4684ef091e5e3ee453ab /gtk
parenta3ad7fa80f764fb7bcbe28fd1ede6a85ee85fc74 (diff)
downloadgtk+-7d9a939f9957ab089c98d91bdf68ec7b4a577588.tar.gz
quartz: gtk-application - inhibit openFiles events from cmdline
When an application is started via cmdline, then openFiles events from MacOS are generated although gtkapplication already interprets the cmdline arguments and opens suitable arguments as files. So they would be opened twice. Depending on the exact situation the openFiles event can also be issued before the startup signal is given. Depending on the application this can result in a crash due to unexpected behaviour. I took this idea from the gedit-app-osx.m file. Also from Jesse van den Kieboom. See: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/2098#note_842975 https://gitlab.gnome.org/GNOME/gtk/-/commit/a3ad7fa80f764fb7bcbe https://gitlab.gnome.org/GNOME/gedit/-/blob/master/gedit/gedit-app-osx.m#L592
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkapplication-quartz.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gtk/gtkapplication-quartz.c b/gtk/gtkapplication-quartz.c
index 7abea53a5d..fec5025496 100644
--- a/gtk/gtkapplication-quartz.c
+++ b/gtk/gtkapplication-quartz.c
@@ -337,6 +337,13 @@ gtk_application_impl_quartz_is_inhibited (GtkApplicationImpl *impl,
static void
gtk_application_impl_quartz_init (GtkApplicationImplQuartz *quartz)
{
+ /* This is required so that Cocoa is not going to parse the
+ command line arguments by itself and generate OpenFile events.
+ We already parse the command line ourselves, so this is needed
+ to prevent opening files twice, etc. */
+ [[NSUserDefaults standardUserDefaults] setObject:@"NO"
+ forKey:@"NSTreatUnknownArgumentsAsOpen"];
+
quartz->combined = g_menu_new ();
}