| @@ -651,6 +651,8 @@ | |||||
| 84AB91FF10A078190048FC39 /* juce_CPlusPlusCodeTokeniser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AB91F910A078190048FC39 /* juce_CPlusPlusCodeTokeniser.cpp */; }; | 84AB91FF10A078190048FC39 /* juce_CPlusPlusCodeTokeniser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AB91F910A078190048FC39 /* juce_CPlusPlusCodeTokeniser.cpp */; }; | ||||
| 84AB920010A078190048FC39 /* juce_CPlusPlusCodeTokeniser.h in Headers */ = {isa = PBXBuildFile; fileRef = 84AB91FA10A078190048FC39 /* juce_CPlusPlusCodeTokeniser.h */; }; | 84AB920010A078190048FC39 /* juce_CPlusPlusCodeTokeniser.h in Headers */ = {isa = PBXBuildFile; fileRef = 84AB91FA10A078190048FC39 /* juce_CPlusPlusCodeTokeniser.h */; }; | ||||
| 84AB927210A082E30048FC39 /* juce_CodeTokeniser.h in Headers */ = {isa = PBXBuildFile; fileRef = 84AB927110A082E30048FC39 /* juce_CodeTokeniser.h */; }; | 84AB927210A082E30048FC39 /* juce_CodeTokeniser.h in Headers */ = {isa = PBXBuildFile; fileRef = 84AB927110A082E30048FC39 /* juce_CodeTokeniser.h */; }; | ||||
| 84AF3FE810EF9FF30035D74F /* juce_ScopedPointer.h in Headers */ = {isa = PBXBuildFile; fileRef = 84AF3FE710EF9FF30035D74F /* juce_ScopedPointer.h */; }; | |||||
| 84AF419B10F0008E0035D74F /* juce_ScopedPointer.h in Headers */ = {isa = PBXBuildFile; fileRef = 84AF3FE710EF9FF30035D74F /* juce_ScopedPointer.h */; }; | |||||
| 84B2053E10D535EC008B4A79 /* juce_ValueTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 843D4A3A10D3C54500624BA6 /* juce_ValueTree.h */; }; | 84B2053E10D535EC008B4A79 /* juce_ValueTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 843D4A3A10D3C54500624BA6 /* juce_ValueTree.h */; }; | ||||
| 84B2053F10D535EC008B4A79 /* juce_ValueTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 843D4A3910D3C54500624BA6 /* juce_ValueTree.cpp */; }; | 84B2053F10D535EC008B4A79 /* juce_ValueTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 843D4A3910D3C54500624BA6 /* juce_ValueTree.cpp */; }; | ||||
| 84D0F00C109B1546007F73A3 /* juce_mac_CoreGraphicsContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = 84D0F00B109B1546007F73A3 /* juce_mac_CoreGraphicsContext.mm */; }; | 84D0F00C109B1546007F73A3 /* juce_mac_CoreGraphicsContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = 84D0F00B109B1546007F73A3 /* juce_mac_CoreGraphicsContext.mm */; }; | ||||
| @@ -1261,6 +1263,7 @@ | |||||
| 84AB91F910A078190048FC39 /* juce_CPlusPlusCodeTokeniser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = juce_CPlusPlusCodeTokeniser.cpp; path = components/code_editor/juce_CPlusPlusCodeTokeniser.cpp; sourceTree = "<group>"; }; | 84AB91F910A078190048FC39 /* juce_CPlusPlusCodeTokeniser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = juce_CPlusPlusCodeTokeniser.cpp; path = components/code_editor/juce_CPlusPlusCodeTokeniser.cpp; sourceTree = "<group>"; }; | ||||
| 84AB91FA10A078190048FC39 /* juce_CPlusPlusCodeTokeniser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = juce_CPlusPlusCodeTokeniser.h; path = components/code_editor/juce_CPlusPlusCodeTokeniser.h; sourceTree = "<group>"; }; | 84AB91FA10A078190048FC39 /* juce_CPlusPlusCodeTokeniser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = juce_CPlusPlusCodeTokeniser.h; path = components/code_editor/juce_CPlusPlusCodeTokeniser.h; sourceTree = "<group>"; }; | ||||
| 84AB927110A082E30048FC39 /* juce_CodeTokeniser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = juce_CodeTokeniser.h; path = components/code_editor/juce_CodeTokeniser.h; sourceTree = "<group>"; }; | 84AB927110A082E30048FC39 /* juce_CodeTokeniser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = juce_CodeTokeniser.h; path = components/code_editor/juce_CodeTokeniser.h; sourceTree = "<group>"; }; | ||||
| 84AF3FE710EF9FF30035D74F /* juce_ScopedPointer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = juce_ScopedPointer.h; sourceTree = "<group>"; }; | |||||
| 84D0F00B109B1546007F73A3 /* juce_mac_CoreGraphicsContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = juce_mac_CoreGraphicsContext.mm; sourceTree = "<group>"; }; | 84D0F00B109B1546007F73A3 /* juce_mac_CoreGraphicsContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = juce_mac_CoreGraphicsContext.mm; sourceTree = "<group>"; }; | ||||
| 84DEDD9E10EE496500909D01 /* juce_HeapBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = juce_HeapBlock.h; sourceTree = "<group>"; }; | 84DEDD9E10EE496500909D01 /* juce_HeapBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = juce_HeapBlock.h; sourceTree = "<group>"; }; | ||||
| 84F1E6DC10403605006A1807 /* juce_Application.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = juce_Application.cpp; path = ../../src/application/juce_Application.cpp; sourceTree = SOURCE_ROOT; }; | 84F1E6DC10403605006A1807 /* juce_Application.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = juce_Application.cpp; path = ../../src/application/juce_Application.cpp; sourceTree = SOURCE_ROOT; }; | ||||
| @@ -2170,6 +2173,7 @@ | |||||
| 84F1E8D910403671006A1807 /* juce_PropertySet.h */, | 84F1E8D910403671006A1807 /* juce_PropertySet.h */, | ||||
| 84F1E8DA10403671006A1807 /* juce_ReferenceCountedArray.h */, | 84F1E8DA10403671006A1807 /* juce_ReferenceCountedArray.h */, | ||||
| 84F1E8DB10403671006A1807 /* juce_ReferenceCountedObject.h */, | 84F1E8DB10403671006A1807 /* juce_ReferenceCountedObject.h */, | ||||
| 84AF3FE710EF9FF30035D74F /* juce_ScopedPointer.h */, | |||||
| 84F1E8DC10403671006A1807 /* juce_SortedSet.h */, | 84F1E8DC10403671006A1807 /* juce_SortedSet.h */, | ||||
| 84F1E8DD10403671006A1807 /* juce_SparseSet.h */, | 84F1E8DD10403671006A1807 /* juce_SparseSet.h */, | ||||
| 843D4A3910D3C54500624BA6 /* juce_ValueTree.cpp */, | 843D4A3910D3C54500624BA6 /* juce_ValueTree.cpp */, | ||||
| @@ -2219,19 +2223,19 @@ | |||||
| 84F1E9251040369C006A1807 /* utilities */ = { | 84F1E9251040369C006A1807 /* utilities */ = { | ||||
| isa = PBXGroup; | isa = PBXGroup; | ||||
| children = ( | children = ( | ||||
| 84F1E9261040369C006A1807 /* juce_UndoManager.h */, | |||||
| 84F1E9271040369C006A1807 /* juce_SystemClipboard.h */, | |||||
| 84F1E9281040369C006A1807 /* juce_UndoManager.cpp */, | |||||
| 84F1E9291040369C006A1807 /* juce_PropertiesFile.h */, | |||||
| 84F1E92A1040369C006A1807 /* juce_UndoableAction.h */, | |||||
| 84F1E92B1040369C006A1807 /* juce_SelectedItemSet.h */, | |||||
| 84F1E9321040369C006A1807 /* juce_DeletedAtShutdown.cpp */, | |||||
| 84F1E92C1040369C006A1807 /* juce_DeletedAtShutdown.h */, | 84F1E92C1040369C006A1807 /* juce_DeletedAtShutdown.h */, | ||||
| 84F1E92D1040369C006A1807 /* juce_PropertiesFile.cpp */, | |||||
| 84F1E92E1040369C006A1807 /* juce_RecentlyOpenedFilesList.h */, | |||||
| 84F1E9311040369C006A1807 /* juce_FileBasedDocument.cpp */, | |||||
| 84F1E92F1040369C006A1807 /* juce_FileBasedDocument.h */, | 84F1E92F1040369C006A1807 /* juce_FileBasedDocument.h */, | ||||
| 84F1E92D1040369C006A1807 /* juce_PropertiesFile.cpp */, | |||||
| 84F1E9291040369C006A1807 /* juce_PropertiesFile.h */, | |||||
| 84F1E9301040369C006A1807 /* juce_RecentlyOpenedFilesList.cpp */, | 84F1E9301040369C006A1807 /* juce_RecentlyOpenedFilesList.cpp */, | ||||
| 84F1E9311040369C006A1807 /* juce_FileBasedDocument.cpp */, | |||||
| 84F1E9321040369C006A1807 /* juce_DeletedAtShutdown.cpp */, | |||||
| 84F1E92E1040369C006A1807 /* juce_RecentlyOpenedFilesList.h */, | |||||
| 84F1E92B1040369C006A1807 /* juce_SelectedItemSet.h */, | |||||
| 84F1E9271040369C006A1807 /* juce_SystemClipboard.h */, | |||||
| 84F1E92A1040369C006A1807 /* juce_UndoableAction.h */, | |||||
| 84F1E9281040369C006A1807 /* juce_UndoManager.cpp */, | |||||
| 84F1E9261040369C006A1807 /* juce_UndoManager.h */, | |||||
| ); | ); | ||||
| name = utilities; | name = utilities; | ||||
| path = ../../src/utilities; | path = ../../src/utilities; | ||||
| @@ -3211,6 +3215,7 @@ | |||||
| 844BB95F10C557A800DF5536 /* juce_Config.h in Headers */, | 844BB95F10C557A800DF5536 /* juce_Config.h in Headers */, | ||||
| 84B2053E10D535EC008B4A79 /* juce_ValueTree.h in Headers */, | 84B2053E10D535EC008B4A79 /* juce_ValueTree.h in Headers */, | ||||
| 84AB6F6E10EF948B00117E64 /* juce_HeapBlock.h in Headers */, | 84AB6F6E10EF948B00117E64 /* juce_HeapBlock.h in Headers */, | ||||
| 84AF419B10F0008E0035D74F /* juce_ScopedPointer.h in Headers */, | |||||
| ); | ); | ||||
| runOnlyForDeploymentPostprocessing = 0; | runOnlyForDeploymentPostprocessing = 0; | ||||
| }; | }; | ||||
| @@ -3536,6 +3541,7 @@ | |||||
| 84F29AA010C2EFA5005014DF /* juce_FillType.h in Headers */, | 84F29AA010C2EFA5005014DF /* juce_FillType.h in Headers */, | ||||
| 843D4A3C10D3C54500624BA6 /* juce_ValueTree.h in Headers */, | 843D4A3C10D3C54500624BA6 /* juce_ValueTree.h in Headers */, | ||||
| 84DEDD9F10EE496500909D01 /* juce_HeapBlock.h in Headers */, | 84DEDD9F10EE496500909D01 /* juce_HeapBlock.h in Headers */, | ||||
| 84AF3FE810EF9FF30035D74F /* juce_ScopedPointer.h in Headers */, | |||||
| ); | ); | ||||
| runOnlyForDeploymentPostprocessing = 0; | runOnlyForDeploymentPostprocessing = 0; | ||||
| }; | }; | ||||
| @@ -39,29 +39,29 @@ ifeq ($(CONFIG),Release) | |||||
| endif | endif | ||||
| OBJECTS := \ | OBJECTS := \ | ||||
| $(OBJDIR)/MainDemoWindow.o \ | |||||
| $(OBJDIR)/BinaryData.o \ | $(OBJDIR)/BinaryData.o \ | ||||
| $(OBJDIR)/ApplicationStartup.o \ | |||||
| $(OBJDIR)/juce_LibrarySource.o \ | $(OBJDIR)/juce_LibrarySource.o \ | ||||
| $(OBJDIR)/ApplicationStartup.o \ | |||||
| $(OBJDIR)/MainDemoWindow.o \ | |||||
| $(OBJDIR)/AudioDemoLatencyPage.o \ | $(OBJDIR)/AudioDemoLatencyPage.o \ | ||||
| $(OBJDIR)/AudioDemoPlaybackPage.o \ | $(OBJDIR)/AudioDemoPlaybackPage.o \ | ||||
| $(OBJDIR)/AudioDemoRecordPage.o \ | |||||
| $(OBJDIR)/AudioDemoSetupPage.o \ | $(OBJDIR)/AudioDemoSetupPage.o \ | ||||
| $(OBJDIR)/AudioDemoSynthPage.o \ | $(OBJDIR)/AudioDemoSynthPage.o \ | ||||
| $(OBJDIR)/AudioDemoTabComponent.o \ | $(OBJDIR)/AudioDemoTabComponent.o \ | ||||
| $(OBJDIR)/CameraDemo.o \ | $(OBJDIR)/CameraDemo.o \ | ||||
| $(OBJDIR)/DragAndDropDemo.o \ | $(OBJDIR)/DragAndDropDemo.o \ | ||||
| $(OBJDIR)/FontsAndTextDemo.o \ | |||||
| $(OBJDIR)/InterprocessCommsDemo.o \ | $(OBJDIR)/InterprocessCommsDemo.o \ | ||||
| $(OBJDIR)/OpenGLDemo.o \ | $(OBJDIR)/OpenGLDemo.o \ | ||||
| $(OBJDIR)/RenderingTestComponent.o \ | |||||
| $(OBJDIR)/QuickTimeDemo.o \ | $(OBJDIR)/QuickTimeDemo.o \ | ||||
| $(OBJDIR)/TableDemo.o \ | $(OBJDIR)/TableDemo.o \ | ||||
| $(OBJDIR)/ThreadingDemo.o \ | $(OBJDIR)/ThreadingDemo.o \ | ||||
| $(OBJDIR)/TreeViewDemo.o \ | $(OBJDIR)/TreeViewDemo.o \ | ||||
| $(OBJDIR)/WebBrowserDemo.o \ | $(OBJDIR)/WebBrowserDemo.o \ | ||||
| $(OBJDIR)/CodeEditorDemo.o \ | $(OBJDIR)/CodeEditorDemo.o \ | ||||
| $(OBJDIR)/FontsAndTextDemo.o \ | |||||
| $(OBJDIR)/RenderingTestComponent.o \ | |||||
| $(OBJDIR)/WidgetsDemo.o \ | $(OBJDIR)/WidgetsDemo.o \ | ||||
| $(OBJDIR)/AudioDemoRecordPage.o \ | |||||
| MKDIR_TYPE := msdos | MKDIR_TYPE := msdos | ||||
| CMD := $(subst \,\\,$(ComSpec)$(COMSPEC)) | CMD := $(subst \,\\,$(ComSpec)$(COMSPEC)) | ||||
| @@ -103,12 +103,12 @@ else | |||||
| -@if exist $(subst /,\,$(OBJDIR)) rmdir /s /q $(subst /,\,$(OBJDIR)) | -@if exist $(subst /,\,$(OBJDIR)) rmdir /s /q $(subst /,\,$(OBJDIR)) | ||||
| endif | endif | ||||
| $(OBJDIR)/MainDemoWindow.o: ../../src/MainDemoWindow.cpp | |||||
| $(OBJDIR)/BinaryData.o: ../../src/BinaryData.cpp | |||||
| -@$(CMD_MKOBJDIR) | -@$(CMD_MKOBJDIR) | ||||
| @echo $(notdir $<) | @echo $(notdir $<) | ||||
| @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | ||||
| $(OBJDIR)/BinaryData.o: ../../src/BinaryData.cpp | |||||
| $(OBJDIR)/juce_LibrarySource.o: ../../src/juce_LibrarySource.cpp | |||||
| -@$(CMD_MKOBJDIR) | -@$(CMD_MKOBJDIR) | ||||
| @echo $(notdir $<) | @echo $(notdir $<) | ||||
| @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | ||||
| @@ -118,7 +118,7 @@ $(OBJDIR)/ApplicationStartup.o: ../../src/ApplicationStartup.cpp | |||||
| @echo $(notdir $<) | @echo $(notdir $<) | ||||
| @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | ||||
| $(OBJDIR)/juce_LibrarySource.o: ../../src/juce_LibrarySource.cpp | |||||
| $(OBJDIR)/MainDemoWindow.o: ../../src/MainDemoWindow.cpp | |||||
| -@$(CMD_MKOBJDIR) | -@$(CMD_MKOBJDIR) | ||||
| @echo $(notdir $<) | @echo $(notdir $<) | ||||
| @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | ||||
| @@ -133,11 +133,6 @@ $(OBJDIR)/AudioDemoPlaybackPage.o: ../../src/demos/AudioDemoPlaybackPage.cpp | |||||
| @echo $(notdir $<) | @echo $(notdir $<) | ||||
| @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | ||||
| $(OBJDIR)/AudioDemoRecordPage.o: ../../src/demos/AudioDemoRecordPage.cpp | |||||
| -@$(CMD_MKOBJDIR) | |||||
| @echo $(notdir $<) | |||||
| @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | |||||
| $(OBJDIR)/AudioDemoSetupPage.o: ../../src/demos/AudioDemoSetupPage.cpp | $(OBJDIR)/AudioDemoSetupPage.o: ../../src/demos/AudioDemoSetupPage.cpp | ||||
| -@$(CMD_MKOBJDIR) | -@$(CMD_MKOBJDIR) | ||||
| @echo $(notdir $<) | @echo $(notdir $<) | ||||
| @@ -163,17 +158,17 @@ $(OBJDIR)/DragAndDropDemo.o: ../../src/demos/DragAndDropDemo.cpp | |||||
| @echo $(notdir $<) | @echo $(notdir $<) | ||||
| @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | ||||
| $(OBJDIR)/InterprocessCommsDemo.o: ../../src/demos/InterprocessCommsDemo.cpp | |||||
| $(OBJDIR)/FontsAndTextDemo.o: ../../src/demos/FontsAndTextDemo.cpp | |||||
| -@$(CMD_MKOBJDIR) | -@$(CMD_MKOBJDIR) | ||||
| @echo $(notdir $<) | @echo $(notdir $<) | ||||
| @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | ||||
| $(OBJDIR)/OpenGLDemo.o: ../../src/demos/OpenGLDemo.cpp | |||||
| $(OBJDIR)/InterprocessCommsDemo.o: ../../src/demos/InterprocessCommsDemo.cpp | |||||
| -@$(CMD_MKOBJDIR) | -@$(CMD_MKOBJDIR) | ||||
| @echo $(notdir $<) | @echo $(notdir $<) | ||||
| @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | ||||
| $(OBJDIR)/RenderingTestComponent.o: ../../src/demos/RenderingTestComponent.cpp | |||||
| $(OBJDIR)/OpenGLDemo.o: ../../src/demos/OpenGLDemo.cpp | |||||
| -@$(CMD_MKOBJDIR) | -@$(CMD_MKOBJDIR) | ||||
| @echo $(notdir $<) | @echo $(notdir $<) | ||||
| @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | ||||
| @@ -208,7 +203,7 @@ $(OBJDIR)/CodeEditorDemo.o: ../../src/demos/CodeEditorDemo.cpp | |||||
| @echo $(notdir $<) | @echo $(notdir $<) | ||||
| @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | ||||
| $(OBJDIR)/FontsAndTextDemo.o: ../../src/demos/FontsAndTextDemo.cpp | |||||
| $(OBJDIR)/RenderingTestComponent.o: ../../src/demos/RenderingTestComponent.cpp | |||||
| -@$(CMD_MKOBJDIR) | -@$(CMD_MKOBJDIR) | ||||
| @echo $(notdir $<) | @echo $(notdir $<) | ||||
| @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | ||||
| @@ -218,5 +213,10 @@ $(OBJDIR)/WidgetsDemo.o: ../../src/demos/WidgetsDemo.cpp | |||||
| @echo $(notdir $<) | @echo $(notdir $<) | ||||
| @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | ||||
| $(OBJDIR)/AudioDemoRecordPage.o: ../../src/demos/AudioDemoRecordPage.cpp | |||||
| -@$(CMD_MKOBJDIR) | |||||
| @echo $(notdir $<) | |||||
| @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | |||||
| -include $(OBJECTS:%.o=%.d) | -include $(OBJECTS:%.o=%.d) | ||||
| @@ -4933,6 +4933,158 @@ private: | |||||
| #ifndef __JUCE_OWNEDARRAY_JUCEHEADER__ | #ifndef __JUCE_OWNEDARRAY_JUCEHEADER__ | ||||
| #define __JUCE_OWNEDARRAY_JUCEHEADER__ | #define __JUCE_OWNEDARRAY_JUCEHEADER__ | ||||
| /********* Start of inlined file: juce_ScopedPointer.h *********/ | |||||
| #ifndef __JUCE_SCOPEDPOINTER_JUCEHEADER__ | |||||
| #define __JUCE_SCOPEDPOINTER_JUCEHEADER__ | |||||
| /** | |||||
| This class holds a pointer which is automatically deleted when this object goes | |||||
| out of scope. | |||||
| Once a pointer has been passed to a ScopedPointer, it will make sure that the pointer | |||||
| gets deleted when the ScopedPointer is deleted. Using the ScopedPointer on the stack or | |||||
| as member variables is a good way to use RAII to avoid accidentally leaking dynamically | |||||
| created objects. | |||||
| A ScopedPointer can be used in pretty much the same way that you'd use a normal pointer | |||||
| to an object. If you use the assignment operator to assign a different object to a | |||||
| ScopedPointer, the old one will be automatically deleted. | |||||
| If you need to get a pointer out of a ScopedPointer without it being deleted, you | |||||
| can use the release() method. | |||||
| */ | |||||
| template <class ObjectType> | |||||
| class ScopedPointer | |||||
| { | |||||
| public: | |||||
| /** Creates a ScopedPointer containing a null pointer. */ | |||||
| inline ScopedPointer() : object (0) | |||||
| { | |||||
| } | |||||
| /** Creates a ScopedPointer that owns the specified object. */ | |||||
| inline ScopedPointer (ObjectType* const objectToTakePossessionOf) | |||||
| : object (objectToTakePossessionOf) | |||||
| { | |||||
| } | |||||
| /** Creates a ScopedPointer that takes its pointer from another ScopedPointer. | |||||
| Because a pointer can only belong to one ScopedPointer, this transfers | |||||
| the pointer from the other object to this one, and the other object is reset to | |||||
| be a null pointer. | |||||
| */ | |||||
| ScopedPointer (ScopedPointer& objectToTransferFrom) | |||||
| : object (objectToTransferFrom.object) | |||||
| { | |||||
| objectToTransferFrom.object = 0; | |||||
| } | |||||
| /** Destructor. | |||||
| This will delete the object that this ScopedPointer currently refers to. | |||||
| */ | |||||
| inline ~ScopedPointer() { delete object; } | |||||
| /** Changes this ScopedPointer to point to a new object. | |||||
| Because a pointer can only belong to one ScopedPointer, this transfers | |||||
| the pointer from the other object to this one, and the other object is reset to | |||||
| be a null pointer. | |||||
| If this ScopedPointer already points to an object, that object | |||||
| will first be deleted. | |||||
| */ | |||||
| const ScopedPointer& operator= (ScopedPointer& objectToTransferFrom) | |||||
| { | |||||
| if (this != &objectToTransferFrom) | |||||
| { | |||||
| // Two ScopedPointers should never be able to refer to the same object - if | |||||
| // this happens, you must have done something dodgy! | |||||
| jassert (object != objectToTransferFrom.object); | |||||
| ObjectType* const oldObject = object; | |||||
| object = objectToTransferFrom.object; | |||||
| objectToTransferFrom.object = 0; | |||||
| delete oldObject; | |||||
| } | |||||
| return *this; | |||||
| } | |||||
| /** Changes this ScopedPointer to point to a new object. | |||||
| If this ScopedPointer already points to an object, that object | |||||
| will first be deleted. | |||||
| The pointer that you pass is may be null. | |||||
| */ | |||||
| const ScopedPointer& operator= (ObjectType* const newObjectToTakePossessionOf) | |||||
| { | |||||
| if (object != newObjectToTakePossessionOf) | |||||
| { | |||||
| ObjectType* const oldObject = object; | |||||
| object = newObjectToTakePossessionOf; | |||||
| delete oldObject; | |||||
| } | |||||
| return *this; | |||||
| } | |||||
| /** Returns the object that this ScopedPointer refers to. | |||||
| */ | |||||
| inline operator ObjectType*() const { return object; } | |||||
| /** Returns the object that this ScopedPointer refers to. | |||||
| */ | |||||
| inline ObjectType& operator*() const { return *object; } | |||||
| /** Lets you access methods and properties of the object that this ScopedPointer refers to. */ | |||||
| inline ObjectType* operator->() const { return object; } | |||||
| /** Returns a pointer to the object by casting it to whatever type you need. */ | |||||
| template <class CastType> | |||||
| inline operator CastType*() const { return static_cast <CastType*> (object); } | |||||
| /** Returns a reference to the address of the object that this ScopedPointer refers to. */ | |||||
| inline ObjectType** operator&() const { return (ObjectType**) &object; } | |||||
| /** Removes the current object from this ScopedPointer without deleting it. | |||||
| This will return the current object, and set the ScopedPointer to a null pointer. | |||||
| */ | |||||
| ObjectType* release() { ObjectType* const o = object; object = 0; return o; } | |||||
| /** Compares the pointer with another pointer. | |||||
| This can be handy for checking whether this is a null pointer. | |||||
| */ | |||||
| inline bool operator== (const ObjectType* const otherPointer) const { return otherPointer == object; } | |||||
| /** Compares the pointer with another pointer. | |||||
| This can be handy for checking whether this is a null pointer. | |||||
| */ | |||||
| inline bool operator!= (const ObjectType* const otherPointer) const { return otherPointer != object; } | |||||
| /** Swaps this object with that of another ScopedPointer. | |||||
| The two objects simply exchange their pointers. | |||||
| */ | |||||
| void swapWith (ScopedPointer <ObjectType>& other) | |||||
| { | |||||
| // Two ScopedPointers should never be able to refer to the same object - if | |||||
| // this happens, you must have done something dodgy! | |||||
| jassert (object != other.object); | |||||
| swapVariables (object, other.object); | |||||
| } | |||||
| private: | |||||
| ObjectType* object; | |||||
| }; | |||||
| #endif // __JUCE_SCOPEDPOINTER_JUCEHEADER__ | |||||
| /********* End of inlined file: juce_ScopedPointer.h *********/ | |||||
| /** An array designed for holding objects. | /** An array designed for holding objects. | ||||
| This holds a list of pointers to objects, and will automatically | This holds a list of pointers to objects, and will automatically | ||||
| @@ -5238,7 +5390,7 @@ public: | |||||
| { | { | ||||
| if (indexToChange >= 0) | if (indexToChange >= 0) | ||||
| { | { | ||||
| ObjectClass* toDelete = 0; | |||||
| ScopedPointer <ObjectClass> toDelete; | |||||
| lock.enter(); | lock.enter(); | ||||
| if (indexToChange < numUsed) | if (indexToChange < numUsed) | ||||
| @@ -5260,8 +5412,6 @@ public: | |||||
| } | } | ||||
| lock.exit(); | lock.exit(); | ||||
| delete toDelete; | |||||
| } | } | ||||
| } | } | ||||
| @@ -5352,8 +5502,8 @@ public: | |||||
| void remove (const int indexToRemove, | void remove (const int indexToRemove, | ||||
| const bool deleteObject = true) | const bool deleteObject = true) | ||||
| { | { | ||||
| ScopedPointer <ObjectClass> toDelete; | |||||
| lock.enter(); | lock.enter(); | ||||
| ObjectClass* toDelete = 0; | |||||
| if (((unsigned int) indexToRemove) < (unsigned int) numUsed) | if (((unsigned int) indexToRemove) < (unsigned int) numUsed) | ||||
| { | { | ||||
| @@ -5373,8 +5523,6 @@ public: | |||||
| } | } | ||||
| lock.exit(); | lock.exit(); | ||||
| delete toDelete; | |||||
| } | } | ||||
| /** Removes a specified object from the array. | /** Removes a specified object from the array. | ||||
| @@ -10018,6 +10166,9 @@ private: | |||||
| #endif | #endif | ||||
| #ifndef __JUCE_REFERENCECOUNTEDOBJECT_JUCEHEADER__ | #ifndef __JUCE_REFERENCECOUNTEDOBJECT_JUCEHEADER__ | ||||
| #endif | |||||
| #ifndef __JUCE_SCOPEDPOINTER_JUCEHEADER__ | |||||
| #endif | #endif | ||||
| #ifndef __JUCE_SORTEDSET_JUCEHEADER__ | #ifndef __JUCE_SORTEDSET_JUCEHEADER__ | ||||
| @@ -12293,7 +12444,7 @@ public: | |||||
| private: | private: | ||||
| File logFile; | File logFile; | ||||
| CriticalSection logLock; | CriticalSection logLock; | ||||
| FileOutputStream* logStream; | |||||
| ScopedPointer <FileOutputStream> logStream; | |||||
| void trimFileSize (int maxFileSizeBytes) const; | void trimFileSize (int maxFileSizeBytes) const; | ||||
| @@ -13688,7 +13839,7 @@ private: | |||||
| String wildCard; | String wildCard; | ||||
| int index; | int index; | ||||
| const int whatToLookFor; | const int whatToLookFor; | ||||
| DirectoryIterator* subIterator; | |||||
| ScopedPointer <DirectoryIterator> subIterator; | |||||
| DirectoryIterator (const DirectoryIterator&); | DirectoryIterator (const DirectoryIterator&); | ||||
| const DirectoryIterator& operator= (const DirectoryIterator&); | const DirectoryIterator& operator= (const DirectoryIterator&); | ||||
| @@ -14197,7 +14348,7 @@ private: | |||||
| friend class ZipInputStream; | friend class ZipInputStream; | ||||
| CriticalSection lock; | CriticalSection lock; | ||||
| InputStream* inputStream; | InputStream* inputStream; | ||||
| InputSource* inputSource; | |||||
| ScopedPointer <InputSource> inputSource; | |||||
| bool deleteStreamWhenDestroyed; | bool deleteStreamWhenDestroyed; | ||||
| int numEntries, centralRecStart; | int numEntries, centralRecStart; | ||||
| @@ -15435,7 +15586,7 @@ private: | |||||
| String lastError, dtdText; | String lastError, dtdText; | ||||
| StringArray tokenisedDTD; | StringArray tokenisedDTD; | ||||
| bool needToLoadDTD, ignoreEmptyTextElements; | bool needToLoadDTD, ignoreEmptyTextElements; | ||||
| InputSource* inputSource; | |||||
| ScopedPointer <InputSource> inputSource; | |||||
| void setLastError (const String& desc, const bool carryOn) throw(); | void setLastError (const String& desc, const bool carryOn) throw(); | ||||
| void skipHeader() throw(); | void skipHeader() throw(); | ||||
| @@ -21162,7 +21313,7 @@ public: | |||||
| If a gradient is active, the overall opacity with which it should be applied | If a gradient is active, the overall opacity with which it should be applied | ||||
| is indicated by the alpha channel of the colour variable. | is indicated by the alpha channel of the colour variable. | ||||
| */ | */ | ||||
| ColourGradient* gradient; | |||||
| ScopedPointer <ColourGradient> gradient; | |||||
| /** Returns the image that should be used for tiling. | /** Returns the image that should be used for tiling. | ||||
| The FillType object just keeps a pointer to this image, it doesn't own it, so you have to | The FillType object just keeps a pointer to this image, it doesn't own it, so you have to | ||||
| @@ -22667,7 +22818,7 @@ protected: | |||||
| private: | private: | ||||
| Component* lastFocusedComponent; | Component* lastFocusedComponent; | ||||
| ComponentDeletionWatcher* dragAndDropTargetComponent; | |||||
| ScopedPointer <ComponentDeletionWatcher> dragAndDropTargetComponent; | |||||
| Component* lastDragAndDropCompUnderMouse; | Component* lastDragAndDropCompUnderMouse; | ||||
| bool fakeMouseMessageSent : 1, isWindowMinimised : 1; | bool fakeMouseMessageSent : 1, isWindowMinimised : 1; | ||||
| @@ -26218,7 +26369,7 @@ private: | |||||
| OwnedArray <ApplicationCommandInfo> commands; | OwnedArray <ApplicationCommandInfo> commands; | ||||
| SortedSet <void*> listeners; | SortedSet <void*> listeners; | ||||
| KeyPressMappingSet* keyMappings; | |||||
| ScopedPointer <KeyPressMappingSet> keyMappings; | |||||
| ApplicationCommandTarget* firstTarget; | ApplicationCommandTarget* firstTarget; | ||||
| void sendListenerInvokeCallback (const ApplicationCommandTarget::InvocationInfo& info) const; | void sendListenerInvokeCallback (const ApplicationCommandTarget::InvocationInfo& info) const; | ||||
| @@ -26528,8 +26679,7 @@ public: | |||||
| private: | private: | ||||
| PropertiesFile* userProps; | |||||
| PropertiesFile* commonProps; | |||||
| ScopedPointer <PropertiesFile> userProps, commonProps; | |||||
| String appName, fileSuffix, folderName; | String appName, fileSuffix, folderName; | ||||
| int msBeforeSaving, options; | int msBeforeSaving, options; | ||||
| @@ -27789,7 +27939,7 @@ private: | |||||
| OwnedArray<File> tracks; | OwnedArray<File> tracks; | ||||
| Array <int> trackStartSamples; | Array <int> trackStartSamples; | ||||
| int currentReaderTrack; | int currentReaderTrack; | ||||
| AudioFormatReader* reader; | |||||
| ScopedPointer <AudioFormatReader> reader; | |||||
| AudioCDReader (const File& volume); | AudioCDReader (const File& volume); | ||||
| public: | public: | ||||
| static int compareElements (const File* const, const File* const) throw(); | static int compareElements (const File* const, const File* const) throw(); | ||||
| @@ -28127,10 +28277,10 @@ public: | |||||
| private: | private: | ||||
| AudioFormatManager& formatManagerToUse; | AudioFormatManager& formatManagerToUse; | ||||
| AudioThumbnailCache& cache; | AudioThumbnailCache& cache; | ||||
| InputSource* source; | |||||
| ScopedPointer <InputSource> source; | |||||
| CriticalSection readerLock; | CriticalSection readerLock; | ||||
| AudioFormatReader* reader; | |||||
| ScopedPointer <AudioFormatReader> reader; | |||||
| MemoryBlock data, cachedLevels; | MemoryBlock data, cachedLevels; | ||||
| int orginalSamplesPerThumbnailSample; | int orginalSamplesPerThumbnailSample; | ||||
| @@ -31884,7 +32034,7 @@ private: | |||||
| SortedSet <void*> buttonListeners; | SortedSet <void*> buttonListeners; | ||||
| friend class InternalButtonRepeatTimer; | friend class InternalButtonRepeatTimer; | ||||
| Timer* repeatTimer; | |||||
| ScopedPointer <Timer> repeatTimer; | |||||
| uint32 buttonPressTime, lastTimeCallbackTime; | uint32 buttonPressTime, lastTimeCallbackTime; | ||||
| ApplicationCommandManager* commandManagerToUse; | ApplicationCommandManager* commandManagerToUse; | ||||
| int autoRepeatDelay, autoRepeatSpeed, autoRepeatMinimumDelay; | int autoRepeatDelay, autoRepeatSpeed, autoRepeatMinimumDelay; | ||||
| @@ -33759,10 +33909,10 @@ private: | |||||
| String text; | String text; | ||||
| Font font; | Font font; | ||||
| Justification justification; | Justification justification; | ||||
| TextEditor* editor; | |||||
| ScopedPointer <TextEditor> editor; | |||||
| SortedSet <void*> listeners; | SortedSet <void*> listeners; | ||||
| Component* ownerComponent; | Component* ownerComponent; | ||||
| ComponentDeletionWatcher* deletionWatcher; | |||||
| ScopedPointer <ComponentDeletionWatcher> deletionWatcher; | |||||
| int horizontalBorderSize, verticalBorderSize; | int horizontalBorderSize, verticalBorderSize; | ||||
| float minimumHorizontalScale; | float minimumHorizontalScale; | ||||
| bool editSingleClick : 1; | bool editSingleClick : 1; | ||||
| @@ -34502,17 +34652,17 @@ private: | |||||
| OwnedArray <AudioDeviceSetup> lastDeviceTypeConfigs; | OwnedArray <AudioDeviceSetup> lastDeviceTypeConfigs; | ||||
| AudioDeviceSetup currentSetup; | AudioDeviceSetup currentSetup; | ||||
| AudioIODevice* currentAudioDevice; | |||||
| ScopedPointer <AudioIODevice> currentAudioDevice; | |||||
| SortedSet <AudioIODeviceCallback*> callbacks; | SortedSet <AudioIODeviceCallback*> callbacks; | ||||
| int numInputChansNeeded, numOutputChansNeeded; | int numInputChansNeeded, numOutputChansNeeded; | ||||
| String currentDeviceType; | String currentDeviceType; | ||||
| BitArray inputChannels, outputChannels; | BitArray inputChannels, outputChannels; | ||||
| XmlElement* lastExplicitSettings; | |||||
| ScopedPointer <XmlElement> lastExplicitSettings; | |||||
| mutable bool listNeedsScanning; | mutable bool listNeedsScanning; | ||||
| bool useInputNames; | bool useInputNames; | ||||
| int inputLevelMeasurementEnabledCount; | int inputLevelMeasurementEnabledCount; | ||||
| double inputLevel; | double inputLevel; | ||||
| AudioSampleBuffer* testSound; | |||||
| ScopedPointer <AudioSampleBuffer> testSound; | |||||
| int testSoundPosition; | int testSoundPosition; | ||||
| AudioSampleBuffer tempBuffer; | AudioSampleBuffer tempBuffer; | ||||
| @@ -34521,7 +34671,7 @@ private: | |||||
| Array <MidiInputCallback*> midiCallbacks; | Array <MidiInputCallback*> midiCallbacks; | ||||
| Array <MidiInput*> midiCallbackDevices; | Array <MidiInput*> midiCallbackDevices; | ||||
| String defaultMidiOutputName; | String defaultMidiOutputName; | ||||
| MidiOutput* defaultMidiOutput; | |||||
| ScopedPointer <MidiOutput> defaultMidiOutput; | |||||
| CriticalSection audioCallbackLock, midiCallbackLock; | CriticalSection audioCallbackLock, midiCallbackLock; | ||||
| double cpuUsageMs, timeToCpuScale; | double cpuUsageMs, timeToCpuScale; | ||||
| @@ -35066,8 +35216,8 @@ public: | |||||
| const MidiMessageSequence::MidiEventHolder* const second) throw(); | const MidiMessageSequence::MidiEventHolder* const second) throw(); | ||||
| private: | private: | ||||
| MidiMessageSequence* tracks [128]; | |||||
| short numTracks, timeFormat; | |||||
| OwnedArray <MidiMessageSequence> tracks; | |||||
| short timeFormat; | |||||
| MidiFile (const MidiFile&); | MidiFile (const MidiFile&); | ||||
| const MidiFile& operator= (const MidiFile&); | const MidiFile& operator= (const MidiFile&); | ||||
| @@ -38914,7 +39064,7 @@ private: | |||||
| friend class SamplerVoice; | friend class SamplerVoice; | ||||
| String name; | String name; | ||||
| AudioSampleBuffer* data; | |||||
| ScopedPointer <AudioSampleBuffer> data; | |||||
| double sourceSampleRate; | double sourceSampleRate; | ||||
| BitArray midiNotes; | BitArray midiNotes; | ||||
| int length, attackSamples, releaseSamples; | int length, attackSamples, releaseSamples; | ||||
| @@ -39321,8 +39471,8 @@ public: | |||||
| private: | private: | ||||
| CriticalSection pipeAndSocketLock; | CriticalSection pipeAndSocketLock; | ||||
| StreamingSocket* socket; | |||||
| NamedPipe* pipe; | |||||
| ScopedPointer <StreamingSocket> socket; | |||||
| ScopedPointer <NamedPipe> pipe; | |||||
| bool callbackConnectionState; | bool callbackConnectionState; | ||||
| const bool useMessageThread; | const bool useMessageThread; | ||||
| const uint32 magicMessageHeader; | const uint32 magicMessageHeader; | ||||
| @@ -39412,7 +39562,7 @@ public: | |||||
| juce_UseDebuggingNewOperator | juce_UseDebuggingNewOperator | ||||
| private: | private: | ||||
| StreamingSocket* volatile socket; | |||||
| ScopedPointer <StreamingSocket> socket; | |||||
| void run(); | void run(); | ||||
| @@ -39568,8 +39718,8 @@ private: | |||||
| friend class CallbackMessage; | friend class CallbackMessage; | ||||
| static MessageManager* instance; | static MessageManager* instance; | ||||
| SortedSet<const MessageListener*> messageListeners; | |||||
| ActionListenerList* broadcastListeners; | |||||
| SortedSet <const MessageListener*> messageListeners; | |||||
| ScopedPointer <ActionListenerList> broadcastListeners; | |||||
| friend class JUCEApplication; | friend class JUCEApplication; | ||||
| bool quitMessagePosted, quitMessageReceived; | bool quitMessagePosted, quitMessageReceived; | ||||
| @@ -40228,14 +40378,8 @@ protected: | |||||
| private: | private: | ||||
| ButtonStyle style; | ButtonStyle style; | ||||
| Drawable* normalImage; | |||||
| Drawable* overImage; | |||||
| Drawable* downImage; | |||||
| Drawable* disabledImage; | |||||
| Drawable* normalImageOn; | |||||
| Drawable* overImageOn; | |||||
| Drawable* downImageOn; | |||||
| Drawable* disabledImageOn; | |||||
| ScopedPointer <Drawable> normalImage, overImage, downImage, disabledImage; | |||||
| ScopedPointer <Drawable> normalImageOn, overImageOn, downImageOn, disabledImageOn; | |||||
| Colour backgroundOff, backgroundOn; | Colour backgroundOff, backgroundOn; | ||||
| int edgeIndent; | int edgeIndent; | ||||
| @@ -40915,7 +41059,7 @@ protected: | |||||
| private: | private: | ||||
| friend class DragImageComponent; | friend class DragImageComponent; | ||||
| Component* dragImageComponent; | |||||
| ScopedPointer <Component> dragImageComponent; | |||||
| String currentDragDesc; | String currentDragDesc; | ||||
| }; | }; | ||||
| @@ -41470,7 +41614,7 @@ private: | |||||
| const int itemId; | const int itemId; | ||||
| ToolbarEditingMode mode; | ToolbarEditingMode mode; | ||||
| Toolbar::ToolbarItemStyle toolbarStyle; | Toolbar::ToolbarItemStyle toolbarStyle; | ||||
| Component* overlayComp; | |||||
| ScopedPointer <Component> overlayComp; | |||||
| int dragOffsetX, dragOffsetY; | int dragOffsetX, dragOffsetY; | ||||
| bool isActive, isBeingDragged, isBeingUsedAsAButton; | bool isActive, isBeingDragged, isBeingUsedAsAButton; | ||||
| Rectangle contentArea; | Rectangle contentArea; | ||||
| @@ -41531,8 +41675,7 @@ public: | |||||
| juce_UseDebuggingNewOperator | juce_UseDebuggingNewOperator | ||||
| private: | private: | ||||
| Drawable* const normalImage; | |||||
| Drawable* const toggledOnImage; | |||||
| ScopedPointer <Drawable> normalImage, toggledOnImage; | |||||
| ToolbarButton (const ToolbarButton&); | ToolbarButton (const ToolbarButton&); | ||||
| const ToolbarButton& operator= (const ToolbarButton&); | const ToolbarButton& operator= (const ToolbarButton&); | ||||
| @@ -43108,7 +43251,7 @@ private: | |||||
| Label* valueBox; | Label* valueBox; | ||||
| Button* incButton; | Button* incButton; | ||||
| Button* decButton; | Button* decButton; | ||||
| Component* popupDisplay; | |||||
| ScopedPointer <Component> popupDisplay; | |||||
| Component* parentForPopupDisplay; | Component* parentForPopupDisplay; | ||||
| float getLinearSliderPos (const double value); | float getLinearSliderPos (const double value); | ||||
| @@ -43508,7 +43651,7 @@ private: | |||||
| OwnedArray <ColumnInfo> columns; | OwnedArray <ColumnInfo> columns; | ||||
| Array <TableHeaderListener*> listeners; | Array <TableHeaderListener*> listeners; | ||||
| Component* dragOverlayComp; | |||||
| ScopedPointer <Component> dragOverlayComp; | |||||
| bool columnsChanged, columnsResized, sortChanged, menuActive, stretchToFit; | bool columnsChanged, columnsResized, sortChanged, menuActive, stretchToFit; | ||||
| int columnIdBeingResized, columnIdBeingDragged, initialColumnWidth; | int columnIdBeingResized, columnIdBeingDragged, initialColumnWidth; | ||||
| @@ -45619,7 +45762,7 @@ protected: | |||||
| private: | private: | ||||
| DirectoryContentsList* fileList; | |||||
| ScopedPointer <DirectoryContentsList> fileList; | |||||
| const FileFilter* fileFilter; | const FileFilter* fileFilter; | ||||
| int flags; | int flags; | ||||
| @@ -46036,7 +46179,7 @@ protected: | |||||
| private: | private: | ||||
| friend class TopLevelWindowManager; | friend class TopLevelWindowManager; | ||||
| bool useDropShadow, useNativeTitleBar, windowIsActive_; | bool useDropShadow, useNativeTitleBar, windowIsActive_; | ||||
| DropShadower* shadower; | |||||
| ScopedPointer <DropShadower> shadower; | |||||
| void setWindowActive (const bool isNowActive) throw(); | void setWindowActive (const bool isNowActive) throw(); | ||||
| @@ -46740,11 +46883,11 @@ protected: | |||||
| #endif | #endif | ||||
| ResizableCornerComponent* resizableCorner; | |||||
| ResizableBorderComponent* resizableBorder; | |||||
| ScopedPointer <ResizableCornerComponent> resizableCorner; | |||||
| ScopedPointer <ResizableBorderComponent> resizableBorder; | |||||
| private: | private: | ||||
| Component* contentComponent; | |||||
| ScopedPointer <Component> contentComponent; | |||||
| bool resizeToFitContent, fullscreen; | bool resizeToFitContent, fullscreen; | ||||
| ComponentDragger dragger; | ComponentDragger dragger; | ||||
| Rectangle lastNonFullScreenPos; | Rectangle lastNonFullScreenPos; | ||||
| @@ -47635,7 +47778,7 @@ public: | |||||
| private: | private: | ||||
| File fileToLoad; | File fileToLoad; | ||||
| Image* currentThumbnail; | |||||
| ScopedPointer <Image> currentThumbnail; | |||||
| String currentDetails; | String currentDetails; | ||||
| void getThumbSize (int& w, int& h) const; | void getThumbSize (int& w, int& h) const; | ||||
| @@ -48138,7 +48281,7 @@ private: | |||||
| bool reentrant; | bool reentrant; | ||||
| int lastX, lastY, lastWidth, lastHeight; | int lastX, lastY, lastWidth, lastHeight; | ||||
| #ifdef JUCE_DEBUG | #ifdef JUCE_DEBUG | ||||
| ComponentDeletionWatcher* deletionWatcher; | |||||
| ScopedPointer <ComponentDeletionWatcher> deletionWatcher; | |||||
| #endif | #endif | ||||
| void unregister() throw(); | void unregister() throw(); | ||||
| @@ -48936,7 +49079,7 @@ private: | |||||
| int itemUnderMouse, currentPopupIndex, topLevelIndexClicked, indexToShowAgain; | int itemUnderMouse, currentPopupIndex, topLevelIndexClicked, indexToShowAgain; | ||||
| int lastMouseX, lastMouseY; | int lastMouseX, lastMouseY; | ||||
| bool inModalState; | bool inModalState; | ||||
| Component* currentPopup; | |||||
| ScopedPointer <Component> currentPopup; | |||||
| int getItemAt (int x, int y); | int getItemAt (int x, int y); | ||||
| void updateItemUnderMouse (const int x, const int y); | void updateItemUnderMouse (const int x, const int y); | ||||
| @@ -49160,9 +49303,9 @@ public: | |||||
| private: | private: | ||||
| int titleBarHeight, menuBarHeight, requiredButtons; | int titleBarHeight, menuBarHeight, requiredButtons; | ||||
| bool positionTitleBarButtonsOnLeft, drawTitleTextCentred; | bool positionTitleBarButtonsOnLeft, drawTitleTextCentred; | ||||
| Button* titleBarButtons [3]; | |||||
| Image* titleBarIcon; | |||||
| MenuBarComponent* menuBar; | |||||
| ScopedPointer <Button> titleBarButtons [3]; | |||||
| ScopedPointer <Image> titleBarIcon; | |||||
| ScopedPointer <MenuBarComponent> menuBar; | |||||
| MenuBarModel* menuBarModel; | MenuBarModel* menuBarModel; | ||||
| class ButtonListenerProxy : public ButtonListener | class ButtonListenerProxy : public ButtonListener | ||||
| @@ -53112,7 +53255,7 @@ public: | |||||
| private: | private: | ||||
| friend class NSViewComponentInternal; | friend class NSViewComponentInternal; | ||||
| NSViewComponentInternal* info; | |||||
| ScopedPointer <NSViewComponentInternal> info; | |||||
| NSViewComponent (const NSViewComponent&); | NSViewComponent (const NSViewComponent&); | ||||
| const NSViewComponent& operator= (const NSViewComponent&); | const NSViewComponent& operator= (const NSViewComponent&); | ||||
| @@ -53543,7 +53686,7 @@ public: | |||||
| private: | private: | ||||
| String currentPageName; | String currentPageName; | ||||
| Component* currentPage; | |||||
| ScopedPointer <Component> currentPage; | |||||
| int buttonSize; | int buttonSize; | ||||
| PreferencesPanel (const PreferencesPanel&); | PreferencesPanel (const PreferencesPanel&); | ||||
| @@ -54160,7 +54303,6 @@ private: | |||||
| Image* backgroundImage; | Image* backgroundImage; | ||||
| Time earliestTimeToDelete; | Time earliestTimeToDelete; | ||||
| int originalClickCounter; | int originalClickCounter; | ||||
| bool isImageInCache; | |||||
| SplashScreen (const SplashScreen&); | SplashScreen (const SplashScreen&); | ||||
| const SplashScreen& operator= (const SplashScreen&); | const SplashScreen& operator= (const SplashScreen&); | ||||
| @@ -54293,7 +54435,7 @@ private: | |||||
| void timerCallback(); | void timerCallback(); | ||||
| double progress; | double progress; | ||||
| AlertWindow* alertWindow; | |||||
| ScopedPointer <AlertWindow> alertWindow; | |||||
| String message; | String message; | ||||
| CriticalSection messageLock; | CriticalSection messageLock; | ||||
| const int timeOutMsWhenCancelling; | const int timeOutMsWhenCancelling; | ||||
| @@ -54572,7 +54714,7 @@ protected: | |||||
| Image& image; | Image& image; | ||||
| LLGCSavedState* currentState; | |||||
| ScopedPointer <LLGCSavedState> currentState; | |||||
| OwnedArray <LLGCSavedState> stateStack; | OwnedArray <LLGCSavedState> stateStack; | ||||
| LowLevelGraphicsSoftwareRenderer (const LowLevelGraphicsSoftwareRenderer& other); | LowLevelGraphicsSoftwareRenderer (const LowLevelGraphicsSoftwareRenderer& other); | ||||
| @@ -55741,6 +55883,13 @@ public: | |||||
| */ | */ | ||||
| static void release (Image* const imageToRelease); | static void release (Image* const imageToRelease); | ||||
| /** Releases an image if it's in the cache, or deletes it if it isn't cached. | |||||
| This is a handy function to use if you want to delete an image but are afraid that | |||||
| it might be cached. | |||||
| */ | |||||
| static void releaseOrDelete (Image* const imageToRelease); | |||||
| /** Checks whether an image is in the cache or not. | /** Checks whether an image is in the cache or not. | ||||
| @returns true if the image is currently in the cache | @returns true if the image is currently in the cache | ||||
| @@ -49,7 +49,7 @@ ApplicationCommandManager::ApplicationCommandManager() | |||||
| ApplicationCommandManager::~ApplicationCommandManager() | ApplicationCommandManager::~ApplicationCommandManager() | ||||
| { | { | ||||
| Desktop::getInstance().removeFocusChangeListener (this); | Desktop::getInstance().removeFocusChangeListener (this); | ||||
| deleteAndZero (keyMappings); | |||||
| keyMappings = 0; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -321,7 +321,7 @@ private: | |||||
| //============================================================================== | //============================================================================== | ||||
| OwnedArray <ApplicationCommandInfo> commands; | OwnedArray <ApplicationCommandInfo> commands; | ||||
| SortedSet <void*> listeners; | SortedSet <void*> listeners; | ||||
| KeyPressMappingSet* keyMappings; | |||||
| ScopedPointer <KeyPressMappingSet> keyMappings; | |||||
| ApplicationCommandTarget* firstTarget; | ApplicationCommandTarget* firstTarget; | ||||
| void sendListenerInvokeCallback (const ApplicationCommandTarget::InvocationInfo& info) const; | void sendListenerInvokeCallback (const ApplicationCommandTarget::InvocationInfo& info) const; | ||||
| @@ -193,9 +193,8 @@ ApplicationCommandTarget::CommandTargetMessageInvoker::~CommandTargetMessageInvo | |||||
| void ApplicationCommandTarget::CommandTargetMessageInvoker::handleMessage (const Message& message) | void ApplicationCommandTarget::CommandTargetMessageInvoker::handleMessage (const Message& message) | ||||
| { | { | ||||
| InvocationInfo* const info = (InvocationInfo*) message.pointerParameter; | |||||
| const ScopedPointer <InvocationInfo> info ((InvocationInfo*) message.pointerParameter); | |||||
| owner->tryToInvoke (*info, false); | owner->tryToInvoke (*info, false); | ||||
| delete info; | |||||
| } | } | ||||
| @@ -38,9 +38,7 @@ juce_ImplementSingleton (ApplicationProperties) | |||||
| //============================================================================== | //============================================================================== | ||||
| ApplicationProperties::ApplicationProperties() throw() | ApplicationProperties::ApplicationProperties() throw() | ||||
| : userProps (0), | |||||
| commonProps (0), | |||||
| msBeforeSaving (3000), | |||||
| : msBeforeSaving (3000), | |||||
| options (PropertiesFile::storeAsBinary), | options (PropertiesFile::storeAsBinary), | ||||
| commonSettingsAreReadOnly (0) | commonSettingsAreReadOnly (0) | ||||
| { | { | ||||
| @@ -153,8 +151,8 @@ bool ApplicationProperties::saveIfNeeded() | |||||
| void ApplicationProperties::closeFiles() | void ApplicationProperties::closeFiles() | ||||
| { | { | ||||
| deleteAndZero (userProps); | |||||
| deleteAndZero (commonProps); | |||||
| userProps = 0; | |||||
| commonProps = 0; | |||||
| } | } | ||||
| @@ -148,8 +148,7 @@ public: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| PropertiesFile* userProps; | |||||
| PropertiesFile* commonProps; | |||||
| ScopedPointer <PropertiesFile> userProps, commonProps; | |||||
| String appName, fileSuffix, folderName; | String appName, fileSuffix, folderName; | ||||
| int msBeforeSaving, options; | int msBeforeSaving, options; | ||||
| @@ -89,8 +89,6 @@ AudioCDReader::AudioCDReader (const File& volume) | |||||
| AudioCDReader::~AudioCDReader() | AudioCDReader::~AudioCDReader() | ||||
| { | { | ||||
| if (reader != 0) | |||||
| delete reader; | |||||
| } | } | ||||
| static int getTrackNumber (const File& file) | static int getTrackNumber (const File& file) | ||||
| @@ -129,13 +127,10 @@ void AudioCDReader::refreshTrackLengths() | |||||
| if (in != 0) | if (in != 0) | ||||
| { | { | ||||
| AudioFormatReader* const r = format.createReaderFor (in, true); | |||||
| ScopedPointer <AudioFormatReader> r (format.createReaderFor (in, true)); | |||||
| if (r != 0) | if (r != 0) | ||||
| { | |||||
| sample += (int) r->lengthInSamples; | sample += (int) r->lengthInSamples; | ||||
| delete r; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -164,7 +159,7 @@ bool AudioCDReader::readSamples (int** destSamples, int numDestChannels, int sta | |||||
| if (track != currentReaderTrack) | if (track != currentReaderTrack) | ||||
| { | { | ||||
| deleteAndZero (reader); | |||||
| reader = 0; | |||||
| if (tracks [track] != 0) | if (tracks [track] != 0) | ||||
| { | { | ||||
| @@ -155,7 +155,7 @@ private: | |||||
| OwnedArray<File> tracks; | OwnedArray<File> tracks; | ||||
| Array <int> trackStartSamples; | Array <int> trackStartSamples; | ||||
| int currentReaderTrack; | int currentReaderTrack; | ||||
| AudioFormatReader* reader; | |||||
| ScopedPointer <AudioFormatReader> reader; | |||||
| AudioCDReader (const File& volume); | AudioCDReader (const File& volume); | ||||
| public: | public: | ||||
| static int compareElements (const File* const, const File* const) throw(); | static int compareElements (const File* const, const File* const) throw(); | ||||
| @@ -72,8 +72,6 @@ AudioThumbnail::AudioThumbnail (const int orginalSamplesPerThumbnailSample_, | |||||
| AudioThumbnailCache& cacheToUse) | AudioThumbnailCache& cacheToUse) | ||||
| : formatManagerToUse (formatManagerToUse_), | : formatManagerToUse (formatManagerToUse_), | ||||
| cache (cacheToUse), | cache (cacheToUse), | ||||
| source (0), | |||||
| reader (0), | |||||
| orginalSamplesPerThumbnailSample (orginalSamplesPerThumbnailSample_) | orginalSamplesPerThumbnailSample (orginalSamplesPerThumbnailSample_) | ||||
| { | { | ||||
| clear(); | clear(); | ||||
| @@ -84,9 +82,7 @@ AudioThumbnail::~AudioThumbnail() | |||||
| cache.removeThumbnail (this); | cache.removeThumbnail (this); | ||||
| const ScopedLock sl (readerLock); | const ScopedLock sl (readerLock); | ||||
| deleteAndZero (reader); | |||||
| delete source; | |||||
| reader = 0; | |||||
| } | } | ||||
| void AudioThumbnail::setSource (InputSource* const newSource) | void AudioThumbnail::setSource (InputSource* const newSource) | ||||
| @@ -94,9 +90,7 @@ void AudioThumbnail::setSource (InputSource* const newSource) | |||||
| cache.removeThumbnail (this); | cache.removeThumbnail (this); | ||||
| timerCallback(); // stops the timer and deletes the reader | timerCallback(); // stops the timer and deletes the reader | ||||
| delete source; | |||||
| source = newSource; | source = newSource; | ||||
| clear(); | clear(); | ||||
| if (newSource != 0 | if (newSource != 0 | ||||
| @@ -170,7 +164,7 @@ void AudioThumbnail::timerCallback() | |||||
| stopTimer(); | stopTimer(); | ||||
| const ScopedLock sl (readerLock); | const ScopedLock sl (readerLock); | ||||
| deleteAndZero (reader); | |||||
| reader = 0; | |||||
| } | } | ||||
| void AudioThumbnail::clear() | void AudioThumbnail::clear() | ||||
| @@ -152,10 +152,10 @@ public: | |||||
| private: | private: | ||||
| AudioFormatManager& formatManagerToUse; | AudioFormatManager& formatManagerToUse; | ||||
| AudioThumbnailCache& cache; | AudioThumbnailCache& cache; | ||||
| InputSource* source; | |||||
| ScopedPointer <InputSource> source; | |||||
| CriticalSection readerLock; | CriticalSection readerLock; | ||||
| AudioFormatReader* reader; | |||||
| ScopedPointer <AudioFormatReader> reader; | |||||
| MemoryBlock data, cachedLevels; | MemoryBlock data, cachedLevels; | ||||
| int orginalSamplesPerThumbnailSample; | int orginalSamplesPerThumbnailSample; | ||||
| @@ -478,12 +478,12 @@ int OggVorbisAudioFormat::estimateOggFileQuality (const File& source) | |||||
| if (in != 0) | if (in != 0) | ||||
| { | { | ||||
| AudioFormatReader* const r = createReaderFor (in, true); | |||||
| ScopedPointer <AudioFormatReader> r (createReaderFor (in, true)); | |||||
| if (r != 0) | if (r != 0) | ||||
| { | { | ||||
| const int64 numSamps = r->lengthInSamples; | const int64 numSamps = r->lengthInSamples; | ||||
| delete r; | |||||
| r = 0; | |||||
| const int64 fileNumSamps = source.getSize() / 4; | const int64 fileNumSamps = source.getSize() / 4; | ||||
| const double ratio = numSamps / (double) fileNumSamps; | const double ratio = numSamps / (double) fileNumSamps; | ||||
| @@ -798,30 +798,26 @@ static bool juce_slowCopyOfWavFileWithNewMetadata (const File& file, const Strin | |||||
| const File dest (file.getNonexistentSibling()); | const File dest (file.getNonexistentSibling()); | ||||
| OutputStream* outStream = dest.createOutputStream(); | |||||
| if (outStream != 0) | |||||
| { | { | ||||
| AudioFormatReader* reader = wav.createReaderFor (file.createInputStream(), true); | |||||
| ScopedPointer <OutputStream> outStream (dest.createOutputStream()); | |||||
| if (reader != 0) | |||||
| if (outStream != 0) | |||||
| { | { | ||||
| AudioFormatWriter* writer = wav.createWriterFor (outStream, reader->sampleRate, | |||||
| reader->numChannels, reader->bitsPerSample, | |||||
| metadata, 0); | |||||
| ScopedPointer <AudioFormatReader> reader (wav.createReaderFor (file.createInputStream(), true)); | |||||
| if (writer != 0) | |||||
| if (reader != 0) | |||||
| { | { | ||||
| ok = writer->writeFromAudioReader (*reader, 0, -1); | |||||
| ScopedPointer <AudioFormatWriter> writer (wav.createWriterFor (outStream, reader->sampleRate, | |||||
| reader->numChannels, reader->bitsPerSample, | |||||
| metadata, 0)); | |||||
| outStream = 0; | |||||
| delete writer; | |||||
| if (writer != 0) | |||||
| { | |||||
| ok = writer->writeFromAudioReader (*reader, 0, -1); | |||||
| outStream.release(); | |||||
| } | |||||
| } | } | ||||
| delete reader; | |||||
| } | } | ||||
| delete outStream; | |||||
| } | } | ||||
| if (ok) | if (ok) | ||||
| @@ -835,13 +831,13 @@ static bool juce_slowCopyOfWavFileWithNewMetadata (const File& file, const Strin | |||||
| bool WavAudioFormat::replaceMetadataInFile (const File& wavFile, const StringPairArray& newMetadata) | bool WavAudioFormat::replaceMetadataInFile (const File& wavFile, const StringPairArray& newMetadata) | ||||
| { | { | ||||
| WavAudioFormatReader* reader = (WavAudioFormatReader*) createReaderFor (wavFile.createInputStream(), true); | |||||
| ScopedPointer <WavAudioFormatReader> reader ((WavAudioFormatReader*) createReaderFor (wavFile.createInputStream(), true)); | |||||
| if (reader != 0) | if (reader != 0) | ||||
| { | { | ||||
| const int64 bwavPos = reader->bwavChunkStart; | const int64 bwavPos = reader->bwavChunkStart; | ||||
| const int64 bwavSize = reader->bwavSize; | const int64 bwavSize = reader->bwavSize; | ||||
| delete reader; | |||||
| reader = 0; | |||||
| if (bwavSize > 0) | if (bwavSize > 0) | ||||
| { | { | ||||
| @@ -852,11 +848,12 @@ bool WavAudioFormat::replaceMetadataInFile (const File& wavFile, const StringPai | |||||
| // the new one will fit in the space available, so write it directly.. | // the new one will fit in the space available, so write it directly.. | ||||
| const int64 oldSize = wavFile.getSize(); | const int64 oldSize = wavFile.getSize(); | ||||
| FileOutputStream* out = wavFile.createOutputStream(); | |||||
| out->setPosition (bwavPos); | |||||
| out->write (chunk.getData(), chunk.getSize()); | |||||
| out->setPosition (oldSize); | |||||
| delete out; | |||||
| { | |||||
| ScopedPointer <FileOutputStream> out (wavFile.createOutputStream()); | |||||
| out->setPosition (bwavPos); | |||||
| out->write (chunk.getData(), chunk.getSize()); | |||||
| out->setPosition (oldSize); | |||||
| } | |||||
| jassert (wavFile.getSize() == oldSize); | jassert (wavFile.getSize() == oldSize); | ||||
| @@ -29,6 +29,7 @@ BEGIN_JUCE_NAMESPACE | |||||
| #include "juce_AudioTransportSource.h" | #include "juce_AudioTransportSource.h" | ||||
| #include "../../threads/juce_ScopedLock.h" | #include "../../threads/juce_ScopedLock.h" | ||||
| #include "../../containers/juce_ScopedPointer.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| @@ -78,8 +79,8 @@ void AudioTransportSource::setSource (PositionableAudioSource* const newSource, | |||||
| PositionableAudioSource* newPositionableSource = 0; | PositionableAudioSource* newPositionableSource = 0; | ||||
| AudioSource* newMasterSource = 0; | AudioSource* newMasterSource = 0; | ||||
| ResamplingAudioSource* oldResamplerSource = resamplerSource; | |||||
| BufferingAudioSource* oldBufferingSource = bufferingSource; | |||||
| ScopedPointer <ResamplingAudioSource> oldResamplerSource (resamplerSource); | |||||
| ScopedPointer <BufferingAudioSource> oldBufferingSource (bufferingSource); | |||||
| AudioSource* oldMasterSource = masterSource; | AudioSource* oldMasterSource = masterSource; | ||||
| if (newSource != 0) | if (newSource != 0) | ||||
| @@ -121,9 +122,6 @@ void AudioTransportSource::setSource (PositionableAudioSource* const newSource, | |||||
| if (oldMasterSource != 0) | if (oldMasterSource != 0) | ||||
| oldMasterSource->releaseResources(); | oldMasterSource->releaseResources(); | ||||
| delete oldResamplerSource; | |||||
| delete oldBufferingSource; | |||||
| } | } | ||||
| void AudioTransportSource::start() | void AudioTransportSource::start() | ||||
| @@ -59,12 +59,10 @@ AudioDeviceManager::AudioDeviceManager() | |||||
| : currentAudioDevice (0), | : currentAudioDevice (0), | ||||
| numInputChansNeeded (0), | numInputChansNeeded (0), | ||||
| numOutputChansNeeded (2), | numOutputChansNeeded (2), | ||||
| lastExplicitSettings (0), | |||||
| listNeedsScanning (true), | listNeedsScanning (true), | ||||
| useInputNames (false), | useInputNames (false), | ||||
| inputLevelMeasurementEnabledCount (0), | inputLevelMeasurementEnabledCount (0), | ||||
| inputLevel (0), | inputLevel (0), | ||||
| testSound (0), | |||||
| tempBuffer (2, 2), | tempBuffer (2, 2), | ||||
| enabledMidiInputs (4), | enabledMidiInputs (4), | ||||
| midiCallbacks (4), | midiCallbacks (4), | ||||
| @@ -78,10 +76,8 @@ AudioDeviceManager::AudioDeviceManager() | |||||
| AudioDeviceManager::~AudioDeviceManager() | AudioDeviceManager::~AudioDeviceManager() | ||||
| { | { | ||||
| deleteAndZero (currentAudioDevice); | |||||
| deleteAndZero (defaultMidiOutput); | |||||
| delete lastExplicitSettings; | |||||
| delete testSound; | |||||
| currentAudioDevice = 0; | |||||
| defaultMidiOutput = 0; | |||||
| } | } | ||||
| @@ -164,7 +160,6 @@ const String AudioDeviceManager::initialise (const int numInputChannelsNeeded, | |||||
| if (e != 0 && e->hasTagName (T("DEVICESETUP"))) | if (e != 0 && e->hasTagName (T("DEVICESETUP"))) | ||||
| { | { | ||||
| delete lastExplicitSettings; | |||||
| lastExplicitSettings = new XmlElement (*e); | lastExplicitSettings = new XmlElement (*e); | ||||
| String error; | String error; | ||||
| @@ -324,7 +319,7 @@ void AudioDeviceManager::getAudioDeviceSetup (AudioDeviceSetup& setup) | |||||
| void AudioDeviceManager::deleteCurrentDevice() | void AudioDeviceManager::deleteCurrentDevice() | ||||
| { | { | ||||
| deleteAndZero (currentAudioDevice); | |||||
| currentAudioDevice = 0; | |||||
| currentSetup.inputDeviceName = String::empty; | currentSetup.inputDeviceName = String::empty; | ||||
| currentSetup.outputDeviceName = String::empty; | currentSetup.outputDeviceName = String::empty; | ||||
| } | } | ||||
| @@ -526,13 +521,13 @@ void AudioDeviceManager::stopDevice() | |||||
| if (currentAudioDevice != 0) | if (currentAudioDevice != 0) | ||||
| currentAudioDevice->stop(); | currentAudioDevice->stop(); | ||||
| deleteAndZero (testSound); | |||||
| testSound = 0; | |||||
| } | } | ||||
| void AudioDeviceManager::closeAudioDevice() | void AudioDeviceManager::closeAudioDevice() | ||||
| { | { | ||||
| stopDevice(); | stopDevice(); | ||||
| deleteAndZero (currentAudioDevice); | |||||
| currentAudioDevice = 0; | |||||
| } | } | ||||
| void AudioDeviceManager::restartLastAudioDevice() | void AudioDeviceManager::restartLastAudioDevice() | ||||
| @@ -556,7 +551,6 @@ void AudioDeviceManager::restartLastAudioDevice() | |||||
| void AudioDeviceManager::updateXml() | void AudioDeviceManager::updateXml() | ||||
| { | { | ||||
| delete lastExplicitSettings; | |||||
| lastExplicitSettings = new XmlElement (T("DEVICESETUP")); | lastExplicitSettings = new XmlElement (T("DEVICESETUP")); | ||||
| lastExplicitSettings->setAttribute (T("deviceType"), currentDeviceType); | lastExplicitSettings->setAttribute (T("deviceType"), currentDeviceType); | ||||
| @@ -719,10 +713,7 @@ void AudioDeviceManager::audioDeviceIOCallbackInt (const float** inputChannelDat | |||||
| testSoundPosition += numSamps; | testSoundPosition += numSamps; | ||||
| if (testSoundPosition >= testSound->getNumSamples()) | if (testSoundPosition >= testSound->getNumSamples()) | ||||
| { | |||||
| delete testSound; | |||||
| testSound = 0; | testSound = 0; | ||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -887,7 +878,7 @@ void AudioDeviceManager::setDefaultMidiOutput (const String& deviceName) | |||||
| for (int i = oldCallbacks.size(); --i >= 0;) | for (int i = oldCallbacks.size(); --i >= 0;) | ||||
| oldCallbacks.getUnchecked(i)->audioDeviceStopped(); | oldCallbacks.getUnchecked(i)->audioDeviceStopped(); | ||||
| deleteAndZero (defaultMidiOutput); | |||||
| defaultMidiOutput = 0; | |||||
| defaultMidiOutputName = deviceName; | defaultMidiOutputName = deviceName; | ||||
| if (deviceName.isNotEmpty()) | if (deviceName.isNotEmpty()) | ||||
| @@ -936,8 +927,7 @@ void AudioDeviceManager::CallbackHandler::handleIncomingMidiMessage (MidiInput* | |||||
| void AudioDeviceManager::playTestSound() | void AudioDeviceManager::playTestSound() | ||||
| { | { | ||||
| audioCallbackLock.enter(); | audioCallbackLock.enter(); | ||||
| AudioSampleBuffer* oldSound = testSound; | |||||
| testSound = 0; | |||||
| AudioSampleBuffer* oldSound = testSound.release(); | |||||
| audioCallbackLock.exit(); | audioCallbackLock.exit(); | ||||
| delete oldSound; | delete oldSound; | ||||
| @@ -422,17 +422,17 @@ private: | |||||
| OwnedArray <AudioDeviceSetup> lastDeviceTypeConfigs; | OwnedArray <AudioDeviceSetup> lastDeviceTypeConfigs; | ||||
| AudioDeviceSetup currentSetup; | AudioDeviceSetup currentSetup; | ||||
| AudioIODevice* currentAudioDevice; | |||||
| ScopedPointer <AudioIODevice> currentAudioDevice; | |||||
| SortedSet <AudioIODeviceCallback*> callbacks; | SortedSet <AudioIODeviceCallback*> callbacks; | ||||
| int numInputChansNeeded, numOutputChansNeeded; | int numInputChansNeeded, numOutputChansNeeded; | ||||
| String currentDeviceType; | String currentDeviceType; | ||||
| BitArray inputChannels, outputChannels; | BitArray inputChannels, outputChannels; | ||||
| XmlElement* lastExplicitSettings; | |||||
| ScopedPointer <XmlElement> lastExplicitSettings; | |||||
| mutable bool listNeedsScanning; | mutable bool listNeedsScanning; | ||||
| bool useInputNames; | bool useInputNames; | ||||
| int inputLevelMeasurementEnabledCount; | int inputLevelMeasurementEnabledCount; | ||||
| double inputLevel; | double inputLevel; | ||||
| AudioSampleBuffer* testSound; | |||||
| ScopedPointer <AudioSampleBuffer> testSound; | |||||
| int testSoundPosition; | int testSoundPosition; | ||||
| AudioSampleBuffer tempBuffer; | AudioSampleBuffer tempBuffer; | ||||
| @@ -441,7 +441,7 @@ private: | |||||
| Array <MidiInputCallback*> midiCallbacks; | Array <MidiInputCallback*> midiCallbacks; | ||||
| Array <MidiInput*> midiCallbackDevices; | Array <MidiInput*> midiCallbackDevices; | ||||
| String defaultMidiOutputName; | String defaultMidiOutputName; | ||||
| MidiOutput* defaultMidiOutput; | |||||
| ScopedPointer <MidiOutput> defaultMidiOutput; | |||||
| CriticalSection audioCallbackLock, midiCallbackLock; | CriticalSection audioCallbackLock, midiCallbackLock; | ||||
| double cpuUsageMs, timeToCpuScale; | double cpuUsageMs, timeToCpuScale; | ||||
| @@ -44,8 +44,7 @@ struct TimeSigInfo | |||||
| }; | }; | ||||
| MidiFile::MidiFile() throw() | MidiFile::MidiFile() throw() | ||||
| : numTracks (0), | |||||
| timeFormat ((short)(unsigned short)0xe728) | |||||
| : timeFormat ((short) (unsigned short) 0xe728) | |||||
| { | { | ||||
| } | } | ||||
| @@ -56,27 +55,23 @@ MidiFile::~MidiFile() throw() | |||||
| void MidiFile::clear() throw() | void MidiFile::clear() throw() | ||||
| { | { | ||||
| while (numTracks > 0) | |||||
| delete tracks [--numTracks]; | |||||
| tracks.clear(); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| int MidiFile::getNumTracks() const throw() | int MidiFile::getNumTracks() const throw() | ||||
| { | { | ||||
| return numTracks; | |||||
| return tracks.size(); | |||||
| } | } | ||||
| const MidiMessageSequence* MidiFile::getTrack (const int index) const throw() | const MidiMessageSequence* MidiFile::getTrack (const int index) const throw() | ||||
| { | { | ||||
| return (((unsigned int) index) < (unsigned int) numTracks) ? tracks[index] : 0; | |||||
| return tracks [index]; | |||||
| } | } | ||||
| void MidiFile::addTrack (const MidiMessageSequence& trackSequence) throw() | void MidiFile::addTrack (const MidiMessageSequence& trackSequence) throw() | ||||
| { | { | ||||
| jassert (numTracks < numElementsInArray (tracks)); | |||||
| if (numTracks < numElementsInArray (tracks)) | |||||
| tracks [numTracks++] = new MidiMessageSequence (trackSequence); | |||||
| tracks.add (new MidiMessageSequence (trackSequence)); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -99,13 +94,13 @@ void MidiFile::setSmpteTimeFormat (const int framesPerSecond, | |||||
| //============================================================================== | //============================================================================== | ||||
| void MidiFile::findAllTempoEvents (MidiMessageSequence& tempoChangeEvents) const | void MidiFile::findAllTempoEvents (MidiMessageSequence& tempoChangeEvents) const | ||||
| { | { | ||||
| for (int i = numTracks; --i >= 0;) | |||||
| for (int i = tracks.size(); --i >= 0;) | |||||
| { | { | ||||
| const int numEvents = tracks[i]->getNumEvents(); | |||||
| const int numEvents = tracks.getUnchecked(i)->getNumEvents(); | |||||
| for (int j = 0; j < numEvents; ++j) | for (int j = 0; j < numEvents; ++j) | ||||
| { | { | ||||
| const MidiMessage& m = tracks[i]->getEventPointer (j)->message; | |||||
| const MidiMessage& m = tracks.getUnchecked(i)->getEventPointer (j)->message; | |||||
| if (m.isTempoMetaEvent()) | if (m.isTempoMetaEvent()) | ||||
| tempoChangeEvents.addEvent (m); | tempoChangeEvents.addEvent (m); | ||||
| @@ -115,13 +110,13 @@ void MidiFile::findAllTempoEvents (MidiMessageSequence& tempoChangeEvents) const | |||||
| void MidiFile::findAllTimeSigEvents (MidiMessageSequence& timeSigEvents) const | void MidiFile::findAllTimeSigEvents (MidiMessageSequence& timeSigEvents) const | ||||
| { | { | ||||
| for (int i = numTracks; --i >= 0;) | |||||
| for (int i = tracks.size(); --i >= 0;) | |||||
| { | { | ||||
| const int numEvents = tracks[i]->getNumEvents(); | |||||
| const int numEvents = tracks.getUnchecked(i)->getNumEvents(); | |||||
| for (int j = 0; j < numEvents; ++j) | for (int j = 0; j < numEvents; ++j) | ||||
| { | { | ||||
| const MidiMessage& m = tracks[i]->getEventPointer (j)->message; | |||||
| const MidiMessage& m = tracks.getUnchecked(i)->getEventPointer (j)->message; | |||||
| if (m.isTimeSignatureMetaEvent()) | if (m.isTimeSignatureMetaEvent()) | ||||
| timeSigEvents.addEvent (m); | timeSigEvents.addEvent (m); | ||||
| @@ -133,8 +128,8 @@ double MidiFile::getLastTimestamp() const | |||||
| { | { | ||||
| double t = 0.0; | double t = 0.0; | ||||
| for (int i = numTracks; --i >= 0;) | |||||
| t = jmax (t, tracks[i]->getEndTime()); | |||||
| for (int i = tracks.size(); --i >= 0;) | |||||
| t = jmax (t, tracks.getUnchecked(i)->getEndTime()); | |||||
| return t; | return t; | ||||
| } | } | ||||
| @@ -366,9 +361,9 @@ void MidiFile::convertTimestampTicksToSeconds() | |||||
| findAllTempoEvents (tempoEvents); | findAllTempoEvents (tempoEvents); | ||||
| findAllTimeSigEvents (tempoEvents); | findAllTimeSigEvents (tempoEvents); | ||||
| for (int i = 0; i < numTracks; ++i) | |||||
| for (int i = 0; i < tracks.size(); ++i) | |||||
| { | { | ||||
| MidiMessageSequence& ms = *tracks[i]; | |||||
| MidiMessageSequence& ms = *tracks.getUnchecked(i); | |||||
| for (int j = ms.getNumEvents(); --j >= 0;) | for (int j = ms.getNumEvents(); --j >= 0;) | ||||
| { | { | ||||
| @@ -408,10 +403,10 @@ bool MidiFile::writeTo (OutputStream& out) | |||||
| out.writeIntBigEndian ((int) bigEndianInt ("MThd")); | out.writeIntBigEndian ((int) bigEndianInt ("MThd")); | ||||
| out.writeIntBigEndian (6); | out.writeIntBigEndian (6); | ||||
| out.writeShortBigEndian (1); // type | out.writeShortBigEndian (1); // type | ||||
| out.writeShortBigEndian (numTracks); | |||||
| out.writeShortBigEndian (tracks.size()); | |||||
| out.writeShortBigEndian (timeFormat); | out.writeShortBigEndian (timeFormat); | ||||
| for (int i = 0; i < numTracks; ++i) | |||||
| for (int i = 0; i < tracks.size(); ++i) | |||||
| writeTrack (out, i); | writeTrack (out, i); | ||||
| out.flush(); | out.flush(); | ||||
| @@ -182,8 +182,8 @@ public: | |||||
| const MidiMessageSequence::MidiEventHolder* const second) throw(); | const MidiMessageSequence::MidiEventHolder* const second) throw(); | ||||
| private: | private: | ||||
| MidiMessageSequence* tracks [128]; | |||||
| short numTracks, timeFormat; | |||||
| OwnedArray <MidiMessageSequence> tracks; | |||||
| short timeFormat; | |||||
| MidiFile (const MidiFile&); | MidiFile (const MidiFile&); | ||||
| const MidiFile& operator= (const MidiFile&); | const MidiFile& operator= (const MidiFile&); | ||||
| @@ -1193,7 +1193,7 @@ public: | |||||
| ~VSTPluginWindow() | ~VSTPluginWindow() | ||||
| { | { | ||||
| #if JUCE_MAC | #if JUCE_MAC | ||||
| deleteAndZero (innerWrapper); | |||||
| innerWrapper = 0; | |||||
| #else | #else | ||||
| closePluginWindow(); | closePluginWindow(); | ||||
| #endif | #endif | ||||
| @@ -1889,7 +1889,7 @@ private: | |||||
| }; | }; | ||||
| friend class InnerWrapperComponent; | friend class InnerWrapperComponent; | ||||
| InnerWrapperComponent* innerWrapper; | |||||
| ScopedPointer <InnerWrapperComponent> innerWrapper; | |||||
| void resized() | void resized() | ||||
| { | { | ||||
| @@ -2825,7 +2825,7 @@ void VSTPluginFormat::findAllTypesForFile (OwnedArray <PluginDescription>& resul | |||||
| desc.fileOrIdentifier = fileOrIdentifier; | desc.fileOrIdentifier = fileOrIdentifier; | ||||
| desc.uid = 0; | desc.uid = 0; | ||||
| VSTPluginInstance* instance = dynamic_cast <VSTPluginInstance*> (createInstanceFromDescription (desc)); | |||||
| ScopedPointer <VSTPluginInstance> instance (dynamic_cast <VSTPluginInstance*> (createInstanceFromDescription (desc))); | |||||
| if (instance == 0) | if (instance == 0) | ||||
| return; | return; | ||||
| @@ -2892,13 +2892,11 @@ void VSTPluginFormat::findAllTypesForFile (OwnedArray <PluginDescription>& resul | |||||
| { | { | ||||
| // crashed while loading... | // crashed while loading... | ||||
| } | } | ||||
| deleteAndZero (instance); | |||||
| } | } | ||||
| AudioPluginInstance* VSTPluginFormat::createInstanceFromDescription (const PluginDescription& desc) | AudioPluginInstance* VSTPluginFormat::createInstanceFromDescription (const PluginDescription& desc) | ||||
| { | { | ||||
| VSTPluginInstance* result = 0; | |||||
| ScopedPointer <VSTPluginInstance> result; | |||||
| if (fileMightContainThisPluginType (desc.fileOrIdentifier)) | if (fileMightContainThisPluginType (desc.fileOrIdentifier)) | ||||
| { | { | ||||
| @@ -2922,14 +2920,14 @@ AudioPluginInstance* VSTPluginFormat::createInstanceFromDescription (const Plugi | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| deleteAndZero (result); | |||||
| result = 0; | |||||
| } | } | ||||
| } | } | ||||
| previousWorkingDirectory.setAsCurrentWorkingDirectory(); | previousWorkingDirectory.setAsCurrentWorkingDirectory(); | ||||
| } | } | ||||
| return result; | |||||
| return result.release(); | |||||
| } | } | ||||
| bool VSTPluginFormat::fileMightContainThisPluginType (const String& fileOrIdentifier) | bool VSTPluginFormat::fileMightContainThisPluginType (const String& fileOrIdentifier) | ||||
| @@ -47,7 +47,6 @@ SamplerSound::SamplerSound (const String& name_, | |||||
| if (sourceSampleRate <= 0 || source.lengthInSamples <= 0) | if (sourceSampleRate <= 0 || source.lengthInSamples <= 0) | ||||
| { | { | ||||
| data = 0; | |||||
| length = 0; | length = 0; | ||||
| attackSamples = 0; | attackSamples = 0; | ||||
| releaseSamples = 0; | releaseSamples = 0; | ||||
| @@ -68,8 +67,6 @@ SamplerSound::SamplerSound (const String& name_, | |||||
| SamplerSound::~SamplerSound() | SamplerSound::~SamplerSound() | ||||
| { | { | ||||
| delete data; | |||||
| data = 0; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -97,7 +97,7 @@ private: | |||||
| friend class SamplerVoice; | friend class SamplerVoice; | ||||
| String name; | String name; | ||||
| AudioSampleBuffer* data; | |||||
| ScopedPointer <AudioSampleBuffer> data; | |||||
| double sourceSampleRate; | double sourceSampleRate; | ||||
| BitArray midiNotes; | BitArray midiNotes; | ||||
| int length, attackSamples, releaseSamples; | int length, attackSamples, releaseSamples; | ||||
| @@ -29,6 +29,7 @@ | |||||
| #include "juce_ArrayAllocationBase.h" | #include "juce_ArrayAllocationBase.h" | ||||
| #include "juce_ElementComparator.h" | #include "juce_ElementComparator.h" | ||||
| #include "../threads/juce_CriticalSection.h" | #include "../threads/juce_CriticalSection.h" | ||||
| #include "../containers/juce_ScopedPointer.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| @@ -341,7 +342,7 @@ public: | |||||
| { | { | ||||
| if (indexToChange >= 0) | if (indexToChange >= 0) | ||||
| { | { | ||||
| ObjectClass* toDelete = 0; | |||||
| ScopedPointer <ObjectClass> toDelete; | |||||
| lock.enter(); | lock.enter(); | ||||
| if (indexToChange < numUsed) | if (indexToChange < numUsed) | ||||
| @@ -363,8 +364,6 @@ public: | |||||
| } | } | ||||
| lock.exit(); | lock.exit(); | ||||
| delete toDelete; | |||||
| } | } | ||||
| } | } | ||||
| @@ -456,8 +455,8 @@ public: | |||||
| void remove (const int indexToRemove, | void remove (const int indexToRemove, | ||||
| const bool deleteObject = true) | const bool deleteObject = true) | ||||
| { | { | ||||
| ScopedPointer <ObjectClass> toDelete; | |||||
| lock.enter(); | lock.enter(); | ||||
| ObjectClass* toDelete = 0; | |||||
| if (((unsigned int) indexToRemove) < (unsigned int) numUsed) | if (((unsigned int) indexToRemove) < (unsigned int) numUsed) | ||||
| { | { | ||||
| @@ -477,8 +476,6 @@ public: | |||||
| } | } | ||||
| lock.exit(); | lock.exit(); | ||||
| delete toDelete; | |||||
| } | } | ||||
| /** Removes a specified object from the array. | /** Removes a specified object from the array. | ||||
| @@ -0,0 +1,181 @@ | |||||
| /* | |||||
| ============================================================================== | |||||
| 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_SCOPEDPOINTER_JUCEHEADER__ | |||||
| #define __JUCE_SCOPEDPOINTER_JUCEHEADER__ | |||||
| //============================================================================== | |||||
| /** | |||||
| This class holds a pointer which is automatically deleted when this object goes | |||||
| out of scope. | |||||
| Once a pointer has been passed to a ScopedPointer, it will make sure that the pointer | |||||
| gets deleted when the ScopedPointer is deleted. Using the ScopedPointer on the stack or | |||||
| as member variables is a good way to use RAII to avoid accidentally leaking dynamically | |||||
| created objects. | |||||
| A ScopedPointer can be used in pretty much the same way that you'd use a normal pointer | |||||
| to an object. If you use the assignment operator to assign a different object to a | |||||
| ScopedPointer, the old one will be automatically deleted. | |||||
| If you need to get a pointer out of a ScopedPointer without it being deleted, you | |||||
| can use the release() method. | |||||
| */ | |||||
| template <class ObjectType> | |||||
| class ScopedPointer | |||||
| { | |||||
| public: | |||||
| //============================================================================== | |||||
| /** Creates a ScopedPointer containing a null pointer. */ | |||||
| inline ScopedPointer() : object (0) | |||||
| { | |||||
| } | |||||
| /** Creates a ScopedPointer that owns the specified object. */ | |||||
| inline ScopedPointer (ObjectType* const objectToTakePossessionOf) | |||||
| : object (objectToTakePossessionOf) | |||||
| { | |||||
| } | |||||
| /** Creates a ScopedPointer that takes its pointer from another ScopedPointer. | |||||
| Because a pointer can only belong to one ScopedPointer, this transfers | |||||
| the pointer from the other object to this one, and the other object is reset to | |||||
| be a null pointer. | |||||
| */ | |||||
| ScopedPointer (ScopedPointer& objectToTransferFrom) | |||||
| : object (objectToTransferFrom.object) | |||||
| { | |||||
| objectToTransferFrom.object = 0; | |||||
| } | |||||
| /** Destructor. | |||||
| This will delete the object that this ScopedPointer currently refers to. | |||||
| */ | |||||
| inline ~ScopedPointer() { delete object; } | |||||
| /** Changes this ScopedPointer to point to a new object. | |||||
| Because a pointer can only belong to one ScopedPointer, this transfers | |||||
| the pointer from the other object to this one, and the other object is reset to | |||||
| be a null pointer. | |||||
| If this ScopedPointer already points to an object, that object | |||||
| will first be deleted. | |||||
| */ | |||||
| const ScopedPointer& operator= (ScopedPointer& objectToTransferFrom) | |||||
| { | |||||
| if (this != &objectToTransferFrom) | |||||
| { | |||||
| // Two ScopedPointers should never be able to refer to the same object - if | |||||
| // this happens, you must have done something dodgy! | |||||
| jassert (object != objectToTransferFrom.object); | |||||
| ObjectType* const oldObject = object; | |||||
| object = objectToTransferFrom.object; | |||||
| objectToTransferFrom.object = 0; | |||||
| delete oldObject; | |||||
| } | |||||
| return *this; | |||||
| } | |||||
| /** Changes this ScopedPointer to point to a new object. | |||||
| If this ScopedPointer already points to an object, that object | |||||
| will first be deleted. | |||||
| The pointer that you pass is may be null. | |||||
| */ | |||||
| const ScopedPointer& operator= (ObjectType* const newObjectToTakePossessionOf) | |||||
| { | |||||
| if (object != newObjectToTakePossessionOf) | |||||
| { | |||||
| ObjectType* const oldObject = object; | |||||
| object = newObjectToTakePossessionOf; | |||||
| delete oldObject; | |||||
| } | |||||
| return *this; | |||||
| } | |||||
| //============================================================================== | |||||
| /** Returns the object that this ScopedPointer refers to. | |||||
| */ | |||||
| inline operator ObjectType*() const { return object; } | |||||
| /** Returns the object that this ScopedPointer refers to. | |||||
| */ | |||||
| inline ObjectType& operator*() const { return *object; } | |||||
| /** Lets you access methods and properties of the object that this ScopedPointer refers to. */ | |||||
| inline ObjectType* operator->() const { return object; } | |||||
| /** Returns a pointer to the object by casting it to whatever type you need. */ | |||||
| template <class CastType> | |||||
| inline operator CastType*() const { return static_cast <CastType*> (object); } | |||||
| /** Returns a reference to the address of the object that this ScopedPointer refers to. */ | |||||
| inline ObjectType** operator&() const { return (ObjectType**) &object; } | |||||
| //============================================================================== | |||||
| /** Removes the current object from this ScopedPointer without deleting it. | |||||
| This will return the current object, and set the ScopedPointer to a null pointer. | |||||
| */ | |||||
| ObjectType* release() { ObjectType* const o = object; object = 0; return o; } | |||||
| //============================================================================== | |||||
| /** Compares the pointer with another pointer. | |||||
| This can be handy for checking whether this is a null pointer. | |||||
| */ | |||||
| inline bool operator== (const ObjectType* const otherPointer) const { return otherPointer == object; } | |||||
| /** Compares the pointer with another pointer. | |||||
| This can be handy for checking whether this is a null pointer. | |||||
| */ | |||||
| inline bool operator!= (const ObjectType* const otherPointer) const { return otherPointer != object; } | |||||
| //============================================================================== | |||||
| /** Swaps this object with that of another ScopedPointer. | |||||
| The two objects simply exchange their pointers. | |||||
| */ | |||||
| void swapWith (ScopedPointer <ObjectType>& other) | |||||
| { | |||||
| // Two ScopedPointers should never be able to refer to the same object - if | |||||
| // this happens, you must have done something dodgy! | |||||
| jassert (object != other.object); | |||||
| swapVariables (object, other.object); | |||||
| } | |||||
| private: | |||||
| //============================================================================== | |||||
| ObjectType* object; | |||||
| }; | |||||
| #endif // __JUCE_SCOPEDPOINTER_JUCEHEADER__ | |||||
| @@ -32,6 +32,7 @@ BEGIN_JUCE_NAMESPACE | |||||
| #include "../io/files/juce_FileOutputStream.h" | #include "../io/files/juce_FileOutputStream.h" | ||||
| #include "../io/files/juce_FileInputStream.h" | #include "../io/files/juce_FileInputStream.h" | ||||
| #include "../threads/juce_ScopedLock.h" | #include "../threads/juce_ScopedLock.h" | ||||
| #include "../containers/juce_ScopedPointer.h" | |||||
| #include "juce_SystemStats.h" | #include "juce_SystemStats.h" | ||||
| @@ -64,7 +65,6 @@ FileLogger::FileLogger (const File& logFile_, | |||||
| FileLogger::~FileLogger() | FileLogger::~FileLogger() | ||||
| { | { | ||||
| deleteAndZero (logStream); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -93,7 +93,7 @@ void FileLogger::trimFileSize (int maxFileSizeBytes) const | |||||
| if (fileSize > maxFileSizeBytes) | if (fileSize > maxFileSizeBytes) | ||||
| { | { | ||||
| FileInputStream* const in = logFile.createInputStream(); | |||||
| ScopedPointer <FileInputStream> in (logFile.createInputStream()); | |||||
| jassert (in != 0); | jassert (in != 0); | ||||
| if (in != 0) | if (in != 0) | ||||
| @@ -107,7 +107,7 @@ void FileLogger::trimFileSize (int maxFileSizeBytes) const | |||||
| contentToSave.fillWith (0); | contentToSave.fillWith (0); | ||||
| in->read (contentToSave.getData(), maxFileSizeBytes); | in->read (contentToSave.getData(), maxFileSizeBytes); | ||||
| delete in; | |||||
| in = 0; | |||||
| content = contentToSave.toString(); | content = contentToSave.toString(); | ||||
| } | } | ||||
| @@ -97,7 +97,7 @@ public: | |||||
| private: | private: | ||||
| File logFile; | File logFile; | ||||
| CriticalSection logLock; | CriticalSection logLock; | ||||
| FileOutputStream* logStream; | |||||
| ScopedPointer <FileOutputStream> logStream; | |||||
| void trimFileSize (int maxFileSizeBytes) const; | void trimFileSize (int maxFileSizeBytes) const; | ||||
| @@ -48,7 +48,7 @@ void Logger::setCurrentLogger (Logger* const newLogger, | |||||
| Logger* const oldLogger = currentLogger; | Logger* const oldLogger = currentLogger; | ||||
| currentLogger = newLogger; | currentLogger = newLogger; | ||||
| if (deleteOldLogger && (oldLogger != 0)) | |||||
| if (deleteOldLogger) | |||||
| delete oldLogger; | delete oldLogger; | ||||
| } | } | ||||
| @@ -30,6 +30,7 @@ BEGIN_JUCE_NAMESPACE | |||||
| #include "juce_MD5.h" | #include "juce_MD5.h" | ||||
| #include "../io/files/juce_FileInputStream.h" | #include "../io/files/juce_FileInputStream.h" | ||||
| #include "../containers/juce_ScopedPointer.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| @@ -115,17 +116,12 @@ MD5::MD5 (InputStream& input, int numBytesToRead) | |||||
| MD5::MD5 (const File& file) | MD5::MD5 (const File& file) | ||||
| { | { | ||||
| FileInputStream* const fin = file.createInputStream(); | |||||
| const ScopedPointer <FileInputStream> fin (file.createInputStream()); | |||||
| if (fin != 0) | if (fin != 0) | ||||
| { | |||||
| processStream (*fin, -1); | processStream (*fin, -1); | ||||
| delete fin; | |||||
| } | |||||
| else | else | ||||
| { | |||||
| zeromem (result, sizeof (result)); | zeromem (result, sizeof (result)); | ||||
| } | |||||
| } | } | ||||
| MD5::~MD5() | MD5::~MD5() | ||||
| @@ -29,14 +29,13 @@ BEGIN_JUCE_NAMESPACE | |||||
| #include "juce_InterprocessConnection.h" | #include "juce_InterprocessConnection.h" | ||||
| #include "../threads/juce_ScopedLock.h" | #include "../threads/juce_ScopedLock.h" | ||||
| #include "../containers/juce_ScopedPointer.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| InterprocessConnection::InterprocessConnection (const bool callbacksOnMessageThread, | InterprocessConnection::InterprocessConnection (const bool callbacksOnMessageThread, | ||||
| const uint32 magicMessageHeaderNumber) | const uint32 magicMessageHeaderNumber) | ||||
| : Thread ("Juce IPC connection"), | : Thread ("Juce IPC connection"), | ||||
| socket (0), | |||||
| pipe (0), | |||||
| callbackConnectionState (false), | callbackConnectionState (false), | ||||
| useMessageThread (callbacksOnMessageThread), | useMessageThread (callbacksOnMessageThread), | ||||
| magicMessageHeader (magicMessageHeaderNumber), | magicMessageHeader (magicMessageHeaderNumber), | ||||
| @@ -69,7 +68,7 @@ bool InterprocessConnection::connectToSocket (const String& hostName, | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| deleteAndZero (socket); | |||||
| socket = 0; | |||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| @@ -79,20 +78,17 @@ bool InterprocessConnection::connectToPipe (const String& pipeName, | |||||
| { | { | ||||
| disconnect(); | disconnect(); | ||||
| NamedPipe* const newPipe = new NamedPipe(); | |||||
| ScopedPointer <NamedPipe> newPipe (new NamedPipe()); | |||||
| if (newPipe->openExisting (pipeName)) | if (newPipe->openExisting (pipeName)) | ||||
| { | { | ||||
| const ScopedLock sl (pipeAndSocketLock); | const ScopedLock sl (pipeAndSocketLock); | ||||
| pipeReceiveMessageTimeout = pipeReceiveMessageTimeoutMs; | pipeReceiveMessageTimeout = pipeReceiveMessageTimeoutMs; | ||||
| initialiseWithPipe (newPipe); | |||||
| initialiseWithPipe (newPipe.release()); | |||||
| return true; | return true; | ||||
| } | } | ||||
| else | |||||
| { | |||||
| delete newPipe; | |||||
| return false; | |||||
| } | |||||
| return false; | |||||
| } | } | ||||
| bool InterprocessConnection::createPipe (const String& pipeName, | bool InterprocessConnection::createPipe (const String& pipeName, | ||||
| @@ -100,20 +96,17 @@ bool InterprocessConnection::createPipe (const String& pipeName, | |||||
| { | { | ||||
| disconnect(); | disconnect(); | ||||
| NamedPipe* const newPipe = new NamedPipe(); | |||||
| ScopedPointer <NamedPipe> newPipe (new NamedPipe()); | |||||
| if (newPipe->createNewPipe (pipeName)) | if (newPipe->createNewPipe (pipeName)) | ||||
| { | { | ||||
| const ScopedLock sl (pipeAndSocketLock); | const ScopedLock sl (pipeAndSocketLock); | ||||
| pipeReceiveMessageTimeout = pipeReceiveMessageTimeoutMs; | pipeReceiveMessageTimeout = pipeReceiveMessageTimeoutMs; | ||||
| initialiseWithPipe (newPipe); | |||||
| initialiseWithPipe (newPipe.release()); | |||||
| return true; | return true; | ||||
| } | } | ||||
| else | |||||
| { | |||||
| delete newPipe; | |||||
| return false; | |||||
| } | |||||
| return false; | |||||
| } | } | ||||
| void InterprocessConnection::disconnect() | void InterprocessConnection::disconnect() | ||||
| @@ -131,8 +124,8 @@ void InterprocessConnection::disconnect() | |||||
| { | { | ||||
| const ScopedLock sl (pipeAndSocketLock); | const ScopedLock sl (pipeAndSocketLock); | ||||
| deleteAndZero (socket); | |||||
| deleteAndZero (pipe); | |||||
| socket = 0; | |||||
| pipe = 0; | |||||
| } | } | ||||
| connectionLostInt(); | connectionLostInt(); | ||||
| @@ -223,12 +216,11 @@ void InterprocessConnection::handleMessage (const Message& message) | |||||
| switch (message.intParameter2) | switch (message.intParameter2) | ||||
| { | { | ||||
| case 0: | case 0: | ||||
| { | |||||
| MemoryBlock* const data = (MemoryBlock*) message.pointerParameter; | |||||
| messageReceived (*data); | |||||
| delete data; | |||||
| break; | |||||
| } | |||||
| { | |||||
| ScopedPointer <MemoryBlock> data ((MemoryBlock*) message.pointerParameter); | |||||
| messageReceived (*data); | |||||
| break; | |||||
| } | |||||
| case 1: | case 1: | ||||
| connectionMade(); | connectionMade(); | ||||
| @@ -320,7 +312,7 @@ bool InterprocessConnection::readNextMessageInt() | |||||
| { | { | ||||
| { | { | ||||
| const ScopedLock sl (pipeAndSocketLock); | const ScopedLock sl (pipeAndSocketLock); | ||||
| deleteAndZero (socket); | |||||
| socket = 0; | |||||
| } | } | ||||
| connectionLostInt(); | connectionLostInt(); | ||||
| @@ -342,7 +334,7 @@ void InterprocessConnection::run() | |||||
| { | { | ||||
| { | { | ||||
| const ScopedLock sl (pipeAndSocketLock); | const ScopedLock sl (pipeAndSocketLock); | ||||
| deleteAndZero (socket); | |||||
| socket = 0; | |||||
| } | } | ||||
| connectionLostInt(); | connectionLostInt(); | ||||
| @@ -364,7 +356,7 @@ void InterprocessConnection::run() | |||||
| { | { | ||||
| { | { | ||||
| const ScopedLock sl (pipeAndSocketLock); | const ScopedLock sl (pipeAndSocketLock); | ||||
| deleteAndZero (pipe); | |||||
| pipe = 0; | |||||
| } | } | ||||
| connectionLostInt(); | connectionLostInt(); | ||||
| @@ -30,6 +30,7 @@ | |||||
| #include "../threads/juce_Thread.h" | #include "../threads/juce_Thread.h" | ||||
| #include "../io/network/juce_Socket.h" | #include "../io/network/juce_Socket.h" | ||||
| #include "../io/files/juce_NamedPipe.h" | #include "../io/files/juce_NamedPipe.h" | ||||
| #include "../containers/juce_ScopedPointer.h" | |||||
| class InterprocessConnectionServer; | class InterprocessConnectionServer; | ||||
| @@ -186,8 +187,8 @@ public: | |||||
| private: | private: | ||||
| CriticalSection pipeAndSocketLock; | CriticalSection pipeAndSocketLock; | ||||
| StreamingSocket* socket; | |||||
| NamedPipe* pipe; | |||||
| ScopedPointer <StreamingSocket> socket; | |||||
| ScopedPointer <NamedPipe> pipe; | |||||
| bool callbackConnectionState; | bool callbackConnectionState; | ||||
| const bool useMessageThread; | const bool useMessageThread; | ||||
| const uint32 magicMessageHeader; | const uint32 magicMessageHeader; | ||||
| @@ -28,12 +28,12 @@ | |||||
| BEGIN_JUCE_NAMESPACE | BEGIN_JUCE_NAMESPACE | ||||
| #include "juce_InterprocessConnectionServer.h" | #include "juce_InterprocessConnectionServer.h" | ||||
| #include "../containers/juce_ScopedPointer.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| InterprocessConnectionServer::InterprocessConnectionServer() | InterprocessConnectionServer::InterprocessConnectionServer() | ||||
| : Thread ("Juce IPC server"), | |||||
| socket (0) | |||||
| : Thread ("Juce IPC server") | |||||
| { | { | ||||
| } | } | ||||
| @@ -55,7 +55,7 @@ bool InterprocessConnectionServer::beginWaitingForSocket (const int portNumber) | |||||
| return true; | return true; | ||||
| } | } | ||||
| deleteAndZero (socket); | |||||
| socket = 0; | |||||
| return false; | return false; | ||||
| } | } | ||||
| @@ -67,28 +67,21 @@ void InterprocessConnectionServer::stop() | |||||
| socket->close(); | socket->close(); | ||||
| stopThread (4000); | stopThread (4000); | ||||
| deleteAndZero (socket); | |||||
| socket = 0; | |||||
| } | } | ||||
| void InterprocessConnectionServer::run() | void InterprocessConnectionServer::run() | ||||
| { | { | ||||
| while ((! threadShouldExit()) && socket != 0) | while ((! threadShouldExit()) && socket != 0) | ||||
| { | { | ||||
| StreamingSocket* const clientSocket = socket->waitForNextConnection(); | |||||
| ScopedPointer <StreamingSocket> clientSocket (socket->waitForNextConnection()); | |||||
| if (clientSocket != 0) | if (clientSocket != 0) | ||||
| { | { | ||||
| InterprocessConnection* newConnection = createConnectionObject(); | InterprocessConnection* newConnection = createConnectionObject(); | ||||
| if (newConnection != 0) | if (newConnection != 0) | ||||
| { | |||||
| newConnection->initialiseWithSocket (clientSocket); | |||||
| } | |||||
| else | |||||
| { | |||||
| delete clientSocket; | |||||
| } | |||||
| newConnection->initialiseWithSocket (clientSocket.release()); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -88,7 +88,7 @@ public: | |||||
| juce_UseDebuggingNewOperator | juce_UseDebuggingNewOperator | ||||
| private: | private: | ||||
| StreamingSocket* volatile socket; | |||||
| ScopedPointer <StreamingSocket> socket; | |||||
| void run(); | void run(); | ||||
| @@ -47,8 +47,7 @@ MessageManager* MessageManager::instance = 0; | |||||
| static const int quitMessageId = 0xfffff321; | static const int quitMessageId = 0xfffff321; | ||||
| MessageManager::MessageManager() throw() | MessageManager::MessageManager() throw() | ||||
| : broadcastListeners (0), | |||||
| quitMessagePosted (false), | |||||
| : quitMessagePosted (false), | |||||
| quitMessageReceived (false), | quitMessageReceived (false), | ||||
| threadWithLock (0) | threadWithLock (0) | ||||
| { | { | ||||
| @@ -57,7 +56,7 @@ MessageManager::MessageManager() throw() | |||||
| MessageManager::~MessageManager() throw() | MessageManager::~MessageManager() throw() | ||||
| { | { | ||||
| deleteAndZero (broadcastListeners); | |||||
| broadcastListeners = 0; | |||||
| doPlatformSpecificShutdown(); | doPlatformSpecificShutdown(); | ||||
| @@ -102,7 +101,7 @@ void MessageManager::postCallbackMessage (Message* const message) | |||||
| // not for public use.. | // not for public use.. | ||||
| void MessageManager::deliverMessage (void* message) | void MessageManager::deliverMessage (void* message) | ||||
| { | { | ||||
| Message* const m = (Message*) message; | |||||
| const ScopedPointer <Message> m ((Message*) message); | |||||
| MessageListener* const recipient = m->messageRecipient; | MessageListener* const recipient = m->messageRecipient; | ||||
| JUCE_TRY | JUCE_TRY | ||||
| @@ -119,7 +118,7 @@ void MessageManager::deliverMessage (void* message) | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| CallbackMessage* const cm = dynamic_cast <CallbackMessage*> (m); | |||||
| CallbackMessage* const cm = dynamic_cast <CallbackMessage*> ((Message*) m); | |||||
| if (cm != 0) | if (cm != 0) | ||||
| cm->messageCallback(); | cm->messageCallback(); | ||||
| @@ -127,8 +126,6 @@ void MessageManager::deliverMessage (void* message) | |||||
| } | } | ||||
| } | } | ||||
| JUCE_CATCH_EXCEPTION | JUCE_CATCH_EXCEPTION | ||||
| delete m; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -174,8 +174,8 @@ private: | |||||
| friend class CallbackMessage; | friend class CallbackMessage; | ||||
| static MessageManager* instance; | static MessageManager* instance; | ||||
| SortedSet<const MessageListener*> messageListeners; | |||||
| ActionListenerList* broadcastListeners; | |||||
| SortedSet <const MessageListener*> messageListeners; | |||||
| ScopedPointer <ActionListenerList> broadcastListeners; | |||||
| friend class JUCEApplication; | friend class JUCEApplication; | ||||
| bool quitMessagePosted, quitMessageReceived; | bool quitMessagePosted, quitMessageReceived; | ||||
| @@ -40,7 +40,6 @@ Button::Button (const String& name) | |||||
| keySource (0), | keySource (0), | ||||
| text (name), | text (name), | ||||
| buttonListeners (2), | buttonListeners (2), | ||||
| repeatTimer (0), | |||||
| buttonPressTime (0), | buttonPressTime (0), | ||||
| lastTimeCallbackTime (0), | lastTimeCallbackTime (0), | ||||
| commandManagerToUse (0), | commandManagerToUse (0), | ||||
| @@ -67,7 +66,7 @@ Button::~Button() | |||||
| if (commandManagerToUse != 0) | if (commandManagerToUse != 0) | ||||
| commandManagerToUse->removeListener (this); | commandManagerToUse->removeListener (this); | ||||
| delete repeatTimer; | |||||
| repeatTimer = 0; | |||||
| clearShortcuts(); | clearShortcuts(); | ||||
| } | } | ||||
| @@ -464,7 +464,7 @@ private: | |||||
| SortedSet <void*> buttonListeners; | SortedSet <void*> buttonListeners; | ||||
| friend class InternalButtonRepeatTimer; | friend class InternalButtonRepeatTimer; | ||||
| Timer* repeatTimer; | |||||
| ScopedPointer <Timer> repeatTimer; | |||||
| uint32 buttonPressTime, lastTimeCallbackTime; | uint32 buttonPressTime, lastTimeCallbackTime; | ||||
| ApplicationCommandManager* commandManagerToUse; | ApplicationCommandManager* commandManagerToUse; | ||||
| int autoRepeatDelay, autoRepeatSpeed, autoRepeatMinimumDelay; | int autoRepeatDelay, autoRepeatSpeed, autoRepeatMinimumDelay; | ||||
| @@ -36,14 +36,6 @@ DrawableButton::DrawableButton (const String& name, | |||||
| const DrawableButton::ButtonStyle buttonStyle) | const DrawableButton::ButtonStyle buttonStyle) | ||||
| : Button (name), | : Button (name), | ||||
| style (buttonStyle), | style (buttonStyle), | ||||
| normalImage (0), | |||||
| overImage (0), | |||||
| downImage (0), | |||||
| disabledImage (0), | |||||
| normalImageOn (0), | |||||
| overImageOn (0), | |||||
| downImageOn (0), | |||||
| disabledImageOn (0), | |||||
| edgeIndent (3) | edgeIndent (3) | ||||
| { | { | ||||
| if (buttonStyle == ImageOnButtonBackground) | if (buttonStyle == ImageOnButtonBackground) | ||||
| @@ -66,14 +58,6 @@ DrawableButton::~DrawableButton() | |||||
| //============================================================================== | //============================================================================== | ||||
| void DrawableButton::deleteImages() | void DrawableButton::deleteImages() | ||||
| { | { | ||||
| deleteAndZero (normalImage); | |||||
| deleteAndZero (overImage); | |||||
| deleteAndZero (downImage); | |||||
| deleteAndZero (disabledImage); | |||||
| deleteAndZero (normalImageOn); | |||||
| deleteAndZero (overImageOn); | |||||
| deleteAndZero (downImageOn); | |||||
| deleteAndZero (disabledImageOn); | |||||
| } | } | ||||
| void DrawableButton::setImages (const Drawable* normal, | void DrawableButton::setImages (const Drawable* normal, | ||||
| @@ -165,14 +165,8 @@ protected: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| ButtonStyle style; | ButtonStyle style; | ||||
| Drawable* normalImage; | |||||
| Drawable* overImage; | |||||
| Drawable* downImage; | |||||
| Drawable* disabledImage; | |||||
| Drawable* normalImageOn; | |||||
| Drawable* overImageOn; | |||||
| Drawable* downImageOn; | |||||
| Drawable* disabledImageOn; | |||||
| ScopedPointer <Drawable> normalImage, overImage, downImage, disabledImage; | |||||
| ScopedPointer <Drawable> normalImageOn, overImageOn, downImageOn, disabledImageOn; | |||||
| Colour backgroundOff, backgroundOn; | Colour backgroundOff, backgroundOn; | ||||
| int edgeIndent; | int edgeIndent; | ||||
| @@ -55,29 +55,9 @@ ImageButton::~ImageButton() | |||||
| void ImageButton::deleteImages() | void ImageButton::deleteImages() | ||||
| { | { | ||||
| if (normalImage != 0) | |||||
| { | |||||
| if (ImageCache::isImageInCache (normalImage)) | |||||
| ImageCache::release (normalImage); | |||||
| else | |||||
| delete normalImage; | |||||
| } | |||||
| if (overImage != 0) | |||||
| { | |||||
| if (ImageCache::isImageInCache (overImage)) | |||||
| ImageCache::release (overImage); | |||||
| else | |||||
| delete overImage; | |||||
| } | |||||
| if (downImage != 0) | |||||
| { | |||||
| if (ImageCache::isImageInCache (downImage)) | |||||
| ImageCache::release (downImage); | |||||
| else | |||||
| delete downImage; | |||||
| } | |||||
| ImageCache::releaseOrDelete (normalImage); | |||||
| ImageCache::releaseOrDelete (overImage); | |||||
| ImageCache::releaseOrDelete (downImage); | |||||
| } | } | ||||
| void ImageButton::setImages (const bool resizeButtonNowToFitThisImage, | void ImageButton::setImages (const bool resizeButtonNowToFitThisImage, | ||||
| @@ -46,8 +46,6 @@ ToolbarButton::ToolbarButton (const int itemId_, | |||||
| ToolbarButton::~ToolbarButton() | ToolbarButton::~ToolbarButton() | ||||
| { | { | ||||
| delete normalImage; | |||||
| delete toggledOnImage; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -81,8 +81,7 @@ public: | |||||
| juce_UseDebuggingNewOperator | juce_UseDebuggingNewOperator | ||||
| private: | private: | ||||
| Drawable* const normalImage; | |||||
| Drawable* const toggledOnImage; | |||||
| ScopedPointer <Drawable> normalImage, toggledOnImage; | |||||
| ToolbarButton (const ToolbarButton&); | ToolbarButton (const ToolbarButton&); | ||||
| const ToolbarButton& operator= (const ToolbarButton&); | const ToolbarButton& operator= (const ToolbarButton&); | ||||
| @@ -38,10 +38,8 @@ Label::Label (const String& componentName, | |||||
| text (labelText), | text (labelText), | ||||
| font (15.0f), | font (15.0f), | ||||
| justification (Justification::centredLeft), | justification (Justification::centredLeft), | ||||
| editor (0), | |||||
| listeners (2), | listeners (2), | ||||
| ownerComponent (0), | ownerComponent (0), | ||||
| deletionWatcher (0), | |||||
| horizontalBorderSize (3), | horizontalBorderSize (3), | ||||
| verticalBorderSize (1), | verticalBorderSize (1), | ||||
| minimumHorizontalScale (0.7f), | minimumHorizontalScale (0.7f), | ||||
| @@ -59,10 +57,7 @@ Label::~Label() | |||||
| if (ownerComponent != 0 && ! deletionWatcher->hasBeenDeleted()) | if (ownerComponent != 0 && ! deletionWatcher->hasBeenDeleted()) | ||||
| ownerComponent->removeComponentListener (this); | ownerComponent->removeComponentListener (this); | ||||
| deleteAndZero (deletionWatcher); | |||||
| if (editor != 0) | |||||
| delete editor; | |||||
| editor = 0; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -136,7 +131,7 @@ void Label::attachToComponent (Component* owner, | |||||
| if (ownerComponent != 0 && ! deletionWatcher->hasBeenDeleted()) | if (ownerComponent != 0 && ! deletionWatcher->hasBeenDeleted()) | ||||
| ownerComponent->removeComponentListener (this); | ownerComponent->removeComponentListener (this); | ||||
| deleteAndZero (deletionWatcher); | |||||
| deletionWatcher = 0; | |||||
| ownerComponent = owner; | ownerComponent = owner; | ||||
| leftOfOwnerComp = onLeft; | leftOfOwnerComp = onLeft; | ||||
| @@ -251,7 +246,7 @@ void Label::hideEditor (const bool discardCurrentEditorContents) | |||||
| const bool changed = (! discardCurrentEditorContents) | const bool changed = (! discardCurrentEditorContents) | ||||
| && updateFromTextEditorContents(); | && updateFromTextEditorContents(); | ||||
| deleteAndZero (editor); | |||||
| editor = 0; | |||||
| repaint(); | repaint(); | ||||
| if (changed) | if (changed) | ||||
| @@ -316,10 +316,10 @@ private: | |||||
| String text; | String text; | ||||
| Font font; | Font font; | ||||
| Justification justification; | Justification justification; | ||||
| TextEditor* editor; | |||||
| ScopedPointer <TextEditor> editor; | |||||
| SortedSet <void*> listeners; | SortedSet <void*> listeners; | ||||
| Component* ownerComponent; | Component* ownerComponent; | ||||
| ComponentDeletionWatcher* deletionWatcher; | |||||
| ScopedPointer <ComponentDeletionWatcher> deletionWatcher; | |||||
| int horizontalBorderSize, verticalBorderSize; | int horizontalBorderSize, verticalBorderSize; | ||||
| float minimumHorizontalScale; | float minimumHorizontalScale; | ||||
| bool editSingleClick : 1; | bool editSingleClick : 1; | ||||
| @@ -872,9 +872,7 @@ void ListBox::setHeaderComponent (Component* const newHeaderComponent) | |||||
| { | { | ||||
| if (headerComponent != newHeaderComponent) | if (headerComponent != newHeaderComponent) | ||||
| { | { | ||||
| if (headerComponent != 0) | |||||
| delete headerComponent; | |||||
| delete headerComponent; | |||||
| headerComponent = newHeaderComponent; | headerComponent = newHeaderComponent; | ||||
| addAndMakeVisible (newHeaderComponent); | addAndMakeVisible (newHeaderComponent); | ||||
| @@ -141,7 +141,7 @@ Slider::Slider (const String& name) | |||||
| Slider::~Slider() | Slider::~Slider() | ||||
| { | { | ||||
| deleteAndZero (popupDisplay); | |||||
| popupDisplay = 0; | |||||
| deleteAllChildren(); | deleteAllChildren(); | ||||
| } | } | ||||
| @@ -1099,7 +1099,7 @@ void Slider::mouseUp (const MouseEvent&) | |||||
| sendDragEnd(); | sendDragEnd(); | ||||
| deleteAndZero (popupDisplay); | |||||
| popupDisplay = 0; | |||||
| if (style == IncDecButtons) | if (style == IncDecButtons) | ||||
| { | { | ||||
| @@ -751,7 +751,7 @@ private: | |||||
| Label* valueBox; | Label* valueBox; | ||||
| Button* incButton; | Button* incButton; | ||||
| Button* decButton; | Button* decButton; | ||||
| Component* popupDisplay; | |||||
| ScopedPointer <Component> popupDisplay; | |||||
| Component* parentForPopupDisplay; | Component* parentForPopupDisplay; | ||||
| float getLinearSliderPos (const double value); | float getLinearSliderPos (const double value); | ||||
| @@ -47,7 +47,6 @@ public: | |||||
| ~DragOverlayComp() | ~DragOverlayComp() | ||||
| { | { | ||||
| delete image; | |||||
| } | } | ||||
| void paint (Graphics& g) | void paint (Graphics& g) | ||||
| @@ -56,7 +55,7 @@ public: | |||||
| } | } | ||||
| private: | private: | ||||
| Image* image; | |||||
| ScopedPointer <Image> image; | |||||
| DragOverlayComp (const DragOverlayComp&); | DragOverlayComp (const DragOverlayComp&); | ||||
| const DragOverlayComp& operator= (const DragOverlayComp&); | const DragOverlayComp& operator= (const DragOverlayComp&); | ||||
| @@ -66,7 +65,6 @@ private: | |||||
| //============================================================================== | //============================================================================== | ||||
| TableHeaderComponent::TableHeaderComponent() | TableHeaderComponent::TableHeaderComponent() | ||||
| : listeners (2), | : listeners (2), | ||||
| dragOverlayComp (0), | |||||
| columnsChanged (false), | columnsChanged (false), | ||||
| columnsResized (false), | columnsResized (false), | ||||
| sortChanged (false), | sortChanged (false), | ||||
| @@ -81,7 +79,7 @@ TableHeaderComponent::TableHeaderComponent() | |||||
| TableHeaderComponent::~TableHeaderComponent() | TableHeaderComponent::~TableHeaderComponent() | ||||
| { | { | ||||
| delete dragOverlayComp; | |||||
| dragOverlayComp = 0; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -465,7 +463,7 @@ const String TableHeaderComponent::toString() const | |||||
| void TableHeaderComponent::restoreFromString (const String& storedVersion) | void TableHeaderComponent::restoreFromString (const String& storedVersion) | ||||
| { | { | ||||
| XmlDocument doc (storedVersion); | XmlDocument doc (storedVersion); | ||||
| XmlElement* const storedXml = doc.getDocumentElement(); | |||||
| ScopedPointer <XmlElement> storedXml (doc.getDocumentElement()); | |||||
| int index = 0; | int index = 0; | ||||
| @@ -493,8 +491,6 @@ void TableHeaderComponent::restoreFromString (const String& storedVersion) | |||||
| setSortColumnId (storedXml->getIntAttribute (T("sortedCol")), | setSortColumnId (storedXml->getIntAttribute (T("sortedCol")), | ||||
| storedXml->getBoolAttribute (T("sortForwards"), true)); | storedXml->getBoolAttribute (T("sortForwards"), true)); | ||||
| } | } | ||||
| delete storedXml; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -619,7 +615,7 @@ void TableHeaderComponent::mouseDrag (const MouseEvent& e) | |||||
| && columnIdBeingDragged == 0 | && columnIdBeingDragged == 0 | ||||
| && ! (e.mouseWasClicked() || e.mods.isPopupMenu())) | && ! (e.mouseWasClicked() || e.mods.isPopupMenu())) | ||||
| { | { | ||||
| deleteAndZero (dragOverlayComp); | |||||
| dragOverlayComp = 0; | |||||
| columnIdBeingResized = getResizeDraggerAt (e.getMouseDownX()); | columnIdBeingResized = getResizeDraggerAt (e.getMouseDownX()); | ||||
| @@ -799,7 +795,7 @@ void TableHeaderComponent::mouseUp (const MouseEvent& e) | |||||
| if (columnIdUnderMouse != 0 && e.mouseWasClicked() && ! e.mods.isPopupMenu()) | if (columnIdUnderMouse != 0 && e.mouseWasClicked() && ! e.mods.isPopupMenu()) | ||||
| columnClicked (columnIdUnderMouse, e.mods); | columnClicked (columnIdUnderMouse, e.mods); | ||||
| deleteAndZero (dragOverlayComp); | |||||
| dragOverlayComp = 0; | |||||
| } | } | ||||
| const MouseCursor TableHeaderComponent::getMouseCursor() | const MouseCursor TableHeaderComponent::getMouseCursor() | ||||
| @@ -413,7 +413,7 @@ private: | |||||
| OwnedArray <ColumnInfo> columns; | OwnedArray <ColumnInfo> columns; | ||||
| Array <TableHeaderListener*> listeners; | Array <TableHeaderListener*> listeners; | ||||
| Component* dragOverlayComp; | |||||
| ScopedPointer <Component> dragOverlayComp; | |||||
| bool columnsChanged, columnsResized, sortChanged, menuActive, stretchToFit; | bool columnsChanged, columnsResized, sortChanged, menuActive, stretchToFit; | ||||
| int columnIdBeingResized, columnIdBeingDragged, initialColumnWidth; | int columnIdBeingResized, columnIdBeingDragged, initialColumnWidth; | ||||
| @@ -102,10 +102,7 @@ public: | |||||
| void clear() throw() | void clear() throw() | ||||
| { | { | ||||
| for (int i = atoms.size(); --i >= 0;) | for (int i = atoms.size(); --i >= 0;) | ||||
| { | |||||
| TextAtom* const atom = getAtom(i); | |||||
| delete atom; | |||||
| } | |||||
| delete getAtom(i); | |||||
| atoms.clear(); | atoms.clear(); | ||||
| } | } | ||||
| @@ -153,7 +153,6 @@ ToolbarItemComponent::ToolbarItemComponent (const int itemId_, | |||||
| itemId (itemId_), | itemId (itemId_), | ||||
| mode (normalMode), | mode (normalMode), | ||||
| toolbarStyle (Toolbar::iconsOnly), | toolbarStyle (Toolbar::iconsOnly), | ||||
| overlayComp (0), | |||||
| dragOffsetX (0), | dragOffsetX (0), | ||||
| dragOffsetY (0), | dragOffsetY (0), | ||||
| isActive (true), | isActive (true), | ||||
| @@ -167,7 +166,7 @@ ToolbarItemComponent::ToolbarItemComponent (const int itemId_, | |||||
| ToolbarItemComponent::~ToolbarItemComponent() | ToolbarItemComponent::~ToolbarItemComponent() | ||||
| { | { | ||||
| jassert (overlayComp == 0 || overlayComp->isValidComponent()); | jassert (overlayComp == 0 || overlayComp->isValidComponent()); | ||||
| delete overlayComp; | |||||
| overlayComp = 0; | |||||
| } | } | ||||
| Toolbar* ToolbarItemComponent::getToolbar() const | Toolbar* ToolbarItemComponent::getToolbar() const | ||||
| @@ -255,7 +254,6 @@ void ToolbarItemComponent::setEditingMode (const ToolbarEditingMode newMode) | |||||
| if (mode == normalMode) | if (mode == normalMode) | ||||
| { | { | ||||
| jassert (overlayComp == 0 || overlayComp->isValidComponent()); | jassert (overlayComp == 0 || overlayComp->isValidComponent()); | ||||
| delete overlayComp; | |||||
| overlayComp = 0; | overlayComp = 0; | ||||
| } | } | ||||
| else if (overlayComp == 0) | else if (overlayComp == 0) | ||||
| @@ -200,7 +200,7 @@ private: | |||||
| const int itemId; | const int itemId; | ||||
| ToolbarEditingMode mode; | ToolbarEditingMode mode; | ||||
| Toolbar::ToolbarItemStyle toolbarStyle; | Toolbar::ToolbarItemStyle toolbarStyle; | ||||
| Component* overlayComp; | |||||
| ScopedPointer <Component> overlayComp; | |||||
| int dragOffsetX, dragOffsetY; | int dragOffsetX, dragOffsetY; | ||||
| bool isActive, isBeingDragged, isBeingUsedAsAButton; | bool isActive, isBeingDragged, isBeingUsedAsAButton; | ||||
| Rectangle contentArea; | Rectangle contentArea; | ||||
| @@ -463,9 +463,8 @@ void TreeView::setRootItem (TreeViewItem* const newRootItem) | |||||
| void TreeView::deleteRootItem() | void TreeView::deleteRootItem() | ||||
| { | { | ||||
| TreeViewItem* const oldItem = rootItem; | |||||
| const ScopedPointer <TreeViewItem> deleter (rootItem); | |||||
| setRootItem (0); | setRootItem (0); | ||||
| delete oldItem; | |||||
| } | } | ||||
| @@ -277,7 +277,7 @@ bool DirectoryContentsList::addFile (const String& filename, | |||||
| || ((! isDir) && fileFilter->isFileSuitable (file)) | || ((! isDir) && fileFilter->isFileSuitable (file)) | ||||
| || (isDir && fileFilter->isDirectorySuitable (file)))) | || (isDir && fileFilter->isDirectorySuitable (file)))) | ||||
| { | { | ||||
| FileInfo* const info = new FileInfo(); | |||||
| ScopedPointer <FileInfo> info (new FileInfo()); | |||||
| info->filename = filename; | info->filename = filename; | ||||
| info->fileSize = fileSize; | info->fileSize = fileSize; | ||||
| @@ -289,15 +289,10 @@ bool DirectoryContentsList::addFile (const String& filename, | |||||
| const ScopedLock sl (fileListLock); | const ScopedLock sl (fileListLock); | ||||
| for (int i = files.size(); --i >= 0;) | for (int i = files.size(); --i >= 0;) | ||||
| { | |||||
| if (files.getUnchecked(i)->filename == info->filename) | if (files.getUnchecked(i)->filename == info->filename) | ||||
| { | |||||
| delete info; | |||||
| return false; | return false; | ||||
| } | |||||
| } | |||||
| files.addSorted (*this, info); | |||||
| files.addSorted (*this, info.release()); | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -146,7 +146,7 @@ FileBrowserComponent::~FileBrowserComponent() | |||||
| removeChildComponent (previewComp); | removeChildComponent (previewComp); | ||||
| deleteAllChildren(); | deleteAllChildren(); | ||||
| deleteAndZero (fileList); | |||||
| fileList = 0; | |||||
| thread.stopThread (10000); | thread.stopThread (10000); | ||||
| } | } | ||||
| @@ -207,7 +207,7 @@ protected: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| DirectoryContentsList* fileList; | |||||
| ScopedPointer <DirectoryContentsList> fileList; | |||||
| const FileFilter* fileFilter; | const FileFilter* fileFilter; | ||||
| int flags; | int flags; | ||||
| @@ -107,7 +107,7 @@ bool FileChooser::showDialog (const bool selectsDirectories, | |||||
| const bool selectMultipleFiles, | const bool selectMultipleFiles, | ||||
| FilePreviewComponent* const previewComponent) | FilePreviewComponent* const previewComponent) | ||||
| { | { | ||||
| ComponentDeletionWatcher* currentlyFocusedChecker = 0; | |||||
| ScopedPointer <ComponentDeletionWatcher> currentlyFocusedChecker; | |||||
| Component* const currentlyFocused = Component::getCurrentlyFocusedComponent(); | Component* const currentlyFocused = Component::getCurrentlyFocusedComponent(); | ||||
| if (currentlyFocused != 0) | if (currentlyFocused != 0) | ||||
| @@ -168,8 +168,6 @@ bool FileChooser::showDialog (const bool selectsDirectories, | |||||
| if (currentlyFocused != 0 && ! currentlyFocusedChecker->hasBeenDeleted()) | if (currentlyFocused != 0 && ! currentlyFocusedChecker->hasBeenDeleted()) | ||||
| currentlyFocused->grabKeyboardFocus(); | currentlyFocused->grabKeyboardFocus(); | ||||
| delete currentlyFocusedChecker; | |||||
| return results.size() > 0; | return results.size() > 0; | ||||
| } | } | ||||
| @@ -243,7 +243,7 @@ Component* FileListComponent::refreshComponentForRow (int row, bool isSelected, | |||||
| if (comp == 0) | if (comp == 0) | ||||
| { | { | ||||
| delete existingComponentToUpdate; | delete existingComponentToUpdate; | ||||
| existingComponentToUpdate = comp = new FileListItemComponent (*this, fileList.getTimeSliceThread()); | |||||
| comp = new FileListItemComponent (*this, fileList.getTimeSliceThread()); | |||||
| } | } | ||||
| DirectoryContentsList::FileInfo fileInfo; | DirectoryContentsList::FileInfo fileInfo; | ||||
| @@ -242,9 +242,7 @@ FileTreeComponent::FileTreeComponent (DirectoryContentsList& listToShow) | |||||
| FileTreeComponent::~FileTreeComponent() | FileTreeComponent::~FileTreeComponent() | ||||
| { | { | ||||
| TreeViewItem* const root = getRootItem(); | |||||
| setRootItem (0); | |||||
| delete root; | |||||
| deleteRootItem(); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -34,13 +34,11 @@ BEGIN_JUCE_NAMESPACE | |||||
| //============================================================================== | //============================================================================== | ||||
| ImagePreviewComponent::ImagePreviewComponent() | ImagePreviewComponent::ImagePreviewComponent() | ||||
| : currentThumbnail (0) | |||||
| { | { | ||||
| } | } | ||||
| ImagePreviewComponent::~ImagePreviewComponent() | ImagePreviewComponent::~ImagePreviewComponent() | ||||
| { | { | ||||
| delete currentThumbnail; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -70,11 +68,11 @@ void ImagePreviewComponent::timerCallback() | |||||
| { | { | ||||
| stopTimer(); | stopTimer(); | ||||
| deleteAndZero (currentThumbnail); | |||||
| currentThumbnail = 0; | |||||
| currentDetails = String::empty; | currentDetails = String::empty; | ||||
| repaint(); | repaint(); | ||||
| FileInputStream* const in = fileToLoad.createInputStream(); | |||||
| ScopedPointer <FileInputStream> in (fileToLoad.createInputStream()); | |||||
| if (in != 0) | if (in != 0) | ||||
| { | { | ||||
| @@ -97,14 +95,9 @@ void ImagePreviewComponent::timerCallback() | |||||
| getThumbSize (w, h); | getThumbSize (w, h); | ||||
| Image* const reduced = currentThumbnail->createCopy (w, h); | |||||
| delete currentThumbnail; | |||||
| currentThumbnail = reduced; | |||||
| currentThumbnail = currentThumbnail->createCopy (w, h); | |||||
| } | } | ||||
| } | } | ||||
| delete in; | |||||
| } | } | ||||
| } | } | ||||
| @@ -60,7 +60,7 @@ public: | |||||
| private: | private: | ||||
| File fileToLoad; | File fileToLoad; | ||||
| Image* currentThumbnail; | |||||
| ScopedPointer <Image> currentThumbnail; | |||||
| String currentDetails; | String currentDetails; | ||||
| void getThumbSize (int& w, int& h) const; | void getThumbSize (int& w, int& h) const; | ||||
| @@ -1412,7 +1412,7 @@ int Component::runModalLoop() | |||||
| Component* const prevFocused = getCurrentlyFocusedComponent(); | Component* const prevFocused = getCurrentlyFocusedComponent(); | ||||
| ComponentDeletionWatcher* deletionChecker = 0; | |||||
| ScopedPointer <ComponentDeletionWatcher> deletionChecker; | |||||
| if (prevFocused != 0) | if (prevFocused != 0) | ||||
| deletionChecker = new ComponentDeletionWatcher (prevFocused); | deletionChecker = new ComponentDeletionWatcher (prevFocused); | ||||
| @@ -1455,13 +1455,8 @@ int Component::runModalLoop() | |||||
| modalComponentStack.removeValue (this); | modalComponentStack.removeValue (this); | ||||
| if (deletionChecker != 0) | |||||
| { | |||||
| if (! deletionChecker->hasBeenDeleted()) | |||||
| prevFocused->grabKeyboardFocus(); | |||||
| delete deletionChecker; | |||||
| } | |||||
| if (deletionChecker != 0 && ! deletionChecker->hasBeenDeleted()) | |||||
| prevFocused->grabKeyboardFocus(); | |||||
| return returnValue; | return returnValue; | ||||
| } | } | ||||
| @@ -3339,12 +3334,12 @@ void Component::grabFocusInternal (const FocusChangeType cause, const bool canTr | |||||
| else | else | ||||
| { | { | ||||
| // find the default child component.. | // find the default child component.. | ||||
| KeyboardFocusTraverser* const traverser = createFocusTraverser(); | |||||
| ScopedPointer <KeyboardFocusTraverser> traverser (createFocusTraverser()); | |||||
| if (traverser != 0) | if (traverser != 0) | ||||
| { | { | ||||
| Component* const defaultComp = traverser->getDefaultComponent (this); | Component* const defaultComp = traverser->getDefaultComponent (this); | ||||
| delete traverser; | |||||
| traverser = 0; | |||||
| if (defaultComp != 0) | if (defaultComp != 0) | ||||
| { | { | ||||
| @@ -3381,13 +3376,13 @@ void Component::moveKeyboardFocusToSibling (const bool moveToNext) | |||||
| if (parentComponent_ != 0) | if (parentComponent_ != 0) | ||||
| { | { | ||||
| KeyboardFocusTraverser* const traverser = createFocusTraverser(); | |||||
| ScopedPointer <KeyboardFocusTraverser> traverser (createFocusTraverser()); | |||||
| if (traverser != 0) | if (traverser != 0) | ||||
| { | { | ||||
| Component* const nextComp = moveToNext ? traverser->getNextComponent (this) | Component* const nextComp = moveToNext ? traverser->getNextComponent (this) | ||||
| : traverser->getPreviousComponent (this); | : traverser->getPreviousComponent (this); | ||||
| delete traverser; | |||||
| traverser = 0; | |||||
| if (nextComp != 0) | if (nextComp != 0) | ||||
| { | { | ||||
| @@ -381,7 +381,7 @@ void KeyMappingEditorComponent::buttonClicked (Button* button) | |||||
| void KeyMappingEditorComponent::changeListenerCallback (void*) | void KeyMappingEditorComponent::changeListenerCallback (void*) | ||||
| { | { | ||||
| XmlElement* openness = tree->getOpennessState (true); | |||||
| ScopedPointer <XmlElement> openness (tree->getOpennessState (true)); | |||||
| clearSubItems(); | clearSubItems(); | ||||
| @@ -401,10 +401,7 @@ void KeyMappingEditorComponent::changeListenerCallback (void*) | |||||
| } | } | ||||
| if (openness != 0) | if (openness != 0) | ||||
| { | |||||
| tree->restoreOpennessState (*openness); | tree->restoreOpennessState (*openness); | ||||
| delete openness; | |||||
| } | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -276,7 +276,7 @@ bool KeyPressMappingSet::restoreFromXml (const XmlElement& xmlVersion) | |||||
| XmlElement* KeyPressMappingSet::createXml (const bool saveDifferencesFromDefaultSet) const | XmlElement* KeyPressMappingSet::createXml (const bool saveDifferencesFromDefaultSet) const | ||||
| { | { | ||||
| KeyPressMappingSet* defaultSet = 0; | |||||
| ScopedPointer <KeyPressMappingSet> defaultSet; | |||||
| if (saveDifferencesFromDefaultSet) | if (saveDifferencesFromDefaultSet) | ||||
| { | { | ||||
| @@ -329,8 +329,6 @@ XmlElement* KeyPressMappingSet::createXml (const bool saveDifferencesFromDefault | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| delete defaultSet; | |||||
| } | } | ||||
| return doc; | return doc; | ||||
| @@ -53,10 +53,6 @@ ComponentMovementWatcher::~ComponentMovementWatcher() | |||||
| component->removeComponentListener (this); | component->removeComponentListener (this); | ||||
| unregister(); | unregister(); | ||||
| #ifdef JUCE_DEBUG | |||||
| delete deletionWatcher; | |||||
| #endif | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -83,7 +83,7 @@ private: | |||||
| bool reentrant; | bool reentrant; | ||||
| int lastX, lastY, lastWidth, lastHeight; | int lastX, lastY, lastWidth, lastHeight; | ||||
| #ifdef JUCE_DEBUG | #ifdef JUCE_DEBUG | ||||
| ComponentDeletionWatcher* deletionWatcher; | |||||
| ScopedPointer <ComponentDeletionWatcher> deletionWatcher; | |||||
| #endif | #endif | ||||
| void unregister() throw(); | void unregister() throw(); | ||||
| @@ -282,10 +282,7 @@ void TabbedButtonBar::removeTab (const int tabIndex) | |||||
| tabs.remove (tabIndex); | tabs.remove (tabIndex); | ||||
| tabColours.remove (tabIndex); | tabColours.remove (tabIndex); | ||||
| TabBarButton* const tb = getTabButton (tabIndex); | |||||
| if (tb != 0) | |||||
| delete tb; | |||||
| delete getTabButton (tabIndex); | |||||
| for (int i = tabIndex + 1; i <= tabs.size(); ++i) | for (int i = tabIndex + 1; i <= tabs.size(); ++i) | ||||
| { | { | ||||
| @@ -56,8 +56,7 @@ MenuBarComponent::MenuBarComponent (MenuBarModel* model_) | |||||
| indexToShowAgain (-1), | indexToShowAgain (-1), | ||||
| lastMouseX (0), | lastMouseX (0), | ||||
| lastMouseY (0), | lastMouseY (0), | ||||
| inModalState (false), | |||||
| currentPopup (0) | |||||
| inModalState (false) | |||||
| { | { | ||||
| setRepaintsOnMouseActivity (true); | setRepaintsOnMouseActivity (true); | ||||
| setWantsKeyboardFocus (false); | setWantsKeyboardFocus (false); | ||||
| @@ -71,7 +70,7 @@ MenuBarComponent::~MenuBarComponent() | |||||
| setModel (0); | setModel (0); | ||||
| Desktop::getInstance().removeGlobalMouseListener (this); | Desktop::getInstance().removeGlobalMouseListener (this); | ||||
| deleteAndZero (currentPopup); | |||||
| currentPopup = 0; | |||||
| } | } | ||||
| void MenuBarComponent::setModel (MenuBarModel* const newModel) | void MenuBarComponent::setModel (MenuBarModel* const newModel) | ||||
| @@ -173,7 +172,7 @@ void MenuBarComponent::updateItemUnderMouse (int x, int y) | |||||
| void MenuBarComponent::hideCurrentMenu() | void MenuBarComponent::hideCurrentMenu() | ||||
| { | { | ||||
| deleteAndZero (currentPopup); | |||||
| currentPopup = 0; | |||||
| repaint(); | repaint(); | ||||
| } | } | ||||
| @@ -191,12 +190,12 @@ void MenuBarComponent::showMenu (int index) | |||||
| indexToShowAgain = -1; | indexToShowAgain = -1; | ||||
| currentPopupIndex = -1; | currentPopupIndex = -1; | ||||
| itemUnderMouse = index; | itemUnderMouse = index; | ||||
| deleteAndZero (currentPopup); | |||||
| currentPopup = 0; | |||||
| menuBarItemsChanged (0); | menuBarItemsChanged (0); | ||||
| Component* const prevFocused = getCurrentlyFocusedComponent(); | Component* const prevFocused = getCurrentlyFocusedComponent(); | ||||
| ComponentDeletionWatcher* prevCompDeletionChecker = 0; | |||||
| ScopedPointer <ComponentDeletionWatcher> prevCompDeletionChecker; | |||||
| if (prevFocused != 0) | if (prevFocused != 0) | ||||
| prevCompDeletionChecker = new ComponentDeletionWatcher (prevFocused); | prevCompDeletionChecker = new ComponentDeletionWatcher (prevFocused); | ||||
| @@ -246,13 +245,10 @@ void MenuBarComponent::showMenu (int index) | |||||
| result = currentPopup->runModalLoop(); | result = currentPopup->runModalLoop(); | ||||
| if (deletionChecker.hasBeenDeleted()) | if (deletionChecker.hasBeenDeleted()) | ||||
| { | |||||
| delete prevCompDeletionChecker; | |||||
| return; | return; | ||||
| } | |||||
| const int lastPopupIndex = currentPopupIndex; | const int lastPopupIndex = currentPopupIndex; | ||||
| deleteAndZero (currentPopup); | |||||
| currentPopup = 0; | |||||
| currentPopupIndex = -1; | currentPopupIndex = -1; | ||||
| if (result != 0) | if (result != 0) | ||||
| @@ -280,13 +276,8 @@ void MenuBarComponent::showMenu (int index) | |||||
| inModalState = false; | inModalState = false; | ||||
| exitModalState (0); | exitModalState (0); | ||||
| if (prevCompDeletionChecker != 0) | |||||
| { | |||||
| if (! prevCompDeletionChecker->hasBeenDeleted()) | |||||
| prevFocused->grabKeyboardFocus(); | |||||
| delete prevCompDeletionChecker; | |||||
| } | |||||
| if (prevCompDeletionChecker != 0 && ! prevCompDeletionChecker->hasBeenDeleted()) | |||||
| prevFocused->grabKeyboardFocus(); | |||||
| int mx, my; | int mx, my; | ||||
| getMouseXYRelative (mx, my); | getMouseXYRelative (mx, my); | ||||
| @@ -356,7 +347,7 @@ void MenuBarComponent::mouseUp (const MouseEvent& e) | |||||
| updateItemUnderMouse (e2.x, e2.y); | updateItemUnderMouse (e2.x, e2.y); | ||||
| if (itemUnderMouse < 0 && dynamic_cast <DummyMenuComponent*> (currentPopup) != 0) | |||||
| if (itemUnderMouse < 0 && dynamic_cast <DummyMenuComponent*> ((Component*) currentPopup) != 0) | |||||
| hideCurrentMenu(); | hideCurrentMenu(); | ||||
| } | } | ||||
| @@ -109,7 +109,7 @@ private: | |||||
| int itemUnderMouse, currentPopupIndex, topLevelIndexClicked, indexToShowAgain; | int itemUnderMouse, currentPopupIndex, topLevelIndexClicked, indexToShowAgain; | ||||
| int lastMouseX, lastMouseY; | int lastMouseX, lastMouseY; | ||||
| bool inModalState; | bool inModalState; | ||||
| Component* currentPopup; | |||||
| ScopedPointer <Component> currentPopup; | |||||
| int getItemAt (int x, int y); | int getItemAt (int x, int y); | ||||
| void updateItemUnderMouse (const int x, const int y); | void updateItemUnderMouse (const int x, const int y); | ||||
| @@ -49,9 +49,9 @@ public: | |||||
| String text; | String text; | ||||
| const Colour textColour; | const Colour textColour; | ||||
| const bool active, isSeparator, isTicked, usesColour; | const bool active, isSeparator, isTicked, usesColour; | ||||
| Image* image; | |||||
| ScopedPointer <Image> image; | |||||
| PopupMenuCustomComponent* const customComp; | PopupMenuCustomComponent* const customComp; | ||||
| PopupMenu* subMenu; | |||||
| ScopedPointer <PopupMenu> subMenu; | |||||
| ApplicationCommandManager* const commandManager; | ApplicationCommandManager* const commandManager; | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -61,9 +61,7 @@ public: | |||||
| isSeparator (true), | isSeparator (true), | ||||
| isTicked (false), | isTicked (false), | ||||
| usesColour (false), | usesColour (false), | ||||
| image (0), | |||||
| customComp (0), | customComp (0), | ||||
| subMenu (0), | |||||
| commandManager (0) | commandManager (0) | ||||
| { | { | ||||
| } | } | ||||
| @@ -85,11 +83,11 @@ public: | |||||
| isSeparator (false), | isSeparator (false), | ||||
| isTicked (isTicked_), | isTicked (isTicked_), | ||||
| usesColour (usesColour_), | usesColour (usesColour_), | ||||
| image (0), | |||||
| customComp (customComp_), | customComp (customComp_), | ||||
| commandManager (commandManager_) | commandManager (commandManager_) | ||||
| { | { | ||||
| subMenu = (subMenu_ != 0) ? new PopupMenu (*subMenu_) : 0; | |||||
| if (subMenu_ != 0) | |||||
| subMenu = new PopupMenu (*subMenu_); | |||||
| if (customComp != 0) | if (customComp != 0) | ||||
| customComp->refCount_++; | customComp->refCount_++; | ||||
| @@ -137,13 +135,9 @@ public: | |||||
| { | { | ||||
| if (other.subMenu != 0) | if (other.subMenu != 0) | ||||
| subMenu = new PopupMenu (*(other.subMenu)); | subMenu = new PopupMenu (*(other.subMenu)); | ||||
| else | |||||
| subMenu = 0; | |||||
| if (other.image != 0) | if (other.image != 0) | ||||
| image = other.image->createCopy(); | image = other.image->createCopy(); | ||||
| else | |||||
| image = 0; | |||||
| if (customComp != 0) | if (customComp != 0) | ||||
| customComp->refCount_++; | customComp->refCount_++; | ||||
| @@ -151,9 +145,6 @@ public: | |||||
| ~MenuItemInfo() throw() | ~MenuItemInfo() throw() | ||||
| { | { | ||||
| delete subMenu; | |||||
| delete image; | |||||
| if (customComp != 0 && --(customComp->refCount_) == 0) | if (customComp != 0 && --(customComp->refCount_) == 0) | ||||
| delete customComp; | delete customComp; | ||||
| } | } | ||||
| @@ -294,7 +285,6 @@ public: | |||||
| menuBarComponent (0), | menuBarComponent (0), | ||||
| managerOfChosenCommand (0), | managerOfChosenCommand (0), | ||||
| componentAttachedTo (0), | componentAttachedTo (0), | ||||
| attachedCompWatcher (0), | |||||
| lastMouseX (0), | lastMouseX (0), | ||||
| lastMouseY (0), | lastMouseY (0), | ||||
| minimumWidth (0), | minimumWidth (0), | ||||
| @@ -335,7 +325,7 @@ public: | |||||
| delete activeSubMenu; | delete activeSubMenu; | ||||
| deleteAllChildren(); | deleteAllChildren(); | ||||
| delete attachedCompWatcher; | |||||
| attachedCompWatcher = 0; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -357,7 +347,7 @@ public: | |||||
| { | { | ||||
| int totalItems = 0; | int totalItems = 0; | ||||
| PopupMenuWindow* const mw = new PopupMenuWindow(); | |||||
| ScopedPointer <PopupMenuWindow> mw (new PopupMenuWindow()); | |||||
| mw->setLookAndFeel (menu.lookAndFeel); | mw->setLookAndFeel (menu.lookAndFeel); | ||||
| mw->setWantsKeyboardFocus (false); | mw->setWantsKeyboardFocus (false); | ||||
| mw->minimumWidth = minimumWidth; | mw->minimumWidth = minimumWidth; | ||||
| @@ -373,17 +363,12 @@ public: | |||||
| ++totalItems; | ++totalItems; | ||||
| } | } | ||||
| if (totalItems == 0) | |||||
| { | |||||
| delete mw; | |||||
| } | |||||
| else | |||||
| if (totalItems > 0) | |||||
| { | { | ||||
| mw->owner = owner_; | mw->owner = owner_; | ||||
| mw->menuBarComponent = menuBarComponent; | mw->menuBarComponent = menuBarComponent; | ||||
| mw->managerOfChosenCommand = managerOfChosenCommand; | mw->managerOfChosenCommand = managerOfChosenCommand; | ||||
| mw->componentAttachedTo = componentAttachedTo; | mw->componentAttachedTo = componentAttachedTo; | ||||
| delete mw->attachedCompWatcher; | |||||
| mw->attachedCompWatcher = componentAttachedTo != 0 ? new ComponentDeletionWatcher (componentAttachedTo) : 0; | mw->attachedCompWatcher = componentAttachedTo != 0 ? new ComponentDeletionWatcher (componentAttachedTo) : 0; | ||||
| mw->calculateWindowPos (minX, maxX, minY, maxY, alignToRectangle); | mw->calculateWindowPos (minX, maxX, minY, maxY, alignToRectangle); | ||||
| @@ -402,7 +387,7 @@ public: | |||||
| mw->addToDesktop (ComponentPeer::windowIsTemporary | mw->addToDesktop (ComponentPeer::windowIsTemporary | ||||
| | mw->getLookAndFeel().getMenuWindowFlags()); | | mw->getLookAndFeel().getMenuWindowFlags()); | ||||
| return mw; | |||||
| return mw.release(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -774,7 +759,7 @@ private: | |||||
| Component* menuBarComponent; | Component* menuBarComponent; | ||||
| ApplicationCommandManager** managerOfChosenCommand; | ApplicationCommandManager** managerOfChosenCommand; | ||||
| Component* componentAttachedTo; | Component* componentAttachedTo; | ||||
| ComponentDeletionWatcher* attachedCompWatcher; | |||||
| ScopedPointer <ComponentDeletionWatcher> attachedCompWatcher; | |||||
| Rectangle windowPos; | Rectangle windowPos; | ||||
| int lastMouseX, lastMouseY; | int lastMouseX, lastMouseY; | ||||
| int minimumWidth, maximumNumColumns, standardItemHeight; | int minimumWidth, maximumNumColumns, standardItemHeight; | ||||
| @@ -1337,10 +1322,7 @@ PopupMenu::~PopupMenu() throw() | |||||
| void PopupMenu::clear() throw() | void PopupMenu::clear() throw() | ||||
| { | { | ||||
| for (int i = items.size(); --i >= 0;) | for (int i = items.size(); --i >= 0;) | ||||
| { | |||||
| MenuItemInfo* const mi = (MenuItemInfo*) items.getUnchecked(i); | |||||
| delete mi; | |||||
| } | |||||
| delete (MenuItemInfo*) items.getUnchecked(i); | |||||
| items.clear(); | items.clear(); | ||||
| separatorPending = false; | separatorPending = false; | ||||
| @@ -1610,29 +1592,28 @@ int PopupMenu::showMenu (const int x, const int y, const int w, const int h, | |||||
| { | { | ||||
| Component* const prevFocused = Component::getCurrentlyFocusedComponent(); | Component* const prevFocused = Component::getCurrentlyFocusedComponent(); | ||||
| ComponentDeletionWatcher* deletionChecker1 = 0; | |||||
| ScopedPointer <ComponentDeletionWatcher> deletionChecker[2]; | |||||
| if (prevFocused != 0) | if (prevFocused != 0) | ||||
| deletionChecker1 = new ComponentDeletionWatcher (prevFocused); | |||||
| deletionChecker[0] = new ComponentDeletionWatcher (prevFocused); | |||||
| Component* const prevTopLevel = (prevFocused != 0) ? prevFocused->getTopLevelComponent() : 0; | Component* const prevTopLevel = (prevFocused != 0) ? prevFocused->getTopLevelComponent() : 0; | ||||
| ComponentDeletionWatcher* deletionChecker2 = 0; | |||||
| if (prevTopLevel != 0) | if (prevTopLevel != 0) | ||||
| deletionChecker2 = new ComponentDeletionWatcher (prevTopLevel); | |||||
| deletionChecker[1] = new ComponentDeletionWatcher (prevTopLevel); | |||||
| wasHiddenBecauseOfAppChange = false; | wasHiddenBecauseOfAppChange = false; | ||||
| int result = 0; | int result = 0; | ||||
| ApplicationCommandManager* managerOfChosenCommand = 0; | ApplicationCommandManager* managerOfChosenCommand = 0; | ||||
| Component* const popupComp = createMenuComponent (x, y, w, h, | |||||
| itemIdThatMustBeVisible, | |||||
| minimumWidth, | |||||
| maximumNumColumns > 0 ? maximumNumColumns : 7, | |||||
| standardItemHeight, | |||||
| alignToRectangle, 0, | |||||
| &managerOfChosenCommand, | |||||
| componentAttachedTo); | |||||
| ScopedPointer <Component> popupComp (createMenuComponent (x, y, w, h, | |||||
| itemIdThatMustBeVisible, | |||||
| minimumWidth, | |||||
| maximumNumColumns > 0 ? maximumNumColumns : 7, | |||||
| standardItemHeight, | |||||
| alignToRectangle, 0, | |||||
| &managerOfChosenCommand, | |||||
| componentAttachedTo)); | |||||
| if (popupComp != 0) | if (popupComp != 0) | ||||
| { | { | ||||
| @@ -1641,21 +1622,18 @@ int PopupMenu::showMenu (const int x, const int y, const int w, const int h, | |||||
| // be stuck behind other comps that are already modal.. | // be stuck behind other comps that are already modal.. | ||||
| result = popupComp->runModalLoop(); | result = popupComp->runModalLoop(); | ||||
| delete popupComp; | |||||
| popupComp = 0; | |||||
| if (! wasHiddenBecauseOfAppChange) | if (! wasHiddenBecauseOfAppChange) | ||||
| { | { | ||||
| if (deletionChecker2 != 0 && ! deletionChecker2->hasBeenDeleted()) | |||||
| if (deletionChecker[1] != 0 && ! deletionChecker[1]->hasBeenDeleted()) | |||||
| prevTopLevel->toFront (true); | prevTopLevel->toFront (true); | ||||
| if (deletionChecker1 != 0 && ! deletionChecker1->hasBeenDeleted()) | |||||
| if (deletionChecker[0] != 0 && ! deletionChecker[0]->hasBeenDeleted()) | |||||
| prevFocused->grabKeyboardFocus(); | prevFocused->grabKeyboardFocus(); | ||||
| } | } | ||||
| } | } | ||||
| delete deletionChecker1; | |||||
| delete deletionChecker2; | |||||
| if (managerOfChosenCommand != 0 && result != 0) | if (managerOfChosenCommand != 0 && result != 0) | ||||
| { | { | ||||
| ApplicationCommandTarget::InvocationInfo info (result); | ApplicationCommandTarget::InvocationInfo info (result); | ||||
| @@ -44,15 +44,13 @@ class DragImageComponent : public Component, | |||||
| public Timer | public Timer | ||||
| { | { | ||||
| private: | private: | ||||
| Image* image; | |||||
| ScopedPointer <Image> image; | |||||
| Component* const source; | Component* const source; | ||||
| DragAndDropContainer* const owner; | DragAndDropContainer* const owner; | ||||
| ComponentDeletionWatcher* sourceWatcher; | |||||
| ScopedPointer <ComponentDeletionWatcher> sourceWatcher, mouseDragSourceWatcher, currentlyOverWatcher; | |||||
| Component* mouseDragSource; | Component* mouseDragSource; | ||||
| ComponentDeletionWatcher* mouseDragSourceWatcher; | |||||
| DragAndDropTarget* currentlyOver; | DragAndDropTarget* currentlyOver; | ||||
| ComponentDeletionWatcher* currentlyOverWatcher; | |||||
| String dragDesc; | String dragDesc; | ||||
| const int imageX, imageY; | const int imageX, imageY; | ||||
| @@ -71,7 +69,6 @@ public: | |||||
| source (s), | source (s), | ||||
| owner (o), | owner (o), | ||||
| currentlyOver (0), | currentlyOver (0), | ||||
| currentlyOverWatcher (0), | |||||
| dragDesc (desc), | dragDesc (desc), | ||||
| imageX (imageX_), | imageX (imageX_), | ||||
| imageY (imageY_), | imageY (imageY_), | ||||
| @@ -98,8 +95,8 @@ public: | |||||
| ~DragImageComponent() | ~DragImageComponent() | ||||
| { | { | ||||
| if (owner->dragImageComponent == this) | |||||
| owner->dragImageComponent = 0; | |||||
| if ((DragImageComponent*) owner->dragImageComponent == this) | |||||
| owner->dragImageComponent.release(); | |||||
| if (! mouseDragSourceWatcher->hasBeenDeleted()) | if (! mouseDragSourceWatcher->hasBeenDeleted()) | ||||
| { | { | ||||
| @@ -109,11 +106,6 @@ public: | |||||
| if (currentlyOver->isInterestedInDragSource (dragDesc, source)) | if (currentlyOver->isInterestedInDragSource (dragDesc, source)) | ||||
| currentlyOver->itemDragExit (dragDesc, source); | currentlyOver->itemDragExit (dragDesc, source); | ||||
| } | } | ||||
| delete mouseDragSourceWatcher; | |||||
| delete sourceWatcher; | |||||
| delete image; | |||||
| delete currentlyOverWatcher; | |||||
| } | } | ||||
| void paint (Graphics& g) | void paint (Graphics& g) | ||||
| @@ -220,8 +212,8 @@ public: | |||||
| // a modal loop and deletes this object before the method completes) | // a modal loop and deletes this object before the method completes) | ||||
| const String dragDescLocal (dragDesc); | const String dragDescLocal (dragDesc); | ||||
| currentlyOverWatcher = 0; | |||||
| currentlyOver = 0; | currentlyOver = 0; | ||||
| deleteAndZero (currentlyOverWatcher); | |||||
| ddt->itemDropped (dragDescLocal, source, relX, relY); | ddt->itemDropped (dragDescLocal, source, relX, relY); | ||||
| } | } | ||||
| @@ -267,7 +259,7 @@ public: | |||||
| } | } | ||||
| currentlyOver = ddt; | currentlyOver = ddt; | ||||
| deleteAndZero (currentlyOverWatcher); | |||||
| currentlyOverWatcher = 0; | |||||
| if (ddt != 0) | if (ddt != 0) | ||||
| { | { | ||||
| @@ -280,7 +272,7 @@ public: | |||||
| else if (currentlyOverWatcher != 0 && currentlyOverWatcher->hasBeenDeleted()) | else if (currentlyOverWatcher != 0 && currentlyOverWatcher->hasBeenDeleted()) | ||||
| { | { | ||||
| currentlyOver = 0; | currentlyOver = 0; | ||||
| deleteAndZero (currentlyOverWatcher); | |||||
| currentlyOverWatcher = 0; | |||||
| } | } | ||||
| if (currentlyOver != 0 | if (currentlyOver != 0 | ||||
| @@ -341,26 +333,23 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| DragAndDropContainer::DragAndDropContainer() | DragAndDropContainer::DragAndDropContainer() | ||||
| : dragImageComponent (0) | |||||
| { | { | ||||
| } | } | ||||
| DragAndDropContainer::~DragAndDropContainer() | DragAndDropContainer::~DragAndDropContainer() | ||||
| { | { | ||||
| delete dragImageComponent; | |||||
| dragImageComponent = 0; | |||||
| } | } | ||||
| void DragAndDropContainer::startDragging (const String& sourceDescription, | void DragAndDropContainer::startDragging (const String& sourceDescription, | ||||
| Component* sourceComponent, | Component* sourceComponent, | ||||
| Image* im, | |||||
| Image* dragImage_, | |||||
| const bool allowDraggingToExternalWindows, | const bool allowDraggingToExternalWindows, | ||||
| const Point* imageOffsetFromMouse) | const Point* imageOffsetFromMouse) | ||||
| { | { | ||||
| if (dragImageComponent != 0) | |||||
| { | |||||
| delete im; | |||||
| } | |||||
| else | |||||
| ScopedPointer <Image> dragImage (dragImage_); | |||||
| if (dragImageComponent == 0) | |||||
| { | { | ||||
| Component* const thisComp = dynamic_cast <Component*> (this); | Component* const thisComp = dynamic_cast <Component*> (this); | ||||
| @@ -370,35 +359,34 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, | |||||
| Desktop::getLastMouseDownPosition (mx, my); | Desktop::getLastMouseDownPosition (mx, my); | ||||
| int imageX = 0, imageY = 0; | int imageX = 0, imageY = 0; | ||||
| if (im == 0) | |||||
| if (dragImage == 0) | |||||
| { | { | ||||
| im = sourceComponent->createComponentSnapshot (Rectangle (0, 0, sourceComponent->getWidth(), sourceComponent->getHeight())); | |||||
| dragImage = sourceComponent->createComponentSnapshot (Rectangle (0, 0, sourceComponent->getWidth(), sourceComponent->getHeight())); | |||||
| if (im->getFormat() != Image::ARGB) | |||||
| if (dragImage->getFormat() != Image::ARGB) | |||||
| { | { | ||||
| Image* newIm = Image::createNativeImage (Image::ARGB, im->getWidth(), im->getHeight(), true); | |||||
| Image* newIm = Image::createNativeImage (Image::ARGB, dragImage->getWidth(), dragImage->getHeight(), true); | |||||
| Graphics g2 (*newIm); | Graphics g2 (*newIm); | ||||
| g2.drawImageAt (im, 0, 0); | |||||
| g2.drawImageAt (dragImage, 0, 0); | |||||
| delete im; | |||||
| im = newIm; | |||||
| dragImage = newIm; | |||||
| } | } | ||||
| im->multiplyAllAlphas (0.6f); | |||||
| dragImage->multiplyAllAlphas (0.6f); | |||||
| const int lo = 150; | const int lo = 150; | ||||
| const int hi = 400; | const int hi = 400; | ||||
| int rx = mx, ry = my; | int rx = mx, ry = my; | ||||
| sourceComponent->globalPositionToRelative (rx, ry); | sourceComponent->globalPositionToRelative (rx, ry); | ||||
| const int cx = jlimit (0, im->getWidth(), rx); | |||||
| const int cy = jlimit (0, im->getHeight(), ry); | |||||
| const int cx = jlimit (0, dragImage->getWidth(), rx); | |||||
| const int cy = jlimit (0, dragImage->getHeight(), ry); | |||||
| for (int y = im->getHeight(); --y >= 0;) | |||||
| for (int y = dragImage->getHeight(); --y >= 0;) | |||||
| { | { | ||||
| const double dy = (y - cy) * (y - cy); | const double dy = (y - cy) * (y - cy); | ||||
| for (int x = im->getWidth(); --x >= 0;) | |||||
| for (int x = dragImage->getWidth(); --x >= 0;) | |||||
| { | { | ||||
| const int dx = x - cx; | const int dx = x - cx; | ||||
| const int distance = roundDoubleToInt (sqrt (dx * dx + dy)); | const int distance = roundDoubleToInt (sqrt (dx * dx + dy)); | ||||
| @@ -409,7 +397,7 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, | |||||
| : (hi - distance) / (float) (hi - lo) | : (hi - distance) / (float) (hi - lo) | ||||
| + Random::getSystemRandom().nextFloat() * 0.008f; | + Random::getSystemRandom().nextFloat() * 0.008f; | ||||
| im->multiplyAlphaAt (x, y, alpha); | |||||
| dragImage->multiplyAlphaAt (x, y, alpha); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -421,8 +409,8 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, | |||||
| { | { | ||||
| if (imageOffsetFromMouse == 0) | if (imageOffsetFromMouse == 0) | ||||
| { | { | ||||
| imageX = im->getWidth() / -2; | |||||
| imageY = im->getHeight() / -2; | |||||
| imageX = dragImage->getWidth() / -2; | |||||
| imageY = dragImage->getHeight() / -2; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -431,35 +419,31 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, | |||||
| } | } | ||||
| } | } | ||||
| DragImageComponent* const dic | |||||
| = new DragImageComponent (im, sourceDescription, sourceComponent, | |||||
| this, imageX, imageY); | |||||
| dragImageComponent = new DragImageComponent (dragImage.release(), sourceDescription, sourceComponent, | |||||
| this, imageX, imageY); | |||||
| dragImageComponent = dic; | |||||
| currentDragDesc = sourceDescription; | currentDragDesc = sourceDescription; | ||||
| if (allowDraggingToExternalWindows) | if (allowDraggingToExternalWindows) | ||||
| { | { | ||||
| if (! Desktop::canUseSemiTransparentWindows()) | if (! Desktop::canUseSemiTransparentWindows()) | ||||
| dic->setOpaque (true); | |||||
| dragImageComponent->setOpaque (true); | |||||
| dic->addToDesktop (ComponentPeer::windowIgnoresMouseClicks | |||||
| | ComponentPeer::windowIsTemporary | |||||
| | ComponentPeer::windowIgnoresKeyPresses); | |||||
| dragImageComponent->addToDesktop (ComponentPeer::windowIgnoresMouseClicks | |||||
| | ComponentPeer::windowIsTemporary | |||||
| | ComponentPeer::windowIgnoresKeyPresses); | |||||
| } | } | ||||
| else | else | ||||
| thisComp->addChildComponent (dic); | |||||
| thisComp->addChildComponent (dragImageComponent); | |||||
| dic->updateLocation (false, mx, my); | |||||
| dic->setVisible (true); | |||||
| ((DragImageComponent*) dragImageComponent)->updateLocation (false, mx, my); | |||||
| dragImageComponent->setVisible (true); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| // this class must only be implemented by an object that | // this class must only be implemented by an object that | ||||
| // is also a Component. | // is also a Component. | ||||
| jassertfalse | jassertfalse | ||||
| delete im; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -180,7 +180,7 @@ protected: | |||||
| private: | private: | ||||
| friend class DragImageComponent; | friend class DragImageComponent; | ||||
| Component* dragImageComponent; | |||||
| ScopedPointer <Component> dragImageComponent; | |||||
| String currentDragDesc; | String currentDragDesc; | ||||
| }; | }; | ||||
| @@ -108,8 +108,7 @@ public: | |||||
| : owner (owner_), | : owner (owner_), | ||||
| h (h_), s (s_), v (v_), | h (h_), s (s_), v (v_), | ||||
| lastHue (0.0f), | lastHue (0.0f), | ||||
| edge (edgeSize), | |||||
| colours (0) | |||||
| edge (edgeSize) | |||||
| { | { | ||||
| addAndMakeVisible (marker = new ColourSpaceMarker()); | addAndMakeVisible (marker = new ColourSpaceMarker()); | ||||
| setMouseCursor (MouseCursor::CrosshairCursor); | setMouseCursor (MouseCursor::CrosshairCursor); | ||||
| @@ -118,7 +117,6 @@ public: | |||||
| ~ColourSpaceView() | ~ColourSpaceView() | ||||
| { | { | ||||
| deleteAllChildren(); | deleteAllChildren(); | ||||
| delete colours; | |||||
| } | } | ||||
| void paint (Graphics& g) | void paint (Graphics& g) | ||||
| @@ -169,7 +167,7 @@ public: | |||||
| if (lastHue != h) | if (lastHue != h) | ||||
| { | { | ||||
| lastHue = h; | lastHue = h; | ||||
| deleteAndZero (colours); | |||||
| colours = 0; | |||||
| repaint(); | repaint(); | ||||
| } | } | ||||
| @@ -178,12 +176,12 @@ public: | |||||
| void resized() | void resized() | ||||
| { | { | ||||
| deleteAndZero (colours); | |||||
| colours = 0; | |||||
| updateMarker(); | updateMarker(); | ||||
| } | } | ||||
| private: | private: | ||||
| Image* colours; | |||||
| ScopedPointer <Image> colours; | |||||
| void updateMarker() const throw() | void updateMarker() const throw() | ||||
| { | { | ||||
| @@ -576,10 +574,7 @@ void ColourSelector::resized() | |||||
| { | { | ||||
| int i; | int i; | ||||
| for (i = swatchComponents.size(); --i >= 0;) | for (i = swatchComponents.size(); --i >= 0;) | ||||
| { | |||||
| SwatchComponent* const sc = (SwatchComponent*) swatchComponents.getUnchecked(i); | |||||
| delete sc; | |||||
| } | |||||
| delete (SwatchComponent*) swatchComponents.getUnchecked(i); | |||||
| for (i = 0; i < numSwatches; ++i) | for (i = 0; i < numSwatches; ++i) | ||||
| { | { | ||||
| @@ -79,7 +79,7 @@ public: | |||||
| private: | private: | ||||
| friend class NSViewComponentInternal; | friend class NSViewComponentInternal; | ||||
| NSViewComponentInternal* info; | |||||
| ScopedPointer <NSViewComponentInternal> info; | |||||
| NSViewComponent (const NSViewComponent&); | NSViewComponent (const NSViewComponent&); | ||||
| const NSViewComponent& operator= (const NSViewComponent&); | const NSViewComponent& operator= (const NSViewComponent&); | ||||
| @@ -36,13 +36,13 @@ BEGIN_JUCE_NAMESPACE | |||||
| //============================================================================== | //============================================================================== | ||||
| PreferencesPanel::PreferencesPanel() | PreferencesPanel::PreferencesPanel() | ||||
| : currentPage (0), | |||||
| buttonSize (70) | |||||
| : buttonSize (70) | |||||
| { | { | ||||
| } | } | ||||
| PreferencesPanel::~PreferencesPanel() | PreferencesPanel::~PreferencesPanel() | ||||
| { | { | ||||
| currentPage = 0; | |||||
| deleteAllChildren(); | deleteAllChildren(); | ||||
| } | } | ||||
| @@ -155,7 +155,7 @@ void PreferencesPanel::setCurrentPage (const String& pageName) | |||||
| { | { | ||||
| currentPageName = pageName; | currentPageName = pageName; | ||||
| deleteAndZero (currentPage); | |||||
| currentPage = 0; | |||||
| currentPage = createComponentForPage (pageName); | currentPage = createComponentForPage (pageName); | ||||
| if (currentPage != 0) | if (currentPage != 0) | ||||
| @@ -137,7 +137,7 @@ public: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| String currentPageName; | String currentPageName; | ||||
| Component* currentPage; | |||||
| ScopedPointer <Component> currentPage; | |||||
| int buttonSize; | int buttonSize; | ||||
| PreferencesPanel (const PreferencesPanel&); | PreferencesPanel (const PreferencesPanel&); | ||||
| @@ -36,6 +36,7 @@ BEGIN_JUCE_NAMESPACE | |||||
| #include "../../../text/juce_LocalisedStrings.h" | #include "../../../text/juce_LocalisedStrings.h" | ||||
| #include "../../../events/juce_MessageManager.h" | #include "../../../events/juce_MessageManager.h" | ||||
| #include "../../../application/juce_Application.h" | #include "../../../application/juce_Application.h" | ||||
| #include "../../../containers/juce_ScopedPointer.h" | |||||
| static const int titleH = 24; | static const int titleH = 24; | ||||
| static const int iconWidth = 80; | static const int iconWidth = 80; | ||||
| @@ -614,14 +615,12 @@ private: | |||||
| LookAndFeel& lf = associatedComponent->isValidComponent() ? associatedComponent->getLookAndFeel() | LookAndFeel& lf = associatedComponent->isValidComponent() ? associatedComponent->getLookAndFeel() | ||||
| : LookAndFeel::getDefaultLookAndFeel(); | : LookAndFeel::getDefaultLookAndFeel(); | ||||
| Component* const alertBox = lf.createAlertWindow (title, message, button1, button2, button3, | |||||
| iconType, numButtons, associatedComponent); | |||||
| ScopedPointer <Component> alertBox (lf.createAlertWindow (title, message, button1, button2, button3, | |||||
| iconType, numButtons, associatedComponent)); | |||||
| jassert (alertBox != 0); // you have to return one of these! | jassert (alertBox != 0); // you have to return one of these! | ||||
| const int result = alertBox->runModalLoop(); | |||||
| delete alertBox; | |||||
| return result; | |||||
| return alertBox->runModalLoop(); | |||||
| } | } | ||||
| static void* showCallback (void* userData) | static void* showCallback (void* userData) | ||||
| @@ -64,7 +64,6 @@ ComponentPeer::ComponentPeer (Component* const component_, | |||||
| lastPaintTime (0), | lastPaintTime (0), | ||||
| constrainer (0), | constrainer (0), | ||||
| lastFocusedComponent (0), | lastFocusedComponent (0), | ||||
| dragAndDropTargetComponent (0), | |||||
| lastDragAndDropCompUnderMouse (0), | lastDragAndDropCompUnderMouse (0), | ||||
| fakeMouseMessageSent (false), | fakeMouseMessageSent (false), | ||||
| isWindowMinimised (false) | isWindowMinimised (false) | ||||
| @@ -75,7 +74,6 @@ ComponentPeer::ComponentPeer (Component* const component_, | |||||
| ComponentPeer::~ComponentPeer() | ComponentPeer::~ComponentPeer() | ||||
| { | { | ||||
| heavyweightPeers.removeValue (this); | heavyweightPeers.removeValue (this); | ||||
| delete dragAndDropTargetComponent; | |||||
| Desktop::getInstance().triggerFocusCallback(); | Desktop::getInstance().triggerFocusCallback(); | ||||
| } | } | ||||
| @@ -687,7 +685,7 @@ void ComponentPeer::handleFileDragMove (const StringArray& files, int x, int y) | |||||
| if (lastTarget != 0) | if (lastTarget != 0) | ||||
| lastTarget->fileDragExit (files); | lastTarget->fileDragExit (files); | ||||
| deleteAndZero (dragAndDropTargetComponent); | |||||
| dragAndDropTargetComponent = 0; | |||||
| if (newTarget != 0) | if (newTarget != 0) | ||||
| { | { | ||||
| @@ -730,7 +728,7 @@ void ComponentPeer::handleFileDragDrop (const StringArray& files, int x, int y) | |||||
| { | { | ||||
| FileDragAndDropTarget* const target = const_cast <FileDragAndDropTarget*> (dynamic_cast <const FileDragAndDropTarget*> (dragAndDropTargetComponent->getComponent())); | FileDragAndDropTarget* const target = const_cast <FileDragAndDropTarget*> (dynamic_cast <const FileDragAndDropTarget*> (dragAndDropTargetComponent->getComponent())); | ||||
| deleteAndZero (dragAndDropTargetComponent); | |||||
| dragAndDropTargetComponent = 0; | |||||
| lastDragAndDropCompUnderMouse = 0; | lastDragAndDropCompUnderMouse = 0; | ||||
| if (target != 0) | if (target != 0) | ||||
| @@ -377,7 +377,7 @@ protected: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| Component* lastFocusedComponent; | Component* lastFocusedComponent; | ||||
| ComponentDeletionWatcher* dragAndDropTargetComponent; | |||||
| ScopedPointer <ComponentDeletionWatcher> dragAndDropTargetComponent; | |||||
| Component* lastDragAndDropCompUnderMouse; | Component* lastDragAndDropCompUnderMouse; | ||||
| bool fakeMouseMessageSent : 1, isWindowMinimised : 1; | bool fakeMouseMessageSent : 1, isWindowMinimised : 1; | ||||
| @@ -48,12 +48,8 @@ DocumentWindow::DocumentWindow (const String& title, | |||||
| positionTitleBarButtonsOnLeft (false), | positionTitleBarButtonsOnLeft (false), | ||||
| #endif | #endif | ||||
| drawTitleTextCentred (true), | drawTitleTextCentred (true), | ||||
| titleBarIcon (0), | |||||
| menuBar (0), | |||||
| menuBarModel (0) | menuBarModel (0) | ||||
| { | { | ||||
| zeromem (titleBarButtons, sizeof (titleBarButtons)); | |||||
| setResizeLimits (128, 128, 32768, 32768); | setResizeLimits (128, 128, 32768, 32768); | ||||
| lookAndFeelChanged(); | lookAndFeelChanged(); | ||||
| @@ -61,11 +57,10 @@ DocumentWindow::DocumentWindow (const String& title, | |||||
| DocumentWindow::~DocumentWindow() | DocumentWindow::~DocumentWindow() | ||||
| { | { | ||||
| for (int i = 0; i < 3; ++i) | |||||
| delete titleBarButtons[i]; | |||||
| for (int i = numElementsInArray (titleBarButtons); --i >= 0;) | |||||
| titleBarButtons[i] = 0; | |||||
| delete titleBarIcon; | |||||
| delete menuBar; | |||||
| menuBar = 0; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -87,11 +82,7 @@ void DocumentWindow::setName (const String& newName) | |||||
| void DocumentWindow::setIcon (const Image* imageToUse) | void DocumentWindow::setIcon (const Image* imageToUse) | ||||
| { | { | ||||
| deleteAndZero (titleBarIcon); | |||||
| if (imageToUse != 0) | |||||
| titleBarIcon = imageToUse->createCopy(); | |||||
| titleBarIcon = imageToUse != 0 ? imageToUse->createCopy() : 0; | |||||
| repaintTitleBar(); | repaintTitleBar(); | ||||
| } | } | ||||
| @@ -121,7 +112,6 @@ void DocumentWindow::setMenuBar (MenuBarModel* menuBarModel_, | |||||
| { | { | ||||
| if (menuBarModel != menuBarModel_) | if (menuBarModel != menuBarModel_) | ||||
| { | { | ||||
| delete menuBar; | |||||
| menuBar = 0; | menuBar = 0; | ||||
| menuBarModel = menuBarModel_; | menuBarModel = menuBarModel_; | ||||
| @@ -302,8 +292,8 @@ int DocumentWindow::getDesktopWindowStyleFlags() const | |||||
| void DocumentWindow::lookAndFeelChanged() | void DocumentWindow::lookAndFeelChanged() | ||||
| { | { | ||||
| int i; | int i; | ||||
| for (i = 0; i < 3; ++i) | |||||
| deleteAndZero (titleBarButtons[i]); | |||||
| for (i = numElementsInArray (titleBarButtons); --i >= 0;) | |||||
| titleBarButtons[i] = 0; | |||||
| if (! isUsingNativeTitleBar()) | if (! isUsingNativeTitleBar()) | ||||
| { | { | ||||
| @@ -353,7 +343,7 @@ void DocumentWindow::activeWindowStatusChanged() | |||||
| { | { | ||||
| ResizableWindow::activeWindowStatusChanged(); | ResizableWindow::activeWindowStatusChanged(); | ||||
| for (int i = 0; i < 3; ++i) | |||||
| for (int i = numElementsInArray (titleBarButtons); --i >= 0;) | |||||
| if (titleBarButtons[i] != 0) | if (titleBarButtons[i] != 0) | ||||
| titleBarButtons[i]->setEnabled (isActiveWindow()); | titleBarButtons[i]->setEnabled (isActiveWindow()); | ||||
| @@ -248,9 +248,9 @@ public: | |||||
| private: | private: | ||||
| int titleBarHeight, menuBarHeight, requiredButtons; | int titleBarHeight, menuBarHeight, requiredButtons; | ||||
| bool positionTitleBarButtonsOnLeft, drawTitleTextCentred; | bool positionTitleBarButtonsOnLeft, drawTitleTextCentred; | ||||
| Button* titleBarButtons [3]; | |||||
| Image* titleBarIcon; | |||||
| MenuBarComponent* menuBar; | |||||
| ScopedPointer <Button> titleBarButtons [3]; | |||||
| ScopedPointer <Image> titleBarIcon; | |||||
| ScopedPointer <MenuBarComponent> menuBar; | |||||
| MenuBarModel* menuBarModel; | MenuBarModel* menuBarModel; | ||||
| class ButtonListenerProxy : public ButtonListener | class ButtonListenerProxy : public ButtonListener | ||||
| @@ -38,9 +38,6 @@ BEGIN_JUCE_NAMESPACE | |||||
| ResizableWindow::ResizableWindow (const String& name, | ResizableWindow::ResizableWindow (const String& name, | ||||
| const bool addToDesktop_) | const bool addToDesktop_) | ||||
| : TopLevelWindow (name, addToDesktop_), | : TopLevelWindow (name, addToDesktop_), | ||||
| resizableCorner (0), | |||||
| resizableBorder (0), | |||||
| contentComponent (0), | |||||
| resizeToFitContent (false), | resizeToFitContent (false), | ||||
| fullscreen (false), | fullscreen (false), | ||||
| lastNonFullScreenPos (50, 50, 256, 256), | lastNonFullScreenPos (50, 50, 256, 256), | ||||
| @@ -61,9 +58,6 @@ ResizableWindow::ResizableWindow (const String& name, | |||||
| const Colour& backgroundColour_, | const Colour& backgroundColour_, | ||||
| const bool addToDesktop_) | const bool addToDesktop_) | ||||
| : TopLevelWindow (name, addToDesktop_), | : TopLevelWindow (name, addToDesktop_), | ||||
| resizableCorner (0), | |||||
| resizableBorder (0), | |||||
| contentComponent (0), | |||||
| resizeToFitContent (false), | resizeToFitContent (false), | ||||
| fullscreen (false), | fullscreen (false), | ||||
| lastNonFullScreenPos (50, 50, 256, 256), | lastNonFullScreenPos (50, 50, 256, 256), | ||||
| @@ -82,9 +76,9 @@ ResizableWindow::ResizableWindow (const String& name, | |||||
| ResizableWindow::~ResizableWindow() | ResizableWindow::~ResizableWindow() | ||||
| { | { | ||||
| deleteAndZero (resizableCorner); | |||||
| deleteAndZero (resizableBorder); | |||||
| deleteAndZero (contentComponent); | |||||
| resizableCorner = 0; | |||||
| resizableBorder = 0; | |||||
| contentComponent = 0; | |||||
| // have you been adding your own components directly to this window..? tut tut tut. | // have you been adding your own components directly to this window..? tut tut tut. | ||||
| // Read the instructions for using a ResizableWindow! | // Read the instructions for using a ResizableWindow! | ||||
| @@ -108,12 +102,10 @@ void ResizableWindow::setContentComponent (Component* const newContentComponent, | |||||
| { | { | ||||
| resizeToFitContent = resizeToFit; | resizeToFitContent = resizeToFit; | ||||
| if (contentComponent != newContentComponent) | |||||
| if (newContentComponent != (Component*) contentComponent) | |||||
| { | { | ||||
| if (deleteOldOne) | |||||
| delete contentComponent; | |||||
| else | |||||
| removeChildComponent (contentComponent); | |||||
| if (! deleteOldOne) | |||||
| removeChildComponent (contentComponent.release()); | |||||
| contentComponent = newContentComponent; | contentComponent = newContentComponent; | ||||
| @@ -224,7 +216,7 @@ void ResizableWindow::setResizable (const bool shouldBeResizable, | |||||
| { | { | ||||
| if (useBottomRightCornerResizer) | if (useBottomRightCornerResizer) | ||||
| { | { | ||||
| deleteAndZero (resizableBorder); | |||||
| resizableBorder = 0; | |||||
| if (resizableCorner == 0) | if (resizableCorner == 0) | ||||
| { | { | ||||
| @@ -234,7 +226,7 @@ void ResizableWindow::setResizable (const bool shouldBeResizable, | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| deleteAndZero (resizableCorner); | |||||
| resizableCorner = 0; | |||||
| if (resizableBorder == 0) | if (resizableBorder == 0) | ||||
| Component::addChildComponent (resizableBorder = new ResizableBorderComponent (this, constrainer)); | Component::addChildComponent (resizableBorder = new ResizableBorderComponent (this, constrainer)); | ||||
| @@ -242,8 +234,8 @@ void ResizableWindow::setResizable (const bool shouldBeResizable, | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| deleteAndZero (resizableCorner); | |||||
| deleteAndZero (resizableBorder); | |||||
| resizableCorner = 0; | |||||
| resizableBorder = 0; | |||||
| } | } | ||||
| if (isUsingNativeTitleBar()) | if (isUsingNativeTitleBar()) | ||||
| @@ -285,8 +277,8 @@ void ResizableWindow::setConstrainer (ComponentBoundsConstrainer* newConstrainer | |||||
| const bool useBottomRightCornerResizer = resizableCorner != 0; | const bool useBottomRightCornerResizer = resizableCorner != 0; | ||||
| const bool shouldBeResizable = useBottomRightCornerResizer || resizableBorder != 0; | const bool shouldBeResizable = useBottomRightCornerResizer || resizableBorder != 0; | ||||
| deleteAndZero (resizableCorner); | |||||
| deleteAndZero (resizableBorder); | |||||
| resizableCorner = 0; | |||||
| resizableBorder = 0; | |||||
| setResizable (shouldBeResizable, useBottomRightCornerResizer); | setResizable (shouldBeResizable, useBottomRightCornerResizer); | ||||
| @@ -338,11 +338,11 @@ protected: | |||||
| #endif | #endif | ||||
| ResizableCornerComponent* resizableCorner; | |||||
| ResizableBorderComponent* resizableBorder; | |||||
| ScopedPointer <ResizableCornerComponent> resizableCorner; | |||||
| ScopedPointer <ResizableBorderComponent> resizableBorder; | |||||
| private: | private: | ||||
| Component* contentComponent; | |||||
| ScopedPointer <Component> contentComponent; | |||||
| bool resizeToFitContent, fullscreen; | bool resizeToFitContent, fullscreen; | ||||
| ComponentDragger dragger; | ComponentDragger dragger; | ||||
| Rectangle lastNonFullScreenPos; | Rectangle lastNonFullScreenPos; | ||||
| @@ -35,18 +35,14 @@ BEGIN_JUCE_NAMESPACE | |||||
| //============================================================================== | //============================================================================== | ||||
| SplashScreen::SplashScreen() | SplashScreen::SplashScreen() | ||||
| : backgroundImage (0), | |||||
| isImageInCache (false) | |||||
| : backgroundImage (0) | |||||
| { | { | ||||
| setOpaque (true); | setOpaque (true); | ||||
| } | } | ||||
| SplashScreen::~SplashScreen() | SplashScreen::~SplashScreen() | ||||
| { | { | ||||
| if (isImageInCache) | |||||
| ImageCache::release (backgroundImage); | |||||
| else | |||||
| delete backgroundImage; | |||||
| ImageCache::releaseOrDelete (backgroundImage); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -62,8 +58,6 @@ void SplashScreen::show (const String& title, | |||||
| if (backgroundImage_ != 0) | if (backgroundImage_ != 0) | ||||
| { | { | ||||
| isImageInCache = ImageCache::isImageInCache (backgroundImage_); | |||||
| setOpaque (! backgroundImage_->hasAlphaChannel()); | setOpaque (! backgroundImage_->hasAlphaChannel()); | ||||
| show (title, | show (title, | ||||
| @@ -144,7 +144,6 @@ private: | |||||
| Image* backgroundImage; | Image* backgroundImage; | ||||
| Time earliestTimeToDelete; | Time earliestTimeToDelete; | ||||
| int originalClickCounter; | int originalClickCounter; | ||||
| bool isImageInCache; | |||||
| SplashScreen (const SplashScreen&); | SplashScreen (const SplashScreen&); | ||||
| const SplashScreen& operator= (const SplashScreen&); | const SplashScreen& operator= (const SplashScreen&); | ||||
| @@ -55,7 +55,6 @@ ThreadWithProgressWindow::ThreadWithProgressWindow (const String& title, | |||||
| ThreadWithProgressWindow::~ThreadWithProgressWindow() | ThreadWithProgressWindow::~ThreadWithProgressWindow() | ||||
| { | { | ||||
| stopThread (timeOutMsWhenCancelling); | stopThread (timeOutMsWhenCancelling); | ||||
| delete alertWindow; | |||||
| } | } | ||||
| bool ThreadWithProgressWindow::runThread (const int priority) | bool ThreadWithProgressWindow::runThread (const int priority) | ||||
| @@ -29,6 +29,7 @@ | |||||
| #include "../windows/juce_AlertWindow.h" | #include "../windows/juce_AlertWindow.h" | ||||
| #include "../../../events/juce_Timer.h" | #include "../../../events/juce_Timer.h" | ||||
| #include "../../../threads/juce_Thread.h" | #include "../../../threads/juce_Thread.h" | ||||
| #include "../../../containers/juce_ScopedPointer.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| @@ -152,7 +153,7 @@ private: | |||||
| void timerCallback(); | void timerCallback(); | ||||
| double progress; | double progress; | ||||
| AlertWindow* alertWindow; | |||||
| ScopedPointer <AlertWindow> alertWindow; | |||||
| String message; | String message; | ||||
| CriticalSection messageLock; | CriticalSection messageLock; | ||||
| const int timeOutMsWhenCancelling; | const int timeOutMsWhenCancelling; | ||||
| @@ -147,8 +147,7 @@ TopLevelWindow::TopLevelWindow (const String& name, | |||||
| : Component (name), | : Component (name), | ||||
| useDropShadow (true), | useDropShadow (true), | ||||
| useNativeTitleBar (false), | useNativeTitleBar (false), | ||||
| windowIsActive_ (false), | |||||
| shadower (0) | |||||
| windowIsActive_ (false) | |||||
| { | { | ||||
| setOpaque (true); | setOpaque (true); | ||||
| @@ -164,7 +163,7 @@ TopLevelWindow::TopLevelWindow (const String& name, | |||||
| TopLevelWindow::~TopLevelWindow() | TopLevelWindow::~TopLevelWindow() | ||||
| { | { | ||||
| deleteAndZero (shadower); | |||||
| shadower = 0; | |||||
| TopLevelWindowManager::getInstance()->removeWindow (this); | TopLevelWindowManager::getInstance()->removeWindow (this); | ||||
| } | } | ||||
| @@ -220,7 +219,7 @@ void TopLevelWindow::setDropShadowEnabled (const bool useShadow) | |||||
| if (isOnDesktop()) | if (isOnDesktop()) | ||||
| { | { | ||||
| deleteAndZero (shadower); | |||||
| shadower = 0; | |||||
| Component::addToDesktop (getDesktopWindowStyleFlags()); | Component::addToDesktop (getDesktopWindowStyleFlags()); | ||||
| } | } | ||||
| else | else | ||||
| @@ -237,7 +236,7 @@ void TopLevelWindow::setDropShadowEnabled (const bool useShadow) | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| deleteAndZero (shadower); | |||||
| shadower = 0; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -160,7 +160,7 @@ protected: | |||||
| private: | private: | ||||
| friend class TopLevelWindowManager; | friend class TopLevelWindowManager; | ||||
| bool useDropShadow, useNativeTitleBar, windowIsActive_; | bool useDropShadow, useNativeTitleBar, windowIsActive_; | ||||
| DropShadower* shadower; | |||||
| ScopedPointer <DropShadower> shadower; | |||||
| void setWindowActive (const bool isNowActive) throw(); | void setWindowActive (const bool isNowActive) throw(); | ||||
| @@ -33,12 +33,12 @@ BEGIN_JUCE_NAMESPACE | |||||
| //============================================================================== | //============================================================================== | ||||
| FillType::FillType() throw() | FillType::FillType() throw() | ||||
| : colour (0xff000000), gradient (0), image (0) | |||||
| : colour (0xff000000), image (0) | |||||
| { | { | ||||
| } | } | ||||
| FillType::FillType (const Colour& colour_) throw() | FillType::FillType (const Colour& colour_) throw() | ||||
| : colour (colour_), gradient (0), image (0) | |||||
| : colour (colour_), image (0) | |||||
| { | { | ||||
| } | } | ||||
| @@ -48,8 +48,7 @@ FillType::FillType (const ColourGradient& gradient_) throw() | |||||
| } | } | ||||
| FillType::FillType (const Image& image_, const AffineTransform& transform_) throw() | FillType::FillType (const Image& image_, const AffineTransform& transform_) throw() | ||||
| : colour (0xff000000), gradient (0), | |||||
| image (&image_), transform (transform_) | |||||
| : colour (0xff000000), image (&image_), transform (transform_) | |||||
| { | { | ||||
| } | } | ||||
| @@ -65,7 +64,6 @@ const FillType& FillType::operator= (const FillType& other) throw() | |||||
| if (this != &other) | if (this != &other) | ||||
| { | { | ||||
| colour = other.colour; | colour = other.colour; | ||||
| delete gradient; | |||||
| gradient = (other.gradient != 0 ? new ColourGradient (*other.gradient) : 0); | gradient = (other.gradient != 0 ? new ColourGradient (*other.gradient) : 0); | ||||
| image = other.image; | image = other.image; | ||||
| transform = other.transform; | transform = other.transform; | ||||
| @@ -76,12 +74,11 @@ const FillType& FillType::operator= (const FillType& other) throw() | |||||
| FillType::~FillType() throw() | FillType::~FillType() throw() | ||||
| { | { | ||||
| delete gradient; | |||||
| } | } | ||||
| void FillType::setColour (const Colour& newColour) throw() | void FillType::setColour (const Colour& newColour) throw() | ||||
| { | { | ||||
| deleteAndZero (gradient); | |||||
| gradient = 0; | |||||
| image = 0; | image = 0; | ||||
| colour = newColour; | colour = newColour; | ||||
| } | } | ||||
| @@ -102,7 +99,7 @@ void FillType::setGradient (const ColourGradient& newGradient) throw() | |||||
| void FillType::setTiledImage (const Image& image_, const AffineTransform& transform_) throw() | void FillType::setTiledImage (const Image& image_, const AffineTransform& transform_) throw() | ||||
| { | { | ||||
| deleteAndZero (gradient); | |||||
| gradient = 0; | |||||
| image = &image_; | image = &image_; | ||||
| transform = transform_; | transform = transform_; | ||||
| colour = Colours::black; | colour = Colours::black; | ||||
| @@ -27,6 +27,7 @@ | |||||
| #define __JUCE_FILLTYPE_JUCEHEADER__ | #define __JUCE_FILLTYPE_JUCEHEADER__ | ||||
| #include "../colour/juce_ColourGradient.h" | #include "../colour/juce_ColourGradient.h" | ||||
| #include "../../../containers/juce_ScopedPointer.h" | |||||
| class Image; | class Image; | ||||
| @@ -114,7 +115,7 @@ public: | |||||
| If a gradient is active, the overall opacity with which it should be applied | If a gradient is active, the overall opacity with which it should be applied | ||||
| is indicated by the alpha channel of the colour variable. | is indicated by the alpha channel of the colour variable. | ||||
| */ | */ | ||||
| ColourGradient* gradient; | |||||
| ScopedPointer <ColourGradient> gradient; | |||||
| /** Returns the image that should be used for tiling. | /** Returns the image that should be used for tiling. | ||||
| The FillType object just keeps a pointer to this image, it doesn't own it, so you have to | The FillType object just keeps a pointer to this image, it doesn't own it, so you have to | ||||
| @@ -1349,7 +1349,6 @@ LowLevelGraphicsSoftwareRenderer::LowLevelGraphicsSoftwareRenderer (Image& image | |||||
| LowLevelGraphicsSoftwareRenderer::~LowLevelGraphicsSoftwareRenderer() | LowLevelGraphicsSoftwareRenderer::~LowLevelGraphicsSoftwareRenderer() | ||||
| { | { | ||||
| delete currentState; | |||||
| } | } | ||||
| bool LowLevelGraphicsSoftwareRenderer::isVectorDevice() const | bool LowLevelGraphicsSoftwareRenderer::isVectorDevice() const | ||||
| @@ -1417,7 +1416,6 @@ void LowLevelGraphicsSoftwareRenderer::restoreState() | |||||
| if (top != 0) | if (top != 0) | ||||
| { | { | ||||
| delete currentState; | |||||
| currentState = top; | currentState = top; | ||||
| stateStack.removeLast (1, false); | stateStack.removeLast (1, false); | ||||
| } | } | ||||
| @@ -1567,8 +1565,8 @@ public: | |||||
| class CachedGlyph | class CachedGlyph | ||||
| { | { | ||||
| public: | public: | ||||
| CachedGlyph() throw() : glyph (0), lastAccessCount (0), edgeTable (0) {} | |||||
| ~CachedGlyph() throw() { delete edgeTable; } | |||||
| CachedGlyph() : glyph (0), lastAccessCount (0) {} | |||||
| ~CachedGlyph() {} | |||||
| void draw (LLGCSavedState& state, Image& image, const float x, const float y) const throw() | void draw (LLGCSavedState& state, Image& image, const float x, const float y) const throw() | ||||
| { | { | ||||
| @@ -1584,7 +1582,7 @@ public: | |||||
| { | { | ||||
| font = newFont; | font = newFont; | ||||
| glyph = glyphNumber; | glyph = glyphNumber; | ||||
| deleteAndZero (edgeTable); | |||||
| edgeTable = 0; | |||||
| Path glyphPath; | Path glyphPath; | ||||
| font.getTypeface()->getOutlineForGlyph (glyphNumber, glyphPath); | font.getTypeface()->getOutlineForGlyph (glyphNumber, glyphPath); | ||||
| @@ -1611,7 +1609,7 @@ public: | |||||
| juce_UseDebuggingNewOperator | juce_UseDebuggingNewOperator | ||||
| private: | private: | ||||
| EdgeTable* edgeTable; | |||||
| ScopedPointer <EdgeTable> edgeTable; | |||||
| CachedGlyph (const CachedGlyph&); | CachedGlyph (const CachedGlyph&); | ||||
| const CachedGlyph& operator= (const CachedGlyph&); | const CachedGlyph& operator= (const CachedGlyph&); | ||||
| @@ -92,7 +92,7 @@ protected: | |||||
| //============================================================================== | //============================================================================== | ||||
| Image& image; | Image& image; | ||||
| LLGCSavedState* currentState; | |||||
| ScopedPointer <LLGCSavedState> currentState; | |||||
| OwnedArray <LLGCSavedState> stateStack; | OwnedArray <LLGCSavedState> stateStack; | ||||
| LowLevelGraphicsSoftwareRenderer (const LowLevelGraphicsSoftwareRenderer& other); | LowLevelGraphicsSoftwareRenderer (const LowLevelGraphicsSoftwareRenderer& other); | ||||
| @@ -104,20 +104,15 @@ Drawable* Drawable::createFromImageData (const void* data, const int numBytes) | |||||
| const String asString (String::createStringFromData (data, numBytes)); | const String asString (String::createStringFromData (data, numBytes)); | ||||
| XmlDocument doc (asString); | XmlDocument doc (asString); | ||||
| XmlElement* const outer = doc.getDocumentElement (true); | |||||
| ScopedPointer <XmlElement> outer (doc.getDocumentElement (true)); | |||||
| if (outer != 0 && outer->hasTagName (T("svg"))) | if (outer != 0 && outer->hasTagName (T("svg"))) | ||||
| { | { | ||||
| XmlElement* const svg = doc.getDocumentElement(); | |||||
| ScopedPointer <XmlElement> svg (doc.getDocumentElement()); | |||||
| if (svg != 0) | if (svg != 0) | ||||
| { | |||||
| result = Drawable::createFromSVG (*svg); | result = Drawable::createFromSVG (*svg); | ||||
| delete svg; | |||||
| } | |||||
| } | } | ||||
| delete outer; | |||||
| } | } | ||||
| return result; | return result; | ||||
| @@ -133,15 +128,9 @@ Drawable* Drawable::createFromImageDataStream (InputStream& dataSource) | |||||
| Drawable* Drawable::createFromImageFile (const File& file) | Drawable* Drawable::createFromImageFile (const File& file) | ||||
| { | { | ||||
| FileInputStream* fin = file.createInputStream(); | |||||
| if (fin == 0) | |||||
| return 0; | |||||
| const ScopedPointer <FileInputStream> fin (file.createInputStream()); | |||||
| Drawable* d = createFromImageDataStream (*fin); | |||||
| delete fin; | |||||
| return d; | |||||
| return fin != 0 ? createFromImageDataStream (*fin) : 0; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -51,12 +51,7 @@ DrawableImage::~DrawableImage() | |||||
| void DrawableImage::clearImage() | void DrawableImage::clearImage() | ||||
| { | { | ||||
| if (canDeleteImage && image != 0) | if (canDeleteImage && image != 0) | ||||
| { | |||||
| if (ImageCache::isImageInCache (image)) | |||||
| ImageCache::release (image); | |||||
| else | |||||
| delete image; | |||||
| } | |||||
| ImageCache::releaseOrDelete (image); | |||||
| image = 0; | image = 0; | ||||
| } | } | ||||
| @@ -137,10 +137,7 @@ TextLayout::~TextLayout() throw() | |||||
| void TextLayout::clear() throw() | void TextLayout::clear() throw() | ||||
| { | { | ||||
| for (int i = tokens.size(); --i >= 0;) | for (int i = tokens.size(); --i >= 0;) | ||||
| { | |||||
| TextLayoutToken* const t = (TextLayoutToken*)tokens.getUnchecked(i); | |||||
| delete t; | |||||
| } | |||||
| delete (TextLayoutToken*) tokens.getUnchecked(i); | |||||
| tokens.clear(); | tokens.clear(); | ||||
| totalLines = 0; | totalLines = 0; | ||||
| @@ -59,7 +59,7 @@ ImageCache::~ImageCache() | |||||
| for (int i = images.size(); --i >= 0;) | for (int i = images.size(); --i >= 0;) | ||||
| { | { | ||||
| CachedImageInfo* const ci = (CachedImageInfo*)(images.getUnchecked(i)); | |||||
| CachedImageInfo* const ci = (CachedImageInfo*) images.getUnchecked(i); | |||||
| delete ci->image; | delete ci->image; | ||||
| delete ci; | delete ci; | ||||
| } | } | ||||
| @@ -134,6 +134,14 @@ void ImageCache::release (Image* const imageToRelease) | |||||
| } | } | ||||
| } | } | ||||
| void ImageCache::releaseOrDelete (Image* const imageToRelease) | |||||
| { | |||||
| if (isImageInCache (imageToRelease)) | |||||
| release (imageToRelease); | |||||
| else | |||||
| delete imageToRelease; | |||||
| } | |||||
| bool ImageCache::isImageInCache (Image* const imageToLookFor) | bool ImageCache::isImageInCache (Image* const imageToLookFor) | ||||
| { | { | ||||
| if (instance != 0) | if (instance != 0) | ||||
| @@ -101,6 +101,13 @@ public: | |||||
| */ | */ | ||||
| static void release (Image* const imageToRelease); | static void release (Image* const imageToRelease); | ||||
| /** Releases an image if it's in the cache, or deletes it if it isn't cached. | |||||
| This is a handy function to use if you want to delete an image but are afraid that | |||||
| it might be cached. | |||||
| */ | |||||
| static void releaseOrDelete (Image* const imageToRelease); | |||||
| /** Checks whether an image is in the cache or not. | /** Checks whether an image is in the cache or not. | ||||
| @returns true if the image is currently in the cache | @returns true if the image is currently in the cache | ||||
| @@ -108,7 +108,7 @@ void ImageConvolutionKernel::applyToImage (Image& destImage, | |||||
| int dw, | int dw, | ||||
| int dh) const | int dh) const | ||||
| { | { | ||||
| Image* imageCreated = 0; | |||||
| ScopedPointer <Image> imageCreated; | |||||
| if (sourceImage == 0) | if (sourceImage == 0) | ||||
| { | { | ||||
| @@ -255,8 +255,6 @@ void ImageConvolutionKernel::applyToImage (Image& destImage, | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| delete imageCreated; | |||||
| } | } | ||||
| END_JUCE_NAMESPACE | END_JUCE_NAMESPACE | ||||