Use std::shared_ptrfor AlbumCoverLoaderResult

Reduces memory fragmentation with Qt 6
This commit is contained in:
Jonas Kvinge
2023-04-06 23:18:10 +02:00
parent 962536bc83
commit b660287779
38 changed files with 363 additions and 294 deletions

View File

@@ -93,7 +93,7 @@ class EditTagDialog : public QDialog {
New
};
struct Data {
explicit Data(const Song &song = Song()) : original_(song), current_(song), cover_action_(UpdateCoverAction::None) {}
explicit Data(const Song &song = Song()) : original_(song), current_(song), cover_action_(UpdateCoverAction::None), cover_result_(std::make_shared<AlbumCoverImageResult>()) {}
static QVariant value(const Song &song, const QString &id);
QVariant original_value(const QString &id) const { return value(original_, id); }
@@ -104,7 +104,7 @@ class EditTagDialog : public QDialog {
Song original_;
Song current_;
UpdateCoverAction cover_action_;
AlbumCoverImageResult cover_result_;
AlbumCoverImageResultPtr cover_result_;
};
private slots:
@@ -120,7 +120,7 @@ class EditTagDialog : public QDialog {
void FetchTag();
void FetchTagSongChosen(const Song &original_song, const Song &new_metadata);
void AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderResult &result);
void AlbumCoverLoaded(const quint64 id, AlbumCoverLoaderResultPtr result);
void LoadCoverFromFile();
void SaveCoverToFile();
@@ -147,7 +147,7 @@ class EditTagDialog : public QDialog {
};
Song *GetFirstSelected();
void UpdateCover(const UpdateCoverAction action, const AlbumCoverImageResult &result = AlbumCoverImageResult());
void UpdateCover(const UpdateCoverAction action, AlbumCoverImageResultPtr result = AlbumCoverImageResultPtr());
bool DoesValueVary(const QModelIndexList &sel, const QString &id) const;
bool IsValueModified(const QModelIndexList &sel, const QString &id) const;