pkgsrc/sysutils/upower/patches/patch-libupower-glib_up-client.h
bsiegert d857076534 Fix segfaults when upower is not running.
On my system, these patches stop xfsettingsd (from XFCE) from crashing
and dumping core during session startup. Thus, it can actually apply the
settings it is supposed to.

I just wish upstream had done a bugfix release, the patches are from 2016 :(

Fixes PR pkg/53455, which I filed :)
ok youri@
2018-07-18 19:18:07 +00:00

39 lines
1.5 KiB
C

$NetBSD: patch-libupower-glib_up-client.h,v 1.1 2018/07/18 19:18:07 bsiegert Exp $
From 932a6a39e35754be571e1274aec4730fd42dba13 Mon Sep 17 00:00:00 2001
From: Martin Pitt <martin.pitt@ubuntu.com>
Date: Wed, 18 May 2016 09:22:43 +0200
Subject: [PATCH 1/9] lib: Add proper error and cancellable handling to
UpClient constructor
A GObject's _init() should never fail or block, but this is currently the case
as up_client_init() connects to upowerd on D-Bus. Convert this to the GInitable
interface and provide a new constructor up_client_new_full() which accepts a
GCancellable and GError, so that clients can do proper error handling
and reporting.
This changes up_client_new() to return NULL when connecting to upowerd fails.
This provides a more well-defined behaviour in this case as clients can check
for this and our methods stop segfaulting as they have checks like
g_return_val_if_fail (UP_IS_CLIENT (client), ...)
Previously we returned a valid object, but trying to call any method on it
segfaulted due to the NULL D-Bus proxy, so client code had no chance to check
whether the UpClient object was really valid.
https://bugs.freedesktop.org/show_bug.cgi?id=95350
--- libupower-glib/up-client.h
+++ libupower-glib/up-client.h
@@ -72,6 +72,7 @@ typedef struct
/* general */
GType up_client_get_type (void);
UpClient *up_client_new (void);
+UpClient *up_client_new_full (GCancellable *cancellable, GError **error);
/* sync versions */
UpDevice * up_client_get_display_device (UpClient *client);
--
2.8.1