Use std::shared_ptrfor AlbumCoverLoaderResult
Reduces memory fragmentation with Qt 6
This commit is contained in:
@@ -22,21 +22,24 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
#include <QImage>
|
||||
|
||||
struct AlbumCoverImageResult {
|
||||
class AlbumCoverImageResult {
|
||||
public:
|
||||
explicit AlbumCoverImageResult(const QUrl &_cover_url = QUrl(),
|
||||
const QString &_mime_type = QString(),
|
||||
const QByteArray &_image_data = QByteArray(),
|
||||
const QImage &_image = QImage()) :
|
||||
cover_url(_cover_url),
|
||||
mime_type(_mime_type),
|
||||
image_data(_image_data), image(_image) {}
|
||||
|
||||
const QImage &_image = QImage())
|
||||
: cover_url(_cover_url),
|
||||
mime_type(_mime_type),
|
||||
image_data(_image_data),
|
||||
image(_image) {}
|
||||
explicit AlbumCoverImageResult(const QImage &_image) : image(_image) {}
|
||||
|
||||
QUrl cover_url;
|
||||
@@ -48,6 +51,10 @@ struct AlbumCoverImageResult {
|
||||
bool is_jpeg() const { return mime_type == "image/jpeg" && !image_data.isEmpty(); }
|
||||
|
||||
};
|
||||
|
||||
using AlbumCoverImageResultPtr = std::shared_ptr<AlbumCoverImageResult>;
|
||||
|
||||
Q_DECLARE_METATYPE(AlbumCoverImageResult)
|
||||
Q_DECLARE_METATYPE(AlbumCoverImageResultPtr)
|
||||
|
||||
#endif // ALBUMCOVERIMAGERESULT_H
|
||||
|
||||
Reference in New Issue
Block a user