gladish: don't crash when unable connect to dbus

This commit is contained in:
Nedko Arnaudov 2014-09-11 18:36:42 +03:00
parent eaf678ec8f
commit 5fe205f2dc
3 changed files with 12 additions and 8 deletions

View File

@ -2,7 +2,7 @@
/* /*
* LADI Session Handler (ladish) * LADI Session Handler (ladish)
* *
* Copyright (C) 2010,2011 Nedko Arnaudov <nedko@arnaudov.name> * Copyright (C) 2010,2011,2014 Nedko Arnaudov <nedko@arnaudov.name>
* *
************************************************************************** **************************************************************************
* This file contains D-Bus related code * This file contains D-Bus related code
@ -28,7 +28,7 @@
#include "../cdbus/helpers.h" #include "../cdbus/helpers.h"
#include <dbus/dbus-glib-lowlevel.h> #include <dbus/dbus-glib-lowlevel.h>
void dbus_init(void) bool dbus_init(void)
{ {
dbus_error_init(&cdbus_g_dbus_error); dbus_error_init(&cdbus_g_dbus_error);
@ -36,12 +36,13 @@ void dbus_init(void)
cdbus_g_dbus_connection = dbus_bus_get(DBUS_BUS_SESSION, &cdbus_g_dbus_error); cdbus_g_dbus_connection = dbus_bus_get(DBUS_BUS_SESSION, &cdbus_g_dbus_error);
if (dbus_error_is_set(&cdbus_g_dbus_error)) if (dbus_error_is_set(&cdbus_g_dbus_error))
{ {
//error_msg("dbus_bus_get() failed"); log_error("Cannot connect to session bus: %s", cdbus_g_dbus_error.message);
//error_msg(cdbus_g_dbus_error.message);
dbus_error_free(&cdbus_g_dbus_error); dbus_error_free(&cdbus_g_dbus_error);
return false;
} }
dbus_connection_setup_with_g_main(cdbus_g_dbus_connection, NULL); dbus_connection_setup_with_g_main(cdbus_g_dbus_connection, NULL);
return true;
} }
void dbus_uninit(void) void dbus_uninit(void)

View File

@ -2,7 +2,7 @@
/* /*
* LADI Session Handler (ladish) * LADI Session Handler (ladish)
* *
* Copyright (C) 2010 Nedko Arnaudov <nedko@arnaudov.name> * Copyright (C) 2010,2014 Nedko Arnaudov <nedko@arnaudov.name>
* *
************************************************************************** **************************************************************************
* This file contains declarations of internal stuff used to glue gui modules together * This file contains declarations of internal stuff used to glue gui modules together
@ -30,7 +30,7 @@
#include "common.h" #include "common.h"
/* dbus.c */ /* dbus.c */
void dbus_init(void); bool dbus_init(void);
void dbus_uninit(void); void dbus_uninit(void);
/* control.c */ /* control.c */

View File

@ -2,7 +2,7 @@
/* /*
* LADI Session Handler (ladish) * LADI Session Handler (ladish)
* *
* Copyright (C) 2008,2009,2010,2011 Nedko Arnaudov <nedko@arnaudov.name> * Copyright (C) 2008,2009,2010,2011,2014 Nedko Arnaudov <nedko@arnaudov.name>
* *
************************************************************************** **************************************************************************
* This file contains the code that implements main() and other top-level functionality * This file contains the code that implements main() and other top-level functionality
@ -92,7 +92,10 @@ int main(int argc, char** argv)
gtk_init(&argc, &argv); gtk_init(&argc, &argv);
dbus_init(); if (!dbus_init())
{
return 1;
}
if (!conf_proxy_init()) if (!conf_proxy_init())
{ {