~ubuntu-branches/ubuntu/saucy/polkit-qt-1/saucy-proposed

« back to all changes in this revision

Viewing changes to debian/patches/fix_exit_crash.diff

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman
  • Date: 2011-12-14 08:54:32 UTC
  • Revision ID: package-import@ubuntu.com-20111214085432-grpqde7wwe0579sk
Tags: 0.99.0-3ubuntu1
Add debian/patches/fix_exit_crash.diff to resolve high frequency
crash on exit issues (LP: #904245)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
commit d3c337da01f3887da031fdb5c2ac784fb3e79210
 
2
Author: Nick Shaforostoff <shafff@ukr.net>
 
3
Date:   Mon Dec 12 01:03:35 2011 +0200
 
4
 
 
5
    BUG: 258916
 
6
    
 
7
    use stricter refing in all places of 'identity' keeping.
 
8
    it is interesting that it would be much harder
 
9
    to accidentaly make same mistake if G API was C++ style and not C.
 
10
    
 
11
    i also moved cleanup of successful sessions in time from system shutdown
 
12
    to session completion as polkit docs say it should be
 
13
 
 
14
Index: polkit-qt-1-0.99.0/agent/polkitqt1-agent-session.cpp
 
15
===================================================================
 
16
--- polkit-qt-1-0.99.0.orig/agent/polkitqt1-agent-session.cpp   2011-12-14 08:24:19.476208706 -0500
 
17
+++ polkit-qt-1-0.99.0/agent/polkitqt1-agent-session.cpp        2011-12-14 08:24:59.664207519 -0500
 
18
@@ -46,7 +46,7 @@
 
19
 
 
20
 Session::Private::~Private()
 
21
 {
 
22
-    g_object_unref(polkitAgentSession);
 
23
+    // polkitAgentSession is freed in Session d'tor
 
24
 }
 
25
 
 
26
 Session::Session(const PolkitQt1::Identity &identity, const QString &cookie, AsyncResult *result, QObject *parent)
 
27
@@ -74,6 +74,9 @@
 
28
 
 
29
 Session::~Session()
 
30
 {
 
31
+    if (d->polkitAgentSession)
 
32
+        g_object_unref(d->polkitAgentSession);
 
33
+
 
34
     delete d;
 
35
 }
 
36
 
 
37
@@ -101,7 +104,11 @@
 
38
 {
 
39
     qDebug() << "COMPLETED";
 
40
     Session *session = (Session *)user_data;
 
41
-    Q_EMIT((Session *)user_data)->completed(gained_authorization);
 
42
+    Q_EMIT(session)->completed(gained_authorization);
 
43
+
 
44
+    //free session here as polkit documentation asks
 
45
+    g_object_unref(session->d->polkitAgentSession);
 
46
+    session->d->polkitAgentSession = 0;
 
47
 }
 
48
 
 
49
 void Session::Private::request(PolkitAgentSession *s, gchar *request, gboolean echo_on, gpointer user_data)
 
50
@@ -139,7 +146,8 @@
 
51
 
 
52
 AsyncResult::~AsyncResult()
 
53
 {
 
54
-    g_object_unref(d->result);
 
55
+    if (d->result)
 
56
+        g_object_unref(d->result);
 
57
 }
 
58
 
 
59
 void AsyncResult::setCompleted()
 
60
Index: polkit-qt-1-0.99.0/core/polkitqt1-identity.cpp
 
61
===================================================================
 
62
--- polkit-qt-1-0.99.0.orig/core/polkitqt1-identity.cpp 2011-12-14 08:24:44.952207954 -0500
 
63
+++ polkit-qt-1-0.99.0/core/polkitqt1-identity.cpp      2011-12-14 08:24:59.664207519 -0500
 
64
@@ -35,11 +35,13 @@
 
65
         : QSharedData(other)
 
66
         , identity(other.identity)
 
67
     {
 
68
-        g_object_ref(identity);
 
69
+        if (identity)
 
70
+            g_object_ref(identity);
 
71
     }
 
72
     ~Data()
 
73
     {
 
74
-        g_object_unref(identity);
 
75
+        if (identity)
 
76
+            g_object_unref(identity);
 
77
     }
 
78
 
 
79
     PolkitIdentity *identity;
 
80
@@ -56,6 +58,8 @@
 
81
 {
 
82
     g_type_init();
 
83
     d->identity = polkitIdentity;
 
84
+    if (d->identity)
 
85
+        g_object_ref(d->identity);
 
86
 }
 
87
 
 
88
 Identity::Identity(const PolkitQt1::Identity& other)
 
89
@@ -86,7 +90,14 @@
 
90
 
 
91
 void Identity::setIdentity(PolkitIdentity *identity)
 
92
 {
 
93
+    if (d->identity == identity)
 
94
+        return;
 
95
+    
 
96
+    if (d->identity)
 
97
+        g_object_unref(d->identity);
 
98
     d->identity = identity;
 
99
+    if (d->identity)
 
100
+        g_object_ref(d->identity);
 
101
 }
 
102
 
 
103
 QString Identity::toString() const