trying to improve the threading issue

This commit is contained in:
Patrick von Reth 2014-02-14 12:24:06 +01:00
parent a8f169428d
commit 50ed6e2943
3 changed files with 32 additions and 5 deletions

View File

@ -27,13 +27,16 @@
#include <QDir>
#include <QDebug>
#include <QMetaEnum>
#include <QApplication>
using namespace Snore;
SnorePlugin::SnorePlugin ( const QString &name ) :
m_name ( name ),
m_initialized(false)
{}
{
moveToThread( qApp->thread() );
}
SnorePlugin::~SnorePlugin()
{

View File

@ -32,9 +32,6 @@ SnoreNotifier::SnoreNotifier():
SnoreBackend("Snore", true, true, true),
m_widgets(2)
{
moveToThread(qApp->thread());//TODO cleanup
QTimer::singleShot(0, this, SLOT(setup()));
}
SnoreNotifier::~SnoreNotifier()
@ -117,3 +114,26 @@ void SnoreNotifier::setup()
connect(w, SIGNAL(invoked()), this, SLOT(slotInvoked()));
}
}
bool SnoreNotifier::initialize(SnoreCore *snore)
{
if(SnoreBackend::initialize(snore))
{
return metaObject()->invokeMethod(this, "setup", Qt::QueuedConnection);
}
return false;
}
bool SnoreNotifier::deinitialize()
{
if(SnoreBackend::deinitialize())
{
for(int i=0;i<m_widgets.size();++i)
{
m_widgets[i]->deleteLater();
}
return true;
}
return false;
}

View File

@ -33,7 +33,9 @@ public:
SnoreNotifier();
~SnoreNotifier();
// SnoreBackend interface
virtual bool initialize(Snore::SnoreCore *snore);
virtual bool deinitialize();
public slots:
virtual void slotNotify(Snore::Notification notification);
virtual void slotCloseNotification(Snore::Notification notification);
@ -48,6 +50,8 @@ private:
QList<Snore::Notification> m_queue;
QVector<NotifyWidget*> m_widgets;
};
#endif // SNORENOTIFIER_H