Use GCancellable to prevent crash in notificationShown
This commit is contained in:
parent
f7b72bffe2
commit
fe8bc30645
|
@ -272,6 +272,7 @@ public:
|
||||||
private:
|
private:
|
||||||
GDBusConnection *_dbusConnection = nullptr;
|
GDBusConnection *_dbusConnection = nullptr;
|
||||||
base::weak_ptr<Manager> _manager;
|
base::weak_ptr<Manager> _manager;
|
||||||
|
GCancellable *_cancellable = nullptr;
|
||||||
|
|
||||||
QString _title;
|
QString _title;
|
||||||
QString _body;
|
QString _body;
|
||||||
|
@ -316,6 +317,7 @@ NotificationData::NotificationData(
|
||||||
NotificationId id,
|
NotificationId id,
|
||||||
bool hideReplyButton)
|
bool hideReplyButton)
|
||||||
: _manager(manager)
|
: _manager(manager)
|
||||||
|
, _cancellable(g_cancellable_new())
|
||||||
, _title(title)
|
, _title(title)
|
||||||
, _imageKey(GetImageKey(CurrentServerInformationValue().specVersion))
|
, _imageKey(GetImageKey(CurrentServerInformationValue().specVersion))
|
||||||
, _id(id) {
|
, _id(id) {
|
||||||
|
@ -461,6 +463,9 @@ NotificationData::~NotificationData() {
|
||||||
g_variant_unref(value);
|
g_variant_unref(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_cancellable_cancel(_cancellable);
|
||||||
|
g_object_unref(_cancellable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationData::show() {
|
void NotificationData::show() {
|
||||||
|
@ -509,7 +514,7 @@ void NotificationData::show() {
|
||||||
nullptr,
|
nullptr,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
-1,
|
-1,
|
||||||
nullptr,
|
_cancellable,
|
||||||
notificationShown,
|
notificationShown,
|
||||||
this);
|
this);
|
||||||
}
|
}
|
||||||
|
@ -518,6 +523,18 @@ void NotificationData::notificationShown(
|
||||||
GObject *source_object,
|
GObject *source_object,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
gpointer user_data) {
|
gpointer user_data) {
|
||||||
|
GError *error = nullptr;
|
||||||
|
|
||||||
|
auto reply = g_dbus_connection_call_finish(
|
||||||
|
reinterpret_cast<GDBusConnection*>(source_object),
|
||||||
|
res,
|
||||||
|
&error);
|
||||||
|
|
||||||
|
if (error && error->code == G_IO_ERROR_CANCELLED) {
|
||||||
|
g_error_free(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const auto notificationData = reinterpret_cast<NotificationData*>(
|
const auto notificationData = reinterpret_cast<NotificationData*>(
|
||||||
user_data);
|
user_data);
|
||||||
|
|
||||||
|
@ -525,13 +542,6 @@ void NotificationData::notificationShown(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GError *error = nullptr;
|
|
||||||
|
|
||||||
auto reply = g_dbus_connection_call_finish(
|
|
||||||
notificationData->_dbusConnection,
|
|
||||||
res,
|
|
||||||
&error);
|
|
||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
g_variant_get(reply, "(u)", ¬ificationData->_notificationId);
|
g_variant_get(reply, "(u)", ¬ificationData->_notificationId);
|
||||||
g_variant_unref(reply);
|
g_variant_unref(reply);
|
||||||
|
|
Loading…
Reference in New Issue