ifcviewer: key sidecar on path stem, drop staleness check

Previously readSidecar/writeSidecar were keyed on (path, file_size) with
staleness rejected at read time.  Switch to pure path-stem keying: foo.ifc
and foo.ifcdb/ both resolve to foo.ifcview, so the same cache serves either
source format.  Staleness is user-managed (delete the sidecar to force a
rebuild), which also lets sidecars be copied or moved independently of the
source.

v8 header drops the source_file_size field.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Dion Moult
2026-04-22 11:58:04 +10:00
parent f898089b27
commit 4f929e90a7
6 changed files with 36 additions and 40 deletions
+2 -9
View File
@@ -54,12 +54,6 @@ QString SceneLoader::displayName(uint32_t mid) const {
return it == models_.end() ? QString() : it->second.display_name;
}
uint64_t SceneLoader::fileSize(uint32_t mid) const {
auto it = models_.find(mid);
if (it == models_.end()) return 0;
return static_cast<uint64_t>(QFileInfo(it->second.file_path).size());
}
ifcopenshell::file* SceneLoader::ifcFile(uint32_t mid) const {
auto it = models_.find(mid);
return it == models_.end() ? nullptr : it->second.streamer->ifcFile();
@@ -124,14 +118,13 @@ void SceneLoader::startNextLoad() {
emit loadStarted(model.id, model.display_name);
std::string ifc_path = model.file_path.toStdString();
uint64_t file_size = this->fileSize(model.id);
uint32_t mid = loading_model_id_;
// Sidecar read on a background thread so the UI stays responsive.
joinSidecarThread();
sidecar_read_thread_ = std::thread([this, ifc_path, file_size, mid]() {
sidecar_read_thread_ = std::thread([this, ifc_path, mid]() {
QElapsedTimer rt; rt.start();
auto cached = readSidecar(ifc_path, file_size);
auto cached = readSidecar(ifc_path);
qDebug(" Sidecar read: %lld ms (%s)", rt.elapsed(), ifc_path.c_str());
auto result = std::make_shared<std::optional<SidecarData>>(std::move(cached));
QMetaObject::invokeMethod(this, [this, mid, result]() {