| 579 | } |
| 580 | |
| 581 | TopDUContext* TopDUContextDynamicData::load(uint topContextIndex) |
| 582 | { |
| 583 | QFile file(pathForTopContext(topContextIndex)); |
| 584 | if (file.open(QIODevice::ReadOnly)) { |
| 585 | if (file.size() == 0) { |
| 586 | qCWarning(LANGUAGE) << "Top-context file is empty" << file.fileName(); |
| 587 | return nullptr; |
| 588 | } |
| 589 | |
| 590 | uint readValue; |
| 591 | file.read(reinterpret_cast<char*>(&readValue), sizeof(uint)); |
| 592 | //now readValue is filled with the top-context data size |
| 593 | QByteArray topContextData = file.read(readValue); |
| 594 | |
| 595 | auto* topData = reinterpret_cast<DUChainBaseData*>(topContextData.data()); |
| 596 | auto* ret = dynamic_cast<TopDUContext*>(DUChainItemSystem::self().create(topData)); |
| 597 | if (!ret) { |
| 598 | qCWarning(LANGUAGE) << "Cannot load a top-context from file" << file.fileName() << |
| 599 | "- the required language-support for handling ID" << topData->classId << "is probably not loaded"; |
| 600 | return nullptr; |
| 601 | } |
| 602 | |
| 603 | TopDUContextDynamicData& target(*ret->m_dynamicData); |
| 604 | |
| 605 | target.m_data.clear(); |
| 606 | target.m_dataLoaded = false; |
| 607 | target.m_onDisk = true; |
| 608 | ret->rebuildDynamicData(nullptr, topContextIndex); |
| 609 | target.m_topContextData.append({topContextData, ( uint )0}); |
| 610 | return ret; |
| 611 | } else { |
| 612 | return nullptr; |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | bool TopDUContextDynamicData::isOnDisk() const |
| 617 | { |
nothing calls this directly
no test coverage detected