Made the mutexes in the model classes "mutable" rather than "static".

This commit is contained in:
LoRd_MuldeR 2014-02-14 23:13:16 +01:00
parent 6982596882
commit ac9c8b3ce9
2 changed files with 45 additions and 40 deletions

View File

@ -31,7 +31,8 @@
inline TYPE get##NAME(void) const \ inline TYPE get##NAME(void) const \
{ \ { \
QMutexLocker lock(&m_mutex); \ QMutexLocker lock(&m_mutex); \
return m_##PREFIX##NAME; \ const TYPE value = m_##PREFIX##NAME; \
return value; \
} \ } \
inline void set##NAME(const TYPE PREFIX##NAME) \ inline void set##NAME(const TYPE PREFIX##NAME) \
{ \ { \
@ -71,7 +72,7 @@ public:
static void savePreferences(PreferencesModel *preferences); static void savePreferences(PreferencesModel *preferences);
protected: protected:
static QMutex m_mutex; mutable QMutex m_mutex;
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -25,59 +25,63 @@
#include <QMutexLocker> #include <QMutexLocker>
#include <QString> #include <QString>
#define SYSINFO_MAKE_FLAG(NAME) \ ///////////////////////////////////////////////////////////////////////////////
inline void set##NAME##Support(const bool &enable) \
{ \ #define SYSINFO_MAKE_FLAG(NAME, VALUE) \
QMutexLocker lock(&m_mutex); \ protected: \
if(enable) setFlag(FLAG_HAS_##NAME); else clrFlag(FLAG_HAS_##NAME); \ static const unsigned int FLAG_HAS_##NAME = VALUE; \
} \ public: \
inline bool has##NAME##Support(void) const \ inline void set##NAME##Support(const bool &enable) \
{ \ { \
QMutexLocker lock(&m_mutex); \ QMutexLocker lock(&m_mutex); \
return ((m_flags & (FLAG_HAS_##NAME)) == FLAG_HAS_##NAME); \ if(enable) setFlag(FLAG_HAS_##NAME); else clrFlag(FLAG_HAS_##NAME); \
} } \
inline bool has##NAME##Support(void) const \
{ \
QMutexLocker lock(&m_mutex); \
const bool enabeld = ((m_flags & (FLAG_HAS_##NAME)) == FLAG_HAS_##NAME); \
return enabeld; \
}
#define SYSINFO_MAKE_PATH(NAME) \ #define SYSINFO_MAKE_PATH(NAME) \
inline void set##NAME##Path(const QString &path) \ protected: \
{ \ QString m_path##NAME; \
QMutexLocker lock(&m_mutex); \ public: \
m_path##NAME = path; \ inline void set##NAME##Path(const QString &path) \
} \ { \
inline const QString & get##NAME##Path(void) const \ QMutexLocker lock(&m_mutex); \
{ \ m_path##NAME = path; \
QMutexLocker lock(&m_mutex); \ } \
return m_path##NAME; \ inline const QString get##NAME##Path(void) const \
} { \
QMutexLocker lock(&m_mutex); \
const QString path = m_path##NAME; \
return path; \
}
///////////////////////////////////////////////////////////////////////////////
class SysinfoModel class SysinfoModel
{ {
public: public:
SysinfoModel(void) { m_flags = 0; } SysinfoModel(void) { m_flags = 0; }
SYSINFO_MAKE_FLAG(X64) SYSINFO_MAKE_FLAG(X64, 0x00000001)
SYSINFO_MAKE_FLAG(MMX) SYSINFO_MAKE_FLAG(MMX, 0x00000002)
SYSINFO_MAKE_FLAG(SSE) SYSINFO_MAKE_FLAG(SSE, 0x00000004)
SYSINFO_MAKE_FLAG(AVS) SYSINFO_MAKE_FLAG(AVS, 0x00000008)
SYSINFO_MAKE_FLAG(VPS) SYSINFO_MAKE_FLAG(VPS, 0x00000010)
SYSINFO_MAKE_FLAG(256, 0x00000020)
SYSINFO_MAKE_PATH(VPS) SYSINFO_MAKE_PATH(VPS)
SYSINFO_MAKE_PATH(App) SYSINFO_MAKE_PATH(App)
protected: protected:
static const unsigned int FLAG_HAS_X64 = 0x00000001; inline void setFlag(const unsigned int &flag) { m_flags = (m_flags | flag); }
static const unsigned int FLAG_HAS_MMX = 0x00000002;
static const unsigned int FLAG_HAS_SSE = 0x00000004;
static const unsigned int FLAG_HAS_AVS = 0x00000008;
static const unsigned int FLAG_HAS_VPS = 0x00000010;
inline void setFlag(const unsigned int &flag) { m_flags = (m_flags | flag); }
inline void clrFlag(const unsigned int &flag) { m_flags = (m_flags & (~flag)); } inline void clrFlag(const unsigned int &flag) { m_flags = (m_flags & (~flag)); }
unsigned int m_flags; unsigned int m_flags;
mutable QMutex m_mutex;
QString m_pathApp;
QString m_pathVPS;
static QMutex m_mutex;
}; };
#undef SYSINFO_MAKE_FLAG #undef SYSINFO_MAKE_FLAG