From b121ab1e4894ef8e0df5effff3a5e579675f1d40 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 10 Dec 2010 15:33:42 +0100 Subject: refuse to open empty translation files they cause a crash. fixing it properly would be in no reasonable relation to the gain (none whatsoever), so just forbid it. yes, this breaks the message freeze ... big deal in a translation application. ;) Task-number: QTBUG-14574 --- tools/linguist/linguist/messagemodel.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/linguist/linguist/messagemodel.cpp b/tools/linguist/linguist/messagemodel.cpp index 39ba9fd..c2edc75 100644 --- a/tools/linguist/linguist/messagemodel.cpp +++ b/tools/linguist/linguist/messagemodel.cpp @@ -209,6 +209,13 @@ bool DataModel::load(const QString &fileName, bool *langGuessed, QWidget *parent return false; } + if (!tor.messageCount()) { + QMessageBox::warning(parent, QObject::tr("Qt Linguist"), + tr("The translation file '%1' will not be loaded because it is empty.") + .arg(Qt::escape(fileName))); + return false; + } + Translator::Duplicates dupes = tor.resolveDuplicates(); if (!dupes.byId.isEmpty() || !dupes.byContents.isEmpty()) { QString err = tr("Duplicate messages found in '%1':").arg(Qt::escape(fileName)); -- cgit v0.12