forked from qt-creator/qt-creator
FilePath: Return optional bytearray for file contents
For differentiating between "error" and "empty file". Change-Id: I2c019ceac625e7be3180afa4d47ae3a24df91c1d Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -74,7 +74,10 @@ static QJsonDocument readJsonFile(const FilePath &filePath)
|
||||
qCDebug(cmakeFileApi) << "readJsonFile:" << filePath;
|
||||
QTC_ASSERT(!filePath.isEmpty(), return {});
|
||||
|
||||
const QJsonDocument doc = QJsonDocument::fromJson(filePath.fileContents());
|
||||
const std::optional<QByteArray> contents = filePath.fileContents();
|
||||
if (!contents)
|
||||
return {};
|
||||
const QJsonDocument doc = QJsonDocument::fromJson(*contents);
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user