Merge lp:~nick-dedekind/unity/smart-scopes.lp1159200 into lp:~unity-team/unity/libunity-7.0-breakage

Proposed by Nick Dedekind
Status: Merged
Approved by: Michal Hruby
Approved revision: no longer in the source branch.
Merged at revision: 3108
Proposed branch: lp:~nick-dedekind/unity/smart-scopes.lp1159200
Merge into: lp:~unity-team/unity/libunity-7.0-breakage
Diff against target: 70 lines (+22/-11)
1 file modified
UnityCore/ScopeProxy.cpp (+22/-11)
To merge this branch: bzr merge lp:~nick-dedekind/unity/smart-scopes.lp1159200
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michal Hruby (community) Approve
Review via email: mp+155742@code.launchpad.net

Commit message

Fixed crash when not receiving a valid reply for an activation request.

Description of the change

Fixed crash when not receiving a valid reply for an activation request.

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

Not sure I like this, doesn't the error case deserve it's own branch?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michal Hruby (mhr3) wrote :

+1

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UnityCore/ScopeProxy.cpp'
2--- UnityCore/ScopeProxy.cpp 2013-03-22 12:55:56 +0000
3+++ UnityCore/ScopeProxy.cpp 2013-03-27 16:22:28 +0000
4@@ -147,6 +147,9 @@
5
6 static void OnScopeSearchCallback(GObject *source_object, GAsyncResult *res, gpointer user_data)
7 {
8+ if (!UNITY_PROTOCOL_IS_SCOPE_PROXY(source_object))
9+ return;
10+
11 std::unique_ptr<SearchData> data(static_cast<SearchData*>(user_data));
12 glib::Error error;
13 std::unique_ptr<GHashTable, void(*)(GHashTable*)> hint_ret(unity_protocol_scope_proxy_search_finish(UNITY_PROTOCOL_SCOPE_PROXY(source_object), res, &error),
14@@ -174,26 +177,34 @@
15 };
16 static void OnScopeActivateCallback(GObject *source_object, GAsyncResult *res, gpointer user_data)
17 {
18+ if (!UNITY_PROTOCOL_IS_SCOPE_PROXY(source_object))
19+ return;
20+
21 std::unique_ptr<ActivateData> data(static_cast<ActivateData*>(user_data));
22 UnityProtocolActivationReplyRaw result;
23+ memset(&result, 0, sizeof(UnityProtocolActivationReplyRaw));
24 glib::Error error;
25 unity_protocol_scope_proxy_activate_finish(UNITY_PROTOCOL_SCOPE_PROXY(source_object), res, &result, &error);
26- if (error && g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
27+
28+ if (error)
29 {
30- LOG_DEBUG(logger) << "Activate cancelled.";
31- return;
32+ if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
33+ {
34+ LOG_DEBUG(logger) << "Activate cancelled.";
35+ return;
36+ }
37+ if (data && data->callback)
38+ data->callback(LocalResult(), ScopeHandledType::NOT_HANDLED, glib::HintsMap(), error);
39 }
40-
41- if (data && data->callback)
42+ else if (data && data->callback)
43 {
44- ScopeHandledType handled = ScopeHandledType::NOT_HANDLED;
45-
46- data->result.uri = result.uri;
47- handled = static_cast<ScopeHandledType>(result.handled);
48+ ScopeHandledType handled = static_cast<ScopeHandledType>(result.handled);
49
50 glib::HintsMap hints;
51- glib::hintsmap_from_hashtable(result.hints, hints);
52+ if (result.hints)
53+ glib::hintsmap_from_hashtable(result.hints, hints);
54
55+ data->result.uri = glib::gchar_to_string(result.uri);
56 data->callback(data->result, handled, hints, error);
57 }
58 }
59@@ -224,10 +235,10 @@
60 if (!UNITY_PROTOCOL_IS_SCOPE_PROXY(source_object))
61 return;
62
63- glib::Object<UnityProtocolScopeProxy> scope_proxy;
64 glib::Error error;
65 DeeSerializableModel* serialisable_model = nullptr;
66 glib::String tmp_channel(unity_protocol_scope_proxy_open_channel_finish(UNITY_PROTOCOL_SCOPE_PROXY(source_object), res, &serialisable_model, &error));
67+
68 if (error && g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
69 {
70 LOG_DEBUG(logger) << "Open channel cancelled.";

Subscribers

People subscribed via source and target branches

to all changes: