[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [Oxygen-Gtk] 03ec846: use singleton instance for OxygenDBus rather
From: Hugo Pereira Da Costa <hugo () oxygen-icons ! org>
Date: 2011-01-15 10:37:51
Message-ID: 20110115103751.B93DEA6090 () git ! kde ! org
[Download RAW message or body]
commit 03ec8462b5a32c525281db3bdb1854a9d5d9772f
branch master
Author: Hugo Pereira Da Costa <hugo@oxygen-icons.org>
Date: Sat Jan 15 11:36:02 2011 +0100
use singleton instance for OxygenDBus rather than static methods.
Moved setupConnection from oxygentheme (::theme_init) to \
StyleWrapper::oxygen_style_instance_init() This fixes crash in emacs, probably \
because the first was initializating DBus in wrong thread.
CCBUG: 263186
diff --git a/src/oxygendbus.cpp b/src/oxygendbus.cpp
index 8cb5a3e..84ba863 100644
--- a/src/oxygendbus.cpp
+++ b/src/oxygendbus.cpp
@@ -30,11 +30,28 @@
namespace Oxygen
{
+ //__________________________________________________________________
+ DBus* DBus::_instance = 0;
+ DBus& DBus::instance( void )
+ {
+ if( !_instance )
+ {
+ _instance = new DBus();
+ _instance->setupConnection();
+ }
+
+ return *_instance;
+ }
//_________________________________________________________
void DBus::setupConnection( void )
{
+ // make sure the method is called only once
+ static bool first( true );
+ if( !first ) return;
+ first = false;
+
#if OXYGEN_DEBUG
std::cerr << "Oxygen::DBus::setupConnection" << std::endl;
#endif
diff --git a/src/oxygendbus.h b/src/oxygendbus.h
index 731bea9..77c459f 100644
--- a/src/oxygendbus.h
+++ b/src/oxygendbus.h
@@ -38,11 +38,18 @@ namespace Oxygen
public:
- //! setup connections
- static void setupConnection( void );
+ //! return singleton
+ static DBus& instance( void );
+
+ //! destructor
+ virtual ~DBus( void )
+ { _instance = 0L; }
protected:
+ //! setup connections
+ void setupConnection( void );
+
/*!
copied from kdelibs/kdeui/kernel/kglobalsettings
used to only update relevant parts on kglobalconfig changes
@@ -66,6 +73,15 @@ namespace Oxygen
static DBusHandlerResult signalFilter( DBusConnection*, DBusMessage*, \
gpointer ); #endif
+ private:
+
+ //! constructor
+ DBus( void )
+ {}
+
+ //! singleton
+ static DBus* _instance;
+
};
}
diff --git a/src/oxygenstylewrapper.cpp b/src/oxygenstylewrapper.cpp
index ae10bc6..21d0ee1 100644
--- a/src/oxygenstylewrapper.cpp
+++ b/src/oxygenstylewrapper.cpp
@@ -32,6 +32,7 @@
#include "oxygen.h"
#include "oxygenanimations.h"
#include "oxygencairoutils.h"
+#include "oxygendbus.h"
#include "oxygengtkcellinfo.h"
#include "oxygengtkdetails.h"
#include "oxygengtktypenames.h"
@@ -2646,6 +2647,7 @@ extern "C" void oxygen_style_instance_init( OxygenStyle* self )
elsewhere, to fix some overwritting that occurs with some distros
*/
Oxygen::Style::instance().settings().initializeColors();
+ Oxygen::DBus::instance();
}
//_______________________________________________________________________________________________________________
diff --git a/src/oxygentheme.cpp b/src/oxygentheme.cpp
index ebb7dfb..8bce794 100644
--- a/src/oxygentheme.cpp
+++ b/src/oxygentheme.cpp
@@ -210,9 +210,6 @@ void theme_init( GTypeModule* module )
if( Oxygen::Style::instance().settings().applicationName().isOpenOffice() )
{ Oxygen::Style::instance().animations().setEnabled( false ); }
- // setup dbus connection
- Oxygen::DBus::setupConnection();
-
}
//_________________________________________________
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic