From 1e1e4ae848ca616b7e98abacf2f54511ffd77ebe Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Mon, 8 Mar 2010 19:22:48 +0000 Subject: [PATCH] Removed the ComponentDeletionWatcher class - use Component::SafePointer or Component::BailOutChecker instead. --- build/macosx/Juce.xcodeproj/project.pbxproj | 6 -- build/win32/vc8/JUCE.vcproj | 4 - juce_amalgamated.cpp | 21 ------ juce_amalgamated.h | 35 +-------- src/gui/components/juce_Component.cpp | 23 ------ src/gui/components/juce_Component.h | 2 +- .../juce_ComponentDeletionWatcher.h | 74 ------------------- src/juce_app_includes.h | 3 - 8 files changed, 2 insertions(+), 166 deletions(-) delete mode 100644 src/gui/components/juce_ComponentDeletionWatcher.h diff --git a/build/macosx/Juce.xcodeproj/project.pbxproj b/build/macosx/Juce.xcodeproj/project.pbxproj index f9889071ec..22147b37e0 100644 --- a/build/macosx/Juce.xcodeproj/project.pbxproj +++ b/build/macosx/Juce.xcodeproj/project.pbxproj @@ -114,7 +114,6 @@ 84816EA410809DCB008FEC33 /* juce_Component.h in Headers */ = {isa = PBXBuildFile; fileRef = 84F1EA4710403708006A1807 /* juce_Component.h */; }; 84816EA510809DCB008FEC33 /* juce_ComponentAnimator.h in Headers */ = {isa = PBXBuildFile; fileRef = 84F1EAA510403709006A1807 /* juce_ComponentAnimator.h */; }; 84816EA610809DCB008FEC33 /* juce_ComponentBoundsConstrainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 84F1EAA710403709006A1807 /* juce_ComponentBoundsConstrainer.h */; }; - 84816EA710809DCB008FEC33 /* juce_ComponentDeletionWatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 84F1EA4810403708006A1807 /* juce_ComponentDeletionWatcher.h */; }; 84816EA810809DCB008FEC33 /* juce_ComponentDragger.h in Headers */ = {isa = PBXBuildFile; fileRef = 84F1EACF10403709006A1807 /* juce_ComponentDragger.h */; }; 84816EA910809DCB008FEC33 /* juce_ComponentListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 84F1EA4A10403708006A1807 /* juce_ComponentListener.h */; }; 84816EAA10809DCB008FEC33 /* juce_ComponentMovementWatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 84F1EAA910403709006A1807 /* juce_ComponentMovementWatcher.h */; }; @@ -958,7 +957,6 @@ 84F1EA43104036D6006A1807 /* juce_WaitableEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 84F1E9E9104036D6006A1807 /* juce_WaitableEvent.h */; }; 84F1EBCC1040370A006A1807 /* juce_Component.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F1EA4610403708006A1807 /* juce_Component.cpp */; }; 84F1EBCD1040370A006A1807 /* juce_Component.h in Headers */ = {isa = PBXBuildFile; fileRef = 84F1EA4710403708006A1807 /* juce_Component.h */; }; - 84F1EBCE1040370A006A1807 /* juce_ComponentDeletionWatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 84F1EA4810403708006A1807 /* juce_ComponentDeletionWatcher.h */; }; 84F1EBCF1040370A006A1807 /* juce_ComponentListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F1EA4910403708006A1807 /* juce_ComponentListener.cpp */; }; 84F1EBD01040370A006A1807 /* juce_ComponentListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 84F1EA4A10403708006A1807 /* juce_ComponentListener.h */; }; 84F1EBD11040370A006A1807 /* juce_Desktop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F1EA4B10403708006A1807 /* juce_Desktop.cpp */; }; @@ -1578,7 +1576,6 @@ 84F1E9E9104036D6006A1807 /* juce_WaitableEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = juce_WaitableEvent.h; path = ../../src/threads/juce_WaitableEvent.h; sourceTree = SOURCE_ROOT; }; 84F1EA4610403708006A1807 /* juce_Component.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = juce_Component.cpp; path = ../../src/gui/components/juce_Component.cpp; sourceTree = SOURCE_ROOT; }; 84F1EA4710403708006A1807 /* juce_Component.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = juce_Component.h; path = ../../src/gui/components/juce_Component.h; sourceTree = SOURCE_ROOT; }; - 84F1EA4810403708006A1807 /* juce_ComponentDeletionWatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = juce_ComponentDeletionWatcher.h; path = ../../src/gui/components/juce_ComponentDeletionWatcher.h; sourceTree = SOURCE_ROOT; }; 84F1EA4910403708006A1807 /* juce_ComponentListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ComponentListener.cpp; path = ../../src/gui/components/juce_ComponentListener.cpp; sourceTree = SOURCE_ROOT; }; 84F1EA4A10403708006A1807 /* juce_ComponentListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = juce_ComponentListener.h; path = ../../src/gui/components/juce_ComponentListener.h; sourceTree = SOURCE_ROOT; }; 84F1EA4B10403708006A1807 /* juce_Desktop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = juce_Desktop.cpp; path = ../../src/gui/components/juce_Desktop.cpp; sourceTree = SOURCE_ROOT; }; @@ -2467,7 +2464,6 @@ children = ( 84F1EA4610403708006A1807 /* juce_Component.cpp */, 84F1EA4710403708006A1807 /* juce_Component.h */, - 84F1EA4810403708006A1807 /* juce_ComponentDeletionWatcher.h */, 84F1EA4910403708006A1807 /* juce_ComponentListener.cpp */, 84F1EA4A10403708006A1807 /* juce_ComponentListener.h */, 84F1EA4B10403708006A1807 /* juce_Desktop.cpp */, @@ -3011,7 +3007,6 @@ 84816EA410809DCB008FEC33 /* juce_Component.h in Headers */, 84816EA510809DCB008FEC33 /* juce_ComponentAnimator.h in Headers */, 84816EA610809DCB008FEC33 /* juce_ComponentBoundsConstrainer.h in Headers */, - 84816EA710809DCB008FEC33 /* juce_ComponentDeletionWatcher.h in Headers */, 84816EA810809DCB008FEC33 /* juce_ComponentDragger.h in Headers */, 84816EA910809DCB008FEC33 /* juce_ComponentListener.h in Headers */, 84816EAA10809DCB008FEC33 /* juce_ComponentMovementWatcher.h in Headers */, @@ -3434,7 +3429,6 @@ 84F1EA42104036D6006A1807 /* juce_TimeSliceThread.h in Headers */, 84F1EA43104036D6006A1807 /* juce_WaitableEvent.h in Headers */, 84F1EBCD1040370A006A1807 /* juce_Component.h in Headers */, - 84F1EBCE1040370A006A1807 /* juce_ComponentDeletionWatcher.h in Headers */, 84F1EBD01040370A006A1807 /* juce_ComponentListener.h in Headers */, 84F1EBD21040370A006A1807 /* juce_Desktop.h in Headers */, 84F1EBD41040370A006A1807 /* juce_ArrowButton.h in Headers */, diff --git a/build/win32/vc8/JUCE.vcproj b/build/win32/vc8/JUCE.vcproj index eae5510abb..d117e3097e 100644 --- a/build/win32/vc8/JUCE.vcproj +++ b/build/win32/vc8/JUCE.vcproj @@ -1344,10 +1344,6 @@ RelativePath="..\..\..\src\gui\components\juce_Component.h" > - - diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 651f2be0e5..1691d4026c 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -41593,27 +41593,6 @@ 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 /*** End of inlined file: juce_Component.cpp ***/ diff --git a/juce_amalgamated.h b/juce_amalgamated.h index b5e349595b..78eddf631a 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -12568,7 +12568,7 @@ public: uint32 getComponentUID() const throw() { return componentUID; } template - class JUCE_API SafePointer : private ComponentListener + class SafePointer : private ComponentListener { public: SafePointer() : comp (0) {} @@ -23466,39 +23466,6 @@ private: #endif #ifndef __JUCE_COMPONENT_JUCEHEADER__ -#endif -#ifndef __JUCE_COMPONENTDELETIONWATCHER_JUCEHEADER__ - -/*** Start of inlined file: juce_ComponentDeletionWatcher.h ***/ -#ifndef __JUCE_COMPONENTDELETIONWATCHER_JUCEHEADER__ -#define __JUCE_COMPONENTDELETIONWATCHER_JUCEHEADER__ - -class JUCE_API ComponentDeletionWatcher -{ -public: - - ComponentDeletionWatcher (const Component* const componentToWatch) throw(); - - ~ComponentDeletionWatcher() throw(); - - bool hasBeenDeleted() const throw(); - - 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__ -/*** End of inlined file: juce_ComponentDeletionWatcher.h ***/ - - #endif #ifndef __JUCE_COMPONENTLISTENER_JUCEHEADER__ diff --git a/src/gui/components/juce_Component.cpp b/src/gui/components/juce_Component.cpp index 07f6660620..031c73f31f 100644 --- a/src/gui/components/juce_Component.cpp +++ b/src/gui/components/juce_Component.cpp @@ -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 diff --git a/src/gui/components/juce_Component.h b/src/gui/components/juce_Component.h index af8c739c2a..19d8489d20 100644 --- a/src/gui/components/juce_Component.h +++ b/src/gui/components/juce_Component.h @@ -1904,7 +1904,7 @@ public: it is running on the message thread. */ template - class JUCE_API SafePointer : private ComponentListener + class SafePointer : private ComponentListener { public: /** Creates a null SafePointer. */ diff --git a/src/gui/components/juce_ComponentDeletionWatcher.h b/src/gui/components/juce_ComponentDeletionWatcher.h deleted file mode 100644 index e846624414..0000000000 --- a/src/gui/components/juce_ComponentDeletionWatcher.h +++ /dev/null @@ -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__ diff --git a/src/juce_app_includes.h b/src/juce_app_includes.h index 882b4758f5..d8ef4b9aa7 100644 --- a/src/juce_app_includes.h +++ b/src/juce_app_includes.h @@ -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