@@ -47,34 +47,13 @@ public:
4747IndicatorsManager::IndicatorsManager(QObject* parent)
4848 : QObject(parent)
4949 , m_loaded(false)
50− , m_upstart(NULL)
5150{
52− auto upstartsession = qgetenv("UPSTART_SESSION");
53− if (!upstartsession.isNull()) {
54− DBusConnection * conn = NULL;
55− conn = dbus_connection_open(upstartsession.constData(), NULL);
56− if (conn != NULL) {
57− m_upstart = nih_dbus_proxy_new(NULL, conn,
58− NULL,
59− DBUS_PATH_UPSTART,
60− NULL, NULL);
61− dbus_connection_unref(conn);
62− }
63− }
64−
65− if (m_upstart != NULL) {
66− m_upstart->auto_start = FALSE;
67− }
6851}
6952
7053IndicatorsManager::~IndicatorsManager()
7154{
7255 unload();
7356
74− if (m_upstart != NULL) {
75− nih_unref(m_upstart, NULL);
76− m_upstart = NULL;
77− }
7857}
7958
8059void IndicatorsManager::load()
@@ -235,17 +214,34 @@ void IndicatorsManager::setLoaded(bool loaded)
235214 m_loaded = loaded;
236215 Q_EMIT loadedChanged(m_loaded);
237216
238− if (m_upstart != NULL) {
217+ auto upstartsession = qgetenv("UPSTART_SESSION");
218+ NihDBusProxy * upstart = NULL;
219+
220+ if (!upstartsession.isNull()) {
221+ DBusConnection * conn = NULL;
222+ conn = dbus_connection_open(upstartsession.constData(), NULL);
223+ if (conn != NULL) {
224+ upstart = nih_dbus_proxy_new(NULL, conn,
225+ NULL,
226+ DBUS_PATH_UPSTART,
227+ NULL, NULL);
228+ dbus_connection_unref(conn);
229+ }
230+ }
231+
232+ if (upstart != NULL) {
239233 int event_sent = 0;
240234 if (m_loaded) {
241− event_sent = upstart_emit_event_sync(NULL, m_upstart, "indicator-services-start", NULL, 0);
235+ event_sent = upstart_emit_event_sync(NULL, upstart, "indicator-services-start", NULL, 0);
242236 } else {
243− event_sent = upstart_emit_event_sync(NULL, m_upstart, "indicator-services-end", NULL, 0);
237+ event_sent = upstart_emit_event_sync(NULL, upstart, "indicator-services-end", NULL, 0);
244238 }
245239
246240 if (event_sent != 0) {
247241 qWarning() << "Unable to send indicator event to Upstart";
248242 }
243+ nih_unref(upstart, NULL);
244+ upstart = NULL;
249245 }
250246 }
251247}