diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h index 50334f87a4..e8d0e0ac76 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h @@ -1284,8 +1284,8 @@ protected: String getProjectType() const { if (projectType.isGUIApplication() || projectType.isCommandLineApp()) return "Application"; - else if (isLibraryDLL()) return "DynamicLibrary"; - else if (projectType.isLibrary()) return "StaticLibrary"; + if (isLibraryDLL()) return "DynamicLibrary"; + if (projectType.isLibrary()) return "StaticLibrary"; jassertfalse; return String::empty; diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h index 388283ee8c..b312aa8acb 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h @@ -65,10 +65,8 @@ public: static XCodeProjectExporter* createForSettings (Project& project, const ValueTree& settings) { - if (settings.hasType (getValueTreeTypeName (false))) - return new XCodeProjectExporter (project, settings, false); - else if (settings.hasType (getValueTreeTypeName (true))) - return new XCodeProjectExporter (project, settings, true); + if (settings.hasType (getValueTreeTypeName (false))) return new XCodeProjectExporter (project, settings, false); + if (settings.hasType (getValueTreeTypeName (true))) return new XCodeProjectExporter (project, settings, true); return nullptr; } @@ -981,21 +979,21 @@ public: private: static String getFileType (const RelativePath& file) { - if (file.hasFileExtension ("cpp;cc;cxx")) return "sourcecode.cpp.cpp"; - else if (file.hasFileExtension (".mm")) return "sourcecode.cpp.objcpp"; - else if (file.hasFileExtension (".m")) return "sourcecode.c.objc"; - else if (file.hasFileExtension (headerFileExtensions)) return "sourcecode.c.h"; - else if (file.hasFileExtension (".framework")) return "wrapper.framework"; - else if (file.hasFileExtension (".jpeg;.jpg")) return "image.jpeg"; - else if (file.hasFileExtension ("png;gif")) return "image" + file.getFileExtension(); - else if (file.hasFileExtension ("html;htm")) return "text.html"; - else if (file.hasFileExtension ("xml;zip;wav")) return "file" + file.getFileExtension(); - else if (file.hasFileExtension ("txt;rtf")) return "text" + file.getFileExtension(); - else if (file.hasFileExtension ("plist")) return "text.plist.xml"; - else if (file.hasFileExtension ("app")) return "wrapper.application"; - else if (file.hasFileExtension ("component;vst;plugin")) return "wrapper.cfbundle"; - else if (file.hasFileExtension ("xcodeproj")) return "wrapper.pb-project"; - else if (file.hasFileExtension ("a")) return "archive.ar"; + if (file.hasFileExtension ("cpp;cc;cxx")) return "sourcecode.cpp.cpp"; + if (file.hasFileExtension (".mm")) return "sourcecode.cpp.objcpp"; + if (file.hasFileExtension (".m")) return "sourcecode.c.objc"; + if (file.hasFileExtension (headerFileExtensions)) return "sourcecode.c.h"; + if (file.hasFileExtension (".framework")) return "wrapper.framework"; + if (file.hasFileExtension (".jpeg;.jpg")) return "image.jpeg"; + if (file.hasFileExtension ("png;gif")) return "image" + file.getFileExtension(); + if (file.hasFileExtension ("html;htm")) return "text.html"; + if (file.hasFileExtension ("xml;zip;wav")) return "file" + file.getFileExtension(); + if (file.hasFileExtension ("txt;rtf")) return "text" + file.getFileExtension(); + if (file.hasFileExtension ("plist")) return "text.plist.xml"; + if (file.hasFileExtension ("app")) return "wrapper.application"; + if (file.hasFileExtension ("component;vst;plugin")) return "wrapper.cfbundle"; + if (file.hasFileExtension ("xcodeproj")) return "wrapper.pb-project"; + if (file.hasFileExtension ("a")) return "archive.ar"; return "file" + file.getFileExtension(); } diff --git a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp index ef23024f66..2eb9df4748 100644 --- a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp +++ b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp @@ -286,16 +286,16 @@ void Synthesiser::noteOff (const int midiChannel, if (voice->getCurrentlyPlayingNote() == midiNoteNumber) { - SynthesiserSound* const sound = voice->getCurrentlyPlayingSound(); - - if (sound != nullptr - && sound->appliesToNote (midiNoteNumber) - && sound->appliesToChannel (midiChannel)) + if (SynthesiserSound* const sound = voice->getCurrentlyPlayingSound()) { - voice->keyIsDown = false; - - if (! (sustainPedalsDown [midiChannel] || voice->sostenutoPedalDown)) - stopVoice (voice, allowTailOff); + if (sound->appliesToNote (midiNoteNumber) + && sound->appliesToChannel (midiChannel)) + { + voice->keyIsDown = false; + + if (! (sustainPedalsDown [midiChannel] || voice->sostenutoPedalDown)) + stopVoice (voice, allowTailOff); + } } } } diff --git a/modules/juce_audio_devices/native/juce_mac_AudioCDBurner.mm b/modules/juce_audio_devices/native/juce_mac_AudioCDBurner.mm index 5233f9b9af..cc5b1c7655 100644 --- a/modules/juce_audio_devices/native/juce_mac_AudioCDBurner.mm +++ b/modules/juce_audio_devices/native/juce_mac_AudioCDBurner.mm @@ -93,9 +93,7 @@ private: static BOOL prepareTrack (id self, SEL, DRTrack*, DRBurn*, NSDictionary*) { - AudioSourceHolder* const source = getSource (self); - - if (source != nullptr) + if (AudioSourceHolder* const source = getSource (self)) { source->source->prepareToPlay (44100 / 75, 44100); source->readPosition = 0; @@ -106,9 +104,7 @@ private: static BOOL prepareTrackForVerification (id self, SEL, DRTrack*) { - AudioSourceHolder* const source = getSource (self); - - if (source != nullptr) + if (AudioSourceHolder* const source = getSource (self)) source->source->prepareToPlay (44100 / 75, 44100); return true; @@ -118,9 +114,7 @@ private: uint32_t bufferLength, uint64_t /*address*/, uint32_t /*blockSize*/, uint32_t* /*flags*/) { - AudioSourceHolder* const source = getSource (self); - - if (source != nullptr) + if (AudioSourceHolder* const source = getSource (self)) { const int numSamples = jmin ((int) bufferLength / 4, (source->lengthInFrames * (44100 / 75)) - source->readPosition); diff --git a/modules/juce_audio_devices/native/juce_mac_AudioCDReader.mm b/modules/juce_audio_devices/native/juce_mac_AudioCDReader.mm index 0e0a8cef75..702e23c6f0 100644 --- a/modules/juce_audio_devices/native/juce_mac_AudioCDReader.mm +++ b/modules/juce_audio_devices/native/juce_mac_AudioCDReader.mm @@ -199,9 +199,7 @@ bool AudioCDReader::readSamples (int** destSamples, int numDestChannels, int sta { reader = nullptr; - FileInputStream* const in = tracks [track].createInputStream(); - - if (in != nullptr) + if (FileInputStream* const in = tracks [track].createInputStream()) { BufferedInputStream* const bin = new BufferedInputStream (in, 65536, true); diff --git a/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp b/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp index e88dfd8c58..f0c1bd6504 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp @@ -432,9 +432,7 @@ MidiInput* MidiInput::openDevice (int index, MidiInputCallback* callback) if (CHECK_ERROR (MIDIObjectGetStringProperty (endPoint, kMIDIPropertyName, &name))) { - MIDIClientRef client = getGlobalMidiClient(); - - if (client != 0) + if (MIDIClientRef client = getGlobalMidiClient()) { MIDIPortRef port; ScopedPointer mpc (new MidiPortAndCallback (*callback)); @@ -473,9 +471,8 @@ MidiInput* MidiInput::createNewDevice (const String& deviceName, MidiInputCallba using namespace CoreMidiHelpers; MidiInput* mi = nullptr; - MIDIClientRef client = getGlobalMidiClient(); - if (client != 0) + if (MIDIClientRef client = getGlobalMidiClient()) { ScopedPointer mpc (new MidiPortAndCallback (*callback)); mpc->active = false; diff --git a/modules/juce_audio_formats/sampler/juce_Sampler.cpp b/modules/juce_audio_formats/sampler/juce_Sampler.cpp index 7e12f9bac7..8b942a1a70 100644 --- a/modules/juce_audio_formats/sampler/juce_Sampler.cpp +++ b/modules/juce_audio_formats/sampler/juce_Sampler.cpp @@ -96,10 +96,7 @@ void SamplerVoice::startNote (const int midiNoteNumber, SynthesiserSound* s, const int /*currentPitchWheelPosition*/) { - const SamplerSound* const sound = dynamic_cast (s); - jassert (sound != nullptr); // this object can only play SamplerSounds! - - if (sound != nullptr) + if (const SamplerSound* const sound = dynamic_cast (s)) { pitchRatio = pow (2.0, (midiNoteNumber - sound->midiRootNote) / 12.0) * sound->sourceSampleRate / getSampleRate(); @@ -127,6 +124,10 @@ void SamplerVoice::startNote (const int midiNoteNumber, else releaseDelta = 0.0f; } + else + { + jassertfalse; // this object can only play SamplerSounds! + } } void SamplerVoice::stopNote (const bool allowTailOff) diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp index 1fee618d8b..d7bf3dd342 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp @@ -857,14 +857,14 @@ struct ConnectionSorter static int compareElements (const AudioProcessorGraph::Connection* const first, const AudioProcessorGraph::Connection* const second) noexcept { - if (first->sourceNodeId < second->sourceNodeId) return -1; - else if (first->sourceNodeId > second->sourceNodeId) return 1; - else if (first->destNodeId < second->destNodeId) return -1; - else if (first->destNodeId > second->destNodeId) return 1; - else if (first->sourceChannelIndex < second->sourceChannelIndex) return -1; - else if (first->sourceChannelIndex > second->sourceChannelIndex) return 1; - else if (first->destChannelIndex < second->destChannelIndex) return -1; - else if (first->destChannelIndex > second->destChannelIndex) return 1; + if (first->sourceNodeId < second->sourceNodeId) return -1; + if (first->sourceNodeId > second->sourceNodeId) return 1; + if (first->destNodeId < second->destNodeId) return -1; + if (first->destNodeId > second->destNodeId) return 1; + if (first->sourceChannelIndex < second->sourceChannelIndex) return -1; + if (first->sourceChannelIndex > second->sourceChannelIndex) return 1; + if (first->destChannelIndex < second->destChannelIndex) return -1; + if (first->destChannelIndex > second->destChannelIndex) return 1; return 0; } diff --git a/modules/juce_core/containers/juce_ReferenceCountedArray.h b/modules/juce_core/containers/juce_ReferenceCountedArray.h index c05a1f7eb8..209851156b 100644 --- a/modules/juce_core/containers/juce_ReferenceCountedArray.h +++ b/modules/juce_core/containers/juce_ReferenceCountedArray.h @@ -69,8 +69,8 @@ public: memcpy (data.elements, other.getRawDataPointer(), numUsed * sizeof (ObjectClass*)); for (int i = numUsed; --i >= 0;) - if (data.elements[i] != nullptr) - data.elements[i]->incReferenceCount(); + if (ObjectClass* o = data.elements[i]) + o->incReferenceCount(); } /** Creates a copy of another array */ @@ -83,8 +83,8 @@ public: memcpy (data.elements, other.getRawDataPointer(), numUsed * sizeof (ObjectClass*)); for (int i = numUsed; --i >= 0;) - if (data.elements[i] != nullptr) - data.elements[i]->incReferenceCount(); + if (ObjectClass* o = data.elements[i]) + o->incReferenceCount(); } /** Copies another array into this one. @@ -126,8 +126,8 @@ public: const ScopedLockType lock (getLock()); while (numUsed > 0) - if (data.elements [--numUsed] != nullptr) - data.elements [numUsed]->decReferenceCount(); + if (ObjectClass* o = data.elements [--numUsed]) + o->decReferenceCount(); jassert (numUsed == 0); data.setAllocatedSize (0); @@ -382,8 +382,8 @@ public: if (indexToChange < numUsed) { - if (data.elements [indexToChange] != nullptr) - data.elements [indexToChange]->decReferenceCount(); + if (ObjectClass* o = data.elements [indexToChange]) + o->decReferenceCount(); data.elements [indexToChange] = newObject; } @@ -531,8 +531,8 @@ public: { ObjectClass** const e = data.elements + indexToRemove; - if (*e != nullptr) - (*e)->decReferenceCount(); + if (ObjectClass* o = *e) + o->decReferenceCount(); --numUsed; const int numberToShift = numUsed - indexToRemove; @@ -563,10 +563,10 @@ public: { ObjectClass** const e = data.elements + indexToRemove; - if (*e != nullptr) + if (ObjectClass* o = *e) { - removedItem = *e; - (*e)->decReferenceCount(); + removedItem = o; + o->decReferenceCount(); } --numUsed; @@ -624,9 +624,9 @@ public: int i; for (i = start; i < endIndex; ++i) { - if (data.elements[i] != nullptr) + if (ObjectClass* o = data.elements[i]) { - data.elements[i]->decReferenceCount(); + o->decReferenceCount(); data.elements[i] = nullptr; // (in case one of the destructors accesses this array and hits a dangling pointer) } } diff --git a/modules/juce_core/maths/juce_Expression.cpp b/modules/juce_core/maths/juce_Expression.cpp index 9f635f0b88..b128da8edb 100644 --- a/modules/juce_core/maths/juce_Expression.cpp +++ b/modules/juce_core/maths/juce_Expression.cpp @@ -877,7 +877,8 @@ struct Expression::Helpers throw ParseError ("Expected \")\""); } - else if (readOperator (".")) + + if (readOperator (".")) { TermPtr rhs (readSymbolOrFunction()); @@ -889,11 +890,10 @@ struct Expression::Helpers return new DotOperator (new SymbolTerm (identifier), rhs); } - else // just a symbol.. - { - jassert (identifier.trim() == identifier); - return new SymbolTerm (identifier); - } + + // just a symbol.. + jassert (identifier.trim() == identifier); + return new SymbolTerm (identifier); } return TermPtr(); @@ -1146,7 +1146,8 @@ double Expression::Scope::evaluateFunction (const String& functionName, const do return v; } - else if (functionName == "max") + + if (functionName == "max") { double v = parameters[0]; for (int i = 1; i < numParams; ++i) @@ -1154,12 +1155,13 @@ double Expression::Scope::evaluateFunction (const String& functionName, const do return v; } - else if (numParams == 1) + + if (numParams == 1) { - if (functionName == "sin") return sin (parameters[0]); - else if (functionName == "cos") return cos (parameters[0]); - else if (functionName == "tan") return tan (parameters[0]); - else if (functionName == "abs") return std::abs (parameters[0]); + if (functionName == "sin") return sin (parameters[0]); + if (functionName == "cos") return cos (parameters[0]); + if (functionName == "tan") return tan (parameters[0]); + if (functionName == "abs") return std::abs (parameters[0]); } } diff --git a/modules/juce_core/text/juce_String.cpp b/modules/juce_core/text/juce_String.cpp index 9fd5e88d5f..14f2acb722 100644 --- a/modules/juce_core/text/juce_String.cpp +++ b/modules/juce_core/text/juce_String.cpp @@ -2070,10 +2070,9 @@ String String::fromUTF8 (const char* const buffer, int bufferSizeBytes) { if (buffer != nullptr) { - if (bufferSizeBytes < 0) - return String (CharPointer_UTF8 (buffer)); - else if (bufferSizeBytes > 0) - return String (CharPointer_UTF8 (buffer), CharPointer_UTF8 (buffer + bufferSizeBytes)); + if (bufferSizeBytes < 0) return String (CharPointer_UTF8 (buffer)); + if (bufferSizeBytes > 0) return String (CharPointer_UTF8 (buffer), + CharPointer_UTF8 (buffer + bufferSizeBytes)); } return String::empty; diff --git a/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp b/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp index fdc68b8cc3..5a7a7d00d0 100644 --- a/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp +++ b/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp @@ -223,9 +223,7 @@ bool PropertiesFile::saveAsXml() e->setAttribute (PropertyFileConstants::nameAttribute, getAllProperties().getAllKeys() [i]); // if the value seems to contain xml, store it as such.. - XmlElement* const childElement = XmlDocument::parse (getAllProperties().getAllValues() [i]); - - if (childElement != nullptr) + if (XmlElement* const childElement = XmlDocument::parse (getAllProperties().getAllValues() [i])) e->addChildElement (childElement); else e->setAttribute (PropertyFileConstants::valueAttribute, diff --git a/modules/juce_graphics/fonts/juce_CustomTypeface.cpp b/modules/juce_graphics/fonts/juce_CustomTypeface.cpp index c75332268e..5818881b50 100644 --- a/modules/juce_graphics/fonts/juce_CustomTypeface.cpp +++ b/modules/juce_graphics/fonts/juce_CustomTypeface.cpp @@ -194,11 +194,10 @@ void CustomTypeface::addKerningPair (const juce_wchar char1, const juce_wchar ch { if (extraAmount != 0) { - GlyphInfo* const g = findGlyph (char1, true); - jassert (g != nullptr); // can only add kerning pairs for characters that exist! - - if (g != nullptr) + if (GlyphInfo* const g = findGlyph (char1, true)) g->addKerningPair (char2, extraAmount); + else + jassertfalse; // can only add kerning pairs for characters that exist! } } diff --git a/modules/juce_graphics/native/juce_RenderingHelpers.h b/modules/juce_graphics/native/juce_RenderingHelpers.h index 6a9f41683d..e3a0383be4 100644 --- a/modules/juce_graphics/native/juce_RenderingHelpers.h +++ b/modules/juce_graphics/native/juce_RenderingHelpers.h @@ -2171,8 +2171,8 @@ public: { if (transform.isOnlyTranslated) return clip->clipRegionIntersects (transform.translated (r)); - else - return getClipBounds().intersects (r); + + return getClipBounds().intersects (r); } return false; diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp index 6e74967a7f..166b7ef1a1 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp @@ -125,17 +125,19 @@ const ApplicationCommandInfo* ApplicationCommandManager::getCommandForID (const String ApplicationCommandManager::getNameOfCommand (const CommandID commandID) const noexcept { - const ApplicationCommandInfo* const ci = getCommandForID (commandID); + if (const ApplicationCommandInfo* const ci = getCommandForID (commandID)) + return ci->shortName; - return ci != nullptr ? ci->shortName : String::empty; + return String::empty; } String ApplicationCommandManager::getDescriptionOfCommand (const CommandID commandID) const noexcept { - const ApplicationCommandInfo* const ci = getCommandForID (commandID); + if (const ApplicationCommandInfo* const ci = getCommandForID (commandID)) + return ci->description.isNotEmpty() ? ci->description + : ci->shortName; - return ci != nullptr ? (ci->description.isNotEmpty() ? ci->description : ci->shortName) - : String::empty; + return String::empty; } StringArray ApplicationCommandManager::getCommandCategories() const diff --git a/modules/juce_gui_basics/components/juce_Desktop.cpp b/modules/juce_gui_basics/components/juce_Desktop.cpp index 8cd4f296ea..b8058c8bad 100644 --- a/modules/juce_gui_basics/components/juce_Desktop.cpp +++ b/modules/juce_gui_basics/components/juce_Desktop.cpp @@ -101,12 +101,8 @@ void Desktop::setDefaultLookAndFeel (LookAndFeel* newDefaultLookAndFeel) currentLookAndFeel = newDefaultLookAndFeel; for (int i = getNumComponents(); --i >= 0;) - { - Component* const c = getComponent (i); - - if (c != nullptr) + if (Component* const c = getComponent (i)) c->sendLookAndFeelChange(); - } } //============================================================================== @@ -304,9 +300,7 @@ void Desktop::sendMouseMove() lastFakeMouseMove = getMousePosition(); - Component* const target = findComponentAt (lastFakeMouseMove); - - if (target != nullptr) + if (Component* const target = findComponentAt (lastFakeMouseMove)) { Component::BailOutChecker checker (target); const Point pos (target->getLocalPoint (nullptr, lastFakeMouseMove)); @@ -405,11 +399,8 @@ void Desktop::Displays::refresh() if (oldDisplays != displays) { for (int i = ComponentPeer::getNumPeers(); --i >= 0;) - { - ComponentPeer* const p = ComponentPeer::getPeer (i); - if (p != nullptr) - p->handleScreenSizeChange(); - } + if (ComponentPeer* const peer = ComponentPeer::getPeer (i)) + peer->handleScreenSizeChange(); } } diff --git a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp index 8b0adc8f46..c7e28d9f36 100644 --- a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp @@ -125,9 +125,8 @@ bool DirectoryContentsList::getFileInfo (const int index, FileInfo& result) const { const ScopedLock sl (fileListLock); - const FileInfo* const info = files [index]; - if (info != nullptr) + if (const FileInfo* const info = files [index]) { result = *info; return true; @@ -139,9 +138,8 @@ bool DirectoryContentsList::getFileInfo (const int index, File DirectoryContentsList::getFile (const int index) const { const ScopedLock sl (fileListLock); - const FileInfo* const info = files [index]; - if (info != nullptr) + if (const FileInfo* const info = files [index]) return root.getChildFile (info->filename); return File::nonexistent; diff --git a/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp b/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp index c48181d229..9ef37913ae 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp @@ -52,12 +52,8 @@ namespace ComponentBuilderHelpers return &c; for (int i = c.getNumChildComponents(); --i >= 0;) - { - Component* const child = findComponentWithID (*c.getChildComponent (i), compId); - - if (child != nullptr) + if (Component* const child = findComponentWithID (*c.getChildComponent (i), compId)) return child; - } return nullptr; } @@ -73,9 +69,7 @@ namespace ComponentBuilderHelpers static void updateComponent (ComponentBuilder& builder, const ValueTree& state) { - Component* topLevelComp = builder.getManagedComponent(); - - if (topLevelComp != nullptr) + if (Component* topLevelComp = builder.getManagedComponent()) { ComponentBuilder::TypeHandler* const type = builder.getHandlerForState (state); const String uid (getStateId (state)); @@ -88,9 +82,7 @@ namespace ComponentBuilderHelpers } else { - Component* const changedComp = findComponentWithID (*topLevelComp, uid); - - if (changedComp != nullptr) + if (Component* const changedComp = findComponentWithID (*topLevelComp, uid)) type->updateComponentFromState (changedComp, state); } } @@ -264,11 +256,10 @@ void ComponentBuilder::updateChildComponents (Component& parent, const ValueTree if (c == nullptr) { - TypeHandler* const type = getHandlerForState (childState); - jassert (type != nullptr); - - if (type != nullptr) + if (TypeHandler* const type = getHandlerForState (childState)) c = ComponentBuilderHelpers::createNewComponent (*type, childState, &parent); + else + jassertfalse; } if (c != nullptr) diff --git a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp index 2a10860bb2..49d90bc982 100644 --- a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp +++ b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp @@ -410,12 +410,12 @@ bool ScrollBar::keyPressed (const KeyPress& key) { if (isVisible()) { - if (key == KeyPress::upKey || key == KeyPress::leftKey) return moveScrollbarInSteps (-1); - else if (key == KeyPress::downKey || key == KeyPress::rightKey) return moveScrollbarInSteps (1); - else if (key == KeyPress::pageUpKey) return moveScrollbarInPages (-1); - else if (key == KeyPress::pageDownKey) return moveScrollbarInPages (1); - else if (key == KeyPress::homeKey) return scrollToTop(); - else if (key == KeyPress::endKey) return scrollToBottom(); + if (key == KeyPress::upKey || key == KeyPress::leftKey) return moveScrollbarInSteps (-1); + if (key == KeyPress::downKey || key == KeyPress::rightKey) return moveScrollbarInSteps (1); + if (key == KeyPress::pageUpKey) return moveScrollbarInPages (-1); + if (key == KeyPress::pageDownKey) return moveScrollbarInPages (1); + if (key == KeyPress::homeKey) return scrollToTop(); + if (key == KeyPress::endKey) return scrollToBottom(); } return false; diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp index 0c5c8c8598..9fdb4f06e0 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp @@ -2045,9 +2045,7 @@ int LookAndFeel::getTabButtonBestWidth (TabBarButton& button, int tabDepth) int width = Font (tabDepth * 0.6f).getStringWidth (button.getButtonText().trim()) + getTabButtonOverlap (tabDepth) * 2; - Component* const extraComponent = button.getExtraComponent(); - - if (extraComponent != nullptr) + if (Component* const extraComponent = button.getExtraComponent()) width += button.getTabbedButtonBar().isVertical() ? extraComponent->getHeight() : extraComponent->getWidth(); @@ -2526,10 +2524,8 @@ void LookAndFeel::drawFileBrowserRow (Graphics& g, int width, int height, } else { - const Drawable* d = isDirectory ? getDefaultFolderImage() - : getDefaultDocumentFileImage(); - - if (d != nullptr) + if (const Drawable* d = isDirectory ? getDefaultFolderImage() + : getDefaultDocumentFileImage()) d->drawWithin (g, Rectangle (2.0f, 2.0f, x - 4.0f, height - 4.0f), RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f); } diff --git a/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp b/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp index 94a55337b2..f3a5a44b40 100644 --- a/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp +++ b/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp @@ -54,8 +54,8 @@ void BubbleComponent::setPosition (Component* componentToPointTo) { jassert (componentToPointTo != nullptr); - if (getParentComponent() != nullptr) - setPosition (getParentComponent()->getLocalArea (componentToPointTo, componentToPointTo->getLocalBounds())); + if (Component* p = getParentComponent()) + setPosition (p->getLocalArea (componentToPointTo, componentToPointTo->getLocalBounds())); else setPosition (componentToPointTo->getScreenBounds()); } diff --git a/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp b/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp index 41204d8e47..8c155abf9d 100644 --- a/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp +++ b/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp @@ -67,10 +67,9 @@ public: { mouseDragSource->removeMouseListener (this); - DragAndDropTarget* const current = getCurrentlyOver(); - - if (current != nullptr && current->isInterestedInDragSource (sourceDetails)) - current->itemDragExit (sourceDetails); + if (DragAndDropTarget* const current = getCurrentlyOver()) + if (current->isInterestedInDragSource (sourceDetails)) + current->itemDragExit (sourceDetails); } } @@ -103,8 +102,8 @@ public: if (wasVisible) // fade the component and remove it - it'll be deleted later by the timer callback dismissWithAnimation (finalTarget == nullptr); - if (getParentComponent() != nullptr) - getParentComponent()->removeChildComponent (this); + if (Component* parent = getParentComponent()) + parent->removeChildComponent (this); if (finalTarget != nullptr) { @@ -135,11 +134,9 @@ public: if (newTargetComp != currentlyOverComp) { - DragAndDropTarget* const lastTarget = getCurrentlyOver(); - - if (lastTarget != nullptr && details.sourceComponent != nullptr - && lastTarget->isInterestedInDragSource (details)) - lastTarget->itemDragExit (details); + if (DragAndDropTarget* const lastTarget = getCurrentlyOver()) + if (details.sourceComponent != nullptr && lastTarget->isInterestedInDragSource (details)) + lastTarget->itemDragExit (details); currentlyOverComp = newTargetComp; @@ -206,13 +203,14 @@ private: while (hit != nullptr) { - DragAndDropTarget* const ddt = dynamic_cast (hit); - - if (ddt != nullptr && ddt->isInterestedInDragSource (details)) + if (DragAndDropTarget* const ddt = dynamic_cast (hit)) { - relativePos = hit->getLocalPoint (nullptr, screenPos); - resultComponent = hit; - return ddt; + if (ddt->isInterestedInDragSource (details)) + { + relativePos = hit->getLocalPoint (nullptr, screenPos); + resultComponent = hit; + return ddt; + } } hit = hit->getParentComponent(); @@ -226,18 +224,17 @@ private: { Point newPos (screenPos - imageOffset); - if (getParentComponent() != nullptr) - newPos = getParentComponent()->getLocalPoint (nullptr, newPos); + if (Component* p = getParentComponent()) + newPos = p->getLocalPoint (nullptr, newPos); setTopLeftPosition (newPos); } void sendDragMove (DragAndDropTarget::SourceDetails& details) const { - DragAndDropTarget* const target = getCurrentlyOver(); - - if (target != nullptr && target->isInterestedInDragSource (details)) - target->itemDragMove (details); + if (DragAndDropTarget* const target = getCurrentlyOver()) + if (target->isInterestedInDragSource (details)) + target->itemDragMove (details); } struct ExternalDragAndDropMessage : public CallbackMessage diff --git a/modules/juce_gui_basics/native/juce_mac_FileChooser.mm b/modules/juce_gui_basics/native/juce_mac_FileChooser.mm index 002cad56ca..1483291260 100644 --- a/modules/juce_gui_basics/native/juce_mac_FileChooser.mm +++ b/modules/juce_gui_basics/native/juce_mac_FileChooser.mm @@ -91,8 +91,7 @@ public: TemporaryMainMenuWithStandardCommands() : oldMenu (MenuBarModel::getMacMainMenu()), oldAppleMenu (nullptr) { - const PopupMenu* appleMenu = MenuBarModel::getMacExtraAppleItemsMenu(); - if (appleMenu != nullptr) + if (const PopupMenu* appleMenu = MenuBarModel::getMacExtraAppleItemsMenu()) oldAppleMenu = new PopupMenu (*appleMenu); MenuBarModel::setMacMainMenu (nullptr); diff --git a/modules/juce_gui_basics/positioning/juce_MarkerList.cpp b/modules/juce_gui_basics/positioning/juce_MarkerList.cpp index a62e99d279..d8b5c19f14 100644 --- a/modules/juce_gui_basics/positioning/juce_MarkerList.cpp +++ b/modules/juce_gui_basics/positioning/juce_MarkerList.cpp @@ -245,15 +245,11 @@ void MarkerList::ValueTreeWrapper::removeMarker (const ValueTree& marker, UndoMa double MarkerList::getMarkerPosition (const Marker& marker, Component* parentComponent) const { - if (parentComponent != nullptr) - { - RelativeCoordinatePositionerBase::ComponentScope scope (*parentComponent); - return marker.position.resolve (&scope); - } - else - { + if (parentComponent == nullptr) return marker.position.resolve (nullptr); - } + + RelativeCoordinatePositionerBase::ComponentScope scope (*parentComponent); + return marker.position.resolve (&scope); } //============================================================================== diff --git a/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp b/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp index a452bcd525..ea3cb965b3 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp @@ -116,8 +116,8 @@ double RelativeCoordinate::resolve (const Expression::Scope* scope) const { if (scope != nullptr) return term.evaluate (*scope); - else - return term.evaluate(); + + return term.evaluate(); } catch (Expression::ParseError&) {} diff --git a/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp b/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp index b7ade41785..8f7e83ab4d 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp @@ -38,9 +38,8 @@ public: } MarkerList* list; - const MarkerList::Marker* const marker = findMarker (component, symbol, list); - if (marker != nullptr) + if (const MarkerList::Marker* const marker = findMarker (component, symbol, list)) return Expression (marker->position.getExpression().evaluate (*this)); return Expression::Scope::getSymbolValue (symbol); @@ -50,9 +49,7 @@ public: { if (scopeName == RelativeCoordinate::Strings::parent) { - Component* const parent = component.getParentComponent(); - - if (parent != nullptr) + if (Component* const parent = component.getParentComponent()) { visitor.visit (MarkerListScope (*parent)); return; @@ -113,14 +110,11 @@ Expression RelativeCoordinatePositionerBase::ComponentScope::getSymbolValue (con default: break; } - Component* const parent = component.getParentComponent(); - - if (parent != nullptr) + if (Component* const parent = component.getParentComponent()) { MarkerList* list; - const MarkerList::Marker* const marker = MarkerListScope::findMarker (*parent, symbol, list); - if (marker != nullptr) + if (const MarkerList::Marker* const marker = MarkerListScope::findMarker (*parent, symbol, list)) { MarkerListScope scope (*parent); return Expression (marker->position.getExpression().evaluate (scope)); @@ -132,11 +126,9 @@ Expression RelativeCoordinatePositionerBase::ComponentScope::getSymbolValue (con void RelativeCoordinatePositionerBase::ComponentScope::visitRelativeScope (const String& scopeName, Visitor& visitor) const { - Component* const targetComp = (scopeName == RelativeCoordinate::Strings::parent) - ? component.getParentComponent() - : findSiblingComponent (scopeName); - - if (targetComp != nullptr) + if (Component* const targetComp = (scopeName == RelativeCoordinate::Strings::parent) + ? component.getParentComponent() + : findSiblingComponent (scopeName)) visitor.visit (ComponentScope (*targetComp)); else Expression::Scope::visitRelativeScope (scopeName, visitor); @@ -149,10 +141,10 @@ String RelativeCoordinatePositionerBase::ComponentScope::getScopeUID() const Component* RelativeCoordinatePositionerBase::ComponentScope::findSiblingComponent (const String& componentID) const { - Component* const parent = component.getParentComponent(); + if (Component* const parent = component.getParentComponent()) + return parent->findChildWithID (componentID); - return parent != nullptr ? parent->findChildWithID (componentID) - : nullptr; + return nullptr; } //============================================================================== @@ -180,14 +172,11 @@ public: break; default: - { - Component* const parent = component.getParentComponent(); - if (parent != nullptr) + if (Component* const parent = component.getParentComponent()) { MarkerList* list; - const MarkerList::Marker* marker = MarkerListScope::findMarker (*parent, symbol, list); - if (marker != nullptr) + if (MarkerListScope::findMarker (*parent, symbol, list) != nullptr) { positioner.registerMarkerListListener (list); } @@ -199,8 +188,7 @@ public: ok = false; } } - } - break; + break; } return ComponentScope::getSymbolValue (symbol); @@ -208,19 +196,16 @@ public: void visitRelativeScope (const String& scopeName, Visitor& visitor) const { - Component* const targetComp = (scopeName == RelativeCoordinate::Strings::parent) - ? component.getParentComponent() - : findSiblingComponent (scopeName); - - if (targetComp != nullptr) + if (Component* const targetComp = (scopeName == RelativeCoordinate::Strings::parent) + ? component.getParentComponent() + : findSiblingComponent (scopeName)) { visitor.visit (DependencyFinderScope (*targetComp, positioner, ok)); } else { // The named component doesn't exist, so we'll watch the parent for changes in case it appears later.. - Component* const parent = component.getParentComponent(); - if (parent != nullptr) + if (Component* const parent = component.getParentComponent()) positioner.registerComponentListener (*parent); positioner.registerComponentListener (component); diff --git a/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp index 1640499c8a..cb1f2a1108 100644 --- a/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp @@ -31,7 +31,6 @@ PropertyComponent::PropertyComponent (const String& name, const int preferredHei PropertyComponent::~PropertyComponent() {} -//============================================================================== void PropertyComponent::paint (Graphics& g) { LookAndFeel& lf = getLookAndFeel(); @@ -42,8 +41,7 @@ void PropertyComponent::paint (Graphics& g) void PropertyComponent::resized() { - Component* const c = getChildComponent(0); - if (c != nullptr) + if (Component* const c = getChildComponent(0)) c->setBounds (getLookAndFeel().getPropertyComponentContentPosition (*this)); } diff --git a/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp b/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp index bf6c799db3..1cbcb29af7 100644 --- a/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp +++ b/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp @@ -87,9 +87,7 @@ public: for (int i = propertyComps.size(); --i >= 0;) propertyComps.getUnchecked(i)->setVisible (open); - PropertyPanel* const pp = findParentComponentOfClass(); - - if (pp != nullptr) + if (PropertyPanel* const pp = findParentComponentOfClass()) pp->resized(); } } diff --git a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp index 0bd88b1b98..bc85ff54f3 100644 --- a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp +++ b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp @@ -87,26 +87,27 @@ int TableHeaderComponent::getNumColumns (const bool onlyCountVisibleColumns) con return num; } - else - { - return columns.size(); - } + + return columns.size(); } String TableHeaderComponent::getColumnName (const int columnId) const { - const ColumnInfo* const ci = getInfoForId (columnId); - return ci != nullptr ? ci->name : String::empty; + if (const ColumnInfo* const ci = getInfoForId (columnId)) + return ci->name; + + return String::empty; } void TableHeaderComponent::setColumnName (const int columnId, const String& newName) { - ColumnInfo* const ci = getInfoForId (columnId); - - if (ci != nullptr && ci->name != newName) + if (ColumnInfo* const ci = getInfoForId (columnId)) { - ci->name = newName; - sendColumnsChanged(); + if (ci->name != newName) + { + ci->name = newName; + sendColumnsChanged(); + } } } @@ -173,8 +174,10 @@ void TableHeaderComponent::moveColumn (const int columnId, int newIndex) int TableHeaderComponent::getColumnWidth (const int columnId) const { - const ColumnInfo* const ci = getInfoForId (columnId); - return ci != nullptr ? ci->width : 0; + if (const ColumnInfo* const ci = getInfoForId (columnId)) + return ci->width; + + return 0; } void TableHeaderComponent::setColumnWidth (const int columnId, const int newWidth) @@ -233,8 +236,10 @@ int TableHeaderComponent::getColumnIdOfIndex (int index, const bool onlyCountVis if (onlyCountVisibleColumns) index = visibleIndexToTotalIndex (index); - const ColumnInfo* const ci = columns [index]; - return (ci != nullptr) ? ci->id : 0; + if (const ColumnInfo* const ci = columns [index]) + return ci->id; + + return 0; } Rectangle TableHeaderComponent::getColumnPosition (const int index) const @@ -355,17 +360,18 @@ void TableHeaderComponent::resizeColumnsToFit (int firstColumnIndex, int targetT void TableHeaderComponent::setColumnVisible (const int columnId, const bool shouldBeVisible) { - ColumnInfo* const ci = getInfoForId (columnId); - - if (ci != nullptr && shouldBeVisible != ci->isVisible()) + if (ColumnInfo* const ci = getInfoForId (columnId)) { - if (shouldBeVisible) - ci->propertyFlags |= visible; - else - ci->propertyFlags &= ~visible; + if (shouldBeVisible != ci->isVisible()) + { + if (shouldBeVisible) + ci->propertyFlags |= visible; + else + ci->propertyFlags &= ~visible; - sendColumnsChanged(); - resized(); + sendColumnsChanged(); + resized(); + } } } @@ -481,10 +487,9 @@ void TableHeaderComponent::removeListener (Listener* const listenerToRemove) //============================================================================== void TableHeaderComponent::columnClicked (int columnId, const ModifierKeys& mods) { - const ColumnInfo* const ci = getInfoForId (columnId); - - if (ci != nullptr && (ci->propertyFlags & sortable) != 0 && ! mods.isPopupMenu()) - setSortColumnId (columnId, (ci->propertyFlags & sortedForwards) == 0); + if (const ColumnInfo* const ci = getInfoForId (columnId)) + if ((ci->propertyFlags & sortable) != 0 && ! mods.isPopupMenu()) + setSortColumnId (columnId, (ci->propertyFlags & sortedForwards) == 0); } void TableHeaderComponent::addMenuItems (PopupMenu& menu, const int /*columnIdClicked*/) diff --git a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp index 6c4f17a50b..1064927142 100644 --- a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp @@ -210,12 +210,12 @@ void DocumentWindow::paint (Graphics& g) for (int i = 0; i < 3; ++i) { - if (titleBarButtons[i] != nullptr) + if (Button* const b = titleBarButtons[i]) { if (positionTitleBarButtonsOnLeft) - titleSpaceX1 = jmax (titleSpaceX1, titleBarButtons[i]->getRight() + (getWidth() - titleBarButtons[i]->getRight()) / 8); + titleSpaceX1 = jmax (titleSpaceX1, b->getRight() + (getWidth() - b->getRight()) / 8); else - titleSpaceX2 = jmin (titleSpaceX2, titleBarButtons[i]->getX() - (titleBarButtons[i]->getX() / 8)); + titleSpaceX2 = jmin (titleSpaceX2, b->getX() - (b->getX() / 8)); } } @@ -232,8 +232,8 @@ void DocumentWindow::resized() { ResizableWindow::resized(); - if (titleBarButtons[1] != nullptr) - titleBarButtons[1]->setToggleState (isFullScreen(), false); + if (Button* const b = getMaximiseButton()) + b->setToggleState (isFullScreen(), false); const Rectangle titleBarArea (getTitleBarArea()); @@ -311,25 +311,25 @@ void DocumentWindow::lookAndFeelChanged() for (int i = 0; i < 3; ++i) { - if (titleBarButtons[i] != nullptr) + if (Button* const b = titleBarButtons[i]) { if (buttonListener == nullptr) buttonListener = new ButtonListenerProxy (*this); - titleBarButtons[i]->addListener (buttonListener); - titleBarButtons[i]->setWantsKeyboardFocus (false); + b->addListener (buttonListener); + b->setWantsKeyboardFocus (false); // (call the Component method directly to avoid the assertion in ResizableWindow) - Component::addAndMakeVisible (titleBarButtons[i]); + Component::addAndMakeVisible (b); } } - if (getCloseButton() != nullptr) + if (Button* const b = getCloseButton()) { #if JUCE_MAC - getCloseButton()->addShortcut (KeyPress ('w', ModifierKeys::commandModifier, 0)); + b->addShortcut (KeyPress ('w', ModifierKeys::commandModifier, 0)); #else - getCloseButton()->addShortcut (KeyPress (KeyPress::F4Key, ModifierKeys::altModifier, 0)); + b->addShortcut (KeyPress (KeyPress::F4Key, ModifierKeys::altModifier, 0)); #endif } } @@ -349,8 +349,8 @@ void DocumentWindow::activeWindowStatusChanged() ResizableWindow::activeWindowStatusChanged(); for (int i = numElementsInArray (titleBarButtons); --i >= 0;) - if (titleBarButtons[i] != nullptr) - titleBarButtons[i]->setEnabled (isActiveWindow()); + if (Button* const b = titleBarButtons[i]) + b->setEnabled (isActiveWindow()); if (menuBar != nullptr) menuBar->setEnabled (isActiveWindow()); diff --git a/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h b/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h index d6204004c3..20e95316ec 100644 --- a/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h +++ b/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h @@ -160,10 +160,10 @@ public: if (w != getWidth() || h != getHeight()) { startTimer (50); - setSize (w, h); - if (getParentComponent() != nullptr) - getParentComponent()->setSize (w, h); + + if (Component* p = getParentComponent()) + p->setSize (w, h); } else { diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp index a898a6885d..f723f019be 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp @@ -570,16 +570,14 @@ Component* OpenGLContext::getTargetComponent() const noexcept OpenGLContext* OpenGLContext::getCurrentContext() { #if JUCE_ANDROID - NativeContext* const nc = NativeContext::getActiveContext(); - if (nc == nullptr) - return nullptr; - - CachedImage* currentContext = CachedImage::get (nc->component); + if (NativeContext* const nc = NativeContext::getActiveContext()) + if (CachedImage* currentContext = CachedImage::get (nc->component)) #else - CachedImage* currentContext = dynamic_cast (Thread::getCurrentThread()); + if (CachedImage* currentContext = dynamic_cast (Thread::getCurrentThread())) #endif + return ¤tContext->context; - return currentContext != nullptr ? ¤tContext->context : nullptr; + return nullptr; } bool OpenGLContext::makeActive() const noexcept { return nativeContext != nullptr && nativeContext->makeActive(); } @@ -620,8 +618,10 @@ void* OpenGLContext::getRawContext() const noexcept OpenGLContext::CachedImage* OpenGLContext::getCachedImage() const noexcept { - Component* const comp = getTargetComponent(); - return comp != nullptr ? CachedImage::get (*comp) : nullptr; + if (Component* const comp = getTargetComponent()) + return CachedImage::get (*comp); + + return nullptr; } bool OpenGLContext::areShadersAvailable() const