From 895d076624616454a8e0061f72bf3dcb1a36d00d Mon Sep 17 00:00:00 2001 From: Matej Marusak Date: Tue, 8 Jan 2019 14:41:38 +0100 Subject: [PATCH] Update to work with new glib Signed-off-by: Matej Marusak --- ...bus-task-Use-modern-GLib-type-macros.patch | 299 ++++++++++++++++++ abrt.spec | 8 +- 2 files changed, 306 insertions(+), 1 deletion(-) create mode 100644 0001-dbus-task-Use-modern-GLib-type-macros.patch diff --git a/0001-dbus-task-Use-modern-GLib-type-macros.patch b/0001-dbus-task-Use-modern-GLib-type-macros.patch new file mode 100644 index 0000000..f188eeb --- /dev/null +++ b/0001-dbus-task-Use-modern-GLib-type-macros.patch @@ -0,0 +1,299 @@ +From 21bdee77727417b6b16feed7b466953873319b58 Mon Sep 17 00:00:00 2001 +From: Ernestas Kulik +Date: Tue, 8 Jan 2019 14:26:15 +0100 +Subject: [PATCH] dbus: task: Use modern GLib type macros + +Signed-off-by: Ernestas Kulik +--- + src/dbus/abrt_problems2_task.c | 111 ++++++++++++++++++++++++--------- + src/dbus/abrt_problems2_task.h | 26 +------- + 2 files changed, 82 insertions(+), 55 deletions(-) + +diff --git a/src/dbus/abrt_problems2_task.c b/src/dbus/abrt_problems2_task.c +index f40381f6..cba6b469 100644 +--- a/src/dbus/abrt_problems2_task.c ++++ b/src/dbus/abrt_problems2_task.c +@@ -25,6 +25,15 @@ enum { + + static guint s_signals[SN_LAST_SIGNAL] = { 0 }; + ++struct _AbrtP2TaskPrivate ++{ ++ gint32 p2t_status; ++ GVariant *p2t_details; ++ GVariant *p2t_results; ++ gint32 p2t_code; ++ GCancellable *p2t_cancellable; ++}; ++ + G_DEFINE_TYPE_WITH_PRIVATE(AbrtP2Task, abrt_p2_task, G_TYPE_OBJECT) + + static void abrt_p2_task_finalize(GObject *gobject) +@@ -74,17 +83,24 @@ static void abrt_p2_task_class_init(AbrtP2TaskClass *klass) + + static void abrt_p2_task_init(AbrtP2Task *self) + { +- self->pv = abrt_p2_task_get_instance_private(self); +- self->pv->p2t_details = g_variant_new("a{sv}", NULL); ++ AbrtP2TaskPrivate *pv; ++ ++ pv = abrt_p2_task_get_instance_private(self); ++ ++ pv->p2t_details = g_variant_new("a{sv}", NULL); + } + + static void abrt_p2_task_change_status(AbrtP2Task *task, + AbrtP2TaskStatus status) + { +- if (task->pv->p2t_status == status) ++ AbrtP2TaskPrivate *pv; ++ ++ pv = abrt_p2_task_get_instance_private(task); ++ ++ if (pv->p2t_status == status) + return; + +- task->pv->p2t_status = status; ++ pv->p2t_status = status; + + g_signal_emit(task, + s_signals[SN_STATUS_CHANGED], +@@ -94,53 +110,77 @@ static void abrt_p2_task_change_status(AbrtP2Task *task, + + AbrtP2TaskStatus abrt_p2_task_status(AbrtP2Task *task) + { +- return task->pv->p2t_status; ++ AbrtP2TaskPrivate *pv; ++ ++ pv = abrt_p2_task_get_instance_private(task); ++ ++ return pv->p2t_status; + } + + GVariant *abrt_p2_task_details(AbrtP2Task *task) + { +- return g_variant_ref(task->pv->p2t_details); ++ AbrtP2TaskPrivate *pv; ++ ++ pv = abrt_p2_task_get_instance_private(task); ++ ++ return g_variant_ref(pv->p2t_details); + } + + void abrt_p2_task_add_detail(AbrtP2Task *task, + const char *key, + GVariant *value) + { ++ AbrtP2TaskPrivate *pv; + GVariantDict dict; +- g_variant_dict_init(&dict, task->pv->p2t_details); ++ ++ pv = abrt_p2_task_get_instance_private(task); ++ ++ g_variant_dict_init(&dict, pv->p2t_details); + g_variant_dict_insert(&dict, key, "v", value); + +- if (task->pv->p2t_details) +- g_variant_unref(task->pv->p2t_details); ++ if (pv->p2t_details) ++ g_variant_unref(pv->p2t_details); + +- task->pv->p2t_details = g_variant_dict_end(&dict); ++ pv->p2t_details = g_variant_dict_end(&dict); + } + + void abrt_p2_task_set_response(AbrtP2Task *task, + GVariant *response) + { +- if (task->pv->p2t_results != NULL) ++ AbrtP2TaskPrivate *pv; ++ ++ pv = abrt_p2_task_get_instance_private(task); ++ ++ if (pv->p2t_results != NULL) + log_warning("Task already has response assigned"); + +- task->pv->p2t_results = response; ++ pv->p2t_results = response; + } + + bool abrt_p2_task_is_cancelled(AbrtP2Task *task) + { +- return (task->pv->p2t_cancellable +- && g_cancellable_is_cancelled(task->pv->p2t_cancellable)) +- || task->pv->p2t_status == ABRT_P2_TASK_STATUS_CANCELED; ++ AbrtP2TaskPrivate *pv; ++ ++ pv = abrt_p2_task_get_instance_private(task); ++ ++ return (pv->p2t_cancellable ++ && g_cancellable_is_cancelled(pv->p2t_cancellable)) ++ || pv->p2t_status == ABRT_P2_TASK_STATUS_CANCELED; + } + + void abrt_p2_task_cancel(AbrtP2Task *task, + GError **error) + { ++ AbrtP2TaskPrivate *pv; ++ + if (abrt_p2_task_is_cancelled(task)) + return; + +- if (task->pv->p2t_status == ABRT_P2_TASK_STATUS_RUNNING) +- g_cancellable_cancel(task->pv->p2t_cancellable); +- else if (task->pv->p2t_status == ABRT_P2_TASK_STATUS_STOPPED) ++ pv = abrt_p2_task_get_instance_private(task); ++ ++ if (pv->p2t_status == ABRT_P2_TASK_STATUS_RUNNING) ++ g_cancellable_cancel(pv->p2t_cancellable); ++ else if (pv->p2t_status == ABRT_P2_TASK_STATUS_STOPPED) + { + ABRT_P2_TASK_VIRTUAL_CANCEL(task, error); + +@@ -157,8 +197,12 @@ void abrt_p2_task_finish(AbrtP2Task *task, + gint32 *code, + GError **error) + { +- if ( task->pv->p2t_status != ABRT_P2_TASK_STATUS_DONE +- && task->pv->p2t_status != ABRT_P2_TASK_STATUS_FAILED) ++ AbrtP2TaskPrivate *pv; ++ ++ pv = abrt_p2_task_get_instance_private(task); ++ ++ if ( pv->p2t_status != ABRT_P2_TASK_STATUS_DONE ++ && pv->p2t_status != ABRT_P2_TASK_STATUS_FAILED) + { + g_set_error(error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, + "Cannot finalize undone task"); +@@ -170,12 +214,12 @@ void abrt_p2_task_finish(AbrtP2Task *task, + if (*error != NULL) + return; + +- if (task->pv->p2t_results) +- *result = g_variant_ref(task->pv->p2t_results); ++ if (pv->p2t_results) ++ *result = g_variant_ref(pv->p2t_results); + else + *result = g_variant_new("a{sv}", NULL); + +- *code = task->pv->p2t_code; ++ *code = pv->p2t_code; + } + + static void abrt_p2_task_finish_gtask(GObject *source_object, +@@ -183,6 +227,7 @@ static void abrt_p2_task_finish_gtask(GObject *source_object, + gpointer user_data) + { + AbrtP2Task *task = ABRT_P2_TASK(source_object); ++ AbrtP2TaskPrivate *pv; + + if (!g_task_is_valid(result, task)) + { +@@ -190,6 +235,8 @@ static void abrt_p2_task_finish_gtask(GObject *source_object, + return; + } + ++ pv = abrt_p2_task_get_instance_private(task); ++ + GError *error = NULL; + const gint32 code = g_task_propagate_int(G_TASK(result), &error); + +@@ -203,7 +250,7 @@ static void abrt_p2_task_finish_gtask(GObject *source_object, + { + log_debug("Task done"); + +- task->pv->p2t_code = code - ABRT_P2_TASK_CODE_DONE; ++ pv->p2t_code = code - ABRT_P2_TASK_CODE_DONE; + abrt_p2_task_change_status(task, ABRT_P2_TASK_STATUS_DONE); + } + else if (abrt_p2_task_is_cancelled(task)) +@@ -263,8 +310,8 @@ static void abrt_p2_task_finish_gtask(GObject *source_object, + abrt_p2_task_change_status(task, ABRT_P2_TASK_STATUS_FAILED); + } + +- g_object_unref(task->pv->p2t_cancellable); +- task->pv->p2t_cancellable = NULL; ++ g_object_unref(pv->p2t_cancellable); ++ pv->p2t_cancellable = NULL; + } + + static void abrt_p2_task_thread(GTask *task, +@@ -289,8 +336,12 @@ void abrt_p2_task_start(AbrtP2Task *task, + GVariant *options, + GError **error) + { +- if ( task->pv->p2t_status != ABRT_P2_TASK_STATUS_NEW +- && task->pv->p2t_status != ABRT_P2_TASK_STATUS_STOPPED) ++ AbrtP2TaskPrivate *pv; ++ ++ pv = abrt_p2_task_get_instance_private(task); ++ ++ if ( pv->p2t_status != ABRT_P2_TASK_STATUS_NEW ++ && pv->p2t_status != ABRT_P2_TASK_STATUS_STOPPED) + { + g_set_error(error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, + "Cannot start task that is not new or stopped"); +@@ -302,9 +353,9 @@ void abrt_p2_task_start(AbrtP2Task *task, + if (*error != NULL) + return; + +- task->pv->p2t_cancellable = g_cancellable_new(); ++ pv->p2t_cancellable = g_cancellable_new(); + GTask *gtask = g_task_new(task, +- task->pv->p2t_cancellable, ++ pv->p2t_cancellable, + abrt_p2_task_finish_gtask, + NULL); + +diff --git a/src/dbus/abrt_problems2_task.h b/src/dbus/abrt_problems2_task.h +index 71f765d9..717af47b 100644 +--- a/src/dbus/abrt_problems2_task.h ++++ b/src/dbus/abrt_problems2_task.h +@@ -45,21 +45,12 @@ G_BEGIN_DECLS + GType abrt_p2_task_get_type (void); + + #define ABRT_TYPE_P2_TASK (abrt_p2_task_get_type ()) +-#define ABRT_P2_TASK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ABRT_TYPE_P2_TASK, AbrtP2Task)) +-#define ABRT_P2_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ABRT_TYPE_P2_TASK, AbrtP2TaskClass)) +-#define ABRT_IS_P2_TASK(obj)(G_TYPE_CHECK_INSTANCE_TYPE ((obj), ABRT_TYPE_P2_TASK)) +-#define ABRT_IS_P2_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ABRT_TYPE_P2_TASK)) +-#define ABRT_P2_TASK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ABRT_TYPE_P2_TASK, AbrtP2TaskClass)) ++G_DECLARE_DERIVABLE_TYPE(AbrtP2Task, abrt_p2_task, ABRT, P2_TASK, GObject) + + typedef struct _AbrtP2Task AbrtP2Task; + typedef struct _AbrtP2TaskClass AbrtP2TaskClass; + typedef struct _AbrtP2TaskPrivate AbrtP2TaskPrivate; + +-static inline void glib_autoptr_cleanup_AbrtP2Task(AbrtP2Task **task) +-{ +- glib_autoptr_cleanup_GObject((GObject **)task); +-} +- + typedef enum { + ABRT_P2_TASK_STATUS_NEW, + ABRT_P2_TASK_STATUS_RUNNING, +@@ -96,21 +87,6 @@ struct _AbrtP2TaskClass + gpointer padding[12]; + }; + +-struct _AbrtP2TaskPrivate +-{ +- gint32 p2t_status; +- GVariant *p2t_details; +- GVariant *p2t_results; +- gint32 p2t_code; +- GCancellable *p2t_cancellable; +-}; +- +-struct _AbrtP2Task +-{ +- GObject parent_instance; +- AbrtP2TaskPrivate *pv; +-}; +- + AbrtP2TaskStatus abrt_p2_task_status(AbrtP2Task *task); + + /* Returns task details in form of key-value entries. +-- +2.20.1 + diff --git a/abrt.spec b/abrt.spec index 2d39a36..7fb2611 100644 --- a/abrt.spec +++ b/abrt.spec @@ -53,10 +53,13 @@ Summary: Automatic bug detection and reporting tool Name: abrt Version: 2.11.1 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2+ URL: https://abrt.readthedocs.org/ Source: https://github.com/abrt/%{name}/archive/%{version}/%{name}-%{version}.tar.gz +# With new glib it is not possible to build in rawhide +# https://github.com/abrt/abrt/commit/21bdee7 +Patch0: 0001-dbus-task-Use-modern-GLib-type-macros.patch BuildRequires: %{dbus_devel} BuildRequires: hostname BuildRequires: gtk3-devel @@ -1239,6 +1242,9 @@ killall abrt-dbus >/dev/null 2>&1 || : %config(noreplace) %{_sysconfdir}/profile.d/abrt-console-notification.sh %changelog +* Tue Jan 08 2019 Matej Marusak 2.11.1-2 +- dbus: task: Use modern GLib type macros + * Tue Jan 08 2019 Matej Marusak 2.11.1-1 - Translation updates - a-a-install-debuginfo: Clean cache if we need space