From bd9a32c757f90441c8c608851cd3d9cd24e25712 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Mon, 12 Sep 2011 21:59:19 +0100 Subject: [PATCH] Removed 'const' from some virtual method return types - this might require a few tweaks to user-code. --- .../JuceDemo/Source/demos/DragAndDropDemo.cpp | 2 +- extras/JuceDemo/Source/demos/TreeViewDemo.cpp | 8 ++---- .../processors/juce_AudioProcessorGraph.cpp | 28 ++++++++++--------- .../juce_gui_basics/buttons/juce_Button.cpp | 2 +- modules/juce_gui_basics/buttons/juce_Button.h | 2 +- .../filebrowser/juce_FileListComponent.cpp | 9 ++---- .../filebrowser/juce_FileTreeComponent.cpp | 19 ++++++------- .../mouse/juce_TooltipClient.h | 4 +-- .../native/juce_android_Windowing.cpp | 1 - .../juce_gui_basics/widgets/juce_ComboBox.h | 2 +- .../juce_gui_basics/widgets/juce_ListBox.cpp | 6 ++-- .../juce_gui_basics/widgets/juce_ListBox.h | 4 +-- .../widgets/juce_TableListBox.cpp | 4 +-- .../widgets/juce_TableListBox.h | 2 +- .../juce_gui_basics/widgets/juce_TreeView.cpp | 8 +++--- .../juce_gui_basics/widgets/juce_TreeView.h | 6 ++-- .../misc/juce_KeyMappingEditorComponent.cpp | 8 +++--- .../misc/juce_KeyMappingEditorComponent.h | 2 +- 18 files changed, 54 insertions(+), 63 deletions(-) diff --git a/extras/JuceDemo/Source/demos/DragAndDropDemo.cpp b/extras/JuceDemo/Source/demos/DragAndDropDemo.cpp index 0121322254..f7c9fd2b72 100644 --- a/extras/JuceDemo/Source/demos/DragAndDropDemo.cpp +++ b/extras/JuceDemo/Source/demos/DragAndDropDemo.cpp @@ -70,7 +70,7 @@ public: Justification::centredLeft, true); } - const var getDragSourceDescription (const SparseSet& selectedRows) + var getDragSourceDescription (const SparseSet& selectedRows) { // for our drag desctription, we'll just make a list of the selected // row numbers - this will be picked up by the drag target and displayed in diff --git a/extras/JuceDemo/Source/demos/TreeViewDemo.cpp b/extras/JuceDemo/Source/demos/TreeViewDemo.cpp index 29df726c85..a5753c88ff 100644 --- a/extras/JuceDemo/Source/demos/TreeViewDemo.cpp +++ b/extras/JuceDemo/Source/demos/TreeViewDemo.cpp @@ -35,16 +35,12 @@ public: { } - ~TreeViewDemoItem() - { - } - int getItemWidth() const { return xml.getIntAttribute ("width", -1); } - const String getUniqueName() const + String getUniqueName() const { return xml.getTagName(); } @@ -98,7 +94,7 @@ public: } } - const var getDragSourceDescription() + var getDragSourceDescription() { return "TreeView Items"; } diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp index 3fa39a4220..7f6aa2e16e 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp @@ -1089,7 +1089,6 @@ bool AudioProcessorGraph::addConnection (const uint32 sourceNodeId, connections.addSorted (sorter, new Connection (sourceNodeId, sourceChannelIndex, destNodeId, destChannelIndex)); triggerAsyncUpdate(); - return true; } @@ -1115,7 +1114,6 @@ bool AudioProcessorGraph::removeConnection (const uint32 sourceNodeId, const int { removeConnection (i); doneAnything = true; - triggerAsyncUpdate(); } } @@ -1134,7 +1132,6 @@ bool AudioProcessorGraph::disconnectNode (const uint32 nodeId) { removeConnection (i); doneAnything = true; - triggerAsyncUpdate(); } } @@ -1164,7 +1161,6 @@ bool AudioProcessorGraph::removeIllegalConnections() { removeConnection (i); doneAnything = true; - triggerAsyncUpdate(); } } @@ -1172,14 +1168,22 @@ bool AudioProcessorGraph::removeIllegalConnections() } //============================================================================== +static void deleteRenderOpArray (Array& ops) +{ + for (int i = ops.size(); --i >= 0;) + delete static_cast (ops.getUnchecked(i)); +} + void AudioProcessorGraph::clearRenderingSequence() { - const ScopedLock sl (renderLock); + Array oldOps; - for (int i = renderingOps.size(); --i >= 0;) - delete static_cast (renderingOps.getUnchecked(i)); + { + const ScopedLock sl (renderLock); + renderingOps.swapWithArray (oldOps); + } - renderingOps.clear(); + deleteRenderOpArray (oldOps); } bool AudioProcessorGraph::isAnInputTo (const uint32 possibleInputId, @@ -1237,8 +1241,6 @@ void AudioProcessorGraph::buildRenderingSequence() numMidiBuffersNeeded = calculator.getNumMidiBuffersNeeded(); } - Array oldRenderingOps (renderingOps); - { // swap over to the new rendering sequence.. const ScopedLock sl (renderLock); @@ -1252,11 +1254,11 @@ void AudioProcessorGraph::buildRenderingSequence() while (midiBuffers.size() < numMidiBuffersNeeded) midiBuffers.add (new MidiBuffer()); - renderingOps = newRenderingOps; + renderingOps.swapWithArray (newRenderingOps); } - for (int i = oldRenderingOps.size(); --i >= 0;) - delete static_cast (oldRenderingOps.getUnchecked(i)); + // delete the old ones.. + deleteRenderOpArray (newRenderingOps); } void AudioProcessorGraph::handleAsyncUpdate() diff --git a/modules/juce_gui_basics/buttons/juce_Button.cpp b/modules/juce_gui_basics/buttons/juce_Button.cpp index b2afacaf4b..1520066ce4 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.cpp +++ b/modules/juce_gui_basics/buttons/juce_Button.cpp @@ -91,7 +91,7 @@ void Button::setTooltip (const String& newTooltip) generateTooltip = false; } -const String Button::getTooltip() +String Button::getTooltip() { if (generateTooltip && commandManagerToUse != nullptr && commandID != 0) { diff --git a/modules/juce_gui_basics/buttons/juce_Button.h b/modules/juce_gui_basics/buttons/juce_Button.h index b4287320cf..3ad12a2049 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.h +++ b/modules/juce_gui_basics/buttons/juce_Button.h @@ -299,7 +299,7 @@ public: void setTooltip (const String& newTooltip); // (implementation of the TooltipClient method) - const String getTooltip(); + String getTooltip(); //============================================================================== diff --git a/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp index d292a5f1fc..d4544e831d 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp @@ -80,7 +80,6 @@ class FileListItemComponent : public Component, public AsyncUpdater { public: - //============================================================================== FileListItemComponent (FileListComponent& owner_, TimeSliceThread& thread_) : owner (owner_), thread (thread_), index (0), highlighted (false) { @@ -226,11 +225,9 @@ Component* FileListComponent::refreshComponentForRow (int row, bool isSelected, } DirectoryContentsList::FileInfo fileInfo; - - if (fileList.getFileInfo (row, fileInfo)) - comp->update (fileList.getDirectory(), &fileInfo, row, isSelected); - else - comp->update (fileList.getDirectory(), nullptr, row, isSelected); + comp->update (fileList.getDirectory(), + fileList.getFileInfo (row, fileInfo) ? &fileInfo : nullptr, + row, isSelected); return comp; } diff --git a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp index 290636e32f..b8c0b2cf01 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp @@ -34,7 +34,6 @@ class FileListTreeItem : public TreeViewItem, public ChangeListener { public: - //============================================================================== FileListTreeItem (FileTreeComponent& owner_, DirectoryContentsList* const parentContentsList_, const int indexInContentsList_, @@ -70,10 +69,10 @@ public: //============================================================================== bool mightContainSubItems() { return isDirectory; } - const String getUniqueName() const { return file.getFullPathName(); } + String getUniqueName() const { return file.getFullPathName(); } int getItemHeight() const { return 22; } - const var getDragSourceDescription() { return owner.getDragAndDropDescription(); } + var getDragSourceDescription() { return owner.getDragAndDropDescription(); } void itemOpennessChanged (bool isNowOpen) { @@ -133,12 +132,11 @@ public: thread.addTimeSliceClient (this); } - owner.getLookAndFeel() - .drawFileBrowserRow (g, width, height, - file.getFileName(), - &icon, fileSize, modTime, - isDirectory, isSelected(), - indexInContentsList, owner); + owner.getLookAndFeel().drawFileBrowserRow (g, width, height, + file.getFileName(), + &icon, fileSize, modTime, + isDirectory, isSelected(), + indexInContentsList, owner); } void itemClicked (const MouseEvent& e) @@ -179,8 +177,7 @@ private: bool isDirectory; TimeSliceThread& thread; Image icon; - String fileSize; - String modTime; + String fileSize, modTime; void updateIcon (const bool onlyUpdateIfCached) { diff --git a/modules/juce_gui_basics/mouse/juce_TooltipClient.h b/modules/juce_gui_basics/mouse/juce_TooltipClient.h index 0529245ace..88ff4f613a 100644 --- a/modules/juce_gui_basics/mouse/juce_TooltipClient.h +++ b/modules/juce_gui_basics/mouse/juce_TooltipClient.h @@ -44,7 +44,7 @@ public: virtual ~TooltipClient() {} /** Returns the string that this object wants to show as its tooltip. */ - virtual const String getTooltip() = 0; + virtual String getTooltip() = 0; }; @@ -73,7 +73,7 @@ public: virtual void setTooltip (const String& newTooltip) { tooltipString = newTooltip; } /** Returns the tooltip assigned to this object. */ - virtual const String getTooltip() { return tooltipString; } + virtual String getTooltip() { return tooltipString; } protected: SettableTooltipClient() {} diff --git a/modules/juce_gui_basics/native/juce_android_Windowing.cpp b/modules/juce_gui_basics/native/juce_android_Windowing.cpp index 8e69031a3e..db82df0530 100644 --- a/modules/juce_gui_basics/native/juce_android_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_android_Windowing.cpp @@ -84,7 +84,6 @@ DECLARE_JNI_CLASS (ComponentPeerView, "com/juce/ComponentPeerView"); class AndroidComponentPeer : public ComponentPeer { public: - //============================================================================== AndroidComponentPeer (Component* const component, const int windowStyleFlags) : ComponentPeer (component, windowStyleFlags), view (android.activity.callObjectMethod (JuceAppActivity.createNewView, component->isOpaque())), diff --git a/modules/juce_gui_basics/widgets/juce_ComboBox.h b/modules/juce_gui_basics/widgets/juce_ComboBox.h index bdd40a5654..fbf2149115 100644 --- a/modules/juce_gui_basics/widgets/juce_ComboBox.h +++ b/modules/juce_gui_basics/widgets/juce_ComboBox.h @@ -350,7 +350,7 @@ public: /** @internal */ void handleAsyncUpdate(); /** @internal */ - const String getTooltip() { return label->getTooltip(); } + String getTooltip() { return label->getTooltip(); } /** @internal */ void mouseDown (const MouseEvent&); /** @internal */ diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/modules/juce_gui_basics/widgets/juce_ListBox.cpp index 50db21fcb9..4d421fb262 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -126,7 +126,7 @@ public: customComponent->setBounds (getLocalBounds()); } - const String getTooltip() + String getTooltip() { if (owner.getModel() != nullptr) return owner.getModel()->getTooltipForRow (row); @@ -944,8 +944,8 @@ void ListBoxModel::selectedRowsChanged (int) {} void ListBoxModel::deleteKeyPressed (int) {} void ListBoxModel::returnKeyPressed (int) {} void ListBoxModel::listWasScrolled() {} -const var ListBoxModel::getDragSourceDescription (const SparseSet&) { return var::null; } -const String ListBoxModel::getTooltipForRow (int) { return String::empty; } +var ListBoxModel::getDragSourceDescription (const SparseSet&) { return var::null; } +String ListBoxModel::getTooltipForRow (int) { return String::empty; } END_JUCE_NAMESPACE diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.h b/modules/juce_gui_basics/widgets/juce_ListBox.h index a44e5dae9e..d308be9adf 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.h +++ b/modules/juce_gui_basics/widgets/juce_ListBox.h @@ -145,12 +145,12 @@ public: @see DragAndDropContainer::startDragging */ - virtual const var getDragSourceDescription (const SparseSet& currentlySelectedRows); + virtual var getDragSourceDescription (const SparseSet& currentlySelectedRows); /** You can override this to provide tool tips for specific rows. @see TooltipClient */ - virtual const String getTooltipForRow (int row); + virtual String getTooltipForRow (int row); }; diff --git a/modules/juce_gui_basics/widgets/juce_TableListBox.cpp b/modules/juce_gui_basics/widgets/juce_TableListBox.cpp index 0051bf3041..14190b3805 100644 --- a/modules/juce_gui_basics/widgets/juce_TableListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_TableListBox.cpp @@ -190,7 +190,7 @@ public: owner.getModel()->cellDoubleClicked (row, columnId, e); } - const String getTooltip() + String getTooltip() { const int columnId = owner.getHeader().getColumnIdAtX (getMouseXYRelative().getX()); @@ -480,7 +480,7 @@ void TableListBoxModel::returnKeyPressed (int) {} void TableListBoxModel::listWasScrolled() {} const String TableListBoxModel::getCellTooltip (int /*rowNumber*/, int /*columnId*/) { return String::empty; } -const var TableListBoxModel::getDragSourceDescription (const SparseSet&) { return var::null; } +var TableListBoxModel::getDragSourceDescription (const SparseSet&) { return var::null; } Component* TableListBoxModel::refreshComponentForCell (int, int, bool, Component* existingComponentToUpdate) { diff --git a/modules/juce_gui_basics/widgets/juce_TableListBox.h b/modules/juce_gui_basics/widgets/juce_TableListBox.h index 19bfd202f4..1768eab43d 100644 --- a/modules/juce_gui_basics/widgets/juce_TableListBox.h +++ b/modules/juce_gui_basics/widgets/juce_TableListBox.h @@ -183,7 +183,7 @@ public: @see getDragSourceCustomData, DragAndDropContainer::startDragging */ - virtual const var getDragSourceDescription (const SparseSet& currentlySelectedRows); + virtual var getDragSourceDescription (const SparseSet& currentlySelectedRows); }; diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.cpp b/modules/juce_gui_basics/widgets/juce_TreeView.cpp index f77b33793c..7541c00149 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.cpp +++ b/modules/juce_gui_basics/widgets/juce_TreeView.cpp @@ -303,7 +303,7 @@ public: owner.itemsChanged(); } - const String getTooltip() + String getTooltip() { Rectangle pos; TreeViewItem* const item = findItemAt (getMouseXYRelative().getY(), pos); @@ -1150,7 +1150,7 @@ TreeViewItem::~TreeViewItem() { } -const String TreeViewItem::getUniqueName() const +String TreeViewItem::getUniqueName() const { return String::empty; } @@ -1311,12 +1311,12 @@ void TreeViewItem::itemSelectionChanged (bool) { } -const String TreeViewItem::getTooltip() +String TreeViewItem::getTooltip() { return String::empty; } -const var TreeViewItem::getDragSourceDescription() +var TreeViewItem::getDragSourceDescription() { return var::null; } diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.h b/modules/juce_gui_basics/widgets/juce_TreeView.h index efc6fccd42..624983c192 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.h +++ b/modules/juce_gui_basics/widgets/juce_TreeView.h @@ -190,7 +190,7 @@ public: If you're not going to store the state, then it's ok not to bother implementing this method. */ - virtual const String getUniqueName() const; + virtual String getUniqueName() const; /** Called when an item is opened or closed. @@ -333,7 +333,7 @@ public: /** The item can return a tool tip string here if it wants to. @see TooltipClient */ - virtual const String getTooltip(); + virtual String getTooltip(); //============================================================================== /** To allow items from your treeview to be dragged-and-dropped, implement this method. @@ -351,7 +351,7 @@ public: @see DragAndDropContainer::startDragging */ - virtual const var getDragSourceDescription(); + virtual var getDragSourceDescription(); /** If you want your item to be able to have files drag-and-dropped onto it, implement this method and return true. diff --git a/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp b/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp index 0fd272818a..8c07d21e96 100644 --- a/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp +++ b/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp @@ -280,7 +280,7 @@ public: { } - const String getUniqueName() const { return String ((int) commandID) + "_id"; } + String getUniqueName() const { return String ((int) commandID) + "_id"; } bool mightContainSubItems() { return false; } int getItemHeight() const { return 20; } @@ -306,7 +306,7 @@ public: { } - const String getUniqueName() const { return categoryName + "_cat"; } + String getUniqueName() const { return categoryName + "_cat"; } bool mightContainSubItems() { return true; } int getItemHeight() const { return 28; } @@ -367,7 +367,7 @@ public: } bool mightContainSubItems() { return true; } - const String getUniqueName() const { return "keys"; } + String getUniqueName() const { return "keys"; } void changeListenerCallback (ChangeBroadcaster*) { @@ -484,7 +484,7 @@ bool KeyMappingEditorComponent::isCommandReadOnly (const CommandID commandID) return ci != nullptr && (ci->flags & ApplicationCommandInfo::readOnlyInKeyEditor) != 0; } -const String KeyMappingEditorComponent::getDescriptionForKeyPress (const KeyPress& key) +String KeyMappingEditorComponent::getDescriptionForKeyPress (const KeyPress& key) { return key.getTextDescription(); } diff --git a/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h b/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h index 0b60e159ea..5422fbb9a7 100644 --- a/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h +++ b/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h @@ -87,7 +87,7 @@ public: method, be sure to let the base class's method handle keys you're not interested in. */ - virtual const String getDescriptionForKeyPress (const KeyPress& key); + virtual String getDescriptionForKeyPress (const KeyPress& key); //============================================================================== /** A set of colour IDs to use to change the colour of various aspects of the editor.