From 1a60fa97657db2fc4ea81fb908face60cdffb720 Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 10 Jan 2018 17:35:08 +0000 Subject: [PATCH] More ScopedPointer/unique_ptr compatibility work --- .../ProjectSaving/jucer_ProjectExporter.h | 2 +- .../buffers/juce_AudioDataConverters.cpp | 6 +- .../mpe/juce_MPEInstrument.cpp | 2 +- .../sources/juce_MixerAudioSource.cpp | 2 +- .../audio_io/juce_AudioDeviceManager.cpp | 64 ++++------ .../audio_io/juce_AudioDeviceManager.h | 14 +-- .../native/juce_mac_CoreAudio.cpp | 12 +- .../native/juce_mac_CoreMidi.cpp | 12 +- .../codecs/juce_OggVorbisAudioFormat.cpp | 4 +- .../codecs/juce_WavAudioFormat.cpp | 20 +++- .../format/juce_AudioFormatManager.cpp | 2 +- .../format/juce_AudioFormatReader.cpp | 2 +- .../sampler/juce_Sampler.cpp | 4 +- .../juce_audio_formats/sampler/juce_Sampler.h | 2 +- .../format/juce_AudioPluginFormat.cpp | 2 +- .../juce_AudioUnitPluginFormat.mm | 4 +- .../format_types/juce_VST3PluginFormat.cpp | 32 ++--- .../format_types/juce_VSTPluginFormat.cpp | 28 +++-- .../processors/juce_AudioProcessorEditor.cpp | 8 +- .../processors/juce_AudioProcessorGraph.cpp | 8 +- .../processors/juce_AudioProcessorGraph.h | 2 +- .../scanning/juce_KnownPluginList.cpp | 4 +- .../scanning/juce_PluginListComponent.cpp | 24 ++-- .../gui/juce_AudioDeviceSelectorComponent.cpp | 113 +++++++++--------- .../gui/juce_AudioThumbnail.cpp | 10 +- .../gui/juce_MidiKeyboardComponent.cpp | 7 +- .../juce_core/containers/juce_OwnedArray.h | 2 +- .../juce_core/javascript/juce_Javascript.cpp | 14 +-- modules/juce_core/maths/juce_Expression.cpp | 12 +- .../juce_core/misc/juce_StdFunctionCompat.cpp | 2 +- modules/juce_core/native/juce_mac_Network.mm | 2 +- .../juce_core/native/juce_posix_SharedCode.h | 2 +- modules/juce_core/network/juce_URL.cpp | 15 +-- .../juce_core/text/juce_LocalisedStrings.cpp | 8 +- modules/juce_core/xml/juce_XmlDocument.cpp | 20 ++-- .../zip/juce_GZIPDecompressorInputStream.cpp | 2 +- modules/juce_core/zip/juce_ZipFile.cpp | 9 +- .../values/juce_ValueTree.cpp | 6 +- .../juce_graphics/colour/juce_FillType.cpp | 4 +- .../native/juce_RenderingHelpers.h | 6 +- .../juce_gui_basics/buttons/juce_Button.cpp | 14 +-- .../buttons/juce_DrawableButton.cpp | 14 +-- .../buttons/juce_ToolbarButton.cpp | 4 +- .../components/juce_Component.cpp | 11 +- .../components/juce_Desktop.cpp | 2 +- .../juce_gui_basics/components/juce_Desktop.h | 4 +- .../drawables/juce_Drawable.cpp | 2 +- .../drawables/juce_SVGParser.cpp | 4 +- .../filebrowser/juce_FileBrowserComponent.cpp | 6 +- .../filebrowser/juce_FilenameComponent.cpp | 2 +- .../layout/juce_ComponentAnimator.cpp | 4 +- .../layout/juce_ComponentBuilder.cpp | 6 +- .../layout/juce_TabbedButtonBar.cpp | 13 +- .../juce_gui_basics/layout/juce_Viewport.cpp | 8 +- .../lookandfeel/juce_LookAndFeel_V2.cpp | 14 +-- .../menus/juce_BurgerMenuComponent.cpp | 2 +- .../juce_gui_basics/menus/juce_PopupMenu.cpp | 6 +- .../native/juce_mac_FileChooser.mm | 7 +- .../native/juce_mac_MainMenu.mm | 2 +- .../properties/juce_TextPropertyComponent.cpp | 3 +- .../juce_gui_basics/widgets/juce_ComboBox.cpp | 4 +- .../juce_gui_basics/widgets/juce_Label.cpp | 15 +-- .../juce_gui_basics/widgets/juce_ListBox.cpp | 15 ++- .../widgets/juce_TableHeaderComponent.cpp | 3 +- .../widgets/juce_TextEditor.cpp | 6 +- .../juce_gui_basics/widgets/juce_Toolbar.cpp | 2 +- .../widgets/juce_ToolbarItemComponent.cpp | 11 +- .../juce_gui_basics/widgets/juce_TreeView.cpp | 4 +- .../windows/juce_DocumentWindow.cpp | 26 ++-- .../windows/juce_ResizableWindow.cpp | 4 +- .../code_editor/juce_CodeEditorComponent.cpp | 8 +- .../misc/juce_PreferencesPanel.cpp | 2 +- .../juce_opengl/opengl/juce_OpenGLContext.cpp | 10 +- .../opengl/juce_OpenGLFrameBuffer.cpp | 9 +- .../opengl/juce_OpenGLGraphicsContext.cpp | 4 +- .../juce_opengl/opengl/juce_OpenGLImage.cpp | 4 +- .../marketplace/juce_OnlineUnlockForm.cpp | 9 +- .../marketplace/juce_OnlineUnlockStatus.cpp | 2 +- .../juce_TracktionMarketplaceStatus.cpp | 2 +- .../playback/juce_VideoComponent.cpp | 10 +- 80 files changed, 404 insertions(+), 368 deletions(-) diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h index e1a023051a..93299efcc6 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h @@ -50,7 +50,7 @@ public: Image image (Image::ARGB, 200, 200, true); Graphics g (image); - ScopedPointer svgDrawable = Drawable::createFromImageData (iconData, (size_t) iconDataSize); + ScopedPointer svgDrawable (Drawable::createFromImageData (iconData, (size_t) iconDataSize)); svgDrawable->drawWithin (g, image.getBounds().toFloat(), RectanglePlacement::fillDestination, 1.0f); diff --git a/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp b/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp index bfa9b74ec6..e8fc19fb7d 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp +++ b/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp @@ -519,8 +519,8 @@ public: conv->convertSamples (inPlace ? reversed : converted, original, numSamples); // ..and back again.. - conv = new AudioData::ConverterInstance , - AudioData::Pointer>(); + conv.reset (new AudioData::ConverterInstance , + AudioData::Pointer>()); if (! inPlace) zeromem (reversed, sizeof (reversed)); @@ -532,7 +532,7 @@ public: AudioData::Pointer d2 (reversed); const int errorMargin = 2 * AudioData::Pointer::get32BitResolution() - + AudioData::Pointer::get32BitResolution(); + + AudioData::Pointer::get32BitResolution(); for (int i = 0; i < numSamples; ++i) { diff --git a/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp b/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp index 539b241979..ed8101aa50 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp @@ -2133,7 +2133,7 @@ private: void noteReleased (MPENote finishedNote) override { noteReleasedCallCounter++; - lastNoteFinished = new MPENote (finishedNote); + lastNoteFinished.reset (new MPENote (finishedNote)); } }; diff --git a/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp b/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp index b3f1d148c0..ed2918e421 100644 --- a/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp @@ -71,7 +71,7 @@ void MixerAudioSource::removeInputSource (AudioSource* const input) return; if (inputsToDelete [index]) - toDelete = input; + toDelete.reset (input); inputsToDelete.shiftBits (-1, index); inputs.remove (index); diff --git a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp index ae7f39e32b..00202a3072 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp @@ -89,14 +89,8 @@ private: //============================================================================== 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() @@ -113,12 +107,12 @@ void AudioDeviceManager::createDeviceTypesIfNeeded() OwnedArray types; createAudioDeviceTypes (types); - for (int i = 0; i < types.size(); ++i) - addAudioDeviceType (types.getUnchecked(i)); + for (auto* t : types) + addAudioDeviceType (t); types.clear (false); - if (AudioIODeviceType* first = availableDeviceTypes.getFirst()) + if (auto* first = availableDeviceTypes.getFirst()) currentDeviceType = first->getTypeName(); } } @@ -171,7 +165,7 @@ void AudioDeviceManager::addAudioDeviceType (AudioIODeviceType* newDeviceType) availableDeviceTypes.add (newDeviceType); 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 AudioDeviceSetup* preferredSetupOptions) { - lastExplicitSettings = new XmlElement (xml); + lastExplicitSettings.reset (new XmlElement (xml)); String error; AudioDeviceSetup setup; @@ -299,10 +293,8 @@ String AudioDeviceManager::initialiseFromXML (const XmlElement& xml, forEachXmlChildElementWithTagName (xml, c, "MIDIINPUT") 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) error = initialise (numInputChansNeeded, numOutputChansNeeded, @@ -319,12 +311,12 @@ String AudioDeviceManager::initialiseWithDefaultDevices (int numInputChannelsNee lastExplicitSettings.reset(); return initialise (numInputChannelsNeeded, numOutputChannelsNeeded, - nullptr, false, String(), nullptr); + nullptr, false, {}, nullptr); } void AudioDeviceManager::insertDefaultDeviceNames (AudioDeviceSetup& setup) const { - if (AudioIODeviceType* type = getCurrentDeviceTypeObject()) + if (auto* type = getCurrentDeviceTypeObject()) { if (setup.outputDeviceName.isEmpty()) setup.outputDeviceName = type->getDeviceNames (false) [type->getDefaultDeviceIndex (false)]; @@ -336,7 +328,7 @@ void AudioDeviceManager::insertDefaultDeviceNames (AudioDeviceSetup& setup) cons 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)) return "No such device: " + newInputDeviceName; - currentAudioDevice = type->createDevice (newOutputDeviceName, newInputDeviceName); + currentAudioDevice.reset (type->createDevice (newOutputDeviceName, newInputDeviceName)); if (currentAudioDevice == nullptr) error = "Can't open the audio device!\n\n" @@ -521,7 +513,7 @@ String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& newSetup { currentDeviceType = currentAudioDevice->getTypeName(); - currentAudioDevice->start (callbackHandler); + currentAudioDevice->start (callbackHandler.get()); currentSetup.sampleRate = currentAudioDevice->getCurrentSampleRate(); currentSetup.bufferSize = currentAudioDevice->getCurrentBufferSizeSamples(); @@ -618,7 +610,7 @@ void AudioDeviceManager::restartLastAudioDevice() void AudioDeviceManager::updateXml() { - lastExplicitSettings = new XmlElement ("DEVICESETUP"); + lastExplicitSettings.reset (new XmlElement ("DEVICESETUP")); lastExplicitSettings->setAttribute ("deviceType", currentDeviceType); lastExplicitSettings->setAttribute ("audioOutputDeviceName", currentSetup.outputDeviceName); @@ -668,7 +660,7 @@ void AudioDeviceManager::addAudioCallback (AudioIODeviceCallback* newCallback) } if (currentAudioDevice != nullptr && newCallback != nullptr) - newCallback->audioDeviceAboutToStart (currentAudioDevice); + newCallback->audioDeviceAboutToStart (currentAudioDevice.get()); const ScopedLock sl (audioCallbackLock); callbacks.add (newCallback); @@ -814,11 +806,11 @@ void AudioDeviceManager::setMidiInputEnabled (const String& name, const bool ena { if (enabled) { - const int index = MidiInput::getDevices().indexOf (name); + auto index = MidiInput::getDevices().indexOf (name); if (index >= 0) { - if (MidiInput* const midiIn = MidiInput::openDevice (index, callbackHandler)) + if (auto* midiIn = MidiInput::openDevice (index, callbackHandler.get())) { enabledMidiInputs.add (midiIn); midiIn->start(); @@ -839,8 +831,8 @@ void AudioDeviceManager::setMidiInputEnabled (const String& name, const bool ena 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 false; @@ -865,7 +857,7 @@ void AudioDeviceManager::removeMidiInputCallback (const String& name, MidiInputC { 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) { @@ -881,13 +873,9 @@ void AudioDeviceManager::handleIncomingMidiMessageInt (MidiInput* source, const { 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()) mc.callback->handleIncomingMidiMessage (source, message); - } } } @@ -911,11 +899,11 @@ void AudioDeviceManager::setDefaultMidiOutput (const String& deviceName) defaultMidiOutputName = deviceName; if (deviceName.isNotEmpty()) - defaultMidiOutput = MidiOutput::openDevice (MidiOutput::getDevices().indexOf (deviceName)); + defaultMidiOutput.reset (MidiOutput::openDevice (MidiOutput::getDevices().indexOf (deviceName))); 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); @@ -982,7 +970,7 @@ void AudioDeviceManager::playTestSound() { 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); const ScopedLock sl (audioCallbackLock); - testSound = newSound; + testSound.reset (newSound); } } diff --git a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h index 05668c269c..7da7ccff1c 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h +++ b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h @@ -234,7 +234,7 @@ public: /** 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. @see setCurrentAudioDeviceType @@ -372,7 +372,7 @@ public: If no device has been selected, or the device can't be opened, this will return nullptr. @see getDefaultMidiOutputName */ - MidiOutput* getDefaultMidiOutput() const noexcept { return defaultMidiOutput; } + MidiOutput* getDefaultMidiOutput() const noexcept { return defaultMidiOutput.get(); } /** Returns a list of the types of device supported. */ const OwnedArray& getAvailableDeviceTypes(); @@ -453,11 +453,11 @@ private: AudioDeviceSetup currentSetup; ScopedPointer currentAudioDevice; Array callbacks; - int numInputChansNeeded, numOutputChansNeeded; + int numInputChansNeeded = 0, numOutputChansNeeded = 2; String currentDeviceType; BigInteger inputChannels, outputChannels; ScopedPointer lastExplicitSettings; - mutable bool listNeedsScanning; + mutable bool listNeedsScanning = true; AudioBuffer tempBuffer; struct MidiCallbackInfo @@ -475,10 +475,10 @@ private: CriticalSection audioCallbackLock, midiCallbackLock; ScopedPointer> testSound; - int testSoundPosition; + int testSoundPosition = 0; - double cpuUsageMs, timeToCpuScale, msPerBlock; - int xruns; + double cpuUsageMs = 0, timeToCpuScale = 0, msPerBlock = 0; + int xruns = 0; struct LevelMeter { diff --git a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp index 0b591de09a..acb6d13c86 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp @@ -965,14 +965,14 @@ public: } jassert (device != nullptr); - internal = device; + internal.reset (device); AudioObjectPropertyAddress pa; pa.mSelector = kAudioObjectPropertySelectorWildcard; pa.mScope = kAudioObjectPropertyScopeWildcard; pa.mElement = kAudioObjectPropertyElementWildcard; - AudioObjectAddPropertyListener (kAudioObjectSystemObject, &pa, hardwareListenerProc, internal); + AudioObjectAddPropertyListener (kAudioObjectSystemObject, &pa, hardwareListenerProc, internal.get()); } ~CoreAudioIODevice() @@ -984,7 +984,7 @@ public: pa.mScope = kAudioObjectPropertyScopeWildcard; pa.mElement = kAudioObjectPropertyElementWildcard; - AudioObjectRemovePropertyListener (kAudioObjectSystemObject, &pa, hardwareListenerProc, internal); + AudioObjectRemovePropertyListener (kAudioObjectSystemObject, &pa, hardwareListenerProc, internal.get()); } StringArray getOutputChannelNames() override { return internal->outChanNames; } @@ -1226,7 +1226,7 @@ public: Array devs; for (auto* d : devices) - devs.add (d->device); + devs.add (d->device.get()); return devs; } @@ -2160,10 +2160,10 @@ public: ScopedPointer in, out; 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) - 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 (out == nullptr) return in.release(); diff --git a/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp b/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp index c2411f94fb..a0c7ea7fe6 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp @@ -511,15 +511,15 @@ MidiInput* MidiInput::openDevice (int index, MidiInputCallback* callback) MIDIPortRef port; ScopedPointer 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))) { - mpc->portAndEndpoint = new MidiPortAndEndpoint (port, endPoint); + mpc->portAndEndpoint.reset (new MidiPortAndEndpoint (port, endPoint)); newInput = new MidiInput (getDevices() [index]); mpc->input = newInput; - newInput->internal = mpc; + newInput->internal = mpc.get(); const ScopedLock sl (callbackLock); activeCallbacks.add (mpc.release()); @@ -553,15 +553,15 @@ MidiInput* MidiInput::createNewDevice (const String& deviceName, MidiInputCallba ScopedCFString name; 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); - mpc->portAndEndpoint = new MidiPortAndEndpoint (0, endPoint); + mpc->portAndEndpoint.reset (new MidiPortAndEndpoint (0, endPoint)); mi = new MidiInput (deviceName); mpc->input = mi; - mi->internal = mpc; + mi->internal = mpc.get(); const ScopedLock sl (callbackLock); activeCallbacks.add (mpc.release()); diff --git a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp index 0f661b7b32..f106c16558 100644 --- a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp @@ -486,7 +486,9 @@ int OggVorbisAudioFormat::estimateOggFileQuality (const File& source) { if (auto* in = source.createInputStream()) { - if (ScopedPointer r = createReaderFor (in, true)) + ScopedPointer r (createReaderFor (in, true)); + + if (r != nullptr) { auto lengthSecs = r->lengthInSamples / r->sampleRate; auto approxBitsPerSecond = (int) (source.getSize() * 8 / lengthSecs); diff --git a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp index babe5722ff..822eebe7a7 100644 --- a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp @@ -1738,13 +1738,19 @@ namespace WavFileHelpers TemporaryFile tempFile (file); WavAudioFormat wav; - if (ScopedPointer reader = wav.createReaderFor (file.createInputStream(), true)) + ScopedPointer reader (wav.createReaderFor (file.createInputStream(), true)); + + if (reader != nullptr) { - if (ScopedPointer outStream = tempFile.getFile().createOutputStream()) + ScopedPointer outStream (tempFile.getFile().createOutputStream()); + + if (outStream != nullptr) { - if (ScopedPointer writer = wav.createWriterFor (outStream, reader->sampleRate, - reader->numChannels, (int) reader->bitsPerSample, - metadata, 0)) + ScopedPointer writer (wav.createWriterFor (outStream.get(), reader->sampleRate, + reader->numChannels, (int) reader->bitsPerSample, + metadata, 0)); + + if (writer != nullptr) { outStream.release(); @@ -1765,7 +1771,9 @@ bool WavAudioFormat::replaceMetadataInFile (const File& wavFile, const StringPai { using namespace WavFileHelpers; - if (ScopedPointer reader = static_cast (createReaderFor (wavFile.createInputStream(), true))) + ScopedPointer reader (static_cast (createReaderFor (wavFile.createInputStream(), true))); + + if (reader != nullptr) { auto bwavPos = reader->bwavChunkStart; auto bwavSize = reader->bwavSize; diff --git a/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp b/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp index 6ec77c356a..05cebf2153 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp @@ -146,7 +146,7 @@ AudioFormatReader* AudioFormatManager::createReaderFor (InputStream* audioFileSt for (auto* af : knownFormats) { - if (auto* r = af->createReaderFor (in, false)) + if (auto* r = af->createReaderFor (in.get(), false)) { in.release(); return r; diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp index f40f46571f..2f914d3705 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp @@ -394,7 +394,7 @@ bool MemoryMappedAudioFormatReader::mapSectionOfFile (Range samplesToMap) const Range fileRange (sampleToFilePos (samplesToMap.getStart()), sampleToFilePos (samplesToMap.getEnd())); - map = new MemoryMappedFile (file, fileRange, MemoryMappedFile::readOnly); + map.reset (new MemoryMappedFile (file, fileRange, MemoryMappedFile::readOnly)); if (map->getData() == nullptr) map.reset(); diff --git a/modules/juce_audio_formats/sampler/juce_Sampler.cpp b/modules/juce_audio_formats/sampler/juce_Sampler.cpp index bef61c0e60..ee5b64b296 100644 --- a/modules/juce_audio_formats/sampler/juce_Sampler.cpp +++ b/modules/juce_audio_formats/sampler/juce_Sampler.cpp @@ -44,9 +44,9 @@ SamplerSound::SamplerSound (const String& soundName, length = jmin ((int) source.lengthInSamples, (int) (maxSampleLengthSeconds * sourceSampleRate)); - data = new AudioBuffer (jmin (2, (int) source.numChannels), length + 4); + data.reset (new AudioBuffer (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); releaseSamples = roundToInt (releaseTimeSecs * sourceSampleRate); diff --git a/modules/juce_audio_formats/sampler/juce_Sampler.h b/modules/juce_audio_formats/sampler/juce_Sampler.h index c6f10ab928..61bd2eae58 100644 --- a/modules/juce_audio_formats/sampler/juce_Sampler.h +++ b/modules/juce_audio_formats/sampler/juce_Sampler.h @@ -79,7 +79,7 @@ public: /** Returns the audio sample data. This could return nullptr if there was a problem loading the data. */ - AudioBuffer* getAudioData() const noexcept { return data; } + AudioBuffer* getAudioData() const noexcept { return data.get(); } //============================================================================== diff --git a/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp b/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp index 8b33d4d043..1811cd3f7e 100644 --- a/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp +++ b/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp @@ -125,7 +125,7 @@ AudioPluginInstance* AudioPluginFormat::createInstanceFromDescription (const Plu createPluginInstanceAsync (desc, initialSampleRate, initialBufferSize, eventSignaler.release()); else createPluginInstance (desc, initialSampleRate, initialBufferSize, - eventSignaler, EventSignaler::staticCompletionCallback); + eventSignaler.get(), EventSignaler::staticCompletionCallback); waitForCreation.wait(); diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index c9c8094bdf..c5bafeb621 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -2223,7 +2223,7 @@ AudioProcessorEditor* AudioUnitPluginInstance::createEditor() ScopedPointer w (new AudioUnitPluginWindowCocoa (*this, false)); if (! static_cast (w.get())->isValid()) - w = nullptr; + w.reset(); #if JUCE_SUPPORT_CARBON if (w == nullptr) @@ -2236,7 +2236,7 @@ AudioProcessorEditor* AudioUnitPluginInstance::createEditor() #endif 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(); } diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index edc9934758..7a4f88a0b5 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -897,14 +897,14 @@ struct DescriptionFactory if (pf2.loadFrom (factory)) { - info2 = new PClassInfo2(); - pf2->getClassInfo2 (i, info2); + info2.reset (new PClassInfo2()); + pf2->getClassInfo2 (i, info2.get()); } 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); createPluginDescription (desc, file, companyName, name, - info, info2, infoW, numInputs, numOutputs); + info, info2.get(), infoW.get(), numInputs, numOutputs); component->terminate(); } @@ -1246,7 +1246,7 @@ private: //============================================================================== bool open (const File& f, const PluginDescription& description) { - dllHandle = new DLLHandle (f.getFullPathName()); + dllHandle.reset (new DLLHandle (f.getFullPathName())); ComSmartPtr pluginFactory (dllHandle->getPluginFactory()); @@ -1572,23 +1572,23 @@ struct VST3ComponentHolder if (pf2.loadFrom (factory)) { - info2 = new PClassInfo2(); - pf2->getClassInfo2 (classIdx, info2); + info2.reset (new PClassInfo2()); + pf2->getClassInfo2 (classIdx, info2.get()); } else { - info2 = nullptr; + info2.reset(); } if (pf3.loadFrom (factory)) { pf3->setHostContext (host->getFUnknown()); - infoW = new PClassInfoW(); - pf3->getClassInfoUnicode (classIdx, infoW); + infoW.reset (new PClassInfoW()); + pf3->getClassInfoUnicode (classIdx, infoW.get()); } else { - infoW = nullptr; + infoW.reset(); } Vst::BusInfo bus; @@ -1606,7 +1606,7 @@ struct VST3ComponentHolder createPluginDescription (description, module->file, factoryInfo.vendor, module->name, - info, info2, infoW, + info, info2.get(), infoW.get(), totalNumInputChannels, totalNumOutputChannels); @@ -2784,14 +2784,14 @@ void VST3PluginFormat::createPluginInstance (const PluginDescription& descriptio if (const VST3Classes::VST3ModuleHandle::Ptr module = VST3Classes::VST3ModuleHandle::findOrCreateModule (file, description)) { - ScopedPointer holder = new VST3Classes::VST3ComponentHolder (module); + ScopedPointer holder (new VST3Classes::VST3ComponentHolder (module)); if (holder->initialise()) { - result = new VST3Classes::VST3PluginInstance (holder.release()); + result.reset (new VST3Classes::VST3PluginInstance (holder.release())); if (! result->initialise()) - result = nullptr; + result.reset(); } } diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 074294971a..713f9a9014 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -447,7 +447,7 @@ struct ModuleHandle : public ReferenceCountedObject .findChildFiles (vstXmlFiles, File::findFiles, false, "*.vstxml"); 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 (! plug.usesCocoaNSView) - addAndMakeVisible (carbonWrapper = new CarbonWrapperComponent (*this)); + { + carbonWrapper.reset (new CarbonWrapperComponent (*this)); + addAndMakeVisible (carbonWrapper.get()); + } else #endif - addAndMakeVisible (cocoaWrapper = new AutoResizingNSViewComponentWithParent()); + { + cocoaWrapper.reset (new AutoResizingNSViewComponentWithParent()); + addAndMakeVisible (cocoaWrapper.get()); + } #endif activeVSTWindows.add (this); @@ -2096,9 +2102,9 @@ public: #if JUCE_MAC #if JUCE_SUPPORT_CARBON - carbonWrapper = nullptr; + carbonWrapper.reset(); #endif - cocoaWrapper = nullptr; + cocoaWrapper.reset(); #elif JUCE_LINUX display = XWindowSystem::getInstance()->displayUnref(); #endif @@ -2791,10 +2797,10 @@ void VSTPluginFormat::createPluginInstance (const PluginDescription& desc, { shellUIDToCreate = desc.uid; - result = VSTPluginInstance::create (module, sampleRate, blockSize); + result.reset (VSTPluginInstance::create (module, sampleRate, blockSize)); if (result != nullptr && ! result->initialiseEffect (sampleRate, blockSize)) - result = nullptr; + result.reset(); } previousWorkingDirectory.setAsCurrentWorkingDirectory(); @@ -2954,9 +2960,13 @@ AudioPluginInstance* VSTPluginFormat::createCustomVSTFromMainCall (void* entryPo ModuleHandle::Ptr module = new ModuleHandle (File(), (MainCall) entryPointFunction); if (module->open()) - if (ScopedPointer result = VSTPluginInstance::create (module, initialSampleRate, initialBufferSize)) + { + ScopedPointer result (VSTPluginInstance::create (module, initialSampleRate, initialBufferSize)); + + if (result != nullptr) if (result->initialiseEffect (initialSampleRate, initialBufferSize)) return result.release(); + } return nullptr; } @@ -2966,7 +2976,7 @@ void VSTPluginFormat::setExtraFunctions (AudioPluginInstance* plugin, ExtraFunct ScopedPointer f (functions); if (auto* vst = dynamic_cast (plugin)) - vst->extraFunctions = f; + std::swap (vst->extraFunctions, f); } AudioPluginInstance* VSTPluginFormat::getPluginInstanceFromVstEffectInterface (void* aEffect) diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp index 98d3709b7d..22d82baf80 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp @@ -46,7 +46,7 @@ AudioProcessorEditor::~AudioProcessorEditor() // if this fails, then the wrapper hasn't called editorBeingDeleted() on the // filter for some reason.. jassert (processor.getActiveEditor() != this); - removeComponentListener (resizeListener); + removeComponentListener (resizeListener.get()); } void AudioProcessorEditor::setControlHighlight (ParameterControlHighlightInfo) {} @@ -77,7 +77,8 @@ void AudioProcessorEditor::initialise() resizable = false; 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) { - Component::addChildComponent (resizableCorner = new ResizableCornerComponent (this, constrainer)); + resizableCorner.reset (new ResizableCornerComponent (this, constrainer)); + Component::addChildComponent (resizableCorner.get()); resizableCorner->setAlwaysOnTop (true); } else diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp index cf9ee5c23c..f981311948 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp @@ -1144,8 +1144,8 @@ void AudioProcessorGraph::clearRenderingSequence() { 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()); - renderSequenceFloat.swapWith (newSequenceF); - renderSequenceDouble.swapWith (newSequenceD); + std::swap (renderSequenceFloat, newSequenceF); + std::swap (renderSequenceDouble, newSequenceD); } void AudioProcessorGraph::handleAsyncUpdate() diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h index 9f0d4de34f..0362943cab 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h @@ -96,7 +96,7 @@ public: const NodeID nodeID; /** 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. diff --git a/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp b/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp index de7329d8fc..f339bb55f7 100644 --- a/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp +++ b/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp @@ -115,7 +115,7 @@ bool KnownPluginList::isListingUpToDate (const String& fileOrIdentifier, void KnownPluginList::setCustomScanner (CustomScanner* newScanner) { - scanner = newScanner; + scanner.reset (newScanner); } bool KnownPluginList::scanAndAddFile (const String& fileOrIdentifier, @@ -425,7 +425,7 @@ struct PluginTreeUtils { current->folder = lastType; tree.subFolders.add (current.release()); - current = new KnownPluginList::PluginTree(); + current.reset (new KnownPluginList::PluginTree()); } lastType = thisType; diff --git a/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp b/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp index 636a457b4e..1c3d960307 100644 --- a/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp +++ b/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp @@ -142,7 +142,7 @@ PluginListComponent::PluginListComponent (AudioPluginFormatManager& manager, Kno allowAsync (allowPluginsWhichRequireAsynchronousInstantiation), numThreads (allowAsync ? 1 : 0) { - tableModel = new TableModel (*this, listToEdit); + tableModel.reset (new TableModel (*this, listToEdit)); TableHeaderComponent& header = table.getHeader(); @@ -154,7 +154,7 @@ PluginListComponent::PluginListComponent (AudioPluginFormatManager& manager, Kno table.setHeaderHeight (22); table.setRowHeight (20); - table.setModel (tableModel); + table.setModel (tableModel.get()); table.setMultipleSelectionEnabled (true); addAndMakeVisible (table); @@ -228,8 +228,8 @@ void PluginListComponent::removeSelectedPlugins() void PluginListComponent::setTableModel (TableListBoxModel* model) { table.setModel (nullptr); - tableModel = model; - table.setModel (tableModel); + tableModel.reset (model); + table.setModel (tableModel.get()); table.getHeader().reSortTable(); table.updateContent(); @@ -479,8 +479,8 @@ private: { 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) { @@ -494,7 +494,7 @@ private: if (numThreads > 0) { - pool = new ThreadPool (numThreads); + pool.reset (new ThreadPool (numThreads)); for (int i = numThreads; --i >= 0;) pool->addJob (new ScanJob (*this), true); @@ -560,9 +560,9 @@ private: 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 @@ -574,8 +574,8 @@ void PluginListComponent::scanFinished (const StringArray& failedFiles) { 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 diff --git a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp index 300d45d40f..8f05eda479 100644 --- a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp @@ -207,7 +207,8 @@ public: { 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(); }; } @@ -353,8 +354,8 @@ public: error = setup.manager->setAudioDeviceSetup (config, true); - showCorrectDeviceName (inputDeviceDropDown, true); - showCorrectDeviceName (outputDeviceDropDown, false); + showCorrectDeviceName (inputDeviceDropDown.get(), true); + showCorrectDeviceName (outputDeviceDropDown.get(), false); updateControlPanelButton(); resized(); @@ -433,12 +434,12 @@ public: { 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->attachToComponent (outputChanList, true); + outputChanLabel->attachToComponent (outputChanList.get(), true); } outputChanList->refresh(); @@ -454,12 +455,12 @@ public: { 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->attachToComponent (inputChanList, true); + inputChanLabel->attachToComponent (inputChanList.get(), true); } inputChanList->refresh(); @@ -564,8 +565,9 @@ private: 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(); }; } @@ -580,9 +582,9 @@ private: { 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(); }; resized(); } @@ -600,19 +602,19 @@ private: { if (outputDeviceDropDown == nullptr) { - outputDeviceDropDown = new ComboBox(); + outputDeviceDropDown.reset (new ComboBox()); 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) { - 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(); }; } } @@ -620,7 +622,7 @@ private: addNamesToDeviceBox (*outputDeviceDropDown, false); } - showCorrectDeviceName (outputDeviceDropDown, false); + showCorrectDeviceName (outputDeviceDropDown.get(), false); } void updateInputsComboBox() @@ -629,31 +631,32 @@ private: { if (inputDeviceDropDown == nullptr) { - inputDeviceDropDown = new ComboBox(); + inputDeviceDropDown.reset (new ComboBox()); 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); } - showCorrectDeviceName (inputDeviceDropDown, true); + showCorrectDeviceName (inputDeviceDropDown.get(), true); } void updateSampleRateComboBox (AudioIODevice* currentDevice) { 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 { @@ -675,10 +678,11 @@ private: { 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 { @@ -975,33 +979,33 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager& if (types.size() > 1) { - deviceTypeDropDown = new ComboBox(); + deviceTypeDropDown.reset (new ComboBox()); for (int i = 0; i < types.size(); ++i) deviceTypeDropDown->addItem (types.getUnchecked(i)->getTypeName(), i + 1); - addAndMakeVisible (deviceTypeDropDown); + addAndMakeVisible (deviceTypeDropDown.get()); deviceTypeDropDown->onChange = [this] { updateDeviceType(); }; - deviceTypeDropDownLabel = new Label ({}, TRANS("Audio device type:")); + deviceTypeDropDownLabel.reset (new Label ({}, TRANS("Audio device type:"))); deviceTypeDropDownLabel->setJustificationType (Justification::centredRight); - deviceTypeDropDownLabel->attachToComponent (deviceTypeDropDown, true); + deviceTypeDropDownLabel->attachToComponent (deviceTypeDropDown.get(), true); } if (showMidiInputOptions) { - addAndMakeVisible (midiInputsList - = new MidiInputSelectorComponentListBox (deviceManager, + midiInputsList.reset (new MidiInputSelectorComponentListBox (deviceManager, "(" + 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->attachToComponent (midiInputsList, true); + midiInputsLabel->attachToComponent (midiInputsList.get(), true); 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(); }; } } @@ -1014,11 +1018,12 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager& if (showMidiOutputSelector) { - addAndMakeVisible (midiOutputSelector = new ComboBox()); + midiOutputSelector.reset (new ComboBox()); + addAndMakeVisible (midiOutputSelector.get()); 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 { @@ -1139,7 +1144,7 @@ void AudioDeviceSelectorComponent::updateAllControls() details.useStereoPairs = showChannelsAsStereoPairs; auto* sp = new AudioDeviceSettingsPanel (*type, details, hideAdvancedOptionsWithButton); - audioDeviceSettingsComp = sp; + audioDeviceSettingsComp.reset (sp); addAndMakeVisible (sp); sp->updateAllControls(); } @@ -1186,7 +1191,7 @@ void AudioDeviceSelectorComponent::handleBluetoothButton() ListBox* AudioDeviceSelectorComponent::getMidiInputSelectorListBox() const noexcept { - return midiInputsList; + return midiInputsList.get(); } } // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp b/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp index fe495c670e..1aae8793d9 100644 --- a/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp @@ -219,8 +219,8 @@ private: void createReader() { 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() @@ -648,7 +648,7 @@ bool AudioThumbnail::setDataSource (LevelDataSource* newSource) 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->sampleRate = sampleRate; @@ -657,7 +657,7 @@ bool AudioThumbnail::setDataSource (LevelDataSource* newSource) } 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); source->initialise (numSamplesFinished); @@ -807,7 +807,7 @@ void AudioThumbnail::drawChannel (Graphics& g, const Rectangle& area, doubl const ScopedLock sl (lock); 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& area, double startTimeSeconds, diff --git a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp index 7c6398d44d..04b66df655 100644 --- a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp @@ -68,8 +68,11 @@ private: MidiKeyboardComponent::MidiKeyboardComponent (MidiKeyboardState& 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.. int note = 0; diff --git a/modules/juce_core/containers/juce_OwnedArray.h b/modules/juce_core/containers/juce_OwnedArray.h index 9ba73590d2..c581be7beb 100644 --- a/modules/juce_core/containers/juce_OwnedArray.h +++ b/modules/juce_core/containers/juce_OwnedArray.h @@ -411,7 +411,7 @@ public: { toDelete.reset (data.elements[indexToChange]); - if (toDelete == newObject) + if (toDelete.get() == newObject) toDelete.release(); } diff --git a/modules/juce_core/javascript/juce_Javascript.cpp b/modules/juce_core/javascript/juce_Javascript.cpp index 11e05c4f16..f6aecc8b94 100644 --- a/modules/juce_core/javascript/juce_Javascript.cpp +++ b/modules/juce_core/javascript/juce_Javascript.cpp @@ -389,7 +389,7 @@ struct JavascriptEngine::RootObject : public DynamicObject 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 { @@ -478,7 +478,7 @@ struct JavascriptEngine::RootObject : public DynamicObject struct BinaryOperatorBase : public Expression { 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; TokenType operation; @@ -674,7 +674,7 @@ struct JavascriptEngine::RootObject : public DynamicObject 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 { @@ -1080,7 +1080,7 @@ struct JavascriptEngine::RootObject : public DynamicObject } match (TokenTypes::closeParen); - fo.body = parseBlock(); + fo.body.reset (parseBlock()); } Expression* parseExpression() @@ -1270,7 +1270,7 @@ struct JavascriptEngine::RootObject : public DynamicObject Expression* parseFunctionCall (FunctionCall* call, ExpPtr& function) { ScopedPointer s (call); - s->object = function; + s->object.reset (function.release()); match (TokenTypes::openParen); while (currentType != TokenTypes::closeParen) @@ -1296,7 +1296,7 @@ struct JavascriptEngine::RootObject : public DynamicObject if (matchIf (TokenTypes::openBracket)) { ScopedPointer s (new ArraySubscript (location)); - s->object = input; + s->object.reset (input.release()); s->index.reset (parseExpression()); match (TokenTypes::closeBracket); return parseSuffixes (s.release()); @@ -1505,7 +1505,7 @@ struct JavascriptEngine::RootObject : public DynamicObject Expression* parseTernaryOperator (ExpPtr& condition) { ScopedPointer e (new ConditionalOp (location)); - e->condition = condition; + e->condition.reset (condition.release()); e->trueBranch.reset (parseExpression()); match (TokenTypes::colon); e->falseBranch.reset (parseExpression()); diff --git a/modules/juce_core/maths/juce_Expression.cpp b/modules/juce_core/maths/juce_Expression.cpp index 23e9b8b5e6..a0c1a26354 100644 --- a/modules/juce_core/maths/juce_Expression.cpp +++ b/modules/juce_core/maths/juce_Expression.cpp @@ -1023,22 +1023,22 @@ Expression Expression::adjustedToGiveNewResult (const double targetValue, const { ScopedPointer newTerm (term->clone()); - Helpers::Constant* termToAdjust = Helpers::findTermToAdjust (newTerm, true); + Helpers::Constant* termToAdjust = Helpers::findTermToAdjust (newTerm.get(), true); if (termToAdjust == nullptr) - termToAdjust = Helpers::findTermToAdjust (newTerm, false); + termToAdjust = Helpers::findTermToAdjust (newTerm.get(), false); 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); - 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); else return Expression (targetValue); diff --git a/modules/juce_core/misc/juce_StdFunctionCompat.cpp b/modules/juce_core/misc/juce_StdFunctionCompat.cpp index bb266491e0..eb6a1f62ef 100644 --- a/modules/juce_core/misc/juce_StdFunctionCompat.cpp +++ b/modules/juce_core/misc/juce_StdFunctionCompat.cpp @@ -66,7 +66,7 @@ namespace FunctionTestsHelpers FunctionObject (const FunctionObject& other) { - bigData = new BigData (*other.bigData); + bigData.reset (new BigData (*other.bigData)); } int operator()(int i) const { return bigData->sum() + i; } diff --git a/modules/juce_core/native/juce_mac_Network.mm b/modules/juce_core/native/juce_mac_Network.mm index d5c6b247ab..4d16ae8fac 100644 --- a/modules/juce_core/native/juce_mac_Network.mm +++ b/modules/juce_core/native/juce_mac_Network.mm @@ -1118,7 +1118,7 @@ private: [req addValue: juceStringToNS (value) forHTTPHeaderField: juceStringToNS (key)]; } - connection = new URLConnectionState (req, numRedirectsToFollow); + connection.reset (new URLConnectionState (req, numRedirectsToFollow)); } } diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h index 0823fecd99..00c25ad164 100644 --- a/modules/juce_core/native/juce_posix_SharedCode.h +++ b/modules/juce_core/native/juce_posix_SharedCode.h @@ -1257,7 +1257,7 @@ bool ChildProcess::start (const StringArray& args, int streamFlags) if (args.size() == 0) return false; - activeProcess = new ActiveProcess (args, streamFlags); + activeProcess.reset (new ActiveProcess (args, streamFlags)); if (activeProcess->childPID == 0) activeProcess.reset(); diff --git a/modules/juce_core/network/juce_URL.cpp b/modules/juce_core/network/juce_URL.cpp index 27d5836ac7..871bd1150f 100644 --- a/modules/juce_core/network/juce_URL.cpp +++ b/modules/juce_core/network/juce_URL.cpp @@ -118,9 +118,11 @@ URL::DownloadTask* URL::DownloadTask::createFallbackDownloader (const URL& urlTo const size_t bufferSize = 0x8000; targetFileToUse.deleteFile(); - if (ScopedPointer outputStream = targetFileToUse.createOutputStream (bufferSize)) + ScopedPointer outputStream (targetFileToUse.createOutputStream (bufferSize)); + + if (outputStream != nullptr) { - ScopedPointer stream = new WebInputStream (urlToUse, usePostRequest); + ScopedPointer stream (new WebInputStream (urlToUse, usePostRequest)); stream->withExtraHeaders (extraHeadersToUse); if (stream->connect (nullptr)) @@ -650,10 +652,9 @@ InputStream* URL::createInputStream (const bool usePostCommand, ScopedPointer 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) {} @@ -670,7 +671,7 @@ InputStream* URL::createInputStream (const bool usePostCommand, ProgressCallbackCaller& operator= (const ProgressCallbackCaller&) { jassertfalse; return *this; } }; - ScopedPointer callbackCaller = + ScopedPointer callbackCaller (progressCallback != nullptr ? new ProgressCallbackCaller (progressCallback, progressCallbackContext) : nullptr); if (headers.isNotEmpty()) @@ -684,7 +685,7 @@ InputStream* URL::createInputStream (const bool usePostCommand, wi->withNumRedirectsToFollow (numRedirectsToFollow); - bool success = wi->connect (callbackCaller); + bool success = wi->connect (callbackCaller.get()); if (statusCode != nullptr) *statusCode = wi->getStatusCode(); diff --git a/modules/juce_core/text/juce_LocalisedStrings.cpp b/modules/juce_core/text/juce_LocalisedStrings.cpp index 4dacb5f270..0ecfcb310e 100644 --- a/modules/juce_core/text/juce_LocalisedStrings.cpp +++ b/modules/juce_core/text/juce_LocalisedStrings.cpp @@ -44,7 +44,7 @@ LocalisedStrings& LocalisedStrings::operator= (const LocalisedStrings& other) languageName = other.languageName; countryCodes = other.countryCodes; translations = other.translations; - fallback = createCopyIfNotNull (other.fallback.get()); + fallback.reset (createCopyIfNotNull (other.fallback.get())); return *this; } @@ -171,19 +171,19 @@ void LocalisedStrings::addStrings (const LocalisedStrings& other) void LocalisedStrings::setFallback (LocalisedStrings* f) { - fallback = f; + fallback.reset (f); } //============================================================================== void LocalisedStrings::setCurrentMappings (LocalisedStrings* newTranslations) { const SpinLock::ScopedLockType sl (currentMappingsLock); - currentMappings = newTranslations; + currentMappings.reset (newTranslations); } LocalisedStrings* LocalisedStrings::getCurrentMappings() { - return currentMappings; + return currentMappings.get(); } String LocalisedStrings::translateWithCurrentMappings (const String& text) { return juce::translate (text); } diff --git a/modules/juce_core/xml/juce_XmlDocument.cpp b/modules/juce_core/xml/juce_XmlDocument.cpp index f07fdb6f0b..59217e1bda 100644 --- a/modules/juce_core/xml/juce_XmlDocument.cpp +++ b/modules/juce_core/xml/juce_XmlDocument.cpp @@ -40,25 +40,25 @@ XmlElement* XmlDocument::parse (const String& xmlData) 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; } namespace XmlIdentifierChars { - static bool isIdentifierCharSlow (const juce_wchar c) noexcept + static bool isIdentifierCharSlow (juce_wchar c) noexcept { return CharacterFunctions::isLetterOrDigit (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 }; @@ -93,7 +93,9 @@ XmlElement* XmlDocument::getDocumentElement (const bool onlyReadOuterDocumentEle { if (originalText.isEmpty() && inputSource != nullptr) { - if (ScopedPointer in = inputSource->createInputStream()) + ScopedPointer in (inputSource->createInputStream()); + + if (in != nullptr) { MemoryOutputStream data; 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 { if (inputSource != nullptr) - if (ScopedPointer in = inputSource->createInputStreamFor (filename.trim().unquoted())) + { + ScopedPointer in (inputSource->createInputStreamFor (filename.trim().unquoted())); + + if (in != nullptr) return in->readEntireStreamAsString(); + } return {}; } diff --git a/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp b/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp index 72a18ff20f..610b10e341 100644 --- a/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp +++ b/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp @@ -286,7 +286,7 @@ bool GZIPDecompressorInputStream::setPosition (int64 newPos) isEof = false; activeBufferSize = 0; currentPos = 0; - helper = new GZIPDecompressHelper (format); + helper.reset (new GZIPDecompressHelper (format)); sourceStream->setPosition (originalSourcePos); } diff --git a/modules/juce_core/zip/juce_ZipFile.cpp b/modules/juce_core/zip/juce_ZipFile.cpp index d41e957fa7..c22a35d011 100644 --- a/modules/juce_core/zip/juce_ZipFile.cpp +++ b/modules/juce_core/zip/juce_ZipFile.cpp @@ -128,7 +128,8 @@ struct ZipFile::ZipInputStream : public InputStream { if (zf.inputSource != nullptr) { - inputStream = streamToDelete = file.inputSource->createInputStream(); + streamToDelete.reset (file.inputSource->createInputStream()); + inputStream = streamToDelete.get(); } else { @@ -223,7 +224,7 @@ ZipFile::ZipFile (InputStream* stream, bool deleteStreamWhenDestroyed) : inputStream (stream) { if (deleteStreamWhenDestroyed) - streamToDelete = inputStream; + streamToDelete.reset (inputStream); init(); } @@ -339,7 +340,7 @@ void ZipFile::init() if (inputSource != nullptr) { in = inputSource->createInputStream(); - toDelete = in; + toDelete.reset (in); } if (in != nullptr) @@ -516,7 +517,7 @@ private: { if (stream == nullptr) { - stream = file.createInputStream(); + stream.reset (file.createInputStream()); if (stream == nullptr) return false; diff --git a/modules/juce_data_structures/values/juce_ValueTree.cpp b/modules/juce_data_structures/values/juce_ValueTree.cpp index 54898e0357..56c64fc6b5 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.cpp +++ b/modules/juce_data_structures/values/juce_ValueTree.cpp @@ -982,7 +982,9 @@ ValueTree ValueTree::fromXml (const XmlElement& xml) String ValueTree::toXmlString() const { - if (ScopedPointer xml = createXml()) + ScopedPointer xml (createXml()); + + if (xml != nullptr) return xml->createDocument ({}); return {}; @@ -1142,7 +1144,7 @@ public: ScopedPointer xml1 (v1.createXml()); ScopedPointer xml2 (v2.createCopy().createXml()); - expect (xml1->isEquivalentTo (xml2, false)); + expect (xml1->isEquivalentTo (xml2.get(), false)); auto v4 = v2.createCopy(); expect (v1.isEquivalentTo (v4)); diff --git a/modules/juce_graphics/colour/juce_FillType.cpp b/modules/juce_graphics/colour/juce_FillType.cpp index 49111f1988..aa586cf07f 100644 --- a/modules/juce_graphics/colour/juce_FillType.cpp +++ b/modules/juce_graphics/colour/juce_FillType.cpp @@ -54,7 +54,7 @@ FillType::FillType (const Image& im, const AffineTransform& t) noexcept FillType::FillType (const FillType& other) : colour (other.colour), - gradient (other.gradient.createCopy()), + gradient (createCopyIfNotNull (other.gradient.get())), image (other.image), transform (other.transform) { @@ -65,7 +65,7 @@ FillType& FillType::operator= (const FillType& other) if (this != &other) { colour = other.colour; - gradient.reset (other.gradient.createCopy()); + gradient.reset (createCopyIfNotNull (other.gradient.get())); image = other.image; transform = other.transform; } diff --git a/modules/juce_graphics/native/juce_RenderingHelpers.h b/modules/juce_graphics/native/juce_RenderingHelpers.h index cf834201e6..7b04700eee 100644 --- a/modules/juce_graphics/native/juce_RenderingHelpers.h +++ b/modules/juce_graphics/native/juce_RenderingHelpers.h @@ -2661,10 +2661,10 @@ public: 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; } void save() @@ -2693,7 +2693,7 @@ public: void endTransparencyLayer() { - const ScopedPointer finishedTransparencyLayer (currentState); + ScopedPointer finishedTransparencyLayer (currentState.release()); restore(); currentState->endTransparencyLayer (*finishedTransparencyLayer); } diff --git a/modules/juce_gui_basics/buttons/juce_Button.cpp b/modules/juce_gui_basics/buttons/juce_Button.cpp index b5b2399243..65684a2d3d 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.cpp +++ b/modules/juce_gui_basics/buttons/juce_Button.cpp @@ -79,7 +79,7 @@ Button::Button (const String& name) : Component (name), text (name) callbackHelper.reset (new CallbackHelper (*this)); setWantsKeyboardFocus (true); - isOn.addListener (callbackHelper); + isOn.addListener (callbackHelper.get()); } Button::~Button() @@ -87,9 +87,9 @@ Button::~Button() clearShortcuts(); if (commandManagerToUse != nullptr) - commandManagerToUse->removeListener (callbackHelper); + commandManagerToUse->removeListener (callbackHelper.get()); - isOn.removeListener (callbackHelper); + isOn.removeListener (callbackHelper.get()); callbackHelper.reset(); } @@ -509,12 +509,12 @@ void Button::parentHierarchyChanged() if (newKeySource != keySource.get()) { if (keySource != nullptr) - keySource->removeKeyListener (callbackHelper); + keySource->removeKeyListener (callbackHelper.get()); keySource = newKeySource; 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 != nullptr) - commandManagerToUse->removeListener (callbackHelper); + commandManagerToUse->removeListener (callbackHelper.get()); commandManagerToUse = newCommandManager; if (commandManagerToUse != nullptr) - commandManagerToUse->addListener (callbackHelper); + commandManagerToUse->addListener (callbackHelper.get()); // 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 diff --git a/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp b/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp index 584ff761dd..a429db4800 100644 --- a/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp @@ -137,8 +137,8 @@ void DrawableButton::buttonStateChanged() } else { - imageToDraw = getToggleState() ? disabledImageOn - : disabledImage; + imageToDraw = getToggleState() ? disabledImageOn.get() + : disabledImage.get(); if (imageToDraw == nullptr) { @@ -201,19 +201,19 @@ Drawable* DrawableButton::getCurrentImage() 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 { 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 diff --git a/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp b/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp index d4f60ac8c0..172c5194f3 100644 --- a/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp @@ -101,9 +101,9 @@ Drawable* ToolbarButton::getImageToUse() const return nullptr; if (getToggleState() && toggledOnImage != nullptr) - return toggledOnImage; + return toggledOnImage.get(); - return normalImage; + return normalImage.get(); } void ToolbarButton::buttonStateChanged() diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index 1caa9e8651..ba0cf99e4a 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -830,7 +830,7 @@ private: void Component::setCachedComponentImage (CachedComponentImage* newCachedImage) { - if (cachedImage != newCachedImage) + if (cachedImage.get() != newCachedImage) { cachedImage.reset (newCachedImage); 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 { - return positioner; + return positioner.get(); } void Component::setPositioner (Positioner* newPositioner) @@ -2775,7 +2774,9 @@ void Component::moveKeyboardFocusToSibling (bool moveToNext) if (parentComponent != nullptr) { - if (ScopedPointer traverser = createFocusTraverser()) + ScopedPointer traverser (createFocusTraverser()); + + if (traverser != nullptr) { auto* nextComp = moveToNext ? traverser->getNextComponent (this) : traverser->getPreviousComponent (this); diff --git a/modules/juce_gui_basics/components/juce_Desktop.cpp b/modules/juce_gui_basics/components/juce_Desktop.cpp index e21dbd4e3e..fe7f2cbc11 100644 --- a/modules/juce_gui_basics/components/juce_Desktop.cpp +++ b/modules/juce_gui_basics/components/juce_Desktop.cpp @@ -96,7 +96,7 @@ LookAndFeel& Desktop::getDefaultLookAndFeel() noexcept if (defaultLookAndFeel == nullptr) defaultLookAndFeel.reset (new LookAndFeel_V4()); - currentLookAndFeel = defaultLookAndFeel; + currentLookAndFeel = defaultLookAndFeel.get(); } return *currentLookAndFeel; diff --git a/modules/juce_gui_basics/components/juce_Desktop.h b/modules/juce_gui_basics/components/juce_Desktop.h index ea0aa61ba4..4d7964ae14 100644 --- a/modules/juce_gui_basics/components/juce_Desktop.h +++ b/modules/juce_gui_basics/components/juce_Desktop.h @@ -373,13 +373,13 @@ public: #ifndef DOXYGEN /** @internal */ void refresh(); + /** @internal */ + ~Displays(); #endif private: friend class Desktop; - friend struct ContainerDeletePolicy; Displays (Desktop&); - ~Displays(); void init (Desktop&); void findDisplays (float masterScale); diff --git a/modules/juce_gui_basics/drawables/juce_Drawable.cpp b/modules/juce_gui_basics/drawables/juce_Drawable.cpp index 84d048d589..4cda296fae 100644 --- a/modules/juce_gui_basics/drawables/juce_Drawable.cpp +++ b/modules/juce_gui_basics/drawables/juce_Drawable.cpp @@ -109,7 +109,7 @@ DrawableComposite* Drawable::getParent() const void Drawable::setClipPath (Drawable* clipPath) { - if (drawableClipPath != clipPath) + if (drawableClipPath.get() != clipPath) { drawableClipPath.reset (clipPath); repaint(); diff --git a/modules/juce_gui_basics/drawables/juce_SVGParser.cpp b/modules/juce_gui_basics/drawables/juce_SVGParser.cpp index 848432daaf..72bfa8a5b8 100644 --- a/modules/juce_gui_basics/drawables/juce_SVGParser.cpp +++ b/modules/juce_gui_basics/drawables/juce_SVGParser.cpp @@ -1711,8 +1711,8 @@ Drawable* Drawable::createFromSVGFile (const File& svgFile) 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)); } } diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp index a9ea7ddd88..a4a2c186e4 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp @@ -334,15 +334,15 @@ FilePreviewComponent* FileBrowserComponent::getPreviewComponent() const noexcept DirectoryContentsDisplayComponent* FileBrowserComponent::getDisplayComponent() const noexcept { - return fileListComponent; + return fileListComponent.get(); } //============================================================================== void FileBrowserComponent::resized() { getLookAndFeel() - .layoutFileBrowserComponent (*this, fileListComponent, previewComp, - ¤tPathBox, &filenameBox, goUpButton); + .layoutFileBrowserComponent (*this, fileListComponent.get(), previewComp, + ¤tPathBox, &filenameBox, goUpButton.get()); } //============================================================================== diff --git a/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp index c61b664613..9ba22184bc 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp @@ -68,7 +68,7 @@ void FilenameComponent::paintOverChildren (Graphics& g) void FilenameComponent::resized() { - getLookAndFeel().layoutFilenameComponent (*this, &filenameBox, browseButton); + getLookAndFeel().layoutFilenameComponent (*this, &filenameBox, browseButton.get()); } KeyboardFocusTraverser* FilenameComponent::createFocusTraverser() diff --git a/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp b/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp index 6225a6fb42..68b500452f 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp @@ -68,8 +68,8 @@ public: bool useTimeslice (const int elapsed) { - if (auto* c = proxy != nullptr ? static_cast (proxy) - : static_cast (component)) + if (auto* c = proxy != nullptr ? proxy.get() + : component.get()) { msElapsed += elapsed; double newProgress = msElapsed / (double) msTotal; diff --git a/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp b/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp index 7a569a7f7f..603e2f1fb7 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp @@ -114,7 +114,7 @@ ComponentBuilder::~ComponentBuilder() #if JUCE_DEBUG // Don't delete the managed component!! The builder owns that component, and will delete // it automatically when it gets deleted. - jassert (componentRef.get() == static_cast (component)); + jassert (componentRef.get() == component.get()); #endif } @@ -125,11 +125,11 @@ Component* ComponentBuilder::getManagedComponent() component.reset (createComponent()); #if JUCE_DEBUG - componentRef = component; + componentRef = component.get(); #endif } - return component; + return component.get(); } Component* ComponentBuilder::createComponent() diff --git a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp index 35b25b8faf..67ee6cb1ef 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp +++ b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp @@ -152,7 +152,7 @@ void TabBarButton::setExtraComponent (Component* comp, ExtraComponentPlacement p void TabBarButton::childBoundsChanged (Component* c) { - if (c == extraComponent) + if (c == extraComponent.get()) { owner.resized(); resized(); @@ -263,7 +263,7 @@ void TabbedButtonBar::addTab (const String& tabName, tabs.insert (insertIndex, newTab); currentTabIndex = tabs.indexOf (currentTab); - addAndMakeVisible (newTab->button, insertIndex); + addAndMakeVisible (newTab->button.get(), insertIndex); resized(); @@ -358,7 +358,7 @@ void TabbedButtonBar::setCurrentTabIndex (int newIndex, bool shouldSendChangeMes TabBarButton* TabbedButtonBar::getTabButton (const int index) const { if (auto* tab = tabs[index]) - return static_cast (tab->button); + return static_cast (tab->button.get()); return nullptr; } @@ -366,7 +366,7 @@ TabBarButton* TabbedButtonBar::getTabButton (const int index) const int TabbedButtonBar::indexOfTabButton (const TabBarButton* button) const { for (int i = tabs.size(); --i >= 0;) - if (tabs.getUnchecked(i)->button == button) + if (tabs.getUnchecked(i)->button.get() == button) return i; return -1; @@ -435,7 +435,8 @@ void TabbedButtonBar::updateTabPositions (bool animate) { if (extraTabsButton == nullptr) { - addAndMakeVisible (extraTabsButton = lf.createTabBarExtrasButton()); + extraTabsButton.reset (lf.createTabBarExtrasButton()); + addAndMakeVisible (extraTabsButton.get()); extraTabsButton->setAlwaysOnTop (true); extraTabsButton->setTriggeredOnMouseDown (true); extraTabsButton->onClick = [this] { showExtraItemsMenu(); }; @@ -569,7 +570,7 @@ void TabbedButtonBar::showExtraItemsMenu() 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)); } diff --git a/modules/juce_gui_basics/layout/juce_Viewport.cpp b/modules/juce_gui_basics/layout/juce_Viewport.cpp index e34e1c0908..a74ee35f47 100644 --- a/modules/juce_gui_basics/layout/juce_Viewport.cpp +++ b/modules/juce_gui_basics/layout/juce_Viewport.cpp @@ -291,7 +291,7 @@ void Viewport::setScrollOnDragEnabled (bool shouldScrollOnDrag) if (isScrollOnDragEnabled() != shouldScrollOnDrag) { if (shouldScrollOnDrag) - dragToScrollListener = new DragToScrollListener (*this); + dragToScrollListener.reset (new DragToScrollListener (*this)); else dragToScrollListener.reset(); } @@ -490,13 +490,13 @@ int Viewport::getScrollBarThickness() const 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()); } - else if (scrollBarThatHasMoved == verticalScrollBar) + else if (scrollBarThatHasMoved == verticalScrollBar.get()) { setViewPosition (getViewPositionX(), newRangeStartInt); } diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp index 63418a81c7..baaa30dd2a 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp @@ -2623,7 +2623,7 @@ void LookAndFeel_V2::layoutFileBrowserComponent (FileBrowserComponent& browserCo //============================================================================== static Drawable* createDrawableFromSVG (const char* data) { - ScopedPointer xml = XmlDocument::parse (data); + ScopedPointer xml (XmlDocument::parse (data)); jassert (xml != nullptr); return Drawable::createFromSVG (*xml); } @@ -2631,7 +2631,7 @@ static Drawable* createDrawableFromSVG (const char* data) const Drawable* LookAndFeel_V2::getDefaultFolderImage() { if (folderImage == nullptr) - folderImage = createDrawableFromSVG (R"svgdata( + folderImage.reset (createDrawableFromSVG (R"svgdata( @@ -2646,22 +2646,22 @@ const Drawable* LookAndFeel_V2::getDefaultFolderImage() -)svgdata"); +)svgdata")); - return folderImage; + return folderImage.get(); } const Drawable* LookAndFeel_V2::getDefaultDocumentFileImage() { if (documentImage == nullptr) - documentImage = createDrawableFromSVG (R"svgdata( + documentImage.reset (createDrawableFromSVG (R"svgdata( -)svgdata"); +)svgdata")); - return documentImage; + return documentImage.get(); } //============================================================================== diff --git a/modules/juce_gui_basics/menus/juce_BurgerMenuComponent.cpp b/modules/juce_gui_basics/menus/juce_BurgerMenuComponent.cpp index 070b45d0d0..8a3e5cacc2 100644 --- a/modules/juce_gui_basics/menus/juce_BurgerMenuComponent.cpp +++ b/modules/juce_gui_basics/menus/juce_BurgerMenuComponent.cpp @@ -181,7 +181,7 @@ void BurgerMenuComponent::paintListBoxItem (int rowIndex, Graphics& g, int w, in hasSubMenu (item), item.text, item.shortcutKeyDescription, - item.image, + item.image.get(), colour); } } diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 123cecd95c..ca010c074c 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -120,7 +120,7 @@ struct ItemComponent : public Component hasSubMenu (item), item.text, item.shortcutKeyDescription, - item.image, + item.image.get(), getColour (item)); } @@ -561,7 +561,7 @@ public: if (mw == window) return true; - mw = mw->activeSubMenu; + mw = mw->activeSubMenu.get(); } return false; @@ -1843,7 +1843,7 @@ bool PopupMenu::MenuItemIterator::next() if (searchRecursively && currentItem->subMenu != nullptr) { index.add (0); - menus.add (currentItem->subMenu); + menus.add (currentItem->subMenu.get()); } else index.setUnchecked (index.size() - 1, index.getLast() + 1); diff --git a/modules/juce_gui_basics/native/juce_mac_FileChooser.mm b/modules/juce_gui_basics/native/juce_mac_FileChooser.mm index 85389dd2d4..853687b8ba 100644 --- a/modules/juce_gui_basics/native/juce_mac_FileChooser.mm +++ b/modules/juce_gui_basics/native/juce_mac_FileChooser.mm @@ -78,7 +78,7 @@ public: delegate = [cls.createInstance() init]; object_setInstanceVariable (delegate, "cppObject", this); - [panel setDelegate:delegate]; + [panel setDelegate: delegate]; filters.addTokens (owner.filters.replaceCharacters (",:", ";;"), ";", String()); filters.trim(); @@ -150,10 +150,9 @@ public: } [panel close]; + [panel release]; } - panel.reset(); - if (delegate != nil) { [delegate release]; @@ -292,7 +291,7 @@ private: NSView* nsViewPreview = nullptr; bool selectsDirectories, selectsFiles, isSave, selectMultiple; - ScopedPointer panel; + NSSavePanel* panel; DelegateType* delegate; StringArray filters; diff --git a/modules/juce_gui_basics/native/juce_mac_MainMenu.mm b/modules/juce_gui_basics/native/juce_mac_MainMenu.mm index 513839b7a2..c27a419196 100644 --- a/modules/juce_gui_basics/native/juce_mac_MainMenu.mm +++ b/modules/juce_gui_basics/native/juce_mac_MainMenu.mm @@ -612,7 +612,7 @@ public: ~TemporaryMainMenuWithStandardCommands() { - MenuBarModel::setMacMainMenu (oldMenu, oldAppleMenu, oldRecentItems); + MenuBarModel::setMacMainMenu (oldMenu, oldAppleMenu.get(), oldRecentItems); } private: diff --git a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp index d41bf7a8e1..81ce960ec5 100644 --- a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp @@ -200,7 +200,8 @@ Value& TextPropertyComponent::getValue() const 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) { diff --git a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp index c47a37106a..f88bcd48df 100644 --- a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp @@ -418,10 +418,10 @@ void ComboBox::lookAndFeelChanged() newLabel->setText (label->getText(), dontSendNotification); } - label = newLabel; + std::swap (label, newLabel); } - addAndMakeVisible (label); + addAndMakeVisible (label.get()); EditableState newEditableState = (label->isEditable() ? labelIsEditable : labelIsNotEditable); diff --git a/modules/juce_gui_basics/widgets/juce_Label.cpp b/modules/juce_gui_basics/widgets/juce_Label.cpp index 8dc76dff6a..1d1f66a70e 100644 --- a/modules/juce_gui_basics/widgets/juce_Label.cpp +++ b/modules/juce_gui_basics/widgets/juce_Label.cpp @@ -221,7 +221,7 @@ void Label::showEditor() resized(); repaint(); - editorShown (editor); + editorShown (editor.get()); enterModalState (false); editor->grabKeyboardFocus(); @@ -254,9 +254,10 @@ void Label::hideEditor (bool discardCurrentEditorContents) if (editor != nullptr) { WeakReference deletionChecker (this); - ScopedPointer outgoingEditor (editor); + ScopedPointer outgoingEditor; + std::swap (outgoingEditor, editor); - editorAboutToBeHidden (outgoingEditor); + editorAboutToBeHidden (outgoingEditor.get()); const bool changed = (! discardCurrentEditorContents) && updateFromTextEditorContents (*outgoingEditor); @@ -311,7 +312,7 @@ TextEditor* Label::createEditorComponent() TextEditor* Label::getCurrentTextEditor() const noexcept { - return editor; + return editor.get(); } //============================================================================== @@ -410,7 +411,7 @@ void Label::textEditorTextChanged (TextEditor& ed) { if (editor != nullptr) { - jassert (&ed == editor); + jassert (&ed == editor.get()); if (! (hasKeyboardFocus (true) || isCurrentlyBlockedByAnotherModalComponent())) { @@ -426,7 +427,7 @@ void Label::textEditorReturnKeyPressed (TextEditor& ed) { if (editor != nullptr) { - jassert (&ed == editor); + jassert (&ed == editor.get()); WeakReference deletionChecker (this); bool changed = updateFromTextEditorContents (ed); @@ -446,7 +447,7 @@ void Label::textEditorEscapeKeyPressed (TextEditor& ed) { if (editor != nullptr) { - jassert (&ed == editor); + jassert (&ed == editor.get()); ignoreUnused (ed); editor->setText (textValue.toString(), false); diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/modules/juce_gui_basics/widgets/juce_ListBox.cpp index 79e86b930c..1130dc4f0e 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -52,11 +52,11 @@ public: { setMouseCursor (m->getMouseCursorForRow (row)); - customComponent = m->refreshComponentForRow (newRow, nowSelected, customComponent.release()); + customComponent.reset (m->refreshComponentForRow (newRow, nowSelected, customComponent.release())); if (customComponent != nullptr) { - addAndMakeVisible (customComponent); + addAndMakeVisible (customComponent.get()); customComponent->setBounds (getLocalBounds()); } } @@ -452,7 +452,7 @@ void ListBox::visibilityChanged() 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 { if (auto* listRowComp = viewport->getComponentForRowIfOnscreen (row)) - return listRowComp->customComponent; + return listRowComp->customComponent.get(); return nullptr; } @@ -850,18 +850,17 @@ void ListBox::parentHierarchyChanged() colourChanged(); } -void ListBox::setOutlineThickness (const int newThickness) +void ListBox::setOutlineThickness (int newThickness) { outlineThickness = newThickness; resized(); } -void ListBox::setHeaderComponent (Component* const newHeaderComponent) +void ListBox::setHeaderComponent (Component* newHeaderComponent) { - if (headerComponent != newHeaderComponent) + if (headerComponent.get() != newHeaderComponent) { headerComponent.reset (newHeaderComponent); - addAndMakeVisible (newHeaderComponent); ListBox::resized(); } diff --git a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp index 3201617690..db60622fd4 100644 --- a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp +++ b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp @@ -695,7 +695,8 @@ void TableHeaderComponent::beginDrag (const MouseEvent& e) auto temp = columnIdBeingDragged; columnIdBeingDragged = 0; - addAndMakeVisible (dragOverlayComp = new DragOverlayComp (createComponentSnapshot (columnRect, false))); + dragOverlayComp.reset (new DragOverlayComp (createComponentSnapshot (columnRect, false))); + addAndMakeVisible (dragOverlayComp.get()); columnIdBeingDragged = temp; dragOverlayComp->setBounds (columnRect); diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index 13f4f88fad..08cbc900ae 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -880,7 +880,8 @@ TextEditor::TextEditor (const String& name, juce_wchar passwordChar) { setMouseCursor (MouseCursor::IBeamCursor); - addAndMakeVisible (viewport = new TextEditorViewport (*this)); + viewport.reset (new TextEditorViewport (*this)); + addAndMakeVisible (viewport.get()); viewport->setViewedComponent (textHolder = new TextHolderComponent (*this)); viewport->setWantsKeyboardFocus (false); viewport->setScrollBarsShown (false, false); @@ -1082,7 +1083,8 @@ void TextEditor::recreateCaret() { if (caret == nullptr) { - textHolder->addChildComponent (caret = getLookAndFeel().createCaretComponent (this)); + caret.reset (getLookAndFeel().createCaretComponent (this)); + textHolder->addChildComponent (caret.get()); updateCaretPosition(); } } diff --git a/modules/juce_gui_basics/widgets/juce_Toolbar.cpp b/modules/juce_gui_basics/widgets/juce_Toolbar.cpp index b1f2c19e4d..f29b54c82e 100644 --- a/modules/juce_gui_basics/widgets/juce_Toolbar.cpp +++ b/modules/juce_gui_basics/widgets/juce_Toolbar.cpp @@ -543,7 +543,7 @@ void Toolbar::showMissingItems() { PopupMenu m; m.addCustomItem (1, new MissingItemsComponent (*this, getThickness())); - m.showMenuAsync (PopupMenu::Options().withTargetComponent (missingItemsButton), nullptr); + m.showMenuAsync (PopupMenu::Options().withTargetComponent (missingItemsButton.get()), nullptr); } } diff --git a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp index 3345ff5ebf..d6e792ad2c 100644 --- a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp +++ b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp @@ -173,9 +173,9 @@ void ToolbarItemComponent::paintButton (Graphics& g, const bool over, const bool 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) { @@ -212,7 +212,7 @@ void ToolbarItemComponent::resized() } else { - contentArea = Rectangle(); + contentArea = {}; } contentAreaChanged (contentArea); @@ -231,7 +231,8 @@ void ToolbarItemComponent::setEditingMode (const ToolbarEditingMode newMode) } else if (overlayComp == nullptr) { - addAndMakeVisible (overlayComp = new ItemDragAndDropOverlayComponent()); + overlayComp.reset (new ItemDragAndDropOverlayComponent()); + addAndMakeVisible (overlayComp.get()); overlayComp->parentSizeChanged(); } diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.cpp b/modules/juce_gui_basics/widgets/juce_TreeView.cpp index e2551fe8ae..48e2da07de 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.cpp +++ b/modules/juce_gui_basics/widgets/juce_TreeView.cpp @@ -440,7 +440,7 @@ TreeView::TreeView (const String& name) : Component (name), viewport (new TreeViewport()) { - addAndMakeVisible (viewport); + addAndMakeVisible (viewport.get()); viewport->setViewedComponent (new ContentComponent (*this)); setWantsKeyboardFocus (true); } @@ -547,7 +547,7 @@ void TreeView::setOpenCloseButtonsVisible (const bool shouldBeVisible) Viewport* TreeView::getViewport() const noexcept { - return viewport; + return viewport.get(); } //============================================================================== diff --git a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp index 79eb5f5cc9..ab6372054e 100644 --- a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp @@ -68,10 +68,10 @@ DocumentWindow::~DocumentWindow() // 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 // 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) b.reset(); @@ -140,7 +140,7 @@ void DocumentWindow::setMenuBar (MenuBarModel* newMenuBarModel, const int newMen Component* DocumentWindow::getMenuBarComponent() const noexcept { - return menuBar; + return menuBar.get(); } void DocumentWindow::setMenuBarComponent (Component* newMenuBarComponent) @@ -229,9 +229,9 @@ void DocumentWindow::resized() .positionDocumentWindowButtons (*this, titleBarArea.getX(), titleBarArea.getY(), titleBarArea.getWidth(), titleBarArea.getHeight(), - titleBarButtons[0], - titleBarButtons[1], - titleBarButtons[2], + titleBarButtons[0].get(), + titleBarButtons[1].get(), + titleBarButtons[2].get(), positionTitleBarButtonsOnLeft); if (menuBar != nullptr) @@ -270,9 +270,9 @@ Rectangle DocumentWindow::getTitleBarArea() 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 { @@ -305,11 +305,11 @@ void DocumentWindow::lookAndFeelChanged() if (buttonListener == nullptr) buttonListener.reset (new ButtonListenerProxy (*this)); - b->addListener (buttonListener); + b->addListener (buttonListener.get()); b->setWantsKeyboardFocus (false); // (call the Component method directly to avoid the assertion in ResizableWindow) - Component::addAndMakeVisible (b); + Component::addAndMakeVisible (b.get()); } } diff --git a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp index f3d7d2a151..6123b577ea 100644 --- a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp @@ -47,8 +47,8 @@ ResizableWindow::~ResizableWindow() // 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 // 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(); resizableBorder.reset(); diff --git a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp index fd5ce3e20f..b03dd7f7b8 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp +++ b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp @@ -367,14 +367,14 @@ CodeEditorComponent::CodeEditorComponent (CodeDocument& doc, CodeTokeniser* cons 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() { - document.removeListener (pimpl); + document.removeListener (pimpl.get()); } int CodeEditorComponent::getGutterSize() const noexcept diff --git a/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp b/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp index 64aee6d07a..b373f4d756 100644 --- a/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp +++ b/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp @@ -126,7 +126,7 @@ void PreferencesPanel::setCurrentPage (const String& pageName) if (currentPage != nullptr) { - addAndMakeVisible (currentPage); + addAndMakeVisible (currentPage.get()); currentPage->toBack(); resized(); } diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp index d9bf013573..f629d608c9 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp @@ -76,11 +76,11 @@ public: : ThreadPoolJob ("OpenGL Rendering"), 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()) - context.nativeContext = nativeContext; + context.nativeContext = nativeContext.get(); else nativeContext.reset(); } @@ -95,7 +95,7 @@ public: { if (nativeContext != nullptr) { - renderThread = new ThreadPool (1); + renderThread.reset (new ThreadPool (1)); resume(); } } @@ -886,7 +886,7 @@ void OpenGLContext::attachTo (Component& component) if (getTargetComponent() != &component) { detach(); - attachment = new Attachment (*this, component); + attachment.reset (new Attachment (*this, component)); } } diff --git a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp index 6ce8d9c6d2..49ee9c0ba3 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp @@ -202,7 +202,7 @@ bool OpenGLFrameBuffer::initialise (OpenGLContext& context, const Image& image) bool OpenGLFrameBuffer::initialise (OpenGLFrameBuffer& other) { - const Pimpl* const p = other.pimpl; + auto* p = other.pimpl.get(); if (p == nullptr) { @@ -242,7 +242,7 @@ void OpenGLFrameBuffer::saveAndRelease() { if (pimpl != nullptr) { - savedState = new SavedState (*this, pimpl->width, pimpl->height); + savedState.reset (new SavedState (*this, pimpl->width, pimpl->height)); pimpl.reset(); } } @@ -251,12 +251,13 @@ bool OpenGLFrameBuffer::reloadSavedCopy (OpenGLContext& context) { if (savedState != nullptr) { - ScopedPointer state (savedState); + ScopedPointer state; + std::swap (state, savedState); if (state->restore (context, *this)) return true; - savedState = state; + std::swap (state, savedState); } return false; diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index 56a3062ebe..847c17fe30 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -1587,7 +1587,7 @@ struct SavedState : public RenderingHelpers::SavedStateBase SavedState (const SavedState& other) : BaseClass (other), font (other.font), state (other.state), transparencyLayer (other.transparencyLayer), - previousTarget (other.previousTarget.createCopy()) + previousTarget (createCopyIfNotNull (other.previousTarget.get())) {} SavedState* beginTransparencyLayer (float opacity) @@ -1600,7 +1600,7 @@ struct SavedState : public RenderingHelpers::SavedStateBase state->flush(); 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()); s->transparencyLayerAlpha = opacity; s->cloneClipIfMultiplyReferenced(); diff --git a/modules/juce_opengl/opengl/juce_OpenGLImage.cpp b/modules/juce_opengl/opengl/juce_OpenGLImage.cpp index b4deaaf2cd..5396c4f3e7 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLImage.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLImage.cpp @@ -156,8 +156,8 @@ private: 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.lineStride = (bitmapData.width * bitmapData.pixelStride + 3) & ~3; diff --git a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp index aceeb8dafa..bfbec1f76b 100644 --- a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp +++ b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp @@ -54,7 +54,8 @@ struct OnlineUnlockForm::OverlayComp : public Component, if (hasCancelButton) { - addAndMakeVisible (cancelButton = new TextButton (TRANS ("Cancel"))); + cancelButton.reset (new TextButton (TRANS ("Cancel"))); + addAndMakeVisible (cancelButton.get()); cancelButton->addListener (this); } @@ -128,7 +129,7 @@ struct OnlineUnlockForm::OverlayComp : public Component, void buttonClicked (Button* button) override { - if (button == cancelButton) + if (button == cancelButton.get()) { form.status.userCancelled(); @@ -267,8 +268,8 @@ void OnlineUnlockForm::lookAndFeelChanged() void OnlineUnlockForm::showBubbleMessage (const String& text, Component& target) { - bubble = new BubbleMessageComponent (500); - addChildComponent (bubble); + bubble.reset (new BubbleMessageComponent (500)); + addChildComponent (bubble.get()); AttributedString attString; attString.append (text, Font (16.0f)); diff --git a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp index ff83a09ba3..deef12c11e 100644 --- a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp +++ b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp @@ -123,7 +123,7 @@ struct KeyFileUtils const MemoryBlock mb (val.toMemoryBlock()); if (CharPointer_UTF8::isValidString (static_cast (mb.getData()), (int) mb.getSize())) - xml = XmlDocument::parse (mb.toString()); + xml.reset (XmlDocument::parse (mb.toString())); } return xml != nullptr ? *xml : XmlElement("key"); diff --git a/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.cpp b/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.cpp index 3e5ea711b6..8eb80e0539 100644 --- a/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.cpp +++ b/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.cpp @@ -57,7 +57,7 @@ String TracktionMarketplaceStatus::readReplyFromWebserver (const String& email, { ScopedLock lock (streamCreationLock); - stream = new WebInputStream (url, true); + stream.reset (new WebInputStream (url, true)); } if (stream->connect (nullptr)) diff --git a/modules/juce_video/playback/juce_VideoComponent.cpp b/modules/juce_video/playback/juce_VideoComponent.cpp index eae852ebb1..c83fea652a 100644 --- a/modules/juce_video/playback/juce_VideoComponent.cpp +++ b/modules/juce_video/playback/juce_VideoComponent.cpp @@ -36,7 +36,7 @@ namespace juce //============================================================================== VideoComponent::VideoComponent() : pimpl (new Pimpl()) { - addAndMakeVisible (pimpl); + addAndMakeVisible (pimpl.get()); } VideoComponent::~VideoComponent() @@ -46,14 +46,14 @@ VideoComponent::~VideoComponent() Result VideoComponent::load (const File& file) { - Result r = pimpl->load (file); + auto r = pimpl->load (file); resized(); return r; } Result VideoComponent::load (const URL& url) { - Result r = pimpl->load (url); + auto r = pimpl->load (url); resized(); return r; } @@ -86,11 +86,11 @@ float VideoComponent::getAudioVolume() const { return pimpl->getV void VideoComponent::resized() { - Rectangle r = getLocalBounds(); + auto r = getLocalBounds(); if (isVideoOpen() && ! r.isEmpty()) { - Rectangle nativeSize = getVideoNativeSize(); + auto nativeSize = getVideoNativeSize(); if (nativeSize.isEmpty()) {