mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-08 04:20:09 +00:00
New class: ScopedPointer, which auto-releases a pointer when it goes out of scope. I've used this extensively to replace a lot of pointer deletions with more RAII-style patterns.
This commit is contained in:
parent
4ed1d791e5
commit
c22c06c80c
126 changed files with 1454 additions and 1838 deletions
|
|
@ -1412,7 +1412,7 @@ int Component::runModalLoop()
|
|||
|
||||
Component* const prevFocused = getCurrentlyFocusedComponent();
|
||||
|
||||
ComponentDeletionWatcher* deletionChecker = 0;
|
||||
ScopedPointer <ComponentDeletionWatcher> deletionChecker;
|
||||
if (prevFocused != 0)
|
||||
deletionChecker = new ComponentDeletionWatcher (prevFocused);
|
||||
|
||||
|
|
@ -1455,13 +1455,8 @@ int Component::runModalLoop()
|
|||
|
||||
modalComponentStack.removeValue (this);
|
||||
|
||||
if (deletionChecker != 0)
|
||||
{
|
||||
if (! deletionChecker->hasBeenDeleted())
|
||||
prevFocused->grabKeyboardFocus();
|
||||
|
||||
delete deletionChecker;
|
||||
}
|
||||
if (deletionChecker != 0 && ! deletionChecker->hasBeenDeleted())
|
||||
prevFocused->grabKeyboardFocus();
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
|
@ -3339,12 +3334,12 @@ void Component::grabFocusInternal (const FocusChangeType cause, const bool canTr
|
|||
else
|
||||
{
|
||||
// find the default child component..
|
||||
KeyboardFocusTraverser* const traverser = createFocusTraverser();
|
||||
ScopedPointer <KeyboardFocusTraverser> traverser (createFocusTraverser());
|
||||
|
||||
if (traverser != 0)
|
||||
{
|
||||
Component* const defaultComp = traverser->getDefaultComponent (this);
|
||||
delete traverser;
|
||||
traverser = 0;
|
||||
|
||||
if (defaultComp != 0)
|
||||
{
|
||||
|
|
@ -3381,13 +3376,13 @@ void Component::moveKeyboardFocusToSibling (const bool moveToNext)
|
|||
|
||||
if (parentComponent_ != 0)
|
||||
{
|
||||
KeyboardFocusTraverser* const traverser = createFocusTraverser();
|
||||
ScopedPointer <KeyboardFocusTraverser> traverser (createFocusTraverser());
|
||||
|
||||
if (traverser != 0)
|
||||
{
|
||||
Component* const nextComp = moveToNext ? traverser->getNextComponent (this)
|
||||
: traverser->getPreviousComponent (this);
|
||||
delete traverser;
|
||||
traverser = 0;
|
||||
|
||||
if (nextComp != 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue