From f86fa3cd776a48367aa15331c1c0b102fd378d03 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 22 Apr 2016 12:18:34 +0200 Subject: [PATCH 1/2] guard m_controller with a QPointer is possible it's null for an instant when the player quits a call to start() in the moment between the app is closed and the teardown is done is unlikely but apparently happens BUG:361985 --- dataengines/mpris2/playeractionjob.cpp | 17 ++++++++++++++--- dataengines/mpris2/playeractionjob.h | 5 +++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/dataengines/mpris2/playeractionjob.cpp b/dataengines/mpris2/playeractionjob.cpp index 578f07ef8..8e91ea368 100644 --- a/dataengines/mpris2/playeractionjob.cpp +++ b/dataengines/mpris2/playeractionjob.cpp @@ -19,8 +19,6 @@ #include "playeractionjob.h" -#include "playercontrol.h" - #include #include #include @@ -46,6 +44,12 @@ void PlayerActionJob::start() { const QString operation(operationName()); + if (!m_controller) { + setError(Failed); + emitResult(); + return; + } + qCDebug(MPRIS2) << "Trying to perform the action" << operationName(); if (!m_controller->isOperationEnabled(operation)) { setError(Denied); @@ -160,6 +164,12 @@ void PlayerActionJob::callFinished(QDBusPendingCallWatcher* watcher) void PlayerActionJob::setDBusProperty(const QString& iface, const QString& propName, const QDBusVariant& value) { + if (!m_controller) { + setError(Failed); + emitResult(); + return; + } + listenToCall( m_controller->propertiesInterface()->Set(iface, propName, value) ); @@ -168,7 +178,8 @@ void PlayerActionJob::setDBusProperty(const QString& iface, const QString& propN QString PlayerActionJob::errorString() const { if (error() == Denied) { - return i18n("The media player '%1' cannot perform the action '%2'.", m_controller->name(), operationName()); + const QString name = m_controller ? m_controller->name() : QString(); + return i18n("The media player '%1' cannot perform the action '%2'.", name, operationName()); } else if (error() == Failed) { return i18n("Attempting to perform the action '%1' failed with the message '%2'.", operationName(), errorText()); diff --git a/dataengines/mpris2/playeractionjob.h b/dataengines/mpris2/playeractionjob.h index 1c47ab407..a00cc7ab0 100644 --- a/dataengines/mpris2/playeractionjob.h +++ b/dataengines/mpris2/playeractionjob.h @@ -22,10 +22,11 @@ #include +#include "playercontrol.h" + class QDBusPendingCallWatcher; class QDBusPendingCall; class QDBusVariant; -class PlayerControl; class PlayerActionJob : public Plasma::ServiceJob { @@ -68,7 +69,7 @@ private Q_SLOTS: private: void listenToCall(const QDBusPendingCall& call); - PlayerControl *m_controller; + QPointer m_controller; }; #endif // PLAYERACTIONJOB_H From a7a22de14c360fa5c975e0bae30fc22e4cd7cc43 Mon Sep 17 00:00:00 2001 From: Wolfgang Bauer Date: Fri, 22 Apr 2016 19:03:28 +0200 Subject: [PATCH 2/2] [digital-clock] Fix display of seconds with certain locales Currently, "Show seconds" has no effect with certain locales (C e.g.) that already contain the seconds in the ShortFormat. The reason is that the seconds are only added to the format string that's used to display the time if they are not part of timeFormatString already (which is not used at all for the display). This patch fixes that check and adds them only depending on the showSeconds config option. REVIEW: 127623 --- .../digital-clock/package/contents/ui/DigitalClock.qml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/applets/digital-clock/package/contents/ui/DigitalClock.qml b/applets/digital-clock/package/contents/ui/DigitalClock.qml index 95bb07145..6fa8e39ab 100644 --- a/applets/digital-clock/package/contents/ui/DigitalClock.qml +++ b/applets/digital-clock/package/contents/ui/DigitalClock.qml @@ -478,11 +478,7 @@ Item { // and Short does not provide seconds. So if seconds are enabled, we need to add it here. // // What happens here is that it looks for the delimiter between "h" and "m", takes it - // and appends it after "mm" and then appends "ss" for the seconds. Also it checks - // if the format string already does not contain the seconds part. - // - // It can happen that Qt uses the 'C' locale (it's a fallback) and that locale - // has always ":ss" part in ShortFormat, so we need to remove it. + // and appends it after "mm" and then appends "ss" for the seconds. function timeFormatCorrection(timeFormatString) { var regexp = /(hh*)(.+)(mm)/i var match = regexp.exec(timeFormatString); @@ -498,7 +494,7 @@ Item { // when uppercase H is used for hours, needs to be h or hh, so toLowerCase() var result = hours.toLowerCase() + delimiter + minutes; - if (main.showSeconds && timeFormatString.indexOf('s') == -1) { + if (main.showSeconds) { result += delimiter + seconds; }