From a21dfab54ed518266c42d3e87e02bd991de8486e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 1 Jun 2015 00:22:35 +0200 Subject: [PATCH] De-duplicate vtables III: QAccessible By making the destructor (usually the first non-inline, non-pure, virtual function, and therefore the trigger for most compilers to emit the vtable and type_info structures for the class in that TU) out-of-line, vtables and, more importantly, type_info strucures for the class are pinned to a single TU. This prevents false negative dynamic_cast and catch evaluation. In this third batch, we de-inline dtors of exported public classes from the QAccessible subsytem. Since they are already exported, users of these classes are unaffected by the change, but since it's public API, and the dtors may have been de-virtualized and inlined into application code, we need to avoid adding code to the out-of-line dtor until Qt 6. Change-Id: I5324bd1b3b9210a3ac5cf4eee9317a34e4a3b048 Reported-by: Volker Krause Task-number: QTBUG-45582 Reviewed-by: Thiago Macieira --- src/gui/accessible/qaccessible.cpp | 111 ++++++++++++++++++++++++++--- src/gui/accessible/qaccessible.h | 36 +++++++--- 2 files changed, 127 insertions(+), 20 deletions(-) diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 36492def68..f2a30e5a18 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -609,6 +609,11 @@ QAccessible::RootObjectHandler QAccessible::installRootObjectHandler(RootObjectH \sa installActivationObserver() */ +QAccessible::ActivationObserver::~ActivationObserver() +{ + // must be empty until ### Qt 6 +} + /*! \internal @@ -1326,9 +1331,13 @@ QColor QAccessibleInterface::backgroundColor() const the overload taking a \l QObject parameter as it might be cheaper. */ -/*! \fn QAccessibleEvent::~QAccessibleEvent() +/*! Destroys the event. */ +QAccessibleEvent::~QAccessibleEvent() +{ + // must be empty until ### Qt 6 +} /*! \fn QAccessible::Event QAccessibleEvent::type() const Returns the event type. @@ -1389,6 +1398,13 @@ QAccessible::Id QAccessibleEvent::uniqueId() const Returns the new value of the accessible object of this event. */ +/*! + \internal +*/ +QAccessibleValueChangeEvent::~QAccessibleValueChangeEvent() +{ + // must be empty until ### Qt 6 +} /*! \class QAccessibleStateChangeEvent @@ -1418,7 +1434,13 @@ QAccessible::Id QAccessibleEvent::uniqueId() const other hand tells about the change and has focused set to \c true since the focus state is changed from \c true to \c false. */ - +/*! + \internal +*/ +QAccessibleStateChangeEvent::~QAccessibleStateChangeEvent() +{ + // must be empty until ### Qt 6 +} /*! \class QAccessibleTableModelChangeEvent @@ -1475,6 +1497,13 @@ QAccessible::Id QAccessibleEvent::uniqueId() const /*! \fn void QAccessibleTableModelChangeEvent::setModelChangeType(ModelChangeType changeType) Sets the type of change to \a changeType. */ +/*! + \internal +*/ +QAccessibleTableModelChangeEvent::~QAccessibleTableModelChangeEvent() +{ + // must be empty until ### Qt 6 +} /*! @@ -1496,6 +1525,14 @@ QAccessible::Id QAccessibleEvent::uniqueId() const /*! \fn void QAccessibleTextCursorEvent::setCursorPosition(int position) Sets the cursor \a position for this event. */ +/*! + \internal +*/ +QAccessibleTextCursorEvent::~QAccessibleTextCursorEvent() +{ + // must be empty until ### Qt 6 +} + /*! \class QAccessibleTextInsertEvent @@ -1519,6 +1556,14 @@ QAccessible::Id QAccessibleEvent::uniqueId() const /*! \fn QString QAccessibleTextInsertEvent::textInserted() const Returns the text that has been inserted. */ +/*! + \internal +*/ +QAccessibleTextInsertEvent::~QAccessibleTextInsertEvent() +{ + // must be empty until ### Qt 6 +} + /*! \class QAccessibleTextRemoveEvent @@ -1543,6 +1588,13 @@ QAccessible::Id QAccessibleEvent::uniqueId() const /*! \fn QString QAccessibleTextRemoveEvent::textRemoved() const Returns the text that has been removed. */ +/*! + \internal +*/ +QAccessibleTextRemoveEvent::~QAccessibleTextRemoveEvent() +{ + // must be empty until ### Qt 6 +} /*! \class QAccessibleTextUpdateEvent @@ -1569,6 +1621,14 @@ QAccessible::Id QAccessibleEvent::uniqueId() const /*! \fn QString QAccessibleTextUpdateEvent::textRemoved() const Returns the removed text. */ +/*! + \internal +*/ +QAccessibleTextUpdateEvent::~QAccessibleTextUpdateEvent() +{ + // must be empty until ### Qt 6 +} + /*! \class QAccessibleTextSelectionEvent @@ -1592,6 +1652,13 @@ QAccessible::Id QAccessibleEvent::uniqueId() const /*! \fn void QAccessibleTextSelectionEvent::setSelection(int start, int end) Sets the selection for this event from position \a start to \a end. */ +/*! + \internal +*/ +QAccessibleTextSelectionEvent::~QAccessibleTextSelectionEvent() +{ + // must be empty until ### Qt 6 +} @@ -1830,9 +1897,12 @@ QDebug operator<<(QDebug d, const QAccessibleEvent &ev) */ /*! - \fn QAccessibleTextInterface::~QAccessibleTextInterface() Destroys the QAccessibleTextInterface. */ +QAccessibleTextInterface::~QAccessibleTextInterface() +{ + // must be empty until ### Qt 6 +} /*! \fn void QAccessibleTextInterface::addSelection(int startOffset, int endOffset) @@ -2212,9 +2282,12 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun */ /*! - \fn QAccessibleEditableTextInterface::~QAccessibleEditableTextInterface() Destroys the QAccessibleEditableTextInterface. */ +QAccessibleEditableTextInterface::~QAccessibleEditableTextInterface() +{ + // must be empty until ### Qt 6 +} /*! \fn void QAccessibleEditableTextInterface::deleteText(int startOffset, int endOffset) @@ -2253,9 +2326,12 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun */ /*! - \fn QAccessibleValueInterface::~QAccessibleValueInterface() - Destructor. + Destroys the QAccessibleValueInterface. */ +QAccessibleValueInterface::~QAccessibleValueInterface() +{ + // must be empty until ### Qt 6 +} /*! \fn QVariant QAccessibleValueInterface::currentValue() const @@ -2313,6 +2389,14 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun \l{IAccessible2 Specification} */ +/*! + Destroys the QAccessibleImageInterface. +*/ +QAccessibleImageInterface::~QAccessibleImageInterface() +{ + // must be empty until ### Qt 6 +} + /*! \class QAccessibleTableCellInterface \inmodule QtGui @@ -2325,9 +2409,12 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun */ /*! - \fn virtual QAccessibleTableCellInterface::~QAccessibleTableCellInterface() Destroys the QAccessibleTableCellInterface. */ +QAccessibleTableCellInterface::~QAccessibleTableCellInterface() +{ + // must be empty until ### Qt 6 +} /*! \fn virtual int QAccessibleTableCellInterface::columnExtent() const @@ -2381,9 +2468,12 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun */ /*! - \fn virtual QAccessibleTableInterface::~QAccessibleTableInterface() Destroys the QAccessibleTableInterface. */ +QAccessibleTableInterface::~QAccessibleTableInterface() +{ + // must be empty until ### Qt 6 +} /*! \fn virtual QAccessibleInterface *QAccessibleTableInterface::cellAt(int row, int column) const @@ -2534,9 +2624,12 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun */ /*! - \fn QAccessibleActionInterface::~QAccessibleActionInterface() Destroys the QAccessibleActionInterface. */ +QAccessibleActionInterface::~QAccessibleActionInterface() +{ + // must be empty until ### Qt 6 +} /*! \fn QStringList QAccessibleActionInterface::actionNames() const diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h index faa8cd719d..66cd067ace 100644 --- a/src/gui/accessible/qaccessible.h +++ b/src/gui/accessible/qaccessible.h @@ -399,7 +399,7 @@ public: class ActivationObserver { public: - virtual ~ActivationObserver() {} + virtual ~ActivationObserver(); virtual void accessibilityActiveChanged(bool active) = 0; }; static void installActivationObserver(ActivationObserver *); @@ -514,7 +514,7 @@ protected: class Q_GUI_EXPORT QAccessibleTextInterface { public: - virtual ~QAccessibleTextInterface() {} + virtual ~QAccessibleTextInterface(); // selection virtual void selection(int selectionIndex, int *startOffset, int *endOffset) const = 0; virtual int selectionCount() const = 0; @@ -547,7 +547,7 @@ public: class Q_GUI_EXPORT QAccessibleEditableTextInterface { public: - virtual ~QAccessibleEditableTextInterface() {} + virtual ~QAccessibleEditableTextInterface(); virtual void deleteText(int startOffset, int endOffset) = 0; virtual void insertText(int offset, const QString &text) = 0; @@ -557,8 +557,7 @@ public: class Q_GUI_EXPORT QAccessibleValueInterface { public: - - virtual ~QAccessibleValueInterface() {} + virtual ~QAccessibleValueInterface(); virtual QVariant currentValue() const = 0; virtual void setCurrentValue(const QVariant &value) = 0; @@ -570,7 +569,7 @@ public: class Q_GUI_EXPORT QAccessibleTableCellInterface { public: - virtual ~QAccessibleTableCellInterface() {} + virtual ~QAccessibleTableCellInterface(); virtual bool isSelected() const = 0; @@ -587,7 +586,7 @@ public: class Q_GUI_EXPORT QAccessibleTableInterface { public: - virtual ~QAccessibleTableInterface() {} + virtual ~QAccessibleTableInterface(); virtual QAccessibleInterface *caption() const = 0; virtual QAccessibleInterface *summary() const = 0; @@ -622,7 +621,7 @@ class Q_GUI_EXPORT QAccessibleActionInterface { Q_DECLARE_TR_FUNCTIONS(QAccessibleActionInterface) public: - virtual ~QAccessibleActionInterface() {} + virtual ~QAccessibleActionInterface(); virtual QStringList actionNames() const = 0; virtual QString localizedActionName(const QString &name) const; @@ -647,7 +646,7 @@ public: class Q_GUI_EXPORT QAccessibleImageInterface { public: - virtual ~QAccessibleImageInterface() {} + virtual ~QAccessibleImageInterface(); virtual QString imageDescription() const = 0; virtual QSize imageSize() const = 0; @@ -691,8 +690,7 @@ public: m_uniqueId = QAccessible::uniqueId(iface); } - virtual ~QAccessibleEvent() - {} + virtual ~QAccessibleEvent(); QAccessible::Event type() const { return m_type; } QObject *object() const { return m_object; } @@ -726,6 +724,7 @@ public: { m_type = QAccessible::StateChanged; } + ~QAccessibleStateChangeEvent(); QAccessible::State changedStates() const { return m_changedStates; @@ -752,6 +751,8 @@ public: m_type = QAccessible::TextCaretMoved; } + ~QAccessibleTextCursorEvent(); + void setCursorPosition(int position) { m_cursorPosition = position; } int cursorPosition() const { return m_cursorPosition; } @@ -776,6 +777,8 @@ public: m_type = QAccessible::TextSelectionChanged; } + ~QAccessibleTextSelectionEvent(); + void setSelection(int start, int end) { m_selectionStart = start; m_selectionEnd = end; @@ -805,6 +808,8 @@ public: m_type = QAccessible::TextInserted; } + ~QAccessibleTextInsertEvent(); + QString textInserted() const { return m_text; } @@ -833,6 +838,8 @@ public: m_type = QAccessible::TextRemoved; } + ~QAccessibleTextRemoveEvent(); + QString textRemoved() const { return m_text; } @@ -860,6 +867,9 @@ public: { m_type = QAccessible::TextUpdated; } + + ~QAccessibleTextUpdateEvent(); + QString textRemoved() const { return m_oldText; } @@ -892,6 +902,8 @@ public: m_type = QAccessible::ValueChanged; } + ~QAccessibleValueChangeEvent(); + void setValue(const QVariant & val) { m_value= val; } QVariant value() const { return m_value; } @@ -926,6 +938,8 @@ public: m_type = QAccessible::TableModelChanged; } + ~QAccessibleTableModelChangeEvent(); + void setModelChangeType(ModelChangeType changeType) { m_modelChangeType = changeType; } ModelChangeType modelChangeType() const { return m_modelChangeType; }