fixed a crash

This commit is contained in:
Patrick von Reth 2014-01-15 18:49:20 +01:00
parent b4cb329145
commit 39ce837ae4
3 changed files with 20 additions and 17 deletions

View File

@ -46,7 +46,7 @@ bool SnorePlugin::initialize( SnoreCore *snore )
qFatal("Something went wrong, plugin %s is already initialized",this->name().toLatin1().constData()); qFatal("Something went wrong, plugin %s is already initialized",this->name().toLatin1().constData());
return false; return false;
} }
qDebug()<<"Initialize"<<m_name<<this<<snore; qDebug() << "Initialize" << m_name << this << snore;
this->m_snore = snore; this->m_snore = snore;
m_initialized = true; m_initialized = true;
return true; return true;
@ -87,11 +87,13 @@ void SnorePlugin::startTimeout(uint id,int timeout){
timer->start(); timer->start();
} }
void SnorePlugin::notificationTimedOut(){ void SnorePlugin::notificationTimedOut()
{
uint id = m_timeout_order.takeFirst(); uint id = m_timeout_order.takeFirst();
m_timeouts.take(id)->deleteLater(); m_timeouts.take(id)->deleteLater();
Notification n = snore()->getActiveNotificationByID(id); Notification n = snore()->getActiveNotificationByID(id);
if(n.isValid()){ if(n.isValid())
{
snore()->requestCloseNotification(n,NotificationEnums::CloseReasons::TIMED_OUT); snore()->requestCloseNotification(n,NotificationEnums::CloseReasons::TIMED_OUT);
} }
} }
@ -100,6 +102,7 @@ bool SnorePlugin::deinitialize()
{ {
if(m_initialized) if(m_initialized)
{ {
qDebug() << "Deinitialize" << m_name << this;
m_initialized = false; m_initialized = false;
return true; return true;
} }

View File

@ -133,8 +133,7 @@ private:
SnarlBackend::SnarlBackend(): SnarlBackend::SnarlBackend():
SnoreBackend("Snarl",true,false), SnoreBackend("Snarl",true,false)
m_defautSnarlinetrface(NULL)
{ {
} }
@ -155,8 +154,7 @@ bool SnarlBackend::initialize(SnoreCore *snore)
} }
m_eventLoop = new SnarlBackend::SnarlWidget(this); m_eventLoop = new SnarlBackend::SnarlWidget(this);
m_applications.insert(snore->d()->defaultApplication().name(),snarlInterface); m_applications.insert(snore->d()->defaultApplication().name(),snarlInterface);
qDebug()<<"Initiating Snarl Backend, Snarl version: "<<snarlInterface->GetVersion(); qDebug() << "Initiating Snarl Backend, Snarl version: " << snarlInterface->GetVersion();
m_defautSnarlinetrface = snarlInterface;
return SnoreBackend::initialize(snore); return SnoreBackend::initialize(snore);
} }
@ -165,16 +163,12 @@ bool SnarlBackend::deinitialize()
{ {
if(SnoreBackend::deinitialize()) if(SnoreBackend::deinitialize())
{ {
if(m_defautSnarlinetrface) if(m_eventLoop)
{ {
delete m_defautSnarlinetrface; m_eventLoop->deleteLater();
m_defautSnarlinetrface = NULL;
delete m_eventLoop;
m_eventLoop = NULL; m_eventLoop = NULL;
m_applications.clear();
} }
m_applications.clear();
return true; return true;
} }
return false; return false;
@ -222,7 +216,7 @@ void SnarlBackend::slotNotify(Notification notification){
{ {
qDebug()<<notification.application()<<"not in snarl interfaces, defaulting"; qDebug()<<notification.application()<<"not in snarl interfaces, defaulting";
qDebug()<<m_applications.keys(); qDebug()<<m_applications.keys();
snarlInterface = m_defautSnarlinetrface; snarlInterface = m_applications[snore()->d()->defaultApplication().name()];
} }
Snarl::V42::SnarlEnums::MessagePriority priority = Snarl::V42::SnarlEnums::PriorityUndefined; Snarl::V42::SnarlEnums::MessagePriority priority = Snarl::V42::SnarlEnums::PriorityUndefined;
@ -278,5 +272,12 @@ void SnarlBackend::slotNotify(Notification notification){
void SnarlBackend::slotCloseNotification(Notification notification) void SnarlBackend::slotCloseNotification(Notification notification)
{ {
m_defautSnarlinetrface->Hide(m_idMap.take(notification.id())); SnarlInterface *snarlInterface = m_applications.value(notification.application().name());
if(snarlInterface == NULL)
{
qDebug()<<notification.application()<<"not in snarl interfaces, defaulting";
qDebug()<<m_applications.keys();
snarlInterface = m_applications[snore()->d()->defaultApplication().name()];
}
snarlInterface->Hide(m_idMap.take(notification.id()));
} }

View File

@ -39,7 +39,6 @@ private:
class SnarlWidget; class SnarlWidget;
SnarlBackend::SnarlWidget* m_eventLoop; SnarlBackend::SnarlWidget* m_eventLoop;
QHash<QString,Snarl::V42::SnarlInterface*> m_applications; QHash<QString,Snarl::V42::SnarlInterface*> m_applications;
Snarl::V42::SnarlInterface* m_defautSnarlinetrface;
public slots: public slots:
void slotRegisterApplication(const Snore::Application &application); void slotRegisterApplication(const Snore::Application &application);