Issue #9598: do not rely on GApplication uniqueness feature.

When passing an application ID (which is necessary for application inhibition to
work, i.e. logoff/reboot/shutdown inhibition), GApplication will try to ensure
process uniqueness, which will trigger a new activation to an already running
process. Since our current code assumes that the application can be activated a
single time only, this was what was triggering a whole lot of errors (on the
first running process) in #9598 because there was all the initialization code
which ran again, whereas it was not supposed to.

This doubly-running initialization code was also what completely messed up the
session files, hence broke the GUI after a restart (#9599).

Therefore passing G_APPLICATION_NON_UNIQUE advertizes we don't want GIO to
handle process uniqueness for us.

Note that this is actually a very interesting feature which we have had in GIMP
codebase forever. It would be interesting to kill all our own uniqueness code in
favor of GIO code (and let them handle/maintain passing command line arguments
from one process to another, for all possible platforms). So I added a TODO for
this (for now, we just ignore this feature as it doesn't work well with current
codebase).
This commit is contained in:
Jehan 2023-06-12 00:58:09 +02:00
parent 7f83b27c3c
commit eb0ee5f33a
2 changed files with 13 additions and 0 deletions

View file

@ -66,6 +66,7 @@ gimp_console_app_new (Gimp *gimp,
app = g_object_new (GIMP_TYPE_CONSOLE_APP,
"application-id", GIMP_APPLICATION_ID,
"flags", G_APPLICATION_DEFAULT_FLAGS | G_APPLICATION_NON_UNIQUE,
"gimp", gimp,
"filenames", filenames,
"as-new", as_new,

View file

@ -131,6 +131,18 @@ gimp_app_new (Gimp *gimp,
app = g_object_new (GIMP_TYPE_APP,
"application-id", GIMP_APPLICATION_ID,
/* We have our own code to handle process uniqueness, so
* when we reached this code, we are already passed this
* (it means that either this is the first process, or we
* don't want uniqueness). See bugs #9598 and #9599 for
* what happens when we let GIO try to handle uniqueness.
*
* TODO: since GApplication has code to pass over files
* and command line arguments, we may eventually want to
* remove our own code for uniqueness and batch command
* inter-process communication. This should be tested.
*/
"flags", G_APPLICATION_DEFAULT_FLAGS | G_APPLICATION_NON_UNIQUE,
"gimp", gimp,
"filenames", filenames,
"as-new", as_new,