MCPcopy Create free account
hub / github.com/audacity/audacity / ApplyChanges

Method ApplyChanges

src/PluginDataModel.cpp:171–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169}
170
171void PluginDataModel::ApplyChanges(const std::function<bool(int, int, const wxString&)>& progressUpdateFn,
172 const std::function<void(const TranslatableString&)>& errorFn)
173{
174 auto& mm = ModuleManager::Get();
175 auto& pm = PluginManager::Get();
176
177 const auto enableCount = std::count_if(
178 mPluginStateModel.begin(),
179 mPluginStateModel.end(),
180 [](const auto& p) { return p.first->GetPluginType() == PluginTypeStub && p.second; }
181 );
182
183 auto counter = 0;
184 for(const auto& [desc, enabled] : mPluginStateModel)
185 {
186 if(desc->GetPluginType() == PluginTypeStub && enabled)
187 {
188 if(progressUpdateFn)
189 {
190 if(!progressUpdateFn(++counter, enableCount, desc->GetPath()))
191 break;
192 }
193
194 TranslatableString errMsg;
195 if (mm.RegisterEffectPlugin(desc->GetProviderID(), desc->GetPath(), errMsg))
196 pm.UnregisterPlugin(desc->GetProviderID() + wxT("_") + desc->GetPath());
197 else if (errorFn)
198 {
199 errorFn(XO("Effect or Command at %s failed to register:\n%s")
200 .Format( desc->GetPath(), !errMsg.empty() ? errMsg : XO("Unknown error") ));
201 }
202 }
203 else
204 desc->SetEnabled(enabled);
205 }
206 pm.Save();
207 pm.NotifyPluginsChanged();
208}
209
210unsigned PluginDataModel::GetColumnCount() const
211{

Callers 1

OnOKMethod · 0.80

Calls 11

GetFunction · 0.85
GetPluginTypeMethod · 0.80
RegisterEffectPluginMethod · 0.80
UnregisterPluginMethod · 0.80
NotifyPluginsChangedMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
GetPathMethod · 0.45
emptyMethod · 0.45
SetEnabledMethod · 0.45
SaveMethod · 0.45

Tested by

no test coverage detected