diff --git a/examples/DemoRunner/Builds/LinuxMakefile/Makefile b/examples/DemoRunner/Builds/LinuxMakefile/Makefile index 25fc8a24b4..0bab1a5616 100644 --- a/examples/DemoRunner/Builds/LinuxMakefile/Makefile +++ b/examples/DemoRunner/Builds/LinuxMakefile/Makefile @@ -35,13 +35,13 @@ ifeq ($(CONFIG),Debug) TARGET_ARCH := -march=native endif - JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DDEBUG=1 -D_DEBUG=1 -DJUCE_DEMO_RUNNER=1 -DJUCE_UNIT_TESTS=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=5.3.2 -DJUCE_APP_VERSION_HEX=0x50302 $(shell pkg-config --cflags alsa freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) + JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DDEBUG=1 -D_DEBUG=1 -DJUCE_DEMO_RUNNER=1 -DJUCE_UNIT_TESTS=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=5.3.2 -DJUCE_APP_VERSION_HEX=0x50302 $(shell pkg-config --cflags alsa freetype2 x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 libcurl) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) JUCE_CPPFLAGS_APP := -DJucePlugin_Build_VST=0 -DJucePlugin_Build_VST3=0 -DJucePlugin_Build_AU=0 -DJucePlugin_Build_AUv3=0 -DJucePlugin_Build_RTAS=0 -DJucePlugin_Build_AAX=0 -DJucePlugin_Build_Standalone=0 -DJucePlugin_Build_Unity=0 JUCE_TARGET_APP := DemoRunner JUCE_CFLAGS += $(JUCE_CPPFLAGS) $(TARGET_ARCH) -g -ggdb -O0 $(CFLAGS) JUCE_CXXFLAGS += $(JUCE_CFLAGS) -std=c++14 $(CXXFLAGS) - JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR) $(shell pkg-config --libs alsa freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -lGL -ldl -lpthread -lrt $(LDFLAGS) + JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR) $(shell pkg-config --libs alsa freetype2 x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 libcurl) -lGL -ldl -lpthread -lrt $(LDFLAGS) CLEANCMD = rm -rf $(JUCE_OUTDIR)/$(TARGET) $(JUCE_OBJDIR) endif @@ -56,13 +56,13 @@ ifeq ($(CONFIG),Release) TARGET_ARCH := -march=native endif - JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DNDEBUG=1 -DJUCE_DEMO_RUNNER=1 -DJUCE_UNIT_TESTS=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=5.3.2 -DJUCE_APP_VERSION_HEX=0x50302 $(shell pkg-config --cflags alsa freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) + JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DNDEBUG=1 -DJUCE_DEMO_RUNNER=1 -DJUCE_UNIT_TESTS=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=5.3.2 -DJUCE_APP_VERSION_HEX=0x50302 $(shell pkg-config --cflags alsa freetype2 x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 libcurl) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) JUCE_CPPFLAGS_APP := -DJucePlugin_Build_VST=0 -DJucePlugin_Build_VST3=0 -DJucePlugin_Build_AU=0 -DJucePlugin_Build_AUv3=0 -DJucePlugin_Build_RTAS=0 -DJucePlugin_Build_AAX=0 -DJucePlugin_Build_Standalone=0 -DJucePlugin_Build_Unity=0 JUCE_TARGET_APP := DemoRunner JUCE_CFLAGS += $(JUCE_CPPFLAGS) $(TARGET_ARCH) -O3 $(CFLAGS) JUCE_CXXFLAGS += $(JUCE_CFLAGS) -std=c++14 $(CXXFLAGS) - JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR) $(shell pkg-config --libs alsa freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -fvisibility=hidden -lGL -ldl -lpthread -lrt $(LDFLAGS) + JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR) $(shell pkg-config --libs alsa freetype2 x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 libcurl) -fvisibility=hidden -lGL -ldl -lpthread -lrt $(LDFLAGS) CLEANCMD = rm -rf $(JUCE_OUTDIR)/$(TARGET) $(JUCE_OBJDIR) endif @@ -238,7 +238,7 @@ $(JUCE_OBJDIR)/include_juce_video_be78589.o: ../../JuceLibraryCode/include_juce_ check-pkg-config: @command -v pkg-config >/dev/null 2>&1 || { echo >&2 "pkg-config not installed. Please, install it."; exit 1; } - @pkg-config --print-errors alsa freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 + @pkg-config --print-errors alsa freetype2 x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 libcurl clean: @echo Cleaning DemoRunner diff --git a/examples/DemoRunner/DemoRunner.jucer b/examples/DemoRunner/DemoRunner.jucer index 485deb0533..ab17c6c0f5 100644 --- a/examples/DemoRunner/DemoRunner.jucer +++ b/examples/DemoRunner/DemoRunner.jucer @@ -258,7 +258,8 @@ useGlobalPath="0"/> - + diff --git a/examples/DemoRunner/JuceLibraryCode/AppConfig.h b/examples/DemoRunner/JuceLibraryCode/AppConfig.h index 6d198a800c..ea91abf777 100644 --- a/examples/DemoRunner/JuceLibraryCode/AppConfig.h +++ b/examples/DemoRunner/JuceLibraryCode/AppConfig.h @@ -198,6 +198,10 @@ //#define JUCE_USE_CURL 0 #endif +#ifndef JUCE_LOAD_CURL_SYMBOLS_LAZILY + //#define JUCE_LOAD_CURL_SYMBOLS_LAZILY 0 +#endif + #ifndef JUCE_CATCH_UNHANDLED_EXCEPTIONS //#define JUCE_CATCH_UNHANDLED_EXCEPTIONS 1 #endif @@ -206,6 +210,10 @@ #define JUCE_ALLOW_STATIC_NULL_VARIABLES 0 #endif +#ifndef JUCE_STRICT_REFCOUNTEDPOINTER + #define JUCE_STRICT_REFCOUNTEDPOINTER 1 +#endif + //============================================================================== // juce_dsp flags: @@ -247,6 +255,10 @@ //#define JUCE_USE_DIRECTWRITE 1 #endif +#ifndef JUCE_DISABLE_COREGRAPHICS_FONT_SMOOTHING + //#define JUCE_DISABLE_COREGRAPHICS_FONT_SMOOTHING 0 +#endif + //============================================================================== // juce_gui_basics flags: diff --git a/extras/AudioPluginHost/Source/Filters/FilterGraph.cpp b/extras/AudioPluginHost/Source/Filters/FilterGraph.cpp index 76d51f1393..8266f67cd3 100644 --- a/extras/AudioPluginHost/Source/Filters/FilterGraph.cpp +++ b/extras/AudioPluginHost/Source/Filters/FilterGraph.cpp @@ -152,7 +152,7 @@ PluginWindow* FilterGraph::getOrCreateWindowFor (AudioProcessorGraph::Node* node closeAnyOpenPluginWindows(); #else for (auto* w : activePluginWindows) - if (w->node == node && w->type == type) + if (w->node.get() == node && w->type == type) return w; #endif diff --git a/extras/Projucer/Builds/LinuxMakefile/Makefile b/extras/Projucer/Builds/LinuxMakefile/Makefile index 0da71e4666..d47f707caf 100644 --- a/extras/Projucer/Builds/LinuxMakefile/Makefile +++ b/extras/Projucer/Builds/LinuxMakefile/Makefile @@ -35,13 +35,13 @@ ifeq ($(CONFIG),Debug) TARGET_ARCH := -march=native endif - JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DDEBUG=1 -D_DEBUG=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=5.3.2 -DJUCE_APP_VERSION_HEX=0x50302 $(shell pkg-config --cflags freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) + JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DDEBUG=1 -D_DEBUG=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=5.3.2 -DJUCE_APP_VERSION_HEX=0x50302 $(shell pkg-config --cflags freetype2 x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 libcurl) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) JUCE_CPPFLAGS_APP := -DJucePlugin_Build_VST=0 -DJucePlugin_Build_VST3=0 -DJucePlugin_Build_AU=0 -DJucePlugin_Build_AUv3=0 -DJucePlugin_Build_RTAS=0 -DJucePlugin_Build_AAX=0 -DJucePlugin_Build_Standalone=0 -DJucePlugin_Build_Unity=0 JUCE_TARGET_APP := Projucer JUCE_CFLAGS += $(JUCE_CPPFLAGS) $(TARGET_ARCH) -g -ggdb -O0 $(CFLAGS) JUCE_CXXFLAGS += $(JUCE_CFLAGS) -std=c++11 $(CXXFLAGS) - JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR) $(shell pkg-config --libs freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -ldl -lpthread -lrt $(LDFLAGS) + JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR) $(shell pkg-config --libs freetype2 x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 libcurl) -ldl -lpthread -lrt $(LDFLAGS) CLEANCMD = rm -rf $(JUCE_OUTDIR)/$(TARGET) $(JUCE_OBJDIR) endif @@ -56,13 +56,13 @@ ifeq ($(CONFIG),Release) TARGET_ARCH := -march=native endif - JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DNDEBUG=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=5.3.2 -DJUCE_APP_VERSION_HEX=0x50302 $(shell pkg-config --cflags freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) + JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DNDEBUG=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=5.3.2 -DJUCE_APP_VERSION_HEX=0x50302 $(shell pkg-config --cflags freetype2 x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 libcurl) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) JUCE_CPPFLAGS_APP := -DJucePlugin_Build_VST=0 -DJucePlugin_Build_VST3=0 -DJucePlugin_Build_AU=0 -DJucePlugin_Build_AUv3=0 -DJucePlugin_Build_RTAS=0 -DJucePlugin_Build_AAX=0 -DJucePlugin_Build_Standalone=0 -DJucePlugin_Build_Unity=0 JUCE_TARGET_APP := Projucer JUCE_CFLAGS += $(JUCE_CPPFLAGS) $(TARGET_ARCH) -O3 $(CFLAGS) JUCE_CXXFLAGS += $(JUCE_CFLAGS) -std=c++11 $(CXXFLAGS) - JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR) $(shell pkg-config --libs freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -fvisibility=hidden -ldl -lpthread -lrt $(LDFLAGS) + JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR) $(shell pkg-config --libs freetype2 x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 libcurl) -fvisibility=hidden -ldl -lpthread -lrt $(LDFLAGS) CLEANCMD = rm -rf $(JUCE_OUTDIR)/$(TARGET) $(JUCE_OBJDIR) endif @@ -454,7 +454,7 @@ $(JUCE_OBJDIR)/include_juce_gui_extra_6dee1c1a.o: ../../JuceLibraryCode/include_ check-pkg-config: @command -v pkg-config >/dev/null 2>&1 || { echo >&2 "pkg-config not installed. Please, install it."; exit 1; } - @pkg-config --print-errors freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 + @pkg-config --print-errors freetype2 x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 libcurl clean: @echo Cleaning Projucer diff --git a/extras/Projucer/JuceLibraryCode/AppConfig.h b/extras/Projucer/JuceLibraryCode/AppConfig.h index 9bd68fa42f..9c5df9a1a0 100644 --- a/extras/Projucer/JuceLibraryCode/AppConfig.h +++ b/extras/Projucer/JuceLibraryCode/AppConfig.h @@ -105,6 +105,10 @@ #define JUCE_USE_CURL 1 #endif +#ifndef JUCE_LOAD_CURL_SYMBOLS_LAZILY + //#define JUCE_LOAD_CURL_SYMBOLS_LAZILY 0 +#endif + #ifndef JUCE_CATCH_UNHANDLED_EXCEPTIONS //#define JUCE_CATCH_UNHANDLED_EXCEPTIONS 1 #endif @@ -113,6 +117,10 @@ #define JUCE_ALLOW_STATIC_NULL_VARIABLES 0 #endif +#ifndef JUCE_STRICT_REFCOUNTEDPOINTER + #define JUCE_STRICT_REFCOUNTEDPOINTER 1 +#endif + //============================================================================== // juce_events flags: @@ -131,6 +139,10 @@ //#define JUCE_USE_DIRECTWRITE 1 #endif +#ifndef JUCE_DISABLE_COREGRAPHICS_FONT_SMOOTHING + //#define JUCE_DISABLE_COREGRAPHICS_FONT_SMOOTHING 0 +#endif + //============================================================================== // juce_gui_basics flags: diff --git a/extras/Projucer/Projucer.jucer b/extras/Projucer/Projucer.jucer index a4b6acd5da..825f9e373b 100644 --- a/extras/Projucer/Projucer.jucer +++ b/extras/Projucer/Projucer.jucer @@ -719,7 +719,8 @@ resource="0" file="Source/Wizards/jucer_TemplateThumbnailsComponent.h"/> - + diff --git a/extras/Projucer/Source/CodeEditor/jucer_LiveBuildCodeEditor.h b/extras/Projucer/Source/CodeEditor/jucer_LiveBuildCodeEditor.h index 71e32d3e13..2e6881bcf0 100644 --- a/extras/Projucer/Source/CodeEditor/jucer_LiveBuildCodeEditor.h +++ b/extras/Projucer/Source/CodeEditor/jucer_LiveBuildCodeEditor.h @@ -450,7 +450,7 @@ private: { public: ControlsComponent (CodeDocument& doc, const Range& selection, - CompileEngineChildProcess* cp, bool showColourSelector) + CompileEngineChildProcess::Ptr cp, bool showColourSelector) : document (doc), start (doc, selection.getStart()), end (doc, selection.getEnd()), @@ -629,7 +629,7 @@ private: ~LiteralHighlightOverlay() { - if (Component* p = getParentComponent()) + if (auto* p = getParentComponent()) { p->removeChildComponent (this); diff --git a/extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineClient.h b/extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineClient.h index b05e1a63e4..d52ed40814 100644 --- a/extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineClient.h +++ b/extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineClient.h @@ -117,34 +117,31 @@ struct ChildProcessCache CompileEngineChildProcess::Ptr getExisting (Project& project) const noexcept { - for (CompileEngineChildProcess* p : processes) + for (auto& p : processes) if (&(p->project) == &project) return p; - return nullptr; + return {}; } CompileEngineChildProcess::Ptr getOrCreate (Project& project) { - CompileEngineChildProcess::Ptr p (getExisting (project)); - - if (p == nullptr) - { - p = new CompileEngineChildProcess (project); - tellNewProcessAboutExistingEditors (p); - processes.add (p); - } + if (auto p = getExisting (project)) + return p; + auto p = new CompileEngineChildProcess (project); + tellNewProcessAboutExistingEditors (*p); + processes.add (p); return p; } - static void tellNewProcessAboutExistingEditors (CompileEngineChildProcess* process) + static void tellNewProcessAboutExistingEditors (CompileEngineChildProcess& process) { - OpenDocumentManager& odm = ProjucerApplication::getApp().openDocumentManager; + auto& odm = ProjucerApplication::getApp().openDocumentManager; for (int i = odm.getNumOpenDocuments(); --i >= 0;) - if (SourceCodeDocument* d = dynamic_cast (odm.getOpenDocument (i))) - process->editorOpened (d->getFile(), d->getCodeDocument()); + if (auto d = dynamic_cast (odm.getOpenDocument (i))) + process.editorOpened (d->getFile(), d->getCodeDocument()); } void removeOrphans() diff --git a/extras/Projucer/Source/Project/UI/Sidebar/jucer_ExporterTreeItems.h b/extras/Projucer/Source/Project/UI/Sidebar/jucer_ExporterTreeItems.h index 0174b47547..c574ad7515 100644 --- a/extras/Projucer/Source/Project/UI/Sidebar/jucer_ExporterTreeItems.h +++ b/extras/Projucer/Source/Project/UI/Sidebar/jucer_ExporterTreeItems.h @@ -74,7 +74,7 @@ public: void showDocument() override { - showSettingsPage (new SettingsComp (exporter.get())); + showSettingsPage (new SettingsComp (*exporter)); } void deleteItem() override @@ -186,15 +186,15 @@ private: //============================================================================== struct SettingsComp : public Component { - SettingsComp (ProjectExporter* exp) - : group (exp->getName(), - ExporterItem::getIconForExporter (exp), - exp->getDescription()) + SettingsComp (ProjectExporter& exp) + : group (exp.getName(), + ExporterItem::getIconForExporter (&exp), + exp.getDescription()) { addAndMakeVisible (group); PropertyListBuilder props; - exp->createPropertyEditors (props); + exp.createPropertyEditors (props); group.setProperties (props); parentSizeChanged(); } @@ -234,7 +234,7 @@ public: void showDocument() override { - showSettingsPage (new SettingsComp (config)); + showSettingsPage (new SettingsComp (*config)); } void deleteItem() override @@ -283,13 +283,13 @@ private: class SettingsComp : public Component { public: - SettingsComp (ProjectExporter::BuildConfiguration* conf) - : group (conf->exporter.getName() + " - " + conf->getName(), Icon (getIcons().config, Colours::transparentBlack)) + SettingsComp (ProjectExporter::BuildConfiguration& conf) + : group (conf.exporter.getName() + " - " + conf.getName(), Icon (getIcons().config, Colours::transparentBlack)) { addAndMakeVisible (group); PropertyListBuilder props; - conf->createPropertyEditors (props); + conf.createPropertyEditors (props); group.setProperties (props); parentSizeChanged(); } diff --git a/extras/Projucer/Source/Project/UI/Sidebar/jucer_LiveBuildTab.h b/extras/Projucer/Source/Project/UI/Sidebar/jucer_LiveBuildTab.h index 3a5b300b11..11b215e7e0 100644 --- a/extras/Projucer/Source/Project/UI/Sidebar/jucer_LiveBuildTab.h +++ b/extras/Projucer/Source/Project/UI/Sidebar/jucer_LiveBuildTab.h @@ -67,7 +67,7 @@ class LiveBuildTab : public Component, private ChangeListener { public: - LiveBuildTab (CompileEngineChildProcess* child, String lastErrorMessage) + LiveBuildTab (const CompileEngineChildProcess::Ptr& child, String lastErrorMessage) { settingsButton.reset (new IconButton ("Settings", &getIcons().settings)); addAndMakeVisible (settingsButton.get()); @@ -80,13 +80,11 @@ public: if (child != nullptr) { addAndMakeVisible (concertinaPanel); - buildConcertina (child); + buildConcertina (*child); isEnabled = true; } else { - isEnabled = false; - errorMessage = getErrorMessage(); errorMessageLabel.reset (new Label ("Error", errorMessage)); errorMessageLabel->setJustificationType (Justification::centred); @@ -158,7 +156,7 @@ public: } } - bool isEnabled; + bool isEnabled = false; String errorMessage; Component::SafePointer errorListComp; @@ -232,16 +230,16 @@ private: } } - void buildConcertina (CompileEngineChildProcess* child) + void buildConcertina (CompileEngineChildProcess& child) { for (auto i = concertinaPanel.getNumPanels() - 1; i >= 0 ; --i) concertinaPanel.removePanel (concertinaPanel.getPanel (i)); headers.clear(); - errorListComp = new ProjucerAppClasses::ErrorListComp (child->errorList); - auto* activities = new CurrentActivitiesComp (child->activityList); - auto* comps = new ComponentListComp (*child); + errorListComp = new ProjucerAppClasses::ErrorListComp (child.errorList); + auto* activities = new CurrentActivitiesComp (child.activityList); + auto* comps = new ComponentListComp (child); concertinaPanel.addPanel (-1, errorListComp, true); concertinaPanel.addPanel (-1, comps, true); diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h index 14c2b07d41..89a32e35b7 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h @@ -303,7 +303,7 @@ public: bool next(); BuildConfiguration& operator*() const { return *config; } - BuildConfiguration* operator->() const { return config; } + BuildConfiguration* operator->() const { return config.get(); } BuildConfiguration::Ptr config; int index; @@ -320,7 +320,7 @@ public: bool next(); const BuildConfiguration& operator*() const { return *config; } - const BuildConfiguration* operator->() const { return config; } + const BuildConfiguration* operator->() const { return config.get(); } BuildConfiguration::Ptr config; int index; diff --git a/extras/UnitTestRunner/Builds/LinuxMakefile/Makefile b/extras/UnitTestRunner/Builds/LinuxMakefile/Makefile index 8a0dcfedb8..6d5bade061 100644 --- a/extras/UnitTestRunner/Builds/LinuxMakefile/Makefile +++ b/extras/UnitTestRunner/Builds/LinuxMakefile/Makefile @@ -35,13 +35,13 @@ ifeq ($(CONFIG),Debug) TARGET_ARCH := -march=native endif - JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DDEBUG=1 -D_DEBUG=1 -DJUCE_UNIT_TESTS=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=1.0.0 -DJUCE_APP_VERSION_HEX=0x10000 $(shell pkg-config --cflags alsa freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) + JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DDEBUG=1 -D_DEBUG=1 -DJUCE_UNIT_TESTS=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=1.0.0 -DJUCE_APP_VERSION_HEX=0x10000 $(shell pkg-config --cflags alsa freetype2 x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 libcurl) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) JUCE_CPPFLAGS_CONSOLEAPP := -DJucePlugin_Build_VST=0 -DJucePlugin_Build_VST3=0 -DJucePlugin_Build_AU=0 -DJucePlugin_Build_AUv3=0 -DJucePlugin_Build_RTAS=0 -DJucePlugin_Build_AAX=0 -DJucePlugin_Build_Standalone=0 -DJucePlugin_Build_Unity=0 JUCE_TARGET_CONSOLEAPP := UnitTestRunner JUCE_CFLAGS += $(JUCE_CPPFLAGS) $(TARGET_ARCH) -g -ggdb -O0 $(CFLAGS) JUCE_CXXFLAGS += $(JUCE_CFLAGS) -std=c++14 $(CXXFLAGS) - JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR) -L/usr/X11R6/lib/ $(shell pkg-config --libs alsa freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -lGL -ldl -lpthread -lrt $(LDFLAGS) + JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR) -L/usr/X11R6/lib/ $(shell pkg-config --libs alsa freetype2 x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 libcurl) -lGL -ldl -lpthread -lrt $(LDFLAGS) CLEANCMD = rm -rf $(JUCE_OUTDIR)/$(TARGET) $(JUCE_OBJDIR) endif @@ -56,13 +56,13 @@ ifeq ($(CONFIG),Release) TARGET_ARCH := -march=native endif - JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DNDEBUG=1 -DJUCE_UNIT_TESTS=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=1.0.0 -DJUCE_APP_VERSION_HEX=0x10000 $(shell pkg-config --cflags alsa freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) + JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DNDEBUG=1 -DJUCE_UNIT_TESTS=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=1.0.0 -DJUCE_APP_VERSION_HEX=0x10000 $(shell pkg-config --cflags alsa freetype2 x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 libcurl) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) JUCE_CPPFLAGS_CONSOLEAPP := -DJucePlugin_Build_VST=0 -DJucePlugin_Build_VST3=0 -DJucePlugin_Build_AU=0 -DJucePlugin_Build_AUv3=0 -DJucePlugin_Build_RTAS=0 -DJucePlugin_Build_AAX=0 -DJucePlugin_Build_Standalone=0 -DJucePlugin_Build_Unity=0 JUCE_TARGET_CONSOLEAPP := UnitTestRunner JUCE_CFLAGS += $(JUCE_CPPFLAGS) $(TARGET_ARCH) -O3 $(CFLAGS) JUCE_CXXFLAGS += $(JUCE_CFLAGS) -std=c++14 $(CXXFLAGS) - JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR) -L/usr/X11R6/lib/ $(shell pkg-config --libs alsa freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -fvisibility=hidden -lGL -ldl -lpthread -lrt $(LDFLAGS) + JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR) -L/usr/X11R6/lib/ $(shell pkg-config --libs alsa freetype2 x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 libcurl) -fvisibility=hidden -lGL -ldl -lpthread -lrt $(LDFLAGS) CLEANCMD = rm -rf $(JUCE_OUTDIR)/$(TARGET) $(JUCE_OBJDIR) endif @@ -202,7 +202,7 @@ $(JUCE_OBJDIR)/include_juce_video_be78589.o: ../../JuceLibraryCode/include_juce_ check-pkg-config: @command -v pkg-config >/dev/null 2>&1 || { echo >&2 "pkg-config not installed. Please, install it."; exit 1; } - @pkg-config --print-errors alsa freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 + @pkg-config --print-errors alsa freetype2 x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0 libcurl clean: @echo Cleaning UnitTestRunner diff --git a/extras/UnitTestRunner/JuceLibraryCode/AppConfig.h b/extras/UnitTestRunner/JuceLibraryCode/AppConfig.h index 4f86f8b15b..6271b11ead 100644 --- a/extras/UnitTestRunner/JuceLibraryCode/AppConfig.h +++ b/extras/UnitTestRunner/JuceLibraryCode/AppConfig.h @@ -197,6 +197,10 @@ //#define JUCE_USE_CURL 0 #endif +#ifndef JUCE_LOAD_CURL_SYMBOLS_LAZILY + //#define JUCE_LOAD_CURL_SYMBOLS_LAZILY 0 +#endif + #ifndef JUCE_CATCH_UNHANDLED_EXCEPTIONS //#define JUCE_CATCH_UNHANDLED_EXCEPTIONS 1 #endif @@ -205,6 +209,10 @@ //#define JUCE_ALLOW_STATIC_NULL_VARIABLES 1 #endif +#ifndef JUCE_STRICT_REFCOUNTEDPOINTER + #define JUCE_STRICT_REFCOUNTEDPOINTER 1 +#endif + //============================================================================== // juce_dsp flags: @@ -246,6 +254,10 @@ //#define JUCE_USE_DIRECTWRITE 1 #endif +#ifndef JUCE_DISABLE_COREGRAPHICS_FONT_SMOOTHING + //#define JUCE_DISABLE_COREGRAPHICS_FONT_SMOOTHING 0 +#endif + //============================================================================== // juce_gui_basics flags: diff --git a/extras/UnitTestRunner/UnitTestRunner.jucer b/extras/UnitTestRunner/UnitTestRunner.jucer index c919765f91..ffdf93d213 100644 --- a/extras/UnitTestRunner/UnitTestRunner.jucer +++ b/extras/UnitTestRunner/UnitTestRunner.jucer @@ -117,7 +117,7 @@ useGlobalPath="0"/> - + diff --git a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp index fa047d1496..ba6f818d6e 100644 --- a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp +++ b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp @@ -323,7 +323,7 @@ void Synthesiser::stopVoice (SynthesiserVoice* voice, float velocity, const bool voice->stopNote (velocity, allowTailOff); // the subclass MUST call clearCurrentNote() if it's not tailing off! RTFM for stopNote()! - jassert (allowTailOff || (voice->getCurrentlyPlayingNote() < 0 && voice->getCurrentlyPlayingSound() == 0)); + jassert (allowTailOff || (voice->getCurrentlyPlayingNote() < 0 && voice->getCurrentlyPlayingSound() == nullptr)); } void Synthesiser::noteOff (const int midiChannel, @@ -338,7 +338,7 @@ void Synthesiser::noteOff (const int midiChannel, if (voice->getCurrentlyPlayingNote() == midiNoteNumber && voice->isPlayingChannel (midiChannel)) { - if (SynthesiserSound* const sound = voice->getCurrentlyPlayingSound()) + if (auto sound = voice->getCurrentlyPlayingSound()) { if (sound->appliesToNote (midiNoteNumber) && sound->appliesToChannel (midiChannel)) diff --git a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h index 3215d10002..62e8cc1a2e 100644 --- a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h +++ b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h @@ -352,7 +352,7 @@ public: int getNumSounds() const noexcept { return sounds.size(); } /** Returns one of the sounds. */ - SynthesiserSound* getSound (int index) const noexcept { return sounds [index]; } + SynthesiserSound::Ptr getSound (int index) const noexcept { return sounds[index]; } /** Adds a new sound to the synthesiser. diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp index 8c6b32763d..db506860f0 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp @@ -938,7 +938,7 @@ AudioProcessorGraph::Node::Ptr AudioProcessorGraph::addNode (AudioProcessor* new newProcessor->setPlayHead (getPlayHead()); Node::Ptr n (new Node (nodeID, newProcessor)); - nodes.add (n); + nodes.add (n.get()); n->setParentGraph (this); topologyChanged(); return n; diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h index a752149d5d..b82c223cb8 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h @@ -185,7 +185,7 @@ public: This will return nullptr if the index is out of range. @see getNodeForId */ - Node* getNode (int index) const noexcept { return nodes [index]; } + Node::Ptr getNode (int index) const noexcept { return nodes[index]; } /** Searches the graph for a node with the given ID number and returns it. If no such node was found, this returns nullptr. diff --git a/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp b/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp index ae94c8cf9f..91ca9b1010 100644 --- a/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp +++ b/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp @@ -944,7 +944,7 @@ struct PhysicalTopologySource::Internal if (auto bi = BlockImplementation::getFrom (*currentBlock)) bi->invalidate(); - disconnectedBlocks.addIfNotAlreadyThere (currentTopology.blocks.removeAndReturn (i)); + disconnectedBlocks.addIfNotAlreadyThere (currentTopology.blocks.removeAndReturn (i).get()); } else { diff --git a/modules/juce_core/containers/juce_ReferenceCountedArray.h b/modules/juce_core/containers/juce_ReferenceCountedArray.h index 6505078ea1..14c0ad8d1d 100644 --- a/modules/juce_core/containers/juce_ReferenceCountedArray.h +++ b/modules/juce_core/containers/juce_ReferenceCountedArray.h @@ -216,7 +216,7 @@ public: /** Returns a raw pointer to the object at this index in the array, without checking whether the index is in-range. */ - inline ObjectClass* getObjectPointerUnchecked (const int index) const noexcept + inline ObjectClass* getObjectPointerUnchecked (int index) const noexcept { const ScopedLockType lock (getLock()); jassert (isPositiveAndBelow (index, numUsed) && data.elements != nullptr); @@ -308,6 +308,13 @@ public: return -1; } + /** Finds the index of the first occurrence of an object in the array. + + @param objectToLookFor the object to look for + @returns the index at which the object was found, or -1 if it's not found + */ + int indexOf (const ObjectClassPtr& objectToLookFor) const noexcept { return indexOf (objectToLookFor.get()); } + /** Returns true if the array contains a specified object. @param objectToLookFor the object to look for @@ -330,6 +337,13 @@ public: return false; } + /** Returns true if the array contains a specified object. + + @param objectToLookFor the object to look for + @returns true if the object is in the array + */ + bool contains (const ObjectClassPtr& objectToLookFor) const noexcept { return contains (objectToLookFor.get()); } + /** Appends a new object to the end of the array. This will increase the new object's reference count. @@ -337,7 +351,7 @@ public: @param newObject the new object to add to the array @see set, insert, addIfNotAlreadyThere, addSorted, addArray */ - ObjectClass* add (ObjectClass* newObject) noexcept + ObjectClass* add (ObjectClass* newObject) { const ScopedLockType lock (getLock()); data.ensureAllocatedSize (numUsed + 1); @@ -350,6 +364,15 @@ public: return newObject; } + /** Appends a new object to the end of the array. + + This will increase the new object's reference count. + + @param newObject the new object to add to the array + @see set, insert, addIfNotAlreadyThere, addSorted, addArray + */ + ObjectClass* add (const ObjectClassPtr& newObject) { return add (newObject.get()); } + /** Inserts a new object into the array at the given index. If the index is less than 0 or greater than the size of the array, the @@ -363,7 +386,7 @@ public: @param newObject the new object to add to the array @see add, addSorted, addIfNotAlreadyThere, set */ - ObjectClass* insert (int indexToInsertAt, ObjectClass* newObject) noexcept + ObjectClass* insert (int indexToInsertAt, ObjectClass* newObject) { if (indexToInsertAt < 0) return add (newObject); @@ -391,6 +414,21 @@ public: return newObject; } + /** Inserts a new object into the array at the given index. + + If the index is less than 0 or greater than the size of the array, the + element will be added to the end of the array. + Otherwise, it will be inserted into the array, moving all the later elements + along to make room. + + This will increase the new object's reference count. + + @param indexToInsertAt the index at which the new element should be inserted + @param newObject the new object to add to the array + @see add, addSorted, addIfNotAlreadyThere, set + */ + ObjectClass* insert (int indexToInsertAt, const ObjectClassPtr& newObject) { return insert (indexToInsertAt, newObject.get()); } + /** Appends a new object at the end of the array as long as the array doesn't already contain it. @@ -399,7 +437,7 @@ public: @param newObject the new object to add to the array @returns true if the object has been added, false otherwise */ - bool addIfNotAlreadyThere (ObjectClass* newObject) noexcept + bool addIfNotAlreadyThere (ObjectClass* newObject) { const ScopedLockType lock (getLock()); @@ -410,6 +448,16 @@ public: return true; } + /** Appends a new object at the end of the array as long as the array doesn't + already contain it. + + If the array already contains a matching object, nothing will be done. + + @param newObject the new object to add to the array + @returns true if the object has been added, false otherwise + */ + bool addIfNotAlreadyThere (const ObjectClassPtr& newObject) { return addIfNotAlreadyThere (newObject.get()); } + /** Replaces an object in the array with a different one. If the index is less than zero, this method does nothing. @@ -638,6 +686,16 @@ public: remove (indexOf (objectToRemove)); } + /** Removes the first occurrence of a specified object from the array. + + If the item isn't found, no action is taken. If it is found, it is + removed and has its reference count decreased. + + @param objectToRemove the object to try to remove + @see remove, removeRange + */ + void removeObject (const ObjectClassPtr& objectToRemove) { removeObject (objectToRemove.get()); } + /** Removes a range of objects from the array. This will remove a set of objects, starting from the given index, diff --git a/modules/juce_core/javascript/juce_Javascript.cpp b/modules/juce_core/javascript/juce_Javascript.cpp index b7d23c122c..8018a7cb19 100644 --- a/modules/juce_core/javascript/juce_Javascript.cpp +++ b/modules/juce_core/javascript/juce_Javascript.cpp @@ -103,7 +103,7 @@ struct JavascriptEngine::RootObject : public DynamicObject static bool isNumericOrUndefined (const var& v) noexcept { return isNumeric (v) || v.isUndefined(); } static int64 getOctalValue (const String& s) { BigInteger b; b.parseString (s.initialSectionContainingOnly ("01234567"), 8); return b.toInt64(); } static Identifier getPrototypeIdentifier() { static const Identifier i ("prototype"); return i; } - static var* getPropertyPointer (DynamicObject* o, const Identifier& i) noexcept { return o->getProperties().getVarPointer (i); } + static var* getPropertyPointer (DynamicObject& o, const Identifier& i) noexcept { return o.getProperties().getVarPointer (i); } //============================================================================== struct CodeLocation @@ -131,9 +131,11 @@ struct JavascriptEngine::RootObject : public DynamicObject //============================================================================== struct Scope { - Scope (const Scope* p, RootObject* r, DynamicObject* s) noexcept : parent (p), root (r), scope (s) {} + Scope (const Scope* p, ReferenceCountedObjectPtr rt, DynamicObject::Ptr scp) noexcept + : parent (p), root (static_cast&&> (rt)), + scope (static_cast (scp)) {} - const Scope* parent; + const Scope* const parent; ReferenceCountedObjectPtr root; DynamicObject::Ptr scope; @@ -141,13 +143,13 @@ struct JavascriptEngine::RootObject : public DynamicObject { if (auto* o = targetObject.getDynamicObject()) { - if (auto* prop = getPropertyPointer (o, functionName)) + if (auto* prop = getPropertyPointer (*o, functionName)) return *prop; for (auto* p = o->getProperty (getPrototypeIdentifier()).getDynamicObject(); p != nullptr; p = p->getProperty (getPrototypeIdentifier()).getDynamicObject()) { - if (auto* prop = getPropertyPointer (p, functionName)) + if (auto* prop = getPropertyPointer (*p, functionName)) return *prop; } @@ -174,14 +176,14 @@ struct JavascriptEngine::RootObject : public DynamicObject var* findRootClassProperty (const Identifier& className, const Identifier& propName) const { if (auto* cls = root->getProperty (className).getDynamicObject()) - return getPropertyPointer (cls, propName); + return getPropertyPointer (*cls, propName); return nullptr; } var findSymbolInParentScopes (const Identifier& name) const { - if (auto* v = getPropertyPointer (scope, name)) + if (auto v = getPropertyPointer (*scope, name)) return *v; return parent != nullptr ? parent->findSymbolInParentScopes (name) @@ -192,9 +194,9 @@ struct JavascriptEngine::RootObject : public DynamicObject { auto* target = args.thisObject.getDynamicObject(); - if (target == nullptr || target == scope) + if (target == nullptr || target == scope.get()) { - if (auto* m = getPropertyPointer (scope, function)) + if (auto* m = getPropertyPointer (*scope, function)) { if (auto fo = dynamic_cast (m->getObject())) { @@ -220,7 +222,7 @@ struct JavascriptEngine::RootObject : public DynamicObject { auto* target = args.thisObject.getDynamicObject(); - if (target == nullptr || target == scope) + if (target == nullptr || target == scope.get()) { if (auto fo = dynamic_cast (m.getObject())) { @@ -238,6 +240,8 @@ struct JavascriptEngine::RootObject : public DynamicObject if (Time::getCurrentTime() > root->timeout) location.throwError (root->timeout == Time() ? "Interrupted" : "Execution timed-out"); } + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Scope) }; //============================================================================== @@ -378,7 +382,7 @@ struct JavascriptEngine::RootObject : public DynamicObject void assign (const Scope& s, const var& newValue) const override { - if (auto* v = getPropertyPointer (s.scope, name)) + if (auto* v = getPropertyPointer (*s.scope, name)) *v = newValue; else s.root->setProperty (name, newValue); @@ -403,7 +407,7 @@ struct JavascriptEngine::RootObject : public DynamicObject } if (auto* o = p.getDynamicObject()) - if (auto* v = getPropertyPointer (o, child)) + if (auto* v = getPropertyPointer (*o, child)) return *v; return var::undefined(); @@ -436,7 +440,7 @@ struct JavascriptEngine::RootObject : public DynamicObject if (auto* o = arrayVar.getDynamicObject()) if (key.isString()) - if (auto* v = getPropertyPointer (o, Identifier (key))) + if (auto* v = getPropertyPointer (*o, Identifier (key))) return *v; return var::undefined(); @@ -1865,13 +1869,13 @@ var JavascriptEngine::evaluate (const String& code, Result* result) var JavascriptEngine::callFunction (const Identifier& function, const var::NativeFunctionArgs& args, Result* result) { - var returnVal (var::undefined()); + auto returnVal = var::undefined(); try { prepareTimeout(); if (result != nullptr) *result = Result::ok(); - RootObject::Scope (nullptr, root, root).findAndInvokeMethod (function, args, returnVal); + RootObject::Scope ({}, root, root).findAndInvokeMethod (function, args, returnVal); } catch (String& error) { @@ -1884,13 +1888,13 @@ var JavascriptEngine::callFunction (const Identifier& function, const var::Nativ var JavascriptEngine::callFunctionObject (DynamicObject* objectScope, const var& functionObject, const var::NativeFunctionArgs& args, Result* result) { - var returnVal (var::undefined()); + auto returnVal = var::undefined(); try { prepareTimeout(); if (result != nullptr) *result = Result::ok(); - RootObject::Scope rootScope (nullptr, root, root); + RootObject::Scope rootScope ({}, root, root); RootObject::Scope (&rootScope, root, objectScope).invokeMethod (functionObject, args, returnVal); } catch (String& error) diff --git a/modules/juce_core/juce_core.h b/modules/juce_core/juce_core.h index b95a958fec..160967b07f 100644 --- a/modules/juce_core/juce_core.h +++ b/modules/juce_core/juce_core.h @@ -173,6 +173,15 @@ #define JUCE_ALLOW_STATIC_NULL_VARIABLES 1 #endif +/** Config: JUCE_STRICT_REFCOUNTEDPOINTER + If enabled, this will make the ReferenceCountedObjectPtr class stricter about allowing + itself to be cast directly to a raw pointer. By default this is disabled, for compatibility + with old code, but if possible, you should always enable it to improve code safety! +*/ +#ifndef JUCE_STRICT_REFCOUNTEDPOINTER + #define JUCE_STRICT_REFCOUNTEDPOINTER 0 +#endif + #ifndef JUCE_STRING_UTF_TYPE #define JUCE_STRING_UTF_TYPE 8 diff --git a/modules/juce_core/maths/juce_Expression.cpp b/modules/juce_core/maths/juce_Expression.cpp index 62a43ae275..ecf5003a47 100644 --- a/modules/juce_core/maths/juce_Expression.cpp +++ b/modules/juce_core/maths/juce_Expression.cpp @@ -107,7 +107,7 @@ struct Expression::Helpers class Constant : public Term { public: - Constant (const double val, const bool resolutionTarget) + Constant (double val, bool resolutionTarget) : value (val), isResolutionTarget (resolutionTarget) {} Type getType() const noexcept { return constantType; } @@ -133,9 +133,9 @@ struct Expression::Helpers class BinaryTerm : public Term { public: - BinaryTerm (Term* const l, Term* const r) : left (l), right (r) + BinaryTerm (TermPtr l, TermPtr r) : left (static_cast (l)), right (static_cast (r)) { - jassert (l != nullptr && r != nullptr); + jassert (left != nullptr && right != nullptr); } int getInputIndexFor (const Term* possibleInput) const @@ -183,9 +183,9 @@ struct Expression::Helpers { jassert (input == left || input == right); if (input != left && input != right) - return TermPtr(); + return {}; - if (const Term* const dest = findDestinationFor (topLevelTerm, this)) + if (auto dest = findDestinationFor (topLevelTerm, this)) return dest->createTermToEvaluateInput (scope, this, overallTarget, topLevelTerm); return new Constant (overallTarget, false); @@ -238,7 +238,7 @@ struct Expression::Helpers Type getType() const noexcept { return functionType; } Term* clone() const { return new Function (functionName, parameters); } int getNumInputs() const { return parameters.size(); } - Term* getInput (int i) const { return parameters.getReference(i).term; } + Term* getInput (int i) const { return parameters.getReference(i).term.get(); } String getName() const { return functionName; } TermPtr resolve (const Scope& scope, int recursionDepth) @@ -300,7 +300,7 @@ struct Expression::Helpers class DotOperator : public BinaryTerm { public: - DotOperator (SymbolTerm* const l, Term* const r) : BinaryTerm (l, r) {} + DotOperator (SymbolTerm* const l, TermPtr r) : BinaryTerm (l, r) {} TermPtr resolve (const Scope& scope, int recursionDepth) { @@ -311,7 +311,7 @@ struct Expression::Helpers return visitor.output; } - Term* clone() const { return new DotOperator (getSymbol(), right); } + Term* clone() const { return new DotOperator (getSymbol(), right.get()); } String getName() const { return "."; } int getOperatorPrecedence() const { return 1; } void writeOperator (String& dest) const { dest << '.'; } @@ -451,7 +451,7 @@ struct Expression::Helpers class Add : public BinaryTerm { public: - Add (Term* const l, Term* const r) : BinaryTerm (l, r) {} + Add (TermPtr l, TermPtr r) : BinaryTerm (l, r) {} Term* clone() const { return new Add (left->clone(), right->clone()); } double performFunction (double lhs, double rhs) const { return lhs + rhs; } @@ -461,11 +461,10 @@ struct Expression::Helpers TermPtr createTermToEvaluateInput (const Scope& scope, const Term* input, double overallTarget, Term* topLevelTerm) const { - const TermPtr newDest (createDestinationTerm (scope, input, overallTarget, topLevelTerm)); - if (newDest == nullptr) - return TermPtr(); + if (auto newDest = createDestinationTerm (scope, input, overallTarget, topLevelTerm)) + return new Subtract (newDest, (input == left ? right : left)->clone()); - return new Subtract (newDest, (input == left ? right : left)->clone()); + return {}; } private: @@ -476,7 +475,7 @@ struct Expression::Helpers class Subtract : public BinaryTerm { public: - Subtract (Term* const l, Term* const r) : BinaryTerm (l, r) {} + Subtract (TermPtr l, TermPtr r) : BinaryTerm (l, r) {} Term* clone() const { return new Subtract (left->clone(), right->clone()); } double performFunction (double lhs, double rhs) const { return lhs - rhs; } @@ -486,14 +485,15 @@ struct Expression::Helpers TermPtr createTermToEvaluateInput (const Scope& scope, const Term* input, double overallTarget, Term* topLevelTerm) const { - const TermPtr newDest (createDestinationTerm (scope, input, overallTarget, topLevelTerm)); - if (newDest == nullptr) - return TermPtr(); + if (auto newDest = createDestinationTerm (scope, input, overallTarget, topLevelTerm)) + { + if (input == left) + return new Add (newDest, right->clone()); - if (input == left) - return new Add (newDest, right->clone()); + return new Subtract (left->clone(), newDest); + } - return new Subtract (left->clone(), newDest); + return {}; } private: @@ -504,7 +504,7 @@ struct Expression::Helpers class Multiply : public BinaryTerm { public: - Multiply (Term* const l, Term* const r) : BinaryTerm (l, r) {} + Multiply (TermPtr l, TermPtr r) : BinaryTerm (l, r) {} Term* clone() const { return new Multiply (left->clone(), right->clone()); } double performFunction (double lhs, double rhs) const { return lhs * rhs; } @@ -514,14 +514,12 @@ struct Expression::Helpers TermPtr createTermToEvaluateInput (const Scope& scope, const Term* input, double overallTarget, Term* topLevelTerm) const { - const TermPtr newDest (createDestinationTerm (scope, input, overallTarget, topLevelTerm)); - if (newDest == nullptr) - return TermPtr(); + if (auto newDest = createDestinationTerm (scope, input, overallTarget, topLevelTerm)) + return new Divide (newDest, (input == left ? right : left)->clone()); - return new Divide (newDest, (input == left ? right : left)->clone()); + return {}; } - private: JUCE_DECLARE_NON_COPYABLE (Multiply) }; @@ -529,7 +527,7 @@ struct Expression::Helpers class Divide : public BinaryTerm { public: - Divide (Term* const l, Term* const r) : BinaryTerm (l, r) {} + Divide (TermPtr l, TermPtr r) : BinaryTerm (l, r) {} Term* clone() const { return new Divide (left->clone(), right->clone()); } double performFunction (double lhs, double rhs) const { return lhs / rhs; } @@ -541,7 +539,7 @@ struct Expression::Helpers { const TermPtr newDest (createDestinationTerm (scope, input, overallTarget, topLevelTerm)); if (newDest == nullptr) - return TermPtr(); + return {}; if (input == left) return new Multiply (newDest, right->clone()); @@ -549,7 +547,6 @@ struct Expression::Helpers return new Divide (left->clone(), newDest); } - private: JUCE_DECLARE_NON_COPYABLE (Divide) }; @@ -610,13 +607,13 @@ struct Expression::Helpers return nullptr; } - static bool containsAnySymbols (const Term* const t) + static bool containsAnySymbols (const Term& t) { - if (t->getType() == Expression::symbolType) + if (t.getType() == Expression::symbolType) return true; - for (int i = t->getNumInputs(); --i >= 0;) - if (containsAnySymbols (t->getInput (i))) + for (int i = t.getNumInputs(); --i >= 0;) + if (containsAnySymbols (*t.getInput (i))) return true; return false; @@ -905,17 +902,17 @@ struct Expression::Helpers return new SymbolTerm (identifier); } - return TermPtr(); + return {}; } TermPtr readParenthesisedExpression() { if (! readOperator ("(")) - return TermPtr(); + return {}; const TermPtr e (readExpression()); if (e == nullptr || ! readOperator (")")) - return TermPtr(); + return {}; return e; } @@ -1089,7 +1086,7 @@ void Expression::findReferencedSymbols (Array& results, const Scope& sco } String Expression::toString() const { return term->toString(); } -bool Expression::usesAnySymbols() const { return Helpers::containsAnySymbols (term); } +bool Expression::usesAnySymbols() const { return Helpers::containsAnySymbols (*term); } Expression::Type Expression::getType() const noexcept { return term->getType(); } String Expression::getSymbolOrFunction() const { return term->getName(); } int Expression::getNumInputs() const { return term->getNumInputs(); } diff --git a/modules/juce_core/memory/juce_ReferenceCountedObject.h b/modules/juce_core/memory/juce_ReferenceCountedObject.h index 61000b0737..0fc3c940a3 100644 --- a/modules/juce_core/memory/juce_ReferenceCountedObject.h +++ b/modules/juce_core/memory/juce_ReferenceCountedObject.h @@ -269,6 +269,13 @@ public: incIfNotNull (referencedObject); } + /** Takes-over the object from another pointer. */ + ReferenceCountedObjectPtr (ReferenceCountedObjectPtr&& other) noexcept + : referencedObject (other.referencedObject) + { + other.referencedObject = nullptr; + } + /** Copies another pointer. This will increment the object's reference-count (if it is non-null). */ @@ -317,14 +324,7 @@ public: } /** Takes-over the object from another pointer. */ - ReferenceCountedObjectPtr (ReferenceCountedObjectPtr&& other) noexcept - : referencedObject (other.referencedObject) - { - other.referencedObject = nullptr; - } - - /** Takes-over the object from another pointer. */ - ReferenceCountedObjectPtr& operator= (ReferenceCountedObjectPtr&& other) + ReferenceCountedObjectPtr& operator= (ReferenceCountedObjectPtr&& other) noexcept { std::swap (referencedObject, other.referencedObject); return *this; @@ -343,24 +343,42 @@ public: /** Returns the object that this pointer references. The pointer returned may be null, of course. */ - operator ReferencedType*() const noexcept { return referencedObject; } + ReferencedType* get() const noexcept { return referencedObject; } - /** Returns the object that this pointer references. + // the -> operator is called on the referenced object + ReferencedType* operator->() const noexcept + { + jassert (referencedObject != nullptr); // null pointer method call! + return referencedObject; + } + + /** Dereferences the object that this pointer references. The pointer returned may be null, of course. */ - ReferencedType* get() const noexcept { return referencedObject; } + ReferencedType& operator*() const noexcept { jassert (referencedObject != nullptr); return *referencedObject; } + + /** Checks whether this pointer is null */ + bool operator== (decltype (nullptr)) const noexcept { return referencedObject == nullptr; } + /** Checks whether this pointer is null */ + bool operator!= (decltype (nullptr)) const noexcept { return referencedObject != nullptr; } + + #if JUCE_STRICT_REFCOUNTEDPOINTER + /** Checks whether this pointer is null */ + operator bool() const noexcept { return referencedObject != nullptr; } + #else /** Returns the object that this pointer references. The pointer returned may be null, of course. + Note that this methods allows the compiler to be very lenient with what it allows you to do + with the pointer, it's safer to disable this by setting JUCE_STRICT_REFCOUNTEDPOINTER=1, which + increased type safety and can prevent some common slip-ups. */ - ReferencedType* getObject() const noexcept { return referencedObject; } + operator ReferencedType*() const noexcept { return referencedObject; } + #endif - // the -> operator is called on the referenced object - ReferencedType* operator->() const noexcept - { - jassert (referencedObject != nullptr); // null pointer method call! - return referencedObject; - } + + // This old method is deprecated in favour of the shorter and more standard get() method. + JUCE_DEPRECATED_WITH_BODY (ReferencedType* getObject() const, { return get(); }) private: //============================================================================== @@ -382,43 +400,43 @@ private: //============================================================================== /** Compares two ReferenceCountedObjectPtrs. */ -template -bool operator== (const ReferenceCountedObjectPtr& object1, ObjectType* const object2) noexcept +template +bool operator== (const ReferenceCountedObjectPtr& object1, const Type* object2) noexcept { return object1.get() == object2; } /** Compares two ReferenceCountedObjectPtrs. */ -template -bool operator== (const ReferenceCountedObjectPtr& object1, const ReferenceCountedObjectPtr& object2) noexcept +template +bool operator== (const ReferenceCountedObjectPtr& object1, const ReferenceCountedObjectPtr& object2) noexcept { return object1.get() == object2.get(); } /** Compares two ReferenceCountedObjectPtrs. */ -template -bool operator== (ObjectType* object1, const ReferenceCountedObjectPtr& object2) noexcept +template +bool operator== (const Type* object1, const ReferenceCountedObjectPtr& object2) noexcept { return object1 == object2.get(); } /** Compares two ReferenceCountedObjectPtrs. */ -template -bool operator!= (const ReferenceCountedObjectPtr& object1, const ObjectType* object2) noexcept +template +bool operator!= (const ReferenceCountedObjectPtr& object1, const Type* object2) noexcept { return object1.get() != object2; } /** Compares two ReferenceCountedObjectPtrs. */ -template -bool operator!= (const ReferenceCountedObjectPtr& object1, const ReferenceCountedObjectPtr& object2) noexcept +template +bool operator!= (const ReferenceCountedObjectPtr& object1, const ReferenceCountedObjectPtr& object2) noexcept { return object1.get() != object2.get(); } /** Compares two ReferenceCountedObjectPtrs. */ -template -bool operator!= (ObjectType* object1, const ReferenceCountedObjectPtr& object2) noexcept +template +bool operator!= (const Type* object1, const ReferenceCountedObjectPtr& object2) noexcept { return object1 != object2.get(); } diff --git a/modules/juce_core/memory/juce_WeakReference.h b/modules/juce_core/memory/juce_WeakReference.h index 488a806ca7..572e34a4ff 100644 --- a/modules/juce_core/memory/juce_WeakReference.h +++ b/modules/juce_core/memory/juce_WeakReference.h @@ -166,7 +166,7 @@ public: /** The first call to this method will create an internal object that is shared by all weak references to the object. */ - SharedPointer* getSharedPointer (ObjectType* object) + SharedRef getSharedPointer (ObjectType* object) { if (sharedPointer == nullptr) { @@ -206,9 +206,12 @@ public: private: SharedRef holder; - static inline SharedPointer* getRef (ObjectType* o) + static inline SharedRef getRef (ObjectType* o) { - return (o != nullptr) ? o->masterReference.getSharedPointer (o) : nullptr; + if (o != nullptr) + return o->masterReference.getSharedPointer (o); + + return {}; } }; diff --git a/modules/juce_data_structures/values/juce_ValueTree.cpp b/modules/juce_data_structures/values/juce_ValueTree.cpp index 8edfb0e675..be1db990ef 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.cpp +++ b/modules/juce_data_structures/values/juce_ValueTree.cpp @@ -394,7 +394,7 @@ public: writeObjectToStream (output, children.getObjectPointerUnchecked(i)); } - static void writeObjectToStream (OutputStream& output, const SharedObject* object) + static void writeObjectToStream (OutputStream& output, const Ptr& object) { if (object != nullptr) { @@ -411,10 +411,11 @@ public: //============================================================================== struct SetPropertyAction : public UndoableAction { - SetPropertyAction (SharedObject* so, const Identifier& propertyName, + SetPropertyAction (Ptr targetObject, const Identifier& propertyName, const var& newVal, const var& oldVal, bool isAdding, bool isDeleting, ValueTree::Listener* listenerToExclude = nullptr) - : target (so), name (propertyName), newValue (newVal), oldValue (oldVal), + : target (static_cast (targetObject)), + name (propertyName), newValue (newVal), oldValue (oldVal), isAddingNewProperty (isAdding), isDeletingProperty (isDeleting), excludeListener (listenerToExclude) { @@ -474,8 +475,8 @@ public: //============================================================================== struct AddOrRemoveChildAction : public UndoableAction { - AddOrRemoveChildAction (SharedObject* parentObject, int index, SharedObject* newChild) - : target (parentObject), + AddOrRemoveChildAction (Ptr parentObject, int index, SharedObject* newChild) + : target (static_cast (parentObject)), child (newChild != nullptr ? newChild : parentObject->children.getObjectPointer (index)), childIndex (index), isDeleting (newChild == nullptr) @@ -488,7 +489,7 @@ public: if (isDeleting) target->removeChild (childIndex, nullptr); else - target->addChild (child, childIndex, nullptr); + target->addChild (child.get(), childIndex, nullptr); return true; } @@ -497,7 +498,7 @@ public: { if (isDeleting) { - target->addChild (child, childIndex, nullptr); + target->addChild (child.get(), childIndex, nullptr); } else { @@ -526,8 +527,8 @@ public: //============================================================================== struct MoveChildAction : public UndoableAction { - MoveChildAction (SharedObject* parentObject, int fromIndex, int toIndex) noexcept - : parent (parentObject), startIndex (fromIndex), endIndex (toIndex) + MoveChildAction (Ptr parentObject, int fromIndex, int toIndex) noexcept + : parent (static_cast (parentObject)), startIndex (fromIndex), endIndex (toIndex) { } @@ -597,7 +598,8 @@ ValueTree::ValueTree (const Identifier& type, addChild (tree, -1, nullptr); } -ValueTree::ValueTree (SharedObject* so) noexcept : object (so) +ValueTree::ValueTree (ReferenceCountedObjectPtr so) noexcept + : object (static_cast&&> (so)) { } @@ -892,7 +894,7 @@ ValueTree ValueTree::getChildWithProperty (const Identifier& propertyName, const bool ValueTree::isAChildOf (const ValueTree& possibleParent) const noexcept { - return object != nullptr && object->isAChildOf (possibleParent.object); + return object != nullptr && object->isAChildOf (possibleParent.object.get()); } int ValueTree::indexOf (const ValueTree& child) const noexcept @@ -905,7 +907,7 @@ void ValueTree::addChild (const ValueTree& child, int index, UndoManager* undoMa jassert (object != nullptr); // Trying to add a child to a null ValueTree! if (object != nullptr) - object->addChild (child.object, index, undoManager); + object->addChild (child.object.get(), index, undoManager); } void ValueTree::appendChild (const ValueTree& child, UndoManager* undoManager) @@ -1056,7 +1058,7 @@ ValueTree ValueTree::readFromStream (InputStream& input) return v; v.object->children.add (child.object); - child.object->parent = v.object; + child.object->parent = v.object.get(); } return v; diff --git a/modules/juce_data_structures/values/juce_ValueTree.h b/modules/juce_data_structures/values/juce_ValueTree.h index 4a5e6ff90a..a24c3cd7c6 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.h +++ b/modules/juce_data_structures/values/juce_ValueTree.h @@ -632,7 +632,7 @@ private: void createListOfChildren (OwnedArray&) const; void reorderChildren (const OwnedArray&, UndoManager*); - explicit ValueTree (SharedObject*) noexcept; + explicit ValueTree (ReferenceCountedObjectPtr) noexcept; }; } // namespace juce diff --git a/modules/juce_dsp/processors/juce_FIRFilter.h b/modules/juce_dsp/processors/juce_FIRFilter.h index bcf1cc3db7..98195e4580 100644 --- a/modules/juce_dsp/processors/juce_FIRFilter.h +++ b/modules/juce_dsp/processors/juce_FIRFilter.h @@ -60,12 +60,15 @@ namespace FIR */ using NumericType = typename SampleTypeHelpers::ElementType::Type; + /** A typedef for a ref-counted pointer to the coefficients object */ + using CoefficientsPtr = typename Coefficients::Ptr; + //============================================================================== /** This will create a filter which will produce silence. */ Filter() : coefficients (new Coefficients) { reset(); } /** Creates a filter with a given set of coefficients. */ - Filter (Coefficients* coefficientsToUse) : coefficients (coefficientsToUse) { reset(); } + Filter (CoefficientsPtr coefficientsToUse) : coefficients (static_cast (coefficientsToUse)) { reset(); } Filter (const Filter&) = default; Filter (Filter&&) = default; diff --git a/modules/juce_dsp/processors/juce_IIRFilter.h b/modules/juce_dsp/processors/juce_IIRFilter.h index 41e71e90e8..587c7630d0 100644 --- a/modules/juce_dsp/processors/juce_IIRFilter.h +++ b/modules/juce_dsp/processors/juce_IIRFilter.h @@ -59,6 +59,9 @@ namespace IIR */ using NumericType = typename SampleTypeHelpers::ElementType::Type; + /** A typedef for a ref-counted pointer to the coefficients object */ + using CoefficientsPtr = typename Coefficients::Ptr; + //============================================================================== /** Creates a filter. @@ -69,7 +72,7 @@ namespace IIR Filter(); /** Creates a filter with a given set of coefficients. */ - Filter (Coefficients* coefficientsToUse); + Filter (CoefficientsPtr coefficientsToUse); Filter (const Filter&) = default; Filter (Filter&&) = default; @@ -83,7 +86,7 @@ namespace IIR If you change the order of the coefficients then you must call reset after modifying them. */ - typename Coefficients::Ptr coefficients; + CoefficientsPtr coefficients; //============================================================================== /** Resets the filter's processing pipeline, ready to start a new stream of data. diff --git a/modules/juce_dsp/processors/juce_IIRFilter_Impl.h b/modules/juce_dsp/processors/juce_IIRFilter_Impl.h index f4f8848f66..709c7dbbc4 100644 --- a/modules/juce_dsp/processors/juce_IIRFilter_Impl.h +++ b/modules/juce_dsp/processors/juce_IIRFilter_Impl.h @@ -42,8 +42,7 @@ Filter::Filter() } template -Filter::Filter (Coefficients::NumericType>* c) - : coefficients (c) +Filter::Filter (CoefficientsPtr c) : coefficients (static_cast (c)) { reset(); } diff --git a/modules/juce_dsp/processors/juce_ProcessorDuplicator.h b/modules/juce_dsp/processors/juce_ProcessorDuplicator.h index 398ba8131a..280945bc60 100644 --- a/modules/juce_dsp/processors/juce_ProcessorDuplicator.h +++ b/modules/juce_dsp/processors/juce_ProcessorDuplicator.h @@ -44,6 +44,7 @@ struct ProcessorDuplicator { ProcessorDuplicator() : state (new StateType()) {} ProcessorDuplicator (StateType* stateToUse) : state (stateToUse) {} + ProcessorDuplicator (typename StateType::Ptr stateToUse) : state (static_cast (stateToUse)) {} ProcessorDuplicator (const ProcessorDuplicator&) = default; ProcessorDuplicator (ProcessorDuplicator&&) = default; diff --git a/modules/juce_dsp/processors/juce_StateVariableFilter.h b/modules/juce_dsp/processors/juce_StateVariableFilter.h index dfa1034e37..5f9bdf6d4a 100644 --- a/modules/juce_dsp/processors/juce_StateVariableFilter.h +++ b/modules/juce_dsp/processors/juce_StateVariableFilter.h @@ -60,11 +60,14 @@ namespace StateVariableFilter */ using NumericType = typename SampleTypeHelpers::ElementType::Type; + /** A typedef for a ref-counted pointer to the coefficients object */ + using ParametersPtr = typename Parameters::Ptr; + //============================================================================== /** Creates a filter with default parameters. */ - Filter() : parameters (new Parameters) { reset(); } + Filter() : parameters (new Parameters) { reset(); } - Filter (Parameters* parametersToUse) : parameters (parametersToUse) { reset(); } + Filter (ParametersPtr parametersToUse) : parameters (static_cast (parametersToUse)) { reset(); } /** Creates a copy of another filter. */ Filter (const Filter&) = default; diff --git a/modules/juce_graphics/fonts/juce_CustomTypeface.cpp b/modules/juce_graphics/fonts/juce_CustomTypeface.cpp index e7e0f8e95a..1f31a3035d 100644 --- a/modules/juce_graphics/fonts/juce_CustomTypeface.cpp +++ b/modules/juce_graphics/fonts/juce_CustomTypeface.cpp @@ -313,7 +313,7 @@ float CustomTypeface::getStringWidth (const String& text) else { if (auto fallbackTypeface = Typeface::getFallbackTypeface()) - if (fallbackTypeface != this) + if (fallbackTypeface.get() != this) x += fallbackTypeface->getStringWidth (String::charToString (c)); } } @@ -342,7 +342,7 @@ void CustomTypeface::getGlyphPositions (const String& text, Array& resultGl { auto fallbackTypeface = getFallbackTypeface(); - if (fallbackTypeface != nullptr && fallbackTypeface != this) + if (fallbackTypeface != nullptr && fallbackTypeface.get() != this) { Array subGlyphs; Array subOffsets; @@ -371,7 +371,7 @@ bool CustomTypeface::getOutlineForGlyph (int glyphNumber, Path& path) } if (auto fallbackTypeface = getFallbackTypeface()) - if (fallbackTypeface != this) + if (fallbackTypeface.get() != this) return fallbackTypeface->getOutlineForGlyph (glyphNumber, path); return false; @@ -389,7 +389,7 @@ EdgeTable* CustomTypeface::getEdgeTableForGlyph (int glyphNumber, const AffineTr else { if (auto fallbackTypeface = getFallbackTypeface()) - if (fallbackTypeface != this) + if (fallbackTypeface.get() != this) return fallbackTypeface->getEdgeTableForGlyph (glyphNumber, transform, fontHeight); } diff --git a/modules/juce_graphics/fonts/juce_Font.cpp b/modules/juce_graphics/fonts/juce_Font.cpp index 2a5ab8bf7b..0060099821 100644 --- a/modules/juce_graphics/fonts/juce_Font.cpp +++ b/modules/juce_graphics/fonts/juce_Font.cpp @@ -392,7 +392,7 @@ Typeface* Font::getTypeface() const jassert (font->typeface != nullptr); } - return font->typeface; + return font->typeface.get(); } //============================================================================== diff --git a/modules/juce_graphics/images/juce_Image.cpp b/modules/juce_graphics/images/juce_Image.cpp index 82c8bd05ff..a1221b3d3e 100644 --- a/modules/juce_graphics/images/juce_Image.cpp +++ b/modules/juce_graphics/images/juce_Image.cpp @@ -156,9 +156,9 @@ ImagePixelData::Ptr NativeImageType::create (Image::PixelFormat format, int widt class SubsectionPixelData : public ImagePixelData { public: - SubsectionPixelData (ImagePixelData* im, Rectangle r) - : ImagePixelData (im->pixelFormat, r.getWidth(), r.getHeight()), - sourceImage (im), area (r) + SubsectionPixelData (ImagePixelData::Ptr source, Rectangle r) + : ImagePixelData (source->pixelFormat, r.getWidth(), r.getHeight()), + sourceImage (static_cast (source)), area (r) { } @@ -225,8 +225,8 @@ Image::Image() noexcept { } -Image::Image (ImagePixelData* instance) noexcept - : image (instance) +Image::Image (ReferenceCountedObjectPtr instance) noexcept + : image (static_cast&&> (instance)) { } diff --git a/modules/juce_graphics/images/juce_Image.h b/modules/juce_graphics/images/juce_Image.h index e9c8e83b57..5fb5818ed0 100644 --- a/modules/juce_graphics/images/juce_Image.h +++ b/modules/juce_graphics/images/juce_Image.h @@ -409,10 +409,10 @@ public: //============================================================================== /** @internal */ - ImagePixelData* getPixelData() const noexcept { return image; } + ImagePixelData* getPixelData() const noexcept { return image.get(); } /** @internal */ - explicit Image (ImagePixelData*) noexcept; + explicit Image (ReferenceCountedObjectPtr) noexcept; /* A null Image object that can be used when you need to return an invalid image. @deprecated If you need a default-constructed var, just use Image() or {}. diff --git a/modules/juce_graphics/native/juce_RenderingHelpers.h b/modules/juce_graphics/native/juce_RenderingHelpers.h index 8561580336..eb472f35af 100644 --- a/modules/juce_graphics/native/juce_RenderingHelpers.h +++ b/modules/juce_graphics/native/juce_RenderingHelpers.h @@ -194,14 +194,14 @@ public: { const ScopedLock sl (lock); - if (auto* g = findExistingGlyph (font, glyphNumber)) + if (auto g = findExistingGlyph (font, glyphNumber)) { ++hits; return g; } ++misses; - auto* g = getGlyphForReuse(); + auto g = getGlyphForReuse(); jassert (g != nullptr); g->generate (font, glyphNumber); return g; @@ -212,16 +212,16 @@ private: Atomic accessCounter, hits, misses; CriticalSection lock; - CachedGlyphType* findExistingGlyph (const Font& font, int glyphNumber) const noexcept + ReferenceCountedObjectPtr findExistingGlyph (const Font& font, int glyphNumber) const noexcept { - for (auto* g : glyphs) + for (auto g : glyphs) if (g->glyph == glyphNumber && g->font == font) return g; - return nullptr; + return {}; } - CachedGlyphType* getGlyphForReuse() + ReferenceCountedObjectPtr getGlyphForReuse() { if (hits.get() + misses.get() > glyphs.size() * 16) { @@ -2397,7 +2397,7 @@ public: void drawImage (const Image& sourceImage, const AffineTransform& trans) { if (clip != nullptr && ! fillType.colour.isTransparent()) - renderImage (sourceImage, trans, nullptr); + renderImage (sourceImage, trans, {}); } static bool isOnlyTranslationAllowingError (const AffineTransform& t, float tolerence) noexcept @@ -2490,7 +2490,7 @@ public: } else if (fillType.isTiledImage()) { - renderImage (fillType.image, fillType.transform, shapeToFill); + renderImage (fillType.image, fillType.transform, shapeToFill.get()); } else { diff --git a/modules/juce_gui_basics/menus/juce_BurgerMenuComponent.cpp b/modules/juce_gui_basics/menus/juce_BurgerMenuComponent.cpp index 8a3e5cacc2..02656f68f2 100644 --- a/modules/juce_gui_basics/menus/juce_BurgerMenuComponent.cpp +++ b/modules/juce_gui_basics/menus/juce_BurgerMenuComponent.cpp @@ -46,7 +46,7 @@ struct CustomMenuBarItemHolder : public Component removeChildComponent (custom); custom = newComponent; - addAndMakeVisible (custom); + addAndMakeVisible (*custom); resized(); } } diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 7acacad3e3..e4b69cbcea 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -79,7 +79,8 @@ struct ItemComponent : public Component if (item.isSectionHeader) customComp = new HeaderItemComponent (item.text); - addAndMakeVisible (customComp); + if (customComp != nullptr) + addAndMakeVisible (*customComp); parent.addAndMakeVisible (this); @@ -95,7 +96,7 @@ struct ItemComponent : public Component ~ItemComponent() { - removeChildComponent (customComp); + removeChildComponent (customComp.get()); } void getIdealSize (int& idealWidth, int& idealHeight, const int standardItemHeight) @@ -1853,7 +1854,9 @@ bool PopupMenu::MenuItemIterator::next() menus.add (currentItem->subMenu.get()); } else + { index.setUnchecked (index.size() - 1, index.getLast() + 1); + } while (index.size() > 0 && index.getLast() >= menus.getLast()->items.size()) { diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp index f68fb96912..29d1ec4cc8 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp @@ -1008,8 +1008,8 @@ ReferenceCountedObject* OpenGLContext::getAssociatedObject (const char* name) co jassert (c != nullptr && nativeContext != nullptr); jassert (getCurrentContext() != nullptr); - const int index = c->associatedObjectNames.indexOf (name); - return index >= 0 ? c->associatedObjects.getUnchecked (index) : nullptr; + auto index = c->associatedObjectNames.indexOf (name); + return index >= 0 ? c->associatedObjects.getUnchecked (index).get() : nullptr; } void OpenGLContext::setAssociatedObject (const char* name, ReferenceCountedObject* newObject) diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index 4d49340a86..6d59968305 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -1298,7 +1298,7 @@ struct StateHelpers if (programs == nullptr) { programs = new ShaderPrograms (context); - context.setAssociatedObject (programValueID, programs); + context.setAssociatedObject (programValueID, programs.get()); } } @@ -1430,7 +1430,7 @@ struct GLState auto p3 = Point (g.point1.x + (g.point2.y - g.point1.y), g.point1.y - (g.point2.x - g.point1.x)).transformedBy (t); - ShaderPrograms* const programs = currentShader.programs; + auto programs = currentShader.programs; const ShaderPrograms::MaskedShaderParams* maskParams = nullptr; if (g.isRadial) @@ -1507,7 +1507,7 @@ struct GLState { blendMode.setPremultipliedBlendingMode (shaderQuadQueue); - ShaderPrograms* const programs = currentShader.programs; + auto programs = currentShader.programs; const ShaderPrograms::MaskedShaderParams* maskParams = nullptr; const ShaderPrograms::ImageParams* imageParams; @@ -1842,18 +1842,18 @@ struct CustomProgram : public ReferenceCountedObject, { } - static CustomProgram* get (const String& hashName) + static ReferenceCountedObjectPtr get (const String& hashName) { if (auto* c = OpenGLContext::getCurrentContext()) return static_cast (c->getAssociatedObject (hashName.toRawUTF8())); - return nullptr; + return {}; } - static CustomProgram* getOrCreate (LowLevelGraphicsContext& gc, const String& hashName, - const String& code, String& errorMessage) + static ReferenceCountedObjectPtr getOrCreate (LowLevelGraphicsContext& gc, const String& hashName, + const String& code, String& errorMessage) { - if (auto* c = get (hashName)) + if (auto c = get (hashName)) return c; if (auto* sc = dynamic_cast (&gc)) @@ -1865,7 +1865,7 @@ struct CustomProgram : public ReferenceCountedObject, { if (auto context = OpenGLContext::getCurrentContext()) { - context->setAssociatedObject (hashName.toRawUTF8(), c); + context->setAssociatedObject (hashName.toRawUTF8(), c.get()); return c; } }