MCPcopy Create free account
hub / github.com/LibrePCB/LibrePCB / openMigrationLog

Method openMigrationLog

libs/librepcb/editor/project/projecteditor.cpp:717–749  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

715 ******************************************************************************/
716
717FilePath ProjectEditor::openMigrationLog() noexcept {
718 if (!mMigrationLog) {
719 return FilePath();
720 }
721
722 // Important: Don't store the HTML in /tmp or ~/.cache because if LibrePCB
723 // runs in a sandbox, other apps may not have access to read those
724 // directories. In addition, even though the cache directory is globally
725 // readable by Snap and Flatpak applications, the Firefox and Chromium Snaps
726 // reject to open HTML files from those places. See:
727 // * https://bugs.launchpad.net/snapd/+bug/1972762
728 // * https://askubuntu.com/questions/1370653/snap-apps-dont-find-files-in-tmp
729 // * https://librepcb.discourse.group/t/unable-to-see-messages-from-file-format-upgrade/1036.
730 // So we store the HTML in the project directory instead, but schedule it for
731 // deletion once the project is saved (leading to a new, final migration log).
732 const FilePath fp =
733 mProject->getPath().getPathTo(mMigrationLog->getRelativeFilePath(true));
734 qInfo().nospace() << "Saving project migration log to " << fp.toNative()
735 << "...";
736 try {
737 FileUtils::writeFile(fp, mMigrationLog->toHtml(true));
738 DesktopServices ds(mWorkspace.getSettings());
739 if (!ds.openLocalPath(fp)) {
740 throw RuntimeError(
741 __FILE__, __LINE__,
742 QString("Failed to open the file '%1' with the web browser.")
743 .arg(fp.toNative()));
744 }
745 } catch (const Exception& e) {
746 QMessageBox::critical(qApp->activeWindow(), "Error", e.getMsg());
747 }
748 return fp;
749}
750
751void ProjectEditor::scheduleErcRun() noexcept {
752 mErcTimer.start(mActiveSchematicTabs.isEmpty() ? 1000 : 100);

Callers

nothing calls this directly

Calls 10

RuntimeErrorClass · 0.85
QStringClass · 0.85
getPathMethod · 0.80
getRelativeFilePathMethod · 0.80
toNativeMethod · 0.80
toHtmlMethod · 0.80
getSettingsMethod · 0.80
openLocalPathMethod · 0.80
FilePathClass · 0.50
getPathToMethod · 0.45

Tested by

no test coverage detected