Fix memory leak when moodbar is disabled
Only call MoodbarLoader::Load when moodbar is enabled.
This commit is contained in:
parent
010a0cc2a7
commit
50d83dc070
@ -1109,6 +1109,7 @@ void MainWindow::ReloadAllSettings() {
|
||||
app_->ReloadSettings();
|
||||
app_->collection()->ReloadSettings();
|
||||
app_->player()->ReloadSettings();
|
||||
app_->moodbar_controller()->ReloadSettings();
|
||||
collection_view_->ReloadSettings();
|
||||
ui_->playlist->view()->ReloadSettings();
|
||||
app_->playlist_manager()->playlist_container()->ReloadSettings();
|
||||
|
@ -26,8 +26,8 @@
|
||||
#include "core/player.h"
|
||||
#include "core/song.h"
|
||||
#include "engine/engine_fwd.h"
|
||||
#include "settings/moodbarsettingspage.h"
|
||||
#include "playlist/playlistmanager.h"
|
||||
#include "playlist/playlistitem.h"
|
||||
|
||||
#include "moodbarcontroller.h"
|
||||
#include "moodbarloader.h"
|
||||
@ -35,14 +35,28 @@
|
||||
|
||||
MoodbarController::MoodbarController(Application* app, QObject* parent)
|
||||
: QObject(parent),
|
||||
app_(app) {
|
||||
app_(app),
|
||||
enabled_(false) {
|
||||
|
||||
connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), SLOT(CurrentSongChanged(Song)));
|
||||
connect(app_->player(), SIGNAL(Stopped()), SLOT(PlaybackStopped()));
|
||||
|
||||
ReloadSettings();
|
||||
|
||||
}
|
||||
|
||||
void MoodbarController::CurrentSongChanged(const Song& song) {
|
||||
void MoodbarController::ReloadSettings() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(MoodbarSettingsPage::kSettingsGroup);
|
||||
enabled_ = s.value("enabled", false).toBool();
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
void MoodbarController::CurrentSongChanged(const Song &song) {
|
||||
|
||||
if (!enabled_) return;
|
||||
|
||||
QByteArray data;
|
||||
MoodbarPipeline* pipeline = nullptr;
|
||||
@ -69,7 +83,9 @@ void MoodbarController::CurrentSongChanged(const Song& song) {
|
||||
}
|
||||
|
||||
void MoodbarController::PlaybackStopped() {
|
||||
emit CurrentMoodbarDataChanged(QByteArray());
|
||||
if (enabled_) {
|
||||
emit CurrentMoodbarDataChanged(QByteArray());
|
||||
}
|
||||
}
|
||||
|
||||
void MoodbarController::AsyncLoadComplete(MoodbarPipeline* pipeline, const QUrl& url) {
|
||||
|
@ -33,6 +33,8 @@ class MoodbarController : public QObject {
|
||||
public:
|
||||
explicit MoodbarController(Application* app, QObject* parent = nullptr);
|
||||
|
||||
void ReloadSettings();
|
||||
|
||||
signals:
|
||||
void CurrentMoodbarDataChanged(const QByteArray& data);
|
||||
|
||||
@ -43,6 +45,7 @@ class MoodbarController : public QObject {
|
||||
|
||||
private:
|
||||
Application* app_;
|
||||
bool enabled_;
|
||||
};
|
||||
|
||||
#endif // MOODBARCONTROLLER_H
|
||||
|
@ -75,7 +75,6 @@ void MoodbarLoader::ReloadSettings() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(MoodbarSettingsPage::kSettingsGroup);
|
||||
enabled_ = s.value("enabled", false).toBool();
|
||||
save_ = s.value("save", false).toBool();
|
||||
s.endGroup();
|
||||
|
||||
@ -148,7 +147,7 @@ void MoodbarLoader::MaybeTakeNextRequest() {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() == qApp->thread());
|
||||
|
||||
if (active_requests_.count() >= kMaxActiveRequests || queued_requests_.isEmpty() || !enabled_) {
|
||||
if (active_requests_.count() >= kMaxActiveRequests || queued_requests_.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user