diff options
author | Sebastien Braun | 2010-10-06 15:09:43 +0200 |
---|---|---|
committer | Sebastien Braun | 2010-10-06 15:09:43 +0200 |
commit | c5c91f40c02d7b8611fb5e479f340fe19254592f (patch) | |
tree | 47384add2533c27506f673929c18af3726127f57 | |
parent | Refactor signal handling in pvsprivinputd (diff) | |
download | pvs-c5c91f40c02d7b8611fb5e479f340fe19254592f.tar.gz pvs-c5c91f40c02d7b8611fb5e479f340fe19254592f.tar.xz pvs-c5c91f40c02d7b8611fb5e479f340fe19254592f.zip |
Fix deletion order bug
PVSCheckPrivileges::instance() is statically allocated. When it is
deleted, the QCoreApplication is already gone (since it is stack-
allocated), and the destructor of QFileSystemWatcher waits forever.
-rw-r--r-- | src/input/pvsCheckPrivileges.cpp | 13 | ||||
-rw-r--r-- | src/input/pvsCheckPrivileges.h | 1 | ||||
-rw-r--r-- | src/input/pvsprivinputd.cpp | 3 |
3 files changed, 15 insertions, 2 deletions
diff --git a/src/input/pvsCheckPrivileges.cpp b/src/input/pvsCheckPrivileges.cpp index 71c5861..57b5d8b 100644 --- a/src/input/pvsCheckPrivileges.cpp +++ b/src/input/pvsCheckPrivileges.cpp @@ -100,8 +100,17 @@ Q_DECLARE_METATYPE(QStringStringMap) PVSCheckPrivileges* PVSCheckPrivileges::instance() { - static PVSCheckPrivileges static_instance; - return &static_instance; + static PVSCheckPrivileges* static_instance = 0; + if(!static_instance) + { + static_instance = new PVSCheckPrivileges(); + } + return static_instance; +} + +void PVSCheckPrivileges::deleteInstance() +{ + delete instance(); } PVSCheckPrivileges::PVSCheckPrivileges(QObject* parent) diff --git a/src/input/pvsCheckPrivileges.h b/src/input/pvsCheckPrivileges.h index fc82e4c..ec6c591 100644 --- a/src/input/pvsCheckPrivileges.h +++ b/src/input/pvsCheckPrivileges.h @@ -114,6 +114,7 @@ public: } static PVSCheckPrivileges* instance(); + static void deleteInstance(); bool require(SessionKind sessionKind, CachedInputContext const& sender); bool require(UserPrivilege userPrivilege, CachedInputContext const& sender); diff --git a/src/input/pvsprivinputd.cpp b/src/input/pvsprivinputd.cpp index 361bf9f..2f19d90 100644 --- a/src/input/pvsprivinputd.cpp +++ b/src/input/pvsprivinputd.cpp @@ -28,6 +28,7 @@ #include <QCoreApplication> #include <QStringList> #include <QSocketNotifier> +#include "pvsCheckPrivileges.h" #include "pvsPrivInputSocket.h" #include "pvsPrivInputHandler.h" #include "pvsPrivInputSignalHandler.h" @@ -151,5 +152,7 @@ int main(int argc, char** argv) // and run the main loop. int ret = app.exec(); + + PVSCheckPrivileges::deleteInstance(); return ret; } |