Guarded g_object_ref/unref to avoid warning messages when the pointer is NULL.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/1/head
Michele Calgaro 3 years ago
parent 8b90718b72
commit 5a4577efe2
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -26,8 +26,6 @@ cmake_minimum_required( VERSION 2.8.12 )
include( FindPkgConfig )
include( CheckCXXSourceCompiles )
include( CheckSymbolExists )
set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" )
include( TDEMacros )

@ -62,7 +62,10 @@ void Session::Private::completed(PolkitAgentSession *s, gboolean gained_authoriz
emit(session)->completed(gained_authorization);
//free session here as polkit documentation asks
g_object_unref(session->d->polkitAgentSession);
if (session->d->polkitAgentSession)
{
g_object_unref(session->d->polkitAgentSession);
}
session->d->polkitAgentSession = 0;
}
@ -171,7 +174,10 @@ void AsyncResult::setCompleted()
}
g_simple_async_result_complete(d->result);
// Assure that completed won't be called twice
g_object_unref(d->result);
if (d->result)
{
g_object_unref(d->result);
}
d->result = NULL;
}

@ -67,7 +67,10 @@ ActionDescription::List actionsToListAndFree(GList *glist)
{
gpointer i = glist2->data;
result.append(ActionDescription(static_cast<PolkitActionDescription*>(i)));
g_object_unref(i);
if (i)
{
g_object_unref(i);
}
}
g_list_free(glist);
return result;
@ -121,14 +124,38 @@ class Authority::Private
Authority::Private::~Private()
{
g_object_unref(m_checkAuthorizationCancellable);
g_object_unref(m_enumerateActionsCancellable);
g_object_unref(m_registerAuthenticationAgentCancellable);
g_object_unref(m_unregisterAuthenticationAgentCancellable);
g_object_unref(m_authenticationAgentResponseCancellable);
g_object_unref(m_enumerateTemporaryAuthorizationsCancellable);
g_object_unref(m_revokeTemporaryAuthorizationsCancellable);
g_object_unref(m_revokeTemporaryAuthorizationCancellable);
if (m_checkAuthorizationCancellable)
{
g_object_unref(m_checkAuthorizationCancellable);
}
if (m_enumerateActionsCancellable)
{
g_object_unref(m_enumerateActionsCancellable);
}
if (m_registerAuthenticationAgentCancellable)
{
g_object_unref(m_registerAuthenticationAgentCancellable);
}
if (m_unregisterAuthenticationAgentCancellable)
{
g_object_unref(m_unregisterAuthenticationAgentCancellable);
}
if (m_authenticationAgentResponseCancellable)
{
g_object_unref(m_authenticationAgentResponseCancellable);
}
if (m_enumerateTemporaryAuthorizationsCancellable)
{
g_object_unref(m_enumerateTemporaryAuthorizationsCancellable);
}
if (m_revokeTemporaryAuthorizationsCancellable)
{
g_object_unref(m_revokeTemporaryAuthorizationsCancellable);
}
if (m_revokeTemporaryAuthorizationCancellable)
{
g_object_unref(m_revokeTemporaryAuthorizationCancellable);
}
}
void Authority::Private::init()
@ -185,7 +212,10 @@ Authority::Authority(TQObject *parent) : TQObject(parent), d(new Private(this))
Authority::~Authority()
{
g_object_unref(d->pkAuthority);
if (d->pkAuthority)
{
g_object_unref(d->pkAuthority);
}
delete d;
}
@ -634,7 +664,10 @@ TemporaryAuthorization::List Authority::enumerateTemporaryAuthorizationsSync(con
for (glist2 = glist; glist2 != NULL; glist2 = g_list_next(glist2))
{
result.append(TemporaryAuthorization((PolkitTemporaryAuthorization*)glist2->data));
g_object_unref(glist2->data);
if (glist2->data)
{
g_object_unref(glist2->data);
}
}
g_list_free(glist);
return result;
@ -667,7 +700,10 @@ void Authority::Private::enumerateTemporaryAuthorizationsCallback(GObject *objec
for (glist2 = glist; glist2 != NULL; glist2 = g_list_next(glist2))
{
res.append(TemporaryAuthorization((PolkitTemporaryAuthorization*)glist2->data));
g_object_unref(glist2->data);
if (glist2->data)
{
g_object_unref(glist2->data);
}
}
g_list_free(glist);
emit authority->enumerateTemporaryAuthorizationsFinished(res);

@ -38,22 +38,31 @@ class Details::Data : public TQShared
{
public:
Data() : details(NULL)
{
}
{
}
Data(const Data &other) : details(other.details)
{
g_object_ref(details);
if (details)
{
g_object_ref(details);
}
}
Data(PolkitDetails *_details) : details(_details)
{
g_object_ref(details);
if (details)
{
g_object_ref(details);
}
}
~Data()
{
g_object_unref(details);
if (details)
{
g_object_unref(details);
}
}
PolkitDetails *details;
@ -65,7 +74,7 @@ class Details::Data : public TQShared
Details::Details() : d(new Data)
{
d->details = polkit_details_new();
d->details = polkit_details_new();
}
Details::Details(PolkitDetails *pkDetails) : d(new Data(pkDetails))
@ -101,33 +110,33 @@ Details::~Details()
TQString Details::lookup(const TQString &key) const
{
const gchar *result = polkit_details_lookup(d->details, key.utf8().data());
if (result != NULL)
{
return TQString::fromUtf8(result);
}
else
{
return TQString::null;
}
const gchar *result = polkit_details_lookup(d->details, key.utf8().data());
if (result != NULL)
{
return TQString::fromUtf8(result);
}
else
{
return TQString::null;
}
}
void Details::insert(const TQString &key, const TQString &value)
{
polkit_details_insert(d->details, key.utf8().data(), value.utf8().data());
polkit_details_insert(d->details, key.utf8().data(), value.utf8().data());
}
TQStringList Details::keys() const
{
gchar **result = polkit_details_get_keys(d->details);
TQStringList list;
int len = g_strv_length(result);
for (int i = 0; i < len; i++)
{
list.append(TQString::fromUtf8(result[i]));
}
g_strfreev(result);
return list;
gchar **result = polkit_details_get_keys(d->details);
TQStringList list;
int len = g_strv_length(result);
for (int i = 0; i < len; i++)
{
list.append(TQString::fromUtf8(result[i]));
}
g_strfreev(result);
return list;
}
}

@ -42,17 +42,26 @@ class Identity::Data : public TQShared
Data(const Data &other) : identity(other.identity)
{
g_object_ref(identity);
if (identity)
{
g_object_ref(identity);
}
}
Data(PolkitIdentity *_identity) : identity(_identity)
{
g_object_ref(identity);
if (identity)
{
g_object_ref(identity);
}
}
~Data()
{
g_object_unref(identity);
if (identity)
{
g_object_unref(identity);
}
}
PolkitIdentity *identity;
@ -111,9 +120,15 @@ void Identity::setIdentity(PolkitIdentity *identity)
{
if (d->identity != identity)
{
g_object_unref(d->identity);
if (d->identity)
{
g_object_unref(d->identity);
}
d->identity = identity;
g_object_ref(identity);
if (d->identity)
{
g_object_ref(d->identity);
}
}
}

@ -42,17 +42,26 @@ class Subject::Data : public TQShared
Data(const Data &other) : subject(other.subject)
{
g_object_ref(subject);
if (subject)
{
g_object_ref(subject);
}
}
Data(PolkitSubject *_subject) : subject(_subject)
{
g_object_ref(subject);
if (subject)
{
g_object_ref(subject);
}
}
~Data()
{
g_object_unref(subject);
if (subject)
{
g_object_unref(subject);
}
}
PolkitSubject *subject;
@ -111,9 +120,15 @@ void Subject::setSubject(PolkitSubject *subject)
{
if (d->subject != subject)
{
g_object_unref(d->subject);
if (d->subject)
{
g_object_unref(d->subject);
}
d->subject = subject;
g_object_ref(subject);
if (d->subject)
{
g_object_ref(d->subject);
}
}
}

Loading…
Cancel
Save