Make QTranslator::load() insist that its return value be checked
Add Q_REQUIRED_RESULT to force callers to check the return; the QTranslator object is unusable if load() fails. Check the result in QTranslator's own test. Task-number: QTBUG-85700 Change-Id: I07509c76470cc87626190670665cd3162bfb17e7 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
a144820ae7
commit
86ebe46f59
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
@ -66,16 +66,17 @@ public:
|
||||
QString language() const;
|
||||
QString filePath() const;
|
||||
|
||||
bool load(const QString & filename,
|
||||
const QString & directory = QString(),
|
||||
const QString & search_delimiters = QString(),
|
||||
const QString & suffix = QString());
|
||||
bool load(const QLocale & locale,
|
||||
const QString & filename,
|
||||
const QString & prefix = QString(),
|
||||
const QString & directory = QString(),
|
||||
const QString & suffix = QString());
|
||||
bool load(const uchar *data, int len, const QString &directory = QString());
|
||||
Q_REQUIRED_RESULT bool load(const QString & filename,
|
||||
const QString & directory = QString(),
|
||||
const QString & search_delimiters = QString(),
|
||||
const QString & suffix = QString());
|
||||
Q_REQUIRED_RESULT bool load(const QLocale & locale,
|
||||
const QString & filename,
|
||||
const QString & prefix = QString(),
|
||||
const QString & directory = QString(),
|
||||
const QString & suffix = QString());
|
||||
Q_REQUIRED_RESULT bool load(const uchar *data, int len,
|
||||
const QString &directory = QString());
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QTranslator)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
@ -284,7 +284,7 @@ void tst_QTranslator::dependencies()
|
||||
{
|
||||
// load
|
||||
QTranslator tor;
|
||||
tor.load("dependencies_la");
|
||||
QVERIFY(tor.load("dependencies_la"));
|
||||
QVERIFY(!tor.isEmpty());
|
||||
QCOMPARE(tor.translate("QPushButton", "Hello world!"), QLatin1String("Hallo Welt!"));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user