| 169 | } |
| 170 | |
| 171 | void 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 | |
| 210 | unsigned PluginDataModel::GetColumnCount() const |
| 211 | { |
no test coverage detected