Commit c5cb64ad authored by Christian Kandeler's avatar Christian Kandeler
Browse files

RemoteLinux: Use QTC_ASSERT instead of idiosyncratic macros.

Change-Id: I57393197d87d54c4b08f457e1dd50d0cbcfaa1f0
Reviewed-on: http://codereview.qt.nokia.com/1872

Reviewed-by: default avatarChristian Kandeler <christian.kandeler@nokia.com>
parent a6cc0641
......@@ -30,10 +30,11 @@
**************************************************************************/
#include "maemodebugsupport.h"
#include <remotelinux/linuxdeviceconfiguration.h>
#include "maemorunconfiguration.h"
#include "maemosshrunner.h"
#include <remotelinux/linuxdeviceconfiguration.h>
namespace RemoteLinux {
namespace Internal {
......
......@@ -37,10 +37,9 @@
#include "maemousedportsgatherer.h"
#include <qt4projectmanager/qt4buildconfiguration.h>
#include <utils/qtcassert.h>
#include <utils/ssh/sshconnection.h>
#define ASSERT_STATE(state) ASSERT_STATE_GENERIC(State, state, m_state)
using namespace Qt4ProjectManager;
using namespace Utils;
......@@ -74,7 +73,7 @@ void MaemoDeploymentMounter::setupMounts(const SshConnection::Ptr &connection,
const QList<MaemoMountSpecification> &mountSpecs,
const Qt4BuildConfiguration *bc)
{
ASSERT_STATE(Inactive);
QTC_ASSERT(m_state == Inactive, return);
m_mountSpecs = mountSpecs;
m_connection = connection;
......@@ -89,7 +88,7 @@ void MaemoDeploymentMounter::setupMounts(const SshConnection::Ptr &connection,
void MaemoDeploymentMounter::tearDownMounts()
{
ASSERT_STATE(Mounted);
QTC_ASSERT(m_state == Mounted, return);
setState(UnmountingCurrentMounts);
unmount();
......@@ -97,7 +96,8 @@ void MaemoDeploymentMounter::tearDownMounts()
void MaemoDeploymentMounter::setupMounter()
{
ASSERT_STATE(UnmountingOldDirs);
QTC_ASSERT(m_state == UnmountingOldDirs, return);
setState(UnmountingCurrentDirs);
m_mounter->resetMountSpecifications();
......@@ -109,8 +109,8 @@ void MaemoDeploymentMounter::setupMounter()
void MaemoDeploymentMounter::unmount()
{
ASSERT_STATE(QList<State>() << UnmountingOldDirs << UnmountingCurrentDirs
<< UnmountingCurrentMounts);
QTC_ASSERT(m_state == UnmountingOldDirs || m_state == UnmountingCurrentDirs
|| m_state == UnmountingCurrentMounts, return);
if (m_mounter->hasValidMountSpecifications())
m_mounter->unmount();
......@@ -120,7 +120,7 @@ void MaemoDeploymentMounter::unmount()
void MaemoDeploymentMounter::handleMounted()
{
ASSERT_STATE(QList<State>() << Mounting << Inactive);
QTC_ASSERT(m_state == Mounting || m_state == Inactive, return);
if (m_state == Inactive)
return;
......@@ -131,8 +131,8 @@ void MaemoDeploymentMounter::handleMounted()
void MaemoDeploymentMounter::handleUnmounted()
{
ASSERT_STATE(QList<State>() << UnmountingOldDirs << UnmountingCurrentDirs
<< UnmountingCurrentMounts << Inactive);
QTC_ASSERT(m_state == UnmountingOldDirs || m_state == UnmountingCurrentDirs
|| m_state == UnmountingCurrentMounts || m_state == Inactive, return);
switch (m_state) {
case UnmountingOldDirs:
......@@ -154,7 +154,8 @@ void MaemoDeploymentMounter::handleUnmounted()
void MaemoDeploymentMounter::handlePortsGathererError(const QString &errorMsg)
{
ASSERT_STATE(QList<State>() << GatheringPorts << Inactive);
QTC_ASSERT(m_state == GatheringPorts || m_state == Inactive, return);
if (m_state == Inactive)
return;
......@@ -165,7 +166,8 @@ void MaemoDeploymentMounter::handlePortsGathererError(const QString &errorMsg)
void MaemoDeploymentMounter::handlePortListReady()
{
ASSERT_STATE(QList<State>() << GatheringPorts << Inactive);
QTC_ASSERT(m_state == GatheringPorts || m_state == Inactive, return);
if (m_state == Inactive)
return;
......@@ -176,8 +178,10 @@ void MaemoDeploymentMounter::handlePortListReady()
void MaemoDeploymentMounter::handleMountError(const QString &errorMsg)
{
ASSERT_STATE(QList<State>() << UnmountingOldDirs << UnmountingCurrentDirs
<< UnmountingCurrentMounts << Mounting << Mounted << Inactive);
QTC_ASSERT(m_state == UnmountingOldDirs || m_state == UnmountingCurrentDirs
|| m_state == UnmountingCurrentMounts || m_state == Mounting || m_state == Mounted
|| m_state == Inactive, return);
if (m_state == Inactive)
return;
......
......@@ -46,9 +46,6 @@
#include <QtCore/QSharedPointer>
#include <QtCore/QCoreApplication>
#define ASSERT_STATE_GENERIC(State, expected, actual) \
MaemoGlobal::assertState<State>(expected, actual, Q_FUNC_INFO)
QT_BEGIN_NAMESPACE
class QProcess;
class QString;
......@@ -149,21 +146,6 @@ 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);
}
}
static bool isValidMaemoQtVersion(const QString &qmakePath, const QString &osType);
private:
static QString madAdminCommand(const QString &qmakePath);
......
......@@ -46,6 +46,7 @@
#include <qt4projectmanager/qt4buildconfiguration.h>
#include <qtsupport/baseqtversion.h>
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
......@@ -53,8 +54,6 @@
#include <QtCore/QStringList>
#include <QtGui/QIcon>
#define ASSERT_STATE(state) ASSERT_STATE_GENERIC(State, state, m_state)
using namespace Core;
using namespace Qt4ProjectManager;
using namespace Utils;
......@@ -85,7 +84,7 @@ MaemoPublisherFremantleFree::MaemoPublisherFremantleFree(const ProjectExplorer::
MaemoPublisherFremantleFree::~MaemoPublisherFremantleFree()
{
ASSERT_STATE(Inactive);
QTC_ASSERT(m_state == Inactive, return);
m_process->kill();
}
......@@ -291,8 +290,8 @@ void MaemoPublisherFremantleFree::handleProcessStdErr()
void MaemoPublisherFremantleFree::handleProcessFinished(bool failedToStart)
{
ASSERT_STATE(QList<State>() << RunningQmake << RunningMakeDistclean
<< BuildingPackage << Inactive);
QTC_ASSERT(m_state == RunningQmake || m_state == RunningMakeDistclean
|| m_state == BuildingPackage || m_state == Inactive, return);
switch (m_state) {
case RunningQmake:
......@@ -399,7 +398,7 @@ void MaemoPublisherFremantleFree::uploadPackage()
void MaemoPublisherFremantleFree::handleScpStarted()
{
ASSERT_STATE(QList<State>() << StartingScp << Inactive);
QTC_ASSERT(m_state == StartingScp || m_state == Inactive, return);
if (m_state == StartingScp)
prepareToSendFile();
......@@ -415,8 +414,8 @@ void MaemoPublisherFremantleFree::handleConnectionError()
void MaemoPublisherFremantleFree::handleUploadJobFinished(int exitStatus)
{
ASSERT_STATE(QList<State>() << PreparingToUploadFile << UploadingFile
<< Inactive);
QTC_ASSERT(m_state == PreparingToUploadFile || m_state == UploadingFile || m_state ==Inactive,
return);
if (m_state != Inactive && (exitStatus != SshRemoteProcess::ExitedNormally
|| m_uploader->process()->exitCode() != 0)) {
......@@ -484,8 +483,8 @@ void MaemoPublisherFremantleFree::sendFile()
void MaemoPublisherFremantleFree::handleScpStdOut(const QByteArray &output)
{
ASSERT_STATE(QList<State>() << PreparingToUploadFile << UploadingFile
<< Inactive);
QTC_ASSERT(m_state == PreparingToUploadFile || m_state == UploadingFile || m_state == Inactive,
return);
if (m_state == Inactive)
return;
......
......@@ -44,8 +44,6 @@
#include <QtCore/QTimer>
#define ASSERT_STATE(state) ASSERT_STATE_GENERIC(State, state, m_state)
using namespace Qt4ProjectManager;
using namespace Utils;
......@@ -68,14 +66,16 @@ MaemoRemoteMounter::~MaemoRemoteMounter()
void MaemoRemoteMounter::setConnection(const SshConnection::Ptr &connection,
const LinuxDeviceConfiguration::ConstPtr &devConf)
{
ASSERT_STATE(Inactive);
QTC_ASSERT(m_state == Inactive, return);
m_connection = connection;
m_devConf = devConf;
}
void MaemoRemoteMounter::setBuildConfiguration(const Qt4BuildConfiguration *bc)
{
ASSERT_STATE(Inactive);
QTC_ASSERT(m_state == Inactive, return);
const QtSupport::BaseQtVersion * const qtVersion = bc->qtVersion();
const AbstractQt4MaemoTarget * const maemoTarget
= qobject_cast<AbstractQt4MaemoTarget *>(bc->target());
......@@ -86,7 +86,7 @@ void MaemoRemoteMounter::setBuildConfiguration(const Qt4BuildConfiguration *bc)
void MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mountSpec,
bool mountAsRoot)
{
ASSERT_STATE(Inactive);
QTC_ASSERT(m_state == Inactive, return);
if (m_remoteMountsAllowed && mountSpec.isValid())
m_mountSpecs << MountInfo(mountSpec, mountAsRoot);
......@@ -100,7 +100,8 @@ bool MaemoRemoteMounter::hasValidMountSpecifications() const
void MaemoRemoteMounter::mount(PortList *freePorts,
const MaemoUsedPortsGatherer *portsGatherer)
{
ASSERT_STATE(Inactive);
QTC_ASSERT(m_state == Inactive, return);
Q_ASSERT(m_utfsServers.isEmpty());
Q_ASSERT(m_connection);
......@@ -117,7 +118,7 @@ void MaemoRemoteMounter::mount(PortList *freePorts,
void MaemoRemoteMounter::unmount()
{
ASSERT_STATE(Inactive);
QTC_ASSERT(m_state == Inactive, return);
if (m_mountSpecs.isEmpty()) {
emit reportProgress(tr("No directories to unmount"));
......@@ -145,7 +146,7 @@ void MaemoRemoteMounter::unmount()
void MaemoRemoteMounter::handleUnmountProcessFinished(int exitStatus)
{
ASSERT_STATE(QList<State>() << Unmounting << Inactive);
QTC_ASSERT(m_state == Unmounting || m_state == Inactive, return);
if (m_state == Inactive)
return;
......@@ -241,7 +242,8 @@ void MaemoRemoteMounter::startUtfsClients()
void MaemoRemoteMounter::handleUtfsClientsStarted()
{
ASSERT_STATE(QList<State>() << UtfsClientsStarting << Inactive);
QTC_ASSERT(m_state == UtfsClientsStarting || m_state == Inactive, return);
if (m_state == UtfsClientsStarting) {
setState(UtfsClientsStarted);
QTimer::singleShot(250, this, SLOT(startUtfsServers()));
......@@ -250,8 +252,8 @@ void MaemoRemoteMounter::handleUtfsClientsStarted()
void MaemoRemoteMounter::handleUtfsClientsFinished(int exitStatus)
{
ASSERT_STATE(QList<State>() << UtfsClientsStarting << UtfsClientsStarted
<< UtfsServersStarted << Inactive);
QTC_ASSERT(m_state == UtfsClientsStarting || m_state == UtfsClientsStarted
|| m_state == UtfsServersStarted || m_state == Inactive, return);
if (m_state == Inactive)
return;
......@@ -273,7 +275,7 @@ void MaemoRemoteMounter::handleUtfsClientsFinished(int exitStatus)
void MaemoRemoteMounter::startUtfsServers()
{
ASSERT_STATE(QList<State>() << UtfsClientsStarted << Inactive);
QTC_ASSERT(m_state == UtfsClientsStarted || m_state == Inactive, return);
if (m_state == Inactive)
return;
......@@ -378,7 +380,8 @@ void MaemoRemoteMounter::killUtfsServer(QProcess *proc)
void MaemoRemoteMounter::handleUtfsServerTimeout()
{
ASSERT_STATE(QList<State>() << UtfsServersStarted << Inactive);
QTC_ASSERT(m_state == UtfsServersStarted || m_state == Inactive, return);
if (m_state == Inactive)
return;
......
......@@ -31,17 +31,15 @@
#include "maemosshrunner.h"
#include "maemoglobal.h"
#include "maemoqemumanager.h"
#include "maemoremotemounter.h"
#include "maemoremotemountsmodel.h"
#include "remotelinuxrunconfiguration.h"
#include "maemorunconfiguration.h"
#include <qt4projectmanager/qt4buildconfiguration.h>
#include <remotelinux/linuxdeviceconfiguration.h>
#include <utils/qtcassert.h>
#define ASSERT_STATE(state) ASSERT_STATE_GENERIC(MountState, state, m_mountState)
using namespace Qt4ProjectManager;
using namespace Utils;
......@@ -93,12 +91,13 @@ bool MaemoSshRunner::canRun(QString &whyNot) const
void MaemoSshRunner::doDeviceSetup()
{
QTC_ASSERT(m_mountState == InactiveMountState, return);
handleDeviceSetupDone(true);
}
void MaemoSshRunner::doAdditionalInitialCleanup()
{
ASSERT_STATE(InactiveMountState);
QTC_ASSERT(m_mountState == InactiveMountState, return);
m_mounter->setConnection(connection(), devConfig());
m_mounter->resetMountSpecifications();
......@@ -115,14 +114,15 @@ void MaemoSshRunner::doAdditionalInitializations()
void MaemoSshRunner::doPostRunCleanup()
{
ASSERT_STATE(Mounted);
QTC_ASSERT(m_mountState == Mounted, return);
m_mountState = PostRunUnmounting;
unmount();
}
void MaemoSshRunner::handleUnmounted()
{
ASSERT_STATE(QList<MountState>() << InitialUnmounting << PostRunUnmounting);
QTC_ASSERT(m_mountState == InitialUnmounting || m_mountState == PostRunUnmounting, return);
switch (m_mountState) {
case InitialUnmounting:
......@@ -146,7 +146,7 @@ void MaemoSshRunner::doAdditionalConnectionErrorHandling()
void MaemoSshRunner::handleMounted()
{
ASSERT_STATE(Mounting);
QTC_ASSERT(m_mountState == Mounting, return);
if (m_mountState == Mounting) {
m_mountState = Mounted;
......@@ -156,7 +156,8 @@ void MaemoSshRunner::handleMounted()
void MaemoSshRunner::handleMounterError(const QString &errorMsg)
{
ASSERT_STATE(QList<MountState>() << InitialUnmounting << Mounting << PostRunUnmounting);
QTC_ASSERT(m_mountState == InitialUnmounting || m_mountState == Mounting
|| m_mountState == PostRunUnmounting, return);
const MountState oldMountState = m_mountState;
m_mountState = InactiveMountState;
......@@ -189,7 +190,8 @@ void MaemoSshRunner::mount()
void MaemoSshRunner::unmount()
{
ASSERT_STATE(QList<MountState>() << InitialUnmounting << PostRunUnmounting);
QTC_ASSERT(m_mountState == InitialUnmounting || m_mountState == PostRunUnmounting, return);
if (m_mounter->hasValidMountSpecifications()) {
QString message;
switch (m_mountState) {
......
......@@ -34,11 +34,11 @@
#include "remotelinuxapplicationrunner.h"
#include "maemomountspecification.h"
#include "maemorunconfiguration.h"
namespace RemoteLinux {
namespace Internal {
class MaemoRemoteMounter;
class MaemoRunConfiguration;
class MaemoSshRunner : public AbstractRemoteLinuxApplicationRunner
{
......
......@@ -31,7 +31,7 @@
#include "remotelinuxdebugsupport.h"
#include "maemoglobal.h"
#include "linuxdeviceconfiguration.h"
#include "maemousedportsgatherer.h"
#include "qt4maemotarget.h"
#include "remotelinuxapplicationrunner.h"
......@@ -40,8 +40,7 @@
#include <projectexplorer/abi.h>
#include <projectexplorer/project.h>
#include <projectexplorer/toolchain.h>
#define ASSERT_STATE(state) ASSERT_STATE_GENERIC(State, state, m_state)
#include <utils/qtcassert.h>
using namespace Utils;
using namespace Debugger;
......@@ -115,7 +114,7 @@ void AbstractRemoteLinuxDebugSupport::showMessage(const QString &msg, int channe
void AbstractRemoteLinuxDebugSupport::handleAdapterSetupRequested()
{
ASSERT_STATE(Inactive);
QTC_ASSERT(m_state == Inactive, return);
setState(StartingRunner);
showMessage(tr("Preparing remote side ...\n"), AppStuff);
......@@ -142,7 +141,7 @@ void AbstractRemoteLinuxDebugSupport::startExecution()
if (m_state == Inactive)
return;
ASSERT_STATE(StartingRunner);
QTC_ASSERT(m_state == StartingRunner, return);
if (m_debuggingType != RemoteLinuxRunConfiguration::DebugQmlOnly) {
if (!setPort(m_gdbServerPort))
......@@ -206,13 +205,15 @@ void AbstractRemoteLinuxDebugSupport::handleDebuggingFinished()
void AbstractRemoteLinuxDebugSupport::handleRemoteOutput(const QByteArray &output)
{
ASSERT_STATE(QList<State>() << Inactive << Debugging);
QTC_ASSERT(m_state == Inactive || m_state == Debugging, return);
showMessage(QString::fromUtf8(output), AppOutput);
}
void AbstractRemoteLinuxDebugSupport::handleRemoteErrorOutput(const QByteArray &output)
{
ASSERT_STATE(QList<State>() << Inactive << StartingRemoteProcess << Debugging);
QTC_ASSERT(m_state == Inactive || m_state == StartingRemoteProcess || m_state == Debugging,
return);
if (!m_engine)
return;
......@@ -248,7 +249,8 @@ void AbstractRemoteLinuxDebugSupport::handleAdapterSetupDone()
void AbstractRemoteLinuxDebugSupport::handleRemoteProcessStarted()
{
Q_ASSERT(m_debuggingType == RemoteLinuxRunConfiguration::DebugQmlOnly);
ASSERT_STATE(StartingRemoteProcess);
QTC_ASSERT(m_state == StartingRemoteProcess, return);
handleAdapterSetupDone();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment