RAM2118 commited on
Commit
d05e94b
·
verified ·
1 Parent(s): c8a084b

Fix: const auto& for temporary binding in loadPluginByIndex and showPluginMenu lambda

Browse files
Files changed (1) hide show
  1. Source/PluginBridgeEditor.cpp +11 -42
Source/PluginBridgeEditor.cpp CHANGED
@@ -46,11 +46,10 @@ PluginBridgeEditor::PluginBridgeEditor(PluginBridgeProcessor& p)
46
  pluginButton.setColour(juce::TextButton::textColourOffId, juce::Colours::white);
47
  addAndMakeVisible(pluginButton);
48
 
49
- // Scan plugins in background on first open
50
  if (!hasScanned)
51
  {
52
  hasScanned = true;
53
- // Scan runs on message thread — fast enough for installed plugins
54
  scanPlugins();
55
  }
56
 
@@ -64,7 +63,6 @@ PluginBridgeEditor::~PluginBridgeEditor()
64
 
65
  void PluginBridgeEditor::paint(juce::Graphics& g)
66
  {
67
- // Dark gradient background
68
  g.fillAll(juce::Colour(0xff12121f));
69
  g.setColour(juce::Colour(0xff1e1e35));
70
  g.fillRoundedRectangle(getLocalBounds().toFloat().reduced(4), 6.0f);
@@ -85,7 +83,6 @@ void PluginBridgeEditor::resized()
85
 
86
  void PluginBridgeEditor::timerCallback()
87
  {
88
- // MCP status
89
  if (processorRef.isMcpServerRunning())
90
  {
91
  statusLabel.setText("MCP: running", juce::dontSendNotification);
@@ -100,7 +97,6 @@ void PluginBridgeEditor::timerCallback()
100
  portLabel.setText("", juce::dontSendNotification);
101
  }
102
 
103
- // Plugin status
104
  auto& mgr = processorRef.getHostedPluginManager();
105
  if (mgr.isLoaded())
106
  {
@@ -119,7 +115,6 @@ void PluginBridgeEditor::timerCallback()
119
 
120
  void PluginBridgeEditor::scanPlugins()
121
  {
122
- // Scan standard plugin directories
123
  for (int i = 0; i < scanFormatManager.getNumFormats(); ++i)
124
  {
125
  auto* format = scanFormatManager.getFormat(i);
@@ -129,15 +124,12 @@ void PluginBridgeEditor::scanPlugins()
129
  knownPlugins,
130
  *format,
131
  searchPaths,
132
- true, // recursive
133
- juce::File() // no dead-mans-pedal for speed
134
  );
135
 
136
  juce::String pluginName;
137
- while (scanner.scanNextFile(false, pluginName))
138
- {
139
- // Scanning...
140
- }
141
  }
142
 
143
  DBG("PluginBridge: Scanned " + juce::String(knownPlugins.getNumTypes()) + " plugins");
@@ -146,56 +138,33 @@ void PluginBridgeEditor::scanPlugins()
146
  void PluginBridgeEditor::showPluginMenu()
147
  {
148
  juce::PopupMenu menu;
149
-
150
- // Sort by manufacturer → plugin name
151
  auto types = knownPlugins.getTypes();
152
 
153
- // Group by manufacturer
154
  juce::StringArray manufacturers;
155
- for (auto& desc : types)
156
  {
157
  if (!manufacturers.contains(desc.manufacturerName))
158
  manufacturers.add(desc.manufacturerName);
159
  }
160
  manufacturers.sort(true);
161
 
162
- int itemId = 1;
163
- for (auto& mfr : manufacturers)
164
  {
165
  juce::PopupMenu subMenu;
166
  for (int i = 0; i < types.size(); ++i)
167
  {
168
  if (types[i].manufacturerName == mfr)
169
- {
170
- subMenu.addItem(itemId, types[i].name + " (" + types[i].pluginFormatName + ")");
171
- }
172
- itemId++;
173
  }
174
  menu.addSubMenu(mfr, subMenu);
175
- // Reset itemId for proper indexing
176
- itemId = 1;
177
- for (int i = 0; i < types.size(); ++i)
178
- {
179
- if (types[i].manufacturerName == mfr)
180
- itemId++;
181
- }
182
- }
183
-
184
- // Simpler approach: flat list with manufacturer prefix, proper IDs
185
- menu.clear();
186
- for (int i = 0; i < types.size(); ++i)
187
- {
188
- menu.addItem(i + 1, types[i].manufacturerName + " — " + types[i].name
189
- + " [" + types[i].pluginFormatName + "]");
190
  }
191
 
192
  menu.showMenuAsync(juce::PopupMenu::Options().withTargetComponent(&pluginButton),
193
- [this, types](int result)
194
  {
195
- if (result > 0 && result <= types.size())
196
- {
197
  loadPluginByIndex(result - 1);
198
- }
199
  });
200
  }
201
 
@@ -204,7 +173,7 @@ void PluginBridgeEditor::loadPluginByIndex(int index)
204
  auto types = knownPlugins.getTypes();
205
  if (index >= 0 && index < types.size())
206
  {
207
- auto& desc = types[index];
208
  juce::File pluginFile(desc.fileOrIdentifier);
209
  processorRef.loadPluginFromFile(pluginFile);
210
  }
 
46
  pluginButton.setColour(juce::TextButton::textColourOffId, juce::Colours::white);
47
  addAndMakeVisible(pluginButton);
48
 
49
+ // Scan plugins on first open
50
  if (!hasScanned)
51
  {
52
  hasScanned = true;
 
53
  scanPlugins();
54
  }
55
 
 
63
 
64
  void PluginBridgeEditor::paint(juce::Graphics& g)
65
  {
 
66
  g.fillAll(juce::Colour(0xff12121f));
67
  g.setColour(juce::Colour(0xff1e1e35));
68
  g.fillRoundedRectangle(getLocalBounds().toFloat().reduced(4), 6.0f);
 
83
 
84
  void PluginBridgeEditor::timerCallback()
85
  {
 
86
  if (processorRef.isMcpServerRunning())
87
  {
88
  statusLabel.setText("MCP: running", juce::dontSendNotification);
 
97
  portLabel.setText("", juce::dontSendNotification);
98
  }
99
 
 
100
  auto& mgr = processorRef.getHostedPluginManager();
101
  if (mgr.isLoaded())
102
  {
 
115
 
116
  void PluginBridgeEditor::scanPlugins()
117
  {
 
118
  for (int i = 0; i < scanFormatManager.getNumFormats(); ++i)
119
  {
120
  auto* format = scanFormatManager.getFormat(i);
 
124
  knownPlugins,
125
  *format,
126
  searchPaths,
127
+ true,
128
+ juce::File()
129
  );
130
 
131
  juce::String pluginName;
132
+ while (scanner.scanNextFile(false, pluginName)) {}
 
 
 
133
  }
134
 
135
  DBG("PluginBridge: Scanned " + juce::String(knownPlugins.getNumTypes()) + " plugins");
 
138
  void PluginBridgeEditor::showPluginMenu()
139
  {
140
  juce::PopupMenu menu;
 
 
141
  auto types = knownPlugins.getTypes();
142
 
143
+ // Group by manufacturer as submenus
144
  juce::StringArray manufacturers;
145
+ for (const auto& desc : types)
146
  {
147
  if (!manufacturers.contains(desc.manufacturerName))
148
  manufacturers.add(desc.manufacturerName);
149
  }
150
  manufacturers.sort(true);
151
 
152
+ for (const auto& mfr : manufacturers)
 
153
  {
154
  juce::PopupMenu subMenu;
155
  for (int i = 0; i < types.size(); ++i)
156
  {
157
  if (types[i].manufacturerName == mfr)
158
+ subMenu.addItem(i + 1, types[i].name + " [" + types[i].pluginFormatName + "]");
 
 
 
159
  }
160
  menu.addSubMenu(mfr, subMenu);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  }
162
 
163
  menu.showMenuAsync(juce::PopupMenu::Options().withTargetComponent(&pluginButton),
164
+ [this](int result)
165
  {
166
+ if (result > 0)
 
167
  loadPluginByIndex(result - 1);
 
168
  });
169
  }
170
 
 
173
  auto types = knownPlugins.getTypes();
174
  if (index >= 0 && index < types.size())
175
  {
176
+ const auto& desc = types[index];
177
  juce::File pluginFile(desc.fileOrIdentifier);
178
  processorRef.loadPluginFromFile(pluginFile);
179
  }