From 18cff29d8f9e4649554e1694d7297bfca1b3ffd3 Mon Sep 17 00:00:00 2001
From: hjk <qthjk@ovi.com>
Date: Thu, 27 Sep 2012 14:04:15 +0200
Subject: [PATCH] bineditor: don't crash when no error string is requested

Task-number: QTCREATORBUG-7930
Change-Id: Ia3b2a21d843ce9de7f61f754da0b276355c377f2
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
---
 src/plugins/bineditor/bineditorplugin.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp
index 7b5d5f8a743..9a14b2da299 100644
--- a/src/plugins/bineditor/bineditorplugin.cpp
+++ b/src/plugins/bineditor/bineditorplugin.cpp
@@ -223,7 +223,11 @@ public:
     bool open(QString *errorString, const QString &fileName, quint64 offset = 0) {
         QFile file(fileName);
         if (offset >= static_cast<quint64>(file.size())) {
-            *errorString = tr("The Binary Editor can not open empty files.");
+            QString msg = tr("The Binary Editor can not open empty files.");
+            if (errorString)
+                *errorString = msg;
+            else
+                QMessageBox::critical(Core::ICore::mainWindow(), tr("File Error"), msg);
             return false;
         }
         if (file.open(QIODevice::ReadOnly)) {
-- 
GitLab