Merge lp://qastaging/~3v1n0/unity/dbus-indicators-proxy into lp://qastaging/unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 2133
Proposed branch: lp://qastaging/~3v1n0/unity/dbus-indicators-proxy
Merge into: lp://qastaging/unity
Prerequisite: lp://qastaging/~3v1n0/unity/indicators-p
Diff against target: 1049 lines (+260/-524)
7 files modified
UnityCore/DBusIndicators.cpp (+202/-450)
UnityCore/DBusIndicators.h (+2/-8)
UnityCore/GLibDBusProxy.cpp (+51/-55)
UnityCore/GLibDBusProxy.h (+2/-2)
UnityCore/Indicators.cpp (+2/-5)
UnityCore/Indicators.h (+1/-1)
plugins/unityshell/src/PanelView.cpp (+0/-3)
To merge this branch: bzr merge lp://qastaging/~3v1n0/unity/dbus-indicators-proxy
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+97328@code.qastaging.launchpad.net

Commit message

DBusIndicators code rewritten to use glib::DBusProxy instead of raw gdbus calls

Description of the change

DBusIndicators code rewritten to use glib::DBusProxy instead of raw gdbus calls.

The code now is more simple, clean and C++ conformant. Also, now we always make sure that the panel is launched when it is not available (before this was not happening in some corner cases).

Tests are covered by lp:~3v1n0/unity/indicators-tests

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

787 + bool auto_reconnect)

What are you actually trying to achieve with this? GDBusProxy automatically reconnects itself if you construct it using a known service name (as opposed to unique bus address). Therefore it seems redundant to me.

If you want to make sure that a service is alive, all you need to do is watch changes to the connected state and if it disconnects, just call any method from given interface and that will dbus-activate the service again.

review: Needs Information
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> 787 + bool auto_reconnect)
>
> What are you actually trying to achieve with this? GDBusProxy automatically
> reconnects itself if you construct it using a known service name (as opposed
> to unique bus address). Therefore it seems redundant to me.

Yeah, I know, but it doesn't work here for the reason we discovered...

> If you want to make sure that a service is alive, all you need to do is watch
> changes to the connected state and if it disconnects, just call any method
> from given interface and that will dbus-activate the service again.

That's what I've tried to do, but it doesn't work here because glib::DBusProxy notify us about the disconnection event when actually the name has vanished, but the proxy is not disconnected yet.
Adding a timeout fixes it, but we should handle that in a better way.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> 787 + bool auto_reconnect)
>
> What are you actually trying to achieve with this? GDBusProxy automatically
> reconnects itself if you construct it using a known service name (as opposed
> to unique bus address). Therefore it seems redundant to me.

Ok this is now fixed into lp:~3v1n0/unity/dbus-indicators-proxy that will merge in this one as you know ;)

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> Ok this is now fixed into lp:~3v1n0/unity/dbus-indicators-proxy that will
> merge in this one as you know ;)

Ops, I meant lp:~3v1n0/unity/dbus-proxy-name-owner-watch

Revision history for this message
Unity Merger (unity-merger) wrote :

The prerequisite lp:~3v1n0/unity/indicators-p has not yet been merged into lp:unity.

Revision history for this message
Michal Hruby (mhr3) wrote :

Overall I'm liking this a lot - mostly because of "(+234/-516)" :) I have some concerns though:

269 + RequestSyncAll();
270 +
271 + reconnect_timeout_id_ = g_timeout_add_seconds(1, [](gpointer data) -> gboolean {
272 + auto self = static_cast<DBusIndicators::Impl*>(data);
273 +
274 + if (!self->gproxy_.IsConnected())
275 + {
276 + self->RequestSyncAll();
277 + return TRUE;
278 + }
279 +
280 + self->reconnect_timeout_id_ = 0;
281 + return FALSE;
282 + }, this);

Are you sure you want to call RequestSyncAll also outside of the lambda expression? Plus you should be checking if reconnect_timeout_id == 0, before calling g_timeout_add...

146 + struct CallData
147 + {
148 + Impl* self;
149 + GVariant *parameters;
150 + };

I'm not really liking this, it's unclear who owns the variant (or rather why isn't it unreffed) - using our Variant wrapper should fix this. What's worse is that the CallData can be alive even after the Impl instance is destroyed which can lead to a crash.

review: Needs Fixing
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> Overall I'm liking this a lot - mostly because of "(+234/-516)" :)

Ehehe ;)

> Are you sure you want to call RequestSyncAll also outside of the lambda
> expression?

Yes. Because after we get a disconnection event we can try immediately to restore the service, it that fails we retry every 1 second. This assures that if we have a valid u-p-s running or in the system as well, we use it!

> Plus you should be checking if reconnect_timeout_id == 0, before
> calling g_timeout_add...

Yes, sure.

> 146 + struct CallData
> 147 + {
> 148 + Impl* self;
> 149 + GVariant *parameters;
> 150 + };
>
> I'm not really liking this, it's unclear who owns the variant (or rather why
> isn't it unreffed) - using our Variant wrapper should fix this.

Well, as you know the proxy handles it, so I didn't ref/unreff'ed it... But I'll move to glib::Variant.

> What's worse
> is that the CallData can be alive even after the Impl instance is destroyed
> which can lead to a crash.

This should be very unlikely using an idle, but I'll make that more safe as well.

Revision history for this message
Michal Hruby (mhr3) wrote :

Awesome, thanks!

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

No proposals found for merge of lp:~3v1n0/unity/indicators-p into lp:unity.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.