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(); }; }