100 lines
3.5 KiB
Diff
100 lines
3.5 KiB
Diff
|
commit 42d40d1d351588a71bef0af1d62a8f6dc586f141
|
||
|
Author: Mario Bensi <mbensi@ipsquad.net>
|
||
|
Date: Mon Jan 31 10:28:51 2011 +0100
|
||
|
|
||
|
Fix crash during the QFileSystemWatcher destruction
|
||
|
|
||
|
The QFileSystemWatcher doesn't work correctly in a singleton
|
||
|
The solution so far was to destroy the QFileSystemWatcher when the
|
||
|
application quits but we have some crash with this solution.
|
||
|
For the moment to workaround the problem, we detach the
|
||
|
QFileSystemWatcher from the parent effectively leaking it on purpose.
|
||
|
|
||
|
diff --git a/solid/solid/backends/fstab/fstabwatcher.cpp b/solid/solid/backends/fstab/fstabwatcher.cpp
|
||
|
index 1d763fa..45282fa 100644
|
||
|
--- a/solid/solid/backends/fstab/fstabwatcher.cpp
|
||
|
+++ b/solid/solid/backends/fstab/fstabwatcher.cpp
|
||
|
@@ -40,6 +40,9 @@ FstabWatcher::FstabWatcher()
|
||
|
: m_isRoutineInstalled(false)
|
||
|
, m_fileSystemWatcher(new QFileSystemWatcher(this))
|
||
|
{
|
||
|
+ if (qApp) {
|
||
|
+ connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(orphanFileSystemWatcher()));
|
||
|
+ }
|
||
|
m_fileSystemWatcher->addPath(MTAB);
|
||
|
m_fileSystemWatcher->addPath(FSTAB);
|
||
|
connect(m_fileSystemWatcher, SIGNAL(fileChanged(QString)), this, SLOT(onFileChanged(QString)));
|
||
|
@@ -47,11 +50,23 @@ FstabWatcher::FstabWatcher()
|
||
|
|
||
|
FstabWatcher::~FstabWatcher()
|
||
|
{
|
||
|
- qRemovePostRoutine(globalFstabWatcher.destroy);
|
||
|
+ // The QFileSystemWatcher doesn't work correctly in a singleton
|
||
|
+ // The solution so far was to destroy the QFileSystemWatcher when the application quits
|
||
|
+ // But we have some crash with this solution.
|
||
|
+ // For the moment to workaround the problem, we detach the QFileSystemWatcher from the parent
|
||
|
+ // effectively leaking it on purpose.
|
||
|
+
|
||
|
+ //qRemovePostRoutine(globalFstabWatcher.destroy);
|
||
|
+}
|
||
|
+
|
||
|
+void FstabWatcher::orphanFileSystemWatcher()
|
||
|
+{
|
||
|
+ m_fileSystemWatcher->setParent(0);
|
||
|
}
|
||
|
|
||
|
FstabWatcher *FstabWatcher::instance()
|
||
|
{
|
||
|
+#if 0
|
||
|
FstabWatcher *fstabWatcher = globalFstabWatcher;
|
||
|
|
||
|
if (fstabWatcher && !fstabWatcher->m_isRoutineInstalled) {
|
||
|
@@ -59,6 +74,9 @@ FstabWatcher *FstabWatcher::instance()
|
||
|
fstabWatcher->m_isRoutineInstalled = true;
|
||
|
}
|
||
|
return fstabWatcher;
|
||
|
+#else
|
||
|
+ return globalFstabWatcher;
|
||
|
+#endif
|
||
|
}
|
||
|
|
||
|
|
||
|
diff --git a/solid/solid/backends/fstab/fstabwatcher.h b/solid/solid/backends/fstab/fstabwatcher.h
|
||
|
index 1992c91..2ca6511 100644
|
||
|
--- a/solid/solid/backends/fstab/fstabwatcher.h
|
||
|
+++ b/solid/solid/backends/fstab/fstabwatcher.h
|
||
|
@@ -46,6 +46,7 @@ namespace Fstab
|
||
|
|
||
|
private Q_SLOTS:
|
||
|
void onFileChanged(const QString &path);
|
||
|
+ void orphanFileSystemWatcher();
|
||
|
|
||
|
private:
|
||
|
bool m_isRoutineInstalled;
|
||
|
commit 350a5d8de016b6daa36c6e29d5d5f83ad6c2b38d
|
||
|
Author: Mario Bensi <mbensi@ipsquad.net>
|
||
|
Date: Tue Feb 1 11:11:58 2011 +0100
|
||
|
|
||
|
Fix solid test
|
||
|
|
||
|
I need to detach parent on QFileSystemWatcher when the FstabWatcher
|
||
|
destructor are called if the aboutToQuit is not called. It's the case in
|
||
|
test.
|
||
|
|
||
|
diff --git a/solid/solid/backends/fstab/fstabwatcher.cpp b/solid/solid/backends/fstab/fstabwatcher.cpp
|
||
|
index 45282fa..449d5ce 100644
|
||
|
--- a/solid/solid/backends/fstab/fstabwatcher.cpp
|
||
|
+++ b/solid/solid/backends/fstab/fstabwatcher.cpp
|
||
|
@@ -56,7 +56,11 @@ FstabWatcher::~FstabWatcher()
|
||
|
// For the moment to workaround the problem, we detach the QFileSystemWatcher from the parent
|
||
|
// effectively leaking it on purpose.
|
||
|
|
||
|
+#if 0
|
||
|
//qRemovePostRoutine(globalFstabWatcher.destroy);
|
||
|
+#else
|
||
|
+ m_fileSystemWatcher->setParent(0);
|
||
|
+#endif
|
||
|
}
|
||
|
|
||
|
void FstabWatcher::orphanFileSystemWatcher()
|