Browse Source

RTAS ppq fix. New class OptionalScopedPointer. Deprecated the ResizableWindow::setContentComponent() method, replacing it with setContentOwned() and setContentNonOwned(), which provide a way to specify the component's ownership when it is added.

tags/2021-05-28
Julian Storer 14 years ago
parent
commit
8fd76650c4
27 changed files with 978 additions and 743 deletions
  1. +1
    -0
      Builds/VisualStudio2005/Juce.vcproj
  2. +1
    -0
      Builds/VisualStudio2008/Juce.vcproj
  3. +1
    -0
      Builds/VisualStudio2008_DLL/Juce.vcproj
  4. +1
    -0
      Builds/VisualStudio2010/Juce.vcxproj
  5. +3
    -0
      Builds/VisualStudio2010/Juce.vcxproj.filters
  6. +2
    -0
      Juce.jucer
  7. +598
    -598
      extras/JuceDemo/Source/MainDemoWindow.cpp
  8. +1
    -5
      extras/JuceDemo/Source/demos/WidgetsDemo.cpp
  9. +10
    -1
      extras/audio plugins/wrapper/RTAS/juce_RTAS_Wrapper.cpp
  10. +69
    -43
      juce_amalgamated.cpp
  11. +168
    -25
      juce_amalgamated.h
  12. +1
    -1
      src/core/juce_StandardHeader.h
  13. +1
    -2
      src/gui/components/controls/juce_Toolbar.cpp
  14. +2
    -1
      src/gui/components/filebrowser/juce_FileChooserDialogBox.cpp
  15. +5
    -9
      src/gui/components/layout/juce_MultiDocumentPanel.cpp
  16. +1
    -6
      src/gui/components/windows/juce_DialogWindow.cpp
  17. +54
    -13
      src/gui/components/windows/juce_ResizableWindow.cpp
  18. +42
    -15
      src/gui/components/windows/juce_ResizableWindow.h
  19. +2
    -3
      src/io/streams/juce_BufferedInputStream.cpp
  20. +2
    -3
      src/io/streams/juce_BufferedInputStream.h
  21. +1
    -2
      src/io/streams/juce_GZIPCompressorOutputStream.cpp
  22. +2
    -3
      src/io/streams/juce_GZIPCompressorOutputStream.h
  23. +2
    -3
      src/io/streams/juce_GZIPDecompressorInputStream.cpp
  24. +2
    -3
      src/io/streams/juce_GZIPDecompressorInputStream.h
  25. +1
    -4
      src/io/streams/juce_SubregionStream.cpp
  26. +2
    -3
      src/io/streams/juce_SubregionStream.h
  27. +3
    -0
      src/juce_core_includes.h

+ 1
- 0
Builds/VisualStudio2005/Juce.vcproj View File

@@ -843,6 +843,7 @@
<File RelativePath="..\..\src\memory\juce_Memory.h"/> <File RelativePath="..\..\src\memory\juce_Memory.h"/>
<File RelativePath="..\..\src\memory\juce_MemoryBlock.cpp"/> <File RelativePath="..\..\src\memory\juce_MemoryBlock.cpp"/>
<File RelativePath="..\..\src\memory\juce_MemoryBlock.h"/> <File RelativePath="..\..\src\memory\juce_MemoryBlock.h"/>
<File RelativePath="..\..\src\memory\juce_OptionalScopedPointer.h"/>
<File RelativePath="..\..\src\memory\juce_ReferenceCountedObject.h"/> <File RelativePath="..\..\src\memory\juce_ReferenceCountedObject.h"/>
<File RelativePath="..\..\src\memory\juce_ScopedPointer.h"/> <File RelativePath="..\..\src\memory\juce_ScopedPointer.h"/>
<File RelativePath="..\..\src\memory\juce_WeakReference.h"/> <File RelativePath="..\..\src\memory\juce_WeakReference.h"/>


+ 1
- 0
Builds/VisualStudio2008/Juce.vcproj View File

@@ -843,6 +843,7 @@
<File RelativePath="..\..\src\memory\juce_Memory.h"/> <File RelativePath="..\..\src\memory\juce_Memory.h"/>
<File RelativePath="..\..\src\memory\juce_MemoryBlock.cpp"/> <File RelativePath="..\..\src\memory\juce_MemoryBlock.cpp"/>
<File RelativePath="..\..\src\memory\juce_MemoryBlock.h"/> <File RelativePath="..\..\src\memory\juce_MemoryBlock.h"/>
<File RelativePath="..\..\src\memory\juce_OptionalScopedPointer.h"/>
<File RelativePath="..\..\src\memory\juce_ReferenceCountedObject.h"/> <File RelativePath="..\..\src\memory\juce_ReferenceCountedObject.h"/>
<File RelativePath="..\..\src\memory\juce_ScopedPointer.h"/> <File RelativePath="..\..\src\memory\juce_ScopedPointer.h"/>
<File RelativePath="..\..\src\memory\juce_WeakReference.h"/> <File RelativePath="..\..\src\memory\juce_WeakReference.h"/>


+ 1
- 0
Builds/VisualStudio2008_DLL/Juce.vcproj View File

@@ -845,6 +845,7 @@
<File RelativePath="..\..\src\memory\juce_Memory.h"/> <File RelativePath="..\..\src\memory\juce_Memory.h"/>
<File RelativePath="..\..\src\memory\juce_MemoryBlock.cpp"/> <File RelativePath="..\..\src\memory\juce_MemoryBlock.cpp"/>
<File RelativePath="..\..\src\memory\juce_MemoryBlock.h"/> <File RelativePath="..\..\src\memory\juce_MemoryBlock.h"/>
<File RelativePath="..\..\src\memory\juce_OptionalScopedPointer.h"/>
<File RelativePath="..\..\src\memory\juce_ReferenceCountedObject.h"/> <File RelativePath="..\..\src\memory\juce_ReferenceCountedObject.h"/>
<File RelativePath="..\..\src\memory\juce_ScopedPointer.h"/> <File RelativePath="..\..\src\memory\juce_ScopedPointer.h"/>
<File RelativePath="..\..\src\memory\juce_WeakReference.h"/> <File RelativePath="..\..\src\memory\juce_WeakReference.h"/>


+ 1
- 0
Builds/VisualStudio2010/Juce.vcxproj View File

@@ -760,6 +760,7 @@
<ClInclude Include="..\..\src\memory\juce_LeakedObjectDetector.h"/> <ClInclude Include="..\..\src\memory\juce_LeakedObjectDetector.h"/>
<ClInclude Include="..\..\src\memory\juce_Memory.h"/> <ClInclude Include="..\..\src\memory\juce_Memory.h"/>
<ClInclude Include="..\..\src\memory\juce_MemoryBlock.h"/> <ClInclude Include="..\..\src\memory\juce_MemoryBlock.h"/>
<ClInclude Include="..\..\src\memory\juce_OptionalScopedPointer.h"/>
<ClInclude Include="..\..\src\memory\juce_ReferenceCountedObject.h"/> <ClInclude Include="..\..\src\memory\juce_ReferenceCountedObject.h"/>
<ClInclude Include="..\..\src\memory\juce_ScopedPointer.h"/> <ClInclude Include="..\..\src\memory\juce_ScopedPointer.h"/>
<ClInclude Include="..\..\src\memory\juce_WeakReference.h"/> <ClInclude Include="..\..\src\memory\juce_WeakReference.h"/>


+ 3
- 0
Builds/VisualStudio2010/Juce.vcxproj.filters View File

@@ -2214,6 +2214,9 @@
<ClInclude Include="..\..\src\memory\juce_MemoryBlock.h"> <ClInclude Include="..\..\src\memory\juce_MemoryBlock.h">
<Filter>Juce\Source\memory</Filter> <Filter>Juce\Source\memory</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\memory\juce_OptionalScopedPointer.h">
<Filter>Juce\Source\memory</Filter>
</ClInclude>
<ClInclude Include="..\..\src\memory\juce_ReferenceCountedObject.h"> <ClInclude Include="..\..\src\memory\juce_ReferenceCountedObject.h">
<Filter>Juce\Source\memory</Filter> <Filter>Juce\Source\memory</Filter>
</ClInclude> </ClInclude>


+ 2
- 0
Juce.jucer View File

@@ -1259,6 +1259,8 @@
file="src/memory/juce_MemoryBlock.cpp"/> file="src/memory/juce_MemoryBlock.cpp"/>
<FILE id="IDj7DQ2" name="juce_MemoryBlock.h" compile="0" resource="0" <FILE id="IDj7DQ2" name="juce_MemoryBlock.h" compile="0" resource="0"
file="src/memory/juce_MemoryBlock.h"/> file="src/memory/juce_MemoryBlock.h"/>
<FILE id="eFXlHM" name="juce_OptionalScopedPointer.h" compile="0" resource="0"
file="src/memory/juce_OptionalScopedPointer.h"/>
<FILE id="0fuAAWP" name="juce_ReferenceCountedObject.h" compile="0" <FILE id="0fuAAWP" name="juce_ReferenceCountedObject.h" compile="0"
resource="0" file="src/memory/juce_ReferenceCountedObject.h"/> resource="0" file="src/memory/juce_ReferenceCountedObject.h"/>
<FILE id="WElk5bz" name="juce_ScopedPointer.h" compile="0" resource="0" <FILE id="WElk5bz" name="juce_ScopedPointer.h" compile="0" resource="0"


+ 598
- 598
extras/JuceDemo/Source/MainDemoWindow.cpp
File diff suppressed because it is too large
View File


+ 1
- 5
extras/JuceDemo/Source/demos/WidgetsDemo.cpp View File

@@ -1009,15 +1009,11 @@ public:
Colours::lightgrey, Colours::lightgrey,
true) true)
{ {
setContentComponent (new ColourSelector());
setContentOwned (new ColourSelector(), false);
centreWithSize (400, 400); centreWithSize (400, 400);
setResizable (true, true); setResizable (true, true);
} }
~ColourSelectorDialogWindow()
{
}
void closeButtonPressed() void closeButtonPressed()
{ {
// we expect this component to be run within a modal loop, so when the close // we expect this component to be run within a modal loop, so when the close


+ 10
- 1
extras/audio plugins/wrapper/RTAS/juce_RTAS_Wrapper.cpp View File

@@ -702,7 +702,16 @@ protected:
midiTransport->GetCurrentTempo (&bpm); midiTransport->GetCurrentTempo (&bpm);
midiTransport->IsTransportPlaying (&isPlaying); midiTransport->IsTransportPlaying (&isPlaying);
midiTransport->GetCurrentMeter (&num, &denom); midiTransport->GetCurrentMeter (&num, &denom);
midiTransport->GetCurrentTickPosition (&ticks);
// (The following is a work-around because GetCurrentTickPosition() doesn't work correctly).
Cmn_Int64 sampleLocation;
if (isPlaying)
midiTransport->GetCurrentRTASSampleLocation (&sampleLocation);
else
midiTransport->GetCurrentTDMSampleLocation (&sampleLocation);
midiTransport->GetCustomTickPosition (&ticks, sampleLocation);
} }
info.bpm = bpm; info.bpm = bpm;


+ 69
- 43
juce_amalgamated.cpp View File

@@ -9995,8 +9995,7 @@ namespace


BufferedInputStream::BufferedInputStream (InputStream* const sourceStream, const int bufferSize_, BufferedInputStream::BufferedInputStream (InputStream* const sourceStream, const int bufferSize_,
const bool deleteSourceWhenDestroyed) const bool deleteSourceWhenDestroyed)
: source (sourceStream),
sourceToDelete (deleteSourceWhenDestroyed ? sourceStream : 0),
: source (sourceStream, deleteSourceWhenDestroyed),
bufferSize (calcBufferStreamBufferSize (bufferSize_, sourceStream)), bufferSize (calcBufferStreamBufferSize (bufferSize_, sourceStream)),
position (sourceStream->getPosition()), position (sourceStream->getPosition()),
lastReadPos (0), lastReadPos (0),
@@ -10007,7 +10006,7 @@ BufferedInputStream::BufferedInputStream (InputStream* const sourceStream, const
} }


BufferedInputStream::BufferedInputStream (InputStream& sourceStream, const int bufferSize_) BufferedInputStream::BufferedInputStream (InputStream& sourceStream, const int bufferSize_)
: source (&sourceStream),
: source (&sourceStream, false),
bufferSize (calcBufferStreamBufferSize (bufferSize_, &sourceStream)), bufferSize (calcBufferStreamBufferSize (bufferSize_, &sourceStream)),
position (sourceStream.getPosition()), position (sourceStream.getPosition()),
lastReadPos (0), lastReadPos (0),
@@ -10445,13 +10444,10 @@ SubregionStream::SubregionStream (InputStream* const sourceStream,
const int64 startPositionInSourceStream_, const int64 startPositionInSourceStream_,
const int64 lengthOfSourceStream_, const int64 lengthOfSourceStream_,
const bool deleteSourceWhenDestroyed) const bool deleteSourceWhenDestroyed)
: source (sourceStream),
: source (sourceStream, deleteSourceWhenDestroyed),
startPositionInSourceStream (startPositionInSourceStream_), startPositionInSourceStream (startPositionInSourceStream_),
lengthOfSourceStream (lengthOfSourceStream_) lengthOfSourceStream (lengthOfSourceStream_)
{ {
if (deleteSourceWhenDestroyed)
sourceToDelete = source;

setPosition (0); setPosition (0);
} }


@@ -55213,7 +55209,7 @@ public:
: DialogWindow (TRANS("Add/remove items from toolbar"), Colours::white, true, true), : DialogWindow (TRANS("Add/remove items from toolbar"), Colours::white, true, true),
toolbar (toolbar_) toolbar (toolbar_)
{ {
setContentComponent (new CustomiserPanel (factory, toolbar, optionFlags), true, true);
setContentOwned (new CustomiserPanel (factory, toolbar, optionFlags), true);
setResizable (true, true); setResizable (true, true);
setResizeLimits (400, 300, 1500, 1000); setResizeLimits (400, 300, 1500, 1000);
positionNearBar(); positionNearBar();
@@ -55222,7 +55218,6 @@ public:
~ToolbarCustomisationDialog() ~ToolbarCustomisationDialog()
{ {
toolbar->setEditingActive (false); toolbar->setEditingActive (false);
setContentComponent (0, true);
} }


void closeButtonPressed() void closeButtonPressed()
@@ -58493,7 +58488,8 @@ FileChooserDialogBox::FileChooserDialogBox (const String& name,
: ResizableWindow (name, backgroundColour, true), : ResizableWindow (name, backgroundColour, true),
warnAboutOverwritingExistingFiles (warnAboutOverwritingExistingFiles_) warnAboutOverwritingExistingFiles (warnAboutOverwritingExistingFiles_)
{ {
setContentComponent (content = new ContentComponent (name, instructions, chooserComponent));
content = new ContentComponent (name, instructions, chooserComponent);
setContentOwned (content, false);


setResizable (true, true); setResizable (true, true);
setResizeLimits (300, 300, 1200, 1000); setResizeLimits (300, 300, 1200, 1000);
@@ -62231,7 +62227,7 @@ void MultiDocumentPanel::addWindow (Component* component)
MultiDocumentPanelWindow* const dw = createNewDocumentWindow(); MultiDocumentPanelWindow* const dw = createNewDocumentWindow();


dw->setResizable (true, false); dw->setResizable (true, false);
dw->setContentComponent (component, false, true);
dw->setContentNonOwned (component, true);
dw->setName (component->getName()); dw->setName (component->getName());


const var bkg (component->getProperties() ["mdiDocumentBkg_"]); const var bkg (component->getProperties() ["mdiDocumentBkg_"]);
@@ -62341,8 +62337,7 @@ bool MultiDocumentPanel::closeDocument (Component* component,


if (dw != 0 && dw->getContentComponent() == component) if (dw != 0 && dw->getContentComponent() == component)
{ {
dw->setContentComponent (0, false);
delete dw;
ScopedPointer<MultiDocumentPanelWindow> (dw)->clearContentComponent();
break; break;
} }
} }
@@ -62356,13 +62351,10 @@ bool MultiDocumentPanel::closeDocument (Component* component,
{ {
for (int i = getNumChildComponents(); --i >= 0;) for (int i = getNumChildComponents(); --i >= 0;)
{ {
MultiDocumentPanelWindow* const dw = dynamic_cast <MultiDocumentPanelWindow*> (getChildComponent (i));
ScopedPointer<MultiDocumentPanelWindow> dw (dynamic_cast <MultiDocumentPanelWindow*> (getChildComponent (i)));


if (dw != 0) if (dw != 0)
{
dw->setContentComponent (0, false);
delete dw;
}
dw->clearContentComponent();
} }


addAndMakeVisible (components.getFirst()); addAndMakeVisible (components.getFirst());
@@ -62498,7 +62490,7 @@ void MultiDocumentPanel::setLayoutMode (const LayoutMode newLayoutMode)
if (dw != 0) if (dw != 0)
{ {
dw->getContentComponent()->getProperties().set ("mdiDocumentPos_", dw->getWindowStateAsString()); dw->getContentComponent()->getProperties().set ("mdiDocumentPos_", dw->getWindowStateAsString());
dw->setContentComponent (0, false);
dw->clearContentComponent();
delete dw; delete dw;
} }
} }
@@ -77557,16 +77549,11 @@ public:
if (! JUCEApplication::isStandaloneApp()) if (! JUCEApplication::isStandaloneApp())
setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level


setContentComponent (contentComponent, true, true);
setContentNonOwned (contentComponent, true);
centreAroundComponent (componentToCentreAround, getWidth(), getHeight()); centreAroundComponent (componentToCentreAround, getWidth(), getHeight());
setResizable (shouldBeResizable, useBottomRightCornerResizer); setResizable (shouldBeResizable, useBottomRightCornerResizer);
} }


~TempDialogWindow()
{
setContentComponent (0, false);
}

void closeButtonPressed() void closeButtonPressed()
{ {
setVisible (false); setVisible (false);
@@ -77986,6 +77973,7 @@ BEGIN_JUCE_NAMESPACE
ResizableWindow::ResizableWindow (const String& name, ResizableWindow::ResizableWindow (const String& name,
const bool addToDesktop_) const bool addToDesktop_)
: TopLevelWindow (name, addToDesktop_), : TopLevelWindow (name, addToDesktop_),
ownsContentComponent (false),
resizeToFitContent (false), resizeToFitContent (false),
fullscreen (false), fullscreen (false),
lastNonFullScreenPos (50, 50, 256, 256), lastNonFullScreenPos (50, 50, 256, 256),
@@ -78006,6 +77994,7 @@ ResizableWindow::ResizableWindow (const String& name,
const Colour& backgroundColour_, const Colour& backgroundColour_,
const bool addToDesktop_) const bool addToDesktop_)
: TopLevelWindow (name, addToDesktop_), : TopLevelWindow (name, addToDesktop_),
ownsContentComponent (false),
resizeToFitContent (false), resizeToFitContent (false),
fullscreen (false), fullscreen (false),
lastNonFullScreenPos (50, 50, 256, 256), lastNonFullScreenPos (50, 50, 256, 256),
@@ -78032,7 +78021,7 @@ ResizableWindow::~ResizableWindow()


resizableCorner = 0; resizableCorner = 0;
resizableBorder = 0; resizableBorder = 0;
contentComponent.deleteAndZero();
clearContentComponent();


// have you been adding your own components directly to this window..? tut tut tut. // have you been adding your own components directly to this window..? tut tut tut.
// Read the instructions for using a ResizableWindow! // Read the instructions for using a ResizableWindow!
@@ -78049,31 +78038,70 @@ int ResizableWindow::getDesktopWindowStyleFlags() const
return styleFlags; return styleFlags;
} }


void ResizableWindow::setContentComponent (Component* const newContentComponent,
const bool deleteOldOne,
const bool resizeToFit)
void ResizableWindow::clearContentComponent()
{ {
resizeToFitContent = resizeToFit;
if (ownsContentComponent)
{
contentComponent.deleteAndZero();
}
else
{
removeChildComponent (contentComponent);
contentComponent = 0;
}
}


if (newContentComponent != static_cast <Component*> (contentComponent))
void ResizableWindow::setContent (Component* newContentComponent,
const bool takeOwnership,
const bool resizeToFitWhenContentChangesSize)
{
if (newContentComponent != contentComponent)
{ {
if (deleteOldOne)
contentComponent.deleteAndZero(); // (avoid using a scoped pointer for this, so that it survives
// external deletion of the content comp)
else
removeChildComponent (contentComponent);
clearContentComponent();


contentComponent = newContentComponent; contentComponent = newContentComponent;

Component::addAndMakeVisible (contentComponent); Component::addAndMakeVisible (contentComponent);
} }


if (resizeToFit)
ownsContentComponent = takeOwnership;
resizeToFitContent = resizeToFitWhenContentChangesSize;

if (resizeToFitWhenContentChangesSize)
childBoundsChanged (contentComponent); childBoundsChanged (contentComponent);


resized(); // must always be called to position the new content comp resized(); // must always be called to position the new content comp
} }


void ResizableWindow::setContentOwned (Component* newContentComponent, const bool resizeToFitWhenContentChangesSize)
{
setContent (newContentComponent, true, resizeToFitWhenContentChangesSize);
}

void ResizableWindow::setContentNonOwned (Component* newContentComponent, const bool resizeToFitWhenContentChangesSize)
{
setContent (newContentComponent, false, resizeToFitWhenContentChangesSize);
}

void ResizableWindow::setContentComponent (Component* const newContentComponent,
const bool deleteOldOne,
const bool resizeToFitWhenContentChangesSize)
{
if (newContentComponent != contentComponent)
{
if (deleteOldOne)
{
contentComponent.deleteAndZero();
}
else
{
removeChildComponent (contentComponent);
contentComponent = 0;
}
}

setContent (newContentComponent, true, resizeToFitWhenContentChangesSize);
}

void ResizableWindow::setContentComponentSize (int width, int height) void ResizableWindow::setContentComponentSize (int width, int height)
{ {
jassert (width > 0 && height > 0); // not a great idea to give it a zero size.. jassert (width > 0 && height > 0); // not a great idea to give it a zero size..
@@ -98258,8 +98286,7 @@ GZIPCompressorOutputStream::GZIPCompressorOutputStream (OutputStream* const dest
int compressionLevel, int compressionLevel,
const bool deleteDestStream, const bool deleteDestStream,
const int windowBits) const int windowBits)
: destStream (destStream_),
streamToDelete (deleteDestStream ? destStream_ : 0),
: destStream (destStream_, deleteDestStream),
buffer ((size_t) GZIPCompressorHelper::gzipCompBufferSize) buffer ((size_t) GZIPCompressorHelper::gzipCompBufferSize)
{ {
if (compressionLevel < 1 || compressionLevel > 9) if (compressionLevel < 1 || compressionLevel > 9)
@@ -105644,8 +105671,7 @@ GZIPDecompressorInputStream::GZIPDecompressorInputStream (InputStream* const sou
const bool deleteSourceWhenDestroyed, const bool deleteSourceWhenDestroyed,
const bool noWrap_, const bool noWrap_,
const int64 uncompressedStreamLength_) const int64 uncompressedStreamLength_)
: sourceStream (sourceStream_),
streamToDelete (deleteSourceWhenDestroyed ? sourceStream_ : 0),
: sourceStream (sourceStream_, deleteSourceWhenDestroyed),
uncompressedStreamLength (uncompressedStreamLength_), uncompressedStreamLength (uncompressedStreamLength_),
noWrap (noWrap_), noWrap (noWrap_),
isEof (false), isEof (false),
@@ -105658,7 +105684,7 @@ GZIPDecompressorInputStream::GZIPDecompressorInputStream (InputStream* const sou
} }


GZIPDecompressorInputStream::GZIPDecompressorInputStream (InputStream& sourceStream_) GZIPDecompressorInputStream::GZIPDecompressorInputStream (InputStream& sourceStream_)
: sourceStream (&sourceStream_),
: sourceStream (&sourceStream_, false),
uncompressedStreamLength (-1), uncompressedStreamLength (-1),
noWrap (false), noWrap (false),
isEof (false), isEof (false),


+ 168
- 25
juce_amalgamated.h View File

@@ -73,7 +73,7 @@ namespace JuceDummyNamespace {}
*/ */
#define JUCE_MAJOR_VERSION 1 #define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 53 #define JUCE_MINOR_VERSION 53
#define JUCE_BUILDNUMBER 30
#define JUCE_BUILDNUMBER 31


/** Current Juce version number. /** Current Juce version number.


@@ -19537,6 +19537,124 @@ private:
#ifndef __JUCE_BUFFEREDINPUTSTREAM_JUCEHEADER__ #ifndef __JUCE_BUFFEREDINPUTSTREAM_JUCEHEADER__
#define __JUCE_BUFFEREDINPUTSTREAM_JUCEHEADER__ #define __JUCE_BUFFEREDINPUTSTREAM_JUCEHEADER__



/*** Start of inlined file: juce_OptionalScopedPointer.h ***/
#ifndef __JUCE_OPTIONALSCOPEDPOINTER_JUCEHEADER__
#define __JUCE_OPTIONALSCOPEDPOINTER_JUCEHEADER__

/**
Holds a pointer to an object which can optionally be deleted when this pointer
goes out of scope.

This acts in many ways like a ScopedPointer, but allows you to specify whether or
not the object is deleted.

@see ScopedPointer
*/
template <class ObjectType>
class OptionalScopedPointer
{
public:

/** Creates an empty OptionalScopedPointer. */
OptionalScopedPointer() : shouldDelete (false) {}

/** Creates an OptionalScopedPointer to point to a given object, and specifying whether
the OptionalScopedPointer will delete it.

If takeOwnership is true, then the OptionalScopedPointer will act like a ScopedPointer,
deleting the object when it is itself deleted. If this parameter is false, then the
OptionalScopedPointer just holds a normal pointer to the object, and won't delete it.
*/
OptionalScopedPointer (ObjectType* objectToHold, bool takeOwnership)
: object (objectToHold), shouldDelete (takeOwnership)
{
}

/** Takes ownership of the object that another OptionalScopedPointer holds.

Like a normal ScopedPointer, the objectToTransferFrom object will become null,
as ownership of the managed object is transferred to this object.

The flag to indicate whether or not to delete the managed object is also
copied from the source object.
*/
OptionalScopedPointer (OptionalScopedPointer& objectToTransferFrom)
: object (objectToTransferFrom.release()),
shouldDelete (objectToTransferFrom.shouldDelete)
{
}

/** Takes ownership of the object that another OptionalScopedPointer holds.

Like a normal ScopedPointer, the objectToTransferFrom object will become null,
as ownership of the managed object is transferred to this object.

The ownership flag that says whether or not to delete the managed object is also
copied from the source object.
*/
OptionalScopedPointer& operator= (OptionalScopedPointer& objectToTransferFrom)
{
if (object != objectToTransferFrom.object)
{
clear();
object = objectToTransferFrom.object;
}

shouldDelete = objectToTransferFrom.shouldDelete;
return *this;
}

/** The destructor may or may not delete the object that is being held, depending on the
takeOwnership flag that was specified when the object was first passed into an
OptionalScopedPointer constructor.
*/
~OptionalScopedPointer()
{
clear();
}

/** Returns the object that this pointer is managing. */
inline operator ObjectType*() const throw() { return object; }

/** Returns the object that this pointer is managing. */
inline ObjectType& operator*() const throw() { return *object; }

/** Lets you access methods and properties of the object that this pointer is holding. */
inline ObjectType* operator->() const throw() { return object; }

/** Removes the current object from this OptionalScopedPointer without deleting it.
This will return the current object, and set this OptionalScopedPointer to a null pointer.
*/
ObjectType* release() throw() { return object.release(); }

/** Resets this pointer to null, possibly deleting the object that it holds, if it has
ownership of it.
*/
void clear()
{
if (! shouldDelete)
object.release();
}

/** Swaps this object with another OptionalScopedPointer.
The two objects simply exchange their states.
*/
void swapWith (OptionalScopedPointer<ObjectType>& other) throw()
{
object.swapWith (other.object);
swapVariables (shouldDelete, other.shouldDelete);
}

private:

ScopedPointer<ObjectType> object;
bool shouldDelete;
};

#endif // __JUCE_OPTIONALSCOPEDPOINTER_JUCEHEADER__
/*** End of inlined file: juce_OptionalScopedPointer.h ***/

/** Wraps another input stream, and reads from it using an intermediate buffer /** Wraps another input stream, and reads from it using an intermediate buffer


If you're using an input stream such as a file input stream, and making lots of If you're using an input stream such as a file input stream, and making lots of
@@ -19583,8 +19701,7 @@ public:


private: private:


InputStream* const source;
ScopedPointer <InputStream> sourceToDelete;
OptionalScopedPointer<InputStream> source;
int bufferSize; int bufferSize;
int64 position, lastReadPos, bufferStart, bufferOverlap; int64 position, lastReadPos, bufferStart, bufferOverlap;
HeapBlock <char> buffer; HeapBlock <char> buffer;
@@ -19686,8 +19803,7 @@ public:


private: private:


OutputStream* const destStream;
ScopedPointer <OutputStream> streamToDelete;
OptionalScopedPointer<OutputStream> destStream;
HeapBlock <uint8> buffer; HeapBlock <uint8> buffer;
class GZIPCompressorHelper; class GZIPCompressorHelper;
friend class ScopedPointer <GZIPCompressorHelper>; friend class ScopedPointer <GZIPCompressorHelper>;
@@ -19754,8 +19870,7 @@ public:
int read (void* destBuffer, int maxBytesToRead); int read (void* destBuffer, int maxBytesToRead);


private: private:
InputStream* const sourceStream;
ScopedPointer <InputStream> streamToDelete;
OptionalScopedPointer<InputStream> sourceStream;
const int64 uncompressedStreamLength; const int64 uncompressedStreamLength;
const bool noWrap; const bool noWrap;
bool isEof; bool isEof;
@@ -19998,8 +20113,7 @@ public:
bool isExhausted(); bool isExhausted();


private: private:
InputStream* const source;
ScopedPointer <InputStream> sourceToDelete;
OptionalScopedPointer<InputStream> source;
const int64 startPositionInSourceStream, lengthOfSourceStream; const int64 startPositionInSourceStream, lengthOfSourceStream;


JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SubregionStream); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SubregionStream);
@@ -20381,6 +20495,9 @@ private:
#endif #endif
#ifndef __JUCE_MEMORYBLOCK_JUCEHEADER__ #ifndef __JUCE_MEMORYBLOCK_JUCEHEADER__


#endif
#ifndef __JUCE_OPTIONALSCOPEDPOINTER_JUCEHEADER__

#endif #endif
#ifndef __JUCE_REFERENCECOUNTEDOBJECT_JUCEHEADER__ #ifndef __JUCE_REFERENCECOUNTEDOBJECT_JUCEHEADER__


@@ -55356,21 +55473,41 @@ public:
You should never add components directly to a ResizableWindow (or any of its subclasses) You should never add components directly to a ResizableWindow (or any of its subclasses)
with addChildComponent(). Instead, add them to the content component. with addChildComponent(). Instead, add them to the content component.


@param newContentComponent the new component to use (or null to not use one) - this
component will be deleted either when replaced by another call
to this method, or when the ResizableWindow is deleted.
To remove a content component without deleting it, use
setContentComponent (0, false).
@param deleteOldOne if true, the previous content component will be deleted; if
false, the previous component will just be removed without
deleting it.
@param resizeToFit if true, the ResizableWindow will maintain its size such that
it always fits around the size of the content component. If false, the
new content will be resized to fit the current space available.
*/
void setContentComponent (Component* newContentComponent,
bool deleteOldOne = true,
bool resizeToFit = false);
@param newContentComponent the new component to use - this component will be deleted when it's
no longer needed (i.e. when the window is deleted or a new content
component is set for it). To set a component that this window will not
delete, call setContentNonOwned() instead.
@param resizeToFitWhenContentChangesSize if true, then the ResizableWindow will maintain its size
such that it always fits around the size of the content component. If false,
the new content will be resized to fit the current space available.
*/
void setContentOwned (Component* newContentComponent,
bool resizeToFitWhenContentChangesSize);

/** Changes the current content component.

This sets a component that will be placed in the centre of the ResizableWindow,
(leaving a space around the edge for the border).

You should never add components directly to a ResizableWindow (or any of its subclasses)
with addChildComponent(). Instead, add them to the content component.

@param newContentComponent the new component to use - this component will NOT be deleted by this
component, so it's the caller's responsibility to manage its lifetime (it's
ok to delete it while this window is still using it). To set a content
component that the window will delete, call setContentOwned() instead.
@param resizeToFitWhenContentChangesSize if true, then the ResizableWindow will maintain its size
such that it always fits around the size of the content component. If false,
the new content will be resized to fit the current space available.
*/
void setContentNonOwned (Component* newContentComponent,
bool resizeToFitWhenContentChangesSize);

/** Removes the current content component.
If the previous content component was added with setContentOwned(), it will also be deleted. If
it was added with setContentNonOwned(), it will simply be removed from this component.
*/
void clearContentComponent();


/** Changes the window so that the content component ends up with the specified size. /** Changes the window so that the content component ends up with the specified size.


@@ -55401,6 +55538,11 @@ public:
backgroundColourId = 0x1005700, /**< A colour to use to fill the window's background. */ backgroundColourId = 0x1005700, /**< A colour to use to fill the window's background. */
}; };


/** @deprecated - use setContentOwned() and setContentNonOwned() instead. */
JUCE_DEPRECATED (void setContentComponent (Component* newContentComponent,
bool deleteOldOne = true,
bool resizeToFit = false));

protected: protected:


/** @internal */ /** @internal */
@@ -55450,7 +55592,7 @@ protected:
private: private:


Component::SafePointer <Component> contentComponent; Component::SafePointer <Component> contentComponent;
bool resizeToFitContent, fullscreen;
bool ownsContentComponent, resizeToFitContent, fullscreen;
ComponentDragger dragger; ComponentDragger dragger;
Rectangle<int> lastNonFullScreenPos; Rectangle<int> lastNonFullScreenPos;
ComponentBoundsConstrainer defaultConstrainer; ComponentBoundsConstrainer defaultConstrainer;
@@ -55460,6 +55602,7 @@ private:
#endif #endif


void updateLastPos(); void updateLastPos();
void setContent (Component* newComp, bool takeOwnership, bool resizeToFit);


#if JUCE_CATCH_DEPRECATED_CODE_MISUSE #if JUCE_CATCH_DEPRECATED_CODE_MISUSE
// The parameters for these methods have changed - please update your code! // The parameters for these methods have changed - please update your code!


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

@@ -33,7 +33,7 @@
*/ */
#define JUCE_MAJOR_VERSION 1 #define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 53 #define JUCE_MINOR_VERSION 53
#define JUCE_BUILDNUMBER 30
#define JUCE_BUILDNUMBER 31
/** Current Juce version number. /** Current Juce version number.


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

@@ -677,7 +677,7 @@ public:
: DialogWindow (TRANS("Add/remove items from toolbar"), Colours::white, true, true), : DialogWindow (TRANS("Add/remove items from toolbar"), Colours::white, true, true),
toolbar (toolbar_) toolbar (toolbar_)
{ {
setContentComponent (new CustomiserPanel (factory, toolbar, optionFlags), true, true);
setContentOwned (new CustomiserPanel (factory, toolbar, optionFlags), true);
setResizable (true, true); setResizable (true, true);
setResizeLimits (400, 300, 1500, 1000); setResizeLimits (400, 300, 1500, 1000);
positionNearBar(); positionNearBar();
@@ -686,7 +686,6 @@ public:
~ToolbarCustomisationDialog() ~ToolbarCustomisationDialog()
{ {
toolbar->setEditingActive (false); toolbar->setEditingActive (false);
setContentComponent (0, true);
} }
void closeButtonPressed() void closeButtonPressed()


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

@@ -106,7 +106,8 @@ FileChooserDialogBox::FileChooserDialogBox (const String& name,
: ResizableWindow (name, backgroundColour, true), : ResizableWindow (name, backgroundColour, true),
warnAboutOverwritingExistingFiles (warnAboutOverwritingExistingFiles_) warnAboutOverwritingExistingFiles (warnAboutOverwritingExistingFiles_)
{ {
setContentComponent (content = new ContentComponent (name, instructions, chooserComponent));
content = new ContentComponent (name, instructions, chooserComponent);
setContentOwned (content, false);
setResizable (true, true); setResizable (true, true);
setResizeLimits (300, 300, 1200, 1000); setResizeLimits (300, 300, 1200, 1000);


+ 5
- 9
src/gui/components/layout/juce_MultiDocumentPanel.cpp View File

@@ -155,7 +155,7 @@ void MultiDocumentPanel::addWindow (Component* component)
MultiDocumentPanelWindow* const dw = createNewDocumentWindow(); MultiDocumentPanelWindow* const dw = createNewDocumentWindow();
dw->setResizable (true, false); dw->setResizable (true, false);
dw->setContentComponent (component, false, true);
dw->setContentNonOwned (component, true);
dw->setName (component->getName()); dw->setName (component->getName());
const var bkg (component->getProperties() ["mdiDocumentBkg_"]); const var bkg (component->getProperties() ["mdiDocumentBkg_"]);
@@ -265,8 +265,7 @@ bool MultiDocumentPanel::closeDocument (Component* component,
if (dw != 0 && dw->getContentComponent() == component) if (dw != 0 && dw->getContentComponent() == component)
{ {
dw->setContentComponent (0, false);
delete dw;
ScopedPointer<MultiDocumentPanelWindow> (dw)->clearContentComponent();
break; break;
} }
} }
@@ -280,13 +279,10 @@ bool MultiDocumentPanel::closeDocument (Component* component,
{ {
for (int i = getNumChildComponents(); --i >= 0;) for (int i = getNumChildComponents(); --i >= 0;)
{ {
MultiDocumentPanelWindow* const dw = dynamic_cast <MultiDocumentPanelWindow*> (getChildComponent (i));
ScopedPointer<MultiDocumentPanelWindow> dw (dynamic_cast <MultiDocumentPanelWindow*> (getChildComponent (i)));
if (dw != 0) if (dw != 0)
{
dw->setContentComponent (0, false);
delete dw;
}
dw->clearContentComponent();
} }
addAndMakeVisible (components.getFirst()); addAndMakeVisible (components.getFirst());
@@ -423,7 +419,7 @@ void MultiDocumentPanel::setLayoutMode (const LayoutMode newLayoutMode)
if (dw != 0) if (dw != 0)
{ {
dw->getContentComponent()->getProperties().set ("mdiDocumentPos_", dw->getWindowStateAsString()); dw->getContentComponent()->getProperties().set ("mdiDocumentPos_", dw->getWindowStateAsString());
dw->setContentComponent (0, false);
dw->clearContentComponent();
delete dw; delete dw;
} }
} }


+ 1
- 6
src/gui/components/windows/juce_DialogWindow.cpp View File

@@ -76,16 +76,11 @@ public:
if (! JUCEApplication::isStandaloneApp()) if (! JUCEApplication::isStandaloneApp())
setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level
setContentComponent (contentComponent, true, true);
setContentNonOwned (contentComponent, true);
centreAroundComponent (componentToCentreAround, getWidth(), getHeight()); centreAroundComponent (componentToCentreAround, getWidth(), getHeight());
setResizable (shouldBeResizable, useBottomRightCornerResizer); setResizable (shouldBeResizable, useBottomRightCornerResizer);
} }
~TempDialogWindow()
{
setContentComponent (0, false);
}
void closeButtonPressed() void closeButtonPressed()
{ {
setVisible (false); setVisible (false);


+ 54
- 13
src/gui/components/windows/juce_ResizableWindow.cpp View File

@@ -38,6 +38,7 @@ BEGIN_JUCE_NAMESPACE
ResizableWindow::ResizableWindow (const String& name, ResizableWindow::ResizableWindow (const String& name,
const bool addToDesktop_) const bool addToDesktop_)
: TopLevelWindow (name, addToDesktop_), : TopLevelWindow (name, addToDesktop_),
ownsContentComponent (false),
resizeToFitContent (false), resizeToFitContent (false),
fullscreen (false), fullscreen (false),
lastNonFullScreenPos (50, 50, 256, 256), lastNonFullScreenPos (50, 50, 256, 256),
@@ -58,6 +59,7 @@ ResizableWindow::ResizableWindow (const String& name,
const Colour& backgroundColour_, const Colour& backgroundColour_,
const bool addToDesktop_) const bool addToDesktop_)
: TopLevelWindow (name, addToDesktop_), : TopLevelWindow (name, addToDesktop_),
ownsContentComponent (false),
resizeToFitContent (false), resizeToFitContent (false),
fullscreen (false), fullscreen (false),
lastNonFullScreenPos (50, 50, 256, 256), lastNonFullScreenPos (50, 50, 256, 256),
@@ -84,7 +86,7 @@ ResizableWindow::~ResizableWindow()
resizableCorner = 0; resizableCorner = 0;
resizableBorder = 0; resizableBorder = 0;
contentComponent.deleteAndZero();
clearContentComponent();
// have you been adding your own components directly to this window..? tut tut tut. // have you been adding your own components directly to this window..? tut tut tut.
// Read the instructions for using a ResizableWindow! // Read the instructions for using a ResizableWindow!
@@ -102,31 +104,70 @@ int ResizableWindow::getDesktopWindowStyleFlags() const
} }
//============================================================================== //==============================================================================
void ResizableWindow::setContentComponent (Component* const newContentComponent,
const bool deleteOldOne,
const bool resizeToFit)
void ResizableWindow::clearContentComponent()
{ {
resizeToFitContent = resizeToFit;
if (ownsContentComponent)
{
contentComponent.deleteAndZero();
}
else
{
removeChildComponent (contentComponent);
contentComponent = 0;
}
}
if (newContentComponent != static_cast <Component*> (contentComponent))
void ResizableWindow::setContent (Component* newContentComponent,
const bool takeOwnership,
const bool resizeToFitWhenContentChangesSize)
{
if (newContentComponent != contentComponent)
{ {
if (deleteOldOne)
contentComponent.deleteAndZero(); // (avoid using a scoped pointer for this, so that it survives
// external deletion of the content comp)
else
removeChildComponent (contentComponent);
clearContentComponent();
contentComponent = newContentComponent; contentComponent = newContentComponent;
Component::addAndMakeVisible (contentComponent); Component::addAndMakeVisible (contentComponent);
} }
if (resizeToFit)
ownsContentComponent = takeOwnership;
resizeToFitContent = resizeToFitWhenContentChangesSize;
if (resizeToFitWhenContentChangesSize)
childBoundsChanged (contentComponent); childBoundsChanged (contentComponent);
resized(); // must always be called to position the new content comp resized(); // must always be called to position the new content comp
} }
void ResizableWindow::setContentOwned (Component* newContentComponent, const bool resizeToFitWhenContentChangesSize)
{
setContent (newContentComponent, true, resizeToFitWhenContentChangesSize);
}
void ResizableWindow::setContentNonOwned (Component* newContentComponent, const bool resizeToFitWhenContentChangesSize)
{
setContent (newContentComponent, false, resizeToFitWhenContentChangesSize);
}
void ResizableWindow::setContentComponent (Component* const newContentComponent,
const bool deleteOldOne,
const bool resizeToFitWhenContentChangesSize)
{
if (newContentComponent != contentComponent)
{
if (deleteOldOne)
{
contentComponent.deleteAndZero();
}
else
{
removeChildComponent (contentComponent);
contentComponent = 0;
}
}
setContent (newContentComponent, true, resizeToFitWhenContentChangesSize);
}
void ResizableWindow::setContentComponentSize (int width, int height) void ResizableWindow::setContentComponentSize (int width, int height)
{ {
jassert (width > 0 && height > 0); // not a great idea to give it a zero size.. jassert (width > 0 && height > 0); // not a great idea to give it a zero size..


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

@@ -245,21 +245,41 @@ public:
You should never add components directly to a ResizableWindow (or any of its subclasses) You should never add components directly to a ResizableWindow (or any of its subclasses)
with addChildComponent(). Instead, add them to the content component. with addChildComponent(). Instead, add them to the content component.
@param newContentComponent the new component to use (or null to not use one) - this
component will be deleted either when replaced by another call
to this method, or when the ResizableWindow is deleted.
To remove a content component without deleting it, use
setContentComponent (0, false).
@param deleteOldOne if true, the previous content component will be deleted; if
false, the previous component will just be removed without
deleting it.
@param resizeToFit if true, the ResizableWindow will maintain its size such that
it always fits around the size of the content component. If false, the
new content will be resized to fit the current space available.
@param newContentComponent the new component to use - this component will be deleted when it's
no longer needed (i.e. when the window is deleted or a new content
component is set for it). To set a component that this window will not
delete, call setContentNonOwned() instead.
@param resizeToFitWhenContentChangesSize if true, then the ResizableWindow will maintain its size
such that it always fits around the size of the content component. If false,
the new content will be resized to fit the current space available.
*/ */
void setContentComponent (Component* newContentComponent,
bool deleteOldOne = true,
bool resizeToFit = false);
void setContentOwned (Component* newContentComponent,
bool resizeToFitWhenContentChangesSize);
/** Changes the current content component.
This sets a component that will be placed in the centre of the ResizableWindow,
(leaving a space around the edge for the border).
You should never add components directly to a ResizableWindow (or any of its subclasses)
with addChildComponent(). Instead, add them to the content component.
@param newContentComponent the new component to use - this component will NOT be deleted by this
component, so it's the caller's responsibility to manage its lifetime (it's
ok to delete it while this window is still using it). To set a content
component that the window will delete, call setContentOwned() instead.
@param resizeToFitWhenContentChangesSize if true, then the ResizableWindow will maintain its size
such that it always fits around the size of the content component. If false,
the new content will be resized to fit the current space available.
*/
void setContentNonOwned (Component* newContentComponent,
bool resizeToFitWhenContentChangesSize);
/** Removes the current content component.
If the previous content component was added with setContentOwned(), it will also be deleted. If
it was added with setContentNonOwned(), it will simply be removed from this component.
*/
void clearContentComponent();
/** Changes the window so that the content component ends up with the specified size. /** Changes the window so that the content component ends up with the specified size.
@@ -291,6 +311,12 @@ public:
backgroundColourId = 0x1005700, /**< A colour to use to fill the window's background. */ backgroundColourId = 0x1005700, /**< A colour to use to fill the window's background. */
}; };
//==============================================================================
/** @deprecated - use setContentOwned() and setContentNonOwned() instead. */
JUCE_DEPRECATED (void setContentComponent (Component* newContentComponent,
bool deleteOldOne = true,
bool resizeToFit = false));
protected: protected:
//============================================================================== //==============================================================================
/** @internal */ /** @internal */
@@ -340,7 +366,7 @@ protected:
private: private:
//============================================================================== //==============================================================================
Component::SafePointer <Component> contentComponent; Component::SafePointer <Component> contentComponent;
bool resizeToFitContent, fullscreen;
bool ownsContentComponent, resizeToFitContent, fullscreen;
ComponentDragger dragger; ComponentDragger dragger;
Rectangle<int> lastNonFullScreenPos; Rectangle<int> lastNonFullScreenPos;
ComponentBoundsConstrainer defaultConstrainer; ComponentBoundsConstrainer defaultConstrainer;
@@ -350,6 +376,7 @@ private:
#endif #endif
void updateLastPos(); void updateLastPos();
void setContent (Component* newComp, bool takeOwnership, bool resizeToFit);
#if JUCE_CATCH_DEPRECATED_CODE_MISUSE #if JUCE_CATCH_DEPRECATED_CODE_MISUSE
// The parameters for these methods have changed - please update your code! // The parameters for these methods have changed - please update your code!


+ 2
- 3
src/io/streams/juce_BufferedInputStream.cpp View File

@@ -49,8 +49,7 @@ namespace
//============================================================================== //==============================================================================
BufferedInputStream::BufferedInputStream (InputStream* const sourceStream, const int bufferSize_, BufferedInputStream::BufferedInputStream (InputStream* const sourceStream, const int bufferSize_,
const bool deleteSourceWhenDestroyed) const bool deleteSourceWhenDestroyed)
: source (sourceStream),
sourceToDelete (deleteSourceWhenDestroyed ? sourceStream : 0),
: source (sourceStream, deleteSourceWhenDestroyed),
bufferSize (calcBufferStreamBufferSize (bufferSize_, sourceStream)), bufferSize (calcBufferStreamBufferSize (bufferSize_, sourceStream)),
position (sourceStream->getPosition()), position (sourceStream->getPosition()),
lastReadPos (0), lastReadPos (0),
@@ -61,7 +60,7 @@ BufferedInputStream::BufferedInputStream (InputStream* const sourceStream, const
} }
BufferedInputStream::BufferedInputStream (InputStream& sourceStream, const int bufferSize_) BufferedInputStream::BufferedInputStream (InputStream& sourceStream, const int bufferSize_)
: source (&sourceStream),
: source (&sourceStream, false),
bufferSize (calcBufferStreamBufferSize (bufferSize_, &sourceStream)), bufferSize (calcBufferStreamBufferSize (bufferSize_, &sourceStream)),
position (sourceStream.getPosition()), position (sourceStream.getPosition()),
lastReadPos (0), lastReadPos (0),


+ 2
- 3
src/io/streams/juce_BufferedInputStream.h View File

@@ -27,7 +27,7 @@
#define __JUCE_BUFFEREDINPUTSTREAM_JUCEHEADER__ #define __JUCE_BUFFEREDINPUTSTREAM_JUCEHEADER__
#include "juce_InputStream.h" #include "juce_InputStream.h"
#include "../../memory/juce_ScopedPointer.h"
#include "../../memory/juce_OptionalScopedPointer.h"
//============================================================================== //==============================================================================
@@ -80,8 +80,7 @@ public:
private: private:
//============================================================================== //==============================================================================
InputStream* const source;
ScopedPointer <InputStream> sourceToDelete;
OptionalScopedPointer<InputStream> source;
int bufferSize; int bufferSize;
int64 position, lastReadPos, bufferStart, bufferOverlap; int64 position, lastReadPos, bufferStart, bufferOverlap;
HeapBlock <char> buffer; HeapBlock <char> buffer;


+ 1
- 2
src/io/streams/juce_GZIPCompressorOutputStream.cpp View File

@@ -133,8 +133,7 @@ GZIPCompressorOutputStream::GZIPCompressorOutputStream (OutputStream* const dest
int compressionLevel, int compressionLevel,
const bool deleteDestStream, const bool deleteDestStream,
const int windowBits) const int windowBits)
: destStream (destStream_),
streamToDelete (deleteDestStream ? destStream_ : 0),
: destStream (destStream_, deleteDestStream),
buffer ((size_t) GZIPCompressorHelper::gzipCompBufferSize) buffer ((size_t) GZIPCompressorHelper::gzipCompBufferSize)
{ {
if (compressionLevel < 1 || compressionLevel > 9) if (compressionLevel < 1 || compressionLevel > 9)


+ 2
- 3
src/io/streams/juce_GZIPCompressorOutputStream.h View File

@@ -27,7 +27,7 @@
#define __JUCE_GZIPCOMPRESSOROUTPUTSTREAM_JUCEHEADER__ #define __JUCE_GZIPCOMPRESSOROUTPUTSTREAM_JUCEHEADER__
#include "juce_OutputStream.h" #include "juce_OutputStream.h"
#include "../../memory/juce_ScopedPointer.h"
#include "../../memory/juce_OptionalScopedPointer.h"
//============================================================================== //==============================================================================
@@ -79,8 +79,7 @@ public:
private: private:
//============================================================================== //==============================================================================
OutputStream* const destStream;
ScopedPointer <OutputStream> streamToDelete;
OptionalScopedPointer<OutputStream> destStream;
HeapBlock <uint8> buffer; HeapBlock <uint8> buffer;
class GZIPCompressorHelper; class GZIPCompressorHelper;
friend class ScopedPointer <GZIPCompressorHelper>; friend class ScopedPointer <GZIPCompressorHelper>;


+ 2
- 3
src/io/streams/juce_GZIPDecompressorInputStream.cpp View File

@@ -161,8 +161,7 @@ GZIPDecompressorInputStream::GZIPDecompressorInputStream (InputStream* const sou
const bool deleteSourceWhenDestroyed, const bool deleteSourceWhenDestroyed,
const bool noWrap_, const bool noWrap_,
const int64 uncompressedStreamLength_) const int64 uncompressedStreamLength_)
: sourceStream (sourceStream_),
streamToDelete (deleteSourceWhenDestroyed ? sourceStream_ : 0),
: sourceStream (sourceStream_, deleteSourceWhenDestroyed),
uncompressedStreamLength (uncompressedStreamLength_), uncompressedStreamLength (uncompressedStreamLength_),
noWrap (noWrap_), noWrap (noWrap_),
isEof (false), isEof (false),
@@ -175,7 +174,7 @@ GZIPDecompressorInputStream::GZIPDecompressorInputStream (InputStream* const sou
} }
GZIPDecompressorInputStream::GZIPDecompressorInputStream (InputStream& sourceStream_) GZIPDecompressorInputStream::GZIPDecompressorInputStream (InputStream& sourceStream_)
: sourceStream (&sourceStream_),
: sourceStream (&sourceStream_, false),
uncompressedStreamLength (-1), uncompressedStreamLength (-1),
noWrap (false), noWrap (false),
isEof (false), isEof (false),


+ 2
- 3
src/io/streams/juce_GZIPDecompressorInputStream.h View File

@@ -27,7 +27,7 @@
#define __JUCE_GZIPDECOMPRESSORINPUTSTREAM_JUCEHEADER__ #define __JUCE_GZIPDECOMPRESSORINPUTSTREAM_JUCEHEADER__
#include "juce_InputStream.h" #include "juce_InputStream.h"
#include "../../memory/juce_ScopedPointer.h"
#include "../../memory/juce_OptionalScopedPointer.h"
//============================================================================== //==============================================================================
@@ -80,8 +80,7 @@ public:
//============================================================================== //==============================================================================
private: private:
InputStream* const sourceStream;
ScopedPointer <InputStream> streamToDelete;
OptionalScopedPointer<InputStream> sourceStream;
const int64 uncompressedStreamLength; const int64 uncompressedStreamLength;
const bool noWrap; const bool noWrap;
bool isEof; bool isEof;


+ 1
- 4
src/io/streams/juce_SubregionStream.cpp View File

@@ -35,13 +35,10 @@ SubregionStream::SubregionStream (InputStream* const sourceStream,
const int64 startPositionInSourceStream_, const int64 startPositionInSourceStream_,
const int64 lengthOfSourceStream_, const int64 lengthOfSourceStream_,
const bool deleteSourceWhenDestroyed) const bool deleteSourceWhenDestroyed)
: source (sourceStream),
: source (sourceStream, deleteSourceWhenDestroyed),
startPositionInSourceStream (startPositionInSourceStream_), startPositionInSourceStream (startPositionInSourceStream_),
lengthOfSourceStream (lengthOfSourceStream_) lengthOfSourceStream (lengthOfSourceStream_)
{ {
if (deleteSourceWhenDestroyed)
sourceToDelete = source;
setPosition (0); setPosition (0);
} }


+ 2
- 3
src/io/streams/juce_SubregionStream.h View File

@@ -27,7 +27,7 @@
#define __JUCE_SUBREGIONSTREAM_JUCEHEADER__ #define __JUCE_SUBREGIONSTREAM_JUCEHEADER__
#include "juce_InputStream.h" #include "juce_InputStream.h"
#include "../../memory/juce_ScopedPointer.h"
#include "../../memory/juce_OptionalScopedPointer.h"
//============================================================================== //==============================================================================
@@ -80,8 +80,7 @@ public:
//============================================================================== //==============================================================================
private: private:
InputStream* const source;
ScopedPointer <InputStream> sourceToDelete;
OptionalScopedPointer<InputStream> source;
const int64 startPositionInSourceStream, lengthOfSourceStream; const int64 startPositionInSourceStream, lengthOfSourceStream;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SubregionStream); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SubregionStream);


+ 3
- 0
src/juce_core_includes.h View File

@@ -221,6 +221,9 @@
#ifndef __JUCE_MEMORYBLOCK_JUCEHEADER__ #ifndef __JUCE_MEMORYBLOCK_JUCEHEADER__
#include "memory/juce_MemoryBlock.h" #include "memory/juce_MemoryBlock.h"
#endif #endif
#ifndef __JUCE_OPTIONALSCOPEDPOINTER_JUCEHEADER__
#include "memory/juce_OptionalScopedPointer.h"
#endif
#ifndef __JUCE_REFERENCECOUNTEDOBJECT_JUCEHEADER__ #ifndef __JUCE_REFERENCECOUNTEDOBJECT_JUCEHEADER__
#include "memory/juce_ReferenceCountedObject.h" #include "memory/juce_ReferenceCountedObject.h"
#endif #endif


Loading…
Cancel
Save