Don't leak AudioScrobbler.
This commit is contained in:
parent
ccedb0fdc6
commit
20de7a1a81
@ -79,7 +79,6 @@ const char* LastFMService::kAuthLoginUrl =
|
|||||||
|
|
||||||
LastFMService::LastFMService(Application* app, QObject* parent)
|
LastFMService::LastFMService(Application* app, QObject* parent)
|
||||||
: Scrobbler(parent),
|
: Scrobbler(parent),
|
||||||
scrobbler_(nullptr),
|
|
||||||
already_scrobbled_(false),
|
already_scrobbled_(false),
|
||||||
scrobbling_enabled_(false),
|
scrobbling_enabled_(false),
|
||||||
connection_problems_(false),
|
connection_problems_(false),
|
||||||
@ -185,8 +184,7 @@ void LastFMService::AuthenticateReplyFinished(QNetworkReply* reply) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Invalidate the scrobbler - it will get recreated later
|
// Invalidate the scrobbler - it will get recreated later
|
||||||
delete scrobbler_;
|
scrobbler_.reset(nullptr);
|
||||||
scrobbler_ = nullptr;
|
|
||||||
|
|
||||||
emit AuthenticationComplete(true, QString());
|
emit AuthenticationComplete(true, QString());
|
||||||
}
|
}
|
||||||
@ -289,16 +287,16 @@ bool LastFMService::InitScrobbler() {
|
|||||||
if (!IsAuthenticated() || !IsScrobblingEnabled()) return false;
|
if (!IsAuthenticated() || !IsScrobblingEnabled()) return false;
|
||||||
|
|
||||||
if (!scrobbler_)
|
if (!scrobbler_)
|
||||||
scrobbler_ = new lastfm::Audioscrobbler(kAudioscrobblerClientId);
|
scrobbler_.reset(new lastfm::Audioscrobbler(kAudioscrobblerClientId));
|
||||||
|
|
||||||
// reemit the signal since the sender is private
|
// reemit the signal since the sender is private
|
||||||
#ifdef HAVE_LIBLASTFM1
|
#ifdef HAVE_LIBLASTFM1
|
||||||
connect(scrobbler_, SIGNAL(scrobblesSubmitted(QList<lastfm::Track>)),
|
connect(scrobbler_.get(), SIGNAL(scrobblesSubmitted(QList<lastfm::Track>)),
|
||||||
SIGNAL(ScrobbleSubmitted()));
|
SIGNAL(ScrobbleSubmitted()));
|
||||||
connect(scrobbler_, SIGNAL(nowPlayingError(int, QString)),
|
connect(scrobbler_.get(), SIGNAL(nowPlayingError(int, QString)),
|
||||||
SIGNAL(ScrobbleError(int)));
|
SIGNAL(ScrobbleError(int)));
|
||||||
#else
|
#else
|
||||||
connect(scrobbler_, SIGNAL(status(int)), SLOT(ScrobblerStatus(int)));
|
connect(scrobbler_.get(), SIGNAL(status(int)), SLOT(ScrobblerStatus(int)));
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ class LastFMService : public Scrobbler {
|
|||||||
void ShowConfig();
|
void ShowConfig();
|
||||||
void ToggleScrobbling();
|
void ToggleScrobbling();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void TokenReceived(bool success, const QString& token);
|
void TokenReceived(bool success, const QString& token);
|
||||||
void AuthenticationComplete(bool success, const QString& error_message);
|
void AuthenticationComplete(bool success, const QString& error_message);
|
||||||
void ScrobblingEnabledChanged(bool value);
|
void ScrobblingEnabledChanged(bool value);
|
||||||
@ -111,7 +111,7 @@ class LastFMService : public Scrobbler {
|
|||||||
static QUrl FixupUrl(const QUrl& url);
|
static QUrl FixupUrl(const QUrl& url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
lastfm::Audioscrobbler* scrobbler_;
|
std::unique_ptr<lastfm::Audioscrobbler> scrobbler_;
|
||||||
lastfm::Track last_track_;
|
lastfm::Track last_track_;
|
||||||
lastfm::Track next_metadata_;
|
lastfm::Track next_metadata_;
|
||||||
bool already_scrobbled_;
|
bool already_scrobbled_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user