Commit 8b463f4f authored by Michael Pyne's avatar Michael Pyne

scrobbler: fix missing QNetworkAccessManager when session active.

Based on patch provided by tanjoodo, but simplified to create the
missing QNetworkAccessManager unilaterally.

This avoids a crash in the scrobbler when scrobbling is attempted with
an active session but no network manager (such as when the configured
internet connection is lost).

Differential Revision: https://phabricator.kde.org/D17140
parent b4fd2593
......@@ -19,7 +19,6 @@
#include <QCryptographicHash>
#include <QDir>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QDomDocument>
......@@ -38,7 +37,7 @@
Scrobbler::Scrobbler(QObject* parent)
: QObject(parent)
, m_networkAccessManager(nullptr)
, m_networkAccessManager(new QNetworkAccessManager(this))
, m_wallet(Scrobbler::openKWallet())
{
QByteArray sessionKey;
......@@ -150,9 +149,6 @@ void Scrobbler::getAuthToken(QString username, QString password)
url.setQuery(urlQuery);
if (!m_networkAccessManager)
m_networkAccessManager = new QNetworkAccessManager(this);
QNetworkReply *reply = m_networkAccessManager->get(QNetworkRequest(url));
connect(reply, SIGNAL(finished()), this, SLOT(handleAuthenticationReply()));
}
......@@ -305,10 +301,6 @@ void Scrobbler::scrobble()
void Scrobbler::post(QMap<QString, QString> &params)
{
if(!m_networkAccessManager) {
return;
}
QUrl url("http://ws.audioscrobbler.com/2.0/");
QByteArray data;
......
......@@ -20,6 +20,7 @@
#include <QObject>
#include <QMap>
#include <QNetworkAccessManager>
#include <QDateTime>
#include <KWallet>
......@@ -66,8 +67,8 @@ private:
QDateTime m_playbackTimer;
FileHandle m_file;
QNetworkAccessManager *m_networkAccessManager;
std::unique_ptr<QNetworkAccessManager> m_networkAccessManager;
std::unique_ptr<Wallet> m_wallet;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment