Use std::shared_ptrfor AlbumCoverLoaderResult
Reduces memory fragmentation with Qt 6
This commit is contained in:
@@ -64,7 +64,7 @@ class AlbumCoverLoader : public QObject {
|
||||
|
||||
quint64 LoadImageAsync(const AlbumCoverLoaderOptions &options, const Song &song);
|
||||
quint64 LoadImageAsync(const AlbumCoverLoaderOptions &options, const QUrl &art_automatic, const QUrl &art_manual, const QUrl &song_url = QUrl(), const Song::Source song_source = Song::Source::Unknown);
|
||||
quint64 LoadImageAsync(const AlbumCoverLoaderOptions &options, const AlbumCoverImageResult &album_cover);
|
||||
quint64 LoadImageAsync(const AlbumCoverLoaderOptions &options, AlbumCoverImageResultPtr album_cover);
|
||||
quint64 LoadImageAsync(const AlbumCoverLoaderOptions &options, const QImage &image);
|
||||
|
||||
void CancelTask(const quint64 id);
|
||||
@@ -79,7 +79,7 @@ class AlbumCoverLoader : public QObject {
|
||||
|
||||
signals:
|
||||
void ExitFinished();
|
||||
void AlbumCoverLoaded(quint64 id, AlbumCoverLoaderResult result);
|
||||
void AlbumCoverLoaded(quint64 id, AlbumCoverLoaderResultPtr result);
|
||||
void SaveEmbeddedCoverAsyncFinished(quint64 id, bool success, bool cleared);
|
||||
|
||||
protected slots:
|
||||
@@ -105,18 +105,19 @@ class AlbumCoverLoader : public QObject {
|
||||
|
||||
quint64 id;
|
||||
Song song;
|
||||
AlbumCoverImageResult album_cover;
|
||||
AlbumCoverImageResultPtr album_cover;
|
||||
State state;
|
||||
AlbumCoverLoaderResult::Type type;
|
||||
bool art_updated;
|
||||
int redirects;
|
||||
};
|
||||
using TaskPtr = std::shared_ptr<Task>;
|
||||
|
||||
struct TryLoadResult {
|
||||
explicit TryLoadResult(const bool _started_async = false,
|
||||
const bool _loaded_success = false,
|
||||
const AlbumCoverLoaderResult::Type _type = AlbumCoverLoaderResult::Type::None,
|
||||
const AlbumCoverImageResult &_album_cover = AlbumCoverImageResult()) :
|
||||
AlbumCoverImageResultPtr _album_cover = AlbumCoverImageResultPtr()) :
|
||||
started_async(_started_async),
|
||||
loaded_success(_loaded_success),
|
||||
type(_type),
|
||||
@@ -126,20 +127,20 @@ class AlbumCoverLoader : public QObject {
|
||||
bool loaded_success;
|
||||
|
||||
AlbumCoverLoaderResult::Type type;
|
||||
AlbumCoverImageResult album_cover;
|
||||
AlbumCoverImageResultPtr album_cover;
|
||||
};
|
||||
|
||||
quint64 EnqueueTask(Task &task);
|
||||
void ProcessTask(Task *task);
|
||||
void NextState(Task *task);
|
||||
TryLoadResult TryLoadImage(Task *task);
|
||||
quint64 EnqueueTask(TaskPtr task);
|
||||
void ProcessTask(TaskPtr task);
|
||||
void NextState(TaskPtr task);
|
||||
TryLoadResult TryLoadImage(TaskPtr task);
|
||||
|
||||
bool stop_requested_;
|
||||
|
||||
QMutex mutex_load_image_async_;
|
||||
QMutex mutex_save_image_async_;
|
||||
QQueue<Task> tasks_;
|
||||
QHash<QNetworkReply*, Task> remote_tasks_;
|
||||
QQueue<TaskPtr> tasks_;
|
||||
QHash<QNetworkReply*, TaskPtr> remote_tasks_;
|
||||
quint64 load_image_async_id_;
|
||||
quint64 save_image_async_id_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user