From 1d63431abb0f46503768b3159a8f2e616b5f522a Mon Sep 17 00:00:00 2001 From: kh1 Date: Mon, 25 Mar 2013 15:29:46 +0100 Subject: Throw if we can't load the requested UI file. Change-Id: Iced4d4649a386a18efabe80dc094461e7b1b1a74 Reviewed-by: Niels Weber Reviewed-by: Tim Jenssen --- src/libs/installer/component.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index 78d4eb68b..76c7d6ef3 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -455,7 +455,7 @@ void Component::loadTranslations(const QDir &directory, const QStringList &qms) QScopedPointer translator(new QTranslator(this)); if (!translator->load(filename)) - throw Error(tr("Could not open the requested translation file at %1").arg(filename)); + throw Error(tr("Could not open the requested translation file '%1'.").arg(filename)); qApp->installTranslator(translator.take()); } } @@ -479,15 +479,23 @@ void Component::loadUserInterfaces(const QDir &directory, const QStringList &uis while (it.hasNext()) { QFile file(it.next()); if (!file.open(QIODevice::ReadOnly)) { - throw Error(tr("Could not open the requested UI file at %1: %2").arg(it.fileName(), + throw Error(tr("Could not open the requested UI file '%1'. Error: %2").arg(it.fileName(), file.errorString())); } static QUiLoader loader; loader.setTranslationEnabled(true); loader.setLanguageChangeEnabled(true); - QWidget *const w = loader.load(&file, MessageBoxHandler::currentBestSuitParent()); - d->m_userInterfaces.insert(w->objectName(), w); + QWidget *const widget = loader.load(&file, MessageBoxHandler::currentBestSuitParent()); + if (!widget) { + throw Error(tr("Could not load the requested UI file '%1'. Error: %2").arg(it.fileName(), +#if QT_VERSION < 0x050000 + tr("An error has occurred while reading the UI file."))); +#else + loader.errorString())); +#endif + } + d->m_userInterfaces.insert(widget->objectName(), widget); } } @@ -512,7 +520,7 @@ void Component::loadLicenses(const QString &directory, const QHash