mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-03 05:21:57 +01:00
Fix memory leaks (#6376)
This commit is contained in:
parent
ec2e8be4d6
commit
546078c317
@ -33,15 +33,14 @@ static const int kTaglibSuffixCacheBytes = 8 * 1024;
|
|||||||
}
|
}
|
||||||
|
|
||||||
CloudStream::CloudStream(const QUrl& url, const QString& filename,
|
CloudStream::CloudStream(const QUrl& url, const QString& filename,
|
||||||
const long length, const QString& auth,
|
const long length, const QString& auth)
|
||||||
QNetworkAccessManager* network)
|
|
||||||
: url_(url),
|
: url_(url),
|
||||||
filename_(filename),
|
filename_(filename),
|
||||||
encoded_filename_(filename_.toUtf8()),
|
encoded_filename_(filename_.toUtf8()),
|
||||||
length_(length),
|
length_(length),
|
||||||
auth_(auth),
|
auth_(auth),
|
||||||
cursor_(0),
|
cursor_(0),
|
||||||
network_(network),
|
network_(new QNetworkAccessManager),
|
||||||
cache_(length),
|
cache_(length),
|
||||||
num_requests_(0) {}
|
num_requests_(0) {}
|
||||||
|
|
||||||
|
@ -18,21 +18,20 @@
|
|||||||
#ifndef GOOGLEDRIVESTREAM_H
|
#ifndef GOOGLEDRIVESTREAM_H
|
||||||
#define GOOGLEDRIVESTREAM_H
|
#define GOOGLEDRIVESTREAM_H
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QObject>
|
||||||
#include <QSslError>
|
#include <QSslError>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include <google/sparsetable>
|
#include <google/sparsetable>
|
||||||
#include <taglib/tiostream.h>
|
#include <taglib/tiostream.h>
|
||||||
|
|
||||||
class QNetworkAccessManager;
|
|
||||||
|
|
||||||
class CloudStream : public QObject, public TagLib::IOStream {
|
class CloudStream : public QObject, public TagLib::IOStream {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
CloudStream(const QUrl& url, const QString& filename, const long length,
|
CloudStream(const QUrl& url, const QString& filename, const long length,
|
||||||
const QString& auth, QNetworkAccessManager* network);
|
const QString& auth);
|
||||||
|
|
||||||
// Taglib::IOStream
|
// Taglib::IOStream
|
||||||
virtual TagLib::FileName name() const;
|
virtual TagLib::FileName name() const;
|
||||||
@ -73,7 +72,7 @@ class CloudStream : public QObject, public TagLib::IOStream {
|
|||||||
const QString auth_;
|
const QString auth_;
|
||||||
|
|
||||||
int cursor_;
|
int cursor_;
|
||||||
QNetworkAccessManager* network_;
|
std::unique_ptr<QNetworkAccessManager> network_;
|
||||||
|
|
||||||
google::sparsetable<char> cache_;
|
google::sparsetable<char> cache_;
|
||||||
int num_requests_;
|
int num_requests_;
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
@ -77,12 +76,6 @@
|
|||||||
#define NumberToASFAttribute(x) \
|
#define NumberToASFAttribute(x) \
|
||||||
TagLib::ASF::Attribute(QStringToTaglibString(QString::number(x)))
|
TagLib::ASF::Attribute(QStringToTaglibString(QString::number(x)))
|
||||||
|
|
||||||
class FileRefFactory {
|
|
||||||
public:
|
|
||||||
virtual ~FileRefFactory() {}
|
|
||||||
virtual TagLib::FileRef* GetFileRef(const QString& filename) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class TagLibFileRefFactory : public FileRefFactory {
|
class TagLibFileRefFactory : public FileRefFactory {
|
||||||
public:
|
public:
|
||||||
virtual TagLib::FileRef* GetFileRef(const QString& filename) {
|
virtual TagLib::FileRef* GetFileRef(const QString& filename) {
|
||||||
@ -122,7 +115,6 @@ const char* kASF_OriginalYear_ID = "WM/OriginalReleaseYear";
|
|||||||
|
|
||||||
TagReader::TagReader()
|
TagReader::TagReader()
|
||||||
: factory_(new TagLibFileRefFactory),
|
: factory_(new TagLibFileRefFactory),
|
||||||
network_(new QNetworkAccessManager),
|
|
||||||
kEmbeddedCover("(embedded)") {}
|
kEmbeddedCover("(embedded)") {}
|
||||||
|
|
||||||
void TagReader::ReadFile(const QString& filename,
|
void TagReader::ReadFile(const QString& filename,
|
||||||
@ -1332,8 +1324,8 @@ bool TagReader::ReadCloudFile(const QUrl& download_url, const QString& title,
|
|||||||
pb::tagreader::SongMetadata* song) const {
|
pb::tagreader::SongMetadata* song) const {
|
||||||
qLog(Debug) << "Loading tags from" << title;
|
qLog(Debug) << "Loading tags from" << title;
|
||||||
|
|
||||||
std::unique_ptr<CloudStream> stream(new CloudStream(
|
std::unique_ptr<CloudStream> stream(
|
||||||
download_url, title, size, authorisation_header, network_));
|
new CloudStream(download_url, title, size, authorisation_header));
|
||||||
stream->Precache();
|
stream->Precache();
|
||||||
std::unique_ptr<TagLib::File> tag;
|
std::unique_ptr<TagLib::File> tag;
|
||||||
if (mime_type == "audio/mpeg" &&
|
if (mime_type == "audio/mpeg" &&
|
||||||
|
@ -21,11 +21,11 @@
|
|||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
|
||||||
#include <taglib/xiphcomment.h>
|
#include <taglib/xiphcomment.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "tagreadermessages.pb.h"
|
#include "tagreadermessages.pb.h"
|
||||||
|
|
||||||
class QNetworkAccessManager;
|
|
||||||
class QString;
|
class QString;
|
||||||
class QTextCodec;
|
class QTextCodec;
|
||||||
class QUrl;
|
class QUrl;
|
||||||
@ -40,7 +40,11 @@ class PopularimeterFrame;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FileRefFactory;
|
class FileRefFactory {
|
||||||
|
public:
|
||||||
|
virtual ~FileRefFactory() {}
|
||||||
|
virtual TagLib::FileRef* GetFileRef(const QString& filename) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class holds all useful methods to read and write tags from/to files.
|
* This class holds all useful methods to read and write tags from/to files.
|
||||||
@ -119,8 +123,7 @@ class TagReader {
|
|||||||
static TagLib::ID3v2::PopularimeterFrame* GetPOPMFrameFromTag(
|
static TagLib::ID3v2::PopularimeterFrame* GetPOPMFrameFromTag(
|
||||||
TagLib::ID3v2::Tag* tag);
|
TagLib::ID3v2::Tag* tag);
|
||||||
|
|
||||||
FileRefFactory* factory_;
|
std::unique_ptr<FileRefFactory> factory_;
|
||||||
QNetworkAccessManager* network_;
|
|
||||||
|
|
||||||
const std::string kEmbeddedCover;
|
const std::string kEmbeddedCover;
|
||||||
};
|
};
|
||||||
|
@ -403,6 +403,8 @@ TagCompleter::TagCompleter(LibraryBackend* backend, Playlist::Column column,
|
|||||||
future);
|
future);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TagCompleter::~TagCompleter() { model()->deleteLater(); }
|
||||||
|
|
||||||
void TagCompleter::ModelReady(QFuture<TagCompletionModel*> future) {
|
void TagCompleter::ModelReady(QFuture<TagCompletionModel*> future) {
|
||||||
TagCompletionModel* model = future.result();
|
TagCompletionModel* model = future.result();
|
||||||
setModel(model);
|
setModel(model);
|
||||||
|
@ -157,6 +157,7 @@ class TagCompleter : public QCompleter {
|
|||||||
public:
|
public:
|
||||||
TagCompleter(LibraryBackend* backend, Playlist::Column column,
|
TagCompleter(LibraryBackend* backend, Playlist::Column column,
|
||||||
QLineEdit* editor);
|
QLineEdit* editor);
|
||||||
|
~TagCompleter();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void ModelReady(QFuture<TagCompletionModel*> future);
|
void ModelReady(QFuture<TagCompletionModel*> future);
|
||||||
|
Loading…
Reference in New Issue
Block a user