From cf09ac882c25cc6d40ea1caf73f8fb538784c6fb Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 25 Nov 2014 11:52:31 +0100 Subject: [PATCH] Perforce: Don't crash on large log output Change-Id: I3766d20f5faaa01f38418cdfdcc4977cf9189fc7 Reviewed-by: Cristian Adam Reviewed-by: hjk --- src/plugins/perforce/perforceplugin.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index 5525e95db34..61c8802cd04 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -1184,7 +1184,15 @@ IEditor *PerforcePlugin::showOutputInEditor(const QString &title, qDebug() << "PerforcePlugin::showOutputInEditor" << title << id.name() << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec); QString s = title; - IEditor *editor = EditorManager::openEditorWithContents(id, &s, output.toUtf8()); + QString content = output; + const int maxSize = EditorManager::maxTextFileSize() - 1000; + if (content.size() >= maxSize) { + content = tr("[Only %1 MB of output shown]").arg(maxSize / 1024 / 1024) + QLatin1Char('\n') + + content.rightRef(maxSize); + + } + IEditor *editor = EditorManager::openEditorWithContents(id, &s, content.toUtf8()); + QTC_ASSERT(editor, return 0); connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)), this, SLOT(vcsAnnotate(QString,QString,QString,int))); PerforceEditorWidget *e = qobject_cast(editor->widget());