mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 04:54:18 +00:00
Merge pull request #6108 from evsh/fix-6103
Workaround problem with moc from Qt4 and #if. Closes #6103, #5451
This commit is contained in:
commit
e230cde6c4
@ -92,9 +92,11 @@ void TorrentFileGuard::setAutoDeleteMode(TorrentFileGuard::AutoDeleteMode mode)
|
|||||||
|
|
||||||
QMetaEnum TorrentFileGuard::modeMetaEnum()
|
QMetaEnum TorrentFileGuard::modeMetaEnum()
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
|
||||||
return QMetaEnum::fromType<AutoDeleteMode>();
|
return QMetaEnum::fromType<AutoDeleteMode>();
|
||||||
#else
|
#else
|
||||||
return staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("AutoDeleteMode"));
|
const int enumeratorIndex = staticMetaObject.indexOfEnumerator("AutoDeleteMode");
|
||||||
|
Q_ASSERT(enumeratorIndex >= 0);
|
||||||
|
return staticMetaObject.enumerator(enumeratorIndex);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
* exception statement from your version.
|
* exception statement from your version.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef TOFFENTFILEGURAD_H
|
||||||
|
#define TOFFENTFILEGURAD_H
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
|
|
||||||
@ -50,6 +53,10 @@ private:
|
|||||||
class TorrentFileGuard
|
class TorrentFileGuard
|
||||||
{
|
{
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
|
// moc from Qt4 ignores Q_ENUMS when it is behind #if QT_VERSION check
|
||||||
|
// this declaration is needed for Qt 4 only
|
||||||
|
// TODO Qt5: remove when dropping Qt4 support
|
||||||
|
Q_ENUMS(AutoDeleteMode)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TorrentFileGuard(const QString &path = QString());
|
TorrentFileGuard(const QString &path = QString());
|
||||||
@ -72,9 +79,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static QMetaEnum modeMetaEnum();
|
static QMetaEnum modeMetaEnum();
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
|
||||||
Q_ENUMS(AutoDeleteMode)
|
|
||||||
#else
|
|
||||||
Q_ENUM(AutoDeleteMode)
|
Q_ENUM(AutoDeleteMode)
|
||||||
#endif
|
#endif
|
||||||
AutoDeleteMode m_mode;
|
AutoDeleteMode m_mode;
|
||||||
@ -87,9 +92,12 @@ private:
|
|||||||
// This problem is NOT present in Qt 5.7.0 and maybe in some older Qt 5 versions too
|
// This problem is NOT present in Qt 5.7.0 and maybe in some older Qt 5 versions too
|
||||||
// Qt 4.8.7 has it.
|
// Qt 4.8.7 has it.
|
||||||
// Therefore, we can't inherit FileGuard :(
|
// Therefore, we can't inherit FileGuard :(
|
||||||
|
// TODO Qt5: port to private inheritance when dropping Qt 4 support
|
||||||
FileGuard m_guard;
|
FileGuard m_guard;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
Q_DECLARE_METATYPE(TorrentFileGuard::AutoDeleteMode)
|
Q_DECLARE_METATYPE(TorrentFileGuard::AutoDeleteMode)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // TOFFENTFILEGURAD_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user