Re: Problems with GApplicationCommanLine printing to wrong instance



On 28 May 2016 at 17:58, Christian Stadelmann
<chris privat genodeftest de> wrote:
Thanks for the reply!

Am Samstag, den 28.05.2016, 16:40 +0200 schrieb Neil Muller:
On 27 May 2016 at 23:48, Christian Stadelmann
<chris privat genodeftest de> wrote:
Hi

I have a trivial application (see below). I expect it to print
"Foo" on
the first instance it is running and "Second" on each successive
instance.

Instead, only the first instance is printing stuff and the second
doesn't do anything before it exits.

Am I doing something wrong? Or did I run into a bug?


You appear to have missed some of the documentation on
GioApplication.

Quoting from the relevant sections

"Another feature that Gio.Application (optionally) provides is
process
uniqueness. Applications can make use of this functionality by
providing a unique application ID. If given, only one application
with
this ID can be running at a time per session."

"The ::command-line signal is emitted on the primary instance when a
commandline is not handled locally."

Since you are providing an applciation ID ("org.test"), and the only
command-line handling is in the "command-line" signal handler,
everything looks like it behaving as documented to me.

So the "command-line" signal handler is executed on the primary
instance if a secondary instance is being started. That's ok for me and
exactly what I expected and watched happen.

Documentation for the "command-line" signal states for the parameter of
this function:

command_line – a Gio.ApplicationCommandLine representing the passed
commandline

I understand it this way:
When the first instance starts, its command line is passed there.
When the second instance starts, its command line is passed into the
first intance's command-line signal handler. This way the 2nd command
line ends up in the first process. This is also what happens.

Now, from g_application_command_line_print() and _printerr():

Formats a message and prints it using the stdout print handler in the
invoking process.
If cmdline is a local invocation then this is exactly equivalent to
g_print(). If cmdline is remote then this is equivalent to calling
g_print() in the invoking process.


But you're not calling do_printerr_literal on the remote cmdline -
you're calling the class method on Gio.ApplicationCommandLine. That's
quite different.

You want to be calling

new_cli.do_print_literal

instead.

-- 
Neil Muller
drnlmuller gmail com

I've got a gmail account. Why haven't I become cool?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]