Commit 8c6d65df authored by Sebastian Krzyszkowiak's avatar Sebastian Krzyszkowiak
Browse files

Merge branch 'resource-cleanups' into 'master'

A couple  of resource cleanup fixes

See merge request Librem5/phosh!807
parents 0472e0f9 4c48aea7
......@@ -536,13 +536,19 @@ on_bus_acquired (GDBusConnection *connection,
const char *name,
gpointer user_data)
{
PhoshGnomeShellManager *self = user_data;
g_autoptr (GError) err = NULL;
PhoshGnomeShellManager *self = PHOSH_GNOME_SHELL_MANAGER (user_data);
PhoshSessionManager *sm;
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self),
connection,
"/org/gnome/Shell",
NULL);
gboolean success;
success = g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self),
connection,
"/org/gnome/Shell",
NULL);
if (!success) {
g_warning ("Failed to export shell interface: %s", err->message);
return;
}
sm = phosh_shell_get_session_manager (phosh_shell_get_default ());
phosh_session_manager_export_end_session (sm, connection);
......@@ -603,18 +609,13 @@ static void
phosh_gnome_shell_manager_dispose (GObject *object)
{
PhoshGnomeShellManager *self = PHOSH_GNOME_SHELL_MANAGER (object);
GList *grabbed;
guint n = 0;
for (grabbed = g_hash_table_get_keys (self->info_by_action); grabbed != NULL; grabbed = grabbed->next) {
AcceleratorInfo *info = grabbed->data;
g_clear_handle_id (&self->dbus_name_id, g_bus_unown_name);
g_hash_table_remove (self->info_by_action, GUINT_TO_POINTER (info->action_id));
++n;
}
g_hash_table_unref (self->info_by_action);
if (g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (self)))
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self));
g_debug ("%d accelerators needed to be cleaned up!", n);
g_clear_pointer (&self->info_by_action, g_hash_table_unref);
G_OBJECT_CLASS (phosh_gnome_shell_manager_parent_class)->dispose (object);
}
......@@ -626,14 +627,14 @@ phosh_gnome_shell_manager_constructed (GObject *object)
PhoshGnomeShellManager *self = PHOSH_GNOME_SHELL_MANAGER (object);
PhoshShell *shell = phosh_shell_get_default ();
G_OBJECT_CLASS (phosh_gnome_shell_manager_parent_class)->constructed (object);
g_object_bind_property_full (shell, "shell-state",
object, "shell-action-mode",
G_BINDING_SYNC_CREATE,
(GBindingTransformFunc) transform_state_to_action_mode,
NULL, NULL, NULL);
G_OBJECT_CLASS (phosh_gnome_shell_manager_parent_class)->constructed (object);
self->dbus_name_id = g_bus_own_name (G_BUS_TYPE_SESSION,
GNOME_SHELL_DBUS_NAME,
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
......
......@@ -303,7 +303,7 @@ on_keybindings_changed (PhoshHome *self,
static gboolean
on_idle (PhoshOskButton *self)
on_idle (PhoshHome *self)
{
g_autoptr (GSettings) settings = NULL;
......
......@@ -367,7 +367,7 @@ on_bus_acquired (GDBusConnection *connection,
const char *name,
gpointer user_data)
{
PhoshIdleManager *self = user_data;
PhoshIdleManager *self = PHOSH_IDLE_MANAGER (user_data);
PhoshMonitor *monitor;
g_autofree char *path = NULL;
......@@ -389,6 +389,8 @@ phosh_idle_manager_dispose (GObject *object)
{
PhoshIdleManager *self = PHOSH_IDLE_MANAGER (object);
g_clear_handle_id (&self->dbus_name_id, g_bus_unown_name);
g_clear_pointer (&self->watches, g_hash_table_destroy);
g_clear_object (&self->manager);
G_OBJECT_CLASS (phosh_idle_manager_parent_class)->dispose (object);
......@@ -431,7 +433,7 @@ phosh_idle_manager_class_init (PhoshIdleManagerClass *klass)
static void
phosh_idle_manager_init (PhoshIdleManager *self)
{
self->dbus_name_id = -1;
self->dbus_name_id = 0;
}
......
......@@ -66,7 +66,7 @@ typedef struct _PhoshLocationManager {
PhoshGeoClueDBusOrgFreedesktopGeoClue2AgentSkeleton parent;
PhoshGeoClueDBusManager *manager_proxy;
int dbus_name_id;
guint dbus_name_id;
GSettings *location_settings;
gboolean enabled;
gboolean active;
......@@ -311,7 +311,7 @@ on_bus_acquired (GObject *source_object,
gpointer user_data)
{
g_autoptr (GError) err = NULL;
PhoshLocationManager *self = user_data;
PhoshLocationManager *self = PHOSH_LOCATION_MANAGER (user_data);
GDBusConnection *connection;
connection = g_bus_get_finish (res, &err);
......@@ -428,6 +428,7 @@ phosh_location_manager_dispose (GObject *object)
/* Close dialog and cancel pending request if ongoing */
g_clear_pointer (&self->prompt, phosh_cp_widget_destroy);
if (self->invocation) {
phosh_geo_clue_dbus_org_freedesktop_geo_clue2_agent_complete_authorize_app (
PHOSH_GEO_CLUE_DBUS_ORG_FREEDESKTOP_GEO_CLUE2_AGENT (self),
......@@ -437,6 +438,11 @@ phosh_location_manager_dispose (GObject *object)
self->invocation = NULL;
}
g_clear_handle_id (&self->dbus_name_id, g_bus_unwatch_name);
if (g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (self)))
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self));
g_clear_object (&self->location_settings);
G_OBJECT_CLASS (phosh_location_manager_parent_class)->dispose (object);
......@@ -462,13 +468,13 @@ phosh_location_manager_constructed (GObject *object)
on_bus_acquired,
self);
g_bus_watch_name (G_BUS_TYPE_SYSTEM,
GEOCLUE_SERVICE,
G_BUS_NAME_WATCHER_FLAGS_NONE,
(GBusNameAppearedCallback) on_manager_name_appeared,
(GBusNameVanishedCallback) on_manager_name_vanished,
self,
NULL);
self->dbus_name_id = g_bus_watch_name (G_BUS_TYPE_SYSTEM,
GEOCLUE_SERVICE,
G_BUS_NAME_WATCHER_FLAGS_NONE,
(GBusNameAppearedCallback) on_manager_name_appeared,
(GBusNameVanishedCallback) on_manager_name_vanished,
g_object_ref (self),
g_object_unref);
}
......
......@@ -393,8 +393,8 @@ phosh_media_player_dispose (GObject *object)
if (self->dbus_id) {
g_dbus_connection_signal_unsubscribe (self->session_bus, self->dbus_id);
self->dbus_id = 0;
g_clear_object (&self->session_bus);
}
g_clear_object (&self->session_bus);
g_clear_object (&self->mpris);
g_clear_object (&self->player);
......
......@@ -244,7 +244,7 @@ out:
static gboolean
on_idle (PhoshTorchManager *self)
on_idle (PhoshModeManager *self)
{
phosh_hostname1_dbus_hostname1_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
......
......@@ -1014,7 +1014,7 @@ on_bus_acquired (GDBusConnection *connection,
const char *name,
gpointer user_data)
{
PhoshMonitorManager *self = user_data;
PhoshMonitorManager *self = PHOSH_MONITOR_MANAGER (user_data);
/* We need to use Mutter's object path here to make gnome-settings happy */
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self),
......@@ -1211,6 +1211,11 @@ phosh_monitor_manager_dispose (GObject *object)
{
PhoshMonitorManager *self = PHOSH_MONITOR_MANAGER (object);
g_clear_handle_id (&self->dbus_name_id, g_bus_unown_name);
if (g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (self)))
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self));
g_clear_object (&self->sensor_proxy_manager);
g_clear_pointer (&self->sensor_proxy_binding, g_binding_unbind);
......
......@@ -259,7 +259,7 @@ static void
wlr_output_power_handle_failed(void *data,
struct zwlr_output_power_v1 *output_power)
{
PhoshMonitor *self = data;
PhoshMonitor *self = PHOSH_MONITOR (data);
g_return_if_fail (PHOSH_IS_MONITOR (self));
g_warning("Failed to set output power mode for %s\n", self->name);
......
......@@ -548,6 +548,11 @@ phosh_notify_manager_dispose (GObject *object)
{
PhoshNotifyManager *self = PHOSH_NOTIFY_MANAGER (object);
g_clear_handle_id (&self->dbus_name_id, g_bus_unown_name);
if (g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (self)))
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self));
g_clear_object (&self->settings);
g_clear_object (&self->list);
......
......@@ -69,7 +69,7 @@ phosh_screen_saver_manager_set_property (GObject *object,
switch (property_id) {
case PROP_LOCKSCREEN_MANAGER:
self->lockscreen_manager = g_value_get_object (value);
self->lockscreen_manager = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -292,7 +292,7 @@ on_bus_acquired (GDBusConnection *connection,
const char *name,
gpointer user_data)
{
PhoshScreenSaverManager *self = user_data;
PhoshScreenSaverManager *self = PHOSH_SCREEN_SAVER_MANAGER (user_data);
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self),
connection,
......@@ -306,6 +306,11 @@ phosh_screen_saver_manager_dispose (GObject *object)
{
PhoshScreenSaverManager *self = PHOSH_SCREEN_SAVER_MANAGER (object);
g_clear_handle_id (&self->dbus_name_id, g_bus_unown_name);
if (g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (self)))
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self));
g_clear_object (&self->lockscreen_manager);
g_clear_object (&self->logind_session_proxy);
g_clear_object (&self->logind_manager_proxy);
......
......@@ -450,7 +450,7 @@ on_bus_acquired (GDBusConnection *connection,
const char *name,
gpointer user_data)
{
PhoshScreenshotManager *self = user_data;
PhoshScreenshotManager *self = PHOSH_SCREENSHOT_MANAGER (user_data);
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self),
connection,
......@@ -487,10 +487,10 @@ phosh_screenshot_manager_dispose (GObject *object)
{
PhoshScreenshotManager *self = PHOSH_SCREENSHOT_MANAGER (object);
if (self->dbus_name_id) {
g_bus_unown_name (self->dbus_name_id);
self->dbus_name_id = 0;
}
g_clear_handle_id (&self->dbus_name_id, g_bus_unown_name);
if (g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (self)))
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self));
g_clear_handle_id (&self->fader_id, g_source_remove);
g_clear_pointer (&self->fader, phosh_cp_widget_destroy);
......
......@@ -383,6 +383,9 @@ phosh_session_manager_dispose (GObject *object)
{
PhoshSessionManager *self = PHOSH_SESSION_MANAGER (object);
if (g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (self)))
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self));
g_clear_pointer (&self->dialog, phosh_cp_widget_destroy);
g_clear_object (&self->priv_proxy);
g_clear_object (&self->proxy);
......
......@@ -148,5 +148,5 @@ brightness_set (int brightness)
void
brightness_dispose (void)
{
g_clear_pointer (&brightness_proxy, g_object_unref);
g_clear_object (&brightness_proxy);
}
......@@ -348,7 +348,6 @@ phosh_shell_dispose (GObject *object)
g_clear_object (&priv->notification_banner);
g_clear_object (&priv->keyboard_events);
/* dispose managers in opposite order of declaration */
g_clear_object (&priv->screenshot_manager);
g_clear_object (&priv->location_manager);
......@@ -373,6 +372,7 @@ phosh_shell_dispose (GObject *object)
g_clear_object (&priv->builtin_monitor);
g_clear_object (&priv->primary_monitor);
g_clear_object (&priv->background_manager);
g_clear_object (&priv->keyboard_events);
/* sensors */
g_clear_object (&priv->proximity);
......
......@@ -121,9 +121,10 @@ phosh_system_prompter_unregister(void)
g_clear_object (&_prompter);
}
if (acquired_prompter) {
if (owner_id) {
g_bus_unown_name (owner_id);
owner_id = 0;
acquired_prompter = FALSE;
}
acquired_prompter = FALSE;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment