MCPcopy Create free account
hub / github.com/MultiMC/Launcher / load

Method load

launcher/minecraft/PackProfile.cpp:272–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270}
271
272bool PackProfile::load()
273{
274 auto filename = componentsFilePath();
275 QFile componentsFile(filename);
276
277 // migrate old config to new one, if needed
278 if(!componentsFile.exists())
279 {
280 if(!migratePreComponentConfig())
281 {
282 // FIXME: the user should be notified...
283 qCritical() << "Failed to convert old pre-component config for instance" << d->m_instance->name();
284 return false;
285 }
286 }
287
288 // load the new component list and swap it with the current one...
289 ComponentContainer newComponents;
290 if(!loadPackProfile(this, filename, patchesPattern(), newComponents))
291 {
292 qCritical() << "Failed to load the component config for instance" << d->m_instance->name();
293 return false;
294 }
295 else
296 {
297 // FIXME: actually use fine-grained updates, not this...
298 beginResetModel();
299 // disconnect all the old components
300 for(auto component: d->components)
301 {
302 disconnect(component.get(), &Component::dataChanged, this, &PackProfile::componentDataChanged);
303 }
304 d->components.clear();
305 d->componentIndex.clear();
306 for(auto component: newComponents)
307 {
308 if(d->componentIndex.contains(component->m_uid))
309 {
310 qWarning() << "Ignoring duplicate component entry" << component->m_uid;
311 continue;
312 }
313 connect(component.get(), &Component::dataChanged, this, &PackProfile::componentDataChanged);
314 d->components.append(component);
315 d->componentIndex[component->m_uid] = component;
316 }
317 endResetModel();
318 d->loaded = true;
319 return true;
320 }
321}
322
323void PackProfile::reload(Net::Mode netmode)
324{

Callers 4

loadComponentFunction · 0.45
loadIndexFunction · 0.45
getVersionFileMethod · 0.45
isVersionChangeableMethod · 0.45

Calls 7

loadPackProfileFunction · 0.85
existsMethod · 0.80
appendMethod · 0.80
nameMethod · 0.45
getMethod · 0.45
clearMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected