diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-08-09 15:26:41 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-08-09 16:08:33 +0000 |
commit | fa99390154844307448dd21dc3d56543349d3891 (patch) | |
tree | 83425adcd57281e364b1b6552182551f12c5861c /src/qml/compiler/qv4compilationunitmapper_unix.cpp | |
parent | 28a055ce33a72651ae8a55bc673a26a6999c30ff (diff) |
Centralized deferred cleanup handling
Move the lambda cleanup code into a shared header file for re-use.
Change-Id: Ib9fb7dce98200bcad2bb688740f9b6c2a1e4aae7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compilationunitmapper_unix.cpp')
-rw-r--r-- | src/qml/compiler/qv4compilationunitmapper_unix.cpp | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/src/qml/compiler/qv4compilationunitmapper_unix.cpp b/src/qml/compiler/qv4compilationunitmapper_unix.cpp index 257a7616b7..7119acc80e 100644 --- a/src/qml/compiler/qv4compilationunitmapper_unix.cpp +++ b/src/qml/compiler/qv4compilationunitmapper_unix.cpp @@ -42,6 +42,7 @@ #include <sys/mman.h> #include <functional> #include <private/qcore_unix_p.h> +#include <private/qdeferredcleanup_p.h> #include "qv4compileddata_p.h" @@ -49,20 +50,6 @@ QT_BEGIN_NAMESPACE using namespace QV4; -namespace { - struct Defer - { - std::function<void()> callback; - template <typename Callback> - Defer(Callback &&cb) - : callback(cb) - {} - ~Defer() { callback(); } - Defer(const Defer &) = delete; - Defer &operator=(const Defer &) = delete; - }; -} - CompiledData::Unit *CompilationUnitMapper::open(const QString &sourcePath, QString *errorString) { close(); @@ -75,7 +62,7 @@ CompiledData::Unit *CompilationUnitMapper::open(const QString &sourcePath, QStri return nullptr; } - Defer cleanup([fd]{ + QDeferredCleanup cleanup([fd]{ qt_safe_close(fd) ; }); |