summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2014-11-13 08:19:10 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2014-11-13 08:33:38 +0100
commite123f5a4d9ec164073d75fd926acadd9d4b2243b (patch)
tree594966b595af10d6ca109a5bf9a8e652750ff9de
parente01496122d6033ec7bd5e72922f275ae028b042c (diff)
downloadqt-creator-e123f5a4d9ec164073d75fd926acadd9d4b2243b.tar.gz
Limit length of file names in DiffEditorDocument::suggestedFileName().
Change-Id: I168831b24bcece5ef825825c448edf684f4f536d Reviewed-by: Orgad Shaneh <orgads@gmail.com>
-rw-r--r--src/plugins/diffeditor/diffeditordocument.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/plugins/diffeditor/diffeditordocument.cpp b/src/plugins/diffeditor/diffeditordocument.cpp
index 470652aa2c..eb52c03a1c 100644
--- a/src/plugins/diffeditor/diffeditordocument.cpp
+++ b/src/plugins/diffeditor/diffeditordocument.cpp
@@ -129,6 +129,7 @@ bool DiffEditorDocument::open(QString *errorString, const QString &fileName)
QString DiffEditorDocument::suggestedFileName() const
{
+ enum { maxSubjectLength = 50 };
QString result = QStringLiteral("0001");
const QString description = m_controller->description();
if (!description.isEmpty()) {
@@ -144,6 +145,10 @@ QString DiffEditorDocument::suggestedFileName() const
subject[i] = space;
}
subject = subject.simplified();
+ if (subject.size() > maxSubjectLength) {
+ const int lastSpace = subject.lastIndexOf(space, maxSubjectLength);
+ subject.truncate(lastSpace > 0 ? lastSpace : maxSubjectLength);
+ }
subject.replace(space, dash);
result += dash;
result += subject;