LocalProcessList: Disable the Qt Creator process (Regression).

Prevent the user from shooting themselves in the foot.

Change-Id: I67344b02fea5c19aa7f3db5b1c2c611c58e8bbf8
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Friedemann Kleint
2012-08-22 14:59:54 +02:00
committed by hjk
parent f5ce3a7f25
commit 25776a3a69
2 changed files with 17 additions and 5 deletions

View File

@@ -40,6 +40,7 @@
#include <signal.h> #include <signal.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#endif #endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
@@ -92,6 +93,7 @@ static QString imageName(DWORD processId)
LocalProcessList::LocalProcessList(const IDevice::ConstPtr &device, QObject *parent) LocalProcessList::LocalProcessList(const IDevice::ConstPtr &device, QObject *parent)
: DeviceProcessList(device, parent) : DeviceProcessList(device, parent)
, m_myPid(GetCurrentProcessId())
{ {
} }
@@ -135,6 +137,7 @@ void LocalProcessList::doKillProcess(const DeviceProcess &process)
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
LocalProcessList::LocalProcessList(const IDevice::ConstPtr &device, QObject *parent) LocalProcessList::LocalProcessList(const IDevice::ConstPtr &device, QObject *parent)
: DeviceProcessList(device, parent) : DeviceProcessList(device, parent)
, m_myPid(getpid())
{} {}
static bool isUnixProcessId(const QString &procname) static bool isUnixProcessId(const QString &procname)
@@ -241,5 +244,13 @@ void LocalProcessList::reportDelayedKillStatus()
} }
#endif // QT_OS_UNIX #endif // QT_OS_UNIX
Qt::ItemFlags LocalProcessList::flags(const QModelIndex &index) const
{
Qt::ItemFlags flags = DeviceProcessList::flags(index);
if (index.isValid() && at(index.row()).pid == m_myPid)
flags &= ~(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
return flags;
}
} // namespace Internal } // namespace Internal
} // namespace RemoteLinux } // namespace RemoteLinux

View File

@@ -47,23 +47,24 @@ class LocalProcessList : public DeviceProcessList
public: public:
LocalProcessList(const IDevice::ConstPtr &device, QObject *parent = 0); LocalProcessList(const IDevice::ConstPtr &device, QObject *parent = 0);
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
private: private:
void doUpdate(); void doUpdate();
void doKillProcess(const DeviceProcess &process); void doKillProcess(const DeviceProcess &process);
#ifdef Q_OS_WIN
private slots: private slots:
#if defined(Q_OS_WIN)
void handleWindowsUpdate(); void handleWindowsUpdate();
#endif #elif defined(Q_OS_UNIX)
#ifdef Q_OS_UNIX
private slots:
void reportDelayedKillStatus(); void reportDelayedKillStatus();
void updateUsingProc(); void updateUsingProc();
void updateUsingPs(); void updateUsingPs();
#endif
private: private:
const qint64 m_myPid;
#ifdef Q_OS_UNIX
QString m_error; QString m_error;
#endif #endif
}; };