| @@ -1284,8 +1284,8 @@ protected: | |||||
| String getProjectType() const | String getProjectType() const | ||||
| { | { | ||||
| if (projectType.isGUIApplication() || projectType.isCommandLineApp()) return "Application"; | 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; | jassertfalse; | ||||
| return String::empty; | return String::empty; | ||||
| @@ -65,10 +65,8 @@ public: | |||||
| static XCodeProjectExporter* createForSettings (Project& project, const ValueTree& settings) | 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; | return nullptr; | ||||
| } | } | ||||
| @@ -981,21 +979,21 @@ public: | |||||
| private: | private: | ||||
| static String getFileType (const RelativePath& file) | 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(); | return "file" + file.getFileExtension(); | ||||
| } | } | ||||
| @@ -286,16 +286,16 @@ void Synthesiser::noteOff (const int midiChannel, | |||||
| if (voice->getCurrentlyPlayingNote() == midiNoteNumber) | 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); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -93,9 +93,7 @@ private: | |||||
| static BOOL prepareTrack (id self, SEL, DRTrack*, DRBurn*, NSDictionary*) | 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->source->prepareToPlay (44100 / 75, 44100); | ||||
| source->readPosition = 0; | source->readPosition = 0; | ||||
| @@ -106,9 +104,7 @@ private: | |||||
| static BOOL prepareTrackForVerification (id self, SEL, DRTrack*) | 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); | source->source->prepareToPlay (44100 / 75, 44100); | ||||
| return true; | return true; | ||||
| @@ -118,9 +114,7 @@ private: | |||||
| uint32_t bufferLength, uint64_t /*address*/, | uint32_t bufferLength, uint64_t /*address*/, | ||||
| uint32_t /*blockSize*/, uint32_t* /*flags*/) | 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, | const int numSamples = jmin ((int) bufferLength / 4, | ||||
| (source->lengthInFrames * (44100 / 75)) - source->readPosition); | (source->lengthInFrames * (44100 / 75)) - source->readPosition); | ||||
| @@ -199,9 +199,7 @@ bool AudioCDReader::readSamples (int** destSamples, int numDestChannels, int sta | |||||
| { | { | ||||
| reader = nullptr; | 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); | BufferedInputStream* const bin = new BufferedInputStream (in, 65536, true); | ||||
| @@ -432,9 +432,7 @@ MidiInput* MidiInput::openDevice (int index, MidiInputCallback* callback) | |||||
| if (CHECK_ERROR (MIDIObjectGetStringProperty (endPoint, kMIDIPropertyName, &name))) | if (CHECK_ERROR (MIDIObjectGetStringProperty (endPoint, kMIDIPropertyName, &name))) | ||||
| { | { | ||||
| MIDIClientRef client = getGlobalMidiClient(); | |||||
| if (client != 0) | |||||
| if (MIDIClientRef client = getGlobalMidiClient()) | |||||
| { | { | ||||
| MIDIPortRef port; | MIDIPortRef port; | ||||
| ScopedPointer <MidiPortAndCallback> mpc (new MidiPortAndCallback (*callback)); | ScopedPointer <MidiPortAndCallback> mpc (new MidiPortAndCallback (*callback)); | ||||
| @@ -473,9 +471,8 @@ MidiInput* MidiInput::createNewDevice (const String& deviceName, MidiInputCallba | |||||
| using namespace CoreMidiHelpers; | using namespace CoreMidiHelpers; | ||||
| MidiInput* mi = nullptr; | MidiInput* mi = nullptr; | ||||
| MIDIClientRef client = getGlobalMidiClient(); | |||||
| if (client != 0) | |||||
| if (MIDIClientRef client = getGlobalMidiClient()) | |||||
| { | { | ||||
| ScopedPointer <MidiPortAndCallback> mpc (new MidiPortAndCallback (*callback)); | ScopedPointer <MidiPortAndCallback> mpc (new MidiPortAndCallback (*callback)); | ||||
| mpc->active = false; | mpc->active = false; | ||||
| @@ -96,10 +96,7 @@ void SamplerVoice::startNote (const int midiNoteNumber, | |||||
| SynthesiserSound* s, | SynthesiserSound* s, | ||||
| const int /*currentPitchWheelPosition*/) | const int /*currentPitchWheelPosition*/) | ||||
| { | { | ||||
| const SamplerSound* const sound = dynamic_cast <const SamplerSound*> (s); | |||||
| jassert (sound != nullptr); // this object can only play SamplerSounds! | |||||
| if (sound != nullptr) | |||||
| if (const SamplerSound* const sound = dynamic_cast <const SamplerSound*> (s)) | |||||
| { | { | ||||
| pitchRatio = pow (2.0, (midiNoteNumber - sound->midiRootNote) / 12.0) | pitchRatio = pow (2.0, (midiNoteNumber - sound->midiRootNote) / 12.0) | ||||
| * sound->sourceSampleRate / getSampleRate(); | * sound->sourceSampleRate / getSampleRate(); | ||||
| @@ -127,6 +124,10 @@ void SamplerVoice::startNote (const int midiNoteNumber, | |||||
| else | else | ||||
| releaseDelta = 0.0f; | releaseDelta = 0.0f; | ||||
| } | } | ||||
| else | |||||
| { | |||||
| jassertfalse; // this object can only play SamplerSounds! | |||||
| } | |||||
| } | } | ||||
| void SamplerVoice::stopNote (const bool allowTailOff) | void SamplerVoice::stopNote (const bool allowTailOff) | ||||
| @@ -857,14 +857,14 @@ struct ConnectionSorter | |||||
| static int compareElements (const AudioProcessorGraph::Connection* const first, | static int compareElements (const AudioProcessorGraph::Connection* const first, | ||||
| const AudioProcessorGraph::Connection* const second) noexcept | 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; | return 0; | ||||
| } | } | ||||
| @@ -69,8 +69,8 @@ public: | |||||
| memcpy (data.elements, other.getRawDataPointer(), numUsed * sizeof (ObjectClass*)); | memcpy (data.elements, other.getRawDataPointer(), numUsed * sizeof (ObjectClass*)); | ||||
| for (int i = numUsed; --i >= 0;) | 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 */ | /** Creates a copy of another array */ | ||||
| @@ -83,8 +83,8 @@ public: | |||||
| memcpy (data.elements, other.getRawDataPointer(), numUsed * sizeof (ObjectClass*)); | memcpy (data.elements, other.getRawDataPointer(), numUsed * sizeof (ObjectClass*)); | ||||
| for (int i = numUsed; --i >= 0;) | 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. | /** Copies another array into this one. | ||||
| @@ -126,8 +126,8 @@ public: | |||||
| const ScopedLockType lock (getLock()); | const ScopedLockType lock (getLock()); | ||||
| while (numUsed > 0) | while (numUsed > 0) | ||||
| if (data.elements [--numUsed] != nullptr) | |||||
| data.elements [numUsed]->decReferenceCount(); | |||||
| if (ObjectClass* o = data.elements [--numUsed]) | |||||
| o->decReferenceCount(); | |||||
| jassert (numUsed == 0); | jassert (numUsed == 0); | ||||
| data.setAllocatedSize (0); | data.setAllocatedSize (0); | ||||
| @@ -382,8 +382,8 @@ public: | |||||
| if (indexToChange < numUsed) | if (indexToChange < numUsed) | ||||
| { | { | ||||
| if (data.elements [indexToChange] != nullptr) | |||||
| data.elements [indexToChange]->decReferenceCount(); | |||||
| if (ObjectClass* o = data.elements [indexToChange]) | |||||
| o->decReferenceCount(); | |||||
| data.elements [indexToChange] = newObject; | data.elements [indexToChange] = newObject; | ||||
| } | } | ||||
| @@ -531,8 +531,8 @@ public: | |||||
| { | { | ||||
| ObjectClass** const e = data.elements + indexToRemove; | ObjectClass** const e = data.elements + indexToRemove; | ||||
| if (*e != nullptr) | |||||
| (*e)->decReferenceCount(); | |||||
| if (ObjectClass* o = *e) | |||||
| o->decReferenceCount(); | |||||
| --numUsed; | --numUsed; | ||||
| const int numberToShift = numUsed - indexToRemove; | const int numberToShift = numUsed - indexToRemove; | ||||
| @@ -563,10 +563,10 @@ public: | |||||
| { | { | ||||
| ObjectClass** const e = data.elements + indexToRemove; | ObjectClass** const e = data.elements + indexToRemove; | ||||
| if (*e != nullptr) | |||||
| if (ObjectClass* o = *e) | |||||
| { | { | ||||
| removedItem = *e; | |||||
| (*e)->decReferenceCount(); | |||||
| removedItem = o; | |||||
| o->decReferenceCount(); | |||||
| } | } | ||||
| --numUsed; | --numUsed; | ||||
| @@ -624,9 +624,9 @@ public: | |||||
| int i; | int i; | ||||
| for (i = start; i < endIndex; ++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) | data.elements[i] = nullptr; // (in case one of the destructors accesses this array and hits a dangling pointer) | ||||
| } | } | ||||
| } | } | ||||
| @@ -877,7 +877,8 @@ struct Expression::Helpers | |||||
| throw ParseError ("Expected \")\""); | throw ParseError ("Expected \")\""); | ||||
| } | } | ||||
| else if (readOperator (".")) | |||||
| if (readOperator (".")) | |||||
| { | { | ||||
| TermPtr rhs (readSymbolOrFunction()); | TermPtr rhs (readSymbolOrFunction()); | ||||
| @@ -889,11 +890,10 @@ struct Expression::Helpers | |||||
| return new DotOperator (new SymbolTerm (identifier), rhs); | 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(); | return TermPtr(); | ||||
| @@ -1146,7 +1146,8 @@ double Expression::Scope::evaluateFunction (const String& functionName, const do | |||||
| return v; | return v; | ||||
| } | } | ||||
| else if (functionName == "max") | |||||
| if (functionName == "max") | |||||
| { | { | ||||
| double v = parameters[0]; | double v = parameters[0]; | ||||
| for (int i = 1; i < numParams; ++i) | for (int i = 1; i < numParams; ++i) | ||||
| @@ -1154,12 +1155,13 @@ double Expression::Scope::evaluateFunction (const String& functionName, const do | |||||
| return v; | 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]); | |||||
| } | } | ||||
| } | } | ||||
| @@ -2070,10 +2070,9 @@ String String::fromUTF8 (const char* const buffer, int bufferSizeBytes) | |||||
| { | { | ||||
| if (buffer != nullptr) | 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; | return String::empty; | ||||
| @@ -223,9 +223,7 @@ bool PropertiesFile::saveAsXml() | |||||
| e->setAttribute (PropertyFileConstants::nameAttribute, getAllProperties().getAllKeys() [i]); | e->setAttribute (PropertyFileConstants::nameAttribute, getAllProperties().getAllKeys() [i]); | ||||
| // if the value seems to contain xml, store it as such.. | // 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); | e->addChildElement (childElement); | ||||
| else | else | ||||
| e->setAttribute (PropertyFileConstants::valueAttribute, | e->setAttribute (PropertyFileConstants::valueAttribute, | ||||
| @@ -194,11 +194,10 @@ void CustomTypeface::addKerningPair (const juce_wchar char1, const juce_wchar ch | |||||
| { | { | ||||
| if (extraAmount != 0) | 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); | g->addKerningPair (char2, extraAmount); | ||||
| else | |||||
| jassertfalse; // can only add kerning pairs for characters that exist! | |||||
| } | } | ||||
| } | } | ||||
| @@ -2171,8 +2171,8 @@ public: | |||||
| { | { | ||||
| if (transform.isOnlyTranslated) | if (transform.isOnlyTranslated) | ||||
| return clip->clipRegionIntersects (transform.translated (r)); | return clip->clipRegionIntersects (transform.translated (r)); | ||||
| else | |||||
| return getClipBounds().intersects (r); | |||||
| return getClipBounds().intersects (r); | |||||
| } | } | ||||
| return false; | return false; | ||||
| @@ -125,17 +125,19 @@ const ApplicationCommandInfo* ApplicationCommandManager::getCommandForID (const | |||||
| String ApplicationCommandManager::getNameOfCommand (const CommandID commandID) const noexcept | 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 | 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 | StringArray ApplicationCommandManager::getCommandCategories() const | ||||
| @@ -101,12 +101,8 @@ void Desktop::setDefaultLookAndFeel (LookAndFeel* newDefaultLookAndFeel) | |||||
| currentLookAndFeel = newDefaultLookAndFeel; | currentLookAndFeel = newDefaultLookAndFeel; | ||||
| for (int i = getNumComponents(); --i >= 0;) | for (int i = getNumComponents(); --i >= 0;) | ||||
| { | |||||
| Component* const c = getComponent (i); | |||||
| if (c != nullptr) | |||||
| if (Component* const c = getComponent (i)) | |||||
| c->sendLookAndFeelChange(); | c->sendLookAndFeelChange(); | ||||
| } | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -304,9 +300,7 @@ void Desktop::sendMouseMove() | |||||
| lastFakeMouseMove = getMousePosition(); | lastFakeMouseMove = getMousePosition(); | ||||
| Component* const target = findComponentAt (lastFakeMouseMove); | |||||
| if (target != nullptr) | |||||
| if (Component* const target = findComponentAt (lastFakeMouseMove)) | |||||
| { | { | ||||
| Component::BailOutChecker checker (target); | Component::BailOutChecker checker (target); | ||||
| const Point<int> pos (target->getLocalPoint (nullptr, lastFakeMouseMove)); | const Point<int> pos (target->getLocalPoint (nullptr, lastFakeMouseMove)); | ||||
| @@ -405,11 +399,8 @@ void Desktop::Displays::refresh() | |||||
| if (oldDisplays != displays) | if (oldDisplays != displays) | ||||
| { | { | ||||
| for (int i = ComponentPeer::getNumPeers(); --i >= 0;) | 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(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -125,9 +125,8 @@ bool DirectoryContentsList::getFileInfo (const int index, | |||||
| FileInfo& result) const | FileInfo& result) const | ||||
| { | { | ||||
| const ScopedLock sl (fileListLock); | const ScopedLock sl (fileListLock); | ||||
| const FileInfo* const info = files [index]; | |||||
| if (info != nullptr) | |||||
| if (const FileInfo* const info = files [index]) | |||||
| { | { | ||||
| result = *info; | result = *info; | ||||
| return true; | return true; | ||||
| @@ -139,9 +138,8 @@ bool DirectoryContentsList::getFileInfo (const int index, | |||||
| File DirectoryContentsList::getFile (const int index) const | File DirectoryContentsList::getFile (const int index) const | ||||
| { | { | ||||
| const ScopedLock sl (fileListLock); | 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 root.getChildFile (info->filename); | ||||
| return File::nonexistent; | return File::nonexistent; | ||||
| @@ -52,12 +52,8 @@ namespace ComponentBuilderHelpers | |||||
| return &c; | return &c; | ||||
| for (int i = c.getNumChildComponents(); --i >= 0;) | 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 child; | ||||
| } | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| @@ -73,9 +69,7 @@ namespace ComponentBuilderHelpers | |||||
| static void updateComponent (ComponentBuilder& builder, const ValueTree& state) | 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); | ComponentBuilder::TypeHandler* const type = builder.getHandlerForState (state); | ||||
| const String uid (getStateId (state)); | const String uid (getStateId (state)); | ||||
| @@ -88,9 +82,7 @@ namespace ComponentBuilderHelpers | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| Component* const changedComp = findComponentWithID (*topLevelComp, uid); | |||||
| if (changedComp != nullptr) | |||||
| if (Component* const changedComp = findComponentWithID (*topLevelComp, uid)) | |||||
| type->updateComponentFromState (changedComp, state); | type->updateComponentFromState (changedComp, state); | ||||
| } | } | ||||
| } | } | ||||
| @@ -264,11 +256,10 @@ void ComponentBuilder::updateChildComponents (Component& parent, const ValueTree | |||||
| if (c == nullptr) | 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); | c = ComponentBuilderHelpers::createNewComponent (*type, childState, &parent); | ||||
| else | |||||
| jassertfalse; | |||||
| } | } | ||||
| if (c != nullptr) | if (c != nullptr) | ||||
| @@ -410,12 +410,12 @@ bool ScrollBar::keyPressed (const KeyPress& key) | |||||
| { | { | ||||
| if (isVisible()) | 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; | return false; | ||||
| @@ -2045,9 +2045,7 @@ int LookAndFeel::getTabButtonBestWidth (TabBarButton& button, int tabDepth) | |||||
| int width = Font (tabDepth * 0.6f).getStringWidth (button.getButtonText().trim()) | int width = Font (tabDepth * 0.6f).getStringWidth (button.getButtonText().trim()) | ||||
| + getTabButtonOverlap (tabDepth) * 2; | + getTabButtonOverlap (tabDepth) * 2; | ||||
| Component* const extraComponent = button.getExtraComponent(); | |||||
| if (extraComponent != nullptr) | |||||
| if (Component* const extraComponent = button.getExtraComponent()) | |||||
| width += button.getTabbedButtonBar().isVertical() ? extraComponent->getHeight() | width += button.getTabbedButtonBar().isVertical() ? extraComponent->getHeight() | ||||
| : extraComponent->getWidth(); | : extraComponent->getWidth(); | ||||
| @@ -2526,10 +2524,8 @@ void LookAndFeel::drawFileBrowserRow (Graphics& g, int width, int height, | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| const Drawable* d = isDirectory ? getDefaultFolderImage() | |||||
| : getDefaultDocumentFileImage(); | |||||
| if (d != nullptr) | |||||
| if (const Drawable* d = isDirectory ? getDefaultFolderImage() | |||||
| : getDefaultDocumentFileImage()) | |||||
| d->drawWithin (g, Rectangle<float> (2.0f, 2.0f, x - 4.0f, height - 4.0f), | d->drawWithin (g, Rectangle<float> (2.0f, 2.0f, x - 4.0f, height - 4.0f), | ||||
| RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f); | RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f); | ||||
| } | } | ||||
| @@ -54,8 +54,8 @@ void BubbleComponent::setPosition (Component* componentToPointTo) | |||||
| { | { | ||||
| jassert (componentToPointTo != nullptr); | jassert (componentToPointTo != nullptr); | ||||
| if (getParentComponent() != nullptr) | |||||
| setPosition (getParentComponent()->getLocalArea (componentToPointTo, componentToPointTo->getLocalBounds())); | |||||
| if (Component* p = getParentComponent()) | |||||
| setPosition (p->getLocalArea (componentToPointTo, componentToPointTo->getLocalBounds())); | |||||
| else | else | ||||
| setPosition (componentToPointTo->getScreenBounds()); | setPosition (componentToPointTo->getScreenBounds()); | ||||
| } | } | ||||
| @@ -67,10 +67,9 @@ public: | |||||
| { | { | ||||
| mouseDragSource->removeMouseListener (this); | 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 | if (wasVisible) // fade the component and remove it - it'll be deleted later by the timer callback | ||||
| dismissWithAnimation (finalTarget == nullptr); | dismissWithAnimation (finalTarget == nullptr); | ||||
| if (getParentComponent() != nullptr) | |||||
| getParentComponent()->removeChildComponent (this); | |||||
| if (Component* parent = getParentComponent()) | |||||
| parent->removeChildComponent (this); | |||||
| if (finalTarget != nullptr) | if (finalTarget != nullptr) | ||||
| { | { | ||||
| @@ -135,11 +134,9 @@ public: | |||||
| if (newTargetComp != currentlyOverComp) | 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; | currentlyOverComp = newTargetComp; | ||||
| @@ -206,13 +203,14 @@ private: | |||||
| while (hit != nullptr) | while (hit != nullptr) | ||||
| { | { | ||||
| DragAndDropTarget* const ddt = dynamic_cast <DragAndDropTarget*> (hit); | |||||
| if (ddt != nullptr && ddt->isInterestedInDragSource (details)) | |||||
| if (DragAndDropTarget* const ddt = dynamic_cast <DragAndDropTarget*> (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(); | hit = hit->getParentComponent(); | ||||
| @@ -226,18 +224,17 @@ private: | |||||
| { | { | ||||
| Point<int> newPos (screenPos - imageOffset); | Point<int> newPos (screenPos - imageOffset); | ||||
| if (getParentComponent() != nullptr) | |||||
| newPos = getParentComponent()->getLocalPoint (nullptr, newPos); | |||||
| if (Component* p = getParentComponent()) | |||||
| newPos = p->getLocalPoint (nullptr, newPos); | |||||
| setTopLeftPosition (newPos); | setTopLeftPosition (newPos); | ||||
| } | } | ||||
| void sendDragMove (DragAndDropTarget::SourceDetails& details) const | 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 | struct ExternalDragAndDropMessage : public CallbackMessage | ||||
| @@ -91,8 +91,7 @@ public: | |||||
| TemporaryMainMenuWithStandardCommands() | TemporaryMainMenuWithStandardCommands() | ||||
| : oldMenu (MenuBarModel::getMacMainMenu()), oldAppleMenu (nullptr) | : oldMenu (MenuBarModel::getMacMainMenu()), oldAppleMenu (nullptr) | ||||
| { | { | ||||
| const PopupMenu* appleMenu = MenuBarModel::getMacExtraAppleItemsMenu(); | |||||
| if (appleMenu != nullptr) | |||||
| if (const PopupMenu* appleMenu = MenuBarModel::getMacExtraAppleItemsMenu()) | |||||
| oldAppleMenu = new PopupMenu (*appleMenu); | oldAppleMenu = new PopupMenu (*appleMenu); | ||||
| MenuBarModel::setMacMainMenu (nullptr); | MenuBarModel::setMacMainMenu (nullptr); | ||||
| @@ -245,15 +245,11 @@ void MarkerList::ValueTreeWrapper::removeMarker (const ValueTree& marker, UndoMa | |||||
| double MarkerList::getMarkerPosition (const Marker& marker, Component* parentComponent) const | 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); | return marker.position.resolve (nullptr); | ||||
| } | |||||
| RelativeCoordinatePositionerBase::ComponentScope scope (*parentComponent); | |||||
| return marker.position.resolve (&scope); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -116,8 +116,8 @@ double RelativeCoordinate::resolve (const Expression::Scope* scope) const | |||||
| { | { | ||||
| if (scope != nullptr) | if (scope != nullptr) | ||||
| return term.evaluate (*scope); | return term.evaluate (*scope); | ||||
| else | |||||
| return term.evaluate(); | |||||
| return term.evaluate(); | |||||
| } | } | ||||
| catch (Expression::ParseError&) | catch (Expression::ParseError&) | ||||
| {} | {} | ||||
| @@ -38,9 +38,8 @@ public: | |||||
| } | } | ||||
| MarkerList* list; | 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 (marker->position.getExpression().evaluate (*this)); | ||||
| return Expression::Scope::getSymbolValue (symbol); | return Expression::Scope::getSymbolValue (symbol); | ||||
| @@ -50,9 +49,7 @@ public: | |||||
| { | { | ||||
| if (scopeName == RelativeCoordinate::Strings::parent) | if (scopeName == RelativeCoordinate::Strings::parent) | ||||
| { | { | ||||
| Component* const parent = component.getParentComponent(); | |||||
| if (parent != nullptr) | |||||
| if (Component* const parent = component.getParentComponent()) | |||||
| { | { | ||||
| visitor.visit (MarkerListScope (*parent)); | visitor.visit (MarkerListScope (*parent)); | ||||
| return; | return; | ||||
| @@ -113,14 +110,11 @@ Expression RelativeCoordinatePositionerBase::ComponentScope::getSymbolValue (con | |||||
| default: break; | default: break; | ||||
| } | } | ||||
| Component* const parent = component.getParentComponent(); | |||||
| if (parent != nullptr) | |||||
| if (Component* const parent = component.getParentComponent()) | |||||
| { | { | ||||
| MarkerList* list; | 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); | MarkerListScope scope (*parent); | ||||
| return Expression (marker->position.getExpression().evaluate (scope)); | 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 | 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)); | visitor.visit (ComponentScope (*targetComp)); | ||||
| else | else | ||||
| Expression::Scope::visitRelativeScope (scopeName, visitor); | Expression::Scope::visitRelativeScope (scopeName, visitor); | ||||
| @@ -149,10 +141,10 @@ String RelativeCoordinatePositionerBase::ComponentScope::getScopeUID() const | |||||
| Component* RelativeCoordinatePositionerBase::ComponentScope::findSiblingComponent (const String& componentID) 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; | break; | ||||
| default: | default: | ||||
| { | |||||
| Component* const parent = component.getParentComponent(); | |||||
| if (parent != nullptr) | |||||
| if (Component* const parent = component.getParentComponent()) | |||||
| { | { | ||||
| MarkerList* list; | MarkerList* list; | ||||
| const MarkerList::Marker* marker = MarkerListScope::findMarker (*parent, symbol, list); | |||||
| if (marker != nullptr) | |||||
| if (MarkerListScope::findMarker (*parent, symbol, list) != nullptr) | |||||
| { | { | ||||
| positioner.registerMarkerListListener (list); | positioner.registerMarkerListListener (list); | ||||
| } | } | ||||
| @@ -199,8 +188,7 @@ public: | |||||
| ok = false; | ok = false; | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| break; | |||||
| break; | |||||
| } | } | ||||
| return ComponentScope::getSymbolValue (symbol); | return ComponentScope::getSymbolValue (symbol); | ||||
| @@ -208,19 +196,16 @@ public: | |||||
| void visitRelativeScope (const String& scopeName, Visitor& visitor) const | 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)); | visitor.visit (DependencyFinderScope (*targetComp, positioner, ok)); | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| // The named component doesn't exist, so we'll watch the parent for changes in case it appears later.. | // 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 (*parent); | ||||
| positioner.registerComponentListener (component); | positioner.registerComponentListener (component); | ||||
| @@ -31,7 +31,6 @@ PropertyComponent::PropertyComponent (const String& name, const int preferredHei | |||||
| PropertyComponent::~PropertyComponent() {} | PropertyComponent::~PropertyComponent() {} | ||||
| //============================================================================== | |||||
| void PropertyComponent::paint (Graphics& g) | void PropertyComponent::paint (Graphics& g) | ||||
| { | { | ||||
| LookAndFeel& lf = getLookAndFeel(); | LookAndFeel& lf = getLookAndFeel(); | ||||
| @@ -42,8 +41,7 @@ void PropertyComponent::paint (Graphics& g) | |||||
| void PropertyComponent::resized() | void PropertyComponent::resized() | ||||
| { | { | ||||
| Component* const c = getChildComponent(0); | |||||
| if (c != nullptr) | |||||
| if (Component* const c = getChildComponent(0)) | |||||
| c->setBounds (getLookAndFeel().getPropertyComponentContentPosition (*this)); | c->setBounds (getLookAndFeel().getPropertyComponentContentPosition (*this)); | ||||
| } | } | ||||
| @@ -87,9 +87,7 @@ public: | |||||
| for (int i = propertyComps.size(); --i >= 0;) | for (int i = propertyComps.size(); --i >= 0;) | ||||
| propertyComps.getUnchecked(i)->setVisible (open); | propertyComps.getUnchecked(i)->setVisible (open); | ||||
| PropertyPanel* const pp = findParentComponentOfClass<PropertyPanel>(); | |||||
| if (pp != nullptr) | |||||
| if (PropertyPanel* const pp = findParentComponentOfClass<PropertyPanel>()) | |||||
| pp->resized(); | pp->resized(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -87,26 +87,27 @@ int TableHeaderComponent::getNumColumns (const bool onlyCountVisibleColumns) con | |||||
| return num; | return num; | ||||
| } | } | ||||
| else | |||||
| { | |||||
| return columns.size(); | |||||
| } | |||||
| return columns.size(); | |||||
| } | } | ||||
| String TableHeaderComponent::getColumnName (const int columnId) const | 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) | 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 | 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) | void TableHeaderComponent::setColumnWidth (const int columnId, const int newWidth) | ||||
| @@ -233,8 +236,10 @@ int TableHeaderComponent::getColumnIdOfIndex (int index, const bool onlyCountVis | |||||
| if (onlyCountVisibleColumns) | if (onlyCountVisibleColumns) | ||||
| index = visibleIndexToTotalIndex (index); | 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<int> TableHeaderComponent::getColumnPosition (const int index) const | Rectangle<int> 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) | 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) | 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*/) | void TableHeaderComponent::addMenuItems (PopupMenu& menu, const int /*columnIdClicked*/) | ||||
| @@ -210,12 +210,12 @@ void DocumentWindow::paint (Graphics& g) | |||||
| for (int i = 0; i < 3; ++i) | for (int i = 0; i < 3; ++i) | ||||
| { | { | ||||
| if (titleBarButtons[i] != nullptr) | |||||
| if (Button* const b = titleBarButtons[i]) | |||||
| { | { | ||||
| if (positionTitleBarButtonsOnLeft) | if (positionTitleBarButtonsOnLeft) | ||||
| titleSpaceX1 = jmax (titleSpaceX1, titleBarButtons[i]->getRight() + (getWidth() - titleBarButtons[i]->getRight()) / 8); | |||||
| titleSpaceX1 = jmax (titleSpaceX1, b->getRight() + (getWidth() - b->getRight()) / 8); | |||||
| else | 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(); | ResizableWindow::resized(); | ||||
| if (titleBarButtons[1] != nullptr) | |||||
| titleBarButtons[1]->setToggleState (isFullScreen(), false); | |||||
| if (Button* const b = getMaximiseButton()) | |||||
| b->setToggleState (isFullScreen(), false); | |||||
| const Rectangle<int> titleBarArea (getTitleBarArea()); | const Rectangle<int> titleBarArea (getTitleBarArea()); | ||||
| @@ -311,25 +311,25 @@ void DocumentWindow::lookAndFeelChanged() | |||||
| for (int i = 0; i < 3; ++i) | for (int i = 0; i < 3; ++i) | ||||
| { | { | ||||
| if (titleBarButtons[i] != nullptr) | |||||
| if (Button* const b = titleBarButtons[i]) | |||||
| { | { | ||||
| if (buttonListener == nullptr) | if (buttonListener == nullptr) | ||||
| buttonListener = new ButtonListenerProxy (*this); | 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) | // (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 | #if JUCE_MAC | ||||
| getCloseButton()->addShortcut (KeyPress ('w', ModifierKeys::commandModifier, 0)); | |||||
| b->addShortcut (KeyPress ('w', ModifierKeys::commandModifier, 0)); | |||||
| #else | #else | ||||
| getCloseButton()->addShortcut (KeyPress (KeyPress::F4Key, ModifierKeys::altModifier, 0)); | |||||
| b->addShortcut (KeyPress (KeyPress::F4Key, ModifierKeys::altModifier, 0)); | |||||
| #endif | #endif | ||||
| } | } | ||||
| } | } | ||||
| @@ -349,8 +349,8 @@ void DocumentWindow::activeWindowStatusChanged() | |||||
| ResizableWindow::activeWindowStatusChanged(); | ResizableWindow::activeWindowStatusChanged(); | ||||
| for (int i = numElementsInArray (titleBarButtons); --i >= 0;) | 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) | if (menuBar != nullptr) | ||||
| menuBar->setEnabled (isActiveWindow()); | menuBar->setEnabled (isActiveWindow()); | ||||
| @@ -160,10 +160,10 @@ public: | |||||
| if (w != getWidth() || h != getHeight()) | if (w != getWidth() || h != getHeight()) | ||||
| { | { | ||||
| startTimer (50); | startTimer (50); | ||||
| setSize (w, h); | setSize (w, h); | ||||
| if (getParentComponent() != nullptr) | |||||
| getParentComponent()->setSize (w, h); | |||||
| if (Component* p = getParentComponent()) | |||||
| p->setSize (w, h); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -570,16 +570,14 @@ Component* OpenGLContext::getTargetComponent() const noexcept | |||||
| OpenGLContext* OpenGLContext::getCurrentContext() | OpenGLContext* OpenGLContext::getCurrentContext() | ||||
| { | { | ||||
| #if JUCE_ANDROID | #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 | #else | ||||
| CachedImage* currentContext = dynamic_cast <CachedImage*> (Thread::getCurrentThread()); | |||||
| if (CachedImage* currentContext = dynamic_cast <CachedImage*> (Thread::getCurrentThread())) | |||||
| #endif | #endif | ||||
| return ¤tContext->context; | |||||
| return currentContext != nullptr ? ¤tContext->context : nullptr; | |||||
| return nullptr; | |||||
| } | } | ||||
| bool OpenGLContext::makeActive() const noexcept { return nativeContext != nullptr && nativeContext->makeActive(); } | 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 | 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 | bool OpenGLContext::areShadersAvailable() const | ||||