diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/image/qimage.cpp | 72 | ||||
-rw-r--r-- | src/gui/image/qimage_conversions.cpp | 58 | ||||
-rw-r--r-- | src/gui/image/qimage_p.h | 33 | ||||
-rw-r--r-- | src/gui/image/qpnghandler.cpp | 1 | ||||
-rw-r--r-- | src/gui/kernel/qclipboard.cpp | 8 | ||||
-rw-r--r-- | src/gui/kernel/qevent.cpp | 1 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 3 | ||||
-rw-r--r-- | src/gui/kernel/qsimpledrag.cpp | 1 | ||||
-rw-r--r-- | src/gui/kernel/qsurfaceformat.cpp | 3 | ||||
-rw-r--r-- | src/gui/kernel/qt_gui_pch.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.cpp | 3 | ||||
-rw-r--r-- | src/gui/opengl/qopenglvertexarrayobject.cpp | 33 | ||||
-rw-r--r-- | src/gui/painting/qplatformbackingstore.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qsyntaxhighlighter.cpp | 10 | ||||
-rw-r--r-- | src/gui/text/qtextdocument.cpp | 4 | ||||
-rw-r--r-- | src/gui/text/qtextdocument.h | 2 | ||||
-rw-r--r-- | src/gui/text/qtextdocumentfragment.cpp | 1 | ||||
-rw-r--r-- | src/gui/text/qtextdocumentwriter.cpp | 16 | ||||
-rw-r--r-- | src/gui/text/qtextdocumentwriter.h | 2 | ||||
-rw-r--r-- | src/gui/text/qtexthtmlparser.cpp | 1 | ||||
-rw-r--r-- | src/gui/text/qtextodfwriter.cpp | 2 |
21 files changed, 150 insertions, 108 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 421362dd9e..0105f1decd 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -118,21 +118,14 @@ QImageData::QImageData() QImageData * QImageData::create(const QSize &size, QImage::Format format) { if (!size.isValid() || format == QImage::Format_Invalid) - return 0; // invalid parameter(s) + return nullptr; // invalid parameter(s) - uint width = size.width(); - uint height = size.height(); - uint depth = qt_depthForFormat(format); - - const int bytes_per_line = ((width * depth + 31) >> 5) << 2; // bytes per scanline (must be multiple of 4) - - // sanity check for potential overflows - if (std::numeric_limits<int>::max()/depth < width - || bytes_per_line <= 0 - || height <= 0 - || std::numeric_limits<qsizetype>::max()/uint(bytes_per_line) < height - || std::numeric_limits<int>::max()/sizeof(uchar *) < uint(height)) - return 0; + int width = size.width(); + int height = size.height(); + int depth = qt_depthForFormat(format); + auto params = calculateImageParameters(width, height, depth); + if (params.bytesPerLine < 0) + return nullptr; QScopedPointer<QImageData> d(new QImageData); @@ -154,18 +147,15 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format) d->has_alpha_clut = false; d->is_cached = false; - d->bytes_per_line = bytes_per_line; - - d->nbytes = d->bytes_per_line*height; + d->bytes_per_line = params.bytesPerLine; + d->nbytes = params.totalSize; d->data = (uchar *)malloc(d->nbytes); - if (!d->data) { - return 0; - } + if (!d->data) + return nullptr; d->ref.ref(); return d.take(); - } QImageData::~QImageData() @@ -786,27 +776,27 @@ QImage::QImage(const QSize &size, Format format) QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QImage::Format format, bool readOnly, QImageCleanupFunction cleanupFunction, void *cleanupInfo) { - QImageData *d = 0; - - if (format == QImage::Format_Invalid) - return d; + if (width <= 0 || height <= 0 || !data || format == QImage::Format_Invalid) + return nullptr; const int depth = qt_depthForFormat(format); - const int calc_bytes_per_line = ((width * depth + 31)/32) * 4; - const int min_bytes_per_line = (width * depth + 7)/8; - - if (bpl <= 0) - bpl = calc_bytes_per_line; - - if (width <= 0 || height <= 0 || !data - || INT_MAX/sizeof(uchar *) < uint(height) - || INT_MAX/uint(depth) < uint(width) - || bpl <= 0 - || bpl < min_bytes_per_line - || INT_MAX/uint(bpl) < uint(height)) - return d; // invalid parameter(s) + auto params = calculateImageParameters(width, height, depth); + if (params.totalSize < 0) + return nullptr; + + if (bpl > 0) { + // can't overflow, because has calculateImageParameters already done this multiplication + const int min_bytes_per_line = (width * depth + 7)/8; + if (bpl < min_bytes_per_line) + return nullptr; + + // recalculate the total with this value + params.bytesPerLine = bpl; + if (mul_overflow<qsizetype>(bpl, height, ¶ms.totalSize)) + return nullptr; + } - d = new QImageData; + QImageData *d = new QImageData; d->ref.ref(); d->own_data = false; @@ -817,8 +807,8 @@ QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QIm d->depth = depth; d->format = format; - d->bytes_per_line = bpl; - d->nbytes = d->bytes_per_line * height; + d->bytes_per_line = params.bytesPerLine; + d->nbytes = params.totalSize; d->cleanupFunction = cleanupFunction; d->cleanupInfo = cleanupInfo; diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 964dc0d5c6..215dd33499 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -817,10 +817,10 @@ static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConve Q_ASSERT(data->own_data); const int depth = 32; - - const qsizetype dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; - const qsizetype nbytes = dst_bytes_per_line * data->height; - uchar *const newData = (uchar *)realloc(data->data, nbytes); + auto params = QImageData::calculateImageParameters(data->width, data->height, depth); + if (params.bytesPerLine < 0) + return false; + uchar *const newData = (uchar *)realloc(data->data, params.totalSize); if (!newData) return false; @@ -828,10 +828,10 @@ static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConve // start converting from the end because the end image is bigger than the source uchar *src_data = newData + data->nbytes; // end of src - quint32 *dest_data = (quint32 *) (newData + nbytes); // end of dest > end of src + quint32 *dest_data = (quint32 *) (newData + params.totalSize); // end of dest > end of src const int width = data->width; const int src_pad = data->bytes_per_line - width; - const int dest_pad = (dst_bytes_per_line >> 2) - width; + const int dest_pad = (params.bytesPerLine >> 2) - width; if (data->colortable.size() == 0) { data->colortable.resize(256); for (int i = 0; i < 256; ++i) @@ -858,9 +858,9 @@ static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConve data->colortable = QVector<QRgb>(); data->format = QImage::Format_ARGB32_Premultiplied; - data->bytes_per_line = dst_bytes_per_line; + data->bytes_per_line = params.bytesPerLine; data->depth = depth; - data->nbytes = nbytes; + data->nbytes = params.totalSize; return true; } @@ -871,10 +871,10 @@ static bool convert_indexed8_to_ARGB_inplace(QImageData *data, Qt::ImageConversi Q_ASSERT(data->own_data); const int depth = 32; - - const qsizetype dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; - const qsizetype nbytes = dst_bytes_per_line * data->height; - uchar *const newData = (uchar *)realloc(data->data, nbytes); + auto params = QImageData::calculateImageParameters(data->width, data->height, depth); + if (params.bytesPerLine < 0) + return false; + uchar *const newData = (uchar *)realloc(data->data, params.totalSize); if (!newData) return false; @@ -882,10 +882,10 @@ static bool convert_indexed8_to_ARGB_inplace(QImageData *data, Qt::ImageConversi // start converting from the end because the end image is bigger than the source uchar *src_data = newData + data->nbytes; - quint32 *dest_data = (quint32 *) (newData + nbytes); + quint32 *dest_data = (quint32 *) (newData + params.totalSize); const int width = data->width; const int src_pad = data->bytes_per_line - width; - const int dest_pad = (dst_bytes_per_line >> 2) - width; + const int dest_pad = (params.bytesPerLine >> 2) - width; if (data->colortable.size() == 0) { data->colortable.resize(256); for (int i = 0; i < 256; ++i) @@ -909,9 +909,9 @@ static bool convert_indexed8_to_ARGB_inplace(QImageData *data, Qt::ImageConversi data->colortable = QVector<QRgb>(); data->format = QImage::Format_ARGB32; - data->bytes_per_line = dst_bytes_per_line; + data->bytes_per_line = params.bytesPerLine; data->depth = depth; - data->nbytes = nbytes; + data->nbytes = params.totalSize; return true; } @@ -939,10 +939,10 @@ static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConvers Q_ASSERT(data->own_data); const int depth = 16; - - const qsizetype dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; - const qsizetype nbytes = dst_bytes_per_line * data->height; - uchar *const newData = (uchar *)realloc(data->data, nbytes); + auto params = QImageData::calculateImageParameters(data->width, data->height, depth); + if (params.bytesPerLine < 0) + return false; + uchar *const newData = (uchar *)realloc(data->data, params.totalSize); if (!newData) return false; @@ -950,10 +950,10 @@ static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConvers // start converting from the end because the end image is bigger than the source uchar *src_data = newData + data->nbytes; - quint16 *dest_data = (quint16 *) (newData + nbytes); + quint16 *dest_data = (quint16 *) (newData + params.totalSize); const int width = data->width; const int src_pad = data->bytes_per_line - width; - const int dest_pad = (dst_bytes_per_line >> 1) - width; + const int dest_pad = (params.bytesPerLine >> 1) - width; quint16 colorTableRGB16[256]; const int tableSize = data->colortable.size(); @@ -983,9 +983,9 @@ static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConvers } data->format = QImage::Format_RGB16; - data->bytes_per_line = dst_bytes_per_line; + data->bytes_per_line = params.bytesPerLine; data->depth = depth; - data->nbytes = nbytes; + data->nbytes = params.totalSize; return true; } @@ -997,6 +997,7 @@ static bool convert_RGB_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFl const int depth = 16; + // cannot overflow, since we're shrinking the buffer const qsizetype dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; const qsizetype src_bytes_per_line = data->bytes_per_line; quint32 *src_data = (quint32 *) data->data; @@ -1013,12 +1014,11 @@ static bool convert_RGB_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFl data->depth = depth; data->nbytes = dst_bytes_per_line * data->height; uchar *const newData = (uchar *)realloc(data->data, data->nbytes); - if (newData) { + if (newData) data->data = newData; - return true; - } else { - return false; - } + + // can't fail, since we're shrinking + return true; } static void convert_ARGB_PM_to_ARGB(QImageData *dest, const QImageData *src) diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index 2fe29a88d3..e3a6c53833 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -52,6 +52,7 @@ // #include <QtGui/private/qtguiglobal_p.h> +#include <QtCore/private/qnumeric_p.h> #include <QMap> #include <QVector> @@ -104,8 +105,40 @@ struct Q_GUI_EXPORT QImageData { // internal image data bool doImageIO(const QImage *image, QImageWriter* io, int quality) const; QPaintEngine *paintEngine; + + struct ImageSizeParameters { + qsizetype bytesPerLine; + qsizetype totalSize; + }; + static ImageSizeParameters calculateImageParameters(qsizetype width, qsizetype height, qsizetype depth); }; +inline QImageData::ImageSizeParameters +QImageData::calculateImageParameters(qsizetype width, qsizetype height, qsizetype depth) +{ + ImageSizeParameters invalid = { -1, -1 }; + if (height <= 0) + return invalid; + + // calculate the size, taking care of overflows + qsizetype bytes_per_line; + if (mul_overflow(width, depth, &bytes_per_line)) + return invalid; + if (add_overflow(bytes_per_line, qsizetype(31), &bytes_per_line)) + return invalid; + // bytes per scanline (must be multiple of 4) + bytes_per_line = (bytes_per_line >> 5) << 2; // can't overflow + + qsizetype total_size; + if (mul_overflow(height, bytes_per_line, &total_size)) + return invalid; + qsizetype dummy; + if (mul_overflow(height, qsizetype(sizeof(uchar *)), &dummy)) + return invalid; // why is this here? + + return { bytes_per_line, total_size }; +} + typedef void (*Image_Converter)(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); typedef bool (*InPlace_Image_Converter)(QImageData *data, Qt::ImageConversionFlags); diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 13129e214b..8ae03d5d38 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -45,7 +45,6 @@ #include <qiodevice.h> #include <qimage.h> #include <qlist.h> -#include <qtextcodec.h> #include <qvariant.h> #include <qvector.h> diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp index 771f0fe93d..a76150d91d 100644 --- a/src/gui/kernel/qclipboard.cpp +++ b/src/gui/kernel/qclipboard.cpp @@ -46,7 +46,9 @@ #include "qvariant.h" #include "qbuffer.h" #include "qimage.h" +#if QT_CONFIG(textcodec) #include "qtextcodec.h" +#endif #include "private/qguiapplication_p.h" #include <qpa/qplatformintegration.h> @@ -298,16 +300,16 @@ QString QClipboard::text(QString &subtype, Mode mode) const const QByteArray rawData = data->data(QLatin1String("text/") + subtype); -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) QTextCodec* codec = QTextCodec::codecForMib(106); // utf-8 is default if (subtype == QLatin1String("html")) codec = QTextCodec::codecForHtml(rawData, codec); else codec = QTextCodec::codecForUtfText(rawData, codec); return codec->toUnicode(rawData); -#else //QT_NO_TEXTCODEC +#else // textcodec return rawData; -#endif //QT_NO_TEXTCODEC +#endif // textcodec } /*! diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 0e35fb7d7b..53d1ac1fc0 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -2533,6 +2533,7 @@ QTabletEvent::QTabletEvent(Type type, const QPointF &pos, const QPointF &globalP */ QTabletEvent::~QTabletEvent() { + delete static_cast<QTabletEventPrivate *>(mExtra); } /*! diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index e5657000cf..f4e2dda05a 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -803,7 +803,8 @@ static void updateBlockedStatusRecursion(QWindow *window, bool shouldBeBlocked) void QGuiApplicationPrivate::updateBlockedStatus(QWindow *window) { bool shouldBeBlocked = false; - if (!QWindowPrivate::get(window)->isPopup() && !self->modalWindowList.isEmpty()) + const bool popupType = (window->type() == Qt::ToolTip) || (window->type() == Qt::Popup); + if (!popupType && !self->modalWindowList.isEmpty()) shouldBeBlocked = self->isWindowBlocked(window); updateBlockedStatusRecursion(window, shouldBeBlocked); } diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index a84f873437..2611dc8580 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -44,7 +44,6 @@ #include "qpixmap.h" #include "qevent.h" #include "qfile.h" -#include "qtextcodec.h" #include "qguiapplication.h" #include "qpoint.h" #include "qbuffer.h" diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index 574310f554..1a814ec21f 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -319,7 +319,8 @@ void QSurfaceFormat::setStereo(bool enable) /*! Returns the number of samples per pixel when multisampling is - enabled. By default, multisampling is disabled. + enabled, or \c -1 when multisampling is disabled. The default + return value is \c -1. \sa setSamples() */ diff --git a/src/gui/kernel/qt_gui_pch.h b/src/gui/kernel/qt_gui_pch.h index db12ba1078..aa5d3f0572 100644 --- a/src/gui/kernel/qt_gui_pch.h +++ b/src/gui/kernel/qt_gui_pch.h @@ -63,7 +63,9 @@ #include <qregexp.h> #include <qstring.h> #include <qstringlist.h> +#if QT_CONFIG(textcodec) #include <qtextcodec.h> +#endif #include <qguiapplication.h> #include <qbitmap.h> diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 67e1283462..5b32405f5e 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -394,6 +394,9 @@ QT_DEFINE_QPA_EVENT_HANDLER(void, handleMouseEvent, QWindow *window, ulong times Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods, Qt::MouseEventSource source) { + Q_ASSERT_X(type != QEvent::MouseButtonDblClick && type != QEvent::NonClientAreaMouseButtonDblClick, + "QWindowSystemInterface::handleMouseEvent", + "QTBUG-71263: Native double clicks are not implemented."); auto localPos = QHighDpi::fromNativeLocalPosition(local, window); auto globalPos = QHighDpi::fromNativePixels(global, window); diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index 0262538250..f0837aff96 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -40,8 +40,10 @@ #include "qopenglvertexarrayobject.h" #include <QtCore/private/qobject_p.h> +#include <QtCore/qthread.h> #include <QtGui/qopenglcontext.h> #include <QtGui/qoffscreensurface.h> +#include <QtGui/qguiapplication.h> #include <QtGui/qopenglfunctions_3_0.h> #include <QtGui/qopenglfunctions_3_2_core.h> @@ -204,18 +206,25 @@ void QOpenGLVertexArrayObjectPrivate::destroy() if (context && context != ctx) { oldContext = ctx; oldContextSurface = ctx ? ctx->surface() : 0; - // Cannot just make the current surface current again with another context. - // The format may be incompatible and some platforms (iOS) may impose - // restrictions on using a window with different contexts. Create an - // offscreen surface (a pbuffer or a hidden window) instead to be safe. - offscreenSurface.reset(new QOffscreenSurface); - offscreenSurface->setFormat(context->format()); - offscreenSurface->create(); - if (context->makeCurrent(offscreenSurface.data())) { - ctx = context; - } else { - qWarning("QOpenGLVertexArrayObject::destroy() failed to make VAO's context current"); + // Before going through the effort of creating an offscreen surface + // check that we are on the GUI thread because otherwise many platforms + // will not able to create that offscreen surface. + if (QThread::currentThread() != qGuiApp->thread()) { ctx = 0; + } else { + // Cannot just make the current surface current again with another context. + // The format may be incompatible and some platforms (iOS) may impose + // restrictions on using a window with different contexts. Create an + // offscreen surface (a pbuffer or a hidden window) instead to be safe. + offscreenSurface.reset(new QOffscreenSurface); + offscreenSurface->setFormat(context->format()); + offscreenSurface->create(); + if (context->makeCurrent(offscreenSurface.data())) { + ctx = context; + } else { + qWarning("QOpenGLVertexArrayObject::destroy() failed to make VAO's context current"); + ctx = 0; + } } } @@ -224,7 +233,7 @@ void QOpenGLVertexArrayObjectPrivate::destroy() context = 0; } - if (vao) { + if (vao && ctx) { switch (vaoFuncsType) { #ifndef QT_OPENGL_ES_2 case Core_3_2: diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index 373722cdb4..3081a4b1b6 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -71,7 +71,7 @@ #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 #endif -#ifndef GL_FRAMEBUFFER_SRB +#ifndef GL_FRAMEBUFFER_SRGB #define GL_FRAMEBUFFER_SRGB 0x8DB9 #endif #ifndef GL_FRAMEBUFFER_SRGB_CAPABLE diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index fcda17605f..b09f8b565a 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -157,14 +157,12 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() void QSyntaxHighlighterPrivate::_q_reformatBlocks(int from, int charsRemoved, int charsAdded) { - if (!inReformatBlocks) + if (!inReformatBlocks && !rehighlightPending) reformatBlocks(from, charsRemoved, charsAdded); } void QSyntaxHighlighterPrivate::reformatBlocks(int from, int charsRemoved, int charsAdded) { - rehighlightPending = false; - QTextBlock block = doc->findBlock(from); if (!block.isValid()) return; @@ -346,8 +344,10 @@ void QSyntaxHighlighter::setDocument(QTextDocument *doc) if (d->doc) { connect(d->doc, SIGNAL(contentsChange(int,int,int)), this, SLOT(_q_reformatBlocks(int,int,int))); - d->rehighlightPending = true; - QTimer::singleShot(0, this, SLOT(_q_delayedRehighlight())); + if (!d->doc->isEmpty()) { + d->rehighlightPending = true; + QTimer::singleShot(0, this, SLOT(_q_delayedRehighlight())); + } } } diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 5d88530e65..6ca4bc8209 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -51,7 +51,9 @@ #include <qregularexpression.h> #endif #include <qvarlengtharray.h> +#if QT_CONFIG(textcodec) #include <qtextcodec.h> +#endif #include <qthread.h> #include <qcoreapplication.h> #include <qmetaobject.h> @@ -209,7 +211,7 @@ QString Qt::convertFromPlainText(const QString &plain, Qt::WhiteSpaceMode mode) This function is defined in the \c <QTextDocument> header file. */ -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) QTextCodec *Qt::codecForHtml(const QByteArray &ba) { return QTextCodec::codecForHtml(ba); diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h index 33c0b48683..c9b22e053b 100644 --- a/src/gui/text/qtextdocument.h +++ b/src/gui/text/qtextdocument.h @@ -75,7 +75,7 @@ namespace Qt Q_GUI_EXPORT bool mightBeRichText(const QString&); Q_GUI_EXPORT QString convertFromPlainText(const QString &plain, WhiteSpaceMode mode = WhiteSpacePre); -#if !defined(QT_NO_TEXTCODEC) || defined(Q_CLANG_QDOC) +#if QT_CONFIG(textcodec) || defined(Q_CLANG_QDOC) Q_GUI_EXPORT QTextCodec *codecForHtml(const QByteArray &ba); #endif } diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp index f0eff2d4f3..e7eaa54a45 100644 --- a/src/gui/text/qtextdocumentfragment.cpp +++ b/src/gui/text/qtextdocumentfragment.cpp @@ -43,7 +43,6 @@ #include "qtextlist.h" #include <qdebug.h> -#include <qtextcodec.h> #include <qbytearray.h> #include <qdatastream.h> #include <qdatetime.h> diff --git a/src/gui/text/qtextdocumentwriter.cpp b/src/gui/text/qtextdocumentwriter.cpp index 731aaf1fcf..5ea04fe9e9 100644 --- a/src/gui/text/qtextdocumentwriter.cpp +++ b/src/gui/text/qtextdocumentwriter.cpp @@ -41,7 +41,9 @@ #include <QtCore/qfile.h> #include <QtCore/qbytearray.h> #include <QtCore/qfileinfo.h> +#if QT_CONFIG(textcodec) #include <QtCore/qtextcodec.h> +#endif #include <QtCore/qtextstream.h> #include <QtCore/qdebug.h> #include "qtextdocument.h" @@ -63,7 +65,7 @@ public: QByteArray format; QIODevice *device; bool deleteDevice; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) QTextCodec *codec; #endif @@ -104,7 +106,7 @@ public: QTextDocumentWriterPrivate::QTextDocumentWriterPrivate(QTextDocumentWriter *qq) : device(0), deleteDevice(false), -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) codec(QTextCodec::codecForName("utf-8")), #endif q(qq) @@ -258,7 +260,7 @@ bool QTextDocumentWriter::write(const QTextDocument *document) #ifndef QT_NO_TEXTODFWRITER if (format == "odf" || format == "opendocumentformat" || format == "odt") { QTextOdfWriter writer(*document, d->device); -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) writer.setCodec(d->codec); #endif return writer.writeAll(); @@ -272,7 +274,7 @@ bool QTextDocumentWriter::write(const QTextDocument *document) return false; } QTextStream ts(d->device); -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) ts.setCodec(d->codec); ts << document->toHtml(d->codec->name()); #endif @@ -286,7 +288,7 @@ bool QTextDocumentWriter::write(const QTextDocument *document) return false; } QTextStream ts(d->device); -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) ts.setCodec(d->codec); #endif ts << document->toPlainText(); @@ -317,7 +319,7 @@ bool QTextDocumentWriter::write(const QTextDocumentFragment &fragment) uses UTF-8. */ -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) void QTextDocumentWriter::setCodec(QTextCodec *codec) { if (codec == 0) @@ -330,7 +332,7 @@ void QTextDocumentWriter::setCodec(QTextCodec *codec) /*! Returns the codec that is currently assigned to the writer. */ -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) QTextCodec *QTextDocumentWriter::codec() const { return d->codec; diff --git a/src/gui/text/qtextdocumentwriter.h b/src/gui/text/qtextdocumentwriter.h index 0502bf1a96..4a57b181b4 100644 --- a/src/gui/text/qtextdocumentwriter.h +++ b/src/gui/text/qtextdocumentwriter.h @@ -70,7 +70,7 @@ public: bool write(const QTextDocument *document); bool write(const QTextDocumentFragment &fragment); -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) void setCodec(QTextCodec *codec); QTextCodec *codec() const; #endif diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index 9d2a5d553a..04300a4d22 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -40,7 +40,6 @@ #include "qtexthtmlparser_p.h" #include <qbytearray.h> -#include <qtextcodec.h> #include <qstack.h> #include <qdebug.h> #include <qthread.h> diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index 5f6a24cc5d..f5d73affab 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -961,7 +961,7 @@ bool QTextOdfWriter::writeAll() return false; } QXmlStreamWriter writer(m_strategy->contentStream); -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) if (m_codec) writer.setCodec(m_codec); #endif |