forked from qt-creator/qt-creator
Maemo: Introduce generic state checking.
This commit is contained in:
@@ -38,6 +38,9 @@
|
|||||||
|
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
|
|
||||||
|
#define ASSERT_STATE_GENERIC(State, expected, actual) \
|
||||||
|
MaemoGlobal::assertState<State>(expected, actual, Q_FUNC_INFO)
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QString;
|
class QString;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
@@ -67,6 +70,21 @@ public:
|
|||||||
}
|
}
|
||||||
return 0;
|
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
|
} // namespace Internal
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
#include <QtCore/QTimer>
|
#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;
|
using namespace Core;
|
||||||
|
|
||||||
@@ -442,18 +442,6 @@ void MaemoRemoteMounter::handleUtfsServerTimeout()
|
|||||||
setState(Inactive);
|
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)
|
void MaemoRemoteMounter::setState(State newState)
|
||||||
{
|
{
|
||||||
if (newState == Inactive)
|
if (newState == Inactive)
|
||||||
|
|||||||
@@ -101,8 +101,6 @@ private:
|
|||||||
UtfsClientsStarting, UtfsClientsStarted, UtfsServersStarted
|
UtfsClientsStarting, UtfsClientsStarted, UtfsServersStarted
|
||||||
};
|
};
|
||||||
|
|
||||||
void assertState(State expectedState, const char *func);
|
|
||||||
void assertState(const QList<State> &expectedStates, const char *func);
|
|
||||||
void setState(State newState);
|
void setState(State newState);
|
||||||
|
|
||||||
void deployUtfsClient();
|
void deployUtfsClient();
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
#include <limits>
|
#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;
|
using namespace Core;
|
||||||
|
|
||||||
@@ -309,18 +309,6 @@ bool MaemoSshRunner::isConnectionUsable() const
|
|||||||
&& m_connection->connectionParameters() == m_devConfig.server;
|
&& 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)
|
void MaemoSshRunner::setState(State newState)
|
||||||
{
|
{
|
||||||
if (newState == Inactive) {
|
if (newState == Inactive) {
|
||||||
|
|||||||
@@ -94,8 +94,6 @@ private:
|
|||||||
ProcessStarting, StopRequested
|
ProcessStarting, StopRequested
|
||||||
};
|
};
|
||||||
|
|
||||||
void assertState(State expectedState, const char *func);
|
|
||||||
void assertState(const QList<State> &expectedStates, const char *func);
|
|
||||||
void setState(State newState);
|
void setState(State newState);
|
||||||
void emitError(const QString &errorMsg);
|
void emitError(const QString &errorMsg);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user