From 6466d50172e68149eb465a3ba1be73df745bf0f6 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 22 Oct 2014 09:46:32 -0400 Subject: Fix the system tray checking to once run one at a time (to prevent possible conflict with different loops modifying tray icons at the same time). This might fix the random desktop crashes since they seem to be tray related. --- lumina-desktop/panel-plugins/systemtray/LSysTray.cpp | 18 +++++++++++++----- lumina-desktop/panel-plugins/systemtray/LSysTray.h | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp b/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp index 36f5f81d..1d1ebe67 100644 --- a/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp +++ b/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp @@ -34,7 +34,7 @@ LSysTray::LSysTray(QWidget *parent, QString id, bool horizontal) : LPPlugin(pare upTimer = new QTimer(this); upTimer->setInterval(300000); //maximum time between refreshes is 5 minutes connect(upTimer, SIGNAL(timeout()), this, SLOT(checkAll()) ); - isRunning = false; stopping = false; + isRunning = false; stopping = false; checking = false; QTimer::singleShot(100, this, SLOT(start()) ); connect(LSession::handle(), SIGNAL(TrayListChanged()), this, SLOT(checkAll()) ); @@ -166,12 +166,15 @@ void LSysTray::closeAll(){ } */ void LSysTray::checkAll(){ - if(!isRunning || stopping){ return; } //Don't check if not running at the moment + if(!isRunning || stopping || checking){ return; } //Don't check if not running at the moment + checking = true; + //qDebug() << "System Tray: Check tray apps"; QList wins = LSession::handle()->currentTrayApps(this->winId()); for(int i=0; iappID()); if(index < 0){ //Tray Icon no longer exists: remove it + //qDebug() << " - SysTray: Remove Icon"; TrayIcon *cont = trayIcons.takeAt(i); LI->removeWidget(cont); delete cont; @@ -184,12 +187,14 @@ void LSysTray::checkAll(){ } }else{ //Tray Icon already exists: just update it + //qDebug() << " - SysTray: Update Icon"; trayIcons[i]->update(); wins.removeAt(index); //Already found - remove from the list } } //Now go through any remaining windows and add them for(int i=0; iattachApp(wins[i]); - if(cont->appID()==0){ qDebug() << "Invalid Container:"; delete cont; continue; } //could not attach window + if(cont->appID()==0){ qDebug() << "Invalid Tray Container:"; delete cont; continue; } //could not attach window LI->update(); //make sure there is no blank space in the layout } + //qDebug() << " - System Tray: check done"; + checking = false; } void LSysTray::UpdateTrayWindow(WId win){ - if(!isRunning || stopping){ return; } + if(!isRunning || stopping || checking){ return; } for(int i=0; iappID()==win){ + if(trayIcons[i]->appID()==win){ + //qDebug() << "System Tray: Update Window " << win; trayIcons[i]->update(); break; } diff --git a/lumina-desktop/panel-plugins/systemtray/LSysTray.h b/lumina-desktop/panel-plugins/systemtray/LSysTray.h index 7f8386fc..f45a52ad 100644 --- a/lumina-desktop/panel-plugins/systemtray/LSysTray.h +++ b/lumina-desktop/panel-plugins/systemtray/LSysTray.h @@ -31,7 +31,7 @@ public: ~LSysTray(); private: - bool isRunning, stopping; + bool isRunning, stopping, checking; QList trayIcons; QFrame *frame; QBoxLayout *LI; //layout items -- cgit