BinEditor: Fix crash on editor initialization

MemoryAgent::doCreateBinEditor calls openEditorWithContents, with empty
contents.

The BinEditor fails to handle this case, and crashes when it divides by
zero.

Task-number: QTCREATORBUG-15835
Change-Id: I8009ef991a445ef4cc192d1bda6a208d51e2b48b
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2016-03-08 16:54:12 +02:00
committed by Orgad Shaneh
parent 83e3d954f9
commit 9057143228
2 changed files with 5 additions and 2 deletions

View File

@@ -243,8 +243,10 @@ public:
bool setContents(const QByteArray &contents) override
{
m_widget->clear();
m_widget->setSizes(0, contents.length(), contents.length());
m_widget->addData(0, contents);
if (!contents.isEmpty()) {
m_widget->setSizes(0, contents.length(), contents.length());
m_widget->addData(0, contents);
}
return true;
}