From 2dc9316420f099a46d3aa3ab04647d47d7b54cfc Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 1 Nov 2017 17:41:06 +0000 Subject: [PATCH] Misc ScopedPointer changes to start using reset() and get() rather than assignments and casts (part of an ongoing drift towards more std::unique_ptr compatibility) --- examples/DSPDemo/Source/Main.cpp | 10 +-- examples/DSPDemo/Source/MainComponent.cpp | 3 +- .../Demo/Source/Demos/AudioLatencyDemo.cpp | 4 +- .../Demo/Source/Demos/AudioPlaybackDemo.cpp | 6 +- .../Demo/Source/Demos/AudioRecordingDemo.cpp | 2 +- .../Demo/Source/Demos/ChildProcessDemo.cpp | 4 +- examples/Demo/Source/Demos/MidiDemo.cpp | 2 +- examples/Demo/Source/Demos/OpenGLDemo.cpp | 14 ++-- examples/Demo/Source/Demos/OpenGLDemo2D.cpp | 6 +- examples/Demo/Source/Demos/UnitTestsDemo.cpp | 2 +- examples/Demo/Source/Demos/XMLandJSONDemo.cpp | 6 +- examples/Demo/Source/Main.cpp | 2 +- examples/Demo/Source/MainWindow.cpp | 10 +-- .../Windows/jucer_AboutWindowComponent.h | 16 ++-- ...ucer_ApplicationUsageDataWindowComponent.h | 6 +- .../jucer_EditorColourSchemeWindowComponent.h | 2 +- .../Windows/jucer_FloatingToolWindow.h | 2 +- .../Source/Application/jucer_Application.cpp | 26 +++--- .../Source/Application/jucer_AutoUpdater.cpp | 20 ++--- .../Source/Application/jucer_CommandLine.cpp | 6 +- .../Source/Application/jucer_MainWindow.cpp | 10 +-- .../Source/Application/jucer_MainWindow.h | 2 +- .../CodeEditor/jucer_ItemPreviewComponent.h | 4 +- .../CodeEditor/jucer_LiveBuildCodeEditor.h | 4 +- .../CodeEditor/jucer_SourceCodeEditor.cpp | 2 +- .../CodeEditor/jucer_SourceCodeEditor.h | 4 +- .../Components/jucer_TabbedComponentHandler.h | 4 +- .../Documents/jucer_ButtonDocument.cpp | 8 +- .../Documents/jucer_ComponentDocument.h | 2 +- .../UI/jucer_JucerDocumentEditor.cpp | 9 +- .../UI/jucer_PaintRoutineEditor.cpp | 6 +- .../UI/jucer_TestComponent.cpp | 2 +- .../ComponentEditor/jucer_BinaryResources.cpp | 2 +- .../ComponentEditor/jucer_ComponentLayout.cpp | 2 +- .../ComponentEditor/jucer_JucerDocument.cpp | 4 +- .../ComponentEditor/jucer_PaintRoutine.cpp | 2 +- .../Licenses/jucer_LicenseController.cpp | 6 +- .../Source/Licenses/jucer_LicenseThread.h | 4 +- .../Source/Licenses/jucer_LicenseWebview.h | 11 ++- .../jucer_CompileEngineClient.cpp | 12 +-- .../jucer_CompileEngineServer.cpp | 2 +- .../UI/Sidebar/jucer_ExporterTreeItems.h | 6 +- .../Project/UI/Sidebar/jucer_TabComponents.h | 8 +- .../UI/jucer_FileGroupInformationComponent.h | 2 +- .../UI/jucer_ProjectContentComponent.cpp | 16 ++-- .../UI/jucer_ProjectContentComponent.h | 2 +- .../Projucer/Source/Project/jucer_Project.cpp | 2 +- .../Projucer/Source/Project/jucer_Project.h | 2 +- .../Source/Settings/jucer_StoredSettings.h | 2 +- .../Utility/UI/jucer_JucerTreeViewBase.cpp | 6 +- .../Utility/UI/jucer_UserSettingsPopup.h | 4 +- .../Wizards/jucer_NewProjectWizardClasses.cpp | 27 +++--- .../Wizards/jucer_NewProjectWizardComponent.h | 2 +- .../jucer_TemplateThumbnailsComponent.h | 2 +- .../audio_io/juce_AudioDeviceManager.cpp | 38 +++++---- .../native/juce_mac_CoreMidi.cpp | 16 ++-- .../codecs/juce_WavAudioFormat.cpp | 6 +- .../format/juce_AudioFormatReader.cpp | 4 +- .../processors/juce_AudioProcessorEditor.cpp | 2 +- .../processors/juce_AudioProcessorGraph.cpp | 4 +- .../scanning/juce_PluginListComponent.cpp | 4 +- .../gui/juce_AudioDeviceSelectorComponent.cpp | 53 ++++++------ .../gui/juce_AudioThumbnail.cpp | 6 +- .../juce_core/containers/juce_OwnedArray.h | 80 +++++++++--------- .../files/juce_DirectoryIterator.cpp | 2 +- .../juce_core/javascript/juce_Javascript.cpp | 2 +- .../memory/juce_OptionalScopedPointer.h | 4 +- modules/juce_core/memory/juce_ScopedPointer.h | 84 ++++++++++++++++--- .../juce_core/misc/juce_StdFunctionCompat.cpp | 12 +-- modules/juce_core/native/juce_mac_Network.mm | 6 +- .../juce_core/native/juce_posix_NamedPipe.cpp | 4 +- .../juce_core/native/juce_posix_SharedCode.h | 6 +- modules/juce_core/zip/juce_ZipFile.cpp | 2 +- .../juce_ApplicationProperties.cpp | 17 ++-- .../juce_ApplicationProperties.h | 2 +- .../app_properties/juce_PropertiesFile.cpp | 2 +- .../undomanager/juce_UndoManager.cpp | 62 ++++++-------- .../undomanager/juce_UndoManager.h | 4 +- .../juce_ConnectedChildProcess.cpp | 10 +-- .../juce_InterprocessConnection.cpp | 8 +- .../juce_InterprocessConnection.h | 4 +- .../juce_InterprocessConnectionServer.cpp | 4 +- .../messages/juce_ApplicationBase.cpp | 6 +- .../messages/juce_MessageManager.cpp | 2 +- .../juce_graphics/colour/juce_FillType.cpp | 18 ++-- .../native/juce_RenderingHelpers.h | 8 +- .../juce_gui_basics/buttons/juce_Button.cpp | 24 +----- modules/juce_gui_basics/buttons/juce_Button.h | 26 +++--- .../juce_ApplicationCommandManager.cpp | 3 +- .../commands/juce_ApplicationCommandManager.h | 4 +- .../components/juce_Component.cpp | 8 +- .../components/juce_Component.h | 2 +- .../drawables/juce_DrawablePath.cpp | 2 +- .../drawables/juce_DrawableShape.cpp | 2 +- .../juce_DirectoryContentsList.cpp | 4 +- .../filebrowser/juce_FileBrowserComponent.cpp | 4 +- .../filebrowser/juce_FilenameComponent.cpp | 2 +- .../layout/juce_ComponentAnimator.cpp | 2 +- .../layout/juce_MultiDocumentPanel.cpp | 4 +- .../layout/juce_MultiDocumentPanel.h | 2 +- .../juce_gui_basics/layout/juce_ScrollBar.cpp | 23 ++--- .../juce_gui_basics/layout/juce_ScrollBar.h | 12 +-- .../layout/juce_TabbedButtonBar.cpp | 8 +- .../layout/juce_TabbedButtonBar.h | 2 +- .../layout/juce_TabbedComponent.cpp | 2 +- .../juce_gui_basics/layout/juce_Viewport.cpp | 6 +- .../juce_gui_basics/menus/juce_PopupMenu.cpp | 8 +- .../misc/juce_JUCESplashScreen.cpp | 2 +- .../native/juce_mac_Windowing.mm | 4 +- .../juce_gui_basics/widgets/juce_ComboBox.cpp | 2 +- .../juce_gui_basics/widgets/juce_Label.cpp | 30 +++---- modules/juce_gui_basics/widgets/juce_Label.h | 18 ++-- .../juce_gui_basics/widgets/juce_ListBox.cpp | 6 +- .../juce_gui_basics/widgets/juce_ListBox.h | 2 +- .../juce_gui_basics/widgets/juce_Slider.cpp | 24 +++--- .../widgets/juce_TableHeaderComponent.cpp | 6 +- .../widgets/juce_TextEditor.cpp | 6 +- .../widgets/juce_ToolbarItemComponent.cpp | 4 +- .../juce_gui_basics/widgets/juce_TreeView.cpp | 4 +- .../windows/juce_DocumentWindow.cpp | 8 +- .../windows/juce_ResizableWindow.cpp | 20 ++--- .../windows/juce_ThreadWithProgressWindow.h | 2 +- .../windows/juce_TopLevelWindow.cpp | 8 +- .../code_editor/juce_CodeEditorComponent.cpp | 8 +- .../misc/juce_KeyMappingEditorComponent.cpp | 6 +- .../misc/juce_PreferencesPanel.cpp | 2 +- .../native/juce_mac_SystemTrayIcon.cpp | 2 +- .../juce_opengl/opengl/juce_OpenGLContext.cpp | 6 +- .../opengl/juce_OpenGLFrameBuffer.cpp | 12 +-- .../opengl/juce_OpenGLGraphicsContext.cpp | 2 +- .../playback/juce_VideoComponent.cpp | 2 +- 131 files changed, 574 insertions(+), 576 deletions(-) diff --git a/examples/DSPDemo/Source/Main.cpp b/examples/DSPDemo/Source/Main.cpp index dad4f3aad7..1520a18057 100644 --- a/examples/DSPDemo/Source/Main.cpp +++ b/examples/DSPDemo/Source/Main.cpp @@ -27,7 +27,7 @@ #include "Main.h" DSPSamplesApplication::DSPSamplesApplication() - : TimeSliceThread ("Audio File Reader Thread"), demoIndex (-1) + : TimeSliceThread ("Audio File Reader Thread") { loopState.addListener (this); } @@ -50,7 +50,7 @@ void DSPSamplesApplication::shutdown() stop(); audioDeviceManager.removeAudioCallback (&audioSourcePlayer); waitForThreadToExit (10000); - mainWindow = nullptr; + mainWindow.reset(); } //============================================================================== @@ -68,8 +68,8 @@ bool DSPSamplesApplication::loadFile (const File& fileToPlay) audioSourcePlayer.setSource (nullptr); mainWindow->setTransportSource (nullptr); - transportSource = nullptr; - readerSource = nullptr; + transportSource.reset(); + readerSource.reset(); reader = formatManager.createReaderFor (fileToPlay); @@ -125,7 +125,7 @@ void DSPSamplesApplication::init() } audioSourcePlayer.setSource (nullptr); - currentDemo = nullptr; + currentDemo.reset(); if (currentDemo == nullptr) if (auto demo = Demo::getList()[demoIndex]) diff --git a/examples/DSPDemo/Source/MainComponent.cpp b/examples/DSPDemo/Source/MainComponent.cpp index 1524501f66..77968ba14b 100644 --- a/examples/DSPDemo/Source/MainComponent.cpp +++ b/examples/DSPDemo/Source/MainComponent.cpp @@ -239,8 +239,7 @@ void MainContentComponent::initParameters() { auto& parameters = DSPSamplesApplication::getApp().getCurrentDemoParameters(); - if (parametersComponent != nullptr) - parametersComponent = nullptr; + parametersComponent.reset(); if (parameters.size() > 0) addAndMakeVisible (parametersComponent = new DemoParametersComponent (parameters)); diff --git a/examples/Demo/Source/Demos/AudioLatencyDemo.cpp b/examples/Demo/Source/Demos/AudioLatencyDemo.cpp index fb0e4041bd..6695e91ec5 100644 --- a/examples/Demo/Source/Demos/AudioLatencyDemo.cpp +++ b/examples/Demo/Source/Demos/AudioLatencyDemo.cpp @@ -328,8 +328,8 @@ public: { MainAppWindow::getSharedAudioDeviceManager().removeAudioCallback (liveAudioScroller); startTestButton.removeListener (this); - latencyTester = nullptr; - liveAudioScroller = nullptr; + latencyTester.reset(); + liveAudioScroller.reset(); } void startTest() diff --git a/examples/Demo/Source/Demos/AudioPlaybackDemo.cpp b/examples/Demo/Source/Demos/AudioPlaybackDemo.cpp index 3ae6e1dca8..57139d7c2d 100644 --- a/examples/Demo/Source/Demos/AudioPlaybackDemo.cpp +++ b/examples/Demo/Source/Demos/AudioPlaybackDemo.cpp @@ -361,11 +361,9 @@ private: // unload the previous file source and delete it.. transportSource.stop(); transportSource.setSource (nullptr); - currentAudioFileSource = nullptr; + currentAudioFileSource.reset(); - AudioFormatReader* reader = formatManager.createReaderFor (audioFile); - - if (reader != nullptr) + if (auto* reader = formatManager.createReaderFor (audioFile)) { currentAudioFileSource = new AudioFormatReaderSource (reader, true); diff --git a/examples/Demo/Source/Demos/AudioRecordingDemo.cpp b/examples/Demo/Source/Demos/AudioRecordingDemo.cpp index 0df121f624..b6990e48fa 100644 --- a/examples/Demo/Source/Demos/AudioRecordingDemo.cpp +++ b/examples/Demo/Source/Demos/AudioRecordingDemo.cpp @@ -95,7 +95,7 @@ public: // Now we can delete the writer object. It's done in this order because the deletion could // take a little time while remaining data gets flushed to disk, so it's best to avoid blocking // the audio callback while this happens. - threadedWriter = nullptr; + threadedWriter.reset(); } bool isRecording() const diff --git a/examples/Demo/Source/Demos/ChildProcessDemo.cpp b/examples/Demo/Source/Demos/ChildProcessDemo.cpp index 18c25341ee..a5dc4156c1 100644 --- a/examples/Demo/Source/Demos/ChildProcessDemo.cpp +++ b/examples/Demo/Source/Demos/ChildProcessDemo.cpp @@ -84,7 +84,7 @@ public: ~ChildProcessDemo() { - masterProcess = nullptr; + masterProcess.reset(); } void paint (Graphics& g) override @@ -134,7 +134,7 @@ public: { if (masterProcess != nullptr) { - masterProcess = nullptr; + masterProcess.reset(); logMessage ("Child process killed"); } } diff --git a/examples/Demo/Source/Demos/MidiDemo.cpp b/examples/Demo/Source/Demos/MidiDemo.cpp index bd1be9d62d..9a8047e0e4 100644 --- a/examples/Demo/Source/Demos/MidiDemo.cpp +++ b/examples/Demo/Source/Demos/MidiDemo.cpp @@ -183,7 +183,7 @@ private: //============================================================================== void setMidiOutput (int index) { - currentMidiOutput = nullptr; + currentMidiOutput.reset(); if (MidiOutput::getDevices() [index].isNotEmpty()) { diff --git a/examples/Demo/Source/Demos/OpenGLDemo.cpp b/examples/Demo/Source/Demos/OpenGLDemo.cpp index 3b866a60c4..a6fabbf974 100644 --- a/examples/Demo/Source/Demos/OpenGLDemo.cpp +++ b/examples/Demo/Source/Demos/OpenGLDemo.cpp @@ -642,10 +642,10 @@ struct OpenGLDemoClasses void freeAllContextObjects() { - shape = nullptr; - shader = nullptr; - attributes = nullptr; - uniforms = nullptr; + shape.reset(); + shader.reset(); + attributes.reset(); + uniforms.reset(); texture.release(); } @@ -832,9 +832,9 @@ struct OpenGLDemoClasses && newShader->addFragmentShader (OpenGLHelpers::translateFragmentShaderToV3 (newFragmentShader)) && newShader->link()) { - shape = nullptr; - attributes = nullptr; - uniforms = nullptr; + shape.reset(); + attributes.reset(); + uniforms.reset(); shader = newShader; shader->use(); diff --git a/examples/Demo/Source/Demos/OpenGLDemo2D.cpp b/examples/Demo/Source/Demos/OpenGLDemo2D.cpp index edae39a45c..b4c5ddef1d 100644 --- a/examples/Demo/Source/Demos/OpenGLDemo2D.cpp +++ b/examples/Demo/Source/Demos/OpenGLDemo2D.cpp @@ -69,7 +69,7 @@ public: ~OpenGL2DShaderDemo() { - shader = nullptr; + shader.reset(); } void paint (Graphics& g) override @@ -78,7 +78,7 @@ public: if (shader == nullptr || shader->getFragmentShaderCode() != fragmentCode) { - shader = nullptr; + shader.reset(); if (fragmentCode.isNotEmpty()) { @@ -89,7 +89,7 @@ public: if (result.failed()) { statusLabel.setText (result.getErrorMessage(), dontSendNotification); - shader = nullptr; + shader.reset(); } } } diff --git a/examples/Demo/Source/Demos/UnitTestsDemo.cpp b/examples/Demo/Source/Demos/UnitTestsDemo.cpp index 6ea7290731..9d7b6991f8 100644 --- a/examples/Demo/Source/Demos/UnitTestsDemo.cpp +++ b/examples/Demo/Source/Demos/UnitTestsDemo.cpp @@ -180,7 +180,7 @@ struct UnitTestClasses if (currentTestThread != nullptr) { currentTestThread->stopThread (15000); - currentTestThread = nullptr; + currentTestThread.reset(); } } diff --git a/examples/Demo/Source/Demos/XMLandJSONDemo.cpp b/examples/Demo/Source/Demos/XMLandJSONDemo.cpp index 72f5053e16..6eae2522cc 100644 --- a/examples/Demo/Source/Demos/XMLandJSONDemo.cpp +++ b/examples/Demo/Source/Demos/XMLandJSONDemo.cpp @@ -296,14 +296,14 @@ private: { // clear the current tree resultsTree.setRootItem (nullptr); - rootItem = nullptr; + rootItem.reset(); // try and parse the editor's contents switch (typeBox.getSelectedItemIndex()) { case xml: rootItem = rebuildXml(); break; case json: rootItem = rebuildJson(); break; - default: rootItem = nullptr; break; + default: rootItem.reset(); break; } // if we have a valid TreeViewItem hide any old error messages and set our TreeView to use it @@ -318,7 +318,7 @@ private: /** Parses the editors contects as XML. */ TreeViewItem* rebuildXml() { - parsedXml = nullptr; + parsedXml.reset(); XmlDocument doc (codeDocument.getAllContent()); parsedXml = doc.getDocumentElement(); diff --git a/examples/Demo/Source/Main.cpp b/examples/Demo/Source/Main.cpp index e7b7c3cc92..5ad91100c0 100644 --- a/examples/Demo/Source/Main.cpp +++ b/examples/Demo/Source/Main.cpp @@ -51,7 +51,7 @@ public: void shutdown() override { // Do your application's shutdown code here.. - mainWindow = nullptr; + mainWindow.reset(); } //============================================================================== diff --git a/examples/Demo/Source/MainWindow.cpp b/examples/Demo/Source/MainWindow.cpp index 687807769a..8cf20c6897 100644 --- a/examples/Demo/Source/MainWindow.cpp +++ b/examples/Demo/Source/MainWindow.cpp @@ -134,7 +134,7 @@ public: void clearCurrentDemo() { - currentDemo = nullptr; + currentDemo.reset(); } void resized() override @@ -202,7 +202,7 @@ public: { if (auto* selectedDemoType = JuceDemoTypeBase::getDemoTypeList() [lastRowSelected]) { - currentDemo = nullptr; + currentDemo.reset(); addAndMakeVisible (currentDemo = selectedDemoType->createComponent()); currentDemo->setName (selectedDemoType->name); resized(); @@ -618,9 +618,9 @@ MainAppWindow::~MainAppWindow() { contentComponent->clearCurrentDemo(); clearContentComponent(); - contentComponent = nullptr; - applicationCommandManager = nullptr; - sharedAudioDeviceManager = nullptr; + contentComponent.reset(); + applicationCommandManager.reset(); + sharedAudioDeviceManager.reset(); #if JUCE_OPENGL openGLContext.detach(); diff --git a/extras/Projucer/Source/Application/Windows/jucer_AboutWindowComponent.h b/extras/Projucer/Source/Application/Windows/jucer_AboutWindowComponent.h index 3ca38739e7..fbb41d02f6 100644 --- a/extras/Projucer/Source/Application/Windows/jucer_AboutWindowComponent.h +++ b/extras/Projucer/Source/Application/Windows/jucer_AboutWindowComponent.h @@ -41,7 +41,7 @@ public: bool showPurchaseButton = false; #if ! JUCER_ENABLE_GPL_MODE - if (LicenseController* controller = ProjucerApplication::getApp().licenseController) + if (auto* controller = ProjucerApplication::getApp().licenseController.get()) showPurchaseButton = (controller->getState().type != LicenseState::Type::indie && controller->getState().type != LicenseState::Type::pro); #endif @@ -130,19 +130,17 @@ private: Rectangle huckleberryLogoBounds; Rectangle juceLogoBounds; - ScopedPointer juceLogo - = Drawable::createFromImageData (BinaryData::juce_icon_png, - BinaryData::juce_icon_pngSize); + ScopedPointer juceLogo { Drawable::createFromImageData (BinaryData::juce_icon_png, + BinaryData::juce_icon_pngSize) }; - ScopedPointer huckleberryLogo - = Drawable::createFromImageData (BinaryData::huckleberry_icon_svg, - BinaryData::huckleberry_icon_svgSize); + ScopedPointer huckleberryLogo { Drawable::createFromImageData (BinaryData::huckleberry_icon_svg, + BinaryData::huckleberry_icon_svgSize) }; void buttonClicked (Button* b) override { - if (b == licenseButton) + if (b == licenseButton.get()) { - if (LicenseController* controller = ProjucerApplication::getApp().licenseController) + if (auto* controller = ProjucerApplication::getApp().licenseController.get()) controller->chooseNewLicense(); } } diff --git a/extras/Projucer/Source/Application/Windows/jucer_ApplicationUsageDataWindowComponent.h b/extras/Projucer/Source/Application/Windows/jucer_ApplicationUsageDataWindowComponent.h index ec5476aedd..c1683574cb 100644 --- a/extras/Projucer/Source/Application/Windows/jucer_ApplicationUsageDataWindowComponent.h +++ b/extras/Projucer/Source/Application/Windows/jucer_ApplicationUsageDataWindowComponent.h @@ -69,7 +69,7 @@ public: { addAndMakeVisible (shareApplicationUsageDataToggle = new ToggleButton()); - LicenseController* controller = ProjucerApplication::getApp().licenseController; + auto* controller = ProjucerApplication::getApp().licenseController.get(); if (controller != nullptr && controller->getState().applicationUsageDataState == LicenseState::ApplicationUsageData::disabled) shareApplicationUsageDataToggle->setToggleState (false, dontSendNotification); @@ -90,7 +90,7 @@ public: ~ApplicationUsageDataWindowComponent() { - if (LicenseController* controller = ProjucerApplication::getApp().licenseController) + if (auto* controller = ProjucerApplication::getApp().licenseController.get()) { auto newApplicationUsageDataState = LicenseState::ApplicationUsageData::enabled; @@ -160,7 +160,7 @@ private: } else if (b == upgradeLicenseButton) { - if (LicenseController* controller = ProjucerApplication::getApp().licenseController) + if (auto* controller = ProjucerApplication::getApp().licenseController.get()) controller->chooseNewLicense(); } } diff --git a/extras/Projucer/Source/Application/Windows/jucer_EditorColourSchemeWindowComponent.h b/extras/Projucer/Source/Application/Windows/jucer_EditorColourSchemeWindowComponent.h index a616d3b964..60884d2422 100644 --- a/extras/Projucer/Source/Application/Windows/jucer_EditorColourSchemeWindowComponent.h +++ b/extras/Projucer/Source/Application/Windows/jucer_EditorColourSchemeWindowComponent.h @@ -39,7 +39,7 @@ public: else content = new AppearanceEditor::EditorPanel(); - changeContent (content); + changeContent (content.get()); } void paint (Graphics& g) override diff --git a/extras/Projucer/Source/Application/Windows/jucer_FloatingToolWindow.h b/extras/Projucer/Source/Application/Windows/jucer_FloatingToolWindow.h index a3ece7ce23..c99851d4d6 100644 --- a/extras/Projucer/Source/Application/Windows/jucer_FloatingToolWindow.h +++ b/extras/Projucer/Source/Application/Windows/jucer_FloatingToolWindow.h @@ -68,7 +68,7 @@ struct FloatingToolWindow : public DialogWindow void closeButtonPressed() override { - owner = nullptr; + owner.reset(); } bool escapeKeyPressed() override diff --git a/extras/Projucer/Source/Application/jucer_Application.cpp b/extras/Projucer/Source/Application/jucer_Application.cpp index 0a5bb645f8..8c9d6ef7be 100644 --- a/extras/Projucer/Source/Application/jucer_Application.cpp +++ b/extras/Projucer/Source/Application/jucer_Application.cpp @@ -195,31 +195,31 @@ void ProjucerApplication::shutdown() Logger::writeToLog ("Server shutdown cleanly"); } - versionChecker = nullptr; - utf8Window = nullptr; - svgPathWindow = nullptr; - aboutWindow = nullptr; - pathsWindow = nullptr; - editorColourSchemeWindow = nullptr; + versionChecker.reset(); + utf8Window.reset(); + svgPathWindow.reset(); + aboutWindow.reset(); + pathsWindow.reset(); + editorColourSchemeWindow.reset(); if (licenseController != nullptr) { licenseController->removeLicenseStatusChangedCallback (this); - licenseController = nullptr; + licenseController.reset(); } mainWindowList.forceCloseAllWindows(); openDocumentManager.clear(); - childProcessCache = nullptr; + childProcessCache.reset(); #if JUCE_MAC MenuBarModel::setMacMainMenu (nullptr); #endif - menuModel = nullptr; - commandManager = nullptr; - settings = nullptr; + menuModel.reset(); + commandManager.reset(); + settings.reset(); LookAndFeel::setDefaultLookAndFeel (nullptr); @@ -739,7 +739,7 @@ void ProjucerApplication::showApplicationUsageDataAgreementPopup() void ProjucerApplication::dismissApplicationUsageDataAgreementPopup() { if (applicationUsageDataWindow != nullptr) - applicationUsageDataWindow = nullptr; + applicationUsageDataWindow.reset(); } void ProjucerApplication::showPathsWindow() @@ -804,7 +804,7 @@ void ProjucerApplication::deleteLogger() } } - logger = nullptr; + logger.reset(); } PropertiesFile::Options ProjucerApplication::getPropertyFileOptionsFor (const String& filename, bool isProjectSettings) diff --git a/extras/Projucer/Source/Application/jucer_AutoUpdater.cpp b/extras/Projucer/Source/Application/jucer_AutoUpdater.cpp index 7da50a1265..7d120d09f9 100644 --- a/extras/Projucer/Source/Application/jucer_AutoUpdater.cpp +++ b/extras/Projucer/Source/Application/jucer_AutoUpdater.cpp @@ -308,16 +308,16 @@ public: ~UpdateUserDialog() { - titleLabel = nullptr; - contentLabel = nullptr; - okButton = nullptr; - cancelButton = nullptr; - changeLogLabel = nullptr; - changeLog = nullptr; - overwriteLabel = nullptr; - overwritePath = nullptr; - overwriteButton = nullptr; - juceIcon = nullptr; + titleLabel.reset(); + contentLabel.reset(); + okButton.reset(); + cancelButton.reset(); + changeLogLabel.reset(); + changeLog.reset(); + overwriteLabel.reset(); + overwritePath.reset(); + overwriteButton.reset(); + juceIcon.reset(); } void paint (Graphics& g) override diff --git a/extras/Projucer/Source/Application/jucer_CommandLine.cpp b/extras/Projucer/Source/Application/jucer_CommandLine.cpp index dd23110145..4d9534e53d 100644 --- a/extras/Projucer/Source/Application/jucer_CommandLine.cpp +++ b/extras/Projucer/Source/Application/jucer_CommandLine.cpp @@ -136,7 +136,7 @@ namespace if (! project->loadFrom (projectFile, true)) { - project = nullptr; + project.reset(); throw CommandLineError ("Failed to load the project file: " + projectFile.getFullPathName()); } } @@ -148,7 +148,7 @@ namespace Result error (justSaveResources ? project->saveResourcesOnly (project->getFile()) : project->saveProject (project->getFile(), true)); - project = nullptr; + project.reset(); if (error.failed()) throw CommandLineError ("Error when saving: " + error.getErrorMessage()); @@ -302,7 +302,7 @@ namespace ScopedPointer out (temp.getFile().createOutputStream()); bool ok = out != nullptr && zip.writeToStream (*out, nullptr); - out = nullptr; + out.reset(); ok = ok && temp.overwriteTargetFileWithTemporary(); if (! ok) diff --git a/extras/Projucer/Source/Application/jucer_MainWindow.cpp b/extras/Projucer/Source/Application/jucer_MainWindow.cpp index 6e64bd3ddf..5c5d62933b 100644 --- a/extras/Projucer/Source/Application/jucer_MainWindow.cpp +++ b/extras/Projucer/Source/Application/jucer_MainWindow.cpp @@ -90,7 +90,7 @@ MainWindow::~MainWindow() getGlobalProperties().setValue ("lastMainWindowPos", getWindowStateAsString()); clearContentComponent(); - currentProject = nullptr; + currentProject.reset(); } void MainWindow::createProjectContentCompIfNeeded() @@ -155,7 +155,7 @@ bool MainWindow::closeProject (Project* project) bool MainWindow::closeCurrentProject() { - return currentProject == nullptr || closeProject (currentProject); + return currentProject == nullptr || closeProject (currentProject.get()); } void MainWindow::setProject (Project* newProject) @@ -200,17 +200,17 @@ bool MainWindow::openFile (const File& file) { ScopedPointer newDoc (new Project (file)); - Result result (newDoc->loadFrom (file, true)); + auto result = newDoc->loadFrom (file, true); if (result.wasOk() && closeCurrentProject()) { - setProject (newDoc); + setProject (newDoc.get()); newDoc.release()->setChangedFlag (false); jassert (getProjectContentComponent() != nullptr); getProjectContentComponent()->reloadLastOpenDocuments(); - if (Project* p = getProject()) + if (auto* p = getProject()) p->updateDeprecatedProjectSettingsInteractively(); return true; diff --git a/extras/Projucer/Source/Application/jucer_MainWindow.h b/extras/Projucer/Source/Application/jucer_MainWindow.h index b934067c75..c38a6bf5e3 100644 --- a/extras/Projucer/Source/Application/jucer_MainWindow.h +++ b/extras/Projucer/Source/Application/jucer_MainWindow.h @@ -50,7 +50,7 @@ public: bool canOpenFile (const File& file) const; bool openFile (const File& file); void setProject (Project* newProject); - Project* getProject() const { return currentProject; } + Project* getProject() const { return currentProject.get(); } void makeVisible(); void restoreWindowPosition(); diff --git a/extras/Projucer/Source/CodeEditor/jucer_ItemPreviewComponent.h b/extras/Projucer/Source/CodeEditor/jucer_ItemPreviewComponent.h index 5a49ed4ab7..7594cad9ea 100644 --- a/extras/Projucer/Source/CodeEditor/jucer_ItemPreviewComponent.h +++ b/extras/Projucer/Source/CodeEditor/jucer_ItemPreviewComponent.h @@ -81,7 +81,7 @@ private: { facts.clear(); facts.add (file.getFullPathName()); - drawable = nullptr; + drawable.reset(); { ScopedPointer input (file.createInputStream()); @@ -94,7 +94,7 @@ private: if (ImageFileFormat* format = ImageFileFormat::findImageFormatForStream (*input)) formatName = " " + format->getFormatName(); - input = nullptr; + input.reset(); Image image (ImageCache::getFromFile (file)); diff --git a/extras/Projucer/Source/CodeEditor/jucer_LiveBuildCodeEditor.h b/extras/Projucer/Source/CodeEditor/jucer_LiveBuildCodeEditor.h index cfd9d438e5..1cae43f414 100644 --- a/extras/Projucer/Source/CodeEditor/jucer_LiveBuildCodeEditor.h +++ b/extras/Projucer/Source/CodeEditor/jucer_LiveBuildCodeEditor.h @@ -345,7 +345,7 @@ private: || underMouse->findParentComponentOfClass() != nullptr)) return; - overlay = nullptr; + overlay.reset(); if (hasKeyboardFocus (true) && underMouse != nullptr && (underMouse == this || underMouse->isParentOf (this))) @@ -372,7 +372,7 @@ private: void hideOverlay() { stopTimer(); - overlay = nullptr; + overlay.reset(); } void focusLost (FocusChangeType) override diff --git a/extras/Projucer/Source/CodeEditor/jucer_SourceCodeEditor.cpp b/extras/Projucer/Source/CodeEditor/jucer_SourceCodeEditor.cpp index e1b0d0eb51..8f79c2a2b5 100644 --- a/extras/Projucer/Source/CodeEditor/jucer_SourceCodeEditor.cpp +++ b/extras/Projucer/Source/CodeEditor/jucer_SourceCodeEditor.cpp @@ -474,7 +474,7 @@ void GenericCodeEditorComponent::showFindPanel() void GenericCodeEditorComponent::hideFindPanel() { - findPanel = nullptr; + findPanel.reset(); } void GenericCodeEditorComponent::findSelection() diff --git a/extras/Projucer/Source/CodeEditor/jucer_SourceCodeEditor.h b/extras/Projucer/Source/CodeEditor/jucer_SourceCodeEditor.h index 7fb1769255..6110d410af 100644 --- a/extras/Projucer/Source/CodeEditor/jucer_SourceCodeEditor.h +++ b/extras/Projucer/Source/CodeEditor/jucer_SourceCodeEditor.h @@ -46,11 +46,11 @@ public: bool hasFileBeenModifiedExternally() override { return modDetector.hasBeenModified(); } void fileHasBeenRenamed (const File& newFile) override { modDetector.fileHasBeenRenamed (newFile); } String getState() const override { return lastState != nullptr ? lastState->toString() : String(); } - void restoreState (const String& state) override { lastState = new CodeEditorComponent::State (state); } + void restoreState (const String& state) override { lastState.reset (new CodeEditorComponent::State (state)); } File getCounterpartFile() const override { - const File file (getFile()); + auto file = getFile(); if (file.hasFileExtension (sourceFileExtensions)) { diff --git a/extras/Projucer/Source/ComponentEditor/Components/jucer_TabbedComponentHandler.h b/extras/Projucer/Source/ComponentEditor/Components/jucer_TabbedComponentHandler.h index 542345e719..fc0095324c 100644 --- a/extras/Projucer/Source/ComponentEditor/Components/jucer_TabbedComponentHandler.h +++ b/extras/Projucer/Source/ComponentEditor/Components/jucer_TabbedComponentHandler.h @@ -378,7 +378,7 @@ private: || jucerComp->getOwnerDocument() == nullptr || jucerComp->getFilename() != jucerComponentFile) { - jucerComp = nullptr; + jucerComp.reset(); jucerComp = new TestComponent (ComponentTypeHandler::findParentDocument (this), 0, false); jucerComp->setFilename (jucerComponentFile); @@ -389,7 +389,7 @@ private: } else { - jucerComp = nullptr; + jucerComp.reset(); } resized(); diff --git a/extras/Projucer/Source/ComponentEditor/Documents/jucer_ButtonDocument.cpp b/extras/Projucer/Source/ComponentEditor/Documents/jucer_ButtonDocument.cpp index b06c7c81c5..95327547c4 100644 --- a/extras/Projucer/Source/ComponentEditor/Documents/jucer_ButtonDocument.cpp +++ b/extras/Projucer/Source/ComponentEditor/Documents/jucer_ButtonDocument.cpp @@ -113,14 +113,14 @@ PaintRoutine* ButtonDocument::getPaintRoutine (const int index) const if (paintStatesEnabled [i]) { if (index == n) - return paintRoutines [i]; - else - ++n; + return paintRoutines[i].get(); + + ++n; } } jassertfalse; - return 0; + return {}; } void ButtonDocument::setStatePaintRoutineEnabled (const int index, bool b) diff --git a/extras/Projucer/Source/ComponentEditor/Documents/jucer_ComponentDocument.h b/extras/Projucer/Source/ComponentEditor/Documents/jucer_ComponentDocument.h index 1b133ba240..5981e0b7a6 100644 --- a/extras/Projucer/Source/ComponentEditor/Documents/jucer_ComponentDocument.h +++ b/extras/Projucer/Source/ComponentEditor/Documents/jucer_ComponentDocument.h @@ -45,7 +45,7 @@ public: StringArray getPaintRoutineNames() const { return StringArray ("Graphics"); } PaintRoutine* getPaintRoutine (const int index) const { return index == 0 ? backgroundGraphics.get() : nullptr; } - ComponentLayout* getComponentLayout() const { return components; } + ComponentLayout* getComponentLayout() const { return components.get(); } //============================================================================== XmlElement* createXml() const; diff --git a/extras/Projucer/Source/ComponentEditor/UI/jucer_JucerDocumentEditor.cpp b/extras/Projucer/Source/ComponentEditor/UI/jucer_JucerDocumentEditor.cpp index e7cb92e2e2..e6e28aaad2 100644 --- a/extras/Projucer/Source/ComponentEditor/UI/jucer_JucerDocumentEditor.cpp +++ b/extras/Projucer/Source/ComponentEditor/UI/jucer_JucerDocumentEditor.cpp @@ -598,8 +598,7 @@ void JucerDocumentEditor::saveLastSelectedTab() const { if (document != nullptr) { - auto* project = document->getCppDocument().getProject(); - if (project != nullptr) + if (auto* project = document->getCppDocument().getProject()) { auto& projectProps = project->getStoredProperties(); @@ -617,7 +616,7 @@ void JucerDocumentEditor::saveLastSelectedTab() const child->setAttribute ("tab", tabbedComponent.getCurrentTabIndex()); - projectProps.setValue ("GUIComponentsLastTab", root); + projectProps.setValue ("GUIComponentsLastTab", root.get()); } } } @@ -626,10 +625,10 @@ void JucerDocumentEditor::restoreLastSelectedTab() { if (document != nullptr) { - auto* project = document->getCppDocument().getProject(); - if (project != nullptr) + if (auto* project = document->getCppDocument().getProject()) { ScopedPointer root (project->getStoredProperties().getXmlValue ("GUIComponentsLastTab")); + if (root != nullptr) { auto* child = root->getChildByName (document->getCppFile().getFileName()); diff --git a/extras/Projucer/Source/ComponentEditor/UI/jucer_PaintRoutineEditor.cpp b/extras/Projucer/Source/ComponentEditor/UI/jucer_PaintRoutineEditor.cpp index 9d98927cd0..c432106d12 100644 --- a/extras/Projucer/Source/ComponentEditor/UI/jucer_PaintRoutineEditor.cpp +++ b/extras/Projucer/Source/ComponentEditor/UI/jucer_PaintRoutineEditor.cpp @@ -154,7 +154,7 @@ void PaintRoutineEditor::visibilityChanged() void PaintRoutineEditor::refreshAllElements() { for (int i = getNumChildComponents(); --i >= 0;) - if (PaintElement* const e = dynamic_cast (getChildComponent (i))) + if (auto* e = dynamic_cast (getChildComponent (i))) if (! graphics.containsElement (e)) removeChildComponent (e); @@ -162,7 +162,7 @@ void PaintRoutineEditor::refreshAllElements() for (int i = graphics.getNumElements(); --i >= 0;) { - PaintElement* const e = graphics.getElement (i); + auto* e = graphics.getElement (i); addAndMakeVisible (e); @@ -268,7 +268,7 @@ void PaintRoutineEditor::filesDropped (const StringArray& filenames, int x, int if (d != nullptr) { - d = nullptr; + d.reset(); document.beginTransaction(); diff --git a/extras/Projucer/Source/ComponentEditor/UI/jucer_TestComponent.cpp b/extras/Projucer/Source/ComponentEditor/UI/jucer_TestComponent.cpp index 231b1735d7..da9460879c 100644 --- a/extras/Projucer/Source/ComponentEditor/UI/jucer_TestComponent.cpp +++ b/extras/Projucer/Source/ComponentEditor/UI/jucer_TestComponent.cpp @@ -94,7 +94,7 @@ void TestComponent::setFilename (const String& newName) { recursiveFiles.add (newFile.getFullPathName()); - loadedDocument = nullptr; + loadedDocument.reset(); filename = newName; lastModificationTime = findFile().getLastModificationTime(); diff --git a/extras/Projucer/Source/ComponentEditor/jucer_BinaryResources.cpp b/extras/Projucer/Source/ComponentEditor/jucer_BinaryResources.cpp index a1179cffce..ff6efffe79 100644 --- a/extras/Projucer/Source/ComponentEditor/jucer_BinaryResources.cpp +++ b/extras/Projucer/Source/ComponentEditor/jucer_BinaryResources.cpp @@ -121,7 +121,7 @@ void BinaryResources::add (const String& name, const String& originalFileName, c r->originalFilename = originalFileName; r->data = data; - r->drawable = nullptr; + r->drawable.reset(); changed(); } diff --git a/extras/Projucer/Source/ComponentEditor/jucer_ComponentLayout.cpp b/extras/Projucer/Source/ComponentEditor/jucer_ComponentLayout.cpp index a1e64719c4..de312f564b 100644 --- a/extras/Projucer/Source/ComponentEditor/jucer_ComponentLayout.cpp +++ b/extras/Projucer/Source/ComponentEditor/jucer_ComponentLayout.cpp @@ -420,7 +420,7 @@ Component* ComponentLayout::addNewComponent (ComponentTypeHandler* const type, i c->getProperties().set ("id", nextCompUID++); ScopedPointer xml (type->createXmlFor (c, this)); - c = nullptr; + c.reset(); c = addComponentFromXml (*xml, true); String memberName (CodeHelpers::makeValidIdentifier (type->getClassName (c), true, true, false)); diff --git a/extras/Projucer/Source/ComponentEditor/jucer_JucerDocument.cpp b/extras/Projucer/Source/ComponentEditor/jucer_JucerDocument.cpp index 8cdaff31e1..9bb9b69aa2 100644 --- a/extras/Projucer/Source/ComponentEditor/jucer_JucerDocument.cpp +++ b/extras/Projucer/Source/ComponentEditor/jucer_JucerDocument.cpp @@ -564,7 +564,7 @@ bool JucerDocument::flushChangesToDocuments (Project* project) cpp->getCodeDocument().replaceAllContent (cppTemplate); } - userDocChangeTimer = nullptr; + userDocChangeTimer.reset(); return true; } @@ -771,7 +771,7 @@ public: jucerDoc->setClassName (newFile.getFileNameWithoutExtension()); jucerDoc->flushChangesToDocuments (&project); - jucerDoc = nullptr; + jucerDoc.reset(); cpp->save(); header->save(); diff --git a/extras/Projucer/Source/ComponentEditor/jucer_PaintRoutine.cpp b/extras/Projucer/Source/ComponentEditor/jucer_PaintRoutine.cpp index 440cf6cc44..81dac7d8d1 100644 --- a/extras/Projucer/Source/ComponentEditor/jucer_PaintRoutine.cpp +++ b/extras/Projucer/Source/ComponentEditor/jucer_PaintRoutine.cpp @@ -553,7 +553,7 @@ void PaintRoutine::dropImageAt (const File& f, int x, int y) if (d != nullptr) { auto bounds = d->getDrawableBounds(); - d = nullptr; + d.reset(); auto* newElement = addNewElement (ObjectTypes::createNewImageElement (this), -1, true); diff --git a/extras/Projucer/Source/Licenses/jucer_LicenseController.cpp b/extras/Projucer/Source/Licenses/jucer_LicenseController.cpp index 5712bd42cb..61c2b21d46 100644 --- a/extras/Projucer/Source/Licenses/jucer_LicenseController.cpp +++ b/extras/Projucer/Source/Licenses/jucer_LicenseController.cpp @@ -114,7 +114,7 @@ LicenseController::LicenseController() LicenseController::~LicenseController() { #if !JUCER_ENABLE_GPL_MODE - thread = nullptr; + thread.reset(); closeWebview (-1); #endif } @@ -155,7 +155,7 @@ void LicenseController::logout() jassert (MessageManager::getInstance()->isThisTheMessageThread()); #if ! JUCER_ENABLE_GPL_MODE - thread = nullptr; + thread.reset(); updateState ({}); #if ! JUCE_LINUX @@ -171,7 +171,7 @@ void LicenseController::chooseNewLicense() jassert (MessageManager::getInstance()->isThisTheMessageThread()); #if ! JUCER_ENABLE_GPL_MODE - thread = nullptr; + thread.reset(); thread = new LicenseThread (*this, true); #endif } diff --git a/extras/Projucer/Source/Licenses/jucer_LicenseThread.h b/extras/Projucer/Source/Licenses/jucer_LicenseThread.h index e98194a23f..9b19d24231 100644 --- a/extras/Projucer/Source/Licenses/jucer_LicenseThread.h +++ b/extras/Projucer/Source/Licenses/jucer_LicenseThread.h @@ -174,7 +174,7 @@ struct LicenseThread : NetWorkerThread if (statusCode == 200) { var result = JSON::parse (shared->readEntireStreamAsString()); - shared = nullptr; + shared.reset(); auto newState = licenseStateFromJSON (result, stateToUpdate.authToken, stateToUpdate.avatar); @@ -222,7 +222,7 @@ struct LicenseThread : NetWorkerThread var json = JSON::parse (shared->withExtraHeaders (accessTokenHeader) .readEntireStreamAsString()); - shared = nullptr; + shared.reset(); if (auto* jsonLicenses = json.getArray()) { diff --git a/extras/Projucer/Source/Licenses/jucer_LicenseWebview.h b/extras/Projucer/Source/Licenses/jucer_LicenseWebview.h index 8261e8a258..fa22257e5a 100644 --- a/extras/Projucer/Source/Licenses/jucer_LicenseWebview.h +++ b/extras/Projucer/Source/Licenses/jucer_LicenseWebview.h @@ -81,15 +81,14 @@ private: struct Header : public Component, private LicenseController::StateChangedCallback, private Button::Listener { - Header () - : avatarButton ("User Settings", &getIcons().user) + Header() : avatarButton ("User Settings", &getIcons().user) { setOpaque (true); addChildComponent (avatarButton); avatarButton.addListener (this); - if (LicenseController* licenseController = ProjucerApplication::getApp().licenseController) + if (auto* licenseController = ProjucerApplication::getApp().licenseController.get()) { licenseController->addLicenseStatusChangedCallback (this); licenseStateChanged (licenseController->getState()); @@ -100,7 +99,7 @@ private: { avatarButton.removeListener (this); - if (LicenseController* licenseController = ProjucerApplication::getApp().licenseController) + if (auto* licenseController = ProjucerApplication::getApp().licenseController.get()) licenseController->removeLicenseStatusChangedCallback (this); } @@ -128,9 +127,9 @@ private: void buttonClicked (Button*) override { - if (LicenseController* licenseController = ProjucerApplication::getApp().licenseController) + if (auto* licenseController = ProjucerApplication::getApp().licenseController.get()) { - const LicenseState::Type type = licenseController->getState().type; + auto type = licenseController->getState().type; auto* content = new UserSettingsPopup (true); content->setSize (200, (type == LicenseState::Type::noLicenseChosenYet ? 100 : 150)); diff --git a/extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineClient.cpp b/extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineClient.cpp index b1c8710409..2b9dc0d2f2 100644 --- a/extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineClient.cpp +++ b/extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineClient.cpp @@ -293,12 +293,12 @@ public: if (isRunningApp && server != nullptr) server->killServerWithoutMercy(); - server = nullptr; + server.reset(); } void restartServer() { - server = nullptr; + server.reset(); server = new ClientIPC (owner); sendRebuild(); } @@ -578,7 +578,7 @@ CompileEngineChildProcess::~CompileEngineChildProcess() { ProjucerApplication::getApp().openDocumentManager.removeListener (this); - process = nullptr; + process.reset(); lastComponentList.clear(); } @@ -588,7 +588,7 @@ void CompileEngineChildProcess::createProcess() process = new ChildProcess (*this, project); if (! process->openedOk) - process = nullptr; + process.reset(); updateAllEditors(); } @@ -662,7 +662,7 @@ bool CompileEngineChildProcess::canKillApp() const void CompileEngineChildProcess::killApp() { - runningAppProcess = nullptr; + runningAppProcess.reset(); } void CompileEngineChildProcess::handleAppLaunched() @@ -675,7 +675,7 @@ void CompileEngineChildProcess::handleAppLaunched() void CompileEngineChildProcess::handleAppQuit() { DBG ("handleAppQuit"); - runningAppProcess = nullptr; + runningAppProcess.reset(); } //============================================================================== diff --git a/extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineServer.cpp b/extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineServer.cpp index a1fe4bdc57..943a66a463 100644 --- a/extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineServer.cpp +++ b/extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineServer.cpp @@ -162,7 +162,7 @@ public: ~ServerIPC() { - zombieKiller = nullptr; + zombieKiller.reset(); if (dll.isLoaded()) dll.projucer_deleteBuilder (liveCodeBuilder); diff --git a/extras/Projucer/Source/Project/UI/Sidebar/jucer_ExporterTreeItems.h b/extras/Projucer/Source/Project/UI/Sidebar/jucer_ExporterTreeItems.h index 4ecf2abb5c..295406df04 100644 --- a/extras/Projucer/Source/Project/UI/Sidebar/jucer_ExporterTreeItems.h +++ b/extras/Projucer/Source/Project/UI/Sidebar/jucer_ExporterTreeItems.h @@ -69,12 +69,12 @@ public: Icon getIcon() const override { - return getIconForExporter (exporter).withColour (getContentColour (true)); + return getIconForExporter (exporter.get()).withColour (getContentColour (true)); } void showDocument() override { - showSettingsPage (new SettingsComp (exporter)); + showSettingsPage (new SettingsComp (exporter.get())); } void deleteItem() override @@ -142,7 +142,7 @@ public: void itemDropped (const DragAndDropTarget::SourceDetails& dragSourceDetails, int insertIndex) override { - const int oldIndex = indexOfConfig (dragSourceDetails.description.toString().fromLastOccurrenceOf ("||", false, false)); + auto oldIndex = indexOfConfig (dragSourceDetails.description.toString().fromLastOccurrenceOf ("||", false, false)); if (oldIndex >= 0) configListTree.moveChild (oldIndex, insertIndex, project.getUndoManagerFor (configListTree)); diff --git a/extras/Projucer/Source/Project/UI/Sidebar/jucer_TabComponents.h b/extras/Projucer/Source/Project/UI/Sidebar/jucer_TabComponents.h index 81f6955ca2..21b3de1995 100644 --- a/extras/Projucer/Source/Project/UI/Sidebar/jucer_TabComponents.h +++ b/extras/Projucer/Source/Project/UI/Sidebar/jucer_TabComponents.h @@ -201,10 +201,10 @@ public: ~ConcertinaTreeComponent() { - treeToDisplay = nullptr; - addButton = nullptr; - findPanel = nullptr; - settingsButton = nullptr; + treeToDisplay.reset(); + addButton.reset(); + findPanel.reset(); + settingsButton.reset(); } void resized() override diff --git a/extras/Projucer/Source/Project/UI/jucer_FileGroupInformationComponent.h b/extras/Projucer/Source/Project/UI/jucer_FileGroupInformationComponent.h index f8c6d30adb..2453357b41 100644 --- a/extras/Projucer/Source/Project/UI/jucer_FileGroupInformationComponent.h +++ b/extras/Projucer/Source/Project/UI/jucer_FileGroupInformationComponent.h @@ -98,7 +98,7 @@ public: if (existingComponentToUpdate == nullptr || dynamic_cast (existing.get())->item != child) { - existing = nullptr; + existing.reset(); existing = new FileOptionComponent (child, dynamic_cast (list.getHeaderComponent())); } } diff --git a/extras/Projucer/Source/Project/UI/jucer_ProjectContentComponent.cpp b/extras/Projucer/Source/Project/UI/jucer_ProjectContentComponent.cpp index c516fe8de1..d35127f528 100644 --- a/extras/Projucer/Source/Project/UI/jucer_ProjectContentComponent.cpp +++ b/extras/Projucer/Source/Project/UI/jucer_ProjectContentComponent.cpp @@ -99,11 +99,11 @@ ProjectContentComponent::~ProjectContentComponent() ProjucerApplication::getApp().openDocumentManager.removeListener (this); - logo = nullptr; - header = nullptr; + logo.reset(); + header.reset(); setProject (nullptr); - contentView = nullptr; - fileNameLabel = nullptr; + contentView.reset(); + fileNameLabel.reset(); removeChildComponent (&bubbleMessage); jassert (getNumChildComponents() <= 1); } @@ -178,8 +178,8 @@ void ProjectContentComponent::setProject (Project* newProject) if (project != nullptr) project->removeChangeListener (this); - contentView = nullptr; - resizerBar = nullptr; + contentView.reset(); + resizerBar.reset(); deleteProjectTabs(); project = newProject; @@ -391,7 +391,7 @@ bool ProjectContentComponent::showDocument (OpenDocumentManager::Document* doc, void ProjectContentComponent::hideEditor() { currentDocument = nullptr; - contentView = nullptr; + contentView.reset(); if (fileNameLabel != nullptr) fileNameLabel->setVisible (false); @@ -416,7 +416,7 @@ bool ProjectContentComponent::setEditorComponent (Component* editor, { if (editor != nullptr) { - contentView = nullptr; + contentView.reset(); if (doc == nullptr) { diff --git a/extras/Projucer/Source/Project/UI/jucer_ProjectContentComponent.h b/extras/Projucer/Source/Project/UI/jucer_ProjectContentComponent.h index f9ef722f2a..85749ab554 100644 --- a/extras/Projucer/Source/Project/UI/jucer_ProjectContentComponent.h +++ b/extras/Projucer/Source/Project/UI/jucer_ProjectContentComponent.h @@ -67,7 +67,7 @@ public: void hideEditor(); bool setEditorComponent (Component* editor, OpenDocumentManager::Document* doc); Component* getEditorComponentContent() const; - Component* getEditorComponent() const { return contentView; } + Component* getEditorComponent() const { return contentView.get(); } Component& getSidebarComponent() { return sidebarTabs; } bool goToPreviousFile(); diff --git a/extras/Projucer/Source/Project/jucer_Project.cpp b/extras/Projucer/Source/Project/jucer_Project.cpp index ef2d53a51b..44a99f447b 100644 --- a/extras/Projucer/Source/Project/jucer_Project.cpp +++ b/extras/Projucer/Source/Project/jucer_Project.cpp @@ -407,7 +407,7 @@ Result Project::loadDocument (const File& file) return Result::fail ("The document contains errors and couldn't be parsed!"); registerRecentFile (file); - enabledModulesList = nullptr; + enabledModulesList.reset(); projectRoot = newTree; removeDefunctExporters(); diff --git a/extras/Projucer/Source/Project/jucer_Project.h b/extras/Projucer/Source/Project/jucer_Project.h index b0caffb97e..74060bd113 100644 --- a/extras/Projucer/Source/Project/jucer_Project.h +++ b/extras/Projucer/Source/Project/jucer_Project.h @@ -297,7 +297,7 @@ public: bool next(); ProjectExporter& operator*() const { return *exporter; } - ProjectExporter* operator->() const { return exporter; } + ProjectExporter* operator->() const { return exporter.get(); } ScopedPointer exporter; int index; diff --git a/extras/Projucer/Source/Settings/jucer_StoredSettings.h b/extras/Projucer/Source/Settings/jucer_StoredSettings.h index 84c79f9713..3f20928e53 100644 --- a/extras/Projucer/Source/Settings/jucer_StoredSettings.h +++ b/extras/Projucer/Source/Settings/jucer_StoredSettings.h @@ -84,7 +84,7 @@ private: propertyFiles.getUnchecked (0)->setValue (isProjectDefaults ? "PROJECT_DEFAULT_SETTINGS" : "FALLBACK_PATHS", - data); + data.get()); } void updateGlobalPreferences(); diff --git a/extras/Projucer/Source/Utility/UI/jucer_JucerTreeViewBase.cpp b/extras/Projucer/Source/Utility/UI/jucer_JucerTreeViewBase.cpp index 7f9a227830..b3e77e5929 100644 --- a/extras/Projucer/Source/Utility/UI/jucer_JucerTreeViewBase.cpp +++ b/extras/Projucer/Source/Utility/UI/jucer_JucerTreeViewBase.cpp @@ -54,10 +54,10 @@ void TreePanelBase::saveOpenness() { if (project != nullptr) { - const ScopedPointer opennessState (tree.getOpennessState (true)); + ScopedPointer opennessState (tree.getOpennessState (true)); if (opennessState != nullptr) - project->getStoredProperties().setValue (opennessStateKey, opennessState); + project->getStoredProperties().setValue (opennessStateKey, opennessState.get()); else project->getStoredProperties().removeValue (opennessStateKey); } @@ -269,5 +269,5 @@ void JucerTreeViewBase::itemDoubleClicked (const MouseEvent&) void JucerTreeViewBase::cancelDelayedSelectionTimer() { - delayedSelectionTimer = nullptr; + delayedSelectionTimer.reset(); } diff --git a/extras/Projucer/Source/Utility/UI/jucer_UserSettingsPopup.h b/extras/Projucer/Source/Utility/UI/jucer_UserSettingsPopup.h index 7e11709ca4..e551b43ab7 100644 --- a/extras/Projucer/Source/Utility/UI/jucer_UserSettingsPopup.h +++ b/extras/Projucer/Source/Utility/UI/jucer_UserSettingsPopup.h @@ -72,7 +72,7 @@ public: switchLicenseButton->addListener (this); } - if (LicenseController* controller = ProjucerApplication::getApp().licenseController) + if (auto* controller = ProjucerApplication::getApp().licenseController.get()) licenseStateChanged (controller->getState()); #endif } @@ -120,7 +120,7 @@ private: else if (b == switchLicenseButton) { dismissCalloutBox(); - if (LicenseController* controller = ProjucerApplication::getApp().licenseController) + if (auto* controller = ProjucerApplication::getApp().licenseController.get()) controller->chooseNewLicense(); } } diff --git a/extras/Projucer/Source/Wizards/jucer_NewProjectWizardClasses.cpp b/extras/Projucer/Source/Wizards/jucer_NewProjectWizardClasses.cpp index 0a2839b8dc..182dd56e8e 100644 --- a/extras/Projucer/Source/Wizards/jucer_NewProjectWizardClasses.cpp +++ b/extras/Projucer/Source/Wizards/jucer_NewProjectWizardClasses.cpp @@ -53,23 +53,23 @@ struct NewProjectWizardClasses return 9; } - static NewProjectWizard* createWizardType (int index) + static ScopedPointer createWizardType (int index) { switch (index) { - case 0: return new NewProjectWizardClasses::GUIAppWizard(); - case 1: return new NewProjectWizardClasses::AnimatedAppWizard(); - case 2: return new NewProjectWizardClasses::OpenGLAppWizard(); - case 3: return new NewProjectWizardClasses::ConsoleAppWizard(); - case 4: return new NewProjectWizardClasses::AudioAppWizard(); - case 5: return new NewProjectWizardClasses::AudioPluginAppWizard(); - case 6: return new NewProjectWizardClasses::StaticLibraryWizard(); - case 7: return new NewProjectWizardClasses::DynamicLibraryWizard(); - case 8: return new NewProjectWizardClasses::BlankAppWizard(); + case 0: return ScopedPointer (new NewProjectWizardClasses::GUIAppWizard()); + case 1: return ScopedPointer (new NewProjectWizardClasses::AnimatedAppWizard()); + case 2: return ScopedPointer (new NewProjectWizardClasses::OpenGLAppWizard()); + case 3: return ScopedPointer (new NewProjectWizardClasses::ConsoleAppWizard()); + case 4: return ScopedPointer (new NewProjectWizardClasses::AudioAppWizard()); + case 5: return ScopedPointer (new NewProjectWizardClasses::AudioPluginAppWizard()); + case 6: return ScopedPointer (new NewProjectWizardClasses::StaticLibraryWizard()); + case 7: return ScopedPointer (new NewProjectWizardClasses::DynamicLibraryWizard()); + case 8: return ScopedPointer (new NewProjectWizardClasses::BlankAppWizard()); default: jassertfalse; break; } - return nullptr; + return {}; } static StringArray getWizardNames() @@ -77,10 +77,7 @@ struct NewProjectWizardClasses StringArray s; for (int i = 0; i < getNumWizards(); ++i) - { - ScopedPointer wiz (createWizardType (i)); - s.add (wiz->getName()); - } + s.add (createWizardType (i)->getName()); return s; } diff --git a/extras/Projucer/Source/Wizards/jucer_NewProjectWizardComponent.h b/extras/Projucer/Source/Wizards/jucer_NewProjectWizardComponent.h index 3180324edb..31418e6914 100644 --- a/extras/Projucer/Source/Wizards/jucer_NewProjectWizardComponent.h +++ b/extras/Projucer/Source/Wizards/jucer_NewProjectWizardComponent.h @@ -519,7 +519,7 @@ private: TextButton cancelButton { TRANS("Cancel") }; ModulesFolderPathBox modulesPathBox; - NewProjectWizardClasses::NewProjectWizard* createWizard() + ScopedPointer createWizard() { return createWizardType (projectType.getSelectedItemIndex()); } diff --git a/extras/Projucer/Source/Wizards/jucer_TemplateThumbnailsComponent.h b/extras/Projucer/Source/Wizards/jucer_TemplateThumbnailsComponent.h index c394598f0d..393ca7d430 100644 --- a/extras/Projucer/Source/Wizards/jucer_TemplateThumbnailsComponent.h +++ b/extras/Projucer/Source/Wizards/jucer_TemplateThumbnailsComponent.h @@ -144,7 +144,7 @@ public: for (int i = 0; i < numWizardButtons; ++i) { - ScopedPointer wizard (createWizardType (i)); + auto wizard = createWizardType (i); TemplateOptionButton* b = new TemplateOptionButton (wizard->getName(), TemplateOptionButton::ImageFitted, diff --git a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp index 78a70498e7..4cbe6e1db8 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp @@ -101,8 +101,8 @@ AudioDeviceManager::AudioDeviceManager() AudioDeviceManager::~AudioDeviceManager() { - currentAudioDevice = nullptr; - defaultMidiOutput = nullptr; + currentAudioDevice.reset(); + defaultMidiOutput.reset(); } //============================================================================== @@ -316,7 +316,7 @@ String AudioDeviceManager::initialiseFromXML (const XmlElement& xml, String AudioDeviceManager::initialiseWithDefaultDevices (int numInputChannelsNeeded, int numOutputChannelsNeeded) { - lastExplicitSettings = nullptr; + lastExplicitSettings.reset(); return initialise (numInputChannelsNeeded, numOutputChannelsNeeded, nullptr, false, String(), nullptr); @@ -389,7 +389,7 @@ void AudioDeviceManager::getAudioDeviceSetup (AudioDeviceSetup& setup) const void AudioDeviceManager::deleteCurrentDevice() { - currentAudioDevice = nullptr; + currentAudioDevice.reset(); currentSetup.inputDeviceName.clear(); currentSetup.outputDeviceName.clear(); } @@ -588,13 +588,13 @@ void AudioDeviceManager::stopDevice() if (currentAudioDevice != nullptr) currentAudioDevice->stop(); - testSound = nullptr; + testSound.reset(); } void AudioDeviceManager::closeAudioDevice() { stopDevice(); - currentAudioDevice = nullptr; + currentAudioDevice.reset(); } void AudioDeviceManager::restartLastAudioDevice() @@ -705,14 +705,14 @@ void AudioDeviceManager::audioDeviceIOCallbackInt (const float** inputChannelDat if (callbacks.size() > 0) { - const double callbackStartTime = Time::getMillisecondCounterHiRes(); + auto callbackStartTime = Time::getMillisecondCounterHiRes(); tempBuffer.setSize (jmax (1, numOutputChannels), jmax (1, numSamples), false, false, true); callbacks.getUnchecked(0)->audioDeviceIOCallback (inputChannelData, numInputChannels, outputChannelData, numOutputChannels, numSamples); - float** const tempChans = tempBuffer.getArrayOfWritePointers(); + auto** tempChans = tempBuffer.getArrayOfWritePointers(); for (int i = callbacks.size(); --i > 0;) { @@ -721,14 +721,14 @@ void AudioDeviceManager::audioDeviceIOCallbackInt (const float** inputChannelDat for (int chan = 0; chan < numOutputChannels; ++chan) { - if (const float* const src = tempChans [chan]) - if (float* const dst = outputChannelData [chan]) + if (auto* src = tempChans [chan]) + if (auto* dst = outputChannelData [chan]) for (int j = 0; j < numSamples; ++j) dst[j] += src[j]; } } - const double msTaken = Time::getMillisecondCounterHiRes() - callbackStartTime; + auto msTaken = Time::getMillisecondCounterHiRes() - callbackStartTime; const double filterAmount = 0.2; cpuUsageMs += filterAmount * (msTaken - cpuUsageMs); @@ -743,16 +743,17 @@ void AudioDeviceManager::audioDeviceIOCallbackInt (const float** inputChannelDat if (testSound != nullptr) { - const int numSamps = jmin (numSamples, testSound->getNumSamples() - testSoundPosition); - const float* const src = testSound->getReadPointer (0, testSoundPosition); + auto numSamps = jmin (numSamples, testSound->getNumSamples() - testSoundPosition); + auto* src = testSound->getReadPointer (0, testSoundPosition); for (int i = 0; i < numOutputChannels; ++i) for (int j = 0; j < numSamps; ++j) outputChannelData [i][j] += src[j]; testSoundPosition += numSamps; + if (testSoundPosition >= testSound->getNumSamples()) - testSound = nullptr; + testSound.reset(); } } @@ -761,8 +762,8 @@ void AudioDeviceManager::audioDeviceAboutToStartInt (AudioIODevice* const device cpuUsageMs = 0; xruns = 0; - const double sampleRate = device->getCurrentSampleRate(); - const int blockSize = device->getCurrentBufferSizeSamples(); + auto sampleRate = device->getCurrentSampleRate(); + auto blockSize = device->getCurrentBufferSizeSamples(); if (sampleRate > 0.0 && blockSize > 0) { @@ -772,6 +773,7 @@ void AudioDeviceManager::audioDeviceAboutToStartInt (AudioIODevice* const device { const ScopedLock sl (audioCallbackLock); + for (int i = callbacks.size(); --i >= 0;) callbacks.getUnchecked(i)->audioDeviceAboutToStart (device); } @@ -787,6 +789,7 @@ void AudioDeviceManager::audioDeviceStoppedInt() sendChangeMessage(); const ScopedLock sl (audioCallbackLock); + for (int i = callbacks.size(); --i >= 0;) callbacks.getUnchecked(i)->audioDeviceStopped(); } @@ -794,6 +797,7 @@ void AudioDeviceManager::audioDeviceStoppedInt() void AudioDeviceManager::audioDeviceErrorInt (const String& message) { const ScopedLock sl (audioCallbackLock); + for (int i = callbacks.size(); --i >= 0;) callbacks.getUnchecked(i)->audioDeviceError (message); } @@ -903,7 +907,7 @@ void AudioDeviceManager::setDefaultMidiOutput (const String& deviceName) for (int i = oldCallbacks.size(); --i >= 0;) oldCallbacks.getUnchecked(i)->audioDeviceStopped(); - defaultMidiOutput = nullptr; + defaultMidiOutput.reset(); defaultMidiOutputName = deviceName; if (deviceName.isNotEmpty()) diff --git a/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp b/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp index 19e0cde208..4fb36ac451 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp @@ -318,8 +318,7 @@ namespace CoreMidiHelpers class MidiPortAndCallback { public: - MidiPortAndCallback (MidiInputCallback& cb) - : input (nullptr), active (false), callback (cb), concatenator (2048) + MidiPortAndCallback (MidiInputCallback& cb) : callback (cb) { } @@ -332,18 +331,19 @@ namespace CoreMidiHelpers activeCallbacks.removeFirstMatchingValue (this); } - if (portAndEndpoint != 0 && portAndEndpoint->port != 0) + if (portAndEndpoint != nullptr && portAndEndpoint->port != 0) CHECK_ERROR (MIDIPortDisconnectSource (portAndEndpoint->port, portAndEndpoint->endPoint)); } void handlePackets (const MIDIPacketList* const pktlist) { - const double time = Time::getMillisecondCounterHiRes() * 0.001; + auto time = Time::getMillisecondCounterHiRes() * 0.001; const ScopedLock sl (callbackLock); + if (activeCallbacks.contains (this) && active) { - const MIDIPacket* packet = &pktlist->packet[0]; + auto* packet = &pktlist->packet[0]; for (unsigned int i = 0; i < pktlist->numPackets; ++i) { @@ -355,13 +355,13 @@ namespace CoreMidiHelpers } } - MidiInput* input; + MidiInput* input = nullptr; ScopedPointer portAndEndpoint; - volatile bool active; + volatile bool active = false; private: MidiInputCallback& callback; - MidiDataConcatenator concatenator; + MidiDataConcatenator concatenator { 2048 }; }; static void midiInputProc (const MIDIPacketList* pktlist, void* readProcRefCon, void* /*srcConnRefCon*/) diff --git a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp index ad96b5fd90..babe5722ff 100644 --- a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp @@ -1749,8 +1749,8 @@ namespace WavFileHelpers outStream.release(); bool ok = writer->writeFromAudioReader (*reader, 0, -1); - writer = nullptr; - reader = nullptr; + writer.reset(); + reader.reset(); return ok && tempFile.overwriteTargetFileWithTemporary(); } @@ -1769,7 +1769,7 @@ bool WavAudioFormat::replaceMetadataInFile (const File& wavFile, const StringPai { auto bwavPos = reader->bwavChunkStart; auto bwavSize = reader->bwavSize; - reader = nullptr; + reader.reset(); if (bwavSize > 0) { diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp index a21b0570e1..af46b3c36e 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp @@ -389,7 +389,7 @@ bool MemoryMappedAudioFormatReader::mapSectionOfFile (Range samplesToMap) { if (map == nullptr || samplesToMap != mappedSection) { - map = nullptr; + map.reset(); const Range fileRange (sampleToFilePos (samplesToMap.getStart()), sampleToFilePos (samplesToMap.getEnd())); @@ -397,7 +397,7 @@ bool MemoryMappedAudioFormatReader::mapSectionOfFile (Range samplesToMap) map = new MemoryMappedFile (file, fileRange, MemoryMappedFile::readOnly); if (map->getData() == nullptr) - map = nullptr; + map.reset(); else mappedSection = Range (jmax ((int64) 0, filePosToSample (map->getRange().getStart() + (bytesPerFrame - 1))), jmin (lengthInSamples, filePosToSample (map->getRange().getEnd()))); diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp index 07097b5682..98d3709b7d 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp @@ -113,7 +113,7 @@ void AudioProcessorEditor::setResizable (const bool shouldBeResizable, const boo } else { - resizableCorner = nullptr; + resizableCorner.reset(); } } } diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp index 2053ab9d16..cf9ee5c23c 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp @@ -1177,8 +1177,8 @@ void AudioProcessorGraph::buildRenderingSequence() { { const ScopedLock sl (getCallbackLock()); - renderSequenceFloat = nullptr; - renderSequenceDouble = nullptr; + renderSequenceFloat.reset(); + renderSequenceDouble.reset(); } for (auto* node : nodes) diff --git a/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp b/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp index 733842ffbe..e5462dfb41 100644 --- a/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp +++ b/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp @@ -385,7 +385,7 @@ public: if (pool != nullptr) { pool->removeAllJobs (true, 60000); - pool = nullptr; + pool.reset(); } } @@ -580,7 +580,7 @@ void PluginListComponent::scanFinished (const StringArray& failedFiles) for (int i = 0; i < failedFiles.size(); ++i) shortNames.add (File::createFileWithoutCheckingPath (failedFiles[i]).getFileName()); - currentScanner = nullptr; // mustn't delete this before using the failed files array + currentScanner.reset(); // mustn't delete this before using the failed files array if (shortNames.size() > 0) AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon, diff --git a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp index f2cb5350c7..79aaec8dca 100644 --- a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp @@ -459,8 +459,8 @@ public: } else { - outputChanLabel = nullptr; - outputChanList = nullptr; + outputChanLabel.reset(); + outputChanList.reset(); } if (setup.maxNumInputChannels > 0 @@ -480,8 +480,8 @@ public: } else { - inputChanLabel = nullptr; - inputChanList = nullptr; + inputChanLabel.reset(); + inputChanList.reset(); } updateSampleRateComboBox (currentDevice); @@ -491,15 +491,15 @@ public: { jassert (setup.manager->getCurrentAudioDevice() == nullptr); // not the correct device type! - inputChanLabel = nullptr; - outputChanLabel = nullptr; - sampleRateLabel = nullptr; - bufferSizeLabel = nullptr; + inputChanLabel.reset(); + outputChanLabel.reset(); + sampleRateLabel.reset(); + bufferSizeLabel.reset(); - inputChanList = nullptr; - outputChanList = nullptr; - sampleRateDropDown = nullptr; - bufferSizeDropDown = nullptr; + inputChanList.reset(); + outputChanList.reset(); + sampleRateDropDown.reset(); + bufferSizeDropDown.reset(); if (outputDeviceDropDown != nullptr) outputDeviceDropDown->setSelectedId (-1, dontSendNotification); @@ -574,8 +574,8 @@ private: void updateControlPanelButton() { - AudioIODevice* const currentDevice = setup.manager->getCurrentAudioDevice(); - showUIButton = nullptr; + auto* currentDevice = setup.manager->getCurrentAudioDevice(); + showUIButton.reset(); if (currentDevice != nullptr && currentDevice->hasControlPanel()) { @@ -606,7 +606,7 @@ private: } } - resetDeviceButton = nullptr; + resetDeviceButton.reset(); } void updateOutputsComboBox() @@ -1033,9 +1033,9 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager& } else { - midiInputsList = nullptr; - midiInputsLabel = nullptr; - bluetoothButton = nullptr; + midiInputsList.reset(); + midiInputsLabel.reset(); + bluetoothButton.reset(); } if (showMidiOutputSelector) @@ -1048,8 +1048,8 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager& } else { - midiOutputSelector = nullptr; - midiOutputLabel = nullptr; + midiOutputSelector.reset(); + midiOutputLabel.reset(); } deviceManager.addChangeListener (this); @@ -1123,7 +1123,7 @@ void AudioDeviceSelectorComponent::comboBoxChanged (ComboBox* comboBoxThatHasCha { if (AudioIODeviceType* const type = deviceManager.getAvailableDeviceTypes() [deviceTypeDropDown->getSelectedId() - 1]) { - audioDeviceSettingsComp = nullptr; + audioDeviceSettingsComp.reset(); deviceManager.setCurrentAudioDeviceType (type->getTypeName(), true); updateAllControls(); // needed in case the type hasn't actually changed } @@ -1153,11 +1153,10 @@ void AudioDeviceSelectorComponent::updateAllControls() || audioDeviceSettingsCompType != deviceManager.getCurrentAudioDeviceType()) { audioDeviceSettingsCompType = deviceManager.getCurrentAudioDeviceType(); - audioDeviceSettingsComp = nullptr; + audioDeviceSettingsComp.reset(); - if (AudioIODeviceType* const type - = deviceManager.getAvailableDeviceTypes() [deviceTypeDropDown == nullptr - ? 0 : deviceTypeDropDown->getSelectedId() - 1]) + if (auto* type = deviceManager.getAvailableDeviceTypes() [deviceTypeDropDown == nullptr + ? 0 : deviceTypeDropDown->getSelectedId() - 1]) { AudioDeviceSetupDetails details; details.manager = &deviceManager; @@ -1167,7 +1166,7 @@ void AudioDeviceSelectorComponent::updateAllControls() details.maxNumOutputChannels = maxOutputChannels; details.useStereoPairs = showChannelsAsStereoPairs; - AudioDeviceSettingsPanel* sp = new AudioDeviceSettingsPanel (*type, details, hideAdvancedOptionsWithButton); + auto* sp = new AudioDeviceSettingsPanel (*type, details, hideAdvancedOptionsWithButton); audioDeviceSettingsComp = sp; addAndMakeVisible (sp); sp->updateAllControls(); @@ -1185,7 +1184,7 @@ void AudioDeviceSelectorComponent::updateAllControls() { midiOutputSelector->clear(); - const StringArray midiOuts (MidiOutput::getDevices()); + auto midiOuts = MidiOutput::getDevices(); midiOutputSelector->addItem (getNoDeviceString(), -1); midiOutputSelector->addSeparator(); diff --git a/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp b/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp index 6aa1db2d24..89bcfc7091 100644 --- a/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp @@ -120,7 +120,7 @@ public: sampleRate = reader->sampleRate; if (lengthInSamples <= 0 || isFullyLoaded()) - reader = nullptr; + reader.reset(); else owner.cache.getTimeSliceThread().addTimeSliceClient (this); } @@ -155,7 +155,7 @@ public: void releaseResources() { const ScopedLock sl (readerLock); - reader = nullptr; + reader.reset(); } int useTimeSlice() override @@ -557,7 +557,7 @@ AudioThumbnail::~AudioThumbnail() void AudioThumbnail::clear() { - source = nullptr; + source.reset(); const ScopedLock sl (lock); clearChannelData(); } diff --git a/modules/juce_core/containers/juce_OwnedArray.h b/modules/juce_core/containers/juce_OwnedArray.h index ccfacb0436..0d08417489 100644 --- a/modules/juce_core/containers/juce_OwnedArray.h +++ b/modules/juce_core/containers/juce_OwnedArray.h @@ -51,7 +51,6 @@ public: //============================================================================== /** Creates an empty array. */ OwnedArray() noexcept - : numUsed (0) { } @@ -139,7 +138,7 @@ public: if (isPositiveAndBelow (index, numUsed)) { jassert (data.elements != nullptr); - return data.elements [index]; + return data.elements[index]; } return nullptr; @@ -154,7 +153,7 @@ public: { const ScopedLockType lock (getLock()); jassert (isPositiveAndBelow (index, numUsed) && data.elements != nullptr); - return data.elements [index]; + return data.elements[index]; } /** Returns a pointer to the first object in the array. @@ -169,7 +168,7 @@ public: if (numUsed > 0) { jassert (data.elements != nullptr); - return data.elements [0]; + return data.elements[0]; } return nullptr; @@ -187,7 +186,7 @@ public: if (numUsed > 0) { jassert (data.elements != nullptr); - return data.elements [numUsed - 1]; + return data.elements[numUsed - 1]; } return nullptr; @@ -233,8 +232,8 @@ public: int indexOf (const ObjectClass* objectToLookFor) const noexcept { const ScopedLockType lock (getLock()); - ObjectClass* const* e = data.elements.get(); - ObjectClass* const* const end_ = e + numUsed; + auto** e = data.elements.get(); + auto** end_ = e + numUsed; for (; e != end_; ++e) if (objectToLookFor == *e) @@ -251,8 +250,8 @@ public: bool contains (const ObjectClass* objectToLookFor) const noexcept { const ScopedLockType lock (getLock()); - ObjectClass* const* e = data.elements.get(); - ObjectClass* const* const end_ = e + numUsed; + auto** e = data.elements.get(); + auto** end_ = e + numUsed; for (; e != end_; ++e) if (objectToLookFor == *e) @@ -279,7 +278,7 @@ public: const ScopedLockType lock (getLock()); data.ensureAllocatedSize (numUsed + 1); jassert (data.elements != nullptr); - data.elements [numUsed++] = newObject; + data.elements[numUsed++] = newObject; return newObject; } @@ -314,8 +313,8 @@ public: data.ensureAllocatedSize (numUsed + 1); jassert (data.elements != nullptr); - ObjectClass** const e = data.elements + indexToInsertAt; - const int numToMove = numUsed - indexToInsertAt; + auto** e = data.elements + indexToInsertAt; + auto numToMove = numUsed - indexToInsertAt; if (numToMove > 0) memmove (e + 1, e, sizeof (ObjectClass*) * (size_t) numToMove); @@ -345,12 +344,12 @@ public: { const ScopedLockType lock (getLock()); data.ensureAllocatedSize (numUsed + numberOfElements); - ObjectClass** insertPos = data.elements; + auto* insertPos = data.elements.get(); if (isPositiveAndBelow (indexToInsertAt, numUsed)) { insertPos += indexToInsertAt; - const size_t numberToMove = (size_t) (numUsed - indexToInsertAt); + auto numberToMove = (size_t) (numUsed - indexToInsertAt); memmove (insertPos + numberOfElements, insertPos, numberToMove * sizeof (ObjectClass*)); } else @@ -410,18 +409,18 @@ public: { if (deleteOldElement) { - toDelete = data.elements [indexToChange]; + toDelete = data.elements[indexToChange]; if (toDelete == newObject) toDelete.release(); } - data.elements [indexToChange] = newObject; + data.elements[indexToChange] = newObject; } else { data.ensureAllocatedSize (numUsed + 1); - data.elements [numUsed++] = newObject; + data.elements[numUsed++] = newObject; } } } @@ -465,7 +464,7 @@ public: while (--numElementsToAdd >= 0) { - data.elements [numUsed] = arrayToAddFrom.getUnchecked (startIndex++); + data.elements[numUsed] = arrayToAddFrom.getUnchecked (startIndex++); ++numUsed; } } @@ -505,7 +504,7 @@ public: jassert (numElementsToAdd <= 0 || data.elements != nullptr); while (--numElementsToAdd >= 0) - data.elements [numUsed++] = createCopyIfNotNull (arrayToAddFrom.getUnchecked (startIndex++)); + data.elements[numUsed++] = createCopyIfNotNull (arrayToAddFrom.getUnchecked (startIndex++)); } /** Inserts a new object into the array assuming that the array is sorted. @@ -552,14 +551,15 @@ public: while (s < e) { - if (comparator.compareElements (objectToLookFor, data.elements [s]) == 0) + if (comparator.compareElements (objectToLookFor, data.elements[s]) == 0) return s; - const int halfway = (s + e) / 2; + auto halfway = (s + e) / 2; + if (halfway == s) break; - if (comparator.compareElements (objectToLookFor, data.elements [halfway]) >= 0) + if (comparator.compareElements (objectToLookFor, data.elements[halfway]) >= 0) s = halfway; else e = halfway; @@ -588,13 +588,13 @@ public: if (isPositiveAndBelow (indexToRemove, numUsed)) { - ObjectClass** const e = data.elements + indexToRemove; + auto** e = data.elements + indexToRemove; if (deleteObject) - toDelete = *e; + toDelete.reset (*e); --numUsed; - const int numToShift = numUsed - indexToRemove; + auto numToShift = numUsed - indexToRemove; if (numToShift > 0) memmove (e, e + 1, sizeof (ObjectClass*) * (size_t) numToShift); @@ -621,7 +621,7 @@ public: if (isPositiveAndBelow (indexToRemove, numUsed)) { - ObjectClass** const e = data.elements + indexToRemove; + auto** e = data.elements + indexToRemove; removedItem = *e; --numUsed; @@ -648,7 +648,7 @@ public: void removeObject (const ObjectClass* objectToRemove, bool deleteObject = true) { const ScopedLockType lock (getLock()); - ObjectClass** const e = data.elements.get(); + auto** e = data.elements.get(); for (int i = 0; i < numUsed; ++i) { @@ -676,7 +676,7 @@ public: void removeRange (int startIndex, int numberToRemove, bool deleteObjects = true) { const ScopedLockType lock (getLock()); - const int endIndex = jlimit (0, numUsed, startIndex + numberToRemove); + auto endIndex = jlimit (0, numUsed, startIndex + numberToRemove); startIndex = jlimit (0, numUsed, startIndex); if (endIndex > startIndex) @@ -685,19 +685,19 @@ public: { for (int i = startIndex; i < endIndex; ++i) { - ContainerDeletePolicy::destroy (data.elements [i]); - data.elements [i] = nullptr; // (in case one of the destructors accesses this array and hits a dangling pointer) + ContainerDeletePolicy::destroy (data.elements[i]); + data.elements[i] = nullptr; // (in case one of the destructors accesses this array and hits a dangling pointer) } } - const int rangeSize = endIndex - startIndex; - ObjectClass** e = data.elements + startIndex; - int numToShift = numUsed - endIndex; + auto rangeSize = endIndex - startIndex; + auto** e = data.elements + startIndex; + auto numToShift = numUsed - endIndex; numUsed -= rangeSize; while (--numToShift >= 0) { - *e = e [rangeSize]; + *e = e[rangeSize]; ++e; } @@ -736,8 +736,8 @@ public: if (isPositiveAndBelow (index1, numUsed) && isPositiveAndBelow (index2, numUsed)) { - std::swap (data.elements [index1], - data.elements [index2]); + std::swap (data.elements[index1], + data.elements[index2]); } } @@ -765,7 +765,7 @@ public: if (! isPositiveAndBelow (newIndex, numUsed)) newIndex = numUsed - 1; - ObjectClass* const value = data.elements [currentIndex]; + auto* value = data.elements[currentIndex]; if (newIndex > currentIndex) { @@ -780,7 +780,7 @@ public: sizeof (ObjectClass*) * (size_t) (currentIndex - newIndex)); } - data.elements [newIndex] = value; + data.elements[newIndex] = value; } } } @@ -882,12 +882,12 @@ public: private: //============================================================================== ArrayAllocationBase data; - int numUsed; + int numUsed = 0; void deleteAllObjects() { while (numUsed > 0) - ContainerDeletePolicy::destroy (data.elements [--numUsed]); + ContainerDeletePolicy::destroy (data.elements[--numUsed]); } JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OwnedArray) diff --git a/modules/juce_core/files/juce_DirectoryIterator.cpp b/modules/juce_core/files/juce_DirectoryIterator.cpp index a0f8aaa38e..5a8a952bca 100644 --- a/modules/juce_core/files/juce_DirectoryIterator.cpp +++ b/modules/juce_core/files/juce_DirectoryIterator.cpp @@ -79,7 +79,7 @@ bool DirectoryIterator::next (bool* const isDirResult, bool* const isHiddenResul if (subIterator->next (isDirResult, isHiddenResult, fileSize, modTime, creationTime, isReadOnly)) return true; - subIterator = nullptr; + subIterator.reset(); } String filename; diff --git a/modules/juce_core/javascript/juce_Javascript.cpp b/modules/juce_core/javascript/juce_Javascript.cpp index 75f7505544..aaa5fb1d14 100644 --- a/modules/juce_core/javascript/juce_Javascript.cpp +++ b/modules/juce_core/javascript/juce_Javascript.cpp @@ -1103,7 +1103,7 @@ struct JavascriptEngine::RootObject : public DynamicObject Expression* parseInPlaceOpExpression (ExpPtr& lhs) { ExpPtr rhs (parseExpression()); - Expression* bareLHS = lhs; // careful - bare pointer is deliberately alised + Expression* bareLHS = lhs.get(); // careful - bare pointer is deliberately alised return new SelfAssignment (location, bareLHS, new OpType (location, lhs, rhs)); } diff --git a/modules/juce_core/memory/juce_OptionalScopedPointer.h b/modules/juce_core/memory/juce_OptionalScopedPointer.h index 898c95ca56..d1eab793b2 100644 --- a/modules/juce_core/memory/juce_OptionalScopedPointer.h +++ b/modules/juce_core/memory/juce_OptionalScopedPointer.h @@ -98,7 +98,7 @@ public: //============================================================================== /** Returns the object that this pointer is managing. */ - inline operator ObjectType*() const noexcept { return object; } + inline operator ObjectType*() const noexcept { return object.get(); } /** Returns the object that this pointer is managing. */ inline ObjectType* get() const noexcept { return object; } @@ -107,7 +107,7 @@ public: inline ObjectType& operator*() const noexcept { return *object; } /** Lets you access methods and properties of the object that this pointer is holding. */ - inline ObjectType* operator->() const noexcept { return object; } + inline ObjectType* operator->() const noexcept { return object.get(); } //============================================================================== /** Removes the current object from this OptionalScopedPointer without deleting it. diff --git a/modules/juce_core/memory/juce_ScopedPointer.h b/modules/juce_core/memory/juce_ScopedPointer.h index a0e741d0a0..9b2dc40aef 100644 --- a/modules/juce_core/memory/juce_ScopedPointer.h +++ b/modules/juce_core/memory/juce_ScopedPointer.h @@ -170,6 +170,12 @@ public: } } + /** Sets this pointer to a new object, deleting the old object that it was previously pointing to if there was one. */ + void reset (ScopedPointer& newObject) + { + reset (newObject.release()); + } + /** Detaches and returns the current object from this ScopedPointer without deleting it. This will return the current object, and set the ScopedPointer to a null pointer. */ @@ -191,7 +197,7 @@ public: /** If the pointer is non-null, this will attempt to return a new copy of the object that is pointed to. If the pointer is null, this will safely return a nullptr. */ - inline ObjectType* createCopy() const { return createCopyIfNotNull (object); } + inline ObjectType* createCopy() const { return createCopyIfNotNull (object); } private: //============================================================================== @@ -206,22 +212,74 @@ private: }; //============================================================================== -/** Compares a ScopedPointer with another pointer. - This can be handy for checking whether this is a null pointer. -*/ -template -bool operator== (const ScopedPointer& pointer1, ObjectType* pointer2) noexcept +/** Compares a ScopedPointer with another pointer. */ +template +bool operator== (ObjectType1* pointer1, const ScopedPointer& pointer2) noexcept { - return static_cast (pointer1) == pointer2; + return pointer1 == pointer2.get(); } -/** Compares a ScopedPointer with another pointer. - This can be handy for checking whether this is a null pointer. -*/ -template -bool operator!= (const ScopedPointer& pointer1, ObjectType* pointer2) noexcept +/** Compares a ScopedPointer with another pointer. */ +template +bool operator!= (ObjectType1* pointer1, const ScopedPointer& pointer2) noexcept { - return static_cast (pointer1) != pointer2; + return pointer1 != pointer2.get(); +} + +/** Compares a ScopedPointer with another pointer. */ +template +bool operator== (const ScopedPointer& pointer1, ObjectType2* pointer2) noexcept +{ + return pointer1.get() == pointer2; +} + +/** Compares a ScopedPointer with another pointer. */ +template +bool operator!= (const ScopedPointer& pointer1, ObjectType2* pointer2) noexcept +{ + return pointer1.get() != pointer2; +} + +/** Compares a ScopedPointer with another pointer. */ +template +bool operator== (const ScopedPointer& pointer1, const ScopedPointer& pointer2) noexcept +{ + return pointer1.get() == pointer2.get(); +} + +/** Compares a ScopedPointer with another pointer. */ +template +bool operator!= (const ScopedPointer& pointer1, const ScopedPointer& pointer2) noexcept +{ + return pointer1.get() != pointer2.get(); +} + +/** Compares a ScopedPointer with a nullptr. */ +template +bool operator== (decltype (nullptr), const ScopedPointer& pointer) noexcept +{ + return pointer.get() == nullptr; +} + +/** Compares a ScopedPointer with a nullptr. */ +template +bool operator!= (decltype (nullptr), const ScopedPointer& pointer) noexcept +{ + return pointer.get() != nullptr; +} + +/** Compares a ScopedPointer with a nullptr. */ +template +bool operator== (const ScopedPointer& pointer, decltype (nullptr)) noexcept +{ + return pointer.get() == nullptr; +} + +/** Compares a ScopedPointer with a nullptr. */ +template +bool operator!= (const ScopedPointer& pointer, decltype (nullptr)) noexcept +{ + return pointer.get() != nullptr; } //============================================================================== diff --git a/modules/juce_core/misc/juce_StdFunctionCompat.cpp b/modules/juce_core/misc/juce_StdFunctionCompat.cpp index 1f98f552f3..80aa696535 100644 --- a/modules/juce_core/misc/juce_StdFunctionCompat.cpp +++ b/modules/juce_core/misc/juce_StdFunctionCompat.cpp @@ -176,7 +176,7 @@ public: ScopedPointer> fStackTmp (new std::function (fStack)); std::function f1 (static_cast&&> (*fStackTmp)); - fStackTmp = nullptr; + fStackTmp.reset(); expectEquals (f1(), 3); ScopedPointer> fHeapTmp (new std::function (fHeap)); @@ -184,12 +184,12 @@ public: if (*fHeapTmp) expect (false); - fHeapTmp = nullptr; + fHeapTmp.reset(); expectEquals (f2(), FunctionTestsHelpers::BigData::bigDataSum); ScopedPointer> fEmptyTmp (new std::function()); std::function f3 (static_cast&&> (*fEmptyTmp)); - fEmptyTmp = nullptr; + fEmptyTmp.reset(); if (f3) expect (false); } @@ -201,7 +201,7 @@ public: ScopedPointer> fStackTmp (new std::function (fStack)); f1 = static_cast&&> (*fStackTmp); - fStackTmp = nullptr; + fStackTmp.reset(); expectEquals (f1(), 3); std::function f2 (fStack); @@ -210,13 +210,13 @@ public: if (*fHeapTmp) expect (false); - fHeapTmp = nullptr; + fHeapTmp.reset(); expectEquals (f2(), FunctionTestsHelpers::BigData::bigDataSum); std::function f3 (fHeap); ScopedPointer> fEmptyTmp (new std::function()); f3 = static_cast&&> (*fEmptyTmp); - fEmptyTmp = nullptr; + fEmptyTmp.reset(); if (f3) expect (false); } diff --git a/modules/juce_core/native/juce_mac_Network.mm b/modules/juce_core/native/juce_mac_Network.mm index 4894fc366b..9804873df5 100644 --- a/modules/juce_core/native/juce_mac_Network.mm +++ b/modules/juce_core/native/juce_mac_Network.mm @@ -941,7 +941,7 @@ public: ~Pimpl() { - connection = nullptr; + connection.reset(); } bool connect (WebInputStream::Listener* webInputListener, int numRetries = 0) @@ -963,12 +963,12 @@ public: #if ! (JUCE_IOS || (defined (__MAC_OS_X_VERSION_MIN_REQUIRED) && defined (__MAC_10_10) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_10)) if (numRetries == 0 && connection->nsUrlErrorCode == NSURLErrorNetworkConnectionLost) { - connection = nullptr; + connection.reset(); return connect (webInputListener, ++numRetries); } #endif - connection = nullptr; + connection.reset(); return false; } diff --git a/modules/juce_core/native/juce_posix_NamedPipe.cpp b/modules/juce_core/native/juce_posix_NamedPipe.cpp index be948ffd4f..4195a7301a 100644 --- a/modules/juce_core/native/juce_posix_NamedPipe.cpp +++ b/modules/juce_core/native/juce_posix_NamedPipe.cpp @@ -191,7 +191,7 @@ void NamedPipe::close() ignoreUnused (done); ScopedWriteLock sl (lock); - pimpl = nullptr; + pimpl.reset(); } } @@ -211,7 +211,7 @@ bool NamedPipe::openInternal (const String& pipeName, const bool createPipe, boo if (createPipe && ! pimpl->createFifos (mustNotExist)) { - pimpl = nullptr; + pimpl.reset(); return false; } diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h index ead34e6a6b..6f1257e7d7 100644 --- a/modules/juce_core/native/juce_posix_SharedCode.h +++ b/modules/juce_core/native/juce_posix_SharedCode.h @@ -880,7 +880,7 @@ bool InterProcessLock::enter (const int timeOutMillisecs) pimpl = new Pimpl (name, timeOutMillisecs); if (pimpl->handle == 0) - pimpl = nullptr; + pimpl.reset(); } else { @@ -898,7 +898,7 @@ void InterProcessLock::exit() jassert (pimpl != nullptr); if (pimpl != nullptr && --(pimpl->refCount) == 0) - pimpl = nullptr; + pimpl.reset(); } //============================================================================== @@ -1260,7 +1260,7 @@ bool ChildProcess::start (const StringArray& args, int streamFlags) activeProcess = new ActiveProcess (args, streamFlags); if (activeProcess->childPID == 0) - activeProcess = nullptr; + activeProcess.reset(); return activeProcess != nullptr; } diff --git a/modules/juce_core/zip/juce_ZipFile.cpp b/modules/juce_core/zip/juce_ZipFile.cpp index c021126a5c..958788a699 100644 --- a/modules/juce_core/zip/juce_ZipFile.cpp +++ b/modules/juce_core/zip/juce_ZipFile.cpp @@ -534,7 +534,7 @@ private: uncompressedSize += bytesRead; } - stream = nullptr; + stream.reset(); return true; } diff --git a/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp b/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp index eca113fb41..ba06f5b910 100644 --- a/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp +++ b/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp @@ -28,7 +28,6 @@ namespace juce { ApplicationProperties::ApplicationProperties() - : commonSettingsAreReadOnly (0) { } @@ -56,16 +55,16 @@ void ApplicationProperties::openFiles() if (userProps == nullptr) { o.commonToAllUsers = false; - userProps = new PropertiesFile (o); + userProps.reset (new PropertiesFile (o)); } if (commonProps == nullptr) { o.commonToAllUsers = true; - commonProps = new PropertiesFile (o); + commonProps.reset (new PropertiesFile (o)); } - userProps->setFallbackPropertySet (commonProps); + userProps->setFallbackPropertySet (commonProps.get()); } } @@ -74,7 +73,7 @@ PropertiesFile* ApplicationProperties::getUserSettings() if (userProps == nullptr) openFiles(); - return userProps; + return userProps.get(); } PropertiesFile* ApplicationProperties::getCommonSettings (const bool returnUserPropsIfReadOnly) @@ -88,10 +87,10 @@ PropertiesFile* ApplicationProperties::getCommonSettings (const bool returnUserP commonSettingsAreReadOnly = commonProps->save() ? -1 : 1; if (commonSettingsAreReadOnly > 0) - return userProps; + return userProps.get(); } - return commonProps; + return commonProps.get(); } bool ApplicationProperties::saveIfNeeded() @@ -102,8 +101,8 @@ bool ApplicationProperties::saveIfNeeded() void ApplicationProperties::closeFiles() { - userProps = nullptr; - commonProps = nullptr; + userProps.reset(); + commonProps.reset(); } } // namespace juce diff --git a/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h b/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h index faa3817c43..6563b72cb5 100644 --- a/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h +++ b/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h @@ -122,7 +122,7 @@ private: //============================================================================== PropertiesFile::Options options; ScopedPointer userProps, commonProps; - int commonSettingsAreReadOnly; + int commonSettingsAreReadOnly = 0; void openFiles(); diff --git a/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp b/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp index d964fb9cdd..a463b48d8c 100644 --- a/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp +++ b/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp @@ -331,7 +331,7 @@ bool PropertiesFile::saveAsBinary() out->writeString (values[i]); } - out = nullptr; + out.reset(); if (tempFile.overwriteTargetFileWithTemporary()) { diff --git a/modules/juce_data_structures/undomanager/juce_UndoManager.cpp b/modules/juce_data_structures/undomanager/juce_UndoManager.cpp index a5a705a32e..b850912973 100644 --- a/modules/juce_data_structures/undomanager/juce_UndoManager.cpp +++ b/modules/juce_data_structures/undomanager/juce_UndoManager.cpp @@ -36,8 +36,8 @@ struct UndoManager::ActionSet bool perform() const { - for (int i = 0; i < actions.size(); ++i) - if (! actions.getUnchecked(i)->perform()) + for (auto* a : actions) + if (! a->perform()) return false; return true; @@ -56,8 +56,8 @@ struct UndoManager::ActionSet { int total = 0; - for (int i = actions.size(); --i >= 0;) - total += actions.getUnchecked(i)->getSizeInUnits(); + for (auto* a : actions) + total += a->getSizeInUnits(); return total; } @@ -68,15 +68,9 @@ struct UndoManager::ActionSet }; //============================================================================== -UndoManager::UndoManager (const int maxNumberOfUnitsToKeep, - const int minimumTransactions) - : totalUnitsStored (0), - nextIndex (0), - newTransaction (true), - reentrancyCheck (false) +UndoManager::UndoManager (int maxNumberOfUnitsToKeep, int minimumTransactions) { - setMaxNumberOfStoredUnits (maxNumberOfUnitsToKeep, - minimumTransactions); + setMaxNumberOfStoredUnits (maxNumberOfUnitsToKeep, minimumTransactions); } UndoManager::~UndoManager() @@ -97,11 +91,10 @@ int UndoManager::getNumberOfUnitsTakenUpByStoredCommands() const return totalUnitsStored; } -void UndoManager::setMaxNumberOfStoredUnits (const int maxNumberOfUnitsToKeep, - const int minimumTransactions) +void UndoManager::setMaxNumberOfStoredUnits (int maxUnits, int minTransactions) { - maxNumUnitsToKeep = jmax (1, maxNumberOfUnitsToKeep); - minimumTransactionsToKeep = jmax (1, minimumTransactions); + maxNumUnitsToKeep = jmax (1, maxUnits); + minimumTransactionsToKeep = jmax (1, minTransactions); } //============================================================================== @@ -118,7 +111,7 @@ bool UndoManager::perform (UndoableAction* const newAction, const String& action return false; } -bool UndoManager::perform (UndoableAction* const newAction) +bool UndoManager::perform (UndoableAction* newAction) { if (newAction != nullptr) { @@ -133,15 +126,15 @@ bool UndoManager::perform (UndoableAction* const newAction) if (action->perform()) { - ActionSet* actionSet = getCurrentSet(); + auto* actionSet = getCurrentSet(); if (actionSet != nullptr && ! newTransaction) { - if (UndoableAction* const lastAction = actionSet->actions.getLast()) + if (auto* lastAction = actionSet->actions.getLast()) { - if (UndoableAction* const coalescedAction = lastAction->createCoalescedAction (action)) + if (auto coalescedAction = lastAction->createCoalescedAction (action.get())) { - action = coalescedAction; + action.reset (coalescedAction); totalUnitsStored -= lastAction->getSizeInUnits(); actionSet->actions.removeLast(); } @@ -176,7 +169,7 @@ void UndoManager::moveFutureTransactionsToStash() while (nextIndex < transactions.size()) { - ActionSet* removed = transactions.removeAndReturn (nextIndex); + auto* removed = transactions.removeAndReturn (nextIndex); stashedFutureTransactions.add (removed); totalUnitsStored -= removed->getTotalSize(); } @@ -191,11 +184,10 @@ void UndoManager::restoreStashedFutureTransactions() transactions.remove (nextIndex); } - for (int i = 0; i < stashedFutureTransactions.size(); ++i) + for (auto* stashed : stashedFutureTransactions) { - ActionSet* action = stashedFutureTransactions.removeAndReturn (i); - totalUnitsStored += action->getTotalSize(); - transactions.add (action); + transactions.add (stashed); + totalUnitsStored += stashed->getTotalSize(); } stashedFutureTransactions.clearQuick (false); @@ -219,7 +211,7 @@ void UndoManager::dropOldTransactionsIfTooLarge() void UndoManager::beginNewTransaction() noexcept { - beginNewTransaction (String()); + beginNewTransaction ({}); } void UndoManager::beginNewTransaction (const String& actionName) noexcept @@ -232,13 +224,13 @@ void UndoManager::setCurrentTransactionName (const String& newName) noexcept { if (newTransaction) newTransactionName = newName; - else if (ActionSet* action = getCurrentSet()) + else if (auto* action = getCurrentSet()) action->name = newName; } String UndoManager::getCurrentTransactionName() const noexcept { - if (ActionSet* action = getCurrentSet()) + if (auto* action = getCurrentSet()) return action->name; return newTransactionName; @@ -253,7 +245,7 @@ bool UndoManager::canRedo() const noexcept { return getNextSet() != nullptr bool UndoManager::undo() { - if (const ActionSet* const s = getCurrentSet()) + if (auto* s = getCurrentSet()) { const ScopedValueSetter setter (reentrancyCheck, true); @@ -272,7 +264,7 @@ bool UndoManager::undo() bool UndoManager::redo() { - if (const ActionSet* const s = getNextSet()) + if (auto* s = getNextSet()) { const ScopedValueSetter setter (reentrancyCheck, true); @@ -335,15 +327,15 @@ bool UndoManager::undoCurrentTransactionOnly() void UndoManager::getActionsInCurrentTransaction (Array& actionsFound) const { if (! newTransaction) - if (const ActionSet* const s = getCurrentSet()) - for (int i = 0; i < s->actions.size(); ++i) - actionsFound.add (s->actions.getUnchecked(i)); + if (auto* s = getCurrentSet()) + for (auto* a : s->actions) + actionsFound.add (a); } int UndoManager::getNumActionsInCurrentTransaction() const { if (! newTransaction) - if (const ActionSet* const s = getCurrentSet()) + if (auto* s = getCurrentSet()) return s->actions.size(); return 0; diff --git a/modules/juce_data_structures/undomanager/juce_UndoManager.h b/modules/juce_data_structures/undomanager/juce_UndoManager.h index 75f3d0f30d..f7a356f8d5 100644 --- a/modules/juce_data_structures/undomanager/juce_UndoManager.h +++ b/modules/juce_data_structures/undomanager/juce_UndoManager.h @@ -232,8 +232,8 @@ private: friend struct ContainerDeletePolicy; OwnedArray transactions, stashedFutureTransactions; String newTransactionName; - int totalUnitsStored, maxNumUnitsToKeep, minimumTransactionsToKeep, nextIndex; - bool newTransaction, reentrancyCheck; + int totalUnitsStored = 0, maxNumUnitsToKeep = 0, minimumTransactionsToKeep = 0, nextIndex = 0; + bool newTransaction = true, reentrancyCheck = false; ActionSet* getCurrentSet() const noexcept; ActionSet* getNextSet() const noexcept; void moveFutureTransactionsToStash(); diff --git a/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp b/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp index 9e7070e4d0..093b5b0862 100644 --- a/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp +++ b/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp @@ -128,7 +128,7 @@ ChildProcessMaster::~ChildProcessMaster() { sendMessageToSlave (MemoryBlock (killMessage, specialMessageSize)); connection->disconnect(); - connection = nullptr; + connection.reset(); } } @@ -145,10 +145,10 @@ bool ChildProcessMaster::sendMessageToSlave (const MemoryBlock& mb) bool ChildProcessMaster::launchSlaveProcess (const File& executable, const String& commandLineUniqueID, int timeoutMs, int streamFlags) { - connection = nullptr; + connection.reset(); jassert (childProcess.kill()); - const String pipeName ("p" + String::toHexString (Random().nextInt64())); + auto pipeName = "p" + String::toHexString (Random().nextInt64()); StringArray args; args.add (executable.getFullPathName()); @@ -164,7 +164,7 @@ bool ChildProcessMaster::launchSlaveProcess (const File& executable, const Strin return true; } - connection = nullptr; + connection.reset(); } return false; @@ -257,7 +257,7 @@ bool ChildProcessSlave::initialiseFromCommandLine (const String& commandLine, connection = new Connection (*this, pipeName, timeoutMs <= 0 ? defaultTimeoutMs : timeoutMs); if (! connection->isConnected()) - connection = nullptr; + connection.reset(); } } diff --git a/modules/juce_events/interprocess/juce_InterprocessConnection.cpp b/modules/juce_events/interprocess/juce_InterprocessConnection.cpp index 8764d061c1..931995421e 100644 --- a/modules/juce_events/interprocess/juce_InterprocessConnection.cpp +++ b/modules/juce_events/interprocess/juce_InterprocessConnection.cpp @@ -45,7 +45,7 @@ InterprocessConnection::~InterprocessConnection() callbackConnectionState = false; disconnect(); masterReference.clear(); - thread = nullptr; + thread.reset(); } //============================================================================== @@ -65,7 +65,7 @@ bool InterprocessConnection::connectToSocket (const String& hostName, return true; } - socket = nullptr; + socket.reset(); return false; } @@ -121,8 +121,8 @@ void InterprocessConnection::disconnect() void InterprocessConnection::deletePipeAndSocket() { const ScopedLock sl (pipeAndSocketLock); - socket = nullptr; - pipe = nullptr; + socket.reset(); + pipe.reset(); } bool InterprocessConnection::isConnected() const diff --git a/modules/juce_events/interprocess/juce_InterprocessConnection.h b/modules/juce_events/interprocess/juce_InterprocessConnection.h index 7a5a1b72d3..5230c95b0d 100644 --- a/modules/juce_events/interprocess/juce_InterprocessConnection.h +++ b/modules/juce_events/interprocess/juce_InterprocessConnection.h @@ -122,10 +122,10 @@ public: bool isConnected() const; /** Returns the socket that this connection is using (or nullptr if it uses a pipe). */ - StreamingSocket* getSocket() const noexcept { return socket; } + StreamingSocket* getSocket() const noexcept { return socket.get(); } /** Returns the pipe that this connection is using (or nullptr if it uses a socket). */ - NamedPipe* getPipe() const noexcept { return pipe; } + NamedPipe* getPipe() const noexcept { return pipe.get(); } /** Returns the name of the machine at the other end of this connection. This may return an empty string if the name is unknown. diff --git a/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp b/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp index 6c9022bd46..8ac24ee50c 100644 --- a/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp +++ b/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp @@ -46,7 +46,7 @@ bool InterprocessConnectionServer::beginWaitingForSocket (const int portNumber, return true; } - socket = nullptr; + socket.reset(); return false; } @@ -58,7 +58,7 @@ void InterprocessConnectionServer::stop() socket->close(); stopThread (4000); - socket = nullptr; + socket.reset(); } int InterprocessConnectionServer::getBoundPort() const noexcept diff --git a/modules/juce_events/messages/juce_ApplicationBase.cpp b/modules/juce_events/messages/juce_ApplicationBase.cpp index cbd549f8b0..4a4642ae4e 100644 --- a/modules/juce_events/messages/juce_ApplicationBase.cpp +++ b/modules/juce_events/messages/juce_ApplicationBase.cpp @@ -304,7 +304,7 @@ bool JUCEApplicationBase::initialiseApp() #if JUCE_HANDLE_MULTIPLE_INSTANCES if (multipleInstanceHandler != nullptr) - MessageManager::getInstance()->registerBroadcastListener (multipleInstanceHandler); + MessageManager::getInstance()->registerBroadcastListener (multipleInstanceHandler.get()); #endif return true; @@ -316,7 +316,7 @@ int JUCEApplicationBase::shutdownApp() #if JUCE_HANDLE_MULTIPLE_INSTANCES if (multipleInstanceHandler != nullptr) - MessageManager::getInstance()->deregisterBroadcastListener (multipleInstanceHandler); + MessageManager::getInstance()->deregisterBroadcastListener (multipleInstanceHandler.get()); #endif JUCE_TRY @@ -326,7 +326,7 @@ int JUCEApplicationBase::shutdownApp() } JUCE_CATCH_EXCEPTION - multipleInstanceHandler = nullptr; + multipleInstanceHandler.reset(); return getApplicationReturnValue(); } diff --git a/modules/juce_events/messages/juce_MessageManager.cpp b/modules/juce_events/messages/juce_MessageManager.cpp index 13d9b5cddb..864e294e79 100644 --- a/modules/juce_events/messages/juce_MessageManager.cpp +++ b/modules/juce_events/messages/juce_MessageManager.cpp @@ -32,7 +32,7 @@ MessageManager::MessageManager() noexcept MessageManager::~MessageManager() noexcept { - broadcaster = nullptr; + broadcaster.reset(); doPlatformSpecificShutdown(); diff --git a/modules/juce_graphics/colour/juce_FillType.cpp b/modules/juce_graphics/colour/juce_FillType.cpp index e0a0c191de..4fc42296e9 100644 --- a/modules/juce_graphics/colour/juce_FillType.cpp +++ b/modules/juce_graphics/colour/juce_FillType.cpp @@ -37,13 +37,13 @@ FillType::FillType (Colour c) noexcept { } -FillType::FillType (const ColourGradient& gradient_) - : colour (0xff000000), gradient (new ColourGradient (gradient_)) +FillType::FillType (const ColourGradient& g) + : colour (0xff000000), gradient (new ColourGradient (g)) { } -FillType::FillType (const Image& image_, const AffineTransform& transform_) noexcept - : colour (0xff000000), image (image_), transform (transform_) +FillType::FillType (const Image& im, const AffineTransform& t) noexcept + : colour (0xff000000), image (im), transform (t) { } @@ -106,7 +106,7 @@ bool FillType::operator!= (const FillType& other) const void FillType::setColour (Colour newColour) noexcept { - gradient = nullptr; + gradient.reset(); image = Image(); colour = newColour; } @@ -125,11 +125,11 @@ void FillType::setGradient (const ColourGradient& newGradient) } } -void FillType::setTiledImage (const Image& image_, const AffineTransform& transform_) noexcept +void FillType::setTiledImage (const Image& newImage, const AffineTransform& newTransform) noexcept { - gradient = nullptr; - image = image_; - transform = transform_; + gradient.reset(); + image = newImage; + transform = newTransform; colour = Colours::black; } diff --git a/modules/juce_graphics/native/juce_RenderingHelpers.h b/modules/juce_graphics/native/juce_RenderingHelpers.h index e552758b2c..987fba713a 100644 --- a/modules/juce_graphics/native/juce_RenderingHelpers.h +++ b/modules/juce_graphics/native/juce_RenderingHelpers.h @@ -297,10 +297,10 @@ public: snapToIntegerCoordinate = typeface->isHinted(); glyph = glyphNumber; - const float fontHeight = font.getHeight(); - edgeTable = typeface->getEdgeTableForGlyph (glyphNumber, - AffineTransform::scale (fontHeight * font.getHorizontalScale(), - fontHeight), fontHeight); + auto fontHeight = font.getHeight(); + edgeTable.reset (typeface->getEdgeTableForGlyph (glyphNumber, + AffineTransform::scale (fontHeight * font.getHorizontalScale(), + fontHeight), fontHeight)); } Font font; diff --git a/modules/juce_gui_basics/buttons/juce_Button.cpp b/modules/juce_gui_basics/buttons/juce_Button.cpp index e82b83897d..fd90a382d6 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.cpp +++ b/modules/juce_gui_basics/buttons/juce_Button.cpp @@ -76,27 +76,7 @@ private: }; //============================================================================== -Button::Button (const String& name) - : Component (name), - text (name), - buttonPressTime (0), - lastRepeatTime (0), - commandManagerToUse (nullptr), - autoRepeatDelay (-1), - autoRepeatSpeed (0), - autoRepeatMinimumDelay (-1), - radioGroupId (0), - connectedEdgeFlags (0), - commandID(), - buttonState (buttonNormal), - lastStatePainted (buttonNormal), - lastToggleState (false), - clickTogglesState (false), - needsToRelease (false), - needsRepainting (false), - isKeyDown (false), - triggerOnMouseDown (false), - generateTooltip (false) +Button::Button (const String& name) : Component (name), text (name) { callbackHelper = new CallbackHelper (*this); @@ -112,7 +92,7 @@ Button::~Button() commandManagerToUse->removeListener (callbackHelper); isOn.removeListener (callbackHelper); - callbackHelper = nullptr; + callbackHelper.reset(); } //============================================================================== diff --git a/modules/juce_gui_basics/buttons/juce_Button.h b/modules/juce_gui_basics/buttons/juce_Button.h index 79de48cc27..91792d98ee 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.h +++ b/modules/juce_gui_basics/buttons/juce_Button.h @@ -479,21 +479,21 @@ private: friend class CallbackHelper; friend struct ContainerDeletePolicy; ScopedPointer callbackHelper; - uint32 buttonPressTime, lastRepeatTime; - ApplicationCommandManager* commandManagerToUse; - int autoRepeatDelay, autoRepeatSpeed, autoRepeatMinimumDelay; - int radioGroupId, connectedEdgeFlags; - CommandID commandID; - ButtonState buttonState, lastStatePainted; + uint32 buttonPressTime = 0, lastRepeatTime = 0; + ApplicationCommandManager* commandManagerToUse = nullptr; + int autoRepeatDelay = -1, autoRepeatSpeed = 0, autoRepeatMinimumDelay = -1; + int radioGroupId = 0, connectedEdgeFlags = 0; + CommandID commandID = {}; + ButtonState buttonState = buttonNormal, lastStatePainted = buttonNormal; Value isOn; - bool lastToggleState; - bool clickTogglesState; - bool needsToRelease; - bool needsRepainting; - bool isKeyDown; - bool triggerOnMouseDown; - bool generateTooltip; + bool lastToggleState = false; + bool clickTogglesState = false; + bool needsToRelease = false; + bool needsRepainting = false; + bool isKeyDown = false; + bool triggerOnMouseDown = false; + bool generateTooltip = false; void repeatTimerCallback(); bool keyStateChangedCallback(); diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp index acd785a369..e68511cff8 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp @@ -28,7 +28,6 @@ namespace juce { ApplicationCommandManager::ApplicationCommandManager() - : firstTarget (nullptr) { keyMappings = new KeyPressMappingSet (*this); Desktop::getInstance().addFocusChangeListener (this); @@ -37,7 +36,7 @@ ApplicationCommandManager::ApplicationCommandManager() ApplicationCommandManager::~ApplicationCommandManager() { Desktop::getInstance().removeFocusChangeListener (this); - keyMappings = nullptr; + keyMappings.reset(); } //============================================================================== diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h index 396002134b..30c7cb98d9 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h @@ -198,7 +198,7 @@ public: @see KeyPressMappingSet */ - KeyPressMappingSet* getKeyMappings() const noexcept { return keyMappings; } + KeyPressMappingSet* getKeyMappings() const noexcept { return keyMappings.get(); } //============================================================================== @@ -304,7 +304,7 @@ private: OwnedArray commands; ListenerList listeners; ScopedPointer keyMappings; - ApplicationCommandTarget* firstTarget; + ApplicationCommandTarget* firstTarget = nullptr; void sendListenerInvokeCallback (const ApplicationCommandTarget::InvocationInfo&); void handleAsyncUpdate() override; diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index b53ccdd8d7..81de6ef716 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -853,7 +853,7 @@ void Component::setBufferedToImage (const bool shouldBeBuffered) } else { - cachedImage = nullptr; + cachedImage.reset(); } } @@ -1334,7 +1334,7 @@ void Component::setTransform (const AffineTransform& newTransform) if (affineTransform != nullptr) { repaint(); - affineTransform = nullptr; + affineTransform.reset(); repaint(); sendMovedResizedMessages (false, false); @@ -2812,7 +2812,7 @@ void Component::grabFocusInternal (const FocusChangeType cause, const bool canTr if (traverser != nullptr) { auto* defaultComp = traverser->getDefaultComponent (this); - traverser = nullptr; + traverser.reset(); if (defaultComp != nullptr) { @@ -2859,7 +2859,7 @@ void Component::moveKeyboardFocusToSibling (const bool moveToNext) { auto* nextComp = moveToNext ? traverser->getNextComponent (this) : traverser->getPreviousComponent (this); - traverser = nullptr; + traverser.reset(); if (nextComp != nullptr) { diff --git a/modules/juce_gui_basics/components/juce_Component.h b/modules/juce_gui_basics/components/juce_Component.h index 9f96c5eb83..39b63a49f9 100644 --- a/modules/juce_gui_basics/components/juce_Component.h +++ b/modules/juce_gui_basics/components/juce_Component.h @@ -2222,7 +2222,7 @@ public: /** Returns the object that was set by setCachedComponentImage(). @see setCachedComponentImage */ - CachedComponentImage* getCachedComponentImage() const noexcept { return cachedImage; } + CachedComponentImage* getCachedComponentImage() const noexcept { return cachedImage.get(); } /** Sets a flag to indicate whether mouse drag events on this Component should be ignored when it is inside a Viewport with drag-to-scroll functionality enabled. This is useful for Components such as sliders that diff --git a/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp b/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp index a581e980f4..d69860650f 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp +++ b/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp @@ -143,7 +143,7 @@ void DrawablePath::setPath (const RelativePointPath& newRelativePath) } else { - relativePath = nullptr; + relativePath.reset(); applyRelativePath (newRelativePath, nullptr); } } diff --git a/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp b/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp index e93130a71a..6b1f27d4da 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp +++ b/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp @@ -103,7 +103,7 @@ void DrawableShape::setFillInternal (RelativeFillType& fill, const RelativeFillT if (fill != newFill) { fill = newFill; - pos = nullptr; + pos.reset(); if (fill.isDynamic()) { diff --git a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp index 7db6e282ce..b8be2c4864 100644 --- a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp @@ -87,7 +87,7 @@ void DirectoryContentsList::stopSearching() { shouldStop = true; thread.removeTimeSliceClient (this); - fileFindHandle = nullptr; + fileFindHandle.reset(); } void DirectoryContentsList::clear() @@ -210,7 +210,7 @@ bool DirectoryContentsList::checkNextFile (bool& hasChanged) return true; } - fileFindHandle = nullptr; + fileFindHandle.reset(); } return false; diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp index 441606298c..da5ba60369 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp @@ -121,8 +121,8 @@ FileBrowserComponent::FileBrowserComponent (int flags_, FileBrowserComponent::~FileBrowserComponent() { - fileListComponent = nullptr; - fileList = nullptr; + fileListComponent.reset(); + fileList.reset(); thread.stopThread (10000); } diff --git a/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp index 11b718fd31..4fda4c4070 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp @@ -88,7 +88,7 @@ void FilenameComponent::setBrowseButtonText (const String& newBrowseButtonText) void FilenameComponent::lookAndFeelChanged() { - browseButton = nullptr; + browseButton.reset(); addAndMakeVisible (browseButton = getLookAndFeel().createFilenameComponentBrowseButton (browseButtonText)); browseButton->setConnectedEdges (Button::ConnectedOnLeft); diff --git a/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp b/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp index 3d7961f5bd..b66fabeabf 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp @@ -61,7 +61,7 @@ public: if (useProxyComponent) proxy = new ProxyComponent (*component); else - proxy = nullptr; + proxy.reset(); component->setVisible (! useProxyComponent); } diff --git a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp index 210fafd4b8..9e81c7b34e 100644 --- a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp +++ b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp @@ -282,7 +282,7 @@ bool MultiDocumentPanel::closeDocument (Component* component, delete component; if (tabComponent != nullptr && tabComponent->getNumTabs() <= numDocsBeforeTabsUsed) - tabComponent = nullptr; + tabComponent.reset(); components.removeFirstMatchingValue (component); @@ -387,7 +387,7 @@ void MultiDocumentPanel::setLayoutMode (const LayoutMode newLayoutMode) if (mode == FloatingWindows) { - tabComponent = nullptr; + tabComponent.reset(); } else { diff --git a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h index 3635711f0a..461470da32 100644 --- a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h +++ b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h @@ -242,7 +242,7 @@ public: Colour getBackgroundColour() const noexcept { return backgroundColour; } /** If the panel is being used in tabbed mode, this returns the TabbedComponent that's involved. */ - TabbedComponent* getCurrentTabbedComponent() const noexcept { return tabComponent; } + TabbedComponent* getCurrentTabbedComponent() const noexcept { return tabComponent.get(); } //============================================================================== /** A subclass must override this to say whether its currently ok for a document diff --git a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp index c84b71c126..056d4ecc4a 100644 --- a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp +++ b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp @@ -57,20 +57,7 @@ private: //============================================================================== -ScrollBar::ScrollBar (const bool shouldBeVertical) - : totalRange (0.0, 1.0), - visibleRange (0.0, 0.1), - singleStepSize (0.1), - thumbAreaStart (0), - thumbAreaSize (0), - thumbStart (0), - thumbSize (0), - initialDelayInMillisecs (100), - repeatDelayInMillisecs (50), - minimumDelayInMillisecs (10), - vertical (shouldBeVertical), - isDraggingThumb (false), - autohides (true) +ScrollBar::ScrollBar (bool shouldBeVertical) : vertical (shouldBeVertical) { setRepaintsOnMouseActivity (true); setFocusContainer (true); @@ -78,8 +65,8 @@ ScrollBar::ScrollBar (const bool shouldBeVertical) ScrollBar::~ScrollBar() { - upButton = nullptr; - downButton = nullptr; + upButton.reset(); + downButton.reset(); } //============================================================================== @@ -302,8 +289,8 @@ void ScrollBar::resized() } else { - upButton = nullptr; - downButton = nullptr; + upButton.reset(); + downButton.reset(); } if (length < 32 + lf.getMinimumScrollbarThumbSize (*this)) diff --git a/modules/juce_gui_basics/layout/juce_ScrollBar.h b/modules/juce_gui_basics/layout/juce_ScrollBar.h index 34996d6a8e..c52efa5dd3 100644 --- a/modules/juce_gui_basics/layout/juce_ScrollBar.h +++ b/modules/juce_gui_basics/layout/juce_ScrollBar.h @@ -382,12 +382,12 @@ public: private: //============================================================================== - Range totalRange, visibleRange; - double singleStepSize, dragStartRange; - int thumbAreaStart, thumbAreaSize, thumbStart, thumbSize; - int dragStartMousePos, lastMousePos; - int initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs; - bool vertical, isDraggingThumb, autohides; + Range totalRange { 0.0, 1.0 }, visibleRange { 0.0, 1.0 }; + double singleStepSize = 0.1, dragStartRange = 0; + int thumbAreaStart = 0, thumbAreaSize = 0, thumbStart = 0, thumbSize = 0; + int dragStartMousePos = 0, lastMousePos = 0; + int initialDelayInMillisecs = 100, repeatDelayInMillisecs = 50, minimumDelayInMillisecs = 10; + bool vertical, isDraggingThumb = false, autohides = true; class ScrollbarButton; friend struct ContainerDeletePolicy; ScopedPointer upButton, downButton; diff --git a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp index 7bcf2a33ad..a4db98061e 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp +++ b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp @@ -214,7 +214,7 @@ TabbedButtonBar::TabbedButtonBar (Orientation orientationToUse) TabbedButtonBar::~TabbedButtonBar() { tabs.clear(); - extraTabsButton = nullptr; + extraTabsButton.reset(); } //============================================================================== @@ -243,7 +243,7 @@ void TabbedButtonBar::setMinimumTabScaleFactor (double newMinimumScale) void TabbedButtonBar::clearTabs() { tabs.clear(); - extraTabsButton = nullptr; + extraTabsButton.reset(); setCurrentTabIndex (-1); } @@ -390,7 +390,7 @@ Rectangle TabbedButtonBar::getTargetBounds (TabBarButton* button) const void TabbedButtonBar::lookAndFeelChanged() { - extraTabsButton = nullptr; + extraTabsButton.reset(); resized(); } @@ -481,7 +481,7 @@ void TabbedButtonBar::updateTabPositions (bool animate) } else { - extraTabsButton = nullptr; + extraTabsButton.reset(); } int pos = 0; diff --git a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h index 54ad0a0596..3296010efd 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h +++ b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h @@ -72,7 +72,7 @@ public: ExtraComponentPlacement extraComponentPlacement); /** Returns the custom component, if there is one. */ - Component* getExtraComponent() const noexcept { return extraComponent; } + Component* getExtraComponent() const noexcept { return extraComponent.get(); } /** Returns the placement of the custom component, if there is one. */ ExtraComponentPlacement getExtraComponentPlacement() const noexcept { return extraCompPlacement; } diff --git a/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp b/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp index 21f45ff98a..9271d2bd94 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp @@ -96,7 +96,7 @@ TabbedComponent::TabbedComponent (const TabbedButtonBar::Orientation orientation TabbedComponent::~TabbedComponent() { clearTabs(); - tabs = nullptr; + tabs.reset(); } //============================================================================== diff --git a/modules/juce_gui_basics/layout/juce_Viewport.cpp b/modules/juce_gui_basics/layout/juce_Viewport.cpp index 632fb11605..635f8d1260 100644 --- a/modules/juce_gui_basics/layout/juce_Viewport.cpp +++ b/modules/juce_gui_basics/layout/juce_Viewport.cpp @@ -99,8 +99,8 @@ void Viewport::setViewedComponent (Component* const newViewedComponent, const bo void Viewport::recreateScrollbars() { - verticalScrollBar = nullptr; - horizontalScrollBar = nullptr; + verticalScrollBar.reset(); + horizontalScrollBar.reset(); addChildComponent (verticalScrollBar = createScrollBarComponent (true)); addChildComponent (horizontalScrollBar = createScrollBarComponent (false)); @@ -298,7 +298,7 @@ void Viewport::setScrollOnDragEnabled (bool shouldScrollOnDrag) if (shouldScrollOnDrag) dragToScrollListener = new DragToScrollListener (*this); else - dragToScrollListener = nullptr; + dragToScrollListener.reset(); } } diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 714ee629fd..c97c3b4ea3 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -271,7 +271,7 @@ public: { getActiveWindows().removeFirstMatchingValue (this); Desktop::getInstance().removeGlobalMouseListener (this); - activeSubMenu = nullptr; + activeSubMenu.reset(); items.clear(); } @@ -313,7 +313,7 @@ public: { WeakReference deletionChecker (this); - activeSubMenu = nullptr; + activeSubMenu.reset(); currentChild = nullptr; if (item != nullptr @@ -901,7 +901,7 @@ public: bool showSubMenuFor (ItemComponent* childComp) { - activeSubMenu = nullptr; + activeSubMenu.reset(); if (childComp != nullptr && hasActiveSubMenu (childComp->item)) @@ -1612,7 +1612,7 @@ struct PopupMenuCompletionCallback : public ModalComponentManager::Callback } // (this would be the place to fade out the component, if that's what's required) - component = nullptr; + component.reset(); if (! PopupMenuSettings::menuWasHiddenBecauseOfAppChange) { diff --git a/modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp b/modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp index 9e2c9c112f..d658b997ab 100644 --- a/modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp +++ b/modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp @@ -142,7 +142,7 @@ void ReportingThreadContainer::sendReport (String address, String& userAgent, St void ReportingThreadContainer::changeListenerCallback (ChangeBroadcaster*) { - reportingThread = nullptr; + reportingThread.reset(); } //============================================================================== diff --git a/modules/juce_gui_basics/native/juce_mac_Windowing.mm b/modules/juce_gui_basics/native/juce_mac_Windowing.mm index a35844e94c..b1119cbbb8 100644 --- a/modules/juce_gui_basics/native/juce_mac_Windowing.mm +++ b/modules/juce_gui_basics/native/juce_mac_Windowing.mm @@ -368,7 +368,7 @@ public: } else { - assertion = nullptr; + assertion.reset(); } } @@ -413,7 +413,7 @@ static ScopedPointer screenSaverDefeater; void Desktop::setScreenSaverEnabled (const bool isEnabled) { if (isEnabled) - screenSaverDefeater = nullptr; + screenSaverDefeater.reset(); else if (screenSaverDefeater == nullptr) screenSaverDefeater = new ScreenSaverDefeater(); } diff --git a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp index 11ab4c97af..f3ff747841 100644 --- a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp @@ -40,7 +40,7 @@ ComboBox::~ComboBox() { currentId.removeListener (this); hidePopup(); - label = nullptr; + label.reset(); } //============================================================================== diff --git a/modules/juce_gui_basics/widgets/juce_Label.cpp b/modules/juce_gui_basics/widgets/juce_Label.cpp index 403c7d3a45..3640e730c8 100644 --- a/modules/juce_gui_basics/widgets/juce_Label.cpp +++ b/modules/juce_gui_basics/widgets/juce_Label.cpp @@ -30,15 +30,7 @@ namespace juce Label::Label (const String& name, const String& labelText) : Component (name), textValue (labelText), - lastTextValue (labelText), - font (15.0f), - justification (Justification::centredLeft), - border (1, 5, 1, 5), - minimumHorizontalScale (0.0f), - keyboardType (TextEditor::textKeyboard), - editSingleClick (false), - editDoubleClick (false), - lossOfFocusDiscardsChanges (false) + lastTextValue (labelText) { setColour (TextEditor::textColourId, Colours::black); setColour (TextEditor::backgroundColourId, Colours::transparentBlack); @@ -54,12 +46,11 @@ Label::~Label() if (ownerComponent != nullptr) ownerComponent->removeComponentListener (this); - editor = nullptr; + editor.reset(); } //============================================================================== -void Label::setText (const String& newText, - const NotificationType notification) +void Label::setText (const String& newText, NotificationType notification) { hideEditor (true); @@ -107,13 +98,13 @@ Font Label::getFont() const noexcept return font; } -void Label::setEditable (const bool editOnSingleClick, - const bool editOnDoubleClick, - const bool lossOfFocusDiscardsChanges_) +void Label::setEditable (bool editOnSingleClick, + bool editOnDoubleClick, + bool lossOfFocusDiscards) { editSingleClick = editOnSingleClick; editDoubleClick = editOnDoubleClick; - lossOfFocusDiscardsChanges = lossOfFocusDiscardsChanges_; + lossOfFocusDiscardsChanges = lossOfFocusDiscards; setWantsKeyboardFocus (editOnSingleClick || editOnDoubleClick); setFocusContainer (editOnSingleClick || editOnDoubleClick); @@ -184,7 +175,7 @@ void Label::componentMovedOrResized (Component& component, bool /*wasMoved*/, bo void Label::componentParentHierarchyChanged (Component& component) { - if (Component* parent = component.getParentComponent()) + if (auto* parent = component.getParentComponent()) parent->addChildComponent (this); } @@ -263,14 +254,13 @@ void Label::hideEditor (const bool discardCurrentEditorContents) if (editor != nullptr) { WeakReference deletionChecker (this); - ScopedPointer outgoingEditor (editor); editorAboutToBeHidden (outgoingEditor); const bool changed = (! discardCurrentEditorContents) && updateFromTextEditorContents (*outgoingEditor); - outgoingEditor = nullptr; + outgoingEditor.reset(); repaint(); if (changed) @@ -308,7 +298,7 @@ static void copyColourIfSpecified (Label& l, TextEditor& ed, int colourID, int t TextEditor* Label::createEditorComponent() { - TextEditor* const ed = new TextEditor (getName()); + auto* ed = new TextEditor (getName()); ed->applyFontToAllText (getLookAndFeel().getLabelFont (*this)); copyAllExplicitColoursTo (*ed); diff --git a/modules/juce_gui_basics/widgets/juce_Label.h b/modules/juce_gui_basics/widgets/juce_Label.h index 34104cdf0d..b34cf3d4d8 100644 --- a/modules/juce_gui_basics/widgets/juce_Label.h +++ b/modules/juce_gui_basics/widgets/juce_Label.h @@ -331,18 +331,18 @@ private: //============================================================================== Value textValue; String lastTextValue; - Font font; - Justification justification; + Font font { 15.0f }; + Justification justification = Justification::centredLeft; ScopedPointer editor; ListenerList listeners; WeakReference ownerComponent; - BorderSize border; - float minimumHorizontalScale; - TextInputTarget::VirtualKeyboardType keyboardType; - bool editSingleClick; - bool editDoubleClick; - bool lossOfFocusDiscardsChanges; - bool leftOfOwnerComp; + BorderSize border { 1, 5, 1, 5 }; + float minimumHorizontalScale = 0; + TextInputTarget::VirtualKeyboardType keyboardType = TextInputTarget::textKeyboard; + bool editSingleClick = false; + bool editDoubleClick = false; + bool lossOfFocusDiscardsChanges = false; + bool leftOfOwnerComp = false; bool updateFromTextEditorContents (TextEditor&); diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/modules/juce_gui_basics/widgets/juce_ListBox.cpp index cba598396e..3a08b4cf0b 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -385,8 +385,8 @@ ListBox::ListBox (const String& name, ListBoxModel* const m) ListBox::~ListBox() { - headerComponent = nullptr; - viewport = nullptr; + headerComponent.reset(); + viewport.reset(); } void ListBox::setModel (ListBoxModel* const newModel) @@ -412,7 +412,7 @@ void ListBox::setMouseMoveSelectsRows (bool b) } else { - mouseMoveSelector = nullptr; + mouseMoveSelector.reset(); } } diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.h b/modules/juce_gui_basics/widgets/juce_ListBox.h index 3a2e567829..27f8fe5484 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.h +++ b/modules/juce_gui_basics/widgets/juce_ListBox.h @@ -497,7 +497,7 @@ public: void setHeaderComponent (Component* newHeaderComponent); /** Returns whatever header component was set with setHeaderComponent(). */ - Component* getHeaderComponent() const noexcept { return headerComponent; } + Component* getHeaderComponent() const noexcept { return headerComponent.get(); } /** Changes the width of the rows in the list. diff --git a/modules/juce_gui_basics/widgets/juce_Slider.cpp b/modules/juce_gui_basics/widgets/juce_Slider.cpp index 7a78630901..664ffd42c7 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -49,7 +49,7 @@ public: currentValue.removeListener (this); valueMin.removeListener (this); valueMax.removeListener (this); - popupDisplay = nullptr; + popupDisplay.reset(); } //============================================================================== @@ -550,7 +550,7 @@ public: auto previousTextBoxContent = (valueBox != nullptr ? valueBox->getText() : owner.getTextFromValue (currentValue.getValue())); - valueBox = nullptr; + valueBox.reset(); owner.addAndMakeVisible (valueBox = lf.createSliderTextBox (owner)); valueBox->setWantsKeyboardFocus (false); @@ -567,7 +567,7 @@ public: } else { - valueBox = nullptr; + valueBox.reset(); } if (style == IncDecButtons) @@ -595,8 +595,8 @@ public: } else { - incButton = nullptr; - decButton = nullptr; + incButton.reset(); + decButton.reset(); } owner.setComponentEffect (lf.getSliderEffect (owner)); @@ -804,8 +804,8 @@ public: incDecDragged = false; useDragEvents = false; mouseDragStartPos = mousePosWhenLastDragged = e.position; - currentDrag = nullptr; - popupDisplay = nullptr; + currentDrag.reset(); + popupDisplay.reset(); if (owner.isEnabled()) { @@ -931,8 +931,8 @@ public: if (sendChangeOnlyOnRelease && valueOnMouseDown != static_cast (currentValue.getValue())) triggerChangeMessage (sendNotificationAsync); - currentDrag = nullptr; - popupDisplay = nullptr; + currentDrag.reset(); + popupDisplay.reset(); if (style == IncDecButtons) { @@ -945,7 +945,7 @@ public: popupDisplay->startTimer (200); } - currentDrag = nullptr; + currentDrag.reset(); } void mouseMove() @@ -975,7 +975,7 @@ public: void mouseExit() { - popupDisplay = nullptr; + popupDisplay.reset(); } void showPopupDisplay() @@ -1307,7 +1307,7 @@ public: void timerCallback() override { stopTimer(); - owner.pimpl->popupDisplay = nullptr; + owner.pimpl->popupDisplay.reset(); } private: diff --git a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp index b939a4ba75..3201617690 100644 --- a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp +++ b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp @@ -55,7 +55,7 @@ TableHeaderComponent::TableHeaderComponent() TableHeaderComponent::~TableHeaderComponent() { - dragOverlayComp = nullptr; + dragOverlayComp.reset(); } //============================================================================== @@ -564,7 +564,7 @@ void TableHeaderComponent::mouseDrag (const MouseEvent& e) && e.mouseWasDraggedSinceMouseDown() && ! e.mods.isPopupMenu()) { - dragOverlayComp = nullptr; + dragOverlayComp.reset(); columnIdBeingResized = getResizeDraggerAt (e.getMouseDownX()); @@ -744,7 +744,7 @@ void TableHeaderComponent::mouseUp (const MouseEvent& e) if (columnIdUnderMouse != 0 && ! (e.mouseWasDraggedSinceMouseDown() || e.mods.isPopupMenu())) columnClicked (columnIdUnderMouse, e.mods); - dragOverlayComp = nullptr; + dragOverlayComp.reset(); } MouseCursor TableHeaderComponent::getMouseCursor() diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index cc26f77ed0..da5190a3b2 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -898,7 +898,7 @@ TextEditor::~TextEditor() textValue.removeListener (textHolder); textValue.referTo (Value()); - viewport = nullptr; + viewport.reset(); textHolder = nullptr; } @@ -1051,7 +1051,7 @@ void TextEditor::applyColourToAllText (const Colour& newColour, bool changeCurre void TextEditor::lookAndFeelChanged() { - caret = nullptr; + caret.reset(); recreateCaret(); repaint(); } @@ -1088,7 +1088,7 @@ void TextEditor::recreateCaret() } else { - caret = nullptr; + caret.reset(); } } diff --git a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp index 21561d193a..3345ff5ebf 100644 --- a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp +++ b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp @@ -141,7 +141,7 @@ ToolbarItemComponent::ToolbarItemComponent (const int itemId_, ToolbarItemComponent::~ToolbarItemComponent() { - overlayComp = nullptr; + overlayComp.reset(); } Toolbar* ToolbarItemComponent::getToolbar() const @@ -227,7 +227,7 @@ void ToolbarItemComponent::setEditingMode (const ToolbarEditingMode newMode) if (mode == normalMode) { - overlayComp = nullptr; + overlayComp.reset(); } else if (overlayComp == nullptr) { diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.cpp b/modules/juce_gui_basics/widgets/juce_TreeView.cpp index 712b89fb77..b01441984b 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.cpp +++ b/modules/juce_gui_basics/widgets/juce_TreeView.cpp @@ -1018,8 +1018,8 @@ void TreeView::showDragHighlight (const InsertPoint& insertPos) noexcept void TreeView::hideDragHighlight() noexcept { - dragInsertPointHighlight = nullptr; - dragTargetGroupHighlight = nullptr; + dragInsertPointHighlight.reset(); + dragTargetGroupHighlight.reset(); } void TreeView::handleDrag (const StringArray& files, const SourceDetails& dragSourceDetails) diff --git a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp index 018a0f08bd..59508689c0 100644 --- a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp @@ -74,9 +74,9 @@ DocumentWindow::~DocumentWindow() jassert (titleBarButtons[2] == nullptr || getIndexOfChildComponent (titleBarButtons[2]) >= 0); for (auto& b : titleBarButtons) - b = nullptr; + b.reset(); - menuBar = nullptr; + menuBar.reset(); } //============================================================================== @@ -125,7 +125,7 @@ void DocumentWindow::setMenuBar (MenuBarModel* newMenuBarModel, const int newMen { if (menuBarModel != newMenuBarModel) { - menuBar = nullptr; + menuBar.reset(); menuBarModel = newMenuBarModel; menuBarHeight = newMenuBarHeight > 0 ? newMenuBarHeight @@ -288,7 +288,7 @@ int DocumentWindow::getDesktopWindowStyleFlags() const void DocumentWindow::lookAndFeelChanged() { for (auto& b : titleBarButtons) - b = nullptr; + b.reset(); if (! isUsingNativeTitleBar()) { diff --git a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp index 068f22635a..b896292a1f 100644 --- a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp @@ -50,8 +50,8 @@ ResizableWindow::~ResizableWindow() jassert (resizableCorner == nullptr || getIndexOfChildComponent (resizableCorner) >= 0); jassert (resizableBorder == nullptr || getIndexOfChildComponent (resizableBorder) >= 0); - resizableCorner = nullptr; - resizableBorder = nullptr; + resizableCorner.reset(); + resizableBorder.reset(); clearContentComponent(); // have you been adding your own components directly to this window..? tut tut tut. @@ -115,8 +115,8 @@ void ResizableWindow::clearContentComponent() } void ResizableWindow::setContent (Component* newContentComponent, - const bool takeOwnership, - const bool resizeToFitWhenContentChangesSize) + bool takeOwnership, + bool resizeToFitWhenContentChangesSize) { if (newContentComponent != contentComponent) { @@ -273,7 +273,7 @@ void ResizableWindow::setResizable (const bool shouldBeResizable, { if (useBottomRightCornerResizer) { - resizableBorder = nullptr; + resizableBorder.reset(); if (resizableCorner == nullptr) { @@ -283,7 +283,7 @@ void ResizableWindow::setResizable (const bool shouldBeResizable, } else { - resizableCorner = nullptr; + resizableCorner.reset(); if (resizableBorder == nullptr) Component::addChildComponent (resizableBorder = new ResizableBorderComponent (this, constrainer)); @@ -291,8 +291,8 @@ void ResizableWindow::setResizable (const bool shouldBeResizable, } else { - resizableCorner = nullptr; - resizableBorder = nullptr; + resizableCorner.reset(); + resizableBorder.reset(); } if (isUsingNativeTitleBar()) @@ -339,8 +339,8 @@ void ResizableWindow::setConstrainer (ComponentBoundsConstrainer* newConstrainer bool useBottomRightCornerResizer = resizableCorner != nullptr; bool shouldBeResizable = useBottomRightCornerResizer || resizableBorder != nullptr; - resizableCorner = nullptr; - resizableBorder = nullptr; + resizableCorner.reset(); + resizableBorder.reset(); setResizable (shouldBeResizable, useBottomRightCornerResizer); updatePeerConstrainer(); diff --git a/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h b/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h index d996157bea..06e408fd47 100644 --- a/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h +++ b/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h @@ -149,7 +149,7 @@ public: void setStatusMessage (const String& newStatusMessage); /** Returns the AlertWindow that is being used. */ - AlertWindow* getAlertWindow() const noexcept { return alertWindow; } + AlertWindow* getAlertWindow() const noexcept { return alertWindow.get(); } //============================================================================== /** This method is called (on the message thread) when the operation has finished. diff --git a/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp b/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp index f8c48777a6..6477be7ec4 100644 --- a/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp @@ -149,7 +149,7 @@ TopLevelWindow::TopLevelWindow (const String& name, const bool shouldAddToDeskto TopLevelWindow::~TopLevelWindow() { - shadower = nullptr; + shadower.reset(); TopLevelWindowManager::getInstance()->removeWindow (this); } @@ -212,7 +212,7 @@ void TopLevelWindow::setDropShadowEnabled (const bool useShadow) if (isOnDesktop()) { - shadower = nullptr; + shadower.reset(); Component::addToDesktop (getDesktopWindowStyleFlags()); } else @@ -229,7 +229,7 @@ void TopLevelWindow::setDropShadowEnabled (const bool useShadow) } else { - shadower = nullptr; + shadower.reset(); } } } @@ -256,7 +256,7 @@ void TopLevelWindow::recreateDesktopWindow() void TopLevelWindow::addToDesktop() { - shadower = nullptr; + shadower.reset(); Component::addToDesktop (getDesktopWindowStyleFlags()); setDropShadowEnabled (isDropShadowEnabled()); // force an update to clear away any fake shadows if necessary. } diff --git a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp index bfc5a38158..8a704089b6 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp +++ b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp @@ -405,7 +405,7 @@ void CodeEditorComponent::setTemporaryUnderlining (const Array>&) Rectangle CodeEditorComponent::getCaretRectangle() { - return getLocalArea (caret, caret->getLocalBounds()); + return getLocalArea (caret.get(), caret->getLocalBounds()); } void CodeEditorComponent::setLineNumbersShown (const bool shouldBeShown) @@ -413,7 +413,7 @@ void CodeEditorComponent::setLineNumbersShown (const bool shouldBeShown) if (showLineNumbers != shouldBeShown) { showLineNumbers = shouldBeShown; - gutter = nullptr; + gutter.reset(); if (shouldBeShown) addAndMakeVisible (gutter = new GutterComponent()); @@ -429,9 +429,9 @@ void CodeEditorComponent::setReadOnly (bool b) noexcept readOnly = b; if (b) - removeChildComponent (caret); + removeChildComponent (caret.get()); else - addAndMakeVisible (caret); + addAndMakeVisible (caret.get()); } } diff --git a/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp b/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp index c619b24120..52af9b3cf9 100644 --- a/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp +++ b/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp @@ -189,7 +189,7 @@ public: button->setNewKey (button->currentKeyEntryWindow->lastPress, false); } - button->currentKeyEntryWindow = nullptr; + button->currentKeyEntryWindow.reset(); } } @@ -405,14 +405,14 @@ KeyMappingEditorComponent::KeyMappingEditorComponent (KeyPressMappingSet& mappin if (showResetToDefaultButton) { addAndMakeVisible (resetButton); - resetButton.addListener (treeItem); + resetButton.addListener (treeItem.get()); } addAndMakeVisible (tree); tree.setColour (TreeView::backgroundColourId, findColour (backgroundColourId)); tree.setRootItemVisible (false); tree.setDefaultOpenness (true); - tree.setRootItem (treeItem); + tree.setRootItem (treeItem.get()); tree.setIndentSize (12); } diff --git a/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp b/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp index cb35ef5165..4cde14cea9 100644 --- a/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp +++ b/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp @@ -121,7 +121,7 @@ void PreferencesPanel::setCurrentPage (const String& pageName) { currentPageName = pageName; - currentPage = nullptr; + currentPage.reset(); currentPage = createComponentForPage (pageName); if (currentPage != nullptr) diff --git a/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp b/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp index c7d893fa98..f6ac4547bc 100644 --- a/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp +++ b/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp @@ -242,7 +242,7 @@ void SystemTrayIconComponent::setIconImage (const Image& newImage) } else { - pimpl = nullptr; + pimpl.reset(); } } diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp index db829f090a..df9a56ea2f 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp @@ -82,7 +82,7 @@ public: if (nativeContext->createdOk()) context.nativeContext = nativeContext; else - nativeContext = nullptr; + nativeContext.reset(); } ~CachedImage() @@ -117,7 +117,7 @@ public: } pause(); - renderThread = nullptr; + renderThread.reset(); } hasInitialised = false; @@ -880,7 +880,7 @@ void OpenGLContext::detach() if (auto* a = attachment.get()) { a->detach(); // must detach before nulling our pointer - attachment = nullptr; + attachment.reset(); } nativeContext = nullptr; diff --git a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp index c7e4a2a4b6..dcbdcc7f60 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp @@ -180,11 +180,11 @@ bool OpenGLFrameBuffer::initialise (OpenGLContext& context, int width, int heigh { jassert (context.isActive()); // The context must be active when creating a framebuffer! - pimpl = nullptr; + pimpl.reset(); pimpl = new Pimpl (context, width, height, false, false); if (! pimpl->createdOk()) - pimpl = nullptr; + pimpl.reset(); return pimpl != nullptr; } @@ -206,7 +206,7 @@ bool OpenGLFrameBuffer::initialise (OpenGLFrameBuffer& other) if (p == nullptr) { - pimpl = nullptr; + pimpl.reset(); return true; } @@ -234,8 +234,8 @@ bool OpenGLFrameBuffer::initialise (OpenGLFrameBuffer& other) void OpenGLFrameBuffer::release() { - pimpl = nullptr; - savedState = nullptr; + pimpl.reset(); + savedState.reset(); } void OpenGLFrameBuffer::saveAndRelease() @@ -243,7 +243,7 @@ void OpenGLFrameBuffer::saveAndRelease() if (pimpl != nullptr) { savedState = new SavedState (*this, pimpl->width, pimpl->height); - pimpl = nullptr; + pimpl.reset(); } } diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index 9d2ecaa352..d3be472ca5 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -1585,7 +1585,7 @@ public: state->flush(); state->target = *finishedLayerState.previousTarget; - finishedLayerState.previousTarget = nullptr; + finishedLayerState.previousTarget.reset(); state->target.makeActive(); const Rectangle clipBounds (clip->getClipBounds()); diff --git a/modules/juce_video/playback/juce_VideoComponent.cpp b/modules/juce_video/playback/juce_VideoComponent.cpp index 135048b037..eae852ebb1 100644 --- a/modules/juce_video/playback/juce_VideoComponent.cpp +++ b/modules/juce_video/playback/juce_VideoComponent.cpp @@ -41,7 +41,7 @@ VideoComponent::VideoComponent() : pimpl (new Pimpl()) VideoComponent::~VideoComponent() { - pimpl = nullptr; + pimpl.reset(); } Result VideoComponent::load (const File& file)