diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2010-10-01 14:14:01 +0100 |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2011-06-27 15:44:20 +0100 |
commit | 4846920c4c42615ecca40b5d2daed276e1de3805 (patch) | |
tree | 0d2e34456ebefc4388c9efad2404aad0a7124e56 /doc/src/snippets/code/src_script_qscriptvalueiterator.cpp | |
parent | b2e678bfd4f190ab27cb380201207d8f227f0739 (diff) | |
download | qt4-tools-4846920c4c42615ecca40b5d2daed276e1de3805.tar.gz |
Create QScopedResource class
This has similar purpose to QScopedPointer, and is implemented using it.
Symbian has many resource classes, e.g. RFile, RSocket, which behave as
value types, but require the Close() member function to be called to release
the server side resource owned by the handle.
This class can be used to give exception safety, for example when trying to
add a resource class to a container std::bad_alloc could be thrown.
By assigning the resource to QScopedResource when it is opened, and calling
take() after it is added to the container, it is ensured that the resource
will be closed if an exception is thrown.
Equivalent to the symbian pattern:
CleanupClosePushL(file);
container.AppendL(file); //transfers ownership, may leave
CleanupStack::Pop(file);
With STL exceptions we can do:
QScopedResource ptr(file);
container.append(file); //transfers ownership, may throw
ptr.take;
Reviewed-By: mread
Diffstat (limited to 'doc/src/snippets/code/src_script_qscriptvalueiterator.cpp')
0 files changed, 0 insertions, 0 deletions