Browse Source

Blocks: lazy load LEDRow to avoid blocks being cleared at the wrong time

tags/2021-05-28
dimitriroli Julian Storer 7 years ago
parent
commit
d69771403e
2 changed files with 9 additions and 5 deletions
  1. +1
    -1
      modules/juce_blocks_basics/blocks/juce_Block.h
  2. +8
    -4
      modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp

+ 1
- 1
modules/juce_blocks_basics/blocks/juce_Block.h View File

@@ -151,7 +151,7 @@ public:
neither delete it or use it after the lifetime of this Block object has finished.
If there are no LEDs, then this method will return nullptr.
*/
virtual LEDRow* getLEDRow() const = 0;
virtual LEDRow* getLEDRow() = 0;
/** If this block has any status LEDs, this will return an array of objects to control them.
Note that the objects in the array belong to this Block object, and the caller must


+ 8
- 4
modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp View File

@@ -1470,9 +1470,6 @@ struct PhysicalTopologySource::Internal
for (auto&& s : modelData.statusLEDs)
statusLights.add (new StatusLightImplementation (*this, s));
if (modelData.numLEDRowLEDs > 0)
ledRow.reset (new LEDRowImplementation (*this));
updateMidiConnectionListener();
}
@@ -1546,7 +1543,14 @@ struct PhysicalTopologySource::Internal
TouchSurface* getTouchSurface() const override { return touchSurface.get(); }
LEDGrid* getLEDGrid() const override { return ledGrid.get(); }
LEDRow* getLEDRow() const override { return ledRow.get(); }
LEDRow* getLEDRow() override
{
if (ledRow == nullptr && modelData.numLEDRowLEDs > 0)
ledRow.reset (new LEDRowImplementation (*this));
return ledRow.get();
}
juce::Array<ControlButton*> getButtons() const override
{


Loading…
Cancel
Save