After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 622151 - [patch] port totem to GtkApplication
[patch] port totem to GtkApplication
Status: RESOLVED FIXED
Product: totem
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: General Totem maintainer(s)
General Totem maintainer(s)
Depends on: 622005 622424
Blocks:
 
 
Reported: 2010-06-20 07:13 UTC by Saleem Abdulrasool
Modified: 2011-02-26 02:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
0002-port-from-unique-to-GtkApplication.patch (13.94 KB, patch)
2010-06-20 07:13 UTC, Saleem Abdulrasool
needs-work Details | Review
0002-port-from-unique-to-GtkApplication.patch (13.69 KB, patch)
2010-06-21 14:30 UTC, Saleem Abdulrasool
none Details | Review
port from unique to GtkApplication (13.73 KB, patch)
2010-06-22 12:30 UTC, Bastien Nocera
none Details | Review
Port from unique to GApplication (14.70 KB, patch)
2010-06-22 17:46 UTC, Bastien Nocera
committed Details | Review

Description Saleem Abdulrasool 2010-06-20 07:13:10 UTC
Created attachment 164105 [details] [review]
0002-port-from-unique-to-GtkApplication.patch

As per our conversation on IRC, attached is a patch for porting Totem to GtkApplication.
Comment 1 Bastien Nocera 2010-06-20 10:04:08 UTC
Review of attachment 164105 [details] [review]:

::: src/totem-options.c
@@ +111,3 @@
 }
 
+static gchar *

Use char *

@@ +134,2 @@
 	commands = NULL;
+	action = totem_get_action_for_command (TOTEM_REMOTE_COMMAND_REPLACE);

Make this a macro.

@@ +149,3 @@
 	} else if (options->replace) {
+		g_free (action);
+		action = totem_get_action_for_command (TOTEM_REMOTE_COMMAND_REPLACE);

Make those 2 commands use the same macro as above.

::: src/totem.c
@@ +73,3 @@
+	   GApplication requires the platform_data to be of type a{sv}.  The
+	   parameter is a dictionary of string value pairs, with a single item,
+	   a string value mapped to url, which is the URL. */

You can remove that. Just explain that it's a{sv}.

@@ +150,3 @@
+static GVariant *
+variant_from_argv (int    argc,
+		   char **argv)

Move to totem-options.[ch]

@@ +242,3 @@
+		   Because default-quit is a constructible-only property, we are
+		   unable to set it after the constructor call.  As a result, we
+		   must explicitly init the gtk application. */

No need for the comment.
Comment 2 Saleem Abdulrasool 2010-06-20 17:34:23 UTC
(In reply to comment #1)
> Review of attachment 164105 [details] [review]:
> 
> ::: src/totem-options.c
> @@ +111,3 @@
>  }
> 
> +static gchar *
> 
> Use char *

Done.

> @@ +134,2 @@
>      commands = NULL;
> +    action = totem_get_action_for_command (TOTEM_REMOTE_COMMAND_REPLACE);
> 
> Make this a macro.

Make a macro for the free/lookup or make the totem_get_action_for_command a macro?

> @@ +149,3 @@
>      } else if (options->replace) {
> +        g_free (action);
> +        action = totem_get_action_for_command (TOTEM_REMOTE_COMMAND_REPLACE);
> 
> Make those 2 commands use the same macro as above.
> 
> ::: src/totem.c
> @@ +73,3 @@
> +       GApplication requires the platform_data to be of type a{sv}.  The
> +       parameter is a dictionary of string value pairs, with a single item,
> +       a string value mapped to url, which is the URL. */
> 
> You can remove that. Just explain that it's a{sv}.

Done.

> @@ +150,3 @@
> +static GVariant *
> +variant_from_argv (int    argc,
> +           char **argv)
> 
> Move to totem-options.[ch]

Why?  Ideally, once there is a way to set the default-quit property as well, this will simply go away.  The only user of it is the constructor for the GtkApplication, so in my mind it makes little sense to move this to totem-options.[ch].

> @@ +242,3 @@
> +           Because default-quit is a constructible-only property, we are
> +           unable to set it after the constructor call.  As a result, we
> +           must explicitly init the gtk application. */
> 
> No need for the comment.

Removed.
Comment 3 Bastien Nocera 2010-06-21 14:12:29 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > Review of attachment 164105 [details] [review] [details]:
> > 
> > ::: src/totem-options.c
> > @@ +111,3 @@
> >  }
> > 
> > +static gchar *
> > 
> > Use char *
> 
> Done.
> 
> > @@ +134,2 @@
> >      commands = NULL;
> > +    action = totem_get_action_for_command (TOTEM_REMOTE_COMMAND_REPLACE);
> > 
> > Make this a macro.
> 
> Make a macro for the free/lookup or make the totem_get_action_for_command a
> macro?

For the free/lookup.

> > @@ +149,3 @@
> >      } else if (options->replace) {
> > +        g_free (action);
> > +        action = totem_get_action_for_command (TOTEM_REMOTE_COMMAND_REPLACE);
> > 
> > Make those 2 commands use the same macro as above.
> > 
> > ::: src/totem.c
> > @@ +73,3 @@
> > +       GApplication requires the platform_data to be of type a{sv}.  The
> > +       parameter is a dictionary of string value pairs, with a single item,
> > +       a string value mapped to url, which is the URL. */
> > 
> > You can remove that. Just explain that it's a{sv}.
> 
> Done.
> 
> > @@ +150,3 @@
> > +static GVariant *
> > +variant_from_argv (int    argc,
> > +           char **argv)
> > 
> > Move to totem-options.[ch]
> 
> Why?  Ideally, once there is a way to set the default-quit property as well,
> this will simply go away.  The only user of it is the constructor for the
> GtkApplication, so in my mind it makes little sense to move this to
> totem-options.[ch].

Fair enough, can you file a bug against gtk+ to that effect?

> > @@ +242,3 @@
> > +           Because default-quit is a constructible-only property, we are
> > +           unable to set it after the constructor call.  As a result, we
> > +           must explicitly init the gtk application. */
> > 
> > No need for the comment.
> 
> Removed.
Comment 4 Saleem Abdulrasool 2010-06-21 14:30:40 UTC
Created attachment 164219 [details] [review]
0002-port-from-unique-to-GtkApplication.patch

Updated the patch, please let me know if I may push.

I had filed a bug for the default-quit property.  Turns out it is a duplicate of bug #622152.
Comment 5 Bastien Nocera 2010-06-21 17:03:31 UTC
Doesn't work for me:
  • #0 __strlen_sse2
    from /lib64/libc.so.6
  • #1 IA__g_strdup
    at gstrfuncs.c line 101
  • #2 value_collect_string
    at gvaluetypes.c line 293
  • #3 IA__g_signal_emit_valist
    at gsignal.c line 2959
  • #4 IA__g_signal_emit
    at gsignal.c line 3041
  • #5 IA__g_closure_invoke
    at gclosure.c line 767
  • #6 signal_emit_unlocked_R
    at gsignal.c line 3183
  • #7 IA__g_signal_emit_valist
    at gsignal.c line 2984
  • #8 IA__g_signal_emit
    at gsignal.c line 3041
  • #9 application_dbus_method_call
    at gdbusapplication.c line 90
  • #10 call_in_idle_cb
    at gdbusconnection.c line 3778
  • #11 g_main_dispatch
    at gmain.c line 2044
  • #12 IA__g_main_context_dispatch
    at gmain.c line 2597
  • #13 g_main_context_iterate
    at gmain.c line 2675
  • #14 IA__g_main_loop_run
    at gmain.c line 2883
  • #15 gtk_main
    from /usr/lib64/libgtk-x11-3.0.so.0
  • #16 main
    at totem.c line 346

The "server" part of Totem crashes.

glib2-2.25.9
gtk3-2.90.3
Comment 6 Saleem Abdulrasool 2010-06-22 04:47:34 UTC
Interesting, I cant seem to reproduce that.  From the backtrace you provided, the issue seems to be in gtk_main?

I have the same versions of glib and gtk+ installed.

Can you please provide me with a concrete way to reproduce this?  Ive tried all the methods, and even with quick succession, have not had any issues.
Comment 7 Bastien Nocera 2010-06-22 11:25:20 UTC
(In reply to comment #6)
> Interesting, I cant seem to reproduce that.  From the backtrace you provided,
> the issue seems to be in gtk_main?
> 
> I have the same versions of glib and gtk+ installed.
> 
> Can you please provide me with a concrete way to reproduce this?  Ive tried all
> the methods, and even with quick succession, have not had any issues.

1. totem &
2. wait for it to start
3. totem /path/to/movie

That should load the movie in the instance we just started.
Comment 8 Bastien Nocera 2010-06-22 12:30:03 UTC
Created attachment 164299 [details] [review]
port from unique to GtkApplication
Comment 9 Bastien Nocera 2010-06-22 12:30:34 UTC
Updated to apply to master.
Comment 10 Bastien Nocera 2010-06-22 17:46:26 UTC
Created attachment 164327 [details] [review]
Port from unique to GApplication
Comment 11 Bastien Nocera 2010-06-22 17:50:48 UTC
Comment on attachment 164327 [details] [review]
Port from unique to GApplication

Committed this patch. I'm debugging why I'm getting crashes with the GtkApplication version of the patch.
Comment 12 Christian Persch 2010-06-25 22:20:23 UTC
+	GEnumValue *value;
[...]
+	if (platform_data) {
+		GVariantIter iter;
+		GVariant *value;
Shadows the first |value| variable.

+		gchar *key;
+
+		g_variant_iter_init (&iter, platform_data);
+		if (g_variant_iter_next (&iter, "{sv}", &key, &value))
+			url = g_variant_get_string (value, NULL);
+	}

This looks wrong. First, you should use "{&sv}" to save a strdup and not leak the |key| (and use |const char *key|). Secondly, should check that key == "url" before using it as such. Also this leaks |value|. And it assumes "url" is the only entry in the dict; should use a "while (next (...)) { if (...) { ...; break; } }
Comment 13 Bastien Nocera 2010-06-27 13:36:19 UTC
Thank Christian for the notice.

commit 350b94324c2120bc042f4330f76ead789f90242f
Author: Bastien Nocera <hadess@hadess.net>
Date:   Sun Jun 27 14:30:23 2010 +0100

    Fix GApplication handling bugs
    
    As spotted by Christian Persch.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=622151#c12
Comment 14 Bastien Nocera 2011-02-26 02:00:01 UTC
I'm guessing this is solved now.