Browse Source

More ScopedPointer/unique_ptr compatibility work

tags/2021-05-28
jules 7 years ago
parent
commit
1a60fa9765
80 changed files with 404 additions and 368 deletions
  1. +1
    -1
      extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h
  2. +3
    -3
      modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp
  3. +1
    -1
      modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp
  4. +1
    -1
      modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp
  5. +26
    -38
      modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp
  6. +7
    -7
      modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h
  7. +6
    -6
      modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp
  8. +6
    -6
      modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp
  9. +3
    -1
      modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp
  10. +14
    -6
      modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp
  11. +1
    -1
      modules/juce_audio_formats/format/juce_AudioFormatManager.cpp
  12. +1
    -1
      modules/juce_audio_formats/format/juce_AudioFormatReader.cpp
  13. +2
    -2
      modules/juce_audio_formats/sampler/juce_Sampler.cpp
  14. +1
    -1
      modules/juce_audio_formats/sampler/juce_Sampler.h
  15. +1
    -1
      modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp
  16. +2
    -2
      modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm
  17. +16
    -16
      modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp
  18. +19
    -9
      modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp
  19. +5
    -3
      modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp
  20. +4
    -4
      modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp
  21. +1
    -1
      modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h
  22. +2
    -2
      modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp
  23. +12
    -12
      modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp
  24. +59
    -54
      modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp
  25. +5
    -5
      modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp
  26. +5
    -2
      modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp
  27. +1
    -1
      modules/juce_core/containers/juce_OwnedArray.h
  28. +7
    -7
      modules/juce_core/javascript/juce_Javascript.cpp
  29. +6
    -6
      modules/juce_core/maths/juce_Expression.cpp
  30. +1
    -1
      modules/juce_core/misc/juce_StdFunctionCompat.cpp
  31. +1
    -1
      modules/juce_core/native/juce_mac_Network.mm
  32. +1
    -1
      modules/juce_core/native/juce_posix_SharedCode.h
  33. +8
    -7
      modules/juce_core/network/juce_URL.cpp
  34. +4
    -4
      modules/juce_core/text/juce_LocalisedStrings.cpp
  35. +13
    -7
      modules/juce_core/xml/juce_XmlDocument.cpp
  36. +1
    -1
      modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp
  37. +5
    -4
      modules/juce_core/zip/juce_ZipFile.cpp
  38. +4
    -2
      modules/juce_data_structures/values/juce_ValueTree.cpp
  39. +2
    -2
      modules/juce_graphics/colour/juce_FillType.cpp
  40. +3
    -3
      modules/juce_graphics/native/juce_RenderingHelpers.h
  41. +7
    -7
      modules/juce_gui_basics/buttons/juce_Button.cpp
  42. +7
    -7
      modules/juce_gui_basics/buttons/juce_DrawableButton.cpp
  43. +2
    -2
      modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp
  44. +6
    -5
      modules/juce_gui_basics/components/juce_Component.cpp
  45. +1
    -1
      modules/juce_gui_basics/components/juce_Desktop.cpp
  46. +2
    -2
      modules/juce_gui_basics/components/juce_Desktop.h
  47. +1
    -1
      modules/juce_gui_basics/drawables/juce_Drawable.cpp
  48. +2
    -2
      modules/juce_gui_basics/drawables/juce_SVGParser.cpp
  49. +3
    -3
      modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp
  50. +1
    -1
      modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp
  51. +2
    -2
      modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp
  52. +3
    -3
      modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp
  53. +7
    -6
      modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp
  54. +4
    -4
      modules/juce_gui_basics/layout/juce_Viewport.cpp
  55. +7
    -7
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp
  56. +1
    -1
      modules/juce_gui_basics/menus/juce_BurgerMenuComponent.cpp
  57. +3
    -3
      modules/juce_gui_basics/menus/juce_PopupMenu.cpp
  58. +3
    -4
      modules/juce_gui_basics/native/juce_mac_FileChooser.mm
  59. +1
    -1
      modules/juce_gui_basics/native/juce_mac_MainMenu.mm
  60. +2
    -1
      modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp
  61. +2
    -2
      modules/juce_gui_basics/widgets/juce_ComboBox.cpp
  62. +8
    -7
      modules/juce_gui_basics/widgets/juce_Label.cpp
  63. +7
    -8
      modules/juce_gui_basics/widgets/juce_ListBox.cpp
  64. +2
    -1
      modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp
  65. +4
    -2
      modules/juce_gui_basics/widgets/juce_TextEditor.cpp
  66. +1
    -1
      modules/juce_gui_basics/widgets/juce_Toolbar.cpp
  67. +6
    -5
      modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp
  68. +2
    -2
      modules/juce_gui_basics/widgets/juce_TreeView.cpp
  69. +13
    -13
      modules/juce_gui_basics/windows/juce_DocumentWindow.cpp
  70. +2
    -2
      modules/juce_gui_basics/windows/juce_ResizableWindow.cpp
  71. +4
    -4
      modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp
  72. +1
    -1
      modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp
  73. +5
    -5
      modules/juce_opengl/opengl/juce_OpenGLContext.cpp
  74. +5
    -4
      modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp
  75. +2
    -2
      modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp
  76. +2
    -2
      modules/juce_opengl/opengl/juce_OpenGLImage.cpp
  77. +5
    -4
      modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp
  78. +1
    -1
      modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp
  79. +1
    -1
      modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.cpp
  80. +5
    -5
      modules/juce_video/playback/juce_VideoComponent.cpp

+ 1
- 1
extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h View File

@@ -50,7 +50,7 @@ public:
Image image (Image::ARGB, 200, 200, true); Image image (Image::ARGB, 200, 200, true);
Graphics g (image); Graphics g (image);
ScopedPointer<Drawable> svgDrawable = Drawable::createFromImageData (iconData, (size_t) iconDataSize);
ScopedPointer<Drawable> svgDrawable (Drawable::createFromImageData (iconData, (size_t) iconDataSize));
svgDrawable->drawWithin (g, image.getBounds().toFloat(), RectanglePlacement::fillDestination, 1.0f); svgDrawable->drawWithin (g, image.getBounds().toFloat(), RectanglePlacement::fillDestination, 1.0f);


+ 3
- 3
modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp View File

@@ -519,8 +519,8 @@ public:
conv->convertSamples (inPlace ? reversed : converted, original, numSamples); conv->convertSamples (inPlace ? reversed : converted, original, numSamples);
// ..and back again.. // ..and back again..
conv = new AudioData::ConverterInstance <AudioData::Pointer<F2, E2, AudioData::NonInterleaved, AudioData::Const>,
AudioData::Pointer<F1, E1, AudioData::NonInterleaved, AudioData::NonConst>>();
conv.reset (new AudioData::ConverterInstance <AudioData::Pointer<F2, E2, AudioData::NonInterleaved, AudioData::Const>,
AudioData::Pointer<F1, E1, AudioData::NonInterleaved, AudioData::NonConst>>());
if (! inPlace) if (! inPlace)
zeromem (reversed, sizeof (reversed)); zeromem (reversed, sizeof (reversed));
@@ -532,7 +532,7 @@ public:
AudioData::Pointer<F1, E1, AudioData::NonInterleaved, AudioData::Const> d2 (reversed); AudioData::Pointer<F1, E1, AudioData::NonInterleaved, AudioData::Const> d2 (reversed);
const int errorMargin = 2 * AudioData::Pointer<F1, E1, AudioData::NonInterleaved, AudioData::Const>::get32BitResolution() const int errorMargin = 2 * AudioData::Pointer<F1, E1, AudioData::NonInterleaved, AudioData::Const>::get32BitResolution()
+ AudioData::Pointer<F2, E2, AudioData::NonInterleaved, AudioData::Const>::get32BitResolution();
+ AudioData::Pointer<F2, E2, AudioData::NonInterleaved, AudioData::Const>::get32BitResolution();
for (int i = 0; i < numSamples; ++i) for (int i = 0; i < numSamples; ++i)
{ {


+ 1
- 1
modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp View File

@@ -2133,7 +2133,7 @@ private:
void noteReleased (MPENote finishedNote) override void noteReleased (MPENote finishedNote) override
{ {
noteReleasedCallCounter++; noteReleasedCallCounter++;
lastNoteFinished = new MPENote (finishedNote);
lastNoteFinished.reset (new MPENote (finishedNote));
} }
}; };


+ 1
- 1
modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp View File

@@ -71,7 +71,7 @@ void MixerAudioSource::removeInputSource (AudioSource* const input)
return; return;
if (inputsToDelete [index]) if (inputsToDelete [index])
toDelete = input;
toDelete.reset (input);
inputsToDelete.shiftBits (-1, index); inputsToDelete.shiftBits (-1, index);
inputs.remove (index); inputs.remove (index);


+ 26
- 38
modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp View File

@@ -89,14 +89,8 @@ private:
//============================================================================== //==============================================================================
AudioDeviceManager::AudioDeviceManager() AudioDeviceManager::AudioDeviceManager()
: numInputChansNeeded (0),
numOutputChansNeeded (2),
listNeedsScanning (true),
testSoundPosition (0),
cpuUsageMs (0),
timeToCpuScale (0)
{ {
callbackHandler = new CallbackHandler (*this);
callbackHandler.reset (new CallbackHandler (*this));
} }
AudioDeviceManager::~AudioDeviceManager() AudioDeviceManager::~AudioDeviceManager()
@@ -113,12 +107,12 @@ void AudioDeviceManager::createDeviceTypesIfNeeded()
OwnedArray<AudioIODeviceType> types; OwnedArray<AudioIODeviceType> types;
createAudioDeviceTypes (types); createAudioDeviceTypes (types);
for (int i = 0; i < types.size(); ++i)
addAudioDeviceType (types.getUnchecked(i));
for (auto* t : types)
addAudioDeviceType (t);
types.clear (false); types.clear (false);
if (AudioIODeviceType* first = availableDeviceTypes.getFirst())
if (auto* first = availableDeviceTypes.getFirst())
currentDeviceType = first->getTypeName(); currentDeviceType = first->getTypeName();
} }
} }
@@ -171,7 +165,7 @@ void AudioDeviceManager::addAudioDeviceType (AudioIODeviceType* newDeviceType)
availableDeviceTypes.add (newDeviceType); availableDeviceTypes.add (newDeviceType);
lastDeviceTypeConfigs.add (new AudioDeviceSetup()); lastDeviceTypeConfigs.add (new AudioDeviceSetup());
newDeviceType->addListener (callbackHandler);
newDeviceType->addListener (callbackHandler.get());
} }
} }
@@ -254,7 +248,7 @@ String AudioDeviceManager::initialiseFromXML (const XmlElement& xml,
const String& preferredDefaultDeviceName, const String& preferredDefaultDeviceName,
const AudioDeviceSetup* preferredSetupOptions) const AudioDeviceSetup* preferredSetupOptions)
{ {
lastExplicitSettings = new XmlElement (xml);
lastExplicitSettings.reset (new XmlElement (xml));
String error; String error;
AudioDeviceSetup setup; AudioDeviceSetup setup;
@@ -299,10 +293,8 @@ String AudioDeviceManager::initialiseFromXML (const XmlElement& xml,
forEachXmlChildElementWithTagName (xml, c, "MIDIINPUT") forEachXmlChildElementWithTagName (xml, c, "MIDIINPUT")
midiInsFromXml.add (c->getStringAttribute ("name")); midiInsFromXml.add (c->getStringAttribute ("name"));
const StringArray allMidiIns (MidiInput::getDevices());
for (int i = allMidiIns.size(); --i >= 0;)
setMidiInputEnabled (allMidiIns[i], midiInsFromXml.contains (allMidiIns[i]));
for (auto& m : MidiInput::getDevices())
setMidiInputEnabled (m, midiInsFromXml.contains (m));
if (error.isNotEmpty() && selectDefaultDeviceOnFailure) if (error.isNotEmpty() && selectDefaultDeviceOnFailure)
error = initialise (numInputChansNeeded, numOutputChansNeeded, error = initialise (numInputChansNeeded, numOutputChansNeeded,
@@ -319,12 +311,12 @@ String AudioDeviceManager::initialiseWithDefaultDevices (int numInputChannelsNee
lastExplicitSettings.reset(); lastExplicitSettings.reset();
return initialise (numInputChannelsNeeded, numOutputChannelsNeeded, return initialise (numInputChannelsNeeded, numOutputChannelsNeeded,
nullptr, false, String(), nullptr);
nullptr, false, {}, nullptr);
} }
void AudioDeviceManager::insertDefaultDeviceNames (AudioDeviceSetup& setup) const void AudioDeviceManager::insertDefaultDeviceNames (AudioDeviceSetup& setup) const
{ {
if (AudioIODeviceType* type = getCurrentDeviceTypeObject())
if (auto* type = getCurrentDeviceTypeObject())
{ {
if (setup.outputDeviceName.isEmpty()) if (setup.outputDeviceName.isEmpty())
setup.outputDeviceName = type->getDeviceNames (false) [type->getDefaultDeviceIndex (false)]; setup.outputDeviceName = type->getDeviceNames (false) [type->getDefaultDeviceIndex (false)];
@@ -336,7 +328,7 @@ void AudioDeviceManager::insertDefaultDeviceNames (AudioDeviceSetup& setup) cons
XmlElement* AudioDeviceManager::createStateXml() const XmlElement* AudioDeviceManager::createStateXml() const
{ {
return lastExplicitSettings.createCopy();
return createCopyIfNotNull (lastExplicitSettings.get());
} }
//============================================================================== //==============================================================================
@@ -473,7 +465,7 @@ String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& newSetup
if (newInputDeviceName.isNotEmpty() && ! deviceListContains (type, true, newInputDeviceName)) if (newInputDeviceName.isNotEmpty() && ! deviceListContains (type, true, newInputDeviceName))
return "No such device: " + newInputDeviceName; return "No such device: " + newInputDeviceName;
currentAudioDevice = type->createDevice (newOutputDeviceName, newInputDeviceName);
currentAudioDevice.reset (type->createDevice (newOutputDeviceName, newInputDeviceName));
if (currentAudioDevice == nullptr) if (currentAudioDevice == nullptr)
error = "Can't open the audio device!\n\n" error = "Can't open the audio device!\n\n"
@@ -521,7 +513,7 @@ String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& newSetup
{ {
currentDeviceType = currentAudioDevice->getTypeName(); currentDeviceType = currentAudioDevice->getTypeName();
currentAudioDevice->start (callbackHandler);
currentAudioDevice->start (callbackHandler.get());
currentSetup.sampleRate = currentAudioDevice->getCurrentSampleRate(); currentSetup.sampleRate = currentAudioDevice->getCurrentSampleRate();
currentSetup.bufferSize = currentAudioDevice->getCurrentBufferSizeSamples(); currentSetup.bufferSize = currentAudioDevice->getCurrentBufferSizeSamples();
@@ -618,7 +610,7 @@ void AudioDeviceManager::restartLastAudioDevice()
void AudioDeviceManager::updateXml() void AudioDeviceManager::updateXml()
{ {
lastExplicitSettings = new XmlElement ("DEVICESETUP");
lastExplicitSettings.reset (new XmlElement ("DEVICESETUP"));
lastExplicitSettings->setAttribute ("deviceType", currentDeviceType); lastExplicitSettings->setAttribute ("deviceType", currentDeviceType);
lastExplicitSettings->setAttribute ("audioOutputDeviceName", currentSetup.outputDeviceName); lastExplicitSettings->setAttribute ("audioOutputDeviceName", currentSetup.outputDeviceName);
@@ -668,7 +660,7 @@ void AudioDeviceManager::addAudioCallback (AudioIODeviceCallback* newCallback)
} }
if (currentAudioDevice != nullptr && newCallback != nullptr) if (currentAudioDevice != nullptr && newCallback != nullptr)
newCallback->audioDeviceAboutToStart (currentAudioDevice);
newCallback->audioDeviceAboutToStart (currentAudioDevice.get());
const ScopedLock sl (audioCallbackLock); const ScopedLock sl (audioCallbackLock);
callbacks.add (newCallback); callbacks.add (newCallback);
@@ -814,11 +806,11 @@ void AudioDeviceManager::setMidiInputEnabled (const String& name, const bool ena
{ {
if (enabled) if (enabled)
{ {
const int index = MidiInput::getDevices().indexOf (name);
auto index = MidiInput::getDevices().indexOf (name);
if (index >= 0) if (index >= 0)
{ {
if (MidiInput* const midiIn = MidiInput::openDevice (index, callbackHandler))
if (auto* midiIn = MidiInput::openDevice (index, callbackHandler.get()))
{ {
enabledMidiInputs.add (midiIn); enabledMidiInputs.add (midiIn);
midiIn->start(); midiIn->start();
@@ -839,8 +831,8 @@ void AudioDeviceManager::setMidiInputEnabled (const String& name, const bool ena
bool AudioDeviceManager::isMidiInputEnabled (const String& name) const bool AudioDeviceManager::isMidiInputEnabled (const String& name) const
{ {
for (int i = enabledMidiInputs.size(); --i >= 0;)
if (enabledMidiInputs[i]->getName() == name)
for (auto* mi : enabledMidiInputs)
if (mi->getName() == name)
return true; return true;
return false; return false;
@@ -865,7 +857,7 @@ void AudioDeviceManager::removeMidiInputCallback (const String& name, MidiInputC
{ {
for (int i = midiCallbacks.size(); --i >= 0;) for (int i = midiCallbacks.size(); --i >= 0;)
{ {
const MidiCallbackInfo& mc = midiCallbacks.getReference(i);
auto& mc = midiCallbacks.getReference(i);
if (mc.callback == callbackToRemove && mc.deviceName == name) if (mc.callback == callbackToRemove && mc.deviceName == name)
{ {
@@ -881,13 +873,9 @@ void AudioDeviceManager::handleIncomingMidiMessageInt (MidiInput* source, const
{ {
const ScopedLock sl (midiCallbackLock); const ScopedLock sl (midiCallbackLock);
for (int i = 0; i < midiCallbacks.size(); ++i)
{
const MidiCallbackInfo& mc = midiCallbacks.getReference(i);
for (auto& mc : midiCallbacks)
if (mc.deviceName.isEmpty() || mc.deviceName == source->getName()) if (mc.deviceName.isEmpty() || mc.deviceName == source->getName())
mc.callback->handleIncomingMidiMessage (source, message); mc.callback->handleIncomingMidiMessage (source, message);
}
} }
} }
@@ -911,11 +899,11 @@ void AudioDeviceManager::setDefaultMidiOutput (const String& deviceName)
defaultMidiOutputName = deviceName; defaultMidiOutputName = deviceName;
if (deviceName.isNotEmpty()) if (deviceName.isNotEmpty())
defaultMidiOutput = MidiOutput::openDevice (MidiOutput::getDevices().indexOf (deviceName));
defaultMidiOutput.reset (MidiOutput::openDevice (MidiOutput::getDevices().indexOf (deviceName)));
if (currentAudioDevice != nullptr) if (currentAudioDevice != nullptr)
for (int i = oldCallbacks.size(); --i >= 0;)
oldCallbacks.getUnchecked(i)->audioDeviceAboutToStart (currentAudioDevice);
for (auto* c : oldCallbacks)
c->audioDeviceAboutToStart (currentAudioDevice.get());
{ {
const ScopedLock sl (audioCallbackLock); const ScopedLock sl (audioCallbackLock);
@@ -982,7 +970,7 @@ void AudioDeviceManager::playTestSound()
{ {
const ScopedLock sl (audioCallbackLock); const ScopedLock sl (audioCallbackLock);
oldSound = testSound;
std::swap (oldSound, testSound);
} }
} }
@@ -1007,7 +995,7 @@ void AudioDeviceManager::playTestSound()
newSound->applyGainRamp (0, soundLength - soundLength / 4, soundLength / 4, 1.0f, 0.0f); newSound->applyGainRamp (0, soundLength - soundLength / 4, soundLength / 4, 1.0f, 0.0f);
const ScopedLock sl (audioCallbackLock); const ScopedLock sl (audioCallbackLock);
testSound = newSound;
testSound.reset (newSound);
} }
} }


+ 7
- 7
modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h View File

@@ -234,7 +234,7 @@ public:
/** Returns the currently-active audio device. */ /** Returns the currently-active audio device. */
AudioIODevice* getCurrentAudioDevice() const noexcept { return currentAudioDevice; }
AudioIODevice* getCurrentAudioDevice() const noexcept { return currentAudioDevice.get(); }
/** Returns the type of audio device currently in use. /** Returns the type of audio device currently in use.
@see setCurrentAudioDeviceType @see setCurrentAudioDeviceType
@@ -372,7 +372,7 @@ public:
If no device has been selected, or the device can't be opened, this will return nullptr. If no device has been selected, or the device can't be opened, this will return nullptr.
@see getDefaultMidiOutputName @see getDefaultMidiOutputName
*/ */
MidiOutput* getDefaultMidiOutput() const noexcept { return defaultMidiOutput; }
MidiOutput* getDefaultMidiOutput() const noexcept { return defaultMidiOutput.get(); }
/** Returns a list of the types of device supported. */ /** Returns a list of the types of device supported. */
const OwnedArray<AudioIODeviceType>& getAvailableDeviceTypes(); const OwnedArray<AudioIODeviceType>& getAvailableDeviceTypes();
@@ -453,11 +453,11 @@ private:
AudioDeviceSetup currentSetup; AudioDeviceSetup currentSetup;
ScopedPointer<AudioIODevice> currentAudioDevice; ScopedPointer<AudioIODevice> currentAudioDevice;
Array<AudioIODeviceCallback*> callbacks; Array<AudioIODeviceCallback*> callbacks;
int numInputChansNeeded, numOutputChansNeeded;
int numInputChansNeeded = 0, numOutputChansNeeded = 2;
String currentDeviceType; String currentDeviceType;
BigInteger inputChannels, outputChannels; BigInteger inputChannels, outputChannels;
ScopedPointer<XmlElement> lastExplicitSettings; ScopedPointer<XmlElement> lastExplicitSettings;
mutable bool listNeedsScanning;
mutable bool listNeedsScanning = true;
AudioBuffer<float> tempBuffer; AudioBuffer<float> tempBuffer;
struct MidiCallbackInfo struct MidiCallbackInfo
@@ -475,10 +475,10 @@ private:
CriticalSection audioCallbackLock, midiCallbackLock; CriticalSection audioCallbackLock, midiCallbackLock;
ScopedPointer<AudioBuffer<float>> testSound; ScopedPointer<AudioBuffer<float>> testSound;
int testSoundPosition;
int testSoundPosition = 0;
double cpuUsageMs, timeToCpuScale, msPerBlock;
int xruns;
double cpuUsageMs = 0, timeToCpuScale = 0, msPerBlock = 0;
int xruns = 0;
struct LevelMeter struct LevelMeter
{ {


+ 6
- 6
modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp View File

@@ -965,14 +965,14 @@ public:
} }
jassert (device != nullptr); jassert (device != nullptr);
internal = device;
internal.reset (device);
AudioObjectPropertyAddress pa; AudioObjectPropertyAddress pa;
pa.mSelector = kAudioObjectPropertySelectorWildcard; pa.mSelector = kAudioObjectPropertySelectorWildcard;
pa.mScope = kAudioObjectPropertyScopeWildcard; pa.mScope = kAudioObjectPropertyScopeWildcard;
pa.mElement = kAudioObjectPropertyElementWildcard; pa.mElement = kAudioObjectPropertyElementWildcard;
AudioObjectAddPropertyListener (kAudioObjectSystemObject, &pa, hardwareListenerProc, internal);
AudioObjectAddPropertyListener (kAudioObjectSystemObject, &pa, hardwareListenerProc, internal.get());
} }
~CoreAudioIODevice() ~CoreAudioIODevice()
@@ -984,7 +984,7 @@ public:
pa.mScope = kAudioObjectPropertyScopeWildcard; pa.mScope = kAudioObjectPropertyScopeWildcard;
pa.mElement = kAudioObjectPropertyElementWildcard; pa.mElement = kAudioObjectPropertyElementWildcard;
AudioObjectRemovePropertyListener (kAudioObjectSystemObject, &pa, hardwareListenerProc, internal);
AudioObjectRemovePropertyListener (kAudioObjectSystemObject, &pa, hardwareListenerProc, internal.get());
} }
StringArray getOutputChannelNames() override { return internal->outChanNames; } StringArray getOutputChannelNames() override { return internal->outChanNames; }
@@ -1226,7 +1226,7 @@ public:
Array<AudioIODevice*> devs; Array<AudioIODevice*> devs;
for (auto* d : devices) for (auto* d : devices)
devs.add (d->device);
devs.add (d->device.get());
return devs; return devs;
} }
@@ -2160,10 +2160,10 @@ public:
ScopedPointer<CoreAudioIODevice> in, out; ScopedPointer<CoreAudioIODevice> in, out;
if (inputDeviceID != 0) if (inputDeviceID != 0)
in = new CoreAudioIODevice (*this, inputDeviceName, inputDeviceID, inputIndex, 0, -1);
in.reset (new CoreAudioIODevice (*this, inputDeviceName, inputDeviceID, inputIndex, 0, -1));
if (outputDeviceID != 0) if (outputDeviceID != 0)
out = new CoreAudioIODevice (*this, outputDeviceName, 0, -1, outputDeviceID, outputIndex);
out.reset (new CoreAudioIODevice (*this, outputDeviceName, 0, -1, outputDeviceID, outputIndex));
if (in == nullptr) return out.release(); if (in == nullptr) return out.release();
if (out == nullptr) return in.release(); if (out == nullptr) return in.release();


+ 6
- 6
modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp View File

@@ -511,15 +511,15 @@ MidiInput* MidiInput::openDevice (int index, MidiInputCallback* callback)
MIDIPortRef port; MIDIPortRef port;
ScopedPointer<MidiPortAndCallback> mpc (new MidiPortAndCallback (*callback)); ScopedPointer<MidiPortAndCallback> mpc (new MidiPortAndCallback (*callback));
if (CHECK_ERROR (MIDIInputPortCreate (client, name.cfString, midiInputProc, mpc, &port)))
if (CHECK_ERROR (MIDIInputPortCreate (client, name.cfString, midiInputProc, mpc.get(), &port)))
{ {
if (CHECK_ERROR (MIDIPortConnectSource (port, endPoint, nullptr))) if (CHECK_ERROR (MIDIPortConnectSource (port, endPoint, nullptr)))
{ {
mpc->portAndEndpoint = new MidiPortAndEndpoint (port, endPoint);
mpc->portAndEndpoint.reset (new MidiPortAndEndpoint (port, endPoint));
newInput = new MidiInput (getDevices() [index]); newInput = new MidiInput (getDevices() [index]);
mpc->input = newInput; mpc->input = newInput;
newInput->internal = mpc;
newInput->internal = mpc.get();
const ScopedLock sl (callbackLock); const ScopedLock sl (callbackLock);
activeCallbacks.add (mpc.release()); activeCallbacks.add (mpc.release());
@@ -553,15 +553,15 @@ MidiInput* MidiInput::createNewDevice (const String& deviceName, MidiInputCallba
ScopedCFString name; ScopedCFString name;
name.cfString = deviceName.toCFString(); name.cfString = deviceName.toCFString();
if (CHECK_ERROR (MIDIDestinationCreate (client, name.cfString, midiInputProc, mpc, &endPoint)))
if (CHECK_ERROR (MIDIDestinationCreate (client, name.cfString, midiInputProc, mpc.get(), &endPoint)))
{ {
CoreMidiHelpers::setUniqueIdForMidiPort (endPoint, deviceName, true); CoreMidiHelpers::setUniqueIdForMidiPort (endPoint, deviceName, true);
mpc->portAndEndpoint = new MidiPortAndEndpoint (0, endPoint);
mpc->portAndEndpoint.reset (new MidiPortAndEndpoint (0, endPoint));
mi = new MidiInput (deviceName); mi = new MidiInput (deviceName);
mpc->input = mi; mpc->input = mi;
mi->internal = mpc;
mi->internal = mpc.get();
const ScopedLock sl (callbackLock); const ScopedLock sl (callbackLock);
activeCallbacks.add (mpc.release()); activeCallbacks.add (mpc.release());


+ 3
- 1
modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp View File

@@ -486,7 +486,9 @@ int OggVorbisAudioFormat::estimateOggFileQuality (const File& source)
{ {
if (auto* in = source.createInputStream()) if (auto* in = source.createInputStream())
{ {
if (ScopedPointer<AudioFormatReader> r = createReaderFor (in, true))
ScopedPointer<AudioFormatReader> r (createReaderFor (in, true));
if (r != nullptr)
{ {
auto lengthSecs = r->lengthInSamples / r->sampleRate; auto lengthSecs = r->lengthInSamples / r->sampleRate;
auto approxBitsPerSecond = (int) (source.getSize() * 8 / lengthSecs); auto approxBitsPerSecond = (int) (source.getSize() * 8 / lengthSecs);


+ 14
- 6
modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp View File

@@ -1738,13 +1738,19 @@ namespace WavFileHelpers
TemporaryFile tempFile (file); TemporaryFile tempFile (file);
WavAudioFormat wav; WavAudioFormat wav;
if (ScopedPointer<AudioFormatReader> reader = wav.createReaderFor (file.createInputStream(), true))
ScopedPointer<AudioFormatReader> reader (wav.createReaderFor (file.createInputStream(), true));
if (reader != nullptr)
{ {
if (ScopedPointer<OutputStream> outStream = tempFile.getFile().createOutputStream())
ScopedPointer<OutputStream> outStream (tempFile.getFile().createOutputStream());
if (outStream != nullptr)
{ {
if (ScopedPointer<AudioFormatWriter> writer = wav.createWriterFor (outStream, reader->sampleRate,
reader->numChannels, (int) reader->bitsPerSample,
metadata, 0))
ScopedPointer<AudioFormatWriter> writer (wav.createWriterFor (outStream.get(), reader->sampleRate,
reader->numChannels, (int) reader->bitsPerSample,
metadata, 0));
if (writer != nullptr)
{ {
outStream.release(); outStream.release();
@@ -1765,7 +1771,9 @@ bool WavAudioFormat::replaceMetadataInFile (const File& wavFile, const StringPai
{ {
using namespace WavFileHelpers; using namespace WavFileHelpers;
if (ScopedPointer<WavAudioFormatReader> reader = static_cast<WavAudioFormatReader*> (createReaderFor (wavFile.createInputStream(), true)))
ScopedPointer<WavAudioFormatReader> reader (static_cast<WavAudioFormatReader*> (createReaderFor (wavFile.createInputStream(), true)));
if (reader != nullptr)
{ {
auto bwavPos = reader->bwavChunkStart; auto bwavPos = reader->bwavChunkStart;
auto bwavSize = reader->bwavSize; auto bwavSize = reader->bwavSize;


+ 1
- 1
modules/juce_audio_formats/format/juce_AudioFormatManager.cpp View File

@@ -146,7 +146,7 @@ AudioFormatReader* AudioFormatManager::createReaderFor (InputStream* audioFileSt
for (auto* af : knownFormats) for (auto* af : knownFormats)
{ {
if (auto* r = af->createReaderFor (in, false))
if (auto* r = af->createReaderFor (in.get(), false))
{ {
in.release(); in.release();
return r; return r;


+ 1
- 1
modules/juce_audio_formats/format/juce_AudioFormatReader.cpp View File

@@ -394,7 +394,7 @@ bool MemoryMappedAudioFormatReader::mapSectionOfFile (Range<int64> samplesToMap)
const Range<int64> fileRange (sampleToFilePos (samplesToMap.getStart()), const Range<int64> fileRange (sampleToFilePos (samplesToMap.getStart()),
sampleToFilePos (samplesToMap.getEnd())); sampleToFilePos (samplesToMap.getEnd()));
map = new MemoryMappedFile (file, fileRange, MemoryMappedFile::readOnly);
map.reset (new MemoryMappedFile (file, fileRange, MemoryMappedFile::readOnly));
if (map->getData() == nullptr) if (map->getData() == nullptr)
map.reset(); map.reset();


+ 2
- 2
modules/juce_audio_formats/sampler/juce_Sampler.cpp View File

@@ -44,9 +44,9 @@ SamplerSound::SamplerSound (const String& soundName,
length = jmin ((int) source.lengthInSamples, length = jmin ((int) source.lengthInSamples,
(int) (maxSampleLengthSeconds * sourceSampleRate)); (int) (maxSampleLengthSeconds * sourceSampleRate));
data = new AudioBuffer<float> (jmin (2, (int) source.numChannels), length + 4);
data.reset (new AudioBuffer<float> (jmin (2, (int) source.numChannels), length + 4));
source.read (data, 0, length + 4, 0, true, true);
source.read (data.get(), 0, length + 4, 0, true, true);
attackSamples = roundToInt (attackTimeSecs * sourceSampleRate); attackSamples = roundToInt (attackTimeSecs * sourceSampleRate);
releaseSamples = roundToInt (releaseTimeSecs * sourceSampleRate); releaseSamples = roundToInt (releaseTimeSecs * sourceSampleRate);


+ 1
- 1
modules/juce_audio_formats/sampler/juce_Sampler.h View File

@@ -79,7 +79,7 @@ public:
/** Returns the audio sample data. /** Returns the audio sample data.
This could return nullptr if there was a problem loading the data. This could return nullptr if there was a problem loading the data.
*/ */
AudioBuffer<float>* getAudioData() const noexcept { return data; }
AudioBuffer<float>* getAudioData() const noexcept { return data.get(); }
//============================================================================== //==============================================================================


+ 1
- 1
modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp View File

@@ -125,7 +125,7 @@ AudioPluginInstance* AudioPluginFormat::createInstanceFromDescription (const Plu
createPluginInstanceAsync (desc, initialSampleRate, initialBufferSize, eventSignaler.release()); createPluginInstanceAsync (desc, initialSampleRate, initialBufferSize, eventSignaler.release());
else else
createPluginInstance (desc, initialSampleRate, initialBufferSize, createPluginInstance (desc, initialSampleRate, initialBufferSize,
eventSignaler, EventSignaler::staticCompletionCallback);
eventSignaler.get(), EventSignaler::staticCompletionCallback);
waitForCreation.wait(); waitForCreation.wait();


+ 2
- 2
modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm View File

@@ -2223,7 +2223,7 @@ AudioProcessorEditor* AudioUnitPluginInstance::createEditor()
ScopedPointer<AudioProcessorEditor> w (new AudioUnitPluginWindowCocoa (*this, false)); ScopedPointer<AudioProcessorEditor> w (new AudioUnitPluginWindowCocoa (*this, false));
if (! static_cast<AudioUnitPluginWindowCocoa*> (w.get())->isValid()) if (! static_cast<AudioUnitPluginWindowCocoa*> (w.get())->isValid())
w = nullptr;
w.reset();
#if JUCE_SUPPORT_CARBON #if JUCE_SUPPORT_CARBON
if (w == nullptr) if (w == nullptr)
@@ -2236,7 +2236,7 @@ AudioProcessorEditor* AudioUnitPluginInstance::createEditor()
#endif #endif
if (w == nullptr) if (w == nullptr)
w = new AudioUnitPluginWindowCocoa (*this, true); // use AUGenericView as a fallback
w.reset (new AudioUnitPluginWindowCocoa (*this, true)); // use AUGenericView as a fallback
return w.release(); return w.release();
} }


+ 16
- 16
modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp View File

@@ -897,14 +897,14 @@ struct DescriptionFactory
if (pf2.loadFrom (factory)) if (pf2.loadFrom (factory))
{ {
info2 = new PClassInfo2();
pf2->getClassInfo2 (i, info2);
info2.reset (new PClassInfo2());
pf2->getClassInfo2 (i, info2.get());
} }
if (pf3.loadFrom (factory)) if (pf3.loadFrom (factory))
{ {
infoW = new PClassInfoW();
pf3->getClassInfoUnicode (i, infoW);
infoW.reset (new PClassInfoW());
pf3->getClassInfoUnicode (i, infoW.get());
} }
} }
@@ -923,7 +923,7 @@ struct DescriptionFactory
auto numOutputs = getNumSingleDirectionChannelsFor (component, false, true); auto numOutputs = getNumSingleDirectionChannelsFor (component, false, true);
createPluginDescription (desc, file, companyName, name, createPluginDescription (desc, file, companyName, name,
info, info2, infoW, numInputs, numOutputs);
info, info2.get(), infoW.get(), numInputs, numOutputs);
component->terminate(); component->terminate();
} }
@@ -1246,7 +1246,7 @@ private:
//============================================================================== //==============================================================================
bool open (const File& f, const PluginDescription& description) bool open (const File& f, const PluginDescription& description)
{ {
dllHandle = new DLLHandle (f.getFullPathName());
dllHandle.reset (new DLLHandle (f.getFullPathName()));
ComSmartPtr<IPluginFactory> pluginFactory (dllHandle->getPluginFactory()); ComSmartPtr<IPluginFactory> pluginFactory (dllHandle->getPluginFactory());
@@ -1572,23 +1572,23 @@ struct VST3ComponentHolder
if (pf2.loadFrom (factory)) if (pf2.loadFrom (factory))
{ {
info2 = new PClassInfo2();
pf2->getClassInfo2 (classIdx, info2);
info2.reset (new PClassInfo2());
pf2->getClassInfo2 (classIdx, info2.get());
} }
else else
{ {
info2 = nullptr;
info2.reset();
} }
if (pf3.loadFrom (factory)) if (pf3.loadFrom (factory))
{ {
pf3->setHostContext (host->getFUnknown()); pf3->setHostContext (host->getFUnknown());
infoW = new PClassInfoW();
pf3->getClassInfoUnicode (classIdx, infoW);
infoW.reset (new PClassInfoW());
pf3->getClassInfoUnicode (classIdx, infoW.get());
} }
else else
{ {
infoW = nullptr;
infoW.reset();
} }
Vst::BusInfo bus; Vst::BusInfo bus;
@@ -1606,7 +1606,7 @@ struct VST3ComponentHolder
createPluginDescription (description, module->file, createPluginDescription (description, module->file,
factoryInfo.vendor, module->name, factoryInfo.vendor, module->name,
info, info2, infoW,
info, info2.get(), infoW.get(),
totalNumInputChannels, totalNumInputChannels,
totalNumOutputChannels); totalNumOutputChannels);
@@ -2784,14 +2784,14 @@ void VST3PluginFormat::createPluginInstance (const PluginDescription& descriptio
if (const VST3Classes::VST3ModuleHandle::Ptr module = VST3Classes::VST3ModuleHandle::findOrCreateModule (file, description)) if (const VST3Classes::VST3ModuleHandle::Ptr module = VST3Classes::VST3ModuleHandle::findOrCreateModule (file, description))
{ {
ScopedPointer<VST3Classes::VST3ComponentHolder> holder = new VST3Classes::VST3ComponentHolder (module);
ScopedPointer<VST3Classes::VST3ComponentHolder> holder (new VST3Classes::VST3ComponentHolder (module));
if (holder->initialise()) if (holder->initialise())
{ {
result = new VST3Classes::VST3PluginInstance (holder.release());
result.reset (new VST3Classes::VST3PluginInstance (holder.release()));
if (! result->initialise()) if (! result->initialise())
result = nullptr;
result.reset();
} }
} }


+ 19
- 9
modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp View File

@@ -447,7 +447,7 @@ struct ModuleHandle : public ReferenceCountedObject
.findChildFiles (vstXmlFiles, File::findFiles, false, "*.vstxml"); .findChildFiles (vstXmlFiles, File::findFiles, false, "*.vstxml");
if (vstXmlFiles.size() > 0) if (vstXmlFiles.size() > 0)
vstXml = XmlDocument::parse (vstXmlFiles.getReference(0));
vstXml.reset (XmlDocument::parse (vstXmlFiles.getReference(0)));
} }
} }
@@ -2077,10 +2077,16 @@ public:
#if JUCE_SUPPORT_CARBON #if JUCE_SUPPORT_CARBON
if (! plug.usesCocoaNSView) if (! plug.usesCocoaNSView)
addAndMakeVisible (carbonWrapper = new CarbonWrapperComponent (*this));
{
carbonWrapper.reset (new CarbonWrapperComponent (*this));
addAndMakeVisible (carbonWrapper.get());
}
else else
#endif #endif
addAndMakeVisible (cocoaWrapper = new AutoResizingNSViewComponentWithParent());
{
cocoaWrapper.reset (new AutoResizingNSViewComponentWithParent());
addAndMakeVisible (cocoaWrapper.get());
}
#endif #endif
activeVSTWindows.add (this); activeVSTWindows.add (this);
@@ -2096,9 +2102,9 @@ public:
#if JUCE_MAC #if JUCE_MAC
#if JUCE_SUPPORT_CARBON #if JUCE_SUPPORT_CARBON
carbonWrapper = nullptr;
carbonWrapper.reset();
#endif #endif
cocoaWrapper = nullptr;
cocoaWrapper.reset();
#elif JUCE_LINUX #elif JUCE_LINUX
display = XWindowSystem::getInstance()->displayUnref(); display = XWindowSystem::getInstance()->displayUnref();
#endif #endif
@@ -2791,10 +2797,10 @@ void VSTPluginFormat::createPluginInstance (const PluginDescription& desc,
{ {
shellUIDToCreate = desc.uid; shellUIDToCreate = desc.uid;
result = VSTPluginInstance::create (module, sampleRate, blockSize);
result.reset (VSTPluginInstance::create (module, sampleRate, blockSize));
if (result != nullptr && ! result->initialiseEffect (sampleRate, blockSize)) if (result != nullptr && ! result->initialiseEffect (sampleRate, blockSize))
result = nullptr;
result.reset();
} }
previousWorkingDirectory.setAsCurrentWorkingDirectory(); previousWorkingDirectory.setAsCurrentWorkingDirectory();
@@ -2954,9 +2960,13 @@ AudioPluginInstance* VSTPluginFormat::createCustomVSTFromMainCall (void* entryPo
ModuleHandle::Ptr module = new ModuleHandle (File(), (MainCall) entryPointFunction); ModuleHandle::Ptr module = new ModuleHandle (File(), (MainCall) entryPointFunction);
if (module->open()) if (module->open())
if (ScopedPointer<VSTPluginInstance> result = VSTPluginInstance::create (module, initialSampleRate, initialBufferSize))
{
ScopedPointer<VSTPluginInstance> result (VSTPluginInstance::create (module, initialSampleRate, initialBufferSize));
if (result != nullptr)
if (result->initialiseEffect (initialSampleRate, initialBufferSize)) if (result->initialiseEffect (initialSampleRate, initialBufferSize))
return result.release(); return result.release();
}
return nullptr; return nullptr;
} }
@@ -2966,7 +2976,7 @@ void VSTPluginFormat::setExtraFunctions (AudioPluginInstance* plugin, ExtraFunct
ScopedPointer<ExtraFunctions> f (functions); ScopedPointer<ExtraFunctions> f (functions);
if (auto* vst = dynamic_cast<VSTPluginInstance*> (plugin)) if (auto* vst = dynamic_cast<VSTPluginInstance*> (plugin))
vst->extraFunctions = f;
std::swap (vst->extraFunctions, f);
} }
AudioPluginInstance* VSTPluginFormat::getPluginInstanceFromVstEffectInterface (void* aEffect) AudioPluginInstance* VSTPluginFormat::getPluginInstanceFromVstEffectInterface (void* aEffect)


+ 5
- 3
modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp View File

@@ -46,7 +46,7 @@ AudioProcessorEditor::~AudioProcessorEditor()
// if this fails, then the wrapper hasn't called editorBeingDeleted() on the // if this fails, then the wrapper hasn't called editorBeingDeleted() on the
// filter for some reason.. // filter for some reason..
jassert (processor.getActiveEditor() != this); jassert (processor.getActiveEditor() != this);
removeComponentListener (resizeListener);
removeComponentListener (resizeListener.get());
} }
void AudioProcessorEditor::setControlHighlight (ParameterControlHighlightInfo) {} void AudioProcessorEditor::setControlHighlight (ParameterControlHighlightInfo) {}
@@ -77,7 +77,8 @@ void AudioProcessorEditor::initialise()
resizable = false; resizable = false;
attachConstrainer (&defaultConstrainer); attachConstrainer (&defaultConstrainer);
addComponentListener (resizeListener = new AudioProcessorEditorListener (*this));
resizeListener.reset (new AudioProcessorEditorListener (*this));
addComponentListener (resizeListener.get());
} }
//============================================================================== //==============================================================================
@@ -108,7 +109,8 @@ void AudioProcessorEditor::setResizable (const bool shouldBeResizable, const boo
{ {
if (shouldHaveCornerResizer) if (shouldHaveCornerResizer)
{ {
Component::addChildComponent (resizableCorner = new ResizableCornerComponent (this, constrainer));
resizableCorner.reset (new ResizableCornerComponent (this, constrainer));
Component::addChildComponent (resizableCorner.get());
resizableCorner->setAlwaysOnTop (true); resizableCorner->setAlwaysOnTop (true);
} }
else else


+ 4
- 4
modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp View File

@@ -1144,8 +1144,8 @@ void AudioProcessorGraph::clearRenderingSequence()
{ {
const ScopedLock sl (getCallbackLock()); const ScopedLock sl (getCallbackLock());
renderSequenceFloat.swapWith (oldSequenceF);
renderSequenceDouble.swapWith (oldSequenceD);
std::swap (renderSequenceFloat, oldSequenceF);
std::swap (renderSequenceDouble, oldSequenceD);
} }
} }
@@ -1187,8 +1187,8 @@ void AudioProcessorGraph::buildRenderingSequence()
const ScopedLock sl (getCallbackLock()); const ScopedLock sl (getCallbackLock());
renderSequenceFloat.swapWith (newSequenceF);
renderSequenceDouble.swapWith (newSequenceD);
std::swap (renderSequenceFloat, newSequenceF);
std::swap (renderSequenceDouble, newSequenceD);
} }
void AudioProcessorGraph::handleAsyncUpdate() void AudioProcessorGraph::handleAsyncUpdate()


+ 1
- 1
modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h View File

@@ -96,7 +96,7 @@ public:
const NodeID nodeID; const NodeID nodeID;
/** The actual processor object that this node represents. */ /** The actual processor object that this node represents. */
AudioProcessor* getProcessor() const noexcept { return processor; }
AudioProcessor* getProcessor() const noexcept { return processor.get(); }
/** A set of user-definable properties that are associated with this node. /** A set of user-definable properties that are associated with this node.


+ 2
- 2
modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp View File

@@ -115,7 +115,7 @@ bool KnownPluginList::isListingUpToDate (const String& fileOrIdentifier,
void KnownPluginList::setCustomScanner (CustomScanner* newScanner) void KnownPluginList::setCustomScanner (CustomScanner* newScanner)
{ {
scanner = newScanner;
scanner.reset (newScanner);
} }
bool KnownPluginList::scanAndAddFile (const String& fileOrIdentifier, bool KnownPluginList::scanAndAddFile (const String& fileOrIdentifier,
@@ -425,7 +425,7 @@ struct PluginTreeUtils
{ {
current->folder = lastType; current->folder = lastType;
tree.subFolders.add (current.release()); tree.subFolders.add (current.release());
current = new KnownPluginList::PluginTree();
current.reset (new KnownPluginList::PluginTree());
} }
lastType = thisType; lastType = thisType;


+ 12
- 12
modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp View File

@@ -142,7 +142,7 @@ PluginListComponent::PluginListComponent (AudioPluginFormatManager& manager, Kno
allowAsync (allowPluginsWhichRequireAsynchronousInstantiation), allowAsync (allowPluginsWhichRequireAsynchronousInstantiation),
numThreads (allowAsync ? 1 : 0) numThreads (allowAsync ? 1 : 0)
{ {
tableModel = new TableModel (*this, listToEdit);
tableModel.reset (new TableModel (*this, listToEdit));
TableHeaderComponent& header = table.getHeader(); TableHeaderComponent& header = table.getHeader();
@@ -154,7 +154,7 @@ PluginListComponent::PluginListComponent (AudioPluginFormatManager& manager, Kno
table.setHeaderHeight (22); table.setHeaderHeight (22);
table.setRowHeight (20); table.setRowHeight (20);
table.setModel (tableModel);
table.setModel (tableModel.get());
table.setMultipleSelectionEnabled (true); table.setMultipleSelectionEnabled (true);
addAndMakeVisible (table); addAndMakeVisible (table);
@@ -228,8 +228,8 @@ void PluginListComponent::removeSelectedPlugins()
void PluginListComponent::setTableModel (TableListBoxModel* model) void PluginListComponent::setTableModel (TableListBoxModel* model)
{ {
table.setModel (nullptr); table.setModel (nullptr);
tableModel = model;
table.setModel (tableModel);
tableModel.reset (model);
table.setModel (tableModel.get());
table.getHeader().reSortTable(); table.getHeader().reSortTable();
table.updateContent(); table.updateContent();
@@ -479,8 +479,8 @@ private:
{ {
pathChooserWindow.setVisible (false); pathChooserWindow.setVisible (false);
scanner = new PluginDirectoryScanner (owner.list, formatToScan, pathList.getPath(),
true, owner.deadMansPedalFile, allowAsync);
scanner.reset (new PluginDirectoryScanner (owner.list, formatToScan, pathList.getPath(),
true, owner.deadMansPedalFile, allowAsync));
if (propertiesToUse != nullptr) if (propertiesToUse != nullptr)
{ {
@@ -494,7 +494,7 @@ private:
if (numThreads > 0) if (numThreads > 0)
{ {
pool = new ThreadPool (numThreads);
pool.reset (new ThreadPool (numThreads));
for (int i = numThreads; --i >= 0;) for (int i = numThreads; --i >= 0;)
pool->addJob (new ScanJob (*this), true); pool->addJob (new ScanJob (*this), true);
@@ -560,9 +560,9 @@ private:
void PluginListComponent::scanFor (AudioPluginFormat& format) void PluginListComponent::scanFor (AudioPluginFormat& format)
{ {
currentScanner = new Scanner (*this, format, propertiesToUse, allowAsync, numThreads,
dialogTitle.isNotEmpty() ? dialogTitle : TRANS("Scanning for plug-ins..."),
dialogText.isNotEmpty() ? dialogText : TRANS("Searching for all possible plug-in files..."));
currentScanner.reset (new Scanner (*this, format, propertiesToUse, allowAsync, numThreads,
dialogTitle.isNotEmpty() ? dialogTitle : TRANS("Scanning for plug-ins..."),
dialogText.isNotEmpty() ? dialogText : TRANS("Searching for all possible plug-in files...")));
} }
bool PluginListComponent::isScanning() const noexcept bool PluginListComponent::isScanning() const noexcept
@@ -574,8 +574,8 @@ void PluginListComponent::scanFinished (const StringArray& failedFiles)
{ {
StringArray shortNames; StringArray shortNames;
for (int i = 0; i < failedFiles.size(); ++i)
shortNames.add (File::createFileWithoutCheckingPath (failedFiles[i]).getFileName());
for (auto& f : failedFiles)
shortNames.add (File::createFileWithoutCheckingPath (f).getFileName());
currentScanner.reset(); // mustn't delete this before using the failed files array currentScanner.reset(); // mustn't delete this before using the failed files array


+ 59
- 54
modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp View File

@@ -207,7 +207,8 @@ public:
{ {
if (hideAdvancedOptionsWithButton) if (hideAdvancedOptionsWithButton)
{ {
addAndMakeVisible (showAdvancedSettingsButton = new TextButton (TRANS("Show advanced settings...")));
showAdvancedSettingsButton.reset (new TextButton (TRANS("Show advanced settings...")));
addAndMakeVisible (showAdvancedSettingsButton.get());
showAdvancedSettingsButton->onClick = [this] { showAdvanced(); }; showAdvancedSettingsButton->onClick = [this] { showAdvanced(); };
} }
@@ -353,8 +354,8 @@ public:
error = setup.manager->setAudioDeviceSetup (config, true); error = setup.manager->setAudioDeviceSetup (config, true);
showCorrectDeviceName (inputDeviceDropDown, true);
showCorrectDeviceName (outputDeviceDropDown, false);
showCorrectDeviceName (inputDeviceDropDown.get(), true);
showCorrectDeviceName (outputDeviceDropDown.get(), false);
updateControlPanelButton(); updateControlPanelButton();
resized(); resized();
@@ -433,12 +434,12 @@ public:
{ {
if (outputChanList == nullptr) if (outputChanList == nullptr)
{ {
addAndMakeVisible (outputChanList
= new ChannelSelectorListBox (setup, ChannelSelectorListBox::audioOutputType,
TRANS ("(no audio output channels found)")));
outputChanLabel = new Label ({}, TRANS("Active output channels:"));
outputChanList.reset (new ChannelSelectorListBox (setup, ChannelSelectorListBox::audioOutputType,
TRANS ("(no audio output channels found)")));
addAndMakeVisible (outputChanList.get());
outputChanLabel.reset (new Label ({}, TRANS("Active output channels:")));
outputChanLabel->setJustificationType (Justification::centredRight); outputChanLabel->setJustificationType (Justification::centredRight);
outputChanLabel->attachToComponent (outputChanList, true);
outputChanLabel->attachToComponent (outputChanList.get(), true);
} }
outputChanList->refresh(); outputChanList->refresh();
@@ -454,12 +455,12 @@ public:
{ {
if (inputChanList == nullptr) if (inputChanList == nullptr)
{ {
addAndMakeVisible (inputChanList
= new ChannelSelectorListBox (setup, ChannelSelectorListBox::audioInputType,
TRANS("(no audio input channels found)")));
inputChanLabel = new Label ({}, TRANS("Active input channels:"));
inputChanList.reset (new ChannelSelectorListBox (setup, ChannelSelectorListBox::audioInputType,
TRANS("(no audio input channels found)")));
addAndMakeVisible (inputChanList.get());
inputChanLabel.reset (new Label ({}, TRANS("Active input channels:")));
inputChanLabel->setJustificationType (Justification::centredRight); inputChanLabel->setJustificationType (Justification::centredRight);
inputChanLabel->attachToComponent (inputChanList, true);
inputChanLabel->attachToComponent (inputChanList.get(), true);
} }
inputChanList->refresh(); inputChanList->refresh();
@@ -564,8 +565,9 @@ private:
if (currentDevice != nullptr && currentDevice->hasControlPanel()) if (currentDevice != nullptr && currentDevice->hasControlPanel())
{ {
addAndMakeVisible (showUIButton = new TextButton (TRANS ("Control Panel"),
TRANS ("Opens the device's own control panel")));
showUIButton.reset (new TextButton (TRANS ("Control Panel"),
TRANS ("Opens the device's own control panel")));
addAndMakeVisible (showUIButton.get());
showUIButton->onClick = [this] { showDeviceUIPanel(); }; showUIButton->onClick = [this] { showDeviceUIPanel(); };
} }
@@ -580,9 +582,9 @@ private:
{ {
if (resetDeviceButton == nullptr) if (resetDeviceButton == nullptr)
{ {
addAndMakeVisible (resetDeviceButton = new TextButton (TRANS ("Reset Device"),
TRANS ("Resets the audio interface - sometimes needed after changing a device's properties in its custom control panel")));
resetDeviceButton.reset (new TextButton (TRANS ("Reset Device"),
TRANS ("Resets the audio interface - sometimes needed after changing a device's properties in its custom control panel")));
addAndMakeVisible (resetDeviceButton.get());
resetDeviceButton->onClick = [this] { resetDevice(); }; resetDeviceButton->onClick = [this] { resetDevice(); };
resized(); resized();
} }
@@ -600,19 +602,19 @@ private:
{ {
if (outputDeviceDropDown == nullptr) if (outputDeviceDropDown == nullptr)
{ {
outputDeviceDropDown = new ComboBox();
outputDeviceDropDown.reset (new ComboBox());
outputDeviceDropDown->onChange = [this] { updateConfig (true, false, false, false); }; outputDeviceDropDown->onChange = [this] { updateConfig (true, false, false, false); };
addAndMakeVisible (outputDeviceDropDown);
addAndMakeVisible (outputDeviceDropDown.get());
outputDeviceLabel = new Label ({}, type.hasSeparateInputsAndOutputs() ? TRANS("Output:")
: TRANS("Device:"));
outputDeviceLabel->attachToComponent (outputDeviceDropDown, true);
outputDeviceLabel.reset (new Label ({}, type.hasSeparateInputsAndOutputs() ? TRANS("Output:")
: TRANS("Device:")));
outputDeviceLabel->attachToComponent (outputDeviceDropDown.get(), true);
if (setup.maxNumOutputChannels > 0) if (setup.maxNumOutputChannels > 0)
{ {
addAndMakeVisible (testButton = new TextButton (TRANS("Test"),
TRANS("Plays a test tone")));
testButton.reset (new TextButton (TRANS("Test"), TRANS("Plays a test tone")));
addAndMakeVisible (testButton.get());
testButton->onClick = [this] { playTestSound(); }; testButton->onClick = [this] { playTestSound(); };
} }
} }
@@ -620,7 +622,7 @@ private:
addNamesToDeviceBox (*outputDeviceDropDown, false); addNamesToDeviceBox (*outputDeviceDropDown, false);
} }
showCorrectDeviceName (outputDeviceDropDown, false);
showCorrectDeviceName (outputDeviceDropDown.get(), false);
} }
void updateInputsComboBox() void updateInputsComboBox()
@@ -629,31 +631,32 @@ private:
{ {
if (inputDeviceDropDown == nullptr) if (inputDeviceDropDown == nullptr)
{ {
inputDeviceDropDown = new ComboBox();
inputDeviceDropDown.reset (new ComboBox());
inputDeviceDropDown->onChange = [this] { updateConfig (false, true, false, false); }; inputDeviceDropDown->onChange = [this] { updateConfig (false, true, false, false); };
addAndMakeVisible (inputDeviceDropDown);
addAndMakeVisible (inputDeviceDropDown.get());
inputDeviceLabel = new Label ({}, TRANS("Input:"));
inputDeviceLabel->attachToComponent (inputDeviceDropDown, true);
inputDeviceLabel.reset (new Label ({}, TRANS("Input:")));
inputDeviceLabel->attachToComponent (inputDeviceDropDown.get(), true);
addAndMakeVisible (inputLevelMeter
= new SimpleDeviceManagerInputLevelMeter (*setup.manager));
inputLevelMeter.reset (new SimpleDeviceManagerInputLevelMeter (*setup.manager));
addAndMakeVisible (inputLevelMeter.get());
} }
addNamesToDeviceBox (*inputDeviceDropDown, true); addNamesToDeviceBox (*inputDeviceDropDown, true);
} }
showCorrectDeviceName (inputDeviceDropDown, true);
showCorrectDeviceName (inputDeviceDropDown.get(), true);
} }
void updateSampleRateComboBox (AudioIODevice* currentDevice) void updateSampleRateComboBox (AudioIODevice* currentDevice)
{ {
if (sampleRateDropDown == nullptr) if (sampleRateDropDown == nullptr)
{ {
addAndMakeVisible (sampleRateDropDown = new ComboBox());
sampleRateDropDown.reset (new ComboBox());
addAndMakeVisible (sampleRateDropDown.get());
sampleRateLabel = new Label ({}, TRANS("Sample rate:"));
sampleRateLabel->attachToComponent (sampleRateDropDown, true);
sampleRateLabel.reset (new Label ({}, TRANS("Sample rate:")));
sampleRateLabel->attachToComponent (sampleRateDropDown.get(), true);
} }
else else
{ {
@@ -675,10 +678,11 @@ private:
{ {
if (bufferSizeDropDown == nullptr) if (bufferSizeDropDown == nullptr)
{ {
addAndMakeVisible (bufferSizeDropDown = new ComboBox());
bufferSizeDropDown.reset (new ComboBox());
addAndMakeVisible (bufferSizeDropDown.get());
bufferSizeLabel = new Label ({}, TRANS("Audio buffer size:"));
bufferSizeLabel->attachToComponent (bufferSizeDropDown, true);
bufferSizeLabel.reset (new Label ({}, TRANS("Audio buffer size:")));
bufferSizeLabel->attachToComponent (bufferSizeDropDown.get(), true);
} }
else else
{ {
@@ -975,33 +979,33 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager&
if (types.size() > 1) if (types.size() > 1)
{ {
deviceTypeDropDown = new ComboBox();
deviceTypeDropDown.reset (new ComboBox());
for (int i = 0; i < types.size(); ++i) for (int i = 0; i < types.size(); ++i)
deviceTypeDropDown->addItem (types.getUnchecked(i)->getTypeName(), i + 1); deviceTypeDropDown->addItem (types.getUnchecked(i)->getTypeName(), i + 1);
addAndMakeVisible (deviceTypeDropDown);
addAndMakeVisible (deviceTypeDropDown.get());
deviceTypeDropDown->onChange = [this] { updateDeviceType(); }; deviceTypeDropDown->onChange = [this] { updateDeviceType(); };
deviceTypeDropDownLabel = new Label ({}, TRANS("Audio device type:"));
deviceTypeDropDownLabel.reset (new Label ({}, TRANS("Audio device type:")));
deviceTypeDropDownLabel->setJustificationType (Justification::centredRight); deviceTypeDropDownLabel->setJustificationType (Justification::centredRight);
deviceTypeDropDownLabel->attachToComponent (deviceTypeDropDown, true);
deviceTypeDropDownLabel->attachToComponent (deviceTypeDropDown.get(), true);
} }
if (showMidiInputOptions) if (showMidiInputOptions)
{ {
addAndMakeVisible (midiInputsList
= new MidiInputSelectorComponentListBox (deviceManager,
midiInputsList.reset (new MidiInputSelectorComponentListBox (deviceManager,
"(" + TRANS("No MIDI inputs available") + ")")); "(" + TRANS("No MIDI inputs available") + ")"));
addAndMakeVisible (midiInputsList.get());
midiInputsLabel = new Label ({}, TRANS ("Active MIDI inputs:"));
midiInputsLabel.reset (new Label ({}, TRANS ("Active MIDI inputs:")));
midiInputsLabel->setJustificationType (Justification::topRight); midiInputsLabel->setJustificationType (Justification::topRight);
midiInputsLabel->attachToComponent (midiInputsList, true);
midiInputsLabel->attachToComponent (midiInputsList.get(), true);
if (BluetoothMidiDevicePairingDialogue::isAvailable()) if (BluetoothMidiDevicePairingDialogue::isAvailable())
{ {
addAndMakeVisible (bluetoothButton = new TextButton (TRANS("Bluetooth MIDI"),
TRANS("Scan for bluetooth MIDI devices")));
bluetoothButton.reset (new TextButton (TRANS("Bluetooth MIDI"), TRANS("Scan for bluetooth MIDI devices")));
addAndMakeVisible (bluetoothButton.get());
bluetoothButton->onClick = [this] { handleBluetoothButton(); }; bluetoothButton->onClick = [this] { handleBluetoothButton(); };
} }
} }
@@ -1014,11 +1018,12 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager&
if (showMidiOutputSelector) if (showMidiOutputSelector)
{ {
addAndMakeVisible (midiOutputSelector = new ComboBox());
midiOutputSelector.reset (new ComboBox());
addAndMakeVisible (midiOutputSelector.get());
midiOutputSelector->onChange = [this] { updateMidiOutput(); }; midiOutputSelector->onChange = [this] { updateMidiOutput(); };
midiOutputLabel = new Label ("lm", TRANS("MIDI Output:"));
midiOutputLabel->attachToComponent (midiOutputSelector, true);
midiOutputLabel.reset (new Label ("lm", TRANS("MIDI Output:")));
midiOutputLabel->attachToComponent (midiOutputSelector.get(), true);
} }
else else
{ {
@@ -1139,7 +1144,7 @@ void AudioDeviceSelectorComponent::updateAllControls()
details.useStereoPairs = showChannelsAsStereoPairs; details.useStereoPairs = showChannelsAsStereoPairs;
auto* sp = new AudioDeviceSettingsPanel (*type, details, hideAdvancedOptionsWithButton); auto* sp = new AudioDeviceSettingsPanel (*type, details, hideAdvancedOptionsWithButton);
audioDeviceSettingsComp = sp;
audioDeviceSettingsComp.reset (sp);
addAndMakeVisible (sp); addAndMakeVisible (sp);
sp->updateAllControls(); sp->updateAllControls();
} }
@@ -1186,7 +1191,7 @@ void AudioDeviceSelectorComponent::handleBluetoothButton()
ListBox* AudioDeviceSelectorComponent::getMidiInputSelectorListBox() const noexcept ListBox* AudioDeviceSelectorComponent::getMidiInputSelectorListBox() const noexcept
{ {
return midiInputsList;
return midiInputsList.get();
} }
} // namespace juce } // namespace juce

+ 5
- 5
modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp View File

@@ -219,8 +219,8 @@ private:
void createReader() void createReader()
{ {
if (reader == nullptr && source != nullptr) if (reader == nullptr && source != nullptr)
if (InputStream* audioFileStream = source->createInputStream())
reader = owner.formatManagerToUse.createReaderFor (audioFileStream);
if (auto* audioFileStream = source->createInputStream())
reader.reset (owner.formatManagerToUse.createReaderFor (audioFileStream));
} }
bool readNextBlock() bool readNextBlock()
@@ -648,7 +648,7 @@ bool AudioThumbnail::setDataSource (LevelDataSource* newSource)
if (cache.loadThumb (*this, newSource->hashCode) && isFullyLoaded()) if (cache.loadThumb (*this, newSource->hashCode) && isFullyLoaded())
{ {
source = newSource; // (make sure this isn't done before loadThumb is called)
source.reset (newSource); // (make sure this isn't done before loadThumb is called)
source->lengthInSamples = totalSamples; source->lengthInSamples = totalSamples;
source->sampleRate = sampleRate; source->sampleRate = sampleRate;
@@ -657,7 +657,7 @@ bool AudioThumbnail::setDataSource (LevelDataSource* newSource)
} }
else else
{ {
source = newSource; // (make sure this isn't done before loadThumb is called)
source.reset (newSource); // (make sure this isn't done before loadThumb is called)
const ScopedLock sl (lock); const ScopedLock sl (lock);
source->initialise (numSamplesFinished); source->initialise (numSamplesFinished);
@@ -807,7 +807,7 @@ void AudioThumbnail::drawChannel (Graphics& g, const Rectangle<int>& area, doubl
const ScopedLock sl (lock); const ScopedLock sl (lock);
window->drawChannel (g, area, startTime, endTime, channelNum, verticalZoomFactor, window->drawChannel (g, area, startTime, endTime, channelNum, verticalZoomFactor,
sampleRate, numChannels, samplesPerThumbSample, source, channels);
sampleRate, numChannels, samplesPerThumbSample, source.get(), channels);
} }
void AudioThumbnail::drawChannels (Graphics& g, const Rectangle<int>& area, double startTimeSeconds, void AudioThumbnail::drawChannels (Graphics& g, const Rectangle<int>& area, double startTimeSeconds,


+ 5
- 2
modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp View File

@@ -68,8 +68,11 @@ private:
MidiKeyboardComponent::MidiKeyboardComponent (MidiKeyboardState& s, Orientation o) MidiKeyboardComponent::MidiKeyboardComponent (MidiKeyboardState& s, Orientation o)
: state (s), orientation (o) : state (s), orientation (o)
{ {
addChildComponent (scrollDown = new UpDownButton (*this, -1));
addChildComponent (scrollUp = new UpDownButton (*this, 1));
scrollDown.reset (new UpDownButton (*this, -1));
scrollUp .reset (new UpDownButton (*this, 1));
addChildComponent (scrollDown.get());
addChildComponent (scrollUp.get());
// initialise with a default set of qwerty key-mappings.. // initialise with a default set of qwerty key-mappings..
int note = 0; int note = 0;


+ 1
- 1
modules/juce_core/containers/juce_OwnedArray.h View File

@@ -411,7 +411,7 @@ public:
{ {
toDelete.reset (data.elements[indexToChange]); toDelete.reset (data.elements[indexToChange]);
if (toDelete == newObject)
if (toDelete.get() == newObject)
toDelete.release(); toDelete.release();
} }


+ 7
- 7
modules/juce_core/javascript/juce_Javascript.cpp View File

@@ -389,7 +389,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
struct DotOperator : public Expression struct DotOperator : public Expression
{ {
DotOperator (const CodeLocation& l, ExpPtr& p, const Identifier& c) noexcept : Expression (l), parent (p), child (c) {}
DotOperator (const CodeLocation& l, ExpPtr& p, const Identifier& c) noexcept : Expression (l), parent (p.release()), child (c) {}
var getResult (const Scope& s) const override var getResult (const Scope& s) const override
{ {
@@ -478,7 +478,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
struct BinaryOperatorBase : public Expression struct BinaryOperatorBase : public Expression
{ {
BinaryOperatorBase (const CodeLocation& l, ExpPtr& a, ExpPtr& b, TokenType op) noexcept BinaryOperatorBase (const CodeLocation& l, ExpPtr& a, ExpPtr& b, TokenType op) noexcept
: Expression (l), lhs (a), rhs (b), operation (op) {}
: Expression (l), lhs (a.release()), rhs (b.release()), operation (op) {}
ExpPtr lhs, rhs; ExpPtr lhs, rhs;
TokenType operation; TokenType operation;
@@ -674,7 +674,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
struct Assignment : public Expression struct Assignment : public Expression
{ {
Assignment (const CodeLocation& l, ExpPtr& dest, ExpPtr& source) noexcept : Expression (l), target (dest), newValue (source) {}
Assignment (const CodeLocation& l, ExpPtr& dest, ExpPtr& source) noexcept : Expression (l), target (dest.release()), newValue (source.release()) {}
var getResult (const Scope& s) const override var getResult (const Scope& s) const override
{ {
@@ -1080,7 +1080,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
} }
match (TokenTypes::closeParen); match (TokenTypes::closeParen);
fo.body = parseBlock();
fo.body.reset (parseBlock());
} }
Expression* parseExpression() Expression* parseExpression()
@@ -1270,7 +1270,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
Expression* parseFunctionCall (FunctionCall* call, ExpPtr& function) Expression* parseFunctionCall (FunctionCall* call, ExpPtr& function)
{ {
ScopedPointer<FunctionCall> s (call); ScopedPointer<FunctionCall> s (call);
s->object = function;
s->object.reset (function.release());
match (TokenTypes::openParen); match (TokenTypes::openParen);
while (currentType != TokenTypes::closeParen) while (currentType != TokenTypes::closeParen)
@@ -1296,7 +1296,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
if (matchIf (TokenTypes::openBracket)) if (matchIf (TokenTypes::openBracket))
{ {
ScopedPointer<ArraySubscript> s (new ArraySubscript (location)); ScopedPointer<ArraySubscript> s (new ArraySubscript (location));
s->object = input;
s->object.reset (input.release());
s->index.reset (parseExpression()); s->index.reset (parseExpression());
match (TokenTypes::closeBracket); match (TokenTypes::closeBracket);
return parseSuffixes (s.release()); return parseSuffixes (s.release());
@@ -1505,7 +1505,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
Expression* parseTernaryOperator (ExpPtr& condition) Expression* parseTernaryOperator (ExpPtr& condition)
{ {
ScopedPointer<ConditionalOp> e (new ConditionalOp (location)); ScopedPointer<ConditionalOp> e (new ConditionalOp (location));
e->condition = condition;
e->condition.reset (condition.release());
e->trueBranch.reset (parseExpression()); e->trueBranch.reset (parseExpression());
match (TokenTypes::colon); match (TokenTypes::colon);
e->falseBranch.reset (parseExpression()); e->falseBranch.reset (parseExpression());


+ 6
- 6
modules/juce_core/maths/juce_Expression.cpp View File

@@ -1023,22 +1023,22 @@ Expression Expression::adjustedToGiveNewResult (const double targetValue, const
{ {
ScopedPointer<Term> newTerm (term->clone()); ScopedPointer<Term> newTerm (term->clone());
Helpers::Constant* termToAdjust = Helpers::findTermToAdjust (newTerm, true);
Helpers::Constant* termToAdjust = Helpers::findTermToAdjust (newTerm.get(), true);
if (termToAdjust == nullptr) if (termToAdjust == nullptr)
termToAdjust = Helpers::findTermToAdjust (newTerm, false);
termToAdjust = Helpers::findTermToAdjust (newTerm.get(), false);
if (termToAdjust == nullptr) if (termToAdjust == nullptr)
{ {
newTerm = new Helpers::Add (newTerm.release(), new Helpers::Constant (0, false));
termToAdjust = Helpers::findTermToAdjust (newTerm, false);
newTerm.reset (new Helpers::Add (newTerm.release(), new Helpers::Constant (0, false)));
termToAdjust = Helpers::findTermToAdjust (newTerm.get(), false);
} }
jassert (termToAdjust != nullptr); jassert (termToAdjust != nullptr);
if (const Term* parent = Helpers::findDestinationFor (newTerm, termToAdjust))
if (const Term* parent = Helpers::findDestinationFor (newTerm.get(), termToAdjust))
{ {
if (const Helpers::TermPtr reverseTerm = parent->createTermToEvaluateInput (scope, termToAdjust, targetValue, newTerm))
if (Helpers::TermPtr reverseTerm = parent->createTermToEvaluateInput (scope, termToAdjust, targetValue, newTerm.get()))
termToAdjust->value = Expression (reverseTerm).evaluate (scope); termToAdjust->value = Expression (reverseTerm).evaluate (scope);
else else
return Expression (targetValue); return Expression (targetValue);


+ 1
- 1
modules/juce_core/misc/juce_StdFunctionCompat.cpp View File

@@ -66,7 +66,7 @@ namespace FunctionTestsHelpers
FunctionObject (const FunctionObject& other) FunctionObject (const FunctionObject& other)
{ {
bigData = new BigData (*other.bigData);
bigData.reset (new BigData (*other.bigData));
} }
int operator()(int i) const { return bigData->sum() + i; } int operator()(int i) const { return bigData->sum() + i; }


+ 1
- 1
modules/juce_core/native/juce_mac_Network.mm View File

@@ -1118,7 +1118,7 @@ private:
[req addValue: juceStringToNS (value) forHTTPHeaderField: juceStringToNS (key)]; [req addValue: juceStringToNS (value) forHTTPHeaderField: juceStringToNS (key)];
} }
connection = new URLConnectionState (req, numRedirectsToFollow);
connection.reset (new URLConnectionState (req, numRedirectsToFollow));
} }
} }


+ 1
- 1
modules/juce_core/native/juce_posix_SharedCode.h View File

@@ -1257,7 +1257,7 @@ bool ChildProcess::start (const StringArray& args, int streamFlags)
if (args.size() == 0) if (args.size() == 0)
return false; return false;
activeProcess = new ActiveProcess (args, streamFlags);
activeProcess.reset (new ActiveProcess (args, streamFlags));
if (activeProcess->childPID == 0) if (activeProcess->childPID == 0)
activeProcess.reset(); activeProcess.reset();


+ 8
- 7
modules/juce_core/network/juce_URL.cpp View File

@@ -118,9 +118,11 @@ URL::DownloadTask* URL::DownloadTask::createFallbackDownloader (const URL& urlTo
const size_t bufferSize = 0x8000; const size_t bufferSize = 0x8000;
targetFileToUse.deleteFile(); targetFileToUse.deleteFile();
if (ScopedPointer<FileOutputStream> outputStream = targetFileToUse.createOutputStream (bufferSize))
ScopedPointer<FileOutputStream> outputStream (targetFileToUse.createOutputStream (bufferSize));
if (outputStream != nullptr)
{ {
ScopedPointer<WebInputStream> stream = new WebInputStream (urlToUse, usePostRequest);
ScopedPointer<WebInputStream> stream (new WebInputStream (urlToUse, usePostRequest));
stream->withExtraHeaders (extraHeadersToUse); stream->withExtraHeaders (extraHeadersToUse);
if (stream->connect (nullptr)) if (stream->connect (nullptr))
@@ -650,10 +652,9 @@ InputStream* URL::createInputStream (const bool usePostCommand,
ScopedPointer<WebInputStream> wi (new WebInputStream (*this, usePostCommand)); ScopedPointer<WebInputStream> wi (new WebInputStream (*this, usePostCommand));
struct ProgressCallbackCaller : WebInputStream::Listener
struct ProgressCallbackCaller : public WebInputStream::Listener
{ {
ProgressCallbackCaller (OpenStreamProgressCallback* const progressCallbackToUse,
void* const progressCallbackContextToUse)
ProgressCallbackCaller (OpenStreamProgressCallback* progressCallbackToUse, void* progressCallbackContextToUse)
: callback (progressCallbackToUse), data (progressCallbackContextToUse) : callback (progressCallbackToUse), data (progressCallbackContextToUse)
{} {}
@@ -670,7 +671,7 @@ InputStream* URL::createInputStream (const bool usePostCommand,
ProgressCallbackCaller& operator= (const ProgressCallbackCaller&) { jassertfalse; return *this; } ProgressCallbackCaller& operator= (const ProgressCallbackCaller&) { jassertfalse; return *this; }
}; };
ScopedPointer<ProgressCallbackCaller> callbackCaller =
ScopedPointer<ProgressCallbackCaller> callbackCaller
(progressCallback != nullptr ? new ProgressCallbackCaller (progressCallback, progressCallbackContext) : nullptr); (progressCallback != nullptr ? new ProgressCallbackCaller (progressCallback, progressCallbackContext) : nullptr);
if (headers.isNotEmpty()) if (headers.isNotEmpty())
@@ -684,7 +685,7 @@ InputStream* URL::createInputStream (const bool usePostCommand,
wi->withNumRedirectsToFollow (numRedirectsToFollow); wi->withNumRedirectsToFollow (numRedirectsToFollow);
bool success = wi->connect (callbackCaller);
bool success = wi->connect (callbackCaller.get());
if (statusCode != nullptr) if (statusCode != nullptr)
*statusCode = wi->getStatusCode(); *statusCode = wi->getStatusCode();


+ 4
- 4
modules/juce_core/text/juce_LocalisedStrings.cpp View File

@@ -44,7 +44,7 @@ LocalisedStrings& LocalisedStrings::operator= (const LocalisedStrings& other)
languageName = other.languageName; languageName = other.languageName;
countryCodes = other.countryCodes; countryCodes = other.countryCodes;
translations = other.translations; translations = other.translations;
fallback = createCopyIfNotNull (other.fallback.get());
fallback.reset (createCopyIfNotNull (other.fallback.get()));
return *this; return *this;
} }
@@ -171,19 +171,19 @@ void LocalisedStrings::addStrings (const LocalisedStrings& other)
void LocalisedStrings::setFallback (LocalisedStrings* f) void LocalisedStrings::setFallback (LocalisedStrings* f)
{ {
fallback = f;
fallback.reset (f);
} }
//============================================================================== //==============================================================================
void LocalisedStrings::setCurrentMappings (LocalisedStrings* newTranslations) void LocalisedStrings::setCurrentMappings (LocalisedStrings* newTranslations)
{ {
const SpinLock::ScopedLockType sl (currentMappingsLock); const SpinLock::ScopedLockType sl (currentMappingsLock);
currentMappings = newTranslations;
currentMappings.reset (newTranslations);
} }
LocalisedStrings* LocalisedStrings::getCurrentMappings() LocalisedStrings* LocalisedStrings::getCurrentMappings()
{ {
return currentMappings;
return currentMappings.get();
} }
String LocalisedStrings::translateWithCurrentMappings (const String& text) { return juce::translate (text); } String LocalisedStrings::translateWithCurrentMappings (const String& text) { return juce::translate (text); }


+ 13
- 7
modules/juce_core/xml/juce_XmlDocument.cpp View File

@@ -40,25 +40,25 @@ XmlElement* XmlDocument::parse (const String& xmlData)
return doc.getDocumentElement(); return doc.getDocumentElement();
} }
void XmlDocument::setInputSource (InputSource* const newSource) noexcept
void XmlDocument::setInputSource (InputSource* newSource) noexcept
{ {
inputSource = newSource;
inputSource.reset (newSource);
} }
void XmlDocument::setEmptyTextElementsIgnored (const bool shouldBeIgnored) noexcept
void XmlDocument::setEmptyTextElementsIgnored (bool shouldBeIgnored) noexcept
{ {
ignoreEmptyTextElements = shouldBeIgnored; ignoreEmptyTextElements = shouldBeIgnored;
} }
namespace XmlIdentifierChars namespace XmlIdentifierChars
{ {
static bool isIdentifierCharSlow (const juce_wchar c) noexcept
static bool isIdentifierCharSlow (juce_wchar c) noexcept
{ {
return CharacterFunctions::isLetterOrDigit (c) return CharacterFunctions::isLetterOrDigit (c)
|| c == '_' || c == '-' || c == ':' || c == '.'; || c == '_' || c == '-' || c == ':' || c == '.';
} }
static bool isIdentifierChar (const juce_wchar c) noexcept
static bool isIdentifierChar (juce_wchar c) noexcept
{ {
static const uint32 legalChars[] = { 0, 0x7ff6000, 0x87fffffe, 0x7fffffe, 0 }; static const uint32 legalChars[] = { 0, 0x7ff6000, 0x87fffffe, 0x7fffffe, 0 };
@@ -93,7 +93,9 @@ XmlElement* XmlDocument::getDocumentElement (const bool onlyReadOuterDocumentEle
{ {
if (originalText.isEmpty() && inputSource != nullptr) if (originalText.isEmpty() && inputSource != nullptr)
{ {
if (ScopedPointer<InputStream> in = inputSource->createInputStream())
ScopedPointer<InputStream> in (inputSource->createInputStream());
if (in != nullptr)
{ {
MemoryOutputStream data; MemoryOutputStream data;
data.writeFromInputStream (*in, onlyReadOuterDocumentElement ? 8192 : -1); data.writeFromInputStream (*in, onlyReadOuterDocumentElement ? 8192 : -1);
@@ -141,8 +143,12 @@ void XmlDocument::setLastError (const String& desc, const bool carryOn)
String XmlDocument::getFileContents (const String& filename) const String XmlDocument::getFileContents (const String& filename) const
{ {
if (inputSource != nullptr) if (inputSource != nullptr)
if (ScopedPointer<InputStream> in = inputSource->createInputStreamFor (filename.trim().unquoted()))
{
ScopedPointer<InputStream> in (inputSource->createInputStreamFor (filename.trim().unquoted()));
if (in != nullptr)
return in->readEntireStreamAsString(); return in->readEntireStreamAsString();
}
return {}; return {};
} }


+ 1
- 1
modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp View File

@@ -286,7 +286,7 @@ bool GZIPDecompressorInputStream::setPosition (int64 newPos)
isEof = false; isEof = false;
activeBufferSize = 0; activeBufferSize = 0;
currentPos = 0; currentPos = 0;
helper = new GZIPDecompressHelper (format);
helper.reset (new GZIPDecompressHelper (format));
sourceStream->setPosition (originalSourcePos); sourceStream->setPosition (originalSourcePos);
} }


+ 5
- 4
modules/juce_core/zip/juce_ZipFile.cpp View File

@@ -128,7 +128,8 @@ struct ZipFile::ZipInputStream : public InputStream
{ {
if (zf.inputSource != nullptr) if (zf.inputSource != nullptr)
{ {
inputStream = streamToDelete = file.inputSource->createInputStream();
streamToDelete.reset (file.inputSource->createInputStream());
inputStream = streamToDelete.get();
} }
else else
{ {
@@ -223,7 +224,7 @@ ZipFile::ZipFile (InputStream* stream, bool deleteStreamWhenDestroyed)
: inputStream (stream) : inputStream (stream)
{ {
if (deleteStreamWhenDestroyed) if (deleteStreamWhenDestroyed)
streamToDelete = inputStream;
streamToDelete.reset (inputStream);
init(); init();
} }
@@ -339,7 +340,7 @@ void ZipFile::init()
if (inputSource != nullptr) if (inputSource != nullptr)
{ {
in = inputSource->createInputStream(); in = inputSource->createInputStream();
toDelete = in;
toDelete.reset (in);
} }
if (in != nullptr) if (in != nullptr)
@@ -516,7 +517,7 @@ private:
{ {
if (stream == nullptr) if (stream == nullptr)
{ {
stream = file.createInputStream();
stream.reset (file.createInputStream());
if (stream == nullptr) if (stream == nullptr)
return false; return false;


+ 4
- 2
modules/juce_data_structures/values/juce_ValueTree.cpp View File

@@ -982,7 +982,9 @@ ValueTree ValueTree::fromXml (const XmlElement& xml)
String ValueTree::toXmlString() const String ValueTree::toXmlString() const
{ {
if (ScopedPointer<XmlElement> xml = createXml())
ScopedPointer<XmlElement> xml (createXml());
if (xml != nullptr)
return xml->createDocument ({}); return xml->createDocument ({});
return {}; return {};
@@ -1142,7 +1144,7 @@ public:
ScopedPointer<XmlElement> xml1 (v1.createXml()); ScopedPointer<XmlElement> xml1 (v1.createXml());
ScopedPointer<XmlElement> xml2 (v2.createCopy().createXml()); ScopedPointer<XmlElement> xml2 (v2.createCopy().createXml());
expect (xml1->isEquivalentTo (xml2, false));
expect (xml1->isEquivalentTo (xml2.get(), false));
auto v4 = v2.createCopy(); auto v4 = v2.createCopy();
expect (v1.isEquivalentTo (v4)); expect (v1.isEquivalentTo (v4));


+ 2
- 2
modules/juce_graphics/colour/juce_FillType.cpp View File

@@ -54,7 +54,7 @@ FillType::FillType (const Image& im, const AffineTransform& t) noexcept
FillType::FillType (const FillType& other) FillType::FillType (const FillType& other)
: colour (other.colour), : colour (other.colour),
gradient (other.gradient.createCopy()),
gradient (createCopyIfNotNull (other.gradient.get())),
image (other.image), image (other.image),
transform (other.transform) transform (other.transform)
{ {
@@ -65,7 +65,7 @@ FillType& FillType::operator= (const FillType& other)
if (this != &other) if (this != &other)
{ {
colour = other.colour; colour = other.colour;
gradient.reset (other.gradient.createCopy());
gradient.reset (createCopyIfNotNull (other.gradient.get()));
image = other.image; image = other.image;
transform = other.transform; transform = other.transform;
} }


+ 3
- 3
modules/juce_graphics/native/juce_RenderingHelpers.h View File

@@ -2661,10 +2661,10 @@ public:
void initialise (StateObjectType* state) void initialise (StateObjectType* state)
{ {
currentState = state;
currentState.reset (state);
} }
inline StateObjectType* operator->() const noexcept { return currentState; }
inline StateObjectType* operator->() const noexcept { return currentState.get(); }
inline StateObjectType& operator*() const noexcept { return *currentState; } inline StateObjectType& operator*() const noexcept { return *currentState; }
void save() void save()
@@ -2693,7 +2693,7 @@ public:
void endTransparencyLayer() void endTransparencyLayer()
{ {
const ScopedPointer<StateObjectType> finishedTransparencyLayer (currentState);
ScopedPointer<StateObjectType> finishedTransparencyLayer (currentState.release());
restore(); restore();
currentState->endTransparencyLayer (*finishedTransparencyLayer); currentState->endTransparencyLayer (*finishedTransparencyLayer);
} }


+ 7
- 7
modules/juce_gui_basics/buttons/juce_Button.cpp View File

@@ -79,7 +79,7 @@ Button::Button (const String& name) : Component (name), text (name)
callbackHelper.reset (new CallbackHelper (*this)); callbackHelper.reset (new CallbackHelper (*this));
setWantsKeyboardFocus (true); setWantsKeyboardFocus (true);
isOn.addListener (callbackHelper);
isOn.addListener (callbackHelper.get());
} }
Button::~Button() Button::~Button()
@@ -87,9 +87,9 @@ Button::~Button()
clearShortcuts(); clearShortcuts();
if (commandManagerToUse != nullptr) if (commandManagerToUse != nullptr)
commandManagerToUse->removeListener (callbackHelper);
commandManagerToUse->removeListener (callbackHelper.get());
isOn.removeListener (callbackHelper);
isOn.removeListener (callbackHelper.get());
callbackHelper.reset(); callbackHelper.reset();
} }
@@ -509,12 +509,12 @@ void Button::parentHierarchyChanged()
if (newKeySource != keySource.get()) if (newKeySource != keySource.get())
{ {
if (keySource != nullptr) if (keySource != nullptr)
keySource->removeKeyListener (callbackHelper);
keySource->removeKeyListener (callbackHelper.get());
keySource = newKeySource; keySource = newKeySource;
if (keySource != nullptr) if (keySource != nullptr)
keySource->addKeyListener (callbackHelper);
keySource->addKeyListener (callbackHelper.get());
} }
} }
@@ -528,12 +528,12 @@ void Button::setCommandToTrigger (ApplicationCommandManager* const newCommandMan
if (commandManagerToUse != newCommandManager) if (commandManagerToUse != newCommandManager)
{ {
if (commandManagerToUse != nullptr) if (commandManagerToUse != nullptr)
commandManagerToUse->removeListener (callbackHelper);
commandManagerToUse->removeListener (callbackHelper.get());
commandManagerToUse = newCommandManager; commandManagerToUse = newCommandManager;
if (commandManagerToUse != nullptr) if (commandManagerToUse != nullptr)
commandManagerToUse->addListener (callbackHelper);
commandManagerToUse->addListener (callbackHelper.get());
// if you've got clickTogglesState turned on, you shouldn't also connect the button // if you've got clickTogglesState turned on, you shouldn't also connect the button
// up to be a command invoker. Instead, your command handler must flip the state of whatever // up to be a command invoker. Instead, your command handler must flip the state of whatever


+ 7
- 7
modules/juce_gui_basics/buttons/juce_DrawableButton.cpp View File

@@ -137,8 +137,8 @@ void DrawableButton::buttonStateChanged()
} }
else else
{ {
imageToDraw = getToggleState() ? disabledImageOn
: disabledImage;
imageToDraw = getToggleState() ? disabledImageOn.get()
: disabledImage.get();
if (imageToDraw == nullptr) if (imageToDraw == nullptr)
{ {
@@ -201,19 +201,19 @@ Drawable* DrawableButton::getCurrentImage() const noexcept
Drawable* DrawableButton::getNormalImage() const noexcept Drawable* DrawableButton::getNormalImage() const noexcept
{ {
return (getToggleState() && normalImageOn != nullptr) ? normalImageOn
: normalImage;
return (getToggleState() && normalImageOn != nullptr) ? normalImageOn.get()
: normalImage.get();
} }
Drawable* DrawableButton::getOverImage() const noexcept Drawable* DrawableButton::getOverImage() const noexcept
{ {
if (getToggleState()) if (getToggleState())
{ {
if (overImageOn != nullptr) return overImageOn;
if (normalImageOn != nullptr) return normalImageOn;
if (overImageOn != nullptr) return overImageOn.get();
if (normalImageOn != nullptr) return normalImageOn.get();
} }
return overImage != nullptr ? overImage : normalImage;
return overImage != nullptr ? overImage.get() : normalImage.get();
} }
Drawable* DrawableButton::getDownImage() const noexcept Drawable* DrawableButton::getDownImage() const noexcept


+ 2
- 2
modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp View File

@@ -101,9 +101,9 @@ Drawable* ToolbarButton::getImageToUse() const
return nullptr; return nullptr;
if (getToggleState() && toggledOnImage != nullptr) if (getToggleState() && toggledOnImage != nullptr)
return toggledOnImage;
return toggledOnImage.get();
return normalImage;
return normalImage.get();
} }
void ToolbarButton::buttonStateChanged() void ToolbarButton::buttonStateChanged()


+ 6
- 5
modules/juce_gui_basics/components/juce_Component.cpp View File

@@ -830,7 +830,7 @@ private:
void Component::setCachedComponentImage (CachedComponentImage* newCachedImage) void Component::setCachedComponentImage (CachedComponentImage* newCachedImage)
{ {
if (cachedImage != newCachedImage)
if (cachedImage.get() != newCachedImage)
{ {
cachedImage.reset (newCachedImage); cachedImage.reset (newCachedImage);
repaint(); repaint();
@@ -2140,14 +2140,13 @@ void Component::copyAllExplicitColoursTo (Component& target) const
} }
//============================================================================== //==============================================================================
Component::Positioner::Positioner (Component& c) noexcept
: component (c)
Component::Positioner::Positioner (Component& c) noexcept : component (c)
{ {
} }
Component::Positioner* Component::getPositioner() const noexcept Component::Positioner* Component::getPositioner() const noexcept
{ {
return positioner;
return positioner.get();
} }
void Component::setPositioner (Positioner* newPositioner) void Component::setPositioner (Positioner* newPositioner)
@@ -2775,7 +2774,9 @@ void Component::moveKeyboardFocusToSibling (bool moveToNext)
if (parentComponent != nullptr) if (parentComponent != nullptr)
{ {
if (ScopedPointer<KeyboardFocusTraverser> traverser = createFocusTraverser())
ScopedPointer<KeyboardFocusTraverser> traverser (createFocusTraverser());
if (traverser != nullptr)
{ {
auto* nextComp = moveToNext ? traverser->getNextComponent (this) auto* nextComp = moveToNext ? traverser->getNextComponent (this)
: traverser->getPreviousComponent (this); : traverser->getPreviousComponent (this);


+ 1
- 1
modules/juce_gui_basics/components/juce_Desktop.cpp View File

@@ -96,7 +96,7 @@ LookAndFeel& Desktop::getDefaultLookAndFeel() noexcept
if (defaultLookAndFeel == nullptr) if (defaultLookAndFeel == nullptr)
defaultLookAndFeel.reset (new LookAndFeel_V4()); defaultLookAndFeel.reset (new LookAndFeel_V4());
currentLookAndFeel = defaultLookAndFeel;
currentLookAndFeel = defaultLookAndFeel.get();
} }
return *currentLookAndFeel; return *currentLookAndFeel;


+ 2
- 2
modules/juce_gui_basics/components/juce_Desktop.h View File

@@ -373,13 +373,13 @@ public:
#ifndef DOXYGEN #ifndef DOXYGEN
/** @internal */ /** @internal */
void refresh(); void refresh();
/** @internal */
~Displays();
#endif #endif
private: private:
friend class Desktop; friend class Desktop;
friend struct ContainerDeletePolicy<Displays>;
Displays (Desktop&); Displays (Desktop&);
~Displays();
void init (Desktop&); void init (Desktop&);
void findDisplays (float masterScale); void findDisplays (float masterScale);


+ 1
- 1
modules/juce_gui_basics/drawables/juce_Drawable.cpp View File

@@ -109,7 +109,7 @@ DrawableComposite* Drawable::getParent() const
void Drawable::setClipPath (Drawable* clipPath) void Drawable::setClipPath (Drawable* clipPath)
{ {
if (drawableClipPath != clipPath)
if (drawableClipPath.get() != clipPath)
{ {
drawableClipPath.reset (clipPath); drawableClipPath.reset (clipPath);
repaint(); repaint();


+ 2
- 2
modules/juce_gui_basics/drawables/juce_SVGParser.cpp View File

@@ -1711,8 +1711,8 @@ Drawable* Drawable::createFromSVGFile (const File& svgFile)
if (svgDocument != nullptr) if (svgDocument != nullptr)
{ {
SVGState state (svgDocument, svgFile);
return state.parseSVGElement (SVGState::XmlPath (svgDocument, nullptr));
SVGState state (svgDocument.get(), svgFile);
return state.parseSVGElement (SVGState::XmlPath (svgDocument.get(), nullptr));
} }
} }


+ 3
- 3
modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp View File

@@ -334,15 +334,15 @@ FilePreviewComponent* FileBrowserComponent::getPreviewComponent() const noexcept
DirectoryContentsDisplayComponent* FileBrowserComponent::getDisplayComponent() const noexcept DirectoryContentsDisplayComponent* FileBrowserComponent::getDisplayComponent() const noexcept
{ {
return fileListComponent;
return fileListComponent.get();
} }
//============================================================================== //==============================================================================
void FileBrowserComponent::resized() void FileBrowserComponent::resized()
{ {
getLookAndFeel() getLookAndFeel()
.layoutFileBrowserComponent (*this, fileListComponent, previewComp,
&currentPathBox, &filenameBox, goUpButton);
.layoutFileBrowserComponent (*this, fileListComponent.get(), previewComp,
&currentPathBox, &filenameBox, goUpButton.get());
} }
//============================================================================== //==============================================================================


+ 1
- 1
modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp View File

@@ -68,7 +68,7 @@ void FilenameComponent::paintOverChildren (Graphics& g)
void FilenameComponent::resized() void FilenameComponent::resized()
{ {
getLookAndFeel().layoutFilenameComponent (*this, &filenameBox, browseButton);
getLookAndFeel().layoutFilenameComponent (*this, &filenameBox, browseButton.get());
} }
KeyboardFocusTraverser* FilenameComponent::createFocusTraverser() KeyboardFocusTraverser* FilenameComponent::createFocusTraverser()


+ 2
- 2
modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp View File

@@ -68,8 +68,8 @@ public:
bool useTimeslice (const int elapsed) bool useTimeslice (const int elapsed)
{ {
if (auto* c = proxy != nullptr ? static_cast<Component*> (proxy)
: static_cast<Component*> (component))
if (auto* c = proxy != nullptr ? proxy.get()
: component.get())
{ {
msElapsed += elapsed; msElapsed += elapsed;
double newProgress = msElapsed / (double) msTotal; double newProgress = msElapsed / (double) msTotal;


+ 3
- 3
modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp View File

@@ -114,7 +114,7 @@ ComponentBuilder::~ComponentBuilder()
#if JUCE_DEBUG #if JUCE_DEBUG
// Don't delete the managed component!! The builder owns that component, and will delete // Don't delete the managed component!! The builder owns that component, and will delete
// it automatically when it gets deleted. // it automatically when it gets deleted.
jassert (componentRef.get() == static_cast<Component*> (component));
jassert (componentRef.get() == component.get());
#endif #endif
} }
@@ -125,11 +125,11 @@ Component* ComponentBuilder::getManagedComponent()
component.reset (createComponent()); component.reset (createComponent());
#if JUCE_DEBUG #if JUCE_DEBUG
componentRef = component;
componentRef = component.get();
#endif #endif
} }
return component;
return component.get();
} }
Component* ComponentBuilder::createComponent() Component* ComponentBuilder::createComponent()


+ 7
- 6
modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp View File

@@ -152,7 +152,7 @@ void TabBarButton::setExtraComponent (Component* comp, ExtraComponentPlacement p
void TabBarButton::childBoundsChanged (Component* c) void TabBarButton::childBoundsChanged (Component* c)
{ {
if (c == extraComponent)
if (c == extraComponent.get())
{ {
owner.resized(); owner.resized();
resized(); resized();
@@ -263,7 +263,7 @@ void TabbedButtonBar::addTab (const String& tabName,
tabs.insert (insertIndex, newTab); tabs.insert (insertIndex, newTab);
currentTabIndex = tabs.indexOf (currentTab); currentTabIndex = tabs.indexOf (currentTab);
addAndMakeVisible (newTab->button, insertIndex);
addAndMakeVisible (newTab->button.get(), insertIndex);
resized(); resized();
@@ -358,7 +358,7 @@ void TabbedButtonBar::setCurrentTabIndex (int newIndex, bool shouldSendChangeMes
TabBarButton* TabbedButtonBar::getTabButton (const int index) const TabBarButton* TabbedButtonBar::getTabButton (const int index) const
{ {
if (auto* tab = tabs[index]) if (auto* tab = tabs[index])
return static_cast<TabBarButton*> (tab->button);
return static_cast<TabBarButton*> (tab->button.get());
return nullptr; return nullptr;
} }
@@ -366,7 +366,7 @@ TabBarButton* TabbedButtonBar::getTabButton (const int index) const
int TabbedButtonBar::indexOfTabButton (const TabBarButton* button) const int TabbedButtonBar::indexOfTabButton (const TabBarButton* button) const
{ {
for (int i = tabs.size(); --i >= 0;) for (int i = tabs.size(); --i >= 0;)
if (tabs.getUnchecked(i)->button == button)
if (tabs.getUnchecked(i)->button.get() == button)
return i; return i;
return -1; return -1;
@@ -435,7 +435,8 @@ void TabbedButtonBar::updateTabPositions (bool animate)
{ {
if (extraTabsButton == nullptr) if (extraTabsButton == nullptr)
{ {
addAndMakeVisible (extraTabsButton = lf.createTabBarExtrasButton());
extraTabsButton.reset (lf.createTabBarExtrasButton());
addAndMakeVisible (extraTabsButton.get());
extraTabsButton->setAlwaysOnTop (true); extraTabsButton->setAlwaysOnTop (true);
extraTabsButton->setTriggeredOnMouseDown (true); extraTabsButton->setTriggeredOnMouseDown (true);
extraTabsButton->onClick = [this] { showExtraItemsMenu(); }; extraTabsButton->onClick = [this] { showExtraItemsMenu(); };
@@ -569,7 +570,7 @@ void TabbedButtonBar::showExtraItemsMenu()
m.addItem (i + 1, tab->name, true, i == currentTabIndex); m.addItem (i + 1, tab->name, true, i == currentTabIndex);
} }
m.showMenuAsync (PopupMenu::Options().withTargetComponent (extraTabsButton),
m.showMenuAsync (PopupMenu::Options().withTargetComponent (extraTabsButton.get()),
ModalCallbackFunction::forComponent (extraItemsMenuCallback, this)); ModalCallbackFunction::forComponent (extraItemsMenuCallback, this));
} }


+ 4
- 4
modules/juce_gui_basics/layout/juce_Viewport.cpp View File

@@ -291,7 +291,7 @@ void Viewport::setScrollOnDragEnabled (bool shouldScrollOnDrag)
if (isScrollOnDragEnabled() != shouldScrollOnDrag) if (isScrollOnDragEnabled() != shouldScrollOnDrag)
{ {
if (shouldScrollOnDrag) if (shouldScrollOnDrag)
dragToScrollListener = new DragToScrollListener (*this);
dragToScrollListener.reset (new DragToScrollListener (*this));
else else
dragToScrollListener.reset(); dragToScrollListener.reset();
} }
@@ -490,13 +490,13 @@ int Viewport::getScrollBarThickness() const
void Viewport::scrollBarMoved (ScrollBar* scrollBarThatHasMoved, double newRangeStart) void Viewport::scrollBarMoved (ScrollBar* scrollBarThatHasMoved, double newRangeStart)
{ {
const int newRangeStartInt = roundToInt (newRangeStart);
auto newRangeStartInt = roundToInt (newRangeStart);
if (scrollBarThatHasMoved == horizontalScrollBar)
if (scrollBarThatHasMoved == horizontalScrollBar.get())
{ {
setViewPosition (newRangeStartInt, getViewPositionY()); setViewPosition (newRangeStartInt, getViewPositionY());
} }
else if (scrollBarThatHasMoved == verticalScrollBar)
else if (scrollBarThatHasMoved == verticalScrollBar.get())
{ {
setViewPosition (getViewPositionX(), newRangeStartInt); setViewPosition (getViewPositionX(), newRangeStartInt);
} }


+ 7
- 7
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp View File

@@ -2623,7 +2623,7 @@ void LookAndFeel_V2::layoutFileBrowserComponent (FileBrowserComponent& browserCo
//============================================================================== //==============================================================================
static Drawable* createDrawableFromSVG (const char* data) static Drawable* createDrawableFromSVG (const char* data)
{ {
ScopedPointer<XmlElement> xml = XmlDocument::parse (data);
ScopedPointer<XmlElement> xml (XmlDocument::parse (data));
jassert (xml != nullptr); jassert (xml != nullptr);
return Drawable::createFromSVG (*xml); return Drawable::createFromSVG (*xml);
} }
@@ -2631,7 +2631,7 @@ static Drawable* createDrawableFromSVG (const char* data)
const Drawable* LookAndFeel_V2::getDefaultFolderImage() const Drawable* LookAndFeel_V2::getDefaultFolderImage()
{ {
if (folderImage == nullptr) if (folderImage == nullptr)
folderImage = createDrawableFromSVG (R"svgdata(
folderImage.reset (createDrawableFromSVG (R"svgdata(
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="706" height="532"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="706" height="532">
<defs> <defs>
<linearGradient id="a"> <linearGradient id="a">
@@ -2646,22 +2646,22 @@ const Drawable* LookAndFeel_V2::getDefaultFolderImage()
<path d="M608.6 136.8L235.2 208a22.7 22.7 0 0 0-16 19l-40.8 241c1.7 8.4 9.6 14.5 17.8 12.3l380-104c8-2.2 10.7-10.2 12.3-18.4l38-210.1c.4-15.4-10.4-11.8-18-11.1z" display="block" fill="url(#c)" opacity=".8" stroke="#446c98" stroke-width="7"/> <path d="M608.6 136.8L235.2 208a22.7 22.7 0 0 0-16 19l-40.8 241c1.7 8.4 9.6 14.5 17.8 12.3l380-104c8-2.2 10.7-10.2 12.3-18.4l38-210.1c.4-15.4-10.4-11.8-18-11.1z" display="block" fill="url(#c)" opacity=".8" stroke="#446c98" stroke-width="7"/>
</g> </g>
</svg> </svg>
)svgdata");
)svgdata"));
return folderImage;
return folderImage.get();
} }
const Drawable* LookAndFeel_V2::getDefaultDocumentFileImage() const Drawable* LookAndFeel_V2::getDefaultDocumentFileImage()
{ {
if (documentImage == nullptr) if (documentImage == nullptr)
documentImage = createDrawableFromSVG (R"svgdata(
documentImage.reset (createDrawableFromSVG (R"svgdata(
<svg version="1" viewBox="-10 -10 450 600" xmlns="http://www.w3.org/2000/svg"> <svg version="1" viewBox="-10 -10 450 600" xmlns="http://www.w3.org/2000/svg">
<path d="M17 0h290l120 132v426c0 10-8 19-17 19H17c-9 0-17-9-17-19V19C0 8 8 0 17 0z" fill="#e5e5e5" stroke="#888888" stroke-width="7"/> <path d="M17 0h290l120 132v426c0 10-8 19-17 19H17c-9 0-17-9-17-19V19C0 8 8 0 17 0z" fill="#e5e5e5" stroke="#888888" stroke-width="7"/>
<path d="M427 132H324c-9 0-17-9-17-19V0l120 132z" fill="#ccc"/> <path d="M427 132H324c-9 0-17-9-17-19V0l120 132z" fill="#ccc"/>
</svg> </svg>
)svgdata");
)svgdata"));
return documentImage;
return documentImage.get();
} }
//============================================================================== //==============================================================================


+ 1
- 1
modules/juce_gui_basics/menus/juce_BurgerMenuComponent.cpp View File

@@ -181,7 +181,7 @@ void BurgerMenuComponent::paintListBoxItem (int rowIndex, Graphics& g, int w, in
hasSubMenu (item), hasSubMenu (item),
item.text, item.text,
item.shortcutKeyDescription, item.shortcutKeyDescription,
item.image,
item.image.get(),
colour); colour);
} }
} }


+ 3
- 3
modules/juce_gui_basics/menus/juce_PopupMenu.cpp View File

@@ -120,7 +120,7 @@ struct ItemComponent : public Component
hasSubMenu (item), hasSubMenu (item),
item.text, item.text,
item.shortcutKeyDescription, item.shortcutKeyDescription,
item.image,
item.image.get(),
getColour (item)); getColour (item));
} }
@@ -561,7 +561,7 @@ public:
if (mw == window) if (mw == window)
return true; return true;
mw = mw->activeSubMenu;
mw = mw->activeSubMenu.get();
} }
return false; return false;
@@ -1843,7 +1843,7 @@ bool PopupMenu::MenuItemIterator::next()
if (searchRecursively && currentItem->subMenu != nullptr) if (searchRecursively && currentItem->subMenu != nullptr)
{ {
index.add (0); index.add (0);
menus.add (currentItem->subMenu);
menus.add (currentItem->subMenu.get());
} }
else else
index.setUnchecked (index.size() - 1, index.getLast() + 1); index.setUnchecked (index.size() - 1, index.getLast() + 1);


+ 3
- 4
modules/juce_gui_basics/native/juce_mac_FileChooser.mm View File

@@ -78,7 +78,7 @@ public:
delegate = [cls.createInstance() init]; delegate = [cls.createInstance() init];
object_setInstanceVariable (delegate, "cppObject", this); object_setInstanceVariable (delegate, "cppObject", this);
[panel setDelegate:delegate];
[panel setDelegate: delegate];
filters.addTokens (owner.filters.replaceCharacters (",:", ";;"), ";", String()); filters.addTokens (owner.filters.replaceCharacters (",:", ";;"), ";", String());
filters.trim(); filters.trim();
@@ -150,10 +150,9 @@ public:
} }
[panel close]; [panel close];
[panel release];
} }
panel.reset();
if (delegate != nil) if (delegate != nil)
{ {
[delegate release]; [delegate release];
@@ -292,7 +291,7 @@ private:
NSView* nsViewPreview = nullptr; NSView* nsViewPreview = nullptr;
bool selectsDirectories, selectsFiles, isSave, selectMultiple; bool selectsDirectories, selectsFiles, isSave, selectMultiple;
ScopedPointer<NSSavePanel> panel;
NSSavePanel* panel;
DelegateType* delegate; DelegateType* delegate;
StringArray filters; StringArray filters;


+ 1
- 1
modules/juce_gui_basics/native/juce_mac_MainMenu.mm View File

@@ -612,7 +612,7 @@ public:
~TemporaryMainMenuWithStandardCommands() ~TemporaryMainMenuWithStandardCommands()
{ {
MenuBarModel::setMacMainMenu (oldMenu, oldAppleMenu, oldRecentItems);
MenuBarModel::setMacMainMenu (oldMenu, oldAppleMenu.get(), oldRecentItems);
} }
private: private:


+ 2
- 1
modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp View File

@@ -200,7 +200,8 @@ Value& TextPropertyComponent::getValue() const
void TextPropertyComponent::createEditor (int maxNumChars, bool isMultiLine, bool isEditable) void TextPropertyComponent::createEditor (int maxNumChars, bool isMultiLine, bool isEditable)
{ {
addAndMakeVisible (textEditor = new LabelComp (*this, maxNumChars, isMultiLine, isEditable));
textEditor.reset (new LabelComp (*this, maxNumChars, isMultiLine, isEditable));
addAndMakeVisible (textEditor.get());
if (isMultiLine) if (isMultiLine)
{ {


+ 2
- 2
modules/juce_gui_basics/widgets/juce_ComboBox.cpp View File

@@ -418,10 +418,10 @@ void ComboBox::lookAndFeelChanged()
newLabel->setText (label->getText(), dontSendNotification); newLabel->setText (label->getText(), dontSendNotification);
} }
label = newLabel;
std::swap (label, newLabel);
} }
addAndMakeVisible (label);
addAndMakeVisible (label.get());
EditableState newEditableState = (label->isEditable() ? labelIsEditable : labelIsNotEditable); EditableState newEditableState = (label->isEditable() ? labelIsEditable : labelIsNotEditable);


+ 8
- 7
modules/juce_gui_basics/widgets/juce_Label.cpp View File

@@ -221,7 +221,7 @@ void Label::showEditor()
resized(); resized();
repaint(); repaint();
editorShown (editor);
editorShown (editor.get());
enterModalState (false); enterModalState (false);
editor->grabKeyboardFocus(); editor->grabKeyboardFocus();
@@ -254,9 +254,10 @@ void Label::hideEditor (bool discardCurrentEditorContents)
if (editor != nullptr) if (editor != nullptr)
{ {
WeakReference<Component> deletionChecker (this); WeakReference<Component> deletionChecker (this);
ScopedPointer<TextEditor> outgoingEditor (editor);
ScopedPointer<TextEditor> outgoingEditor;
std::swap (outgoingEditor, editor);
editorAboutToBeHidden (outgoingEditor);
editorAboutToBeHidden (outgoingEditor.get());
const bool changed = (! discardCurrentEditorContents) const bool changed = (! discardCurrentEditorContents)
&& updateFromTextEditorContents (*outgoingEditor); && updateFromTextEditorContents (*outgoingEditor);
@@ -311,7 +312,7 @@ TextEditor* Label::createEditorComponent()
TextEditor* Label::getCurrentTextEditor() const noexcept TextEditor* Label::getCurrentTextEditor() const noexcept
{ {
return editor;
return editor.get();
} }
//============================================================================== //==============================================================================
@@ -410,7 +411,7 @@ void Label::textEditorTextChanged (TextEditor& ed)
{ {
if (editor != nullptr) if (editor != nullptr)
{ {
jassert (&ed == editor);
jassert (&ed == editor.get());
if (! (hasKeyboardFocus (true) || isCurrentlyBlockedByAnotherModalComponent())) if (! (hasKeyboardFocus (true) || isCurrentlyBlockedByAnotherModalComponent()))
{ {
@@ -426,7 +427,7 @@ void Label::textEditorReturnKeyPressed (TextEditor& ed)
{ {
if (editor != nullptr) if (editor != nullptr)
{ {
jassert (&ed == editor);
jassert (&ed == editor.get());
WeakReference<Component> deletionChecker (this); WeakReference<Component> deletionChecker (this);
bool changed = updateFromTextEditorContents (ed); bool changed = updateFromTextEditorContents (ed);
@@ -446,7 +447,7 @@ void Label::textEditorEscapeKeyPressed (TextEditor& ed)
{ {
if (editor != nullptr) if (editor != nullptr)
{ {
jassert (&ed == editor);
jassert (&ed == editor.get());
ignoreUnused (ed); ignoreUnused (ed);
editor->setText (textValue.toString(), false); editor->setText (textValue.toString(), false);


+ 7
- 8
modules/juce_gui_basics/widgets/juce_ListBox.cpp View File

@@ -52,11 +52,11 @@ public:
{ {
setMouseCursor (m->getMouseCursorForRow (row)); setMouseCursor (m->getMouseCursorForRow (row));
customComponent = m->refreshComponentForRow (newRow, nowSelected, customComponent.release());
customComponent.reset (m->refreshComponentForRow (newRow, nowSelected, customComponent.release()));
if (customComponent != nullptr) if (customComponent != nullptr)
{ {
addAndMakeVisible (customComponent);
addAndMakeVisible (customComponent.get());
customComponent->setBounds (getLocalBounds()); customComponent->setBounds (getLocalBounds());
} }
} }
@@ -452,7 +452,7 @@ void ListBox::visibilityChanged()
Viewport* ListBox::getViewport() const noexcept Viewport* ListBox::getViewport() const noexcept
{ {
return viewport;
return viewport.get();
} }
//============================================================================== //==============================================================================
@@ -655,7 +655,7 @@ int ListBox::getInsertionIndexForPosition (const int x, const int y) const noexc
Component* ListBox::getComponentForRowNumber (const int row) const noexcept Component* ListBox::getComponentForRowNumber (const int row) const noexcept
{ {
if (auto* listRowComp = viewport->getComponentForRowIfOnscreen (row)) if (auto* listRowComp = viewport->getComponentForRowIfOnscreen (row))
return listRowComp->customComponent;
return listRowComp->customComponent.get();
return nullptr; return nullptr;
} }
@@ -850,18 +850,17 @@ void ListBox::parentHierarchyChanged()
colourChanged(); colourChanged();
} }
void ListBox::setOutlineThickness (const int newThickness)
void ListBox::setOutlineThickness (int newThickness)
{ {
outlineThickness = newThickness; outlineThickness = newThickness;
resized(); resized();
} }
void ListBox::setHeaderComponent (Component* const newHeaderComponent)
void ListBox::setHeaderComponent (Component* newHeaderComponent)
{ {
if (headerComponent != newHeaderComponent)
if (headerComponent.get() != newHeaderComponent)
{ {
headerComponent.reset (newHeaderComponent); headerComponent.reset (newHeaderComponent);
addAndMakeVisible (newHeaderComponent); addAndMakeVisible (newHeaderComponent);
ListBox::resized(); ListBox::resized();
} }


+ 2
- 1
modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp View File

@@ -695,7 +695,8 @@ void TableHeaderComponent::beginDrag (const MouseEvent& e)
auto temp = columnIdBeingDragged; auto temp = columnIdBeingDragged;
columnIdBeingDragged = 0; columnIdBeingDragged = 0;
addAndMakeVisible (dragOverlayComp = new DragOverlayComp (createComponentSnapshot (columnRect, false)));
dragOverlayComp.reset (new DragOverlayComp (createComponentSnapshot (columnRect, false)));
addAndMakeVisible (dragOverlayComp.get());
columnIdBeingDragged = temp; columnIdBeingDragged = temp;
dragOverlayComp->setBounds (columnRect); dragOverlayComp->setBounds (columnRect);


+ 4
- 2
modules/juce_gui_basics/widgets/juce_TextEditor.cpp View File

@@ -880,7 +880,8 @@ TextEditor::TextEditor (const String& name, juce_wchar passwordChar)
{ {
setMouseCursor (MouseCursor::IBeamCursor); setMouseCursor (MouseCursor::IBeamCursor);
addAndMakeVisible (viewport = new TextEditorViewport (*this));
viewport.reset (new TextEditorViewport (*this));
addAndMakeVisible (viewport.get());
viewport->setViewedComponent (textHolder = new TextHolderComponent (*this)); viewport->setViewedComponent (textHolder = new TextHolderComponent (*this));
viewport->setWantsKeyboardFocus (false); viewport->setWantsKeyboardFocus (false);
viewport->setScrollBarsShown (false, false); viewport->setScrollBarsShown (false, false);
@@ -1082,7 +1083,8 @@ void TextEditor::recreateCaret()
{ {
if (caret == nullptr) if (caret == nullptr)
{ {
textHolder->addChildComponent (caret = getLookAndFeel().createCaretComponent (this));
caret.reset (getLookAndFeel().createCaretComponent (this));
textHolder->addChildComponent (caret.get());
updateCaretPosition(); updateCaretPosition();
} }
} }


+ 1
- 1
modules/juce_gui_basics/widgets/juce_Toolbar.cpp View File

@@ -543,7 +543,7 @@ void Toolbar::showMissingItems()
{ {
PopupMenu m; PopupMenu m;
m.addCustomItem (1, new MissingItemsComponent (*this, getThickness())); m.addCustomItem (1, new MissingItemsComponent (*this, getThickness()));
m.showMenuAsync (PopupMenu::Options().withTargetComponent (missingItemsButton), nullptr);
m.showMenuAsync (PopupMenu::Options().withTargetComponent (missingItemsButton.get()), nullptr);
} }
} }


+ 6
- 5
modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp View File

@@ -173,9 +173,9 @@ void ToolbarItemComponent::paintButton (Graphics& g, const bool over, const bool
if (toolbarStyle != Toolbar::iconsOnly) if (toolbarStyle != Toolbar::iconsOnly)
{ {
const int indent = contentArea.getX();
int y = indent;
int h = getHeight() - indent * 2;
auto indent = contentArea.getX();
auto y = indent;
auto h = getHeight() - indent * 2;
if (toolbarStyle == Toolbar::iconsWithText) if (toolbarStyle == Toolbar::iconsWithText)
{ {
@@ -212,7 +212,7 @@ void ToolbarItemComponent::resized()
} }
else else
{ {
contentArea = Rectangle<int>();
contentArea = {};
} }
contentAreaChanged (contentArea); contentAreaChanged (contentArea);
@@ -231,7 +231,8 @@ void ToolbarItemComponent::setEditingMode (const ToolbarEditingMode newMode)
} }
else if (overlayComp == nullptr) else if (overlayComp == nullptr)
{ {
addAndMakeVisible (overlayComp = new ItemDragAndDropOverlayComponent());
overlayComp.reset (new ItemDragAndDropOverlayComponent());
addAndMakeVisible (overlayComp.get());
overlayComp->parentSizeChanged(); overlayComp->parentSizeChanged();
} }


+ 2
- 2
modules/juce_gui_basics/widgets/juce_TreeView.cpp View File

@@ -440,7 +440,7 @@ TreeView::TreeView (const String& name)
: Component (name), : Component (name),
viewport (new TreeViewport()) viewport (new TreeViewport())
{ {
addAndMakeVisible (viewport);
addAndMakeVisible (viewport.get());
viewport->setViewedComponent (new ContentComponent (*this)); viewport->setViewedComponent (new ContentComponent (*this));
setWantsKeyboardFocus (true); setWantsKeyboardFocus (true);
} }
@@ -547,7 +547,7 @@ void TreeView::setOpenCloseButtonsVisible (const bool shouldBeVisible)
Viewport* TreeView::getViewport() const noexcept Viewport* TreeView::getViewport() const noexcept
{ {
return viewport;
return viewport.get();
} }
//============================================================================== //==============================================================================


+ 13
- 13
modules/juce_gui_basics/windows/juce_DocumentWindow.cpp View File

@@ -68,10 +68,10 @@ DocumentWindow::~DocumentWindow()
// Don't delete or remove the resizer components yourself! They're managed by the // Don't delete or remove the resizer components yourself! They're managed by the
// DocumentWindow, and you should leave them alone! You may have deleted them // DocumentWindow, and you should leave them alone! You may have deleted them
// accidentally by careless use of deleteAllChildren()..? // accidentally by careless use of deleteAllChildren()..?
jassert (menuBar == nullptr || getIndexOfChildComponent (menuBar) >= 0);
jassert (titleBarButtons[0] == nullptr || getIndexOfChildComponent (titleBarButtons[0]) >= 0);
jassert (titleBarButtons[1] == nullptr || getIndexOfChildComponent (titleBarButtons[1]) >= 0);
jassert (titleBarButtons[2] == nullptr || getIndexOfChildComponent (titleBarButtons[2]) >= 0);
jassert (menuBar == nullptr || getIndexOfChildComponent (menuBar.get()) >= 0);
jassert (titleBarButtons[0] == nullptr || getIndexOfChildComponent (titleBarButtons[0].get()) >= 0);
jassert (titleBarButtons[1] == nullptr || getIndexOfChildComponent (titleBarButtons[1].get()) >= 0);
jassert (titleBarButtons[2] == nullptr || getIndexOfChildComponent (titleBarButtons[2].get()) >= 0);
for (auto& b : titleBarButtons) for (auto& b : titleBarButtons)
b.reset(); b.reset();
@@ -140,7 +140,7 @@ void DocumentWindow::setMenuBar (MenuBarModel* newMenuBarModel, const int newMen
Component* DocumentWindow::getMenuBarComponent() const noexcept Component* DocumentWindow::getMenuBarComponent() const noexcept
{ {
return menuBar;
return menuBar.get();
} }
void DocumentWindow::setMenuBarComponent (Component* newMenuBarComponent) void DocumentWindow::setMenuBarComponent (Component* newMenuBarComponent)
@@ -229,9 +229,9 @@ void DocumentWindow::resized()
.positionDocumentWindowButtons (*this, .positionDocumentWindowButtons (*this,
titleBarArea.getX(), titleBarArea.getY(), titleBarArea.getX(), titleBarArea.getY(),
titleBarArea.getWidth(), titleBarArea.getHeight(), titleBarArea.getWidth(), titleBarArea.getHeight(),
titleBarButtons[0],
titleBarButtons[1],
titleBarButtons[2],
titleBarButtons[0].get(),
titleBarButtons[1].get(),
titleBarButtons[2].get(),
positionTitleBarButtonsOnLeft); positionTitleBarButtonsOnLeft);
if (menuBar != nullptr) if (menuBar != nullptr)
@@ -270,9 +270,9 @@ Rectangle<int> DocumentWindow::getTitleBarArea()
return { border.getLeft(), border.getTop(), getWidth() - border.getLeftAndRight(), getTitleBarHeight() }; return { border.getLeft(), border.getTop(), getWidth() - border.getLeftAndRight(), getTitleBarHeight() };
} }
Button* DocumentWindow::getCloseButton() const noexcept { return titleBarButtons[2]; }
Button* DocumentWindow::getMinimiseButton() const noexcept { return titleBarButtons[0]; }
Button* DocumentWindow::getMaximiseButton() const noexcept { return titleBarButtons[1]; }
Button* DocumentWindow::getCloseButton() const noexcept { return titleBarButtons[2].get(); }
Button* DocumentWindow::getMinimiseButton() const noexcept { return titleBarButtons[0].get(); }
Button* DocumentWindow::getMaximiseButton() const noexcept { return titleBarButtons[1].get(); }
int DocumentWindow::getDesktopWindowStyleFlags() const int DocumentWindow::getDesktopWindowStyleFlags() const
{ {
@@ -305,11 +305,11 @@ void DocumentWindow::lookAndFeelChanged()
if (buttonListener == nullptr) if (buttonListener == nullptr)
buttonListener.reset (new ButtonListenerProxy (*this)); buttonListener.reset (new ButtonListenerProxy (*this));
b->addListener (buttonListener);
b->addListener (buttonListener.get());
b->setWantsKeyboardFocus (false); b->setWantsKeyboardFocus (false);
// (call the Component method directly to avoid the assertion in ResizableWindow) // (call the Component method directly to avoid the assertion in ResizableWindow)
Component::addAndMakeVisible (b);
Component::addAndMakeVisible (b.get());
} }
} }


+ 2
- 2
modules/juce_gui_basics/windows/juce_ResizableWindow.cpp View File

@@ -47,8 +47,8 @@ ResizableWindow::~ResizableWindow()
// Don't delete or remove the resizer components yourself! They're managed by the // Don't delete or remove the resizer components yourself! They're managed by the
// ResizableWindow, and you should leave them alone! You may have deleted them // ResizableWindow, and you should leave them alone! You may have deleted them
// accidentally by careless use of deleteAllChildren()..? // accidentally by careless use of deleteAllChildren()..?
jassert (resizableCorner == nullptr || getIndexOfChildComponent (resizableCorner) >= 0);
jassert (resizableBorder == nullptr || getIndexOfChildComponent (resizableBorder) >= 0);
jassert (resizableCorner == nullptr || getIndexOfChildComponent (resizableCorner.get()) >= 0);
jassert (resizableBorder == nullptr || getIndexOfChildComponent (resizableBorder.get()) >= 0);
resizableCorner.reset(); resizableCorner.reset();
resizableBorder.reset(); resizableBorder.reset();


+ 4
- 4
modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp View File

@@ -367,14 +367,14 @@ CodeEditorComponent::CodeEditorComponent (CodeDocument& doc, CodeTokeniser* cons
setLineNumbersShown (true); setLineNumbersShown (true);
verticalScrollBar.addListener (pimpl);
horizontalScrollBar.addListener (pimpl);
document.addListener (pimpl);
verticalScrollBar.addListener (pimpl.get());
horizontalScrollBar.addListener (pimpl.get());
document.addListener (pimpl.get());
} }
CodeEditorComponent::~CodeEditorComponent() CodeEditorComponent::~CodeEditorComponent()
{ {
document.removeListener (pimpl);
document.removeListener (pimpl.get());
} }
int CodeEditorComponent::getGutterSize() const noexcept int CodeEditorComponent::getGutterSize() const noexcept


+ 1
- 1
modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp View File

@@ -126,7 +126,7 @@ void PreferencesPanel::setCurrentPage (const String& pageName)
if (currentPage != nullptr) if (currentPage != nullptr)
{ {
addAndMakeVisible (currentPage);
addAndMakeVisible (currentPage.get());
currentPage->toBack(); currentPage->toBack();
resized(); resized();
} }


+ 5
- 5
modules/juce_opengl/opengl/juce_OpenGLContext.cpp View File

@@ -76,11 +76,11 @@ public:
: ThreadPoolJob ("OpenGL Rendering"), : ThreadPoolJob ("OpenGL Rendering"),
context (c), component (comp) context (c), component (comp)
{ {
nativeContext = new NativeContext (component, pixFormat, contextToShare,
c.useMultisampling, c.versionRequired);
nativeContext.reset (new NativeContext (component, pixFormat, contextToShare,
c.useMultisampling, c.versionRequired));
if (nativeContext->createdOk()) if (nativeContext->createdOk())
context.nativeContext = nativeContext;
context.nativeContext = nativeContext.get();
else else
nativeContext.reset(); nativeContext.reset();
} }
@@ -95,7 +95,7 @@ public:
{ {
if (nativeContext != nullptr) if (nativeContext != nullptr)
{ {
renderThread = new ThreadPool (1);
renderThread.reset (new ThreadPool (1));
resume(); resume();
} }
} }
@@ -886,7 +886,7 @@ void OpenGLContext::attachTo (Component& component)
if (getTargetComponent() != &component) if (getTargetComponent() != &component)
{ {
detach(); detach();
attachment = new Attachment (*this, component);
attachment.reset (new Attachment (*this, component));
} }
} }


+ 5
- 4
modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp View File

@@ -202,7 +202,7 @@ bool OpenGLFrameBuffer::initialise (OpenGLContext& context, const Image& image)
bool OpenGLFrameBuffer::initialise (OpenGLFrameBuffer& other) bool OpenGLFrameBuffer::initialise (OpenGLFrameBuffer& other)
{ {
const Pimpl* const p = other.pimpl;
auto* p = other.pimpl.get();
if (p == nullptr) if (p == nullptr)
{ {
@@ -242,7 +242,7 @@ void OpenGLFrameBuffer::saveAndRelease()
{ {
if (pimpl != nullptr) if (pimpl != nullptr)
{ {
savedState = new SavedState (*this, pimpl->width, pimpl->height);
savedState.reset (new SavedState (*this, pimpl->width, pimpl->height));
pimpl.reset(); pimpl.reset();
} }
} }
@@ -251,12 +251,13 @@ bool OpenGLFrameBuffer::reloadSavedCopy (OpenGLContext& context)
{ {
if (savedState != nullptr) if (savedState != nullptr)
{ {
ScopedPointer<SavedState> state (savedState);
ScopedPointer<SavedState> state;
std::swap (state, savedState);
if (state->restore (context, *this)) if (state->restore (context, *this))
return true; return true;
savedState = state;
std::swap (state, savedState);
} }
return false; return false;


+ 2
- 2
modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp View File

@@ -1587,7 +1587,7 @@ struct SavedState : public RenderingHelpers::SavedStateBase<SavedState>
SavedState (const SavedState& other) SavedState (const SavedState& other)
: BaseClass (other), font (other.font), state (other.state), : BaseClass (other), font (other.font), state (other.state),
transparencyLayer (other.transparencyLayer), transparencyLayer (other.transparencyLayer),
previousTarget (other.previousTarget.createCopy())
previousTarget (createCopyIfNotNull (other.previousTarget.get()))
{} {}
SavedState* beginTransparencyLayer (float opacity) SavedState* beginTransparencyLayer (float opacity)
@@ -1600,7 +1600,7 @@ struct SavedState : public RenderingHelpers::SavedStateBase<SavedState>
state->flush(); state->flush();
s->transparencyLayer = Image (OpenGLImageType().create (Image::ARGB, clipBounds.getWidth(), clipBounds.getHeight(), true)); s->transparencyLayer = Image (OpenGLImageType().create (Image::ARGB, clipBounds.getWidth(), clipBounds.getHeight(), true));
s->previousTarget = new Target (state->target);
s->previousTarget.reset (new Target (state->target));
state->target = Target (state->target.context, *OpenGLImageType::getFrameBufferFrom (s->transparencyLayer), clipBounds.getPosition()); state->target = Target (state->target.context, *OpenGLImageType::getFrameBufferFrom (s->transparencyLayer), clipBounds.getPosition());
s->transparencyLayerAlpha = opacity; s->transparencyLayerAlpha = opacity;
s->cloneClipIfMultiplyReferenced(); s->cloneClipIfMultiplyReferenced();


+ 2
- 2
modules/juce_opengl/opengl/juce_OpenGLImage.cpp View File

@@ -156,8 +156,8 @@ private:
static void initialise (OpenGLFrameBuffer& frameBuffer, Image::BitmapData& bitmapData, int x, int y) static void initialise (OpenGLFrameBuffer& frameBuffer, Image::BitmapData& bitmapData, int x, int y)
{ {
DataReleaser* r = new DataReleaser (frameBuffer, x, y, bitmapData.width, bitmapData.height);
bitmapData.dataReleaser = r;
auto* r = new DataReleaser (frameBuffer, x, y, bitmapData.width, bitmapData.height);
bitmapData.dataReleaser.reset (r);
bitmapData.data = (uint8*) r->data.get(); bitmapData.data = (uint8*) r->data.get();
bitmapData.lineStride = (bitmapData.width * bitmapData.pixelStride + 3) & ~3; bitmapData.lineStride = (bitmapData.width * bitmapData.pixelStride + 3) & ~3;


+ 5
- 4
modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp View File

@@ -54,7 +54,8 @@ struct OnlineUnlockForm::OverlayComp : public Component,
if (hasCancelButton) if (hasCancelButton)
{ {
addAndMakeVisible (cancelButton = new TextButton (TRANS ("Cancel")));
cancelButton.reset (new TextButton (TRANS ("Cancel")));
addAndMakeVisible (cancelButton.get());
cancelButton->addListener (this); cancelButton->addListener (this);
} }
@@ -128,7 +129,7 @@ struct OnlineUnlockForm::OverlayComp : public Component,
void buttonClicked (Button* button) override void buttonClicked (Button* button) override
{ {
if (button == cancelButton)
if (button == cancelButton.get())
{ {
form.status.userCancelled(); form.status.userCancelled();
@@ -267,8 +268,8 @@ void OnlineUnlockForm::lookAndFeelChanged()
void OnlineUnlockForm::showBubbleMessage (const String& text, Component& target) void OnlineUnlockForm::showBubbleMessage (const String& text, Component& target)
{ {
bubble = new BubbleMessageComponent (500);
addChildComponent (bubble);
bubble.reset (new BubbleMessageComponent (500));
addChildComponent (bubble.get());
AttributedString attString; AttributedString attString;
attString.append (text, Font (16.0f)); attString.append (text, Font (16.0f));


+ 1
- 1
modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp View File

@@ -123,7 +123,7 @@ struct KeyFileUtils
const MemoryBlock mb (val.toMemoryBlock()); const MemoryBlock mb (val.toMemoryBlock());
if (CharPointer_UTF8::isValidString (static_cast<const char*> (mb.getData()), (int) mb.getSize())) if (CharPointer_UTF8::isValidString (static_cast<const char*> (mb.getData()), (int) mb.getSize()))
xml = XmlDocument::parse (mb.toString());
xml.reset (XmlDocument::parse (mb.toString()));
} }
return xml != nullptr ? *xml : XmlElement("key"); return xml != nullptr ? *xml : XmlElement("key");


+ 1
- 1
modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.cpp View File

@@ -57,7 +57,7 @@ String TracktionMarketplaceStatus::readReplyFromWebserver (const String& email,
{ {
ScopedLock lock (streamCreationLock); ScopedLock lock (streamCreationLock);
stream = new WebInputStream (url, true);
stream.reset (new WebInputStream (url, true));
} }
if (stream->connect (nullptr)) if (stream->connect (nullptr))


+ 5
- 5
modules/juce_video/playback/juce_VideoComponent.cpp View File

@@ -36,7 +36,7 @@ namespace juce
//============================================================================== //==============================================================================
VideoComponent::VideoComponent() : pimpl (new Pimpl()) VideoComponent::VideoComponent() : pimpl (new Pimpl())
{ {
addAndMakeVisible (pimpl);
addAndMakeVisible (pimpl.get());
} }
VideoComponent::~VideoComponent() VideoComponent::~VideoComponent()
@@ -46,14 +46,14 @@ VideoComponent::~VideoComponent()
Result VideoComponent::load (const File& file) Result VideoComponent::load (const File& file)
{ {
Result r = pimpl->load (file);
auto r = pimpl->load (file);
resized(); resized();
return r; return r;
} }
Result VideoComponent::load (const URL& url) Result VideoComponent::load (const URL& url)
{ {
Result r = pimpl->load (url);
auto r = pimpl->load (url);
resized(); resized();
return r; return r;
} }
@@ -86,11 +86,11 @@ float VideoComponent::getAudioVolume() const { return pimpl->getV
void VideoComponent::resized() void VideoComponent::resized()
{ {
Rectangle<int> r = getLocalBounds();
auto r = getLocalBounds();
if (isVideoOpen() && ! r.isEmpty()) if (isVideoOpen() && ! r.isEmpty())
{ {
Rectangle<int> nativeSize = getVideoNativeSize();
auto nativeSize = getVideoNativeSize();
if (nativeSize.isEmpty()) if (nativeSize.isEmpty())
{ {


Loading…
Cancel
Save