From f7f25c5f7c1d58f35d88bbe71d00fcd06608a29a Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Mon, 18 Apr 2016 19:29:18 +0000 Subject: [PATCH] knotify: simplify idle players cleanup Signed-off-by: Ivailo Monev --- knotify/notifybysound.cpp | 22 +++++----------------- knotify/notifybysound.h | 3 --- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/knotify/notifybysound.cpp b/knotify/notifybysound.cpp index 349412b3..9a1a2cf3 100644 --- a/knotify/notifybysound.cpp +++ b/knotify/notifybysound.cpp @@ -60,7 +60,6 @@ NotifyBySound::NotifyBySound(QObject *parent) : KNotifyPlugin(parent),d(new Priv connect(d->signalmapper, SIGNAL(mapped(int)), this, SLOT(slotSoundFinished(int))); d->currentPlayer = new KAudioPlayer(this); - startTimer(1000); loadConfig(); } @@ -133,28 +132,17 @@ void NotifyBySound::notify( int eventId, KNotifyConfig * config ) } } - -void NotifyBySound::timerEvent(QTimerEvent *e) -{ - QMutableMapIterator iter(d->playerObjects); - while (iter.hasNext()) { - iter.next(); - KAudioPlayer *player = iter.value(); - if (player != d->currentPlayer && !player->isPlaying()) { - kDebug() << "destroying idle player"; - d->playerObjects.remove(d->playerObjects.key(player)); - player->deleteLater(); - } - } - KNotifyPlugin::timerEvent(e); -} - void NotifyBySound::slotSoundFinished(int id) { kDebug() << id; if (d->playerObjects.contains(id)) { KAudioPlayer *player=d->playerObjects.value(id); disconnect(player, SIGNAL(finished()), d->signalmapper, SLOT(map())); + if (player != d->currentPlayer) { + kDebug() << "destroying idle player"; + d->playerObjects.remove(id); + player->deleteLater(); + } } finish(id); } diff --git a/knotify/notifybysound.h b/knotify/notifybysound.h index 44f6463c..34ed8e6b 100644 --- a/knotify/notifybysound.h +++ b/knotify/notifybysound.h @@ -44,9 +44,6 @@ class NotifyBySound : public KNotifyPlugin public: void setVolume( int v ); - protected: - void timerEvent(QTimerEvent *); - private Q_SLOTS: void slotSoundFinished(int id); void closeNow(); -- 2.11.0