From 0e9829ea3b43119b4e60ea2f8eca14a423cb1349 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Tue, 11 Oct 2016 23:34:20 +0200 Subject: Add missing check of QFile::open return value in about dialog Test-Information: Build successfully with Qt 5.6.1 on macOS 10.12 and opening about dialog, license window and change log window still works. Change-Id: I4a91b41f3848ee8049c179598b1b8e498d8ed35d diff --git a/Swift/QtUI/QtAboutWidget.cpp b/Swift/QtUI/QtAboutWidget.cpp index 2fc8bae..d90e35a 100644 --- a/Swift/QtUI/QtAboutWidget.cpp +++ b/Swift/QtUI/QtAboutWidget.cpp @@ -16,8 +16,11 @@ #include #include +#include #include +#include + namespace Swift { QtAboutWidget::QtAboutWidget() : QDialog() { @@ -91,14 +94,18 @@ void QtAboutWidget::openPlainTextWindow(const QString& path) { text->setAttribute(Qt::WA_DeleteOnClose); text->setReadOnly(true); QFile file(path); - file.open(QIODevice::ReadOnly); - QTextStream in(&file); - in.setCodec("UTF-8"); - text->setPlainText(in.readAll()); - file.close(); - text->resize(500, 600); - text->show(); - text->activateWindow(); + if (file.open(QIODevice::ReadOnly)) { + QTextStream in(&file); + in.setCodec("UTF-8"); + text->setPlainText(in.readAll()); + file.close(); + text->resize(500, 600); + text->show(); + text->activateWindow(); + } + else { + SWIFT_LOG(error) << "Failed to open " << Q2PSTRING(path) << "." << std::endl; + } } } -- cgit v0.10.2-6-g49f6