MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / writeProjectFile

Method writeProjectFile

app/src/DataModel/ProjectModel.cpp:7713–7737  ·  view source on GitHub ↗

* @brief Atomically serializes the current project to @p path. */

Source from the content-addressed store, hash-verified

7711 * @brief Atomically serializes the current project to @p path.
7712 */
7713bool DataModel::ProjectModel::writeProjectFile(const QString& path)
7714{
7715 Q_ASSERT(!path.isEmpty());
7716
7717 QSaveFile file(path);
7718 if (!file.open(QFile::WriteOnly)) {
7719 qWarning() << "[ProjectModel] File open error:" << file.errorString();
7720 return false;
7721 }
7722
7723 const QByteArray payload = QJsonDocument(serializeToJson()).toJson(QJsonDocument::Indented);
7724 if (file.write(payload) != payload.size()) {
7725 qWarning() << "[ProjectModel] Short write:" << file.errorString();
7726 file.cancelWriting();
7727 return false;
7728 }
7729
7730 if (!file.commit()) {
7731 qWarning() << "[ProjectModel] Commit failed:" << file.errorString();
7732 return false;
7733 }
7734
7735 watchProjectFile();
7736 return true;
7737}
7738
7739/**
7740 * @brief Returns the SHA-256 of the file at @p path, or an empty array when unreadable.

Callers

nothing calls this directly

Calls 7

isEmptyMethod · 0.80
errorStringMethod · 0.80
commitMethod · 0.80
openMethod · 0.45
toJsonMethod · 0.45
writeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected