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:
@@ -652,8 +652,16 @@ void LoggingViewManagerWidget::loadAndUpdateFromPreset()
|
||||
if (fp.isEmpty())
|
||||
return;
|
||||
// read file, update categories
|
||||
const std::optional<QByteArray> contents = fp.fileContents();
|
||||
if (!contents) {
|
||||
QMessageBox::critical(ICore::dialogParent(),
|
||||
tr("Error"),
|
||||
tr("Failed to open preset file \"%1\" for reading")
|
||||
.arg(fp.toUserOutput()));
|
||||
return;
|
||||
}
|
||||
QJsonParseError error;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(fp.fileContents(), &error);
|
||||
QJsonDocument doc = QJsonDocument::fromJson(*contents, &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
QMessageBox::critical(ICore::dialogParent(), tr("Error"),
|
||||
tr("Failed to read preset file \"%1\": %2").arg(fp.toUserOutput())
|
||||
|
||||
Reference in New Issue
Block a user