From bb450be0e7db25e3b28e642cecdd311285d977ee Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Fri, 31 May 2013 22:06:35 +0200 Subject: [PATCH] Delay resuming as we will most likely fail connecting directly --- src/tomahawk/linux/UPowerHandler.cpp | 14 +++++++++++++- src/tomahawk/linux/UPowerHandler.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/tomahawk/linux/UPowerHandler.cpp b/src/tomahawk/linux/UPowerHandler.cpp index bee306afe..e5a74c0c8 100644 --- a/src/tomahawk/linux/UPowerHandler.cpp +++ b/src/tomahawk/linux/UPowerHandler.cpp @@ -20,6 +20,10 @@ #include "UPowerHandler.h" #include "utils/Logger.h" +#include + +#define UPOWER_RESUME_DELAY 2000 + using namespace Tomahawk; const char* UPowerHandler::UPowerService = "org.freedesktop.UPower"; @@ -61,7 +65,15 @@ UPowerHandler::handleSleep() void UPowerHandler::handleResume() { - QMutexLocker locker( &m_mutex ); + m_mutex.lock(); + // Delay resuming for other wakeup actions, e.g. reconnecting to the network, to take place. + QTimer::singleShot( UPOWER_RESUME_DELAY, this, SLOT( actualResume() ) ); +} + +void +UPowerHandler::actualResume() +{ tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Awake from sleep so connecting all accounts"; Tomahawk::Accounts::AccountManager::instance()->connectAll(); + m_mutex.unlock(); } diff --git a/src/tomahawk/linux/UPowerHandler.h b/src/tomahawk/linux/UPowerHandler.h index 6ffd64f71..9ee501edf 100644 --- a/src/tomahawk/linux/UPowerHandler.h +++ b/src/tomahawk/linux/UPowerHandler.h @@ -44,6 +44,7 @@ private: private slots: void handleSleep(); void handleResume(); + void actualResume(); }; }