Commit aa2ea094 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Maemo: Create file watchers on demand.



As QFileSystemWatcher cause some shutdown time.
Rubber-stamped-by: default avatarChristian Kandeler <christian.kandeler@nokia.com>
parent b7bb522d
...@@ -79,6 +79,8 @@ MaemoQemuManager::MaemoQemuManager(QObject *parent) ...@@ -79,6 +79,8 @@ MaemoQemuManager::MaemoQemuManager(QObject *parent)
, m_qemuProcess(new QProcess(this)) , m_qemuProcess(new QProcess(this))
, m_runningQtId(INT_MIN) , m_runningQtId(INT_MIN)
, m_userTerminated(false) , m_userTerminated(false)
, m_runtimeRootWatcher(0)
, m_runtimeFolderWatcher(0)
{ {
m_qemuStarterIcon.addFile(":/qt-maemo/images/qemu-run.png", iconSize); m_qemuStarterIcon.addFile(":/qt-maemo/images/qemu-run.png", iconSize);
m_qemuStarterIcon.addFile(":/qt-maemo/images/qemu-stop.png", iconSize, m_qemuStarterIcon.addFile(":/qt-maemo/images/qemu-stop.png", iconSize,
...@@ -124,13 +126,26 @@ MaemoQemuManager::MaemoQemuManager(QObject *parent) ...@@ -124,13 +126,26 @@ MaemoQemuManager::MaemoQemuManager(QObject *parent)
SLOT(qemuOutput())); SLOT(qemuOutput()));
connect(this, SIGNAL(qemuProcessStatus(QemuStatus, QString)), connect(this, SIGNAL(qemuProcessStatus(QemuStatus, QString)),
this, SLOT(qemuStatusChanged(QemuStatus, QString))); this, SLOT(qemuStatusChanged(QemuStatus, QString)));
}
m_runtimeRootWatcher = new QFileSystemWatcher(this); QFileSystemWatcher *MaemoQemuManager::runtimeRootWatcher()
connect(m_runtimeRootWatcher, SIGNAL(directoryChanged(QString)), this, {
SLOT(runtimeRootChanged(QString))); if (!m_runtimeRootWatcher) {
m_runtimeFolderWatcher = new QFileSystemWatcher(this); m_runtimeRootWatcher = new QFileSystemWatcher(this);
connect(m_runtimeFolderWatcher, SIGNAL(directoryChanged(QString)), this, connect(m_runtimeRootWatcher, SIGNAL(directoryChanged(QString)), this,
SLOT(runtimeFolderChanged(QString))); SLOT(runtimeRootChanged(QString)));
}
return m_runtimeRootWatcher;
}
QFileSystemWatcher *MaemoQemuManager::runtimeFolderWatcher()
{
if (!m_runtimeFolderWatcher) {
m_runtimeFolderWatcher = new QFileSystemWatcher(this);
connect(m_runtimeFolderWatcher, SIGNAL(directoryChanged(QString)), this,
SLOT(runtimeFolderChanged(QString)));
}
return m_runtimeFolderWatcher;
} }
MaemoQemuManager::~MaemoQemuManager() MaemoQemuManager::~MaemoQemuManager()
...@@ -170,8 +185,8 @@ void MaemoQemuManager::qtVersionsChanged(const QList<int> &uniqueIds) ...@@ -170,8 +185,8 @@ void MaemoQemuManager::qtVersionsChanged(const QList<int> &uniqueIds)
= MaemoQemuRuntimeParser::parseRuntime(version); = MaemoQemuRuntimeParser::parseRuntime(version);
if (runtime.isValid()) { if (runtime.isValid()) {
m_runtimes.insert(uniqueId, runtime); m_runtimes.insert(uniqueId, runtime);
if (!m_runtimeRootWatcher->directories().contains(runtime.m_watchPath)) if (!runtimeRootWatcher()->directories().contains(runtime.m_watchPath))
m_runtimeRootWatcher->addPath(runtime.m_watchPath); runtimeRootWatcher()->addPath(runtime.m_watchPath);
} else { } else {
m_runtimes.remove(uniqueId); m_runtimes.remove(uniqueId);
} }
...@@ -462,7 +477,7 @@ void MaemoQemuManager::runtimeRootChanged(const QString &directory) ...@@ -462,7 +477,7 @@ void MaemoQemuManager::runtimeRootChanged(const QString &directory)
if (!QFile::exists(runtime.m_root + QLatin1String("/information"))) { if (!QFile::exists(runtime.m_root + QLatin1String("/information"))) {
// install might be still in progress // install might be still in progress
uniqueIds.removeAll(uniqueId); uniqueIds.removeAll(uniqueId);
m_runtimeFolderWatcher->addPath(runtime.m_root); runtimeFolderWatcher()->addPath(runtime.m_root);
} }
} }
} }
...@@ -480,7 +495,8 @@ void MaemoQemuManager::runtimeFolderChanged(const QString &directory) ...@@ -480,7 +495,8 @@ void MaemoQemuManager::runtimeFolderChanged(const QString &directory)
uniqueIds.append(it.key()); uniqueIds.append(it.key());
} }
notify(uniqueIds); notify(uniqueIds);
m_runtimeFolderWatcher->removePath(directory); if (m_runtimeFolderWatcher)
m_runtimeFolderWatcher->removePath(directory);
} }
} }
......
...@@ -123,6 +123,8 @@ private: ...@@ -123,6 +123,8 @@ private:
private: private:
QAction *m_qemuAction; QAction *m_qemuAction;
QProcess *m_qemuProcess; QProcess *m_qemuProcess;
QFileSystemWatcher *runtimeRootWatcher();
QFileSystemWatcher *runtimeFolderWatcher();
int m_runningQtId; int m_runningQtId;
bool m_userTerminated; bool m_userTerminated;
......
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