diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoglobal.h b/src/plugins/qt4projectmanager/qt-maemo/maemoglobal.h index 7305dd342869ec7a8d215722076acae85568f6cd..d6ed5f24b85bde12f9b67978ad2d2b223a7b43e9 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoglobal.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoglobal.h @@ -38,6 +38,9 @@ #include <QtCore/QList> +#define ASSERT_STATE_GENERIC(State, expected, actual) \ + MaemoGlobal::assertState<State>(expected, actual, Q_FUNC_INFO) + QT_BEGIN_NAMESPACE class QString; QT_END_NAMESPACE @@ -67,6 +70,21 @@ public: } return 0; } + + template<typename State> static void assertState(State expected, + State actual, const char *func) + { + assertState(QList<State>() << expected, actual, func); + } + + template<typename State> static void assertState(const QList<State> &expected, + State actual, const char *func) + { + if (!expected.contains(actual)) { + qWarning("Warning: Unexpected state %d in function %s.", + actual, func); + } + } }; } // namespace Internal diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp index 8431fea3ca1ac521c19787f3ef9afeb9d860ae09..5c4189ff80918d0c24b6c9a671c8805bf368d317 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp @@ -39,7 +39,7 @@ #include <QtCore/QTimer> -#define ASSERT_STATE(state) assertState(state, Q_FUNC_INFO) +#define ASSERT_STATE(state) ASSERT_STATE_GENERIC(State, state, m_state) using namespace Core; @@ -442,18 +442,6 @@ void MaemoRemoteMounter::handleUtfsServerTimeout() setState(Inactive); } -void MaemoRemoteMounter::assertState(State expectedState, const char *func) -{ - assertState(QList<State>() << expectedState, func); -} - -void MaemoRemoteMounter::assertState(const QList<State> &expectedStates, - const char *func) -{ - QTC_ASSERT(expectedStates.contains(m_state), - qDebug("Unexpected state %d at %s.", m_state, func)) -} - void MaemoRemoteMounter::setState(State newState) { if (newState == Inactive) diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.h b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.h index 8e297be80dff983e3c7011cb894a25f0a2951187..ddd70a67ae1d733d6d8e4de0d3cb26d22d09a63c 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.h @@ -101,8 +101,6 @@ private: UtfsClientsStarting, UtfsClientsStarted, UtfsServersStarted }; - void assertState(State expectedState, const char *func); - void assertState(const QList<State> &expectedStates, const char *func); void setState(State newState); void deployUtfsClient(); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp index 16db4f4386977cb5f78b4a880c591a21466ce9ae..f431c65c5a6281dc8e71f1aa507ff83458bc8446 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp @@ -48,7 +48,7 @@ #include <limits> -#define ASSERT_STATE(state) assertState(state, Q_FUNC_INFO) +#define ASSERT_STATE(state) ASSERT_STATE_GENERIC(State, state, m_state) using namespace Core; @@ -309,18 +309,6 @@ bool MaemoSshRunner::isConnectionUsable() const && m_connection->connectionParameters() == m_devConfig.server; } -void MaemoSshRunner::assertState(State expectedState, const char *func) -{ - assertState(QList<State>() << expectedState, func); -} - -void MaemoSshRunner::assertState(const QList<State> &expectedStates, - const char *func) -{ - if (!expectedStates.contains(m_state)) - qWarning("Unexpected state %d at %s.", m_state, func); -} - void MaemoSshRunner::setState(State newState) { if (newState == Inactive) { diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h index 2c756a2382b2b8db4e1d862de1e9a3cda17e7b24..b79b0ca2a2e40a5e971bb7f37947c11884555146 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h @@ -94,8 +94,6 @@ private: ProcessStarting, StopRequested }; - void assertState(State expectedState, const char *func); - void assertState(const QList<State> &expectedStates, const char *func); void setState(State newState); void emitError(const QString &errorMsg);