Browse Source

New class: ScopedPointer, which auto-releases a pointer when it goes out of scope. I've used this extensively to replace a lot of pointer deletions with more RAII-style patterns.

tags/2021-05-28
Julian Storer 16 years ago
parent
commit
c22c06c80c
100 changed files with 1294 additions and 1584 deletions
  1. +184
    -184
      build/linux/JUCE.make
  2. +16
    -10
      build/macosx/Juce.xcodeproj/project.pbxproj
  3. +17
    -17
      extras/juce demo/build/linux/JuceDemo.make
  4. +357
    -732
      juce_amalgamated.cpp
  5. +212
    -63
      juce_amalgamated.h
  6. +1
    -1
      src/application/juce_ApplicationCommandManager.cpp
  7. +1
    -1
      src/application/juce_ApplicationCommandManager.h
  8. +1
    -2
      src/application/juce_ApplicationCommandTarget.cpp
  9. +3
    -5
      src/application/juce_ApplicationProperties.cpp
  10. +1
    -2
      src/application/juce_ApplicationProperties.h
  11. +2
    -7
      src/audio/audio_file_formats/juce_AudioCDReader.cpp
  12. +1
    -1
      src/audio/audio_file_formats/juce_AudioCDReader.h
  13. +2
    -8
      src/audio/audio_file_formats/juce_AudioThumbnail.cpp
  14. +2
    -2
      src/audio/audio_file_formats/juce_AudioThumbnail.h
  15. +2
    -2
      src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp
  16. +20
    -23
      src/audio/audio_file_formats/juce_WavAudioFormat.cpp
  17. +3
    -5
      src/audio/audio_sources/juce_AudioTransportSource.cpp
  18. +7
    -17
      src/audio/devices/juce_AudioDeviceManager.cpp
  19. +4
    -4
      src/audio/devices/juce_AudioDeviceManager.h
  20. +17
    -22
      src/audio/midi/juce_MidiFile.cpp
  21. +2
    -2
      src/audio/midi/juce_MidiFile.h
  22. +6
    -8
      src/audio/plugins/formats/juce_VSTPluginFormat.cpp
  23. +0
    -3
      src/audio/synthesisers/juce_Sampler.cpp
  24. +1
    -1
      src/audio/synthesisers/juce_Sampler.h
  25. +3
    -6
      src/containers/juce_OwnedArray.h
  26. +181
    -0
      src/containers/juce_ScopedPointer.h
  27. +3
    -3
      src/core/juce_FileLogger.cpp
  28. +1
    -1
      src/core/juce_FileLogger.h
  29. +1
    -1
      src/core/juce_Logger.cpp
  30. +2
    -6
      src/cryptography/juce_MD5.cpp
  31. +20
    -28
      src/events/juce_InterprocessConnection.cpp
  32. +3
    -2
      src/events/juce_InterprocessConnection.h
  33. +6
    -13
      src/events/juce_InterprocessConnectionServer.cpp
  34. +1
    -1
      src/events/juce_InterprocessConnectionServer.h
  35. +4
    -7
      src/events/juce_MessageManager.cpp
  36. +2
    -2
      src/events/juce_MessageManager.h
  37. +1
    -2
      src/gui/components/buttons/juce_Button.cpp
  38. +1
    -1
      src/gui/components/buttons/juce_Button.h
  39. +0
    -16
      src/gui/components/buttons/juce_DrawableButton.cpp
  40. +2
    -8
      src/gui/components/buttons/juce_DrawableButton.h
  41. +3
    -23
      src/gui/components/buttons/juce_ImageButton.cpp
  42. +0
    -2
      src/gui/components/buttons/juce_ToolbarButton.cpp
  43. +1
    -2
      src/gui/components/buttons/juce_ToolbarButton.h
  44. +3
    -8
      src/gui/components/controls/juce_Label.cpp
  45. +2
    -2
      src/gui/components/controls/juce_Label.h
  46. +1
    -3
      src/gui/components/controls/juce_ListBox.cpp
  47. +2
    -2
      src/gui/components/controls/juce_Slider.cpp
  48. +1
    -1
      src/gui/components/controls/juce_Slider.h
  49. +5
    -9
      src/gui/components/controls/juce_TableHeaderComponent.cpp
  50. +1
    -1
      src/gui/components/controls/juce_TableHeaderComponent.h
  51. +1
    -4
      src/gui/components/controls/juce_TextEditor.cpp
  52. +1
    -3
      src/gui/components/controls/juce_ToolbarItemComponent.cpp
  53. +1
    -1
      src/gui/components/controls/juce_ToolbarItemComponent.h
  54. +1
    -2
      src/gui/components/controls/juce_TreeView.cpp
  55. +2
    -7
      src/gui/components/filebrowser/juce_DirectoryContentsList.cpp
  56. +1
    -1
      src/gui/components/filebrowser/juce_FileBrowserComponent.cpp
  57. +1
    -1
      src/gui/components/filebrowser/juce_FileBrowserComponent.h
  58. +1
    -3
      src/gui/components/filebrowser/juce_FileChooser.cpp
  59. +1
    -1
      src/gui/components/filebrowser/juce_FileListComponent.cpp
  60. +1
    -3
      src/gui/components/filebrowser/juce_FileTreeComponent.cpp
  61. +3
    -10
      src/gui/components/filebrowser/juce_ImagePreviewComponent.cpp
  62. +1
    -1
      src/gui/components/filebrowser/juce_ImagePreviewComponent.h
  63. +7
    -12
      src/gui/components/juce_Component.cpp
  64. +1
    -4
      src/gui/components/keyboard/juce_KeyMappingEditorComponent.cpp
  65. +1
    -3
      src/gui/components/keyboard/juce_KeyPressMappingSet.cpp
  66. +0
    -4
      src/gui/components/layout/juce_ComponentMovementWatcher.cpp
  67. +1
    -1
      src/gui/components/layout/juce_ComponentMovementWatcher.h
  68. +1
    -4
      src/gui/components/layout/juce_TabbedButtonBar.cpp
  69. +9
    -18
      src/gui/components/menus/juce_MenuBarComponent.cpp
  70. +1
    -1
      src/gui/components/menus/juce_MenuBarComponent.h
  71. +24
    -46
      src/gui/components/menus/juce_PopupMenu.cpp
  72. +35
    -51
      src/gui/components/mouse/juce_DragAndDropContainer.cpp
  73. +1
    -1
      src/gui/components/mouse/juce_DragAndDropContainer.h
  74. +5
    -10
      src/gui/components/special/juce_ColourSelector.cpp
  75. +1
    -1
      src/gui/components/special/juce_NSViewComponent.h
  76. +3
    -3
      src/gui/components/special/juce_PreferencesPanel.cpp
  77. +1
    -1
      src/gui/components/special/juce_PreferencesPanel.h
  78. +4
    -5
      src/gui/components/windows/juce_AlertWindow.cpp
  79. +2
    -4
      src/gui/components/windows/juce_ComponentPeer.cpp
  80. +1
    -1
      src/gui/components/windows/juce_ComponentPeer.h
  81. +7
    -17
      src/gui/components/windows/juce_DocumentWindow.cpp
  82. +3
    -3
      src/gui/components/windows/juce_DocumentWindow.h
  83. +12
    -20
      src/gui/components/windows/juce_ResizableWindow.cpp
  84. +3
    -3
      src/gui/components/windows/juce_ResizableWindow.h
  85. +2
    -8
      src/gui/components/windows/juce_SplashScreen.cpp
  86. +0
    -1
      src/gui/components/windows/juce_SplashScreen.h
  87. +0
    -1
      src/gui/components/windows/juce_ThreadWithProgressWindow.cpp
  88. +2
    -1
      src/gui/components/windows/juce_ThreadWithProgressWindow.h
  89. +4
    -5
      src/gui/components/windows/juce_TopLevelWindow.cpp
  90. +1
    -1
      src/gui/components/windows/juce_TopLevelWindow.h
  91. +5
    -8
      src/gui/graphics/contexts/juce_FillType.cpp
  92. +2
    -1
      src/gui/graphics/contexts/juce_FillType.h
  93. +4
    -6
      src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp
  94. +1
    -1
      src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h
  95. +4
    -15
      src/gui/graphics/drawables/juce_Drawable.cpp
  96. +1
    -6
      src/gui/graphics/drawables/juce_DrawableImage.cpp
  97. +1
    -4
      src/gui/graphics/fonts/juce_TextLayout.cpp
  98. +9
    -1
      src/gui/graphics/imaging/juce_ImageCache.cpp
  99. +7
    -0
      src/gui/graphics/imaging/juce_ImageCache.h
  100. +1
    -3
      src/gui/graphics/imaging/juce_ImageConvolutionKernel.cpp

+ 184
- 184
build/linux/JUCE.make
File diff suppressed because it is too large
View File


+ 16
- 10
build/macosx/Juce.xcodeproj/project.pbxproj View File

@@ -651,6 +651,8 @@
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 */; };
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 */; };
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 */; };
@@ -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>"; };
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>"; };
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>"; };
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; };
@@ -2170,6 +2173,7 @@
84F1E8D910403671006A1807 /* juce_PropertySet.h */,
84F1E8DA10403671006A1807 /* juce_ReferenceCountedArray.h */,
84F1E8DB10403671006A1807 /* juce_ReferenceCountedObject.h */,
84AF3FE710EF9FF30035D74F /* juce_ScopedPointer.h */,
84F1E8DC10403671006A1807 /* juce_SortedSet.h */,
84F1E8DD10403671006A1807 /* juce_SparseSet.h */,
843D4A3910D3C54500624BA6 /* juce_ValueTree.cpp */,
@@ -2219,19 +2223,19 @@
84F1E9251040369C006A1807 /* utilities */ = {
isa = PBXGroup;
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 */,
84F1E92D1040369C006A1807 /* juce_PropertiesFile.cpp */,
84F1E92E1040369C006A1807 /* juce_RecentlyOpenedFilesList.h */,
84F1E9311040369C006A1807 /* juce_FileBasedDocument.cpp */,
84F1E92F1040369C006A1807 /* juce_FileBasedDocument.h */,
84F1E92D1040369C006A1807 /* juce_PropertiesFile.cpp */,
84F1E9291040369C006A1807 /* juce_PropertiesFile.h */,
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;
path = ../../src/utilities;
@@ -3211,6 +3215,7 @@
844BB95F10C557A800DF5536 /* juce_Config.h in Headers */,
84B2053E10D535EC008B4A79 /* juce_ValueTree.h in Headers */,
84AB6F6E10EF948B00117E64 /* juce_HeapBlock.h in Headers */,
84AF419B10F0008E0035D74F /* juce_ScopedPointer.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -3536,6 +3541,7 @@
84F29AA010C2EFA5005014DF /* juce_FillType.h in Headers */,
843D4A3C10D3C54500624BA6 /* juce_ValueTree.h in Headers */,
84DEDD9F10EE496500909D01 /* juce_HeapBlock.h in Headers */,
84AF3FE810EF9FF30035D74F /* juce_ScopedPointer.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};


+ 17
- 17
extras/juce demo/build/linux/JuceDemo.make View File

@@ -39,29 +39,29 @@ ifeq ($(CONFIG),Release)
endif

OBJECTS := \
$(OBJDIR)/MainDemoWindow.o \
$(OBJDIR)/BinaryData.o \
$(OBJDIR)/ApplicationStartup.o \
$(OBJDIR)/juce_LibrarySource.o \
$(OBJDIR)/ApplicationStartup.o \
$(OBJDIR)/MainDemoWindow.o \
$(OBJDIR)/AudioDemoLatencyPage.o \
$(OBJDIR)/AudioDemoPlaybackPage.o \
$(OBJDIR)/AudioDemoRecordPage.o \
$(OBJDIR)/AudioDemoSetupPage.o \
$(OBJDIR)/AudioDemoSynthPage.o \
$(OBJDIR)/AudioDemoTabComponent.o \
$(OBJDIR)/CameraDemo.o \
$(OBJDIR)/DragAndDropDemo.o \
$(OBJDIR)/FontsAndTextDemo.o \
$(OBJDIR)/InterprocessCommsDemo.o \
$(OBJDIR)/OpenGLDemo.o \
$(OBJDIR)/RenderingTestComponent.o \
$(OBJDIR)/QuickTimeDemo.o \
$(OBJDIR)/TableDemo.o \
$(OBJDIR)/ThreadingDemo.o \
$(OBJDIR)/TreeViewDemo.o \
$(OBJDIR)/WebBrowserDemo.o \
$(OBJDIR)/CodeEditorDemo.o \
$(OBJDIR)/FontsAndTextDemo.o \
$(OBJDIR)/RenderingTestComponent.o \
$(OBJDIR)/WidgetsDemo.o \
$(OBJDIR)/AudioDemoRecordPage.o \

MKDIR_TYPE := msdos
CMD := $(subst \,\\,$(ComSpec)$(COMSPEC))
@@ -103,12 +103,12 @@ else
-@if exist $(subst /,\,$(OBJDIR)) rmdir /s /q $(subst /,\,$(OBJDIR))
endif

$(OBJDIR)/MainDemoWindow.o: ../../src/MainDemoWindow.cpp
$(OBJDIR)/BinaryData.o: ../../src/BinaryData.cpp
-@$(CMD_MKOBJDIR)
@echo $(notdir $<)
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<"

$(OBJDIR)/BinaryData.o: ../../src/BinaryData.cpp
$(OBJDIR)/juce_LibrarySource.o: ../../src/juce_LibrarySource.cpp
-@$(CMD_MKOBJDIR)
@echo $(notdir $<)
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<"
@@ -118,7 +118,7 @@ $(OBJDIR)/ApplicationStartup.o: ../../src/ApplicationStartup.cpp
@echo $(notdir $<)
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<"

$(OBJDIR)/juce_LibrarySource.o: ../../src/juce_LibrarySource.cpp
$(OBJDIR)/MainDemoWindow.o: ../../src/MainDemoWindow.cpp
-@$(CMD_MKOBJDIR)
@echo $(notdir $<)
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<"
@@ -133,11 +133,6 @@ $(OBJDIR)/AudioDemoPlaybackPage.o: ../../src/demos/AudioDemoPlaybackPage.cpp
@echo $(notdir $<)
@$(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
-@$(CMD_MKOBJDIR)
@echo $(notdir $<)
@@ -163,17 +158,17 @@ $(OBJDIR)/DragAndDropDemo.o: ../../src/demos/DragAndDropDemo.cpp
@echo $(notdir $<)
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<"

$(OBJDIR)/InterprocessCommsDemo.o: ../../src/demos/InterprocessCommsDemo.cpp
$(OBJDIR)/FontsAndTextDemo.o: ../../src/demos/FontsAndTextDemo.cpp
-@$(CMD_MKOBJDIR)
@echo $(notdir $<)
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<"

$(OBJDIR)/OpenGLDemo.o: ../../src/demos/OpenGLDemo.cpp
$(OBJDIR)/InterprocessCommsDemo.o: ../../src/demos/InterprocessCommsDemo.cpp
-@$(CMD_MKOBJDIR)
@echo $(notdir $<)
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<"

$(OBJDIR)/RenderingTestComponent.o: ../../src/demos/RenderingTestComponent.cpp
$(OBJDIR)/OpenGLDemo.o: ../../src/demos/OpenGLDemo.cpp
-@$(CMD_MKOBJDIR)
@echo $(notdir $<)
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<"
@@ -208,7 +203,7 @@ $(OBJDIR)/CodeEditorDemo.o: ../../src/demos/CodeEditorDemo.cpp
@echo $(notdir $<)
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<"

$(OBJDIR)/FontsAndTextDemo.o: ../../src/demos/FontsAndTextDemo.cpp
$(OBJDIR)/RenderingTestComponent.o: ../../src/demos/RenderingTestComponent.cpp
-@$(CMD_MKOBJDIR)
@echo $(notdir $<)
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<"
@@ -218,5 +213,10 @@ $(OBJDIR)/WidgetsDemo.o: ../../src/demos/WidgetsDemo.cpp
@echo $(notdir $<)
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<"

$(OBJDIR)/AudioDemoRecordPage.o: ../../src/demos/AudioDemoRecordPage.cpp
-@$(CMD_MKOBJDIR)
@echo $(notdir $<)
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<"

-include $(OBJECTS:%.o=%.d)


+ 357
- 732
juce_amalgamated.cpp
File diff suppressed because it is too large
View File


+ 212
- 63
juce_amalgamated.h View File

@@ -4933,6 +4933,158 @@ private:
#ifndef __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.

This holds a list of pointers to objects, and will automatically
@@ -5238,7 +5390,7 @@ public:
{
if (indexToChange >= 0)
{
ObjectClass* toDelete = 0;
ScopedPointer <ObjectClass> toDelete;
lock.enter();

if (indexToChange < numUsed)
@@ -5260,8 +5412,6 @@ public:
}

lock.exit();

delete toDelete;
}
}

@@ -5352,8 +5502,8 @@ public:
void remove (const int indexToRemove,
const bool deleteObject = true)
{
ScopedPointer <ObjectClass> toDelete;
lock.enter();
ObjectClass* toDelete = 0;

if (((unsigned int) indexToRemove) < (unsigned int) numUsed)
{
@@ -5373,8 +5523,6 @@ public:
}

lock.exit();

delete toDelete;
}

/** Removes a specified object from the array.
@@ -10018,6 +10166,9 @@ private:
#endif
#ifndef __JUCE_REFERENCECOUNTEDOBJECT_JUCEHEADER__

#endif
#ifndef __JUCE_SCOPEDPOINTER_JUCEHEADER__

#endif
#ifndef __JUCE_SORTEDSET_JUCEHEADER__

@@ -12293,7 +12444,7 @@ public:
private:
File logFile;
CriticalSection logLock;
FileOutputStream* logStream;
ScopedPointer <FileOutputStream> logStream;

void trimFileSize (int maxFileSizeBytes) const;

@@ -13688,7 +13839,7 @@ private:
String wildCard;
int index;
const int whatToLookFor;
DirectoryIterator* subIterator;
ScopedPointer <DirectoryIterator> subIterator;

DirectoryIterator (const DirectoryIterator&);
const DirectoryIterator& operator= (const DirectoryIterator&);
@@ -14197,7 +14348,7 @@ private:
friend class ZipInputStream;
CriticalSection lock;
InputStream* inputStream;
InputSource* inputSource;
ScopedPointer <InputSource> inputSource;

bool deleteStreamWhenDestroyed;
int numEntries, centralRecStart;
@@ -15435,7 +15586,7 @@ private:
String lastError, dtdText;
StringArray tokenisedDTD;
bool needToLoadDTD, ignoreEmptyTextElements;
InputSource* inputSource;
ScopedPointer <InputSource> inputSource;

void setLastError (const String& desc, const bool carryOn) throw();
void skipHeader() throw();
@@ -21162,7 +21313,7 @@ public:
If a gradient is active, the overall opacity with which it should be applied
is indicated by the alpha channel of the colour variable.
*/
ColourGradient* gradient;
ScopedPointer <ColourGradient> gradient;

/** 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
@@ -22667,7 +22818,7 @@ protected:
private:

Component* lastFocusedComponent;
ComponentDeletionWatcher* dragAndDropTargetComponent;
ScopedPointer <ComponentDeletionWatcher> dragAndDropTargetComponent;
Component* lastDragAndDropCompUnderMouse;
bool fakeMouseMessageSent : 1, isWindowMinimised : 1;

@@ -26218,7 +26369,7 @@ private:

OwnedArray <ApplicationCommandInfo> commands;
SortedSet <void*> listeners;
KeyPressMappingSet* keyMappings;
ScopedPointer <KeyPressMappingSet> keyMappings;
ApplicationCommandTarget* firstTarget;

void sendListenerInvokeCallback (const ApplicationCommandTarget::InvocationInfo& info) const;
@@ -26528,8 +26679,7 @@ public:

private:

PropertiesFile* userProps;
PropertiesFile* commonProps;
ScopedPointer <PropertiesFile> userProps, commonProps;

String appName, fileSuffix, folderName;
int msBeforeSaving, options;
@@ -27789,7 +27939,7 @@ private:
OwnedArray<File> tracks;
Array <int> trackStartSamples;
int currentReaderTrack;
AudioFormatReader* reader;
ScopedPointer <AudioFormatReader> reader;
AudioCDReader (const File& volume);
public:
static int compareElements (const File* const, const File* const) throw();
@@ -28127,10 +28277,10 @@ public:
private:
AudioFormatManager& formatManagerToUse;
AudioThumbnailCache& cache;
InputSource* source;
ScopedPointer <InputSource> source;

CriticalSection readerLock;
AudioFormatReader* reader;
ScopedPointer <AudioFormatReader> reader;

MemoryBlock data, cachedLevels;
int orginalSamplesPerThumbnailSample;
@@ -31884,7 +32034,7 @@ private:
SortedSet <void*> buttonListeners;

friend class InternalButtonRepeatTimer;
Timer* repeatTimer;
ScopedPointer <Timer> repeatTimer;
uint32 buttonPressTime, lastTimeCallbackTime;
ApplicationCommandManager* commandManagerToUse;
int autoRepeatDelay, autoRepeatSpeed, autoRepeatMinimumDelay;
@@ -33759,10 +33909,10 @@ private:
String text;
Font font;
Justification justification;
TextEditor* editor;
ScopedPointer <TextEditor> editor;
SortedSet <void*> listeners;
Component* ownerComponent;
ComponentDeletionWatcher* deletionWatcher;
ScopedPointer <ComponentDeletionWatcher> deletionWatcher;
int horizontalBorderSize, verticalBorderSize;
float minimumHorizontalScale;
bool editSingleClick : 1;
@@ -34502,17 +34652,17 @@ private:
OwnedArray <AudioDeviceSetup> lastDeviceTypeConfigs;

AudioDeviceSetup currentSetup;
AudioIODevice* currentAudioDevice;
ScopedPointer <AudioIODevice> currentAudioDevice;
SortedSet <AudioIODeviceCallback*> callbacks;
int numInputChansNeeded, numOutputChansNeeded;
String currentDeviceType;
BitArray inputChannels, outputChannels;
XmlElement* lastExplicitSettings;
ScopedPointer <XmlElement> lastExplicitSettings;
mutable bool listNeedsScanning;
bool useInputNames;
int inputLevelMeasurementEnabledCount;
double inputLevel;
AudioSampleBuffer* testSound;
ScopedPointer <AudioSampleBuffer> testSound;
int testSoundPosition;
AudioSampleBuffer tempBuffer;

@@ -34521,7 +34671,7 @@ private:
Array <MidiInputCallback*> midiCallbacks;
Array <MidiInput*> midiCallbackDevices;
String defaultMidiOutputName;
MidiOutput* defaultMidiOutput;
ScopedPointer <MidiOutput> defaultMidiOutput;
CriticalSection audioCallbackLock, midiCallbackLock;

double cpuUsageMs, timeToCpuScale;
@@ -35066,8 +35216,8 @@ public:
const MidiMessageSequence::MidiEventHolder* const second) throw();

private:
MidiMessageSequence* tracks [128];
short numTracks, timeFormat;
OwnedArray <MidiMessageSequence> tracks;
short timeFormat;

MidiFile (const MidiFile&);
const MidiFile& operator= (const MidiFile&);
@@ -38914,7 +39064,7 @@ private:
friend class SamplerVoice;

String name;
AudioSampleBuffer* data;
ScopedPointer <AudioSampleBuffer> data;
double sourceSampleRate;
BitArray midiNotes;
int length, attackSamples, releaseSamples;
@@ -39321,8 +39471,8 @@ public:

private:
CriticalSection pipeAndSocketLock;
StreamingSocket* socket;
NamedPipe* pipe;
ScopedPointer <StreamingSocket> socket;
ScopedPointer <NamedPipe> pipe;
bool callbackConnectionState;
const bool useMessageThread;
const uint32 magicMessageHeader;
@@ -39412,7 +39562,7 @@ public:
juce_UseDebuggingNewOperator

private:
StreamingSocket* volatile socket;
ScopedPointer <StreamingSocket> socket;

void run();

@@ -39568,8 +39718,8 @@ private:
friend class CallbackMessage;
static MessageManager* instance;

SortedSet<const MessageListener*> messageListeners;
ActionListenerList* broadcastListeners;
SortedSet <const MessageListener*> messageListeners;
ScopedPointer <ActionListenerList> broadcastListeners;

friend class JUCEApplication;
bool quitMessagePosted, quitMessageReceived;
@@ -40228,14 +40378,8 @@ protected:
private:

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;
int edgeIndent;

@@ -40915,7 +41059,7 @@ protected:

private:
friend class DragImageComponent;
Component* dragImageComponent;
ScopedPointer <Component> dragImageComponent;
String currentDragDesc;
};

@@ -41470,7 +41614,7 @@ private:
const int itemId;
ToolbarEditingMode mode;
Toolbar::ToolbarItemStyle toolbarStyle;
Component* overlayComp;
ScopedPointer <Component> overlayComp;
int dragOffsetX, dragOffsetY;
bool isActive, isBeingDragged, isBeingUsedAsAButton;
Rectangle contentArea;
@@ -41531,8 +41675,7 @@ public:
juce_UseDebuggingNewOperator

private:
Drawable* const normalImage;
Drawable* const toggledOnImage;
ScopedPointer <Drawable> normalImage, toggledOnImage;

ToolbarButton (const ToolbarButton&);
const ToolbarButton& operator= (const ToolbarButton&);
@@ -43108,7 +43251,7 @@ private:
Label* valueBox;
Button* incButton;
Button* decButton;
Component* popupDisplay;
ScopedPointer <Component> popupDisplay;
Component* parentForPopupDisplay;

float getLinearSliderPos (const double value);
@@ -43508,7 +43651,7 @@ private:

OwnedArray <ColumnInfo> columns;
Array <TableHeaderListener*> listeners;
Component* dragOverlayComp;
ScopedPointer <Component> dragOverlayComp;

bool columnsChanged, columnsResized, sortChanged, menuActive, stretchToFit;
int columnIdBeingResized, columnIdBeingDragged, initialColumnWidth;
@@ -45619,7 +45762,7 @@ protected:

private:

DirectoryContentsList* fileList;
ScopedPointer <DirectoryContentsList> fileList;
const FileFilter* fileFilter;

int flags;
@@ -46036,7 +46179,7 @@ protected:
private:
friend class TopLevelWindowManager;
bool useDropShadow, useNativeTitleBar, windowIsActive_;
DropShadower* shadower;
ScopedPointer <DropShadower> shadower;

void setWindowActive (const bool isNowActive) throw();

@@ -46740,11 +46883,11 @@ protected:

#endif

ResizableCornerComponent* resizableCorner;
ResizableBorderComponent* resizableBorder;
ScopedPointer <ResizableCornerComponent> resizableCorner;
ScopedPointer <ResizableBorderComponent> resizableBorder;

private:
Component* contentComponent;
ScopedPointer <Component> contentComponent;
bool resizeToFitContent, fullscreen;
ComponentDragger dragger;
Rectangle lastNonFullScreenPos;
@@ -47635,7 +47778,7 @@ public:

private:
File fileToLoad;
Image* currentThumbnail;
ScopedPointer <Image> currentThumbnail;
String currentDetails;

void getThumbSize (int& w, int& h) const;
@@ -48138,7 +48281,7 @@ private:
bool reentrant;
int lastX, lastY, lastWidth, lastHeight;
#ifdef JUCE_DEBUG
ComponentDeletionWatcher* deletionWatcher;
ScopedPointer <ComponentDeletionWatcher> deletionWatcher;
#endif

void unregister() throw();
@@ -48936,7 +49079,7 @@ private:
int itemUnderMouse, currentPopupIndex, topLevelIndexClicked, indexToShowAgain;
int lastMouseX, lastMouseY;
bool inModalState;
Component* currentPopup;
ScopedPointer <Component> currentPopup;

int getItemAt (int x, int y);
void updateItemUnderMouse (const int x, const int y);
@@ -49160,9 +49303,9 @@ public:
private:
int titleBarHeight, menuBarHeight, requiredButtons;
bool positionTitleBarButtonsOnLeft, drawTitleTextCentred;
Button* titleBarButtons [3];
Image* titleBarIcon;
MenuBarComponent* menuBar;
ScopedPointer <Button> titleBarButtons [3];
ScopedPointer <Image> titleBarIcon;
ScopedPointer <MenuBarComponent> menuBar;
MenuBarModel* menuBarModel;

class ButtonListenerProxy : public ButtonListener
@@ -53112,7 +53255,7 @@ public:

private:
friend class NSViewComponentInternal;
NSViewComponentInternal* info;
ScopedPointer <NSViewComponentInternal> info;

NSViewComponent (const NSViewComponent&);
const NSViewComponent& operator= (const NSViewComponent&);
@@ -53543,7 +53686,7 @@ public:
private:

String currentPageName;
Component* currentPage;
ScopedPointer <Component> currentPage;
int buttonSize;

PreferencesPanel (const PreferencesPanel&);
@@ -54160,7 +54303,6 @@ private:
Image* backgroundImage;
Time earliestTimeToDelete;
int originalClickCounter;
bool isImageInCache;

SplashScreen (const SplashScreen&);
const SplashScreen& operator= (const SplashScreen&);
@@ -54293,7 +54435,7 @@ private:
void timerCallback();

double progress;
AlertWindow* alertWindow;
ScopedPointer <AlertWindow> alertWindow;
String message;
CriticalSection messageLock;
const int timeOutMsWhenCancelling;
@@ -54572,7 +54714,7 @@ protected:

Image& image;

LLGCSavedState* currentState;
ScopedPointer <LLGCSavedState> currentState;
OwnedArray <LLGCSavedState> stateStack;

LowLevelGraphicsSoftwareRenderer (const LowLevelGraphicsSoftwareRenderer& other);
@@ -55741,6 +55883,13 @@ public:
*/
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.

@returns true if the image is currently in the cache


+ 1
- 1
src/application/juce_ApplicationCommandManager.cpp View File

@@ -49,7 +49,7 @@ ApplicationCommandManager::ApplicationCommandManager()
ApplicationCommandManager::~ApplicationCommandManager()
{
Desktop::getInstance().removeFocusChangeListener (this);
deleteAndZero (keyMappings);
keyMappings = 0;
}
//==============================================================================


+ 1
- 1
src/application/juce_ApplicationCommandManager.h View File

@@ -321,7 +321,7 @@ private:
//==============================================================================
OwnedArray <ApplicationCommandInfo> commands;
SortedSet <void*> listeners;
KeyPressMappingSet* keyMappings;
ScopedPointer <KeyPressMappingSet> keyMappings;
ApplicationCommandTarget* firstTarget;
void sendListenerInvokeCallback (const ApplicationCommandTarget::InvocationInfo& info) const;


+ 1
- 2
src/application/juce_ApplicationCommandTarget.cpp View File

@@ -193,9 +193,8 @@ ApplicationCommandTarget::CommandTargetMessageInvoker::~CommandTargetMessageInvo
void ApplicationCommandTarget::CommandTargetMessageInvoker::handleMessage (const Message& message)
{
InvocationInfo* const info = (InvocationInfo*) message.pointerParameter;
const ScopedPointer <InvocationInfo> info ((InvocationInfo*) message.pointerParameter);
owner->tryToInvoke (*info, false);
delete info;
}


+ 3
- 5
src/application/juce_ApplicationProperties.cpp View File

@@ -38,9 +38,7 @@ juce_ImplementSingleton (ApplicationProperties)
//==============================================================================
ApplicationProperties::ApplicationProperties() throw()
: userProps (0),
commonProps (0),
msBeforeSaving (3000),
: msBeforeSaving (3000),
options (PropertiesFile::storeAsBinary),
commonSettingsAreReadOnly (0)
{
@@ -153,8 +151,8 @@ bool ApplicationProperties::saveIfNeeded()
void ApplicationProperties::closeFiles()
{
deleteAndZero (userProps);
deleteAndZero (commonProps);
userProps = 0;
commonProps = 0;
}


+ 1
- 2
src/application/juce_ApplicationProperties.h View File

@@ -148,8 +148,7 @@ public:
private:
//==============================================================================
PropertiesFile* userProps;
PropertiesFile* commonProps;
ScopedPointer <PropertiesFile> userProps, commonProps;
String appName, fileSuffix, folderName;
int msBeforeSaving, options;


+ 2
- 7
src/audio/audio_file_formats/juce_AudioCDReader.cpp View File

@@ -89,8 +89,6 @@ AudioCDReader::AudioCDReader (const File& volume)
AudioCDReader::~AudioCDReader()
{
if (reader != 0)
delete reader;
}
static int getTrackNumber (const File& file)
@@ -129,13 +127,10 @@ void AudioCDReader::refreshTrackLengths()
if (in != 0)
{
AudioFormatReader* const r = format.createReaderFor (in, true);
ScopedPointer <AudioFormatReader> r (format.createReaderFor (in, true));
if (r != 0)
{
sample += (int) r->lengthInSamples;
delete r;
}
}
}
@@ -164,7 +159,7 @@ bool AudioCDReader::readSamples (int** destSamples, int numDestChannels, int sta
if (track != currentReaderTrack)
{
deleteAndZero (reader);
reader = 0;
if (tracks [track] != 0)
{


+ 1
- 1
src/audio/audio_file_formats/juce_AudioCDReader.h View File

@@ -155,7 +155,7 @@ private:
OwnedArray<File> tracks;
Array <int> trackStartSamples;
int currentReaderTrack;
AudioFormatReader* reader;
ScopedPointer <AudioFormatReader> reader;
AudioCDReader (const File& volume);
public:
static int compareElements (const File* const, const File* const) throw();


+ 2
- 8
src/audio/audio_file_formats/juce_AudioThumbnail.cpp View File

@@ -72,8 +72,6 @@ AudioThumbnail::AudioThumbnail (const int orginalSamplesPerThumbnailSample_,
AudioThumbnailCache& cacheToUse)
: formatManagerToUse (formatManagerToUse_),
cache (cacheToUse),
source (0),
reader (0),
orginalSamplesPerThumbnailSample (orginalSamplesPerThumbnailSample_)
{
clear();
@@ -84,9 +82,7 @@ AudioThumbnail::~AudioThumbnail()
cache.removeThumbnail (this);
const ScopedLock sl (readerLock);
deleteAndZero (reader);
delete source;
reader = 0;
}
void AudioThumbnail::setSource (InputSource* const newSource)
@@ -94,9 +90,7 @@ void AudioThumbnail::setSource (InputSource* const newSource)
cache.removeThumbnail (this);
timerCallback(); // stops the timer and deletes the reader
delete source;
source = newSource;
clear();
if (newSource != 0
@@ -170,7 +164,7 @@ void AudioThumbnail::timerCallback()
stopTimer();
const ScopedLock sl (readerLock);
deleteAndZero (reader);
reader = 0;
}
void AudioThumbnail::clear()


+ 2
- 2
src/audio/audio_file_formats/juce_AudioThumbnail.h View File

@@ -152,10 +152,10 @@ public:
private:
AudioFormatManager& formatManagerToUse;
AudioThumbnailCache& cache;
InputSource* source;
ScopedPointer <InputSource> source;
CriticalSection readerLock;
AudioFormatReader* reader;
ScopedPointer <AudioFormatReader> reader;
MemoryBlock data, cachedLevels;
int orginalSamplesPerThumbnailSample;


+ 2
- 2
src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp View File

@@ -478,12 +478,12 @@ int OggVorbisAudioFormat::estimateOggFileQuality (const File& source)
if (in != 0)
{
AudioFormatReader* const r = createReaderFor (in, true);
ScopedPointer <AudioFormatReader> r (createReaderFor (in, true));
if (r != 0)
{
const int64 numSamps = r->lengthInSamples;
delete r;
r = 0;
const int64 fileNumSamps = source.getSize() / 4;
const double ratio = numSamps / (double) fileNumSamps;


+ 20
- 23
src/audio/audio_file_formats/juce_WavAudioFormat.cpp View File

@@ -798,30 +798,26 @@ static bool juce_slowCopyOfWavFileWithNewMetadata (const File& file, const Strin
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)
@@ -835,13 +831,13 @@ static bool juce_slowCopyOfWavFileWithNewMetadata (const File& file, const Strin
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)
{
const int64 bwavPos = reader->bwavChunkStart;
const int64 bwavSize = reader->bwavSize;
delete reader;
reader = 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..
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);


+ 3
- 5
src/audio/audio_sources/juce_AudioTransportSource.cpp View File

@@ -29,6 +29,7 @@ BEGIN_JUCE_NAMESPACE
#include "juce_AudioTransportSource.h"
#include "../../threads/juce_ScopedLock.h"
#include "../../containers/juce_ScopedPointer.h"
//==============================================================================
@@ -78,8 +79,8 @@ void AudioTransportSource::setSource (PositionableAudioSource* const newSource,
PositionableAudioSource* newPositionableSource = 0;
AudioSource* newMasterSource = 0;
ResamplingAudioSource* oldResamplerSource = resamplerSource;
BufferingAudioSource* oldBufferingSource = bufferingSource;
ScopedPointer <ResamplingAudioSource> oldResamplerSource (resamplerSource);
ScopedPointer <BufferingAudioSource> oldBufferingSource (bufferingSource);
AudioSource* oldMasterSource = masterSource;
if (newSource != 0)
@@ -121,9 +122,6 @@ void AudioTransportSource::setSource (PositionableAudioSource* const newSource,
if (oldMasterSource != 0)
oldMasterSource->releaseResources();
delete oldResamplerSource;
delete oldBufferingSource;
}
void AudioTransportSource::start()


+ 7
- 17
src/audio/devices/juce_AudioDeviceManager.cpp View File

@@ -59,12 +59,10 @@ AudioDeviceManager::AudioDeviceManager()
: currentAudioDevice (0),
numInputChansNeeded (0),
numOutputChansNeeded (2),
lastExplicitSettings (0),
listNeedsScanning (true),
useInputNames (false),
inputLevelMeasurementEnabledCount (0),
inputLevel (0),
testSound (0),
tempBuffer (2, 2),
enabledMidiInputs (4),
midiCallbacks (4),
@@ -78,10 +76,8 @@ 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")))
{
delete lastExplicitSettings;
lastExplicitSettings = new XmlElement (*e);
String error;
@@ -324,7 +319,7 @@ void AudioDeviceManager::getAudioDeviceSetup (AudioDeviceSetup& setup)
void AudioDeviceManager::deleteCurrentDevice()
{
deleteAndZero (currentAudioDevice);
currentAudioDevice = 0;
currentSetup.inputDeviceName = String::empty;
currentSetup.outputDeviceName = String::empty;
}
@@ -526,13 +521,13 @@ void AudioDeviceManager::stopDevice()
if (currentAudioDevice != 0)
currentAudioDevice->stop();
deleteAndZero (testSound);
testSound = 0;
}
void AudioDeviceManager::closeAudioDevice()
{
stopDevice();
deleteAndZero (currentAudioDevice);
currentAudioDevice = 0;
}
void AudioDeviceManager::restartLastAudioDevice()
@@ -556,7 +551,6 @@ void AudioDeviceManager::restartLastAudioDevice()
void AudioDeviceManager::updateXml()
{
delete lastExplicitSettings;
lastExplicitSettings = new XmlElement (T("DEVICESETUP"));
lastExplicitSettings->setAttribute (T("deviceType"), currentDeviceType);
@@ -719,10 +713,7 @@ void AudioDeviceManager::audioDeviceIOCallbackInt (const float** inputChannelDat
testSoundPosition += numSamps;
if (testSoundPosition >= testSound->getNumSamples())
{
delete testSound;
testSound = 0;
}
}
}
@@ -887,7 +878,7 @@ void AudioDeviceManager::setDefaultMidiOutput (const String& deviceName)
for (int i = oldCallbacks.size(); --i >= 0;)
oldCallbacks.getUnchecked(i)->audioDeviceStopped();
deleteAndZero (defaultMidiOutput);
defaultMidiOutput = 0;
defaultMidiOutputName = deviceName;
if (deviceName.isNotEmpty())
@@ -936,8 +927,7 @@ void AudioDeviceManager::CallbackHandler::handleIncomingMidiMessage (MidiInput*
void AudioDeviceManager::playTestSound()
{
audioCallbackLock.enter();
AudioSampleBuffer* oldSound = testSound;
testSound = 0;
AudioSampleBuffer* oldSound = testSound.release();
audioCallbackLock.exit();
delete oldSound;


+ 4
- 4
src/audio/devices/juce_AudioDeviceManager.h View File

@@ -422,17 +422,17 @@ private:
OwnedArray <AudioDeviceSetup> lastDeviceTypeConfigs;
AudioDeviceSetup currentSetup;
AudioIODevice* currentAudioDevice;
ScopedPointer <AudioIODevice> currentAudioDevice;
SortedSet <AudioIODeviceCallback*> callbacks;
int numInputChansNeeded, numOutputChansNeeded;
String currentDeviceType;
BitArray inputChannels, outputChannels;
XmlElement* lastExplicitSettings;
ScopedPointer <XmlElement> lastExplicitSettings;
mutable bool listNeedsScanning;
bool useInputNames;
int inputLevelMeasurementEnabledCount;
double inputLevel;
AudioSampleBuffer* testSound;
ScopedPointer <AudioSampleBuffer> testSound;
int testSoundPosition;
AudioSampleBuffer tempBuffer;
@@ -441,7 +441,7 @@ private:
Array <MidiInputCallback*> midiCallbacks;
Array <MidiInput*> midiCallbackDevices;
String defaultMidiOutputName;
MidiOutput* defaultMidiOutput;
ScopedPointer <MidiOutput> defaultMidiOutput;
CriticalSection audioCallbackLock, midiCallbackLock;
double cpuUsageMs, timeToCpuScale;


+ 17
- 22
src/audio/midi/juce_MidiFile.cpp View File

@@ -44,8 +44,7 @@ struct TimeSigInfo
};
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()
{
while (numTracks > 0)
delete tracks [--numTracks];
tracks.clear();
}
//==============================================================================
int MidiFile::getNumTracks() const throw()
{
return numTracks;
return tracks.size();
}
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()
{
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
{
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)
{
const MidiMessage& m = tracks[i]->getEventPointer (j)->message;
const MidiMessage& m = tracks.getUnchecked(i)->getEventPointer (j)->message;
if (m.isTempoMetaEvent())
tempoChangeEvents.addEvent (m);
@@ -115,13 +110,13 @@ void MidiFile::findAllTempoEvents (MidiMessageSequence& tempoChangeEvents) 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)
{
const MidiMessage& m = tracks[i]->getEventPointer (j)->message;
const MidiMessage& m = tracks.getUnchecked(i)->getEventPointer (j)->message;
if (m.isTimeSignatureMetaEvent())
timeSigEvents.addEvent (m);
@@ -133,8 +128,8 @@ double MidiFile::getLastTimestamp() const
{
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;
}
@@ -366,9 +361,9 @@ void MidiFile::convertTimestampTicksToSeconds()
findAllTempoEvents (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;)
{
@@ -408,10 +403,10 @@ bool MidiFile::writeTo (OutputStream& out)
out.writeIntBigEndian ((int) bigEndianInt ("MThd"));
out.writeIntBigEndian (6);
out.writeShortBigEndian (1); // type
out.writeShortBigEndian (numTracks);
out.writeShortBigEndian (tracks.size());
out.writeShortBigEndian (timeFormat);
for (int i = 0; i < numTracks; ++i)
for (int i = 0; i < tracks.size(); ++i)
writeTrack (out, i);
out.flush();


+ 2
- 2
src/audio/midi/juce_MidiFile.h View File

@@ -182,8 +182,8 @@ public:
const MidiMessageSequence::MidiEventHolder* const second) throw();
private:
MidiMessageSequence* tracks [128];
short numTracks, timeFormat;
OwnedArray <MidiMessageSequence> tracks;
short timeFormat;
MidiFile (const MidiFile&);
const MidiFile& operator= (const MidiFile&);


+ 6
- 8
src/audio/plugins/formats/juce_VSTPluginFormat.cpp View File

@@ -1193,7 +1193,7 @@ public:
~VSTPluginWindow()
{
#if JUCE_MAC
deleteAndZero (innerWrapper);
innerWrapper = 0;
#else
closePluginWindow();
#endif
@@ -1889,7 +1889,7 @@ private:
};
friend class InnerWrapperComponent;
InnerWrapperComponent* innerWrapper;
ScopedPointer <InnerWrapperComponent> innerWrapper;
void resized()
{
@@ -2825,7 +2825,7 @@ void VSTPluginFormat::findAllTypesForFile (OwnedArray <PluginDescription>& resul
desc.fileOrIdentifier = fileOrIdentifier;
desc.uid = 0;
VSTPluginInstance* instance = dynamic_cast <VSTPluginInstance*> (createInstanceFromDescription (desc));
ScopedPointer <VSTPluginInstance> instance (dynamic_cast <VSTPluginInstance*> (createInstanceFromDescription (desc)));
if (instance == 0)
return;
@@ -2892,13 +2892,11 @@ void VSTPluginFormat::findAllTypesForFile (OwnedArray <PluginDescription>& resul
{
// crashed while loading...
}
deleteAndZero (instance);
}
AudioPluginInstance* VSTPluginFormat::createInstanceFromDescription (const PluginDescription& desc)
{
VSTPluginInstance* result = 0;
ScopedPointer <VSTPluginInstance> result;
if (fileMightContainThisPluginType (desc.fileOrIdentifier))
{
@@ -2922,14 +2920,14 @@ AudioPluginInstance* VSTPluginFormat::createInstanceFromDescription (const Plugi
}
else
{
deleteAndZero (result);
result = 0;
}
}
previousWorkingDirectory.setAsCurrentWorkingDirectory();
}
return result;
return result.release();
}
bool VSTPluginFormat::fileMightContainThisPluginType (const String& fileOrIdentifier)


+ 0
- 3
src/audio/synthesisers/juce_Sampler.cpp View File

@@ -47,7 +47,6 @@ SamplerSound::SamplerSound (const String& name_,
if (sourceSampleRate <= 0 || source.lengthInSamples <= 0)
{
data = 0;
length = 0;
attackSamples = 0;
releaseSamples = 0;
@@ -68,8 +67,6 @@ SamplerSound::SamplerSound (const String& name_,
SamplerSound::~SamplerSound()
{
delete data;
data = 0;
}
//==============================================================================


+ 1
- 1
src/audio/synthesisers/juce_Sampler.h View File

@@ -97,7 +97,7 @@ private:
friend class SamplerVoice;
String name;
AudioSampleBuffer* data;
ScopedPointer <AudioSampleBuffer> data;
double sourceSampleRate;
BitArray midiNotes;
int length, attackSamples, releaseSamples;


+ 3
- 6
src/containers/juce_OwnedArray.h View File

@@ -29,6 +29,7 @@
#include "juce_ArrayAllocationBase.h"
#include "juce_ElementComparator.h"
#include "../threads/juce_CriticalSection.h"
#include "../containers/juce_ScopedPointer.h"
//==============================================================================
@@ -341,7 +342,7 @@ public:
{
if (indexToChange >= 0)
{
ObjectClass* toDelete = 0;
ScopedPointer <ObjectClass> toDelete;
lock.enter();
if (indexToChange < numUsed)
@@ -363,8 +364,6 @@ public:
}
lock.exit();
delete toDelete;
}
}
@@ -456,8 +455,8 @@ public:
void remove (const int indexToRemove,
const bool deleteObject = true)
{
ScopedPointer <ObjectClass> toDelete;
lock.enter();
ObjectClass* toDelete = 0;
if (((unsigned int) indexToRemove) < (unsigned int) numUsed)
{
@@ -477,8 +476,6 @@ public:
}
lock.exit();
delete toDelete;
}
/** Removes a specified object from the array.


+ 181
- 0
src/containers/juce_ScopedPointer.h View File

@@ -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__

+ 3
- 3
src/core/juce_FileLogger.cpp View File

@@ -32,6 +32,7 @@ BEGIN_JUCE_NAMESPACE
#include "../io/files/juce_FileOutputStream.h"
#include "../io/files/juce_FileInputStream.h"
#include "../threads/juce_ScopedLock.h"
#include "../containers/juce_ScopedPointer.h"
#include "juce_SystemStats.h"
@@ -64,7 +65,6 @@ FileLogger::FileLogger (const File& logFile_,
FileLogger::~FileLogger()
{
deleteAndZero (logStream);
}
//==============================================================================
@@ -93,7 +93,7 @@ void FileLogger::trimFileSize (int maxFileSizeBytes) const
if (fileSize > maxFileSizeBytes)
{
FileInputStream* const in = logFile.createInputStream();
ScopedPointer <FileInputStream> in (logFile.createInputStream());
jassert (in != 0);
if (in != 0)
@@ -107,7 +107,7 @@ void FileLogger::trimFileSize (int maxFileSizeBytes) const
contentToSave.fillWith (0);
in->read (contentToSave.getData(), maxFileSizeBytes);
delete in;
in = 0;
content = contentToSave.toString();
}


+ 1
- 1
src/core/juce_FileLogger.h View File

@@ -97,7 +97,7 @@ public:
private:
File logFile;
CriticalSection logLock;
FileOutputStream* logStream;
ScopedPointer <FileOutputStream> logStream;
void trimFileSize (int maxFileSizeBytes) const;


+ 1
- 1
src/core/juce_Logger.cpp View File

@@ -48,7 +48,7 @@ void Logger::setCurrentLogger (Logger* const newLogger,
Logger* const oldLogger = currentLogger;
currentLogger = newLogger;
if (deleteOldLogger && (oldLogger != 0))
if (deleteOldLogger)
delete oldLogger;
}


+ 2
- 6
src/cryptography/juce_MD5.cpp View File

@@ -30,6 +30,7 @@ BEGIN_JUCE_NAMESPACE
#include "juce_MD5.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)
{
FileInputStream* const fin = file.createInputStream();
const ScopedPointer <FileInputStream> fin (file.createInputStream());
if (fin != 0)
{
processStream (*fin, -1);
delete fin;
}
else
{
zeromem (result, sizeof (result));
}
}
MD5::~MD5()


+ 20
- 28
src/events/juce_InterprocessConnection.cpp View File

@@ -29,14 +29,13 @@ BEGIN_JUCE_NAMESPACE
#include "juce_InterprocessConnection.h"
#include "../threads/juce_ScopedLock.h"
#include "../containers/juce_ScopedPointer.h"
//==============================================================================
InterprocessConnection::InterprocessConnection (const bool callbacksOnMessageThread,
const uint32 magicMessageHeaderNumber)
: Thread ("Juce IPC connection"),
socket (0),
pipe (0),
callbackConnectionState (false),
useMessageThread (callbacksOnMessageThread),
magicMessageHeader (magicMessageHeaderNumber),
@@ -69,7 +68,7 @@ bool InterprocessConnection::connectToSocket (const String& hostName,
}
else
{
deleteAndZero (socket);
socket = 0;
return false;
}
}
@@ -79,20 +78,17 @@ bool InterprocessConnection::connectToPipe (const String& pipeName,
{
disconnect();
NamedPipe* const newPipe = new NamedPipe();
ScopedPointer <NamedPipe> newPipe (new NamedPipe());
if (newPipe->openExisting (pipeName))
{
const ScopedLock sl (pipeAndSocketLock);
pipeReceiveMessageTimeout = pipeReceiveMessageTimeoutMs;
initialiseWithPipe (newPipe);
initialiseWithPipe (newPipe.release());
return true;
}
else
{
delete newPipe;
return false;
}
return false;
}
bool InterprocessConnection::createPipe (const String& pipeName,
@@ -100,20 +96,17 @@ bool InterprocessConnection::createPipe (const String& pipeName,
{
disconnect();
NamedPipe* const newPipe = new NamedPipe();
ScopedPointer <NamedPipe> newPipe (new NamedPipe());
if (newPipe->createNewPipe (pipeName))
{
const ScopedLock sl (pipeAndSocketLock);
pipeReceiveMessageTimeout = pipeReceiveMessageTimeoutMs;
initialiseWithPipe (newPipe);
initialiseWithPipe (newPipe.release());
return true;
}
else
{
delete newPipe;
return false;
}
return false;
}
void InterprocessConnection::disconnect()
@@ -131,8 +124,8 @@ void InterprocessConnection::disconnect()
{
const ScopedLock sl (pipeAndSocketLock);
deleteAndZero (socket);
deleteAndZero (pipe);
socket = 0;
pipe = 0;
}
connectionLostInt();
@@ -223,12 +216,11 @@ void InterprocessConnection::handleMessage (const Message& message)
switch (message.intParameter2)
{
case 0:
{
MemoryBlock* const data = (MemoryBlock*) message.pointerParameter;
messageReceived (*data);
delete data;
break;
}
{
ScopedPointer <MemoryBlock> data ((MemoryBlock*) message.pointerParameter);
messageReceived (*data);
break;
}
case 1:
connectionMade();
@@ -320,7 +312,7 @@ bool InterprocessConnection::readNextMessageInt()
{
{
const ScopedLock sl (pipeAndSocketLock);
deleteAndZero (socket);
socket = 0;
}
connectionLostInt();
@@ -342,7 +334,7 @@ void InterprocessConnection::run()
{
{
const ScopedLock sl (pipeAndSocketLock);
deleteAndZero (socket);
socket = 0;
}
connectionLostInt();
@@ -364,7 +356,7 @@ void InterprocessConnection::run()
{
{
const ScopedLock sl (pipeAndSocketLock);
deleteAndZero (pipe);
pipe = 0;
}
connectionLostInt();


+ 3
- 2
src/events/juce_InterprocessConnection.h View File

@@ -30,6 +30,7 @@
#include "../threads/juce_Thread.h"
#include "../io/network/juce_Socket.h"
#include "../io/files/juce_NamedPipe.h"
#include "../containers/juce_ScopedPointer.h"
class InterprocessConnectionServer;
@@ -186,8 +187,8 @@ public:
private:
CriticalSection pipeAndSocketLock;
StreamingSocket* socket;
NamedPipe* pipe;
ScopedPointer <StreamingSocket> socket;
ScopedPointer <NamedPipe> pipe;
bool callbackConnectionState;
const bool useMessageThread;
const uint32 magicMessageHeader;


+ 6
- 13
src/events/juce_InterprocessConnectionServer.cpp View File

@@ -28,12 +28,12 @@
BEGIN_JUCE_NAMESPACE
#include "juce_InterprocessConnectionServer.h"
#include "../containers/juce_ScopedPointer.h"
//==============================================================================
InterprocessConnectionServer::InterprocessConnectionServer()
: Thread ("Juce IPC server"),
socket (0)
: Thread ("Juce IPC server")
{
}
@@ -55,7 +55,7 @@ bool InterprocessConnectionServer::beginWaitingForSocket (const int portNumber)
return true;
}
deleteAndZero (socket);
socket = 0;
return false;
}
@@ -67,28 +67,21 @@ void InterprocessConnectionServer::stop()
socket->close();
stopThread (4000);
deleteAndZero (socket);
socket = 0;
}
void InterprocessConnectionServer::run()
{
while ((! threadShouldExit()) && socket != 0)
{
StreamingSocket* const clientSocket = socket->waitForNextConnection();
ScopedPointer <StreamingSocket> clientSocket (socket->waitForNextConnection());
if (clientSocket != 0)
{
InterprocessConnection* newConnection = createConnectionObject();
if (newConnection != 0)
{
newConnection->initialiseWithSocket (clientSocket);
}
else
{
delete clientSocket;
}
newConnection->initialiseWithSocket (clientSocket.release());
}
}
}


+ 1
- 1
src/events/juce_InterprocessConnectionServer.h View File

@@ -88,7 +88,7 @@ public:
juce_UseDebuggingNewOperator
private:
StreamingSocket* volatile socket;
ScopedPointer <StreamingSocket> socket;
void run();


+ 4
- 7
src/events/juce_MessageManager.cpp View File

@@ -47,8 +47,7 @@ MessageManager* MessageManager::instance = 0;
static const int quitMessageId = 0xfffff321;
MessageManager::MessageManager() throw()
: broadcastListeners (0),
quitMessagePosted (false),
: quitMessagePosted (false),
quitMessageReceived (false),
threadWithLock (0)
{
@@ -57,7 +56,7 @@ MessageManager::MessageManager() throw()
MessageManager::~MessageManager() throw()
{
deleteAndZero (broadcastListeners);
broadcastListeners = 0;
doPlatformSpecificShutdown();
@@ -102,7 +101,7 @@ void MessageManager::postCallbackMessage (Message* const message)
// not for public use..
void MessageManager::deliverMessage (void* message)
{
Message* const m = (Message*) message;
const ScopedPointer <Message> m ((Message*) message);
MessageListener* const recipient = m->messageRecipient;
JUCE_TRY
@@ -119,7 +118,7 @@ void MessageManager::deliverMessage (void* message)
}
else
{
CallbackMessage* const cm = dynamic_cast <CallbackMessage*> (m);
CallbackMessage* const cm = dynamic_cast <CallbackMessage*> ((Message*) m);
if (cm != 0)
cm->messageCallback();
@@ -127,8 +126,6 @@ void MessageManager::deliverMessage (void* message)
}
}
JUCE_CATCH_EXCEPTION
delete m;
}
//==============================================================================


+ 2
- 2
src/events/juce_MessageManager.h View File

@@ -174,8 +174,8 @@ private:
friend class CallbackMessage;
static MessageManager* instance;
SortedSet<const MessageListener*> messageListeners;
ActionListenerList* broadcastListeners;
SortedSet <const MessageListener*> messageListeners;
ScopedPointer <ActionListenerList> broadcastListeners;
friend class JUCEApplication;
bool quitMessagePosted, quitMessageReceived;


+ 1
- 2
src/gui/components/buttons/juce_Button.cpp View File

@@ -40,7 +40,6 @@ Button::Button (const String& name)
keySource (0),
text (name),
buttonListeners (2),
repeatTimer (0),
buttonPressTime (0),
lastTimeCallbackTime (0),
commandManagerToUse (0),
@@ -67,7 +66,7 @@ Button::~Button()
if (commandManagerToUse != 0)
commandManagerToUse->removeListener (this);
delete repeatTimer;
repeatTimer = 0;
clearShortcuts();
}


+ 1
- 1
src/gui/components/buttons/juce_Button.h View File

@@ -464,7 +464,7 @@ private:
SortedSet <void*> buttonListeners;
friend class InternalButtonRepeatTimer;
Timer* repeatTimer;
ScopedPointer <Timer> repeatTimer;
uint32 buttonPressTime, lastTimeCallbackTime;
ApplicationCommandManager* commandManagerToUse;
int autoRepeatDelay, autoRepeatSpeed, autoRepeatMinimumDelay;


+ 0
- 16
src/gui/components/buttons/juce_DrawableButton.cpp View File

@@ -36,14 +36,6 @@ DrawableButton::DrawableButton (const String& name,
const DrawableButton::ButtonStyle buttonStyle)
: Button (name),
style (buttonStyle),
normalImage (0),
overImage (0),
downImage (0),
disabledImage (0),
normalImageOn (0),
overImageOn (0),
downImageOn (0),
disabledImageOn (0),
edgeIndent (3)
{
if (buttonStyle == ImageOnButtonBackground)
@@ -66,14 +58,6 @@ DrawableButton::~DrawableButton()
//==============================================================================
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,


+ 2
- 8
src/gui/components/buttons/juce_DrawableButton.h View File

@@ -165,14 +165,8 @@ protected:
private:
//==============================================================================
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;
int edgeIndent;


+ 3
- 23
src/gui/components/buttons/juce_ImageButton.cpp View File

@@ -55,29 +55,9 @@ ImageButton::~ImageButton()
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,


+ 0
- 2
src/gui/components/buttons/juce_ToolbarButton.cpp View File

@@ -46,8 +46,6 @@ ToolbarButton::ToolbarButton (const int itemId_,
ToolbarButton::~ToolbarButton()
{
delete normalImage;
delete toggledOnImage;
}
//==============================================================================


+ 1
- 2
src/gui/components/buttons/juce_ToolbarButton.h View File

@@ -81,8 +81,7 @@ public:
juce_UseDebuggingNewOperator
private:
Drawable* const normalImage;
Drawable* const toggledOnImage;
ScopedPointer <Drawable> normalImage, toggledOnImage;
ToolbarButton (const ToolbarButton&);
const ToolbarButton& operator= (const ToolbarButton&);


+ 3
- 8
src/gui/components/controls/juce_Label.cpp View File

@@ -38,10 +38,8 @@ Label::Label (const String& componentName,
text (labelText),
font (15.0f),
justification (Justification::centredLeft),
editor (0),
listeners (2),
ownerComponent (0),
deletionWatcher (0),
horizontalBorderSize (3),
verticalBorderSize (1),
minimumHorizontalScale (0.7f),
@@ -59,10 +57,7 @@ Label::~Label()
if (ownerComponent != 0 && ! deletionWatcher->hasBeenDeleted())
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())
ownerComponent->removeComponentListener (this);
deleteAndZero (deletionWatcher);
deletionWatcher = 0;
ownerComponent = owner;
leftOfOwnerComp = onLeft;
@@ -251,7 +246,7 @@ void Label::hideEditor (const bool discardCurrentEditorContents)
const bool changed = (! discardCurrentEditorContents)
&& updateFromTextEditorContents();
deleteAndZero (editor);
editor = 0;
repaint();
if (changed)


+ 2
- 2
src/gui/components/controls/juce_Label.h View File

@@ -316,10 +316,10 @@ private:
String text;
Font font;
Justification justification;
TextEditor* editor;
ScopedPointer <TextEditor> editor;
SortedSet <void*> listeners;
Component* ownerComponent;
ComponentDeletionWatcher* deletionWatcher;
ScopedPointer <ComponentDeletionWatcher> deletionWatcher;
int horizontalBorderSize, verticalBorderSize;
float minimumHorizontalScale;
bool editSingleClick : 1;


+ 1
- 3
src/gui/components/controls/juce_ListBox.cpp View File

@@ -872,9 +872,7 @@ void ListBox::setHeaderComponent (Component* const newHeaderComponent)
{
if (headerComponent != newHeaderComponent)
{
if (headerComponent != 0)
delete headerComponent;
delete headerComponent;
headerComponent = newHeaderComponent;
addAndMakeVisible (newHeaderComponent);


+ 2
- 2
src/gui/components/controls/juce_Slider.cpp View File

@@ -141,7 +141,7 @@ Slider::Slider (const String& name)
Slider::~Slider()
{
deleteAndZero (popupDisplay);
popupDisplay = 0;
deleteAllChildren();
}
@@ -1099,7 +1099,7 @@ void Slider::mouseUp (const MouseEvent&)
sendDragEnd();
deleteAndZero (popupDisplay);
popupDisplay = 0;
if (style == IncDecButtons)
{


+ 1
- 1
src/gui/components/controls/juce_Slider.h View File

@@ -751,7 +751,7 @@ private:
Label* valueBox;
Button* incButton;
Button* decButton;
Component* popupDisplay;
ScopedPointer <Component> popupDisplay;
Component* parentForPopupDisplay;
float getLinearSliderPos (const double value);


+ 5
- 9
src/gui/components/controls/juce_TableHeaderComponent.cpp View File

@@ -47,7 +47,6 @@ public:
~DragOverlayComp()
{
delete image;
}
void paint (Graphics& g)
@@ -56,7 +55,7 @@ public:
}
private:
Image* image;
ScopedPointer <Image> image;
DragOverlayComp (const DragOverlayComp&);
const DragOverlayComp& operator= (const DragOverlayComp&);
@@ -66,7 +65,6 @@ private:
//==============================================================================
TableHeaderComponent::TableHeaderComponent()
: listeners (2),
dragOverlayComp (0),
columnsChanged (false),
columnsResized (false),
sortChanged (false),
@@ -81,7 +79,7 @@ TableHeaderComponent::TableHeaderComponent()
TableHeaderComponent::~TableHeaderComponent()
{
delete dragOverlayComp;
dragOverlayComp = 0;
}
//==============================================================================
@@ -465,7 +463,7 @@ const String TableHeaderComponent::toString() const
void TableHeaderComponent::restoreFromString (const String& storedVersion)
{
XmlDocument doc (storedVersion);
XmlElement* const storedXml = doc.getDocumentElement();
ScopedPointer <XmlElement> storedXml (doc.getDocumentElement());
int index = 0;
@@ -493,8 +491,6 @@ void TableHeaderComponent::restoreFromString (const String& storedVersion)
setSortColumnId (storedXml->getIntAttribute (T("sortedCol")),
storedXml->getBoolAttribute (T("sortForwards"), true));
}
delete storedXml;
}
//==============================================================================
@@ -619,7 +615,7 @@ void TableHeaderComponent::mouseDrag (const MouseEvent& e)
&& columnIdBeingDragged == 0
&& ! (e.mouseWasClicked() || e.mods.isPopupMenu()))
{
deleteAndZero (dragOverlayComp);
dragOverlayComp = 0;
columnIdBeingResized = getResizeDraggerAt (e.getMouseDownX());
@@ -799,7 +795,7 @@ void TableHeaderComponent::mouseUp (const MouseEvent& e)
if (columnIdUnderMouse != 0 && e.mouseWasClicked() && ! e.mods.isPopupMenu())
columnClicked (columnIdUnderMouse, e.mods);
deleteAndZero (dragOverlayComp);
dragOverlayComp = 0;
}
const MouseCursor TableHeaderComponent::getMouseCursor()


+ 1
- 1
src/gui/components/controls/juce_TableHeaderComponent.h View File

@@ -413,7 +413,7 @@ private:
OwnedArray <ColumnInfo> columns;
Array <TableHeaderListener*> listeners;
Component* dragOverlayComp;
ScopedPointer <Component> dragOverlayComp;
bool columnsChanged, columnsResized, sortChanged, menuActive, stretchToFit;
int columnIdBeingResized, columnIdBeingDragged, initialColumnWidth;


+ 1
- 4
src/gui/components/controls/juce_TextEditor.cpp View File

@@ -102,10 +102,7 @@ public:
void clear() throw()
{
for (int i = atoms.size(); --i >= 0;)
{
TextAtom* const atom = getAtom(i);
delete atom;
}
delete getAtom(i);
atoms.clear();
}


+ 1
- 3
src/gui/components/controls/juce_ToolbarItemComponent.cpp View File

@@ -153,7 +153,6 @@ ToolbarItemComponent::ToolbarItemComponent (const int itemId_,
itemId (itemId_),
mode (normalMode),
toolbarStyle (Toolbar::iconsOnly),
overlayComp (0),
dragOffsetX (0),
dragOffsetY (0),
isActive (true),
@@ -167,7 +166,7 @@ ToolbarItemComponent::ToolbarItemComponent (const int itemId_,
ToolbarItemComponent::~ToolbarItemComponent()
{
jassert (overlayComp == 0 || overlayComp->isValidComponent());
delete overlayComp;
overlayComp = 0;
}
Toolbar* ToolbarItemComponent::getToolbar() const
@@ -255,7 +254,6 @@ void ToolbarItemComponent::setEditingMode (const ToolbarEditingMode newMode)
if (mode == normalMode)
{
jassert (overlayComp == 0 || overlayComp->isValidComponent());
delete overlayComp;
overlayComp = 0;
}
else if (overlayComp == 0)


+ 1
- 1
src/gui/components/controls/juce_ToolbarItemComponent.h View File

@@ -200,7 +200,7 @@ private:
const int itemId;
ToolbarEditingMode mode;
Toolbar::ToolbarItemStyle toolbarStyle;
Component* overlayComp;
ScopedPointer <Component> overlayComp;
int dragOffsetX, dragOffsetY;
bool isActive, isBeingDragged, isBeingUsedAsAButton;
Rectangle contentArea;


+ 1
- 2
src/gui/components/controls/juce_TreeView.cpp View File

@@ -463,9 +463,8 @@ void TreeView::setRootItem (TreeViewItem* const newRootItem)
void TreeView::deleteRootItem()
{
TreeViewItem* const oldItem = rootItem;
const ScopedPointer <TreeViewItem> deleter (rootItem);
setRootItem (0);
delete oldItem;
}


+ 2
- 7
src/gui/components/filebrowser/juce_DirectoryContentsList.cpp View File

@@ -277,7 +277,7 @@ bool DirectoryContentsList::addFile (const String& filename,
|| ((! isDir) && fileFilter->isFileSuitable (file))
|| (isDir && fileFilter->isDirectorySuitable (file))))
{
FileInfo* const info = new FileInfo();
ScopedPointer <FileInfo> info (new FileInfo());
info->filename = filename;
info->fileSize = fileSize;
@@ -289,15 +289,10 @@ bool DirectoryContentsList::addFile (const String& filename,
const ScopedLock sl (fileListLock);
for (int i = files.size(); --i >= 0;)
{
if (files.getUnchecked(i)->filename == info->filename)
{
delete info;
return false;
}
}
files.addSorted (*this, info);
files.addSorted (*this, info.release());
return true;
}


+ 1
- 1
src/gui/components/filebrowser/juce_FileBrowserComponent.cpp View File

@@ -146,7 +146,7 @@ FileBrowserComponent::~FileBrowserComponent()
removeChildComponent (previewComp);
deleteAllChildren();
deleteAndZero (fileList);
fileList = 0;
thread.stopThread (10000);
}


+ 1
- 1
src/gui/components/filebrowser/juce_FileBrowserComponent.h View File

@@ -207,7 +207,7 @@ protected:
private:
//==============================================================================
DirectoryContentsList* fileList;
ScopedPointer <DirectoryContentsList> fileList;
const FileFilter* fileFilter;
int flags;


+ 1
- 3
src/gui/components/filebrowser/juce_FileChooser.cpp View File

@@ -107,7 +107,7 @@ bool FileChooser::showDialog (const bool selectsDirectories,
const bool selectMultipleFiles,
FilePreviewComponent* const previewComponent)
{
ComponentDeletionWatcher* currentlyFocusedChecker = 0;
ScopedPointer <ComponentDeletionWatcher> currentlyFocusedChecker;
Component* const currentlyFocused = Component::getCurrentlyFocusedComponent();
if (currentlyFocused != 0)
@@ -168,8 +168,6 @@ bool FileChooser::showDialog (const bool selectsDirectories,
if (currentlyFocused != 0 && ! currentlyFocusedChecker->hasBeenDeleted())
currentlyFocused->grabKeyboardFocus();
delete currentlyFocusedChecker;
return results.size() > 0;
}


+ 1
- 1
src/gui/components/filebrowser/juce_FileListComponent.cpp View File

@@ -243,7 +243,7 @@ Component* FileListComponent::refreshComponentForRow (int row, bool isSelected,
if (comp == 0)
{
delete existingComponentToUpdate;
existingComponentToUpdate = comp = new FileListItemComponent (*this, fileList.getTimeSliceThread());
comp = new FileListItemComponent (*this, fileList.getTimeSliceThread());
}
DirectoryContentsList::FileInfo fileInfo;


+ 1
- 3
src/gui/components/filebrowser/juce_FileTreeComponent.cpp View File

@@ -242,9 +242,7 @@ FileTreeComponent::FileTreeComponent (DirectoryContentsList& listToShow)
FileTreeComponent::~FileTreeComponent()
{
TreeViewItem* const root = getRootItem();
setRootItem (0);
delete root;
deleteRootItem();
}
//==============================================================================


+ 3
- 10
src/gui/components/filebrowser/juce_ImagePreviewComponent.cpp View File

@@ -34,13 +34,11 @@ BEGIN_JUCE_NAMESPACE
//==============================================================================
ImagePreviewComponent::ImagePreviewComponent()
: currentThumbnail (0)
{
}
ImagePreviewComponent::~ImagePreviewComponent()
{
delete currentThumbnail;
}
//==============================================================================
@@ -70,11 +68,11 @@ void ImagePreviewComponent::timerCallback()
{
stopTimer();
deleteAndZero (currentThumbnail);
currentThumbnail = 0;
currentDetails = String::empty;
repaint();
FileInputStream* const in = fileToLoad.createInputStream();
ScopedPointer <FileInputStream> in (fileToLoad.createInputStream());
if (in != 0)
{
@@ -97,14 +95,9 @@ void ImagePreviewComponent::timerCallback()
getThumbSize (w, h);
Image* const reduced = currentThumbnail->createCopy (w, h);
delete currentThumbnail;
currentThumbnail = reduced;
currentThumbnail = currentThumbnail->createCopy (w, h);
}
}
delete in;
}
}


+ 1
- 1
src/gui/components/filebrowser/juce_ImagePreviewComponent.h View File

@@ -60,7 +60,7 @@ public:
private:
File fileToLoad;
Image* currentThumbnail;
ScopedPointer <Image> currentThumbnail;
String currentDetails;
void getThumbSize (int& w, int& h) const;


+ 7
- 12
src/gui/components/juce_Component.cpp View File

@@ -1412,7 +1412,7 @@ int Component::runModalLoop()
Component* const prevFocused = getCurrentlyFocusedComponent();
ComponentDeletionWatcher* deletionChecker = 0;
ScopedPointer <ComponentDeletionWatcher> deletionChecker;
if (prevFocused != 0)
deletionChecker = new ComponentDeletionWatcher (prevFocused);
@@ -1455,13 +1455,8 @@ int Component::runModalLoop()
modalComponentStack.removeValue (this);
if (deletionChecker != 0)
{
if (! deletionChecker->hasBeenDeleted())
prevFocused->grabKeyboardFocus();
delete deletionChecker;
}
if (deletionChecker != 0 && ! deletionChecker->hasBeenDeleted())
prevFocused->grabKeyboardFocus();
return returnValue;
}
@@ -3339,12 +3334,12 @@ void Component::grabFocusInternal (const FocusChangeType cause, const bool canTr
else
{
// find the default child component..
KeyboardFocusTraverser* const traverser = createFocusTraverser();
ScopedPointer <KeyboardFocusTraverser> traverser (createFocusTraverser());
if (traverser != 0)
{
Component* const defaultComp = traverser->getDefaultComponent (this);
delete traverser;
traverser = 0;
if (defaultComp != 0)
{
@@ -3381,13 +3376,13 @@ void Component::moveKeyboardFocusToSibling (const bool moveToNext)
if (parentComponent_ != 0)
{
KeyboardFocusTraverser* const traverser = createFocusTraverser();
ScopedPointer <KeyboardFocusTraverser> traverser (createFocusTraverser());
if (traverser != 0)
{
Component* const nextComp = moveToNext ? traverser->getNextComponent (this)
: traverser->getPreviousComponent (this);
delete traverser;
traverser = 0;
if (nextComp != 0)
{


+ 1
- 4
src/gui/components/keyboard/juce_KeyMappingEditorComponent.cpp View File

@@ -381,7 +381,7 @@ void KeyMappingEditorComponent::buttonClicked (Button* button)
void KeyMappingEditorComponent::changeListenerCallback (void*)
{
XmlElement* openness = tree->getOpennessState (true);
ScopedPointer <XmlElement> openness (tree->getOpennessState (true));
clearSubItems();
@@ -401,10 +401,7 @@ void KeyMappingEditorComponent::changeListenerCallback (void*)
}
if (openness != 0)
{
tree->restoreOpennessState (*openness);
delete openness;
}
}
//==============================================================================


+ 1
- 3
src/gui/components/keyboard/juce_KeyPressMappingSet.cpp View File

@@ -276,7 +276,7 @@ bool KeyPressMappingSet::restoreFromXml (const XmlElement& xmlVersion)
XmlElement* KeyPressMappingSet::createXml (const bool saveDifferencesFromDefaultSet) const
{
KeyPressMappingSet* defaultSet = 0;
ScopedPointer <KeyPressMappingSet> defaultSet;
if (saveDifferencesFromDefaultSet)
{
@@ -329,8 +329,6 @@ XmlElement* KeyPressMappingSet::createXml (const bool saveDifferencesFromDefault
}
}
}
delete defaultSet;
}
return doc;


+ 0
- 4
src/gui/components/layout/juce_ComponentMovementWatcher.cpp View File

@@ -53,10 +53,6 @@ ComponentMovementWatcher::~ComponentMovementWatcher()
component->removeComponentListener (this);
unregister();
#ifdef JUCE_DEBUG
delete deletionWatcher;
#endif
}
//==============================================================================


+ 1
- 1
src/gui/components/layout/juce_ComponentMovementWatcher.h View File

@@ -83,7 +83,7 @@ private:
bool reentrant;
int lastX, lastY, lastWidth, lastHeight;
#ifdef JUCE_DEBUG
ComponentDeletionWatcher* deletionWatcher;
ScopedPointer <ComponentDeletionWatcher> deletionWatcher;
#endif
void unregister() throw();


+ 1
- 4
src/gui/components/layout/juce_TabbedButtonBar.cpp View File

@@ -282,10 +282,7 @@ void TabbedButtonBar::removeTab (const int tabIndex)
tabs.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)
{


+ 9
- 18
src/gui/components/menus/juce_MenuBarComponent.cpp View File

@@ -56,8 +56,7 @@ MenuBarComponent::MenuBarComponent (MenuBarModel* model_)
indexToShowAgain (-1),
lastMouseX (0),
lastMouseY (0),
inModalState (false),
currentPopup (0)
inModalState (false)
{
setRepaintsOnMouseActivity (true);
setWantsKeyboardFocus (false);
@@ -71,7 +70,7 @@ MenuBarComponent::~MenuBarComponent()
setModel (0);
Desktop::getInstance().removeGlobalMouseListener (this);
deleteAndZero (currentPopup);
currentPopup = 0;
}
void MenuBarComponent::setModel (MenuBarModel* const newModel)
@@ -173,7 +172,7 @@ void MenuBarComponent::updateItemUnderMouse (int x, int y)
void MenuBarComponent::hideCurrentMenu()
{
deleteAndZero (currentPopup);
currentPopup = 0;
repaint();
}
@@ -191,12 +190,12 @@ void MenuBarComponent::showMenu (int index)
indexToShowAgain = -1;
currentPopupIndex = -1;
itemUnderMouse = index;
deleteAndZero (currentPopup);
currentPopup = 0;
menuBarItemsChanged (0);
Component* const prevFocused = getCurrentlyFocusedComponent();
ComponentDeletionWatcher* prevCompDeletionChecker = 0;
ScopedPointer <ComponentDeletionWatcher> prevCompDeletionChecker;
if (prevFocused != 0)
prevCompDeletionChecker = new ComponentDeletionWatcher (prevFocused);
@@ -246,13 +245,10 @@ void MenuBarComponent::showMenu (int index)
result = currentPopup->runModalLoop();
if (deletionChecker.hasBeenDeleted())
{
delete prevCompDeletionChecker;
return;
}
const int lastPopupIndex = currentPopupIndex;
deleteAndZero (currentPopup);
currentPopup = 0;
currentPopupIndex = -1;
if (result != 0)
@@ -280,13 +276,8 @@ void MenuBarComponent::showMenu (int index)
inModalState = false;
exitModalState (0);
if (prevCompDeletionChecker != 0)
{
if (! prevCompDeletionChecker->hasBeenDeleted())
prevFocused->grabKeyboardFocus();
delete prevCompDeletionChecker;
}
if (prevCompDeletionChecker != 0 && ! prevCompDeletionChecker->hasBeenDeleted())
prevFocused->grabKeyboardFocus();
int mx, my;
getMouseXYRelative (mx, my);
@@ -356,7 +347,7 @@ void MenuBarComponent::mouseUp (const MouseEvent& e)
updateItemUnderMouse (e2.x, e2.y);
if (itemUnderMouse < 0 && dynamic_cast <DummyMenuComponent*> (currentPopup) != 0)
if (itemUnderMouse < 0 && dynamic_cast <DummyMenuComponent*> ((Component*) currentPopup) != 0)
hideCurrentMenu();
}


+ 1
- 1
src/gui/components/menus/juce_MenuBarComponent.h View File

@@ -109,7 +109,7 @@ private:
int itemUnderMouse, currentPopupIndex, topLevelIndexClicked, indexToShowAgain;
int lastMouseX, lastMouseY;
bool inModalState;
Component* currentPopup;
ScopedPointer <Component> currentPopup;
int getItemAt (int x, int y);
void updateItemUnderMouse (const int x, const int y);


+ 24
- 46
src/gui/components/menus/juce_PopupMenu.cpp View File

@@ -49,9 +49,9 @@ public:
String text;
const Colour textColour;
const bool active, isSeparator, isTicked, usesColour;
Image* image;
ScopedPointer <Image> image;
PopupMenuCustomComponent* const customComp;
PopupMenu* subMenu;
ScopedPointer <PopupMenu> subMenu;
ApplicationCommandManager* const commandManager;
//==============================================================================
@@ -61,9 +61,7 @@ public:
isSeparator (true),
isTicked (false),
usesColour (false),
image (0),
customComp (0),
subMenu (0),
commandManager (0)
{
}
@@ -85,11 +83,11 @@ public:
isSeparator (false),
isTicked (isTicked_),
usesColour (usesColour_),
image (0),
customComp (customComp_),
commandManager (commandManager_)
{
subMenu = (subMenu_ != 0) ? new PopupMenu (*subMenu_) : 0;
if (subMenu_ != 0)
subMenu = new PopupMenu (*subMenu_);
if (customComp != 0)
customComp->refCount_++;
@@ -137,13 +135,9 @@ public:
{
if (other.subMenu != 0)
subMenu = new PopupMenu (*(other.subMenu));
else
subMenu = 0;
if (other.image != 0)
image = other.image->createCopy();
else
image = 0;
if (customComp != 0)
customComp->refCount_++;
@@ -151,9 +145,6 @@ public:
~MenuItemInfo() throw()
{
delete subMenu;
delete image;
if (customComp != 0 && --(customComp->refCount_) == 0)
delete customComp;
}
@@ -294,7 +285,6 @@ public:
menuBarComponent (0),
managerOfChosenCommand (0),
componentAttachedTo (0),
attachedCompWatcher (0),
lastMouseX (0),
lastMouseY (0),
minimumWidth (0),
@@ -335,7 +325,7 @@ public:
delete activeSubMenu;
deleteAllChildren();
delete attachedCompWatcher;
attachedCompWatcher = 0;
}
//==============================================================================
@@ -357,7 +347,7 @@ public:
{
int totalItems = 0;
PopupMenuWindow* const mw = new PopupMenuWindow();
ScopedPointer <PopupMenuWindow> mw (new PopupMenuWindow());
mw->setLookAndFeel (menu.lookAndFeel);
mw->setWantsKeyboardFocus (false);
mw->minimumWidth = minimumWidth;
@@ -373,17 +363,12 @@ public:
++totalItems;
}
if (totalItems == 0)
{
delete mw;
}
else
if (totalItems > 0)
{
mw->owner = owner_;
mw->menuBarComponent = menuBarComponent;
mw->managerOfChosenCommand = managerOfChosenCommand;
mw->componentAttachedTo = componentAttachedTo;
delete mw->attachedCompWatcher;
mw->attachedCompWatcher = componentAttachedTo != 0 ? new ComponentDeletionWatcher (componentAttachedTo) : 0;
mw->calculateWindowPos (minX, maxX, minY, maxY, alignToRectangle);
@@ -402,7 +387,7 @@ public:
mw->addToDesktop (ComponentPeer::windowIsTemporary
| mw->getLookAndFeel().getMenuWindowFlags());
return mw;
return mw.release();
}
}
@@ -774,7 +759,7 @@ private:
Component* menuBarComponent;
ApplicationCommandManager** managerOfChosenCommand;
Component* componentAttachedTo;
ComponentDeletionWatcher* attachedCompWatcher;
ScopedPointer <ComponentDeletionWatcher> attachedCompWatcher;
Rectangle windowPos;
int lastMouseX, lastMouseY;
int minimumWidth, maximumNumColumns, standardItemHeight;
@@ -1337,10 +1322,7 @@ PopupMenu::~PopupMenu() throw()
void PopupMenu::clear() throw()
{
for (int i = items.size(); --i >= 0;)
{
MenuItemInfo* const mi = (MenuItemInfo*) items.getUnchecked(i);
delete mi;
}
delete (MenuItemInfo*) items.getUnchecked(i);
items.clear();
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();
ComponentDeletionWatcher* deletionChecker1 = 0;
ScopedPointer <ComponentDeletionWatcher> deletionChecker[2];
if (prevFocused != 0)
deletionChecker1 = new ComponentDeletionWatcher (prevFocused);
deletionChecker[0] = new ComponentDeletionWatcher (prevFocused);
Component* const prevTopLevel = (prevFocused != 0) ? prevFocused->getTopLevelComponent() : 0;
ComponentDeletionWatcher* deletionChecker2 = 0;
if (prevTopLevel != 0)
deletionChecker2 = new ComponentDeletionWatcher (prevTopLevel);
deletionChecker[1] = new ComponentDeletionWatcher (prevTopLevel);
wasHiddenBecauseOfAppChange = false;
int result = 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)
{
@@ -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..
result = popupComp->runModalLoop();
delete popupComp;
popupComp = 0;
if (! wasHiddenBecauseOfAppChange)
{
if (deletionChecker2 != 0 && ! deletionChecker2->hasBeenDeleted())
if (deletionChecker[1] != 0 && ! deletionChecker[1]->hasBeenDeleted())
prevTopLevel->toFront (true);
if (deletionChecker1 != 0 && ! deletionChecker1->hasBeenDeleted())
if (deletionChecker[0] != 0 && ! deletionChecker[0]->hasBeenDeleted())
prevFocused->grabKeyboardFocus();
}
}
delete deletionChecker1;
delete deletionChecker2;
if (managerOfChosenCommand != 0 && result != 0)
{
ApplicationCommandTarget::InvocationInfo info (result);


+ 35
- 51
src/gui/components/mouse/juce_DragAndDropContainer.cpp View File

@@ -44,15 +44,13 @@ class DragImageComponent : public Component,
public Timer
{
private:
Image* image;
ScopedPointer <Image> image;
Component* const source;
DragAndDropContainer* const owner;
ComponentDeletionWatcher* sourceWatcher;
ScopedPointer <ComponentDeletionWatcher> sourceWatcher, mouseDragSourceWatcher, currentlyOverWatcher;
Component* mouseDragSource;
ComponentDeletionWatcher* mouseDragSourceWatcher;
DragAndDropTarget* currentlyOver;
ComponentDeletionWatcher* currentlyOverWatcher;
String dragDesc;
const int imageX, imageY;
@@ -71,7 +69,6 @@ public:
source (s),
owner (o),
currentlyOver (0),
currentlyOverWatcher (0),
dragDesc (desc),
imageX (imageX_),
imageY (imageY_),
@@ -98,8 +95,8 @@ public:
~DragImageComponent()
{
if (owner->dragImageComponent == this)
owner->dragImageComponent = 0;
if ((DragImageComponent*) owner->dragImageComponent == this)
owner->dragImageComponent.release();
if (! mouseDragSourceWatcher->hasBeenDeleted())
{
@@ -109,11 +106,6 @@ public:
if (currentlyOver->isInterestedInDragSource (dragDesc, source))
currentlyOver->itemDragExit (dragDesc, source);
}
delete mouseDragSourceWatcher;
delete sourceWatcher;
delete image;
delete currentlyOverWatcher;
}
void paint (Graphics& g)
@@ -220,8 +212,8 @@ public:
// a modal loop and deletes this object before the method completes)
const String dragDescLocal (dragDesc);
currentlyOverWatcher = 0;
currentlyOver = 0;
deleteAndZero (currentlyOverWatcher);
ddt->itemDropped (dragDescLocal, source, relX, relY);
}
@@ -267,7 +259,7 @@ public:
}
currentlyOver = ddt;
deleteAndZero (currentlyOverWatcher);
currentlyOverWatcher = 0;
if (ddt != 0)
{
@@ -280,7 +272,7 @@ public:
else if (currentlyOverWatcher != 0 && currentlyOverWatcher->hasBeenDeleted())
{
currentlyOver = 0;
deleteAndZero (currentlyOverWatcher);
currentlyOverWatcher = 0;
}
if (currentlyOver != 0
@@ -341,26 +333,23 @@ public:
//==============================================================================
DragAndDropContainer::DragAndDropContainer()
: dragImageComponent (0)
{
}
DragAndDropContainer::~DragAndDropContainer()
{
delete dragImageComponent;
dragImageComponent = 0;
}
void DragAndDropContainer::startDragging (const String& sourceDescription,
Component* sourceComponent,
Image* im,
Image* dragImage_,
const bool allowDraggingToExternalWindows,
const Point* imageOffsetFromMouse)
{
if (dragImageComponent != 0)
{
delete im;
}
else
ScopedPointer <Image> dragImage (dragImage_);
if (dragImageComponent == 0)
{
Component* const thisComp = dynamic_cast <Component*> (this);
@@ -370,35 +359,34 @@ void DragAndDropContainer::startDragging (const String& sourceDescription,
Desktop::getLastMouseDownPosition (mx, my);
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);
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 hi = 400;
int rx = mx, ry = my;
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);
for (int x = im->getWidth(); --x >= 0;)
for (int x = dragImage->getWidth(); --x >= 0;)
{
const int dx = x - cx;
const int distance = roundDoubleToInt (sqrt (dx * dx + dy));
@@ -409,7 +397,7 @@ void DragAndDropContainer::startDragging (const String& sourceDescription,
: (hi - distance) / (float) (hi - lo)
+ 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)
{
imageX = im->getWidth() / -2;
imageY = im->getHeight() / -2;
imageX = dragImage->getWidth() / -2;
imageY = dragImage->getHeight() / -2;
}
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;
if (allowDraggingToExternalWindows)
{
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
thisComp->addChildComponent (dic);
thisComp->addChildComponent (dragImageComponent);
dic->updateLocation (false, mx, my);
dic->setVisible (true);
((DragImageComponent*) dragImageComponent)->updateLocation (false, mx, my);
dragImageComponent->setVisible (true);
}
else
{
// this class must only be implemented by an object that
// is also a Component.
jassertfalse
delete im;
}
}
}


+ 1
- 1
src/gui/components/mouse/juce_DragAndDropContainer.h View File

@@ -180,7 +180,7 @@ protected:
private:
friend class DragImageComponent;
Component* dragImageComponent;
ScopedPointer <Component> dragImageComponent;
String currentDragDesc;
};


+ 5
- 10
src/gui/components/special/juce_ColourSelector.cpp View File

@@ -108,8 +108,7 @@ public:
: owner (owner_),
h (h_), s (s_), v (v_),
lastHue (0.0f),
edge (edgeSize),
colours (0)
edge (edgeSize)
{
addAndMakeVisible (marker = new ColourSpaceMarker());
setMouseCursor (MouseCursor::CrosshairCursor);
@@ -118,7 +117,6 @@ public:
~ColourSpaceView()
{
deleteAllChildren();
delete colours;
}
void paint (Graphics& g)
@@ -169,7 +167,7 @@ public:
if (lastHue != h)
{
lastHue = h;
deleteAndZero (colours);
colours = 0;
repaint();
}
@@ -178,12 +176,12 @@ public:
void resized()
{
deleteAndZero (colours);
colours = 0;
updateMarker();
}
private:
Image* colours;
ScopedPointer <Image> colours;
void updateMarker() const throw()
{
@@ -576,10 +574,7 @@ void ColourSelector::resized()
{
int i;
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)
{


+ 1
- 1
src/gui/components/special/juce_NSViewComponent.h View File

@@ -79,7 +79,7 @@ public:
private:
friend class NSViewComponentInternal;
NSViewComponentInternal* info;
ScopedPointer <NSViewComponentInternal> info;
NSViewComponent (const NSViewComponent&);
const NSViewComponent& operator= (const NSViewComponent&);


+ 3
- 3
src/gui/components/special/juce_PreferencesPanel.cpp View File

@@ -36,13 +36,13 @@ BEGIN_JUCE_NAMESPACE
//==============================================================================
PreferencesPanel::PreferencesPanel()
: currentPage (0),
buttonSize (70)
: buttonSize (70)
{
}
PreferencesPanel::~PreferencesPanel()
{
currentPage = 0;
deleteAllChildren();
}
@@ -155,7 +155,7 @@ void PreferencesPanel::setCurrentPage (const String& pageName)
{
currentPageName = pageName;
deleteAndZero (currentPage);
currentPage = 0;
currentPage = createComponentForPage (pageName);
if (currentPage != 0)


+ 1
- 1
src/gui/components/special/juce_PreferencesPanel.h View File

@@ -137,7 +137,7 @@ public:
private:
//==============================================================================
String currentPageName;
Component* currentPage;
ScopedPointer <Component> currentPage;
int buttonSize;
PreferencesPanel (const PreferencesPanel&);


+ 4
- 5
src/gui/components/windows/juce_AlertWindow.cpp View File

@@ -36,6 +36,7 @@ BEGIN_JUCE_NAMESPACE
#include "../../../text/juce_LocalisedStrings.h"
#include "../../../events/juce_MessageManager.h"
#include "../../../application/juce_Application.h"
#include "../../../containers/juce_ScopedPointer.h"
static const int titleH = 24;
static const int iconWidth = 80;
@@ -614,14 +615,12 @@ private:
LookAndFeel& lf = associatedComponent->isValidComponent() ? associatedComponent->getLookAndFeel()
: 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!
const int result = alertBox->runModalLoop();
delete alertBox;
return result;
return alertBox->runModalLoop();
}
static void* showCallback (void* userData)


+ 2
- 4
src/gui/components/windows/juce_ComponentPeer.cpp View File

@@ -64,7 +64,6 @@ ComponentPeer::ComponentPeer (Component* const component_,
lastPaintTime (0),
constrainer (0),
lastFocusedComponent (0),
dragAndDropTargetComponent (0),
lastDragAndDropCompUnderMouse (0),
fakeMouseMessageSent (false),
isWindowMinimised (false)
@@ -75,7 +74,6 @@ ComponentPeer::ComponentPeer (Component* const component_,
ComponentPeer::~ComponentPeer()
{
heavyweightPeers.removeValue (this);
delete dragAndDropTargetComponent;
Desktop::getInstance().triggerFocusCallback();
}
@@ -687,7 +685,7 @@ void ComponentPeer::handleFileDragMove (const StringArray& files, int x, int y)
if (lastTarget != 0)
lastTarget->fileDragExit (files);
deleteAndZero (dragAndDropTargetComponent);
dragAndDropTargetComponent = 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()));
deleteAndZero (dragAndDropTargetComponent);
dragAndDropTargetComponent = 0;
lastDragAndDropCompUnderMouse = 0;
if (target != 0)


+ 1
- 1
src/gui/components/windows/juce_ComponentPeer.h View File

@@ -377,7 +377,7 @@ protected:
private:
//==============================================================================
Component* lastFocusedComponent;
ComponentDeletionWatcher* dragAndDropTargetComponent;
ScopedPointer <ComponentDeletionWatcher> dragAndDropTargetComponent;
Component* lastDragAndDropCompUnderMouse;
bool fakeMouseMessageSent : 1, isWindowMinimised : 1;


+ 7
- 17
src/gui/components/windows/juce_DocumentWindow.cpp View File

@@ -48,12 +48,8 @@ DocumentWindow::DocumentWindow (const String& title,
positionTitleBarButtonsOnLeft (false),
#endif
drawTitleTextCentred (true),
titleBarIcon (0),
menuBar (0),
menuBarModel (0)
{
zeromem (titleBarButtons, sizeof (titleBarButtons));
setResizeLimits (128, 128, 32768, 32768);
lookAndFeelChanged();
@@ -61,11 +57,10 @@ DocumentWindow::DocumentWindow (const String& title,
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)
{
deleteAndZero (titleBarIcon);
if (imageToUse != 0)
titleBarIcon = imageToUse->createCopy();
titleBarIcon = imageToUse != 0 ? imageToUse->createCopy() : 0;
repaintTitleBar();
}
@@ -121,7 +112,6 @@ void DocumentWindow::setMenuBar (MenuBarModel* menuBarModel_,
{
if (menuBarModel != menuBarModel_)
{
delete menuBar;
menuBar = 0;
menuBarModel = menuBarModel_;
@@ -302,8 +292,8 @@ int DocumentWindow::getDesktopWindowStyleFlags() const
void DocumentWindow::lookAndFeelChanged()
{
int i;
for (i = 0; i < 3; ++i)
deleteAndZero (titleBarButtons[i]);
for (i = numElementsInArray (titleBarButtons); --i >= 0;)
titleBarButtons[i] = 0;
if (! isUsingNativeTitleBar())
{
@@ -353,7 +343,7 @@ void DocumentWindow::activeWindowStatusChanged()
{
ResizableWindow::activeWindowStatusChanged();
for (int i = 0; i < 3; ++i)
for (int i = numElementsInArray (titleBarButtons); --i >= 0;)
if (titleBarButtons[i] != 0)
titleBarButtons[i]->setEnabled (isActiveWindow());


+ 3
- 3
src/gui/components/windows/juce_DocumentWindow.h View File

@@ -248,9 +248,9 @@ public:
private:
int titleBarHeight, menuBarHeight, requiredButtons;
bool positionTitleBarButtonsOnLeft, drawTitleTextCentred;
Button* titleBarButtons [3];
Image* titleBarIcon;
MenuBarComponent* menuBar;
ScopedPointer <Button> titleBarButtons [3];
ScopedPointer <Image> titleBarIcon;
ScopedPointer <MenuBarComponent> menuBar;
MenuBarModel* menuBarModel;
class ButtonListenerProxy : public ButtonListener


+ 12
- 20
src/gui/components/windows/juce_ResizableWindow.cpp View File

@@ -38,9 +38,6 @@ BEGIN_JUCE_NAMESPACE
ResizableWindow::ResizableWindow (const String& name,
const bool addToDesktop_)
: TopLevelWindow (name, addToDesktop_),
resizableCorner (0),
resizableBorder (0),
contentComponent (0),
resizeToFitContent (false),
fullscreen (false),
lastNonFullScreenPos (50, 50, 256, 256),
@@ -61,9 +58,6 @@ ResizableWindow::ResizableWindow (const String& name,
const Colour& backgroundColour_,
const bool addToDesktop_)
: TopLevelWindow (name, addToDesktop_),
resizableCorner (0),
resizableBorder (0),
contentComponent (0),
resizeToFitContent (false),
fullscreen (false),
lastNonFullScreenPos (50, 50, 256, 256),
@@ -82,9 +76,9 @@ ResizableWindow::ResizableWindow (const String& name,
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.
// Read the instructions for using a ResizableWindow!
@@ -108,12 +102,10 @@ void ResizableWindow::setContentComponent (Component* const newContentComponent,
{
resizeToFitContent = resizeToFit;
if (contentComponent != newContentComponent)
if (newContentComponent != (Component*) contentComponent)
{
if (deleteOldOne)
delete contentComponent;
else
removeChildComponent (contentComponent);
if (! deleteOldOne)
removeChildComponent (contentComponent.release());
contentComponent = newContentComponent;
@@ -224,7 +216,7 @@ void ResizableWindow::setResizable (const bool shouldBeResizable,
{
if (useBottomRightCornerResizer)
{
deleteAndZero (resizableBorder);
resizableBorder = 0;
if (resizableCorner == 0)
{
@@ -234,7 +226,7 @@ void ResizableWindow::setResizable (const bool shouldBeResizable,
}
else
{
deleteAndZero (resizableCorner);
resizableCorner = 0;
if (resizableBorder == 0)
Component::addChildComponent (resizableBorder = new ResizableBorderComponent (this, constrainer));
@@ -242,8 +234,8 @@ void ResizableWindow::setResizable (const bool shouldBeResizable,
}
else
{
deleteAndZero (resizableCorner);
deleteAndZero (resizableBorder);
resizableCorner = 0;
resizableBorder = 0;
}
if (isUsingNativeTitleBar())
@@ -285,8 +277,8 @@ void ResizableWindow::setConstrainer (ComponentBoundsConstrainer* newConstrainer
const bool useBottomRightCornerResizer = resizableCorner != 0;
const bool shouldBeResizable = useBottomRightCornerResizer || resizableBorder != 0;
deleteAndZero (resizableCorner);
deleteAndZero (resizableBorder);
resizableCorner = 0;
resizableBorder = 0;
setResizable (shouldBeResizable, useBottomRightCornerResizer);


+ 3
- 3
src/gui/components/windows/juce_ResizableWindow.h View File

@@ -338,11 +338,11 @@ protected:
#endif
ResizableCornerComponent* resizableCorner;
ResizableBorderComponent* resizableBorder;
ScopedPointer <ResizableCornerComponent> resizableCorner;
ScopedPointer <ResizableBorderComponent> resizableBorder;
private:
Component* contentComponent;
ScopedPointer <Component> contentComponent;
bool resizeToFitContent, fullscreen;
ComponentDragger dragger;
Rectangle lastNonFullScreenPos;


+ 2
- 8
src/gui/components/windows/juce_SplashScreen.cpp View File

@@ -35,18 +35,14 @@ BEGIN_JUCE_NAMESPACE
//==============================================================================
SplashScreen::SplashScreen()
: backgroundImage (0),
isImageInCache (false)
: backgroundImage (0)
{
setOpaque (true);
}
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)
{
isImageInCache = ImageCache::isImageInCache (backgroundImage_);
setOpaque (! backgroundImage_->hasAlphaChannel());
show (title,


+ 0
- 1
src/gui/components/windows/juce_SplashScreen.h View File

@@ -144,7 +144,6 @@ private:
Image* backgroundImage;
Time earliestTimeToDelete;
int originalClickCounter;
bool isImageInCache;
SplashScreen (const SplashScreen&);
const SplashScreen& operator= (const SplashScreen&);


+ 0
- 1
src/gui/components/windows/juce_ThreadWithProgressWindow.cpp View File

@@ -55,7 +55,6 @@ ThreadWithProgressWindow::ThreadWithProgressWindow (const String& title,
ThreadWithProgressWindow::~ThreadWithProgressWindow()
{
stopThread (timeOutMsWhenCancelling);
delete alertWindow;
}
bool ThreadWithProgressWindow::runThread (const int priority)


+ 2
- 1
src/gui/components/windows/juce_ThreadWithProgressWindow.h View File

@@ -29,6 +29,7 @@
#include "../windows/juce_AlertWindow.h"
#include "../../../events/juce_Timer.h"
#include "../../../threads/juce_Thread.h"
#include "../../../containers/juce_ScopedPointer.h"
//==============================================================================
@@ -152,7 +153,7 @@ private:
void timerCallback();
double progress;
AlertWindow* alertWindow;
ScopedPointer <AlertWindow> alertWindow;
String message;
CriticalSection messageLock;
const int timeOutMsWhenCancelling;


+ 4
- 5
src/gui/components/windows/juce_TopLevelWindow.cpp View File

@@ -147,8 +147,7 @@ TopLevelWindow::TopLevelWindow (const String& name,
: Component (name),
useDropShadow (true),
useNativeTitleBar (false),
windowIsActive_ (false),
shadower (0)
windowIsActive_ (false)
{
setOpaque (true);
@@ -164,7 +163,7 @@ TopLevelWindow::TopLevelWindow (const String& name,
TopLevelWindow::~TopLevelWindow()
{
deleteAndZero (shadower);
shadower = 0;
TopLevelWindowManager::getInstance()->removeWindow (this);
}
@@ -220,7 +219,7 @@ void TopLevelWindow::setDropShadowEnabled (const bool useShadow)
if (isOnDesktop())
{
deleteAndZero (shadower);
shadower = 0;
Component::addToDesktop (getDesktopWindowStyleFlags());
}
else
@@ -237,7 +236,7 @@ void TopLevelWindow::setDropShadowEnabled (const bool useShadow)
}
else
{
deleteAndZero (shadower);
shadower = 0;
}
}
}


+ 1
- 1
src/gui/components/windows/juce_TopLevelWindow.h View File

@@ -160,7 +160,7 @@ protected:
private:
friend class TopLevelWindowManager;
bool useDropShadow, useNativeTitleBar, windowIsActive_;
DropShadower* shadower;
ScopedPointer <DropShadower> shadower;
void setWindowActive (const bool isNowActive) throw();


+ 5
- 8
src/gui/graphics/contexts/juce_FillType.cpp View File

@@ -33,12 +33,12 @@ BEGIN_JUCE_NAMESPACE
//==============================================================================
FillType::FillType() throw()
: colour (0xff000000), gradient (0), image (0)
: colour (0xff000000), image (0)
{
}
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()
: 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)
{
colour = other.colour;
delete gradient;
gradient = (other.gradient != 0 ? new ColourGradient (*other.gradient) : 0);
image = other.image;
transform = other.transform;
@@ -76,12 +74,11 @@ const FillType& FillType::operator= (const FillType& other) throw()
FillType::~FillType() throw()
{
delete gradient;
}
void FillType::setColour (const Colour& newColour) throw()
{
deleteAndZero (gradient);
gradient = 0;
image = 0;
colour = newColour;
}
@@ -102,7 +99,7 @@ void FillType::setGradient (const ColourGradient& newGradient) throw()
void FillType::setTiledImage (const Image& image_, const AffineTransform& transform_) throw()
{
deleteAndZero (gradient);
gradient = 0;
image = &image_;
transform = transform_;
colour = Colours::black;


+ 2
- 1
src/gui/graphics/contexts/juce_FillType.h View File

@@ -27,6 +27,7 @@
#define __JUCE_FILLTYPE_JUCEHEADER__
#include "../colour/juce_ColourGradient.h"
#include "../../../containers/juce_ScopedPointer.h"
class Image;
@@ -114,7 +115,7 @@ public:
If a gradient is active, the overall opacity with which it should be applied
is indicated by the alpha channel of the colour variable.
*/
ColourGradient* gradient;
ScopedPointer <ColourGradient> gradient;
/** 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


+ 4
- 6
src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp View File

@@ -1349,7 +1349,6 @@ LowLevelGraphicsSoftwareRenderer::LowLevelGraphicsSoftwareRenderer (Image& image
LowLevelGraphicsSoftwareRenderer::~LowLevelGraphicsSoftwareRenderer()
{
delete currentState;
}
bool LowLevelGraphicsSoftwareRenderer::isVectorDevice() const
@@ -1417,7 +1416,6 @@ void LowLevelGraphicsSoftwareRenderer::restoreState()
if (top != 0)
{
delete currentState;
currentState = top;
stateStack.removeLast (1, false);
}
@@ -1567,8 +1565,8 @@ public:
class CachedGlyph
{
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()
{
@@ -1584,7 +1582,7 @@ public:
{
font = newFont;
glyph = glyphNumber;
deleteAndZero (edgeTable);
edgeTable = 0;
Path glyphPath;
font.getTypeface()->getOutlineForGlyph (glyphNumber, glyphPath);
@@ -1611,7 +1609,7 @@ public:
juce_UseDebuggingNewOperator
private:
EdgeTable* edgeTable;
ScopedPointer <EdgeTable> edgeTable;
CachedGlyph (const CachedGlyph&);
const CachedGlyph& operator= (const CachedGlyph&);


+ 1
- 1
src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h View File

@@ -92,7 +92,7 @@ protected:
//==============================================================================
Image& image;
LLGCSavedState* currentState;
ScopedPointer <LLGCSavedState> currentState;
OwnedArray <LLGCSavedState> stateStack;
LowLevelGraphicsSoftwareRenderer (const LowLevelGraphicsSoftwareRenderer& other);


+ 4
- 15
src/gui/graphics/drawables/juce_Drawable.cpp View File

@@ -104,20 +104,15 @@ Drawable* Drawable::createFromImageData (const void* data, const int numBytes)
const String asString (String::createStringFromData (data, numBytes));
XmlDocument doc (asString);
XmlElement* const outer = doc.getDocumentElement (true);
ScopedPointer <XmlElement> outer (doc.getDocumentElement (true));
if (outer != 0 && outer->hasTagName (T("svg")))
{
XmlElement* const svg = doc.getDocumentElement();
ScopedPointer <XmlElement> svg (doc.getDocumentElement());
if (svg != 0)
{
result = Drawable::createFromSVG (*svg);
delete svg;
}
}
delete outer;
}
return result;
@@ -133,15 +128,9 @@ Drawable* Drawable::createFromImageDataStream (InputStream& dataSource)
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;
}
//==============================================================================


+ 1
- 6
src/gui/graphics/drawables/juce_DrawableImage.cpp View File

@@ -51,12 +51,7 @@ DrawableImage::~DrawableImage()
void DrawableImage::clearImage()
{
if (canDeleteImage && image != 0)
{
if (ImageCache::isImageInCache (image))
ImageCache::release (image);
else
delete image;
}
ImageCache::releaseOrDelete (image);
image = 0;
}


+ 1
- 4
src/gui/graphics/fonts/juce_TextLayout.cpp View File

@@ -137,10 +137,7 @@ TextLayout::~TextLayout() throw()
void TextLayout::clear() throw()
{
for (int i = tokens.size(); --i >= 0;)
{
TextLayoutToken* const t = (TextLayoutToken*)tokens.getUnchecked(i);
delete t;
}
delete (TextLayoutToken*) tokens.getUnchecked(i);
tokens.clear();
totalLines = 0;


+ 9
- 1
src/gui/graphics/imaging/juce_ImageCache.cpp View File

@@ -59,7 +59,7 @@ ImageCache::~ImageCache()
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;
}
@@ -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)
{
if (instance != 0)


+ 7
- 0
src/gui/graphics/imaging/juce_ImageCache.h View File

@@ -101,6 +101,13 @@ public:
*/
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.
@returns true if the image is currently in the cache


+ 1
- 3
src/gui/graphics/imaging/juce_ImageConvolutionKernel.cpp View File

@@ -108,7 +108,7 @@ void ImageConvolutionKernel::applyToImage (Image& destImage,
int dw,
int dh) const
{
Image* imageCreated = 0;
ScopedPointer <Image> imageCreated;
if (sourceImage == 0)
{
@@ -255,8 +255,6 @@ void ImageConvolutionKernel::applyToImage (Image& destImage,
}
}
}
delete imageCreated;
}
END_JUCE_NAMESPACE

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save