diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-02-24 21:16:12 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-03-24 22:28:23 +0100 |
commit | a5690fa2a4cce2698225f1f558183f6fe306d860 (patch) | |
tree | 822d4e237412afd38008de04d9be11fd0718f101 /src | |
parent | 054246ebffcdd20da72a8e464b40eaf64d484743 (diff) | |
download | mana-a5690fa2a4cce2698225f1f558183f6fe306d860.tar.gz mana-a5690fa2a4cce2698225f1f558183f6fe306d860.tar.bz2 mana-a5690fa2a4cce2698225f1f558183f6fe306d860.tar.xz mana-a5690fa2a4cce2698225f1f558183f6fe306d860.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/cpp0x_compat/cstdint | 7 | ||||
-rw-r--r-- | src/gui/serverdialog.cpp | 4 | ||||
-rw-r--r-- | src/gui/serverdialog.h | 2 | ||||
-rw-r--r-- | src/utils/mutex.h | 5 |
5 files changed, 20 insertions, 4 deletions
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) |