summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-10-11 21:34:20 (GMT)
committerKevin Smith <kevin.smith@isode.com>2016-10-24 08:21:53 (GMT)
commit0e9829ea3b43119b4e60ea2f8eca14a423cb1349 (patch)
treefa2003d2e00130879e36ded996d844b866ddb5e4
parent2a58e24ba8d0a75da353a55583cf16bf32df3c7a (diff)
downloadswift-0e9829ea3b43119b4e60ea2f8eca14a423cb1349.zip
swift-0e9829ea3b43119b4e60ea2f8eca14a423cb1349.tar.bz2
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
-rw-r--r--Swift/QtUI/QtAboutWidget.cpp23
1 files changed, 15 insertions, 8 deletions
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 <QVBoxLayout>
#include <QtGlobal>
+#include <Swiften/Base/Log.h>
#include <Swiften/Base/Platform.h>
+#include <Swift/QtUI/QtSwiftUtil.h>
+
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;
+ }
}
}