Replace expensive inherits with cheaper qobject_cast (1)

The accessibility implementations require the type to be fully
defined anyway in order to call type-specific APIs, so there's no
need to use inherits(). Use qobject_cast instead.

Change-Id: I5c013be57f48272a748451f4888911fe6aa6574e
Reviewed-by: Pavel Dubsky <pavel.dubsky@qt.io>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
(cherry picked from commit 3973d6c529605fbce8457d7663d244ebadbe7160)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Volker Hilsheimer 2024-04-18 12:02:27 +02:00 committed by Qt Cherry-pick Bot
parent dca3837201
commit eed30ff352

View File

@ -95,7 +95,7 @@ QWidgetList _q_ac_childWidgets(const QWidget *widget)
QAccessiblePlainTextEdit::QAccessiblePlainTextEdit(QWidget* o)
:QAccessibleTextWidget(o)
{
Q_ASSERT(widget()->inherits("QPlainTextEdit"));
Q_ASSERT(qobject_cast<QPlainTextEdit *>(widget()));
}
QPlainTextEdit* QAccessiblePlainTextEdit::plainTextEdit() const
@ -192,7 +192,7 @@ void QAccessiblePlainTextEdit::scrollToSubstring(int startIndex, int endIndex)
QAccessibleTextEdit::QAccessibleTextEdit(QWidget *o)
: QAccessibleTextWidget(o, QAccessible::EditableText)
{
Q_ASSERT(widget()->inherits("QTextEdit"));
Q_ASSERT(qobject_cast<QTextEdit *>(widget()));
}
/*! Returns the text edit. */