From a5690fa2a4cce2698225f1f558183f6fe306d860 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Fri, 24 Feb 2012 21:16:12 +0100 Subject: Introduced compile-time option to disable use of C++0x This is in order to still support older compilers, in particular GCC 4.2.1, so that Mana may be compiled for Maemo 5. Reviewed-by: Yohann Ferreira --- src/CMakeLists.txt | 6 +++++- src/cpp0x_compat/cstdint | 7 +++++++ src/gui/serverdialog.cpp | 4 ++-- src/gui/serverdialog.h | 2 +- src/utils/mutex.h | 5 +++++ 5 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 src/cpp0x_compat/cstdint (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 977524e9..e0a42478 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,7 +34,11 @@ ENDIF() SET(FLAGS "-DPACKAGE_VERSION=\\\"${VERSION}\\\"") SET(FLAGS "${FLAGS} -DPKG_DATADIR=\\\"${PKG_DATADIR}/\\\"") SET(FLAGS "${FLAGS} -DLOCALEDIR=\\\"${LOCALEDIR}/\\\"") -SET(FLAGS "${FLAGS} -std=c++0x") +IF (ENABLE_CPP0X) + SET(FLAGS "${FLAGS} -std=c++0x -DENABLE_CPP0X=1") +ELSE() + INCLUDE_DIRECTORIES("cpp0x_compat") +ENDIF() IF (ENABLE_NLS) SET(FLAGS "${FLAGS} -DENABLE_NLS=1") diff --git a/src/cpp0x_compat/cstdint b/src/cpp0x_compat/cstdint new file mode 100644 index 00000000..d8d71d9d --- /dev/null +++ b/src/cpp0x_compat/cstdint @@ -0,0 +1,7 @@ +/* + * Compatibility header used when the compiler doesn't support C++0x. + * + * It doesn't seem necessary for it to contain anything, at least GCC 4.2.1 + * compiles Mana fine so it apparently understands types like uint16_t by + * default. + */ diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index f9fcb597..49de7f38 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -90,13 +90,13 @@ ServersListModel::ServersListModel(ServerInfos *servers, ServerDialog *parent): int ServersListModel::getNumberOfElements() { - MutexLocker lock = mParent->lock(); + MutexLocker lock(mParent->getMutex()); return mServers->size(); } std::string ServersListModel::getElementAt(int elementIndex) { - MutexLocker lock = mParent->lock(); + MutexLocker lock(mParent->getMutex()); const ServerInfo &server = mServers->at(elementIndex); std::string myServer; myServer += server.hostname; diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h index eedf5134..cf9e62e7 100644 --- a/src/gui/serverdialog.h +++ b/src/gui/serverdialog.h @@ -113,7 +113,7 @@ class ServerDialog : public Window, protected: friend class ServersListModel; - MutexLocker lock() { return MutexLocker(&mMutex); } + Mutex *getMutex() { return &mMutex; } friend class CustomServerDialog; /** diff --git a/src/utils/mutex.h b/src/utils/mutex.h index 26ad754e..f7f26233 100644 --- a/src/utils/mutex.h +++ b/src/utils/mutex.h @@ -53,7 +53,9 @@ class MutexLocker { public: MutexLocker(Mutex *mutex); +#ifdef ENABLE_CPP0X MutexLocker(MutexLocker&&); +#endif ~MutexLocker(); private: @@ -93,11 +95,14 @@ inline MutexLocker::MutexLocker(Mutex *mutex): mMutex->lock(); } +#ifdef ENABLE_CPP0X inline MutexLocker::MutexLocker(MutexLocker&& rhs): mMutex(rhs.mMutex) { rhs.mMutex = NULL; } +#endif + inline MutexLocker::~MutexLocker() { if (mMutex) -- cgit v1.2.3-60-g2f50