Merge lp:~jamesh/whoopsie-preferences/bug-1720331 into lp:whoopsie-preferences

Proposed by James Henstridge
Status: Merged
Merged at revision: 72
Proposed branch: lp:~jamesh/whoopsie-preferences/bug-1720331
Merge into: lp:whoopsie-preferences
Diff against target: 81 lines (+27/-13)
3 files modified
configure.ac (+1/-1)
debian/changelog (+14/-0)
src/whoopsie-preferences.c (+12/-12)
To merge this branch: bzr merge lp:~jamesh/whoopsie-preferences/bug-1720331
Reviewer Review Type Date Requested Status
Daisy Pluckers Pending
Review via email: mp+332105@code.launchpad.net

Commit message

Don't export object on the bus until it has been fully constructed.

Description of the change

Don't export object on the bus until it has been fully constructed.

As well as ensuring that the WhoopsiePreferences object is usable as soon as it attaches to the bus, it also silences a PropertiesChanged signal broadcast during startup as whoopsie-preferences reads the current system configuration.

This helps avoid confusion when whoopsie-preferences is activated by one of the Set method calls. For example, the following chain of events:

 1. C->S SetReportCrashes(true) method call
 2. dbus-daemon activates whoopsie-preferences
 3. S->C PropertiesChanged(ReportCrashes=true) signal with current state
 4. S->C SetReportCrashes method return message
 5. S->C PropertiesChanged(ReportCrashes=false) signal with new state

Here, the first signal broadcast at (3) is unwanted, and can confuse the client into thinking that its change has been ignored or some other client has changed the state.

By setting the initial values for the properties before exporting on the bus, the initial signal broadcast is avoided.

To post a comment you must log in.
Revision history for this message
James Henstridge (jamesh) wrote :

The difference can be demonstrated by running the following command in one terminal:

    sudo dbus-monitor --system 'interface=com.ubuntu.WhoopsiePreferences' 'interface=org.freedesktop.DBus.Properties,arg0=com.ubuntu.WhoopsiePreferences'

And then in another terminal compare starting the old version of whoopsie-preferences vs. the version from this branch. The spurious signal is gone.

Using d-feet to call SetReportCrashes shows that PropertiesChanged is still sent when a change actually happens though.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'configure.ac'
--- configure.ac 2014-04-01 11:31:55 +0000
+++ configure.ac 2017-10-11 10:57:52 +0000
@@ -1,5 +1,5 @@
1AC_INIT([whoopsie-preferences], 1AC_INIT([whoopsie-preferences],
2 [0.11], 2 [0.19],
3 [http://launchpad.net/whoopsie-preferences])3 [http://launchpad.net/whoopsie-preferences])
44
5m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])5m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
66
=== modified file 'debian/changelog'
--- debian/changelog 2015-09-10 14:00:51 +0000
+++ debian/changelog 2017-10-11 10:57:52 +0000
@@ -1,3 +1,17 @@
1whoopsie-preferences (0.19) artful; urgency=medium
2
3 * Don't export object on the bus until it has been fully constructed.
4 (LP: #1720331)
5
6 -- James Henstridge <james.henstridge@canonical.com> Wed, 11 Oct 2017 18:20:35 +0800
7
8whoopsie-preferences (0.18build1) artful; urgency=medium
9
10 * No-change rebuild to pick up -fPIE compiler default in static
11 libraries
12
13 -- Steve Langasek <steve.langasek@ubuntu.com> Fri, 21 Apr 2017 20:59:50 +0000
14
1whoopsie-preferences (0.18) wily; urgency=medium15whoopsie-preferences (0.18) wily; urgency=medium
216
3 * Truncate the file manually if update-rc.d fails (e.g. on an r/o phone).17 * Truncate the file manually if update-rc.d fails (e.g. on an r/o phone).
418
=== modified file 'src/whoopsie-preferences.c'
--- src/whoopsie-preferences.c 2015-09-10 13:19:51 +0000
+++ src/whoopsie-preferences.c 2017-10-11 10:57:52 +0000
@@ -487,18 +487,6 @@
487 WhoopsiePreferences* interface;487 WhoopsiePreferences* interface;
488 GError* error = NULL;488 GError* error = NULL;
489489
490 interface = whoopsie_preferences_skeleton_new ();
491 if (!g_dbus_interface_skeleton_export (
492 G_DBUS_INTERFACE_SKELETON (interface),
493 connection,
494 "/com/ubuntu/WhoopsiePreferences", &error)) {
495
496 g_print ("Could not export path: %s\n", error->message);
497 g_error_free (error);
498 g_main_loop_quit (loop);
499 return;
500 }
501
502 authority = polkit_authority_get_sync (NULL, &error);490 authority = polkit_authority_get_sync (NULL, &error);
503 if (authority == NULL) {491 if (authority == NULL) {
504 g_print ("Could not get authority: %s\n", error->message);492 g_print ("Could not get authority: %s\n", error->message);
@@ -509,6 +497,7 @@
509 loop_shutdown = g_timeout_add_seconds (60, (GSourceFunc) g_main_loop_quit,497 loop_shutdown = g_timeout_add_seconds (60, (GSourceFunc) g_main_loop_quit,
510 loop);498 loop);
511499
500 interface = whoopsie_preferences_skeleton_new ();
512 g_signal_connect (interface, "notify::report-crashes",501 g_signal_connect (interface, "notify::report-crashes",
513 G_CALLBACK (whoopsie_preferences_changed),502 G_CALLBACK (whoopsie_preferences_changed),
514 "report_crashes");503 "report_crashes");
@@ -535,6 +524,17 @@
535 monitor_autoreport_file (interface);524 monitor_autoreport_file (interface);
536 whoopsie_preferences_load (interface);525 whoopsie_preferences_load (interface);
537 whoopsie_preferences_dbus_notify (interface);526 whoopsie_preferences_dbus_notify (interface);
527
528 if (!g_dbus_interface_skeleton_export (
529 G_DBUS_INTERFACE_SKELETON (interface),
530 connection,
531 "/com/ubuntu/WhoopsiePreferences", &error)) {
532
533 g_print ("Could not export path: %s\n", error->message);
534 g_error_free (error);
535 g_main_loop_quit (loop);
536 return;
537 }
538}538}
539539
540static void540static void

Subscribers

People subscribed via source and target branches