1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-31 03:00:05 +00:00

Removed the ComponentDeletionWatcher class - use Component::SafePointer or Component::BailOutChecker instead.

This commit is contained in:
Julian Storer 2010-03-08 19:22:48 +00:00
parent 28518aa834
commit 1e1e4ae848
8 changed files with 2 additions and 166 deletions

View file

@ -28,7 +28,6 @@
BEGIN_JUCE_NAMESPACE
#include "juce_Component.h"
#include "juce_ComponentDeletionWatcher.h"
#include "juce_Desktop.h"
#include "windows/juce_ComponentPeer.h"
#include "keyboard/juce_KeyListener.h"
@ -3197,27 +3196,5 @@ bool Component::BailOutChecker::shouldBailOut() const throw()
return safePointer1 == 0 || safePointer2 != component2;
}
//==============================================================================
ComponentDeletionWatcher::ComponentDeletionWatcher (const Component* const componentToWatch_) throw()
: componentToWatch (componentToWatch_),
componentUID (componentToWatch_->getComponentUID())
{
// not possible to check on an already-deleted object..
jassert (componentToWatch_->isValidComponent());
}
ComponentDeletionWatcher::~ComponentDeletionWatcher() throw() {}
bool ComponentDeletionWatcher::hasBeenDeleted() const throw()
{
return ! (componentToWatch->isValidComponent()
&& componentToWatch->getComponentUID() == componentUID);
}
const Component* ComponentDeletionWatcher::getComponent() const throw()
{
return hasBeenDeleted() ? 0 : componentToWatch;
}
END_JUCE_NAMESPACE

View file

@ -1904,7 +1904,7 @@ public:
it is running on the message thread.
*/
template <class ComponentType>
class JUCE_API SafePointer : private ComponentListener
class SafePointer : private ComponentListener
{
public:
/** Creates a null SafePointer. */

View file

@ -1,74 +0,0 @@
/*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-9 by Raw Material Software Ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the GNU General
Public License (Version 2), as published by the Free Software Foundation.
A copy of the license is included in the JUCE distribution, or can be found
online at www.gnu.org/licenses.
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.rawmaterialsoftware.com/juce for more information.
==============================================================================
*/
#ifndef __JUCE_COMPONENTDELETIONWATCHER_JUCEHEADER__
#define __JUCE_COMPONENTDELETIONWATCHER_JUCEHEADER__
#include "juce_Component.h"
//==============================================================================
/**
Object for monitoring a component, and later testing whether it's still valid.
Slightly obscure, this one, but it's used internally for making sure that
after some callbacks, a component hasn't been deleted. It's more reliable than
just using isValidComponent(), which can provide false-positives if a new
component is created at the same memory location as an old one.
*/
class JUCE_API ComponentDeletionWatcher
{
public:
//==============================================================================
/** Creates a watcher for a given component.
The component must be valid at the time it's passed in.
*/
ComponentDeletionWatcher (const Component* const componentToWatch) throw();
/** Destructor. */
~ComponentDeletionWatcher() throw();
/** Returns true if the component has been deleted since the time that this
object was created.
*/
bool hasBeenDeleted() const throw();
/** Returns the component that's being watched, or null if it has been deleted. */
const Component* getComponent() const throw();
//==============================================================================
juce_UseDebuggingNewOperator
private:
const Component* const componentToWatch;
const uint32 componentUID;
ComponentDeletionWatcher (const ComponentDeletionWatcher&);
ComponentDeletionWatcher& operator= (const ComponentDeletionWatcher&);
};
#endif // __JUCE_COMPONENTDELETIONWATCHER_JUCEHEADER__

View file

@ -398,9 +398,6 @@
#ifndef __JUCE_COMPONENT_JUCEHEADER__
#include "gui/components/juce_Component.h"
#endif
#ifndef __JUCE_COMPONENTDELETIONWATCHER_JUCEHEADER__
#include "gui/components/juce_ComponentDeletionWatcher.h"
#endif
#ifndef __JUCE_COMPONENTLISTENER_JUCEHEADER__
#include "gui/components/juce_ComponentListener.h"
#endif