Initial review of various [q-r] by Utensil Candel.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53444 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -11,11 +11,12 @@
|
||||
@wxheader{recguard.h}
|
||||
|
||||
This is a completely opaque class which exists only to be used with
|
||||
wxRecursionGuard, please see the example in that
|
||||
class documentation.
|
||||
wxRecursionGuard, please see the example in that class' documentation.
|
||||
|
||||
Please notice that wxRecursionGuardFlag object must be declared
|
||||
@c static or the recursion would never be detected.
|
||||
@remarks
|
||||
|
||||
wxRecursionGuardFlag object must be declared @c static or the recursion
|
||||
would never be detected.
|
||||
|
||||
@library{wxbase}
|
||||
@category{FIXME}
|
||||
@@ -42,22 +43,22 @@ public:
|
||||
|
||||
@code
|
||||
void Foo()
|
||||
{
|
||||
static wxRecursionGuardFlag s_flag;
|
||||
wxRecursionGuard guard(s_flag);
|
||||
if ( guard.IsInside() )
|
||||
{
|
||||
static wxRecursionGuardFlag s_flag;
|
||||
wxRecursionGuard guard(s_flag);
|
||||
if ( guard.IsInside() )
|
||||
{
|
||||
// don't allow reentrancy
|
||||
return;
|
||||
}
|
||||
|
||||
...
|
||||
// don't allow reentrancy
|
||||
return;
|
||||
}
|
||||
|
||||
...
|
||||
}
|
||||
@endcode
|
||||
|
||||
As you can see, wxRecursionGuard simply tests the flag value and sets it to
|
||||
@true if it hadn't been already set.
|
||||
wxRecursionGuard::IsInside allows testing the old flag
|
||||
IsInside() allows testing the old flag
|
||||
value. The advantage of using this class compared to directly manipulating the
|
||||
flag is that the flag is always reset in the wxRecursionGuard destructor and so
|
||||
you don't risk to forget to do it even if the function returns in an unexpected
|
||||
@@ -70,7 +71,7 @@ class wxRecursionGuard
|
||||
{
|
||||
public:
|
||||
/**
|
||||
A wxRecursionGuard object must always be initialized with a (static)
|
||||
A wxRecursionGuard object must always be initialized with a @c static
|
||||
wxRecursionGuardFlag. The constructor saves the
|
||||
value of the flag to be able to return the correct value from
|
||||
IsInside().
|
||||
@@ -80,16 +81,18 @@ public:
|
||||
/**
|
||||
The destructor resets the flag value so that the function can be entered again
|
||||
the next time.
|
||||
Note that it is not virtual and so this class is not meant to be derived from
|
||||
(besides, there is absolutely no reason to do it anyhow).
|
||||
|
||||
@note This is not virtual, so this class is not meant to be derived
|
||||
from (besides, there is absolutely no reason to do it anyhow).
|
||||
*/
|
||||
~wxRecursionGuard();
|
||||
|
||||
/**
|
||||
Returns @true if we're already inside the code block "protected" by this
|
||||
wxRecursionGuard (i.e. between this line and the end of current scope). Usually
|
||||
the function using wxRecursionGuard takes some specific actions in such case
|
||||
(may be simply returning) to prevent reentrant calls to itself.
|
||||
wxRecursionGuard (i.e. between this line and the end of current scope).
|
||||
Usually the function using wxRecursionGuard takes some specific actions
|
||||
in such case (may be simply returning) to prevent reentrant calls to itself.
|
||||
|
||||
If this method returns @false, it is safe to continue.
|
||||
*/
|
||||
bool IsInside() const;
|
||||
|
Reference in New Issue
Block a user