This page describes a suggestion for a new single instance scheme.

Modes of Operation

To allow control over whether gedit should run as a single instance application, or as a standalone application, and to allow proper blocking of the gedit process when waiting for files to be finished editing (like is used often with $EDITOR), the following modes of operations are suggested:

1. Single Instance (default)

  1. Instance already exists
    • Send command line arguments over DBus to existing instance
    • Use Message-Wait strategy for --wait

  2. Instance does not yet exist
    • Use default command line handling
    • Use For-Wait strategy for --wait

2. Standalone (--standalone)

  • Do not start DBus
  • Use default command line handling
  • Use Fork-Wait strategy for --wait

Fork-Wait strategy

The Fork-Wait strategy will fork the process. The parent process continues to run the normal mode of operation, starting up gedit etc. The child process will wait for a signal from the parent process that the wait is over (see Wait Handlers).

Message-Wait strategy

This strategy is slightly different since signalling that the wait is done has to be done over the message bus now. The process installs the wait with a certain message and then waits for a 'wait done' message to be sent by the instance process over the bus.

Wait Handlers

Wait handlers can be installed on documents or windows. If files were opened from the command line, wait handlers are installed on the documents opened by those files. In this case, the wait is done if all those documents are closed. If a new window was opened to open these documents, the window is also destroyed. If no files were specified and a new window was opened (either there was none, or with --new-window), then install a wait handler on the newly opened window. The wait done is signalled when this window is closed.

Apps/Gedit/Attic/NewSingleInstance (last edited 2020-04-14 13:34:06 by SébastienWilmet)