From 8da0980aefd199c4c3fae0216c77ba11c7352acf Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 18 Jan 2024 17:13:04 -0800 Subject: [PATCH] QMimeBinaryProvider: move CacheFile up in the file Amends 329722a322a80d5ea8d6f9aa993c2fc4995b08a4 ("QMimeBinaryProvider: manage m_cacheFile with a std::unique_ptr"), which added the std::unique_ptr. This is required because in C++23 std::unique_ptr's destructor became constexpr and is therefore instantiated more eagerly. The type must be fully defined (not forward-declared) when the std::unique_ptr member is initialised in the QMimeBinaryProvider constructors. Fixes: QTBUG-121204 Change-Id: I76ffba14ece04f24b43efffd17ab9a861aff89b8 Reviewed-by: Ahmad Samir (cherry picked from commit c8db469fd584cfd2bee34b572601b19bfb2cd921) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 7d12cf673a221cec92f080e3364cc939ab3dd34a) --- src/corelib/mimetypes/qmimeprovider.cpp | 54 ++++++++++++------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp index 1d92d759f92..cbc18e5a736 100644 --- a/src/corelib/mimetypes/qmimeprovider.cpp +++ b/src/corelib/mimetypes/qmimeprovider.cpp @@ -51,6 +51,33 @@ QT_BEGIN_NAMESPACE using namespace Qt::StringLiterals; +struct QMimeBinaryProvider::CacheFile +{ + CacheFile(const QString &fileName); + ~CacheFile(); + + bool isValid() const { return m_valid; } + inline quint16 getUint16(int offset) const + { + return qFromBigEndian(*reinterpret_cast(data + offset)); + } + inline quint32 getUint32(int offset) const + { + return qFromBigEndian(*reinterpret_cast(data + offset)); + } + inline const char *getCharStar(int offset) const + { + return reinterpret_cast(data + offset); + } + bool load(); + bool reload(); + + QFile file; + uchar *data; + QDateTime m_mtime; + bool m_valid; +}; + static inline void appendIfNew(QStringList &list, const QString &str) { if (!list.contains(str)) @@ -88,33 +115,6 @@ QMimeBinaryProvider::QMimeBinaryProvider(QMimeDatabasePrivate *db, const QString ensureLoaded(); } -struct QMimeBinaryProvider::CacheFile -{ - CacheFile(const QString &fileName); - ~CacheFile(); - - bool isValid() const { return m_valid; } - inline quint16 getUint16(int offset) const - { - return qFromBigEndian(*reinterpret_cast(data + offset)); - } - inline quint32 getUint32(int offset) const - { - return qFromBigEndian(*reinterpret_cast(data + offset)); - } - inline const char *getCharStar(int offset) const - { - return reinterpret_cast(data + offset); - } - bool load(); - bool reload(); - - QFile file; - uchar *data; - QDateTime m_mtime; - bool m_valid; -}; - QMimeBinaryProvider::CacheFile::CacheFile(const QString &fileName) : file(fileName), m_valid(false) {