summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-02-09 09:03:17 +0100
committerMarc Mutz <marc.mutz@qt.io>2023-02-15 16:21:53 +0100
commitc889ffed9f4d59c8f7c5849d7b5c8ece729520d0 (patch)
treec0d9e391c3b0691fb2ca203b4bbb86fe8731247f
parent545400addd7935c87ec79596ac3010b4f9016a84 (diff)
downloadqtbase-c889ffed9f4d59c8f7c5849d7b5c8ece729520d0.tar.gz
QTextStream: make dtor non-virtual come Qt 7
There's no reason to treat QTextStream polymorphically: it has no virtual functions other than the dtor. So don't. Removing the vtable is BiC, so we can only do it come Qt 7, but let's warn already, and "deprecate" the virtual'ness (indirectly) by marking the class final as an opt-in. The extra macro beside the class name throws off syncqt, so add a #pragma qt_class. [ChangeLog][Deprecation Notice] Inheriting QTextStream is deprecated. QTextStream will no longer have a virtual destructor in Qt 7. If your code inherits QTextStream, port to a design that doesn't require a polymorphic QTextStream. You may define the macro QT_NO_INHERITABLE_TEXT_STREAM to mark QTextStream as final to assist you in checking for such code. This is the default if you're compiling with QT_DISABLE_DEPRECATED_UP_TO set to Qt 6.9. Fixes: QTBUG-111051 Change-Id: Ib32b8c0e49990d791cdc502bf40cb250f034404b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--src/corelib/serialization/qtextstream.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/corelib/serialization/qtextstream.h b/src/corelib/serialization/qtextstream.h
index b29ba5ba27..11822fc27d 100644
--- a/src/corelib/serialization/qtextstream.h
+++ b/src/corelib/serialization/qtextstream.h
@@ -12,6 +12,11 @@
#include <stdio.h>
+#if 0
+// the macros around the class name throw off syncqt:
+#pragma qt_class(QTextStream)
+#endif
+
#ifdef Status
#error qtextstream.h must be included before any header file that defines Status
#endif
@@ -22,8 +27,18 @@ class QIODevice;
class QLocale;
class QString;
+#if !QT_DEPRECATED_SINCE(6, 9)
+# define QT_NO_INHERITABLE_TEXT_STREAM
+#endif
+
+#ifdef QT_NO_INHERITABLE_TEXT_STREAM
+# define QT_TEXT_STREAM_FINAL final
+#else
+# define QT_TEXT_STREAM_FINAL
+#endif
+
class QTextStreamPrivate;
-class Q_CORE_EXPORT QTextStream : public QIODeviceBase
+class Q_CORE_EXPORT QTextStream QT_TEXT_STREAM_FINAL : public QIODeviceBase
{
Q_DECLARE_PRIVATE(QTextStream)
@@ -60,7 +75,8 @@ public:
explicit QTextStream(QString *string, OpenMode openMode = ReadWrite);
explicit QTextStream(QByteArray *array, OpenMode openMode = ReadWrite);
explicit QTextStream(const QByteArray &array, OpenMode openMode = ReadOnly);
- virtual ~QTextStream();
+ QT6_ONLY(virtual)
+ ~QTextStream();
void setEncoding(QStringConverter::Encoding encoding);
QStringConverter::Encoding encoding() const;