diff options
39 files changed, 636 insertions, 224 deletions
diff --git a/config.tests/unix/compile.test b/config.tests/unix/compile.test index a854bd1..f9c18fc 100755 --- a/config.tests/unix/compile.test +++ b/config.tests/unix/compile.test @@ -64,7 +64,8 @@ test -d "$OUTDIR/$TEST" || mkdir -p "$OUTDIR/$TEST" cd "$OUTDIR/$TEST" -make distclean >/dev/null 2>&1 +test -e Makefile && make distclean >/dev/null 2>&1 + "$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "CONFIG+=$QMAKE_CONFIG" "LIBS*=$LFLAGS" "LIBS+=$MAC_ARCH_LFLAGS" "INCLUDEPATH*=$INCLUDEPATH" "QMAKE_CXXFLAGS*=$CXXFLAGS" "QMAKE_CXXFLAGS+=$MAC_ARCH_CXXFLAGS" "$SRCDIR/$TEST/$EXE.pro" -o "$OUTDIR/$TEST/Makefile" if [ "$VERBOSE" = "yes" ]; then diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index 9fd4a04..acbaa87 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -181,6 +181,7 @@ <li><a href="qthelp.html">Help Module</a></li> <li><a href="qtnetwork.html">Network Module</a></li> <li><a href="qtopengl.html">OpenGL Module</a></li> + <li><a href="qtopenvg.html">OpenVG Module</a></li> <li><a href="qtscript.html">Script Module</a></li> <li><a href="qtsql.html">SQL Module</a></li> <li><a href="qtsvg.html">SVG Module</a></li> diff --git a/doc/src/qmake-manual.qdoc b/doc/src/qmake-manual.qdoc index f8347c1..7960de7 100644 --- a/doc/src/qmake-manual.qdoc +++ b/doc/src/qmake-manual.qdoc @@ -1922,6 +1922,14 @@ typically handled by \c qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + \target QMAKE_INCDIR_EGL + \section1 QMAKE_INCDIR_EGL + + This variable contains the location of EGL header files to be added + to INCLUDEPATH when building an application with OpenGL/ES or + OpenVG support. The value of this variable is typically handled by + \c qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + \target QMAKE_INCDIR_OPENGL \section1 QMAKE_INCDIR_OPENGL @@ -1930,6 +1938,20 @@ value of this variable is typically handled by \c qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + If the OpenGL implementation uses EGL (most OpenGL/ES systems), + then QMAKE_INCDIR_EGL may also need to be set. + + \target QMAKE_INCDIR_OPENVG + \section1 QMAKE_INCDIR_OPENVG + + This variable contains the location of OpenVG header files to be added + to INCLUDEPATH when building an application with OpenVG support. The + value of this variable is typically handled by \c qmake or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + + If the OpenVG implementation uses EGL then QMAKE_INCDIR_EGL may also + need to be set. + \target QMAKE_INCDIR_QT \section1 QMAKE_INCDIR_QT @@ -2078,6 +2100,13 @@ \c qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + \section1 QMAKE_LIBDIR_EGL + + This variable contains the location of the EGL library + directory, when EGL is used with OpenGL/ES or OpenVG. The value + of this variable is typically handled by \c qmake or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + \section1 QMAKE_LIBDIR_OPENGL This variable contains the location of the OpenGL library @@ -2085,6 +2114,19 @@ \c qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + If the OpenGL implementation uses EGL (most OpenGL/ES systems), + then QMAKE_LIBDIR_EGL may also need to be set. + + \section1 QMAKE_LIBDIR_OPENVG + + This variable contains the location of the OpenVG library + directory. The value of this variable is typically handled by + \c qmake or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + + If the OpenVG implementation uses EGL, then QMAKE_LIBDIR_EGL + may also need to be set. + \section1 QMAKE_LIBDIR_QT This variable contains the location of the Qt library @@ -2116,18 +2158,41 @@ project on Windows. \l{#QMAKE_LIBS_WINDOW}{QMAKE_LIBS_WINDOW} should now be used instead. + \section1 QMAKE_LIBS_EGL + + This variable contains all EGL libraries when building Qt with + OpenGL/ES or OpenVG. The value of this variable is typically + handled by \c qmake or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. The usual value is \c{-lEGL}. + \section1 QMAKE_LIBS_OPENGL This variable contains all OpenGL libraries. The value of this variable is typically handled by \c qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + If the OpenGL implementation uses EGL (most OpenGL/ES systems), + then QMAKE_LIBS_EGL may also need to be set. + \section1 QMAKE_LIBS_OPENGL_QT This variable contains all OpenGL Qt libraries.The value of this variable is typically handled by \c qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + \section1 QMAKE_LIBS_OPENVG + + This variable contains all OpenVG libraries. The value of this + variable is typically handled by \c qmake or \l{#QMAKESPEC}{qmake.conf} + and rarely needs to be modified. The usual value is \c{-lOpenVG}. + + Some OpenVG engines are implemented on top of OpenGL. This will + be detected at configure time and QMAKE_LIBS_OPENGL will be implicitly + added to QMAKE_LIBS_OPENVG wherever the OpenVG libraries are linked. + + If the OpenVG implementation uses EGL, then QMAKE_LIBS_EGL may also + need to be set. + \section1 QMAKE_LIBS_QT This variable contains all Qt libraries.The value of this diff --git a/doc/src/qtopenvg.qdoc b/doc/src/qtopenvg.qdoc index ad036ef..38be288 100644 --- a/doc/src/qtopenvg.qdoc +++ b/doc/src/qtopenvg.qdoc @@ -42,32 +42,283 @@ /*! \module QtOpenVG \title QtOpenVG Module + \since 4.6 \contentspage Qt's Modules \previouspage QtOpenGL - \nextpage QtSql + \nextpage QtScript \ingroup modules - \brief The QtOpenVG module offers classes that make it easy to - use OpenVG in Qt applications. + \brief The QtOpenVG module provides support classes for OpenVG painting. - From the OpenVG 1.1 Specification: + \tableofcontents - \quotation + OpenVG is a standard API from the + \l{http://www.khronos.org/openvg}{Khronos Group} for accelerated + 2D vector graphics that is appearing in an increasing number of + embedded devices. - OpenVG is an application programming interface (API) for hardware-accelerated two- - dimensional vector and raster graphics developed under the auspices of the Khronos - Group (www.khronos.org). It provides a device-independent and vendor-neutral interface - for sophisticated 2D graphical applications, while allowing device manufacturers to - provide hardware acceleration where appropriate. + OpenVG is optimized for 2D vector operations, and closely matches + the functionality in QPainter. It can therefore be an excellent + substitute for the default raster-based QPaintEngine on hardware + that supports OpenVG. - \endquotation + \section1 Building Qt with OpenVG support - The specification, and a reference implementation of it are available from the - \l{http://www.khronos.org/registry/vg/}{Khronos Group}. + OpenVG support can be enabled by passing the \c{-openvg} option + to configure. It is assumed that the following qmake variables + are set to appropriate values in the qmake.conf file for your + platform: - \bold{Note:} Khronos and OpenVG are trademarks of The Khronos Group Inc. OpenGL is a - registered trademark, and OpenGL ES is a trademark, of Silicon Graphics, Inc. + \list + \o QMAKE_INCDIR_OPENVG + \o QMAKE_LIBDIR_OPENVG + \o QMAKE_LIBS_OPENVG + \endlist + Most OpenVG implementations are based on EGL, so the following + variables may also need to be set: - The Qt OpenVG module makes it easy to use OpenVG in Qt applications. + \list + \o QMAKE_INCDIR_EGL + \o QMAKE_LIBDIR_EGL + \o QMAKE_LIBS_EGL + \endlist + + See \l{qmake Variable Reference} for more information on these variables. + + Two kinds of OpenVG engines are currently supported: EGL based, + and engines built on top of OpenGL such as + \l{http://sourceforge.net/projects/shivavg}{ShivaVG}. + EGL based engines are preferred. + + It is assumed that the EGL implementation has some way to turn a + QWidget::winId() into an EGL rendering surface with + \c{eglCreateWindowSurface()}. If this is not the case, then + modifications may be needed to the code under \c{src/gui/egl} and + \c{src/plugins/graphicssystems/openvg} to accomodate the EGL + implementation. + + The ShivaVG graphics system under \c{src/plugins/graphicssystems/shivavg} + is an example of how to integrate a non-EGL implementation of + OpenVG into Qt. It is currently only supported with Qt/X11 + and being an example only, the resulting screen output may not + be as good as with other OpenVG engines. + + \section1 Using the OpenVG graphics system + + Once the graphics system plugin has been built and installed, + applications can be run as follows to use the plugin: + + \code + app -graphicssystem OpenVG + \endcode + + If ShivaVG is being used, then substitute \c ShivaVG instead of + \c OpenVG in the line above. + + If the plugin fails to load, try setting the \c QT_DEBUG_PLUGINS + environment variable to 1 and try again. Usually the plugin + cannot be loaded because Qt cannot locate it in the directory + \c{plugins/graphicssystems} within the Qt installation, or the + dynamic library path does not include the directory containing + the system's \c libOpenVG.so library. + + \section1 Supported features + + \section2 Context modes + + The default configuration is "single-context" mode, where a single + EGLContext object is used for all drawing, regardless of the surface. + Multiple EGLSurfaces are created, one for each window surface or pixmap. + eglMakeCurrent() is called with the same EGLContext every time, but a + different EGLSurface. + + Single-context mode is necessary for QPixmapData to be implemented in + terms of a VGImage. If single-context mode is not enabled, then QPixmapData + will use the fallback QRasterPixmapData implementation, which is less + efficient performance-wise. + + Single-context mode can be disabled with the QVG_NO_SINGLE_CONTEXT define + if the OpenVG engine does not support one context with multiple surfaces. + + \section2 Transformation matrices + + All affine and projective transformation matrices are supported. + + QVGPaintEngine will use the engine to accelerate affine transformation + matrices only. When a projective transformation matrix is used, + QVGPaintEngine will transform the coordinates before passing them + to the engine. This will probably incur a performance penalty. + + Pixmaps and images are always transformed by the engine, because + OpenVG specifies that projective transformations must work for images. + + It is recommended that client applications should avoid using projective + transformations for non-image elements in performance critical code. + + \section2 Composition modes + + The following composition modes are supported: + + \list + \o QPainter::CompositionMode_SourceOver + \o QPainter::CompositionMode_DestinationOver + \o QPainter::CompositionMode_Source + \o QPainter::CompositionMode_SourceIn + \o QPainter::CompositionMode_DestinationIn + \o QPainter::CompositionMode_Plus + \o QPainter::CompositionMode_Multiply + \o QPainter::CompositionMode_Screen + \o QPainter::CompositionMode_Darken + \o QPainter::CompositionMode_Lighten + \endlist + + The other members of QPainter::CompositionMode are not supported + because OpenVG 1.1 does not have an equivalent in its \c VGBlendMode + enumeration. Any attempt to set an unsupported mode will result in + the actual mode being set to QPainter::CompositionMode_SourceOver. + Client applications should avoid using unsupported modes. + + \section2 Pens and brushes + + All pen styles are supported, including cosmetic pens. + + All brush styles are supported except for conical gradients, which are + not supported by OpenVG 1.1. Conical gradients will be converted into a + solid color brush corresponding to the first color in the gradient's + color ramp. + + Affine matrices are supported for brush transforms, but not projective + matrices. + + \section2 Rectangles, lines, and points + + Rectangles and lines use cached VGPath objects to try to accelerate + drawing operations. vgModifyPathCoords() is used to modify the + co-ordinates in the cached VGPath object each time fillRect(), + drawRects(), or drawLines() is called. + + If the engine does not implement vgModifyPathCoords() properly, then the + QVG_NO_MODIFY_PATH define can be set to disable path caching. This will + incur a performance penalty. + + Points are implemented as lines from the point to itself. The cached + line drawing VGPath object is used when drawing points. + + \section2 Polygons and Ellipses + + Polygon and ellipse drawing creates a new VGPath object every time + drawPolygon() or drawEllipse() is called. If the client application is + making heavy use of these functions, the constant creation and destruction + of VGPath objects could have an impact on performance. + + If a projective transformation is active, ellipses are converted into + cubic curves prior to transformation, which may further impact performance. + + Client applications should avoid polygon and ellipse drawing in performance + critical code if possible. + + \section2 Other Objects + + Most other objects (arcs, pies, etc) use drawPath(), which takes a + QPainterPath argument. The default implementation in QPainterEngineEx + converts the QPainterPath into a QVectorPath and then calls draw(), + which in turn converts the QVectorPath into a VGPath for drawing. + + To reduce the overhead, we have overridden drawPath() in QVGPaintEngine + to convert QPainterPath's directly into VGPath's. This should help improve + performance compared to the default implementation. + + Client applications should try to avoid these types of objects in + performance critical code because of the QPainterPath to VGPath + conversion cost. + + \section2 Clipping + + Clipping with QRect, QRectF, and QRegion objects is supported on all + OpenVG engines with vgMask() if the transformation matrix is the identity + or a simple origin translation. + + Clipping with an arbitrary QPainterPath, or setting the clip region when + the transformation matrix is simple, is supported only if the OpenVG engine + has the vgRenderToMask() function (OpenVG 1.1 and higher). + + The QVG_NO_RENDER_TO_MASK define will disable the use of vgRenderToMask(). + + The QVG_SCISSOR_CLIP define will disable clipping with vgMask() or + vgRenderToMask() and instead use the scissor rectangle list to perform + clipping. Clipping with an arbitrary QPainterPath will not be supported. + The QVG_SCISSOR_CLIP define should only be used if the OpenVG engine + does not support vgMask() or vgRenderToMask(). + + \section2 Opacity + + Opacity is supported for all drawing operations. Solid color pens, + solid color brushes, gradient brushes, and image drawing with drawPixmap() + and drawImage() will probably have the best performance compared to + other kinds of pens and brushes. + + \section2 Text Drawing + + If OpenVG 1.1 is used, the paint engine will use VG fonts to cache glyphs + while drawing. If the engine does not support VG fonts correctly, + QVG_NO_DRAW_GLYPHS can be defined to disable this mode. Text drawing + performance will suffer if VG fonts are not used. + + By default, image-based glyphs are used. If QVG_NO_IMAGE_GLYPHS is defined, + then path-based glyphs will be used instead. QVG_NO_IMAGE_GLYPHS is ignored + if QVG_NO_DRAW_GLYPHS is defined. + + If path-based glyphs are used, then the OpenVG engine will need to + support hinting to render text with good results. Image-based glyphs + avoids the need for hinting and will usually give better results than + path-based glyphs. + + \section2 Pixmaps + + In single-context mode, pixmaps will be implemented using VGImage + unless QVG_NO_PIXMAP_DATA is defined. + + QVGPixmapData will convert QImage's into VGImage's when the application + calls drawPixmap(), and the pixmap will be kept in VGImage form for the + lifetime of the QVGPixmapData object. When the application tries to paint + into a QPixmap with QPainter, the data will be converted back into a + QImage and the raster paint engine will be used to render into the QImage. + + This arrangement optimizes for the case of drawing the same static pixmap + over and over (e.g. for icons), but does not optimize the case of drawing + into pixmaps. + + Bitmaps must use QRasterPixmapData. They are not accelerated with + VGImage at present. + + \section2 Pixmap filters + + Convolution, colorize, and drop shadow filters are accelerated using + OpenVG operations. + + \section1 Known issues + + Performance of copying the contents of an OpenVG-rendered window to the + screen needs platform-specific work in the QVGWindowSurface class. + + Clipping with arbitrary non-rectangular paths only works on engines + that support vgRenderToMask(). Simple rectangular paths are supported + on all engines that correctly implement vgMask(). + + The paint engine is not yet thread-safe, so it is not recommended for + use in threaded Qt applications that draw from multiple threads. + Drawing should be limited to the main GUI thread. + + Performance of projective matrices for non-image drawing is not as good + as for affine matrices. + + QPixmap's are implemented as VGImage objects so that they can be quickly + rendered with drawPixmap(). Rendering into a QPixmap using QPainter + will use the default Qt raster paint engine on a QImage copy of the + QPixmap, and will not be accelerated. This issue may be addressed in + a future version of the engine. + + ShivaVG support is highly experimental and limited to Qt/X11. It is + provided as an example of how to integrate a non-EGL engine. */ diff --git a/doc/src/qtscript.qdoc b/doc/src/qtscript.qdoc index ac13ddf..f2ac6c9 100644 --- a/doc/src/qtscript.qdoc +++ b/doc/src/qtscript.qdoc @@ -44,7 +44,7 @@ \title QtScript Module \since 4.3 \contentspage Qt's Modules - \previouspage QtOpenGL + \previouspage QtOpenVG \nextpage QtScriptTools \ingroup modules \ingroup scripting diff --git a/mkspecs/common/mac-llvm.conf b/mkspecs/common/mac-llvm.conf index 624aec4..55850c6 100644 --- a/mkspecs/common/mac-llvm.conf +++ b/mkspecs/common/mac-llvm.conf @@ -48,8 +48,8 @@ QMAKE_CXXFLAGS_DWARF2 += $$QMAKE_CFLAGS_DWARF2 QMAKE_CXXFLAGS_PRECOMPILE += -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE -QMAKE_LINK = llvm-g++ -QMAKE_LINK_SHLIB = llvm-g++ +QMAKE_LINK = $$QMAKE_CXX +QMAKE_LINK_SHLIB = $$QMAKE_CXX QMAKE_LFLAGS += -headerpad_max_install_names QMAKE_LFLAGS_RELEASE += QMAKE_LFLAGS_DEBUG += diff --git a/mkspecs/macx-llvm/qmake.conf b/mkspecs/macx-llvm/qmake.conf index cb8aaa1..de8040c 100644 --- a/mkspecs/macx-llvm/qmake.conf +++ b/mkspecs/macx-llvm/qmake.conf @@ -14,6 +14,4 @@ QMAKE_INCREMENTAL_STYLE = sublib include(../common/mac-llvm.conf) -QMAKE_OBJECTIVE_CC = gcc - load(qt_config) diff --git a/qmake/generators/metamakefile.cpp b/qmake/generators/metamakefile.cpp index 233e8e5..7f4e914 100644 --- a/qmake/generators/metamakefile.cpp +++ b/qmake/generators/metamakefile.cpp @@ -136,7 +136,12 @@ BuildsMetaMakefileGenerator::init() Build *build = new Build; build->name = name; build->makefile = createMakefileGenerator(project, false); - makefiles += build; + if (build->makefile){ + makefiles += build; + }else { + delete build; + return false; + } } return true; } @@ -437,7 +442,7 @@ MetaMakefileGenerator::createMakefileGenerator(QMakeProject *proj, bool noIO) QString gen = proj->first("MAKEFILE_GENERATOR"); if(gen.isEmpty()) { - fprintf(stderr, "No generator specified in config file: %s\n", + fprintf(stderr, "MAKEFILE_GENERATOR variable not set as a result of parsing : %s. Possibly qmake was not able to find files included using \"include(..)\" - enable qmake debugging to investigate more.\n", proj->projectFile().toLatin1().constData()); } else if(gen == "UNIX") { mkfile = new UnixMakefileGenerator; diff --git a/src/corelib/arch/macosx/arch.pri b/src/corelib/arch/macosx/arch.pri index e42a962..a2b1bf7 100644 --- a/src/corelib/arch/macosx/arch.pri +++ b/src/corelib/arch/macosx/arch.pri @@ -1,7 +1,6 @@ # # Mac OS X architecture # -!*-icc*:!*-g++* { - contains($$list($$system(uname -m)), .*86):SOURCES += $$QT_ARCH_CPP/../i386/qatomic.s - else:SOURCES += $$QT_ARCH_CPP/../powerpc/qatomic32.s -} + +# Left blank intentionally since all the current compilers that we support can +# handle in-line assembly. diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 32c6aef..d4e5d44 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -1560,7 +1560,7 @@ QTextCodec *QTextCodec::codecForHtml(const QByteArray &ba) */ QTextCodec *QTextCodec::codecForUtfText(const QByteArray &ba, QTextCodec *defaultCodec) { - const uint arraySize = ba.size(); + const int arraySize = ba.size(); if (arraySize > 3) { if ((uchar)ba[0] == 0x00 diff --git a/src/corelib/concurrent/qtconcurrentthreadengine.h b/src/corelib/concurrent/qtconcurrentthreadengine.h index 286c2b8..896b193 100644 --- a/src/corelib/concurrent/qtconcurrentthreadengine.h +++ b/src/corelib/concurrent/qtconcurrentthreadengine.h @@ -66,7 +66,7 @@ namespace QtConcurrent { // The ThreadEngineBarrier counts worker threads, and allows one // thread to wait for all others to finish. Tested for its use in // QtConcurrent, requires more testing for use as a general class. -class ThreadEngineBarrier +class Q_CORE_EXPORT ThreadEngineBarrier { private: // The thread count is maintained as an integer in the count atomic diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 928805a..0471a1b 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -48,6 +48,8 @@ #pragma qt_sync_stop_processing #endif +#include <QtCore/qatomic.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -138,14 +140,14 @@ namespace QtSharedPointer { inline void internalConstruct(T *ptr) { -#ifndef QT_NO_DEBUG +#ifdef QT_SHAREDPOINTER_TRACK_POINTERS if (ptr) internalSafetyCheckAdd(ptr); #endif value = ptr; } inline void internalDestroy() { -#ifndef QT_NO_DEBUG +#ifdef QT_SHAREDPOINTER_TRACK_POINTERS if (value) internalSafetyCheckRemove(value); #endif } diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 3ff263d..71482f5 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -169,7 +169,7 @@ static int ucstricmp(const ushort *a, const ushort *ae, const uchar *b) // Unicode case-insensitive comparison static int ucstrcmp(const QChar *a, int alen, const QChar *b, int blen) { - if (a == b) + if (a == b && alen == blen) return 0; int l = qMin(alen, blen); while (l-- && *a == *b) diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index aea0c6c..c93a065 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -28,6 +28,8 @@ HEADERS += \ tools/qregexp.h \ tools/qringbuffer_p.h \ tools/qshareddata.h \ + tools/qsharedpointer.h \ + tools/qsharedpointer_impl.h \ tools/qset.h \ tools/qsize.h \ tools/qstack.h \ diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp index 416e14a..42d3a9a 100644 --- a/src/gui/dialogs/qcolordialog.cpp +++ b/src/gui/dialogs/qcolordialog.cpp @@ -1262,7 +1262,7 @@ void QColorShower::retranslateStrings() void QColorShower::updateQColor() { QColor oldQColor(curQColor); - curQColor.setRgba(qRgba(qRed(curCol), qGreen(curCol), qBlue(curCol), qAlpha(curCol))); + curQColor.setRgba(qRgba(qRed(curCol), qGreen(curCol), qBlue(curCol), currentAlpha())); if (curQColor != oldQColor) emit currentColorChanged(curQColor); } diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 0c74cfa..324fac7 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -1905,10 +1905,14 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam // don't show resize-cursors for fixed-size widgets QRect fs = widget->frameStrut(); if (!widget->isMinimized()) { + if (widget->minimumHeight() == widget->maximumHeight()) { + if (pos.y() < -(fs.top() - fs.left())) + return HTCAPTION; + if (pos.y() >= widget->height()) + return HTBORDER; + } if (widget->minimumWidth() == widget->maximumWidth() && (pos.x() < 0 || pos.x() >= widget->width())) - break; - if (widget->minimumHeight() == widget->maximumHeight() && (pos.y() < -(fs.top() - fs.left()) || pos.y() >= widget->height())) - break; + return HTBORDER; } } diff --git a/src/gui/kernel/qmime_mac.cpp b/src/gui/kernel/qmime_mac.cpp index 31c66e4..903b677 100644 --- a/src/gui/kernel/qmime_mac.cpp +++ b/src/gui/kernel/qmime_mac.cpp @@ -502,6 +502,8 @@ QList<QByteArray> QMacPasteboardMimeHTMLText::convertFromMime(const QString &mim #ifdef Q_WS_MAC32 +// This can be removed once 10.6 is the minimum (or we have to require 64-bit) whichever comes first. + #include <QuickTime/QuickTime.h> #include <qlibrary.h> @@ -1099,7 +1101,10 @@ void QMacPasteboardMime::initialize() //standard types that we wrap new QMacPasteboardMimeTiff; #ifdef Q_WS_MAC32 - new QMacPasteboardMimePict; + // 10.6 does automatic synthesis to and from PICT to standard image types (like TIFF), + // so don't bother doing it ourselves, especially since it's not available in 64-bit. + if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_6) + new QMacPasteboardMimePict; #endif new QMacPasteboardMimeUnicodeText; new QMacPasteboardMimePlainText; diff --git a/src/gui/statemachine/qguistatemachine.cpp b/src/gui/statemachine/qguistatemachine.cpp index fd14cf9..7fba78e 100644 --- a/src/gui/statemachine/qguistatemachine.cpp +++ b/src/gui/statemachine/qguistatemachine.cpp @@ -154,7 +154,8 @@ static QEvent *cloneEvent(QEvent *e) case QEvent::DeferredDelete: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; - case QEvent::DragEnter: +#ifndef QT_NO_DRAGANDDROP + case QEvent::DragEnter: return new QDragEnterEvent(*static_cast<QDragEnterEvent*>(e)); case QEvent::DragMove: return new QDragMoveEvent(*static_cast<QDragMoveEvent*>(e)); @@ -165,6 +166,7 @@ static QEvent *cloneEvent(QEvent *e) case QEvent::DragResponse: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; +#endif case QEvent::ChildAdded: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; @@ -295,12 +297,12 @@ static QEvent *cloneEvent(QEvent *e) case QEvent::StatusTip: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; - +#ifndef QT_NO_ACTION case QEvent::ActionChanged: case QEvent::ActionAdded: case QEvent::ActionRemoved: return new QActionEvent(*static_cast<QActionEvent*>(e)); - +#endif case QEvent::FileOpen: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; @@ -386,7 +388,7 @@ static QEvent *cloneEvent(QEvent *e) case QEvent::ZeroTimerEvent: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; - +#ifndef QT_NO_GRAPHICSVIEW case QEvent::GraphicsSceneMouseMove: case QEvent::GraphicsSceneMousePress: case QEvent::GraphicsSceneMouseRelease: @@ -450,7 +452,7 @@ static QEvent *cloneEvent(QEvent *e) case QEvent::GraphicsSceneWheel: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; - +#endif case QEvent::KeyboardLayoutChange: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; @@ -494,7 +496,7 @@ static QEvent *cloneEvent(QEvent *e) case QEvent::FutureCallOut: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; - +#ifndef QT_NO_GRAPHICSVIEW case QEvent::GraphicsSceneResize: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; @@ -506,7 +508,7 @@ static QEvent *cloneEvent(QEvent *e) me2->setOldPos(me->oldPos()); return me2; } - +#endif case QEvent::CursorChange: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index 24ff792..ed3bdb5 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -3197,7 +3197,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, //have all the information we need (ie. the layout's margin) const QToolBar *tb = qobject_cast<const QToolBar*>(widget); const int margin = tb && tb->layout() ? tb->layout()->margin() : 2; - const int handleExtent = pixelMetric(QStyle::PM_ToolBarExtensionExtent, opt, tb); + const int handleExtent = pixelMetric(QStyle::PM_ToolBarHandleExtent, opt, tb); if (tbopt->state & QStyle::State_Horizontal) { r = QRect(margin, margin, handleExtent, tbopt->rect.height() - 2*margin); r = QStyle::visualRect(tbopt->direction, tbopt->rect, r); diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 829ac12..407fcb6 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2210,6 +2210,7 @@ bool QTextEngine::atWordSeparator(int position) const case '\'': case '"': case '~': + case '|': return true; default: return false; diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index cbfa5bf..ea5e323 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -994,15 +994,15 @@ void QDockAreaLayoutInfo::unnest(int index) } } -void QDockAreaLayoutInfo::remove(QList<int> path) +void QDockAreaLayoutInfo::remove(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); if (path.count() > 1) { - int index = path.takeFirst(); + const int index = path.first(); QDockAreaLayoutItem &item = item_list[index]; Q_ASSERT(item.subinfo != 0); - item.subinfo->remove(path); + item.subinfo->remove(path.mid(1)); unnest(index); } else { int index = path.first(); @@ -1010,18 +1010,18 @@ void QDockAreaLayoutInfo::remove(QList<int> path) } } -QLayoutItem *QDockAreaLayoutInfo::plug(QList<int> path) +QLayoutItem *QDockAreaLayoutInfo::plug(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + int index = path.first(); if (index < 0) index = -index - 1; - if (!path.isEmpty()) { + if (path.count() > 1) { const QDockAreaLayoutItem &item = item_list.at(index); Q_ASSERT(item.subinfo != 0); - return item.subinfo->plug(path); + return item.subinfo->plug(path.mid(1)); } QDockAreaLayoutItem &item = item_list[index]; @@ -1059,18 +1059,17 @@ QLayoutItem *QDockAreaLayoutInfo::plug(QList<int> path) return item.widgetItem; } -QLayoutItem *QDockAreaLayoutInfo::unplug(QList<int> path) +QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); + const int index = path.first(); if (path.count() > 1) { - int index = path.takeFirst(); const QDockAreaLayoutItem &item = item_list.at(index); Q_ASSERT(item.subinfo != 0); - return item.subinfo->unplug(path); + return item.subinfo->unplug(path.mid(1)); } - int index = path.first(); QDockAreaLayoutItem &item = item_list[index]; int prev = this->prev(index); int next = this->next(index); @@ -1142,12 +1141,12 @@ static QRect dockedGeometry(QWidget *widget) return result; } -bool QDockAreaLayoutInfo::insertGap(QList<int> path, QLayoutItem *dockWidgetItem) +bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem) { Q_ASSERT(!path.isEmpty()); bool insert_tabbed = false; - int index = path.takeFirst(); + int index = path.first(); if (index < 0) { insert_tabbed = true; index = -index - 1; @@ -1155,7 +1154,7 @@ bool QDockAreaLayoutInfo::insertGap(QList<int> path, QLayoutItem *dockWidgetItem // dump(qDebug() << "insertGap() before:" << index << tabIndex, *this, QString()); - if (!path.isEmpty()) { + if (path.count() > 1) { QDockAreaLayoutItem &item = item_list[index]; if (item.subinfo == 0 @@ -1194,8 +1193,7 @@ bool QDockAreaLayoutInfo::insertGap(QList<int> path, QLayoutItem *dockWidgetItem #endif } - bool result = item.subinfo->insertGap(path, dockWidgetItem); - return result; + return item.subinfo->insertGap(path.mid(1), dockWidgetItem); } // create the gap item @@ -1295,16 +1293,16 @@ QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(QWidget *widget) return 0; } -QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(QList<int> path) +QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path) { - int index = path.takeFirst(); + int index = path.first(); if (index < 0) index = -index - 1; if (index >= item_list.count()) return this; - if (path.isEmpty() || item_list.at(index).subinfo == 0) + if (path.count() == 1 || item_list.at(index).subinfo == 0) return this; - return item_list.at(index).subinfo->info(path); + return item_list.at(index).subinfo->info(path.mid(1)); } QRect QDockAreaLayoutInfo::itemRect(int index) const @@ -1335,17 +1333,18 @@ QRect QDockAreaLayoutInfo::itemRect(int index) const return result; } -QRect QDockAreaLayoutInfo::itemRect(QList<int> path) const +QRect QDockAreaLayoutInfo::itemRect(const QList<int> &path) const { Q_ASSERT(!path.isEmpty()); + const int index = path.first(); if (path.count() > 1) { - const QDockAreaLayoutItem &item = item_list.at(path.takeFirst()); + const QDockAreaLayoutItem &item = item_list.at(index); Q_ASSERT(item.subinfo != 0); - return item.subinfo->itemRect(path); + return item.subinfo->itemRect(path.mid(1)); } - return itemRect(path.first()); + return itemRect(index); } QRect QDockAreaLayoutInfo::separatorRect(int index) const @@ -1367,16 +1366,17 @@ QRect QDockAreaLayoutInfo::separatorRect(int index) const return QRect(pos, s); } -QRect QDockAreaLayoutInfo::separatorRect(QList<int> path) const +QRect QDockAreaLayoutInfo::separatorRect(const QList<int> &path) const { Q_ASSERT(!path.isEmpty()); + const int index = path.first(); if (path.count() > 1) { - const QDockAreaLayoutItem &item = item_list.at(path.takeFirst()); + const QDockAreaLayoutItem &item = item_list.at(index); Q_ASSERT(item.subinfo != 0); - return item.subinfo->separatorRect(path); + return item.subinfo->separatorRect(path.mid(1)); } - return separatorRect(path.first()); + return separatorRect(index); } QList<int> QDockAreaLayoutInfo::findSeparator(const QPoint &_pos) const @@ -1702,15 +1702,16 @@ void QDockAreaLayoutInfo::split(int index, Qt::Orientation orientation, } } -QDockAreaLayoutItem &QDockAreaLayoutInfo::item(QList<int> path) +QDockAreaLayoutItem &QDockAreaLayoutInfo::item(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); + const int index = path.first(); if (path.count() > 1) { - QDockAreaLayoutItem &item = item_list[path.takeFirst()]; + const QDockAreaLayoutItem &item = item_list.at(index); Q_ASSERT(item.subinfo != 0); - return item.subinfo->item(path); + return item.subinfo->item(path.mid(1)); } - return item_list[path.first()]; + return item_list[index]; } QLayoutItem *QDockAreaLayoutInfo::itemAt(int *x, int index) const @@ -2474,37 +2475,37 @@ QDockAreaLayoutInfo *QDockAreaLayout::info(QWidget *widget) return 0; } -QDockAreaLayoutInfo *QDockAreaLayout::info(QList<int> path) +QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - if (path.isEmpty()) + if (path.count() == 1) return &docks[index]; - return docks[index].info(path); + return docks[index].info(path.mid(1)); } -const QDockAreaLayoutInfo *QDockAreaLayout::info(QList<int> path) const +const QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path) const { return const_cast<QDockAreaLayout*>(this)->info(path); } -QDockAreaLayoutItem &QDockAreaLayout::item(QList<int> path) +QDockAreaLayoutItem &QDockAreaLayout::item(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - return docks[index].item(path); + return docks[index].item(path.mid(1)); } -QRect QDockAreaLayout::itemRect(QList<int> path) const +QRect QDockAreaLayout::itemRect(const QList<int> &path) const { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - return docks[index].itemRect(path); + return docks[index].itemRect(path.mid(1)); } QRect QDockAreaLayout::separatorRect(int index) const @@ -2528,49 +2529,49 @@ QRect QDockAreaLayout::separatorRect(int index) const return QRect(); } -QRect QDockAreaLayout::separatorRect(QList<int> path) const +QRect QDockAreaLayout::separatorRect(const QList<int> &path) const { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - if (path.isEmpty()) + if (path.count() == 1) return separatorRect(index); else - return docks[index].separatorRect(path); + return docks[index].separatorRect(path.mid(1)); } -bool QDockAreaLayout::insertGap(QList<int> path, QLayoutItem *dockWidgetItem) +bool QDockAreaLayout::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem) { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - return docks[index].insertGap(path, dockWidgetItem); + return docks[index].insertGap(path.mid(1), dockWidgetItem); } -QLayoutItem *QDockAreaLayout::plug(QList<int> path) +QLayoutItem *QDockAreaLayout::plug(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - return docks[index].plug(path); + return docks[index].plug(path.mid(1)); } -QLayoutItem *QDockAreaLayout::unplug(QList<int> path) +QLayoutItem *QDockAreaLayout::unplug(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - return docks[index].unplug(path); + return docks[index].unplug(path.mid(1)); } -void QDockAreaLayout::remove(QList<int> path) +void QDockAreaLayout::remove(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - docks[index].remove(path); + docks[index].remove(path.mid(1)); } static inline int qMin(int i1, int i2, int i3) { return qMin(i1, qMin(i2, i3)); } @@ -3111,14 +3112,12 @@ QRegion QDockAreaLayout::separatorRegion() const return result; } -int QDockAreaLayout::separatorMove(QList<int> separator, const QPoint &origin, +int QDockAreaLayout::separatorMove(const QList<int> &separator, const QPoint &origin, const QPoint &dest) { int delta = 0; int index = separator.last(); - - if (separator.count() > 1) { QDockAreaLayoutInfo *info = this->info(separator); delta = pick(info->o, dest - origin); @@ -3255,7 +3254,7 @@ QSet<QWidget*> QDockAreaLayout::usedSeparatorWidgets() const return result; } -QRect QDockAreaLayout::gapRect(QList<int> path) const +QRect QDockAreaLayout::gapRect(const QList<int> &path) const { const QDockAreaLayoutInfo *info = this->info(path); if (info == 0) diff --git a/src/gui/widgets/qdockarealayout_p.h b/src/gui/widgets/qdockarealayout_p.h index 771aa52..543a201 100644 --- a/src/gui/widgets/qdockarealayout_p.h +++ b/src/gui/widgets/qdockarealayout_p.h @@ -136,18 +136,18 @@ public: QSize sizeHint() const; QSize size() const; - bool insertGap(QList<int> path, QLayoutItem *dockWidgetItem); - QLayoutItem *plug(QList<int> path); - QLayoutItem *unplug(QList<int> path); + bool insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem); + QLayoutItem *plug(const QList<int> &path); + QLayoutItem *unplug(const QList<int> &path); enum TabMode { NoTabs, AllowTabs, ForceTabs }; QList<int> gapIndex(const QPoint &pos, bool nestingEnabled, TabMode tabMode) const; - void remove(QList<int> path); + void remove(const QList<int> &path); void unnest(int index); void split(int index, Qt::Orientation orientation, QLayoutItem *dockWidgetItem); void tab(int index, QLayoutItem *dockWidgetItem); - QDockAreaLayoutItem &item(QList<int> path); - QDockAreaLayoutInfo *info(QList<int> path); + QDockAreaLayoutItem &item(const QList<int> &path); + QDockAreaLayoutInfo *info(const QList<int> &path); QDockAreaLayoutInfo *info(QWidget *widget); enum { // sentinel values used to validate state data @@ -162,9 +162,9 @@ public: bool expansive(Qt::Orientation o) const; int changeSize(int index, int size, bool below); QRect itemRect(int index) const; - QRect itemRect(QList<int> path) const; + QRect itemRect(const QList<int> &path) const; QRect separatorRect(int index) const; - QRect separatorRect(QList<int> path) const; + QRect separatorRect(const QList<int> &path) const; void clear(); bool isEmpty() const; @@ -246,18 +246,18 @@ public: QList<int> gapIndex(const QPoint &pos) const; QList<int> findSeparator(const QPoint &pos) const; - QDockAreaLayoutItem &item(QList<int> path); - QDockAreaLayoutInfo *info(QList<int> path); - const QDockAreaLayoutInfo *info(QList<int> path) const; + QDockAreaLayoutItem &item(const QList<int> &path); + QDockAreaLayoutInfo *info(const QList<int> &path); + const QDockAreaLayoutInfo *info(const QList<int> &path) const; QDockAreaLayoutInfo *info(QWidget *widget); - QRect itemRect(QList<int> path) const; + QRect itemRect(const QList<int> &path) const; QRect separatorRect(int index) const; - QRect separatorRect(QList<int> path) const; + QRect separatorRect(const QList<int> &path) const; - bool insertGap(QList<int> path, QLayoutItem *dockWidgetItem); - QLayoutItem *plug(QList<int> path); - QLayoutItem *unplug(QList<int> path); - void remove(QList<int> path); + bool insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem); + QLayoutItem *plug(const QList<int> &path); + QLayoutItem *unplug(const QList<int> &path); + void remove(const QList<int> &path); void fitLayout(); @@ -277,7 +277,7 @@ public: void paintSeparators(QPainter *p, QWidget *widget, const QRegion &clip, const QPoint &mouse) const; QRegion separatorRegion() const; - int separatorMove(QList<int> separator, const QPoint &origin, const QPoint &dest); + int separatorMove(const QList<int> &separator, const QPoint &origin, const QPoint &dest); void updateSeparatorWidgets() const; QLayoutItem *itemAt(int *x, int index) const; @@ -289,7 +289,7 @@ public: void setGrid(QVector<QLayoutStruct> *ver_struct_list, QVector<QLayoutStruct> *hor_struct_list); - QRect gapRect(QList<int> path) const; + QRect gapRect(const QList<int> &path) const; void keepSize(QDockWidget *w); diff --git a/src/gui/widgets/qtoolbararealayout.cpp b/src/gui/widgets/qtoolbararealayout.cpp index 8a10355..db2afd6 100644 --- a/src/gui/widgets/qtoolbararealayout.cpp +++ b/src/gui/widgets/qtoolbararealayout.cpp @@ -526,9 +526,10 @@ QList<int> QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos) const return QList<int>(); } -bool QToolBarAreaLayoutInfo::insertGap(QList<int> path, QLayoutItem *item) +bool QToolBarAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *item) { - int j = path.at(0); + Q_ASSERT(path.count() == 2); + int j = path.first(); if (j == lines.count()) lines.append(QToolBarAreaLayoutLine(o)); @@ -570,8 +571,9 @@ void QToolBarAreaLayoutInfo::clear() rect = QRect(); } -QRect QToolBarAreaLayoutInfo::itemRect(QList<int> path) const +QRect QToolBarAreaLayoutInfo::itemRect(const QList<int> &path) const { + Q_ASSERT(path.count() == 2); int j = path.at(0); int k = path.at(1); @@ -623,10 +625,8 @@ QRect QToolBarAreaLayoutInfo::appendLineDropRect() const ** QToolBarAreaLayout */ -QToolBarAreaLayout::QToolBarAreaLayout(QMainWindow *win) +QToolBarAreaLayout::QToolBarAreaLayout(const QMainWindow *win) : mainWindow(win), visible(true) { - visible = true; - mainWindow = win; for (int i = 0; i < QInternal::DockCount; ++i) { QInternal::DockPosition pos = static_cast<QInternal::DockPosition>(i); docks[i] = QToolBarAreaLayoutInfo(pos); @@ -1064,16 +1064,17 @@ QList<int> QToolBarAreaLayout::currentGapIndex() const return QList<int>(); } -bool QToolBarAreaLayout::insertGap(QList<int> path, QLayoutItem *item) +bool QToolBarAreaLayout::insertGap(const QList<int> &path, QLayoutItem *item) { - Q_ASSERT(!path.isEmpty()); - int i = path.takeFirst(); + Q_ASSERT(path.count() == 3); + const int i = path.first(); Q_ASSERT(i >= 0 && i < QInternal::DockCount); - return docks[i].insertGap(path, item); + return docks[i].insertGap(path.mid(1), item); } -void QToolBarAreaLayout::remove(QList<int> path) +void QToolBarAreaLayout::remove(const QList<int> &path) { + Q_ASSERT(path.count() == 3); docks[path.at(0)].lines[path.at(1)].toolBarItems.removeAt(path.at(2)); } @@ -1104,7 +1105,7 @@ void QToolBarAreaLayout::clear() rect = QRect(); } -QToolBarAreaLayoutItem &QToolBarAreaLayout::item(QList<int> path) +QToolBarAreaLayoutItem &QToolBarAreaLayout::item(const QList<int> &path) { Q_ASSERT(path.count() == 3); @@ -1116,18 +1117,18 @@ QToolBarAreaLayoutItem &QToolBarAreaLayout::item(QList<int> path) return line.toolBarItems[path.at(2)]; } -QRect QToolBarAreaLayout::itemRect(QList<int> path) const +QRect QToolBarAreaLayout::itemRect(const QList<int> &path) const { - int i = path.takeFirst(); + const int i = path.first(); - QRect r = docks[i].itemRect(path); + QRect r = docks[i].itemRect(path.mid(1)); if (docks[i].o == Qt::Horizontal) r = QStyle::visualRect(mainWindow->layoutDirection(), docks[i].rect, r); return r; } -QLayoutItem *QToolBarAreaLayout::plug(QList<int> path) +QLayoutItem *QToolBarAreaLayout::plug(const QList<int> &path) { QToolBarAreaLayoutItem &item = this->item(path); Q_ASSERT(item.gap); @@ -1136,9 +1137,10 @@ QLayoutItem *QToolBarAreaLayout::plug(QList<int> path) return item.widgetItem; } -QLayoutItem *QToolBarAreaLayout::unplug(QList<int> path, QToolBarAreaLayout *other) +QLayoutItem *QToolBarAreaLayout::unplug(const QList<int> &path, QToolBarAreaLayout *other) { //other needs to be update as well + Q_ASSERT(path.count() == 3); QToolBarAreaLayoutItem &item = this->item(path); //update the leading space here diff --git a/src/gui/widgets/qtoolbararealayout_p.h b/src/gui/widgets/qtoolbararealayout_p.h index a44fbc7..636c9ca 100644 --- a/src/gui/widgets/qtoolbararealayout_p.h +++ b/src/gui/widgets/qtoolbararealayout_p.h @@ -174,9 +174,9 @@ public: void moveToolBar(QToolBar *toolbar, int pos); QList<int> gapIndex(const QPoint &pos) const; - bool insertGap(QList<int> path, QLayoutItem *item); + bool insertGap(const QList<int> &path, QLayoutItem *item); void clear(); - QRect itemRect(QList<int> path) const; + QRect itemRect(const QList<int> &path) const; QRect appendLineDropRect() const; QRect rect; @@ -194,11 +194,11 @@ public: }; QRect rect; - QMainWindow *mainWindow; + const QMainWindow *mainWindow; QToolBarAreaLayoutInfo docks[4]; bool visible; - QToolBarAreaLayout(QMainWindow *win); + QToolBarAreaLayout(const QMainWindow *win); QRect fitLayout(); @@ -230,14 +230,14 @@ public: QList<int> indexOf(QWidget *toolBar) const; QList<int> gapIndex(const QPoint &pos) const; QList<int> currentGapIndex() const; - bool insertGap(QList<int> path, QLayoutItem *item); - void remove(QList<int> path); + bool insertGap(const QList<int> &path, QLayoutItem *item); + void remove(const QList<int> &path); void remove(QLayoutItem *item); void clear(); - QToolBarAreaLayoutItem &item(QList<int> path); - QRect itemRect(QList<int> path) const; - QLayoutItem *plug(QList<int> path); - QLayoutItem *unplug(QList<int> path, QToolBarAreaLayout *other); + QToolBarAreaLayoutItem &item(const QList<int> &path); + QRect itemRect(const QList<int> &path) const; + QLayoutItem *plug(const QList<int> &path); + QLayoutItem *unplug(const QList<int> &path, QToolBarAreaLayout *other); void saveState(QDataStream &stream) const; bool restoreState(QDataStream &stream, const QList<QToolBar*> &toolBars, uchar tmarker, bool pre43, bool testing = false); diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index f0c694d..365ae8b 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -174,22 +174,29 @@ bool QHttpNetworkConnectionPrivate::isSocketReading(QAbstractSocket *socket) con } -void QHttpNetworkConnectionPrivate::appendData(QHttpNetworkReply &reply, const QByteArray &fragment, bool compressed) +void QHttpNetworkConnectionPrivate::appendUncompressedData(QHttpNetworkReply &reply, const QByteArray &fragment) { - QByteArray *ba = (compressed) ? &reply.d_func()->compressedData : &reply.d_func()->responseData; - ba->append(fragment); - return; + reply.d_func()->responseData.append(fragment); } -qint64 QHttpNetworkConnectionPrivate::bytesAvailable(const QHttpNetworkReply &reply, bool compressed) const +void QHttpNetworkConnectionPrivate::appendCompressedData(QHttpNetworkReply &reply, const QByteArray &fragment) { - const QByteArray *ba = (compressed) ? &reply.d_func()->compressedData : &reply.d_func()->responseData; - return ba->size(); + reply.d_func()->compressedData.append(fragment); } -qint64 QHttpNetworkConnectionPrivate::read(QHttpNetworkReply &reply, QByteArray &data, qint64 maxSize, bool compressed) +qint64 QHttpNetworkConnectionPrivate::uncompressedBytesAvailable(const QHttpNetworkReply &reply) const { - QByteArray *ba = (compressed) ? &reply.d_func()->compressedData : &reply.d_func()->responseData; + return reply.d_func()->responseData.size(); +} + +qint64 QHttpNetworkConnectionPrivate::compressedBytesAvailable(const QHttpNetworkReply &reply) const +{ + return reply.d_func()->compressedData.size(); +} + +qint64 QHttpNetworkConnectionPrivate::read(QHttpNetworkReply &reply, QByteArray &data, qint64 maxSize) +{ + QByteArray *ba = &reply.d_func()->responseData; if (maxSize == -1 || maxSize >= ba->size()) { // read the whole data data = *ba; @@ -524,12 +531,14 @@ bool QHttpNetworkConnectionPrivate::expand(QAbstractSocket *socket, QHttpNetwork Q_ASSERT(socket); Q_ASSERT(reply); - qint64 total = bytesAvailable(*reply, true); + qint64 total = compressedBytesAvailable(*reply); if (total >= CHUNK || dataComplete) { int i = indexOf(socket); // uncompress the data QByteArray content, inflated; - read(*reply, content, -1, true); + content = reply->d_func()->compressedData; + reply->d_func()->compressedData.clear(); + int ret = Z_OK; if (content.size()) ret = reply->d_func()->gunzipBodyPartially(content, inflated); @@ -537,7 +546,7 @@ bool QHttpNetworkConnectionPrivate::expand(QAbstractSocket *socket, QHttpNetwork if (ret >= retCheck) { if (inflated.size()) { reply->d_func()->totalProgress += inflated.size(); - appendData(*reply, inflated, false); + appendUncompressedData(*reply, inflated); if (shouldEmitSignals(reply)) { emit reply->readyRead(); // make sure that the reply is valid @@ -638,7 +647,11 @@ void QHttpNetworkConnectionPrivate::receiveReply(QAbstractSocket *socket, QHttpN fragment.open(QIODevice::WriteOnly); bytes = reply->d_func()->readBody(socket, &fragment); if (bytes) { - appendData(*reply, fragment.data(), reply->d_func()->autoDecompress); + if (reply->d_func()->autoDecompress) + appendCompressedData(*reply, fragment.data()); + else + appendUncompressedData(*reply, fragment.data()); + if (!reply->d_func()->autoDecompress) { reply->d_func()->totalProgress += fragment.size(); if (shouldEmitSignals(reply)) { diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h index 64a6faa..bc4d948 100644 --- a/src/network/access/qhttpnetworkconnection_p.h +++ b/src/network/access/qhttpnetworkconnection_p.h @@ -254,9 +254,14 @@ public: bool pendingAuthSignal; // there is an incomplete authentication signal bool pendingProxyAuthSignal; // there is an incomplete proxy authentication signal - void appendData(QHttpNetworkReply &reply, const QByteArray &fragment, bool compressed); - qint64 bytesAvailable(const QHttpNetworkReply &reply, bool compressed = false) const; - qint64 read(QHttpNetworkReply &reply, QByteArray &data, qint64 maxSize, bool compressed); + void appendUncompressedData(QHttpNetworkReply &reply, const QByteArray &fragment); + void appendCompressedData(QHttpNetworkReply &reply, const QByteArray &fragment); + + qint64 uncompressedBytesAvailable(const QHttpNetworkReply &reply) const; + qint64 compressedBytesAvailable(const QHttpNetworkReply &reply) const; + + qint64 read(QHttpNetworkReply &reply, QByteArray &data, qint64 maxSize); + void emitReplyError(QAbstractSocket *socket, QHttpNetworkReply *reply, QNetworkReply::NetworkError errorCode); bool handleAuthenticateChallenge(QAbstractSocket *socket, QHttpNetworkReply *reply, bool isProxy, bool &resend); void allDone(QAbstractSocket *socket, QHttpNetworkReply *reply); diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index c4d4a9c..47fb6d1 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -162,7 +162,7 @@ qint64 QHttpNetworkReply::bytesAvailable() const { Q_D(const QHttpNetworkReply); if (d->connection) - return d->connection->d_func()->bytesAvailable(*this); + return d->connection->d_func()->uncompressedBytesAvailable(*this); else return -1; } @@ -172,7 +172,7 @@ QByteArray QHttpNetworkReply::read(qint64 maxSize) Q_D(QHttpNetworkReply); QByteArray data; if (d->connection) - d->connection->d_func()->read(*this, data, maxSize, false); + d->connection->d_func()->read(*this, data, maxSize); return data; } diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index 4959b60..4e32f91 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -64,19 +64,23 @@ QT_MODULE(OpenGL) static const char* const qglslMainVertexShader = "\ + uniform highp float depth;\ void setPosition();\ void main(void)\ {\ setPosition();\ + gl_Position.z = depth * gl_Position.w;\ }"; static const char* const qglslMainWithTexCoordsVertexShader = "\ attribute lowp vec2 textureCoordArray; \ varying lowp vec2 textureCoords; \ + uniform highp float depth;\ void setPosition();\ void main(void) \ {\ setPosition();\ + gl_Position.z = depth * gl_Position.w;\ textureCoords = textureCoordArray; \ }"; @@ -84,20 +88,16 @@ static const char* const qglslMainWithTexCoordsVertexShader = "\ static const char* const qglslPositionOnlyVertexShader = "\ attribute highp vec4 vertexCoordsArray;\ uniform highp mat4 pmvMatrix;\ - uniform highp float depth;\ void setPosition(void)\ {\ gl_Position = pmvMatrix * vertexCoordsArray;\ - gl_Position.z = depth;\ }"; static const char* const qglslUntransformedPositionVertexShader = "\ attribute highp vec4 vertexCoordsArray;\ - uniform highp float depth;\ void setPosition(void)\ {\ gl_Position = vertexCoordsArray;\ - gl_Position.z = depth;\ }"; // Pattern Brush - This assumes the texture size is 8x8 and thus, the inverted size is 0.125 @@ -108,11 +108,9 @@ static const char* const qglslPositionWithPatternBrushVertexShader = "\ uniform mediump vec2 invertedTextureSize; \ uniform mediump mat3 brushTransform; \ varying mediump vec2 patternTexCoords; \ - uniform highp float depth;\ void setPosition(void) { \ gl_Position = pmvMatrix * vertexCoordsArray;\ gl_Position.xy = gl_Position.xy / gl_Position.w; \ - gl_Position.z = depth;\ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ @@ -142,11 +140,9 @@ static const char* const qglslPositionWithLinearGradientBrushVertexShader = "\ uniform highp vec3 linearData; \ uniform highp mat3 brushTransform; \ varying mediump float index ; \ - uniform highp float depth;\ void setPosition() { \ gl_Position = pmvMatrix * vertexCoordsArray;\ gl_Position.xy = gl_Position.xy / gl_Position.w; \ - gl_Position.z = depth;\ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ @@ -174,12 +170,10 @@ static const char* const qglslPositionWithConicalGradientBrushVertexShader = "\ uniform mediump vec2 halfViewportSize; \ uniform highp mat3 brushTransform; \ varying highp vec2 A; \ - uniform highp float depth;\ void setPosition(void)\ {\ gl_Position = pmvMatrix * vertexCoordsArray;\ gl_Position.xy = gl_Position.xy / gl_Position.w; \ - gl_Position.z = depth; \ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ @@ -215,12 +209,10 @@ static const char* const qglslPositionWithRadialGradientBrushVertexShader = "\ uniform highp vec2 fmp; \ varying highp float b; \ varying highp vec2 A; \ - uniform highp float depth;\ void setPosition(void) \ {\ gl_Position = pmvMatrix * vertexCoordsArray;\ gl_Position.xy = gl_Position.xy / gl_Position.w; \ - gl_Position.z = depth; \ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ @@ -254,11 +246,9 @@ static const char* const qglslPositionWithTextureBrushVertexShader = "\ uniform mediump vec2 invertedTextureSize; \ uniform mediump mat3 brushTransform; \ varying mediump vec2 brushTextureCoords; \ - uniform highp float depth;\ void setPosition(void) { \ gl_Position = pmvMatrix * vertexCoordsArray;\ gl_Position.xy = gl_Position.xy / gl_Position.w; \ - gl_Position.z = depth; \ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 91df197..e24742f 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -654,6 +654,9 @@ void QGL2PaintEngineEx::sync() glDisable(GL_BLEND); glActiveTexture(GL_TEXTURE0); + + d->needsSync = true; + d->shaderManager->setDirty(); } void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) @@ -1216,6 +1219,7 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->simpleShaderDepthUniformDirty = true; d->depthUniformDirty = true; d->opacityUniformDirty = true; + d->needsSync = false; d->use_system_clip = !systemClip().isEmpty(); @@ -1294,11 +1298,15 @@ void QGL2PaintEngineEx::ensureActive() ctx->d_ptr->active_engine = this; - glDisable(GL_DEPTH_TEST); + d->needsSync = true; + } + if (d->needsSync) { glViewport(0, 0, d->width, d->height); - + glDepthMask(false); + glDepthFunc(GL_LEQUAL); setState(state()); + d->needsSync = false; } } diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 448964b..0d28a49 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -248,6 +248,8 @@ public: uint uniformIdentifiers[NumUniforms]; GLuint lastTexture; + + bool needsSync; }; QT_END_NAMESPACE diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 1b499b6..3185664 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -378,7 +378,7 @@ void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) Q_D(QDirectFBPaintEngine); d->dirtyClip = true; const QPoint bottom = d->transform.map(QPoint(0, int(path.controlPointRect().bottom()))); - if (bottom.y() >= d->lastLockedHeight) + if (bottom.y() > d->lastLockedHeight) d->lock(); QRasterPaintEngine::clip(path, op); } @@ -389,7 +389,7 @@ void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) d->dirtyClip = true; if (d->clip() && !d->clip()->hasRectClip && d->clip()->enabled) { const QPoint bottom = d->transform.map(QPoint(0, rect.bottom())); - if (bottom.y() >= d->lastLockedHeight) + if (bottom.y() > d->lastLockedHeight) d->lock(); } @@ -567,6 +567,7 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, QPixmapData *data = pixmap.pixmapData(); Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(data); + dfbData->unlockDirectFB(); IDirectFBSurface *s = dfbData->directFBSurface(); d->blit(r, s, sr); } @@ -598,6 +599,10 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, QRasterPaintEngine::drawTiledPixmap(r, pix, sp); } else { d->unlock(); + QPixmapData *data = pixmap.pixmapData(); + Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); + QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(data); + dfbData->unlockDirectFB(); d->drawTiledPixmap(r, pixmap); } } @@ -913,11 +918,17 @@ void QDirectFBPaintEnginePrivate::end() void QDirectFBPaintEnginePrivate::setPen(const QPen &p) { pen = p; - simplePen = (pen.style() == Qt::NoPen) || - (pen.style() == Qt::SolidLine - && !antialiased - && (pen.brush().style() == Qt::SolidPattern) - && (pen.widthF() <= 1 && scale != NoScale)); + if (pen.style() == Qt::NoPen) { + simplePen = true; + } else if (pen.style() == Qt::SolidLine + && !antialiased + && pen.brush().style() == Qt::SolidPattern + && pen.widthF() <= 1.0 + && (scale == NoScale || pen.isCosmetic())) { + simplePen = true; + } else { + simplePen = false; + } } void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode mode) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index 9dc7818..c9d5d7c 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -90,7 +90,6 @@ void QDirectFBPixmapData::resize(int width, int height) setSerialNumber(++global_ser_no); } - // mostly duplicated from qimage.cpp (QImageData::checkForAlphaPixels) static bool checkForAlphaPixels(const QImage &img) { @@ -209,6 +208,7 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect) QPixmapData::copy(data, rect); return; } + unlockDirectFB(); const QDirectFBPixmapData *otherData = static_cast<const QDirectFBPixmapData*>(data); IDirectFBSurface *src = otherData->directFBSurface(); @@ -296,10 +296,10 @@ void QDirectFBPixmapData::fill(const QColor &color) QPixmap QDirectFBPixmapData::transformed(const QTransform &transform, Qt::TransformationMode mode) const { + QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(this); if (!dfbSurface || transform.type() != QTransform::TxScale || mode != Qt::FastTransformation) { - QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(this); const QImage *image = that->buffer(); Q_ASSERT(image); const QImage transformed = image->transformed(transform, mode); @@ -308,6 +308,7 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform, data->fromImage(transformed, Qt::AutoColor); return QPixmap(data); } + that->unlockDirectFB(); const QSize size = transform.mapRect(QRect(0, 0, w, h)).size(); if (size.isEmpty()) diff --git a/src/script/qscriptecmaglobal.cpp b/src/script/qscriptecmaglobal.cpp index a7cb115..b756a27 100644 --- a/src/script/qscriptecmaglobal.cpp +++ b/src/script/qscriptecmaglobal.cpp @@ -305,8 +305,7 @@ public: } if (context->state() != QScriptContext::ExceptionState) { - QTextStream qout(stdout, QIODevice::WriteOnly); - qout << result << endl; + qDebug(qPrintable(result)); context->setReturnValue(eng->undefinedValue()); } #ifndef Q_SCRIPT_NO_EVENT_NOTIFY diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp index d714327..0c4fff0 100644 --- a/src/sql/drivers/ibase/qsql_ibase.cpp +++ b/src/sql/drivers/ibase/qsql_ibase.cpp @@ -97,6 +97,7 @@ static bool getIBaseError(QString& msg, ISC_STATUS* status, ISC_LONG &sqlcode, Q static void createDA(XSQLDA *&sqlda) { sqlda = (XSQLDA *) malloc(XSQLDA_LENGTH(1)); + if (sqlda == (XSQLDA*)0) return; sqlda->sqln = 1; sqlda->sqld = 0; sqlda->version = SQLDA_CURRENT_VERSION; @@ -106,8 +107,10 @@ static void createDA(XSQLDA *&sqlda) static void enlargeDA(XSQLDA *&sqlda, int n) { - free(sqlda); + if (sqlda != (XSQLDA*)0) + free(sqlda); sqlda = (XSQLDA *) malloc(XSQLDA_LENGTH(n)); + if (sqlda == (XSQLDA*)0) return; sqlda->sqln = n; sqlda->version = SQLDA_CURRENT_VERSION; } @@ -126,14 +129,14 @@ static void initDA(XSQLDA *sqlda) case SQL_TYPE_DATE: case SQL_TEXT: case SQL_BLOB: - sqlda->sqlvar[i].sqldata = (char*)malloc(sqlda->sqlvar[i].sqllen); + sqlda->sqlvar[i].sqldata = new char[sqlda->sqlvar[i].sqllen]; break; case SQL_ARRAY: - sqlda->sqlvar[i].sqldata = (char*)malloc(sizeof(ISC_QUAD)); + sqlda->sqlvar[i].sqldata = new char[sizeof(ISC_QUAD)]; memset(sqlda->sqlvar[i].sqldata, 0, sizeof(ISC_QUAD)); break; case SQL_VARYING: - sqlda->sqlvar[i].sqldata = (char*)malloc(sqlda->sqlvar[i].sqllen + sizeof(short)); + sqlda->sqlvar[i].sqldata = new char[sqlda->sqlvar[i].sqllen + sizeof(short)]; break; default: // not supported - do not bind. @@ -141,7 +144,7 @@ static void initDA(XSQLDA *sqlda) break; } if (sqlda->sqlvar[i].sqltype & 1) { - sqlda->sqlvar[i].sqlind = (short*)malloc(sizeof(short)); + sqlda->sqlvar[i].sqlind = new short[1]; *(sqlda->sqlvar[i].sqlind) = 0; } else { sqlda->sqlvar[i].sqlind = 0; @@ -154,8 +157,8 @@ static void delDA(XSQLDA *&sqlda) if (!sqlda) return; for (int i = 0; i < sqlda->sqld; ++i) { - free(sqlda->sqlvar[i].sqlind); - free(sqlda->sqlvar[i].sqldata); + delete [] sqlda->sqlvar[i].sqlind; + delete [] sqlda->sqlvar[i].sqldata; } free(sqlda); sqlda = 0; @@ -300,7 +303,7 @@ struct QIBaseEventBuffer { #endif ISC_LONG bufferLength; ISC_LONG eventId; - + enum QIBaseSubscriptionState { Starting, Subscribed, Finished }; QIBaseSubscriptionState subscriptionState; }; @@ -451,8 +454,8 @@ QVariant QIBaseResultPrivate::fetchBlob(ISC_QUAD *bId) } ba.resize(read); - bool isErr = (status[1] == isc_segstr_eof ? false : - isError(QT_TRANSLATE_NOOP("QIBaseResult", + bool isErr = (status[1] == isc_segstr_eof ? false : + isError(QT_TRANSLATE_NOOP("QIBaseResult", "Unable to read BLOB"), QSqlError::StatementError)); @@ -519,7 +522,7 @@ static char* readArrayBuffer(QList<QVariant>& list, char *buffer, short curDim, valList.append(tc->toUnicode(buffer, o)); else valList.append(QString::fromUtf8(buffer, o)); - + buffer += strLen; } break; } @@ -644,8 +647,8 @@ char* fillList<float>(char *buffer, const QList<QVariant> &list, float*) return buffer; } -static char* qFillBufferWithString(char *buffer, const QString& string, - short buflen, bool varying, bool array, +static char* qFillBufferWithString(char *buffer, const QString& string, + short buflen, bool varying, bool array, QTextCodec *tc) { QByteArray str = encodeString(tc, string); // keep a copy of the string alive in this scope @@ -885,7 +888,16 @@ bool QIBaseResult::prepare(const QString& query) setAt(QSql::BeforeFirstRow); createDA(d->sqlda); + if (d->sqlda == (XSQLDA*)0) { + qWarning()<<"QIOBaseResult: createDA(): failed to allocate memory"; + return false; + } + createDA(d->inda); + if (d->inda == (XSQLDA*)0){ + qWarning()<<"QIOBaseResult: createDA(): failed to allocate memory"; + return false; + } if (!d->transaction()) return false; @@ -906,6 +918,10 @@ bool QIBaseResult::prepare(const QString& query) return false; if (d->inda->sqld > d->inda->sqln) { enlargeDA(d->inda, d->inda->sqld); + if (d->inda == (XSQLDA*)0) { + qWarning()<<"QIOBaseResult: enlargeDA(): failed to allocate memory"; + return false; + } isc_dsql_describe_bind(d->status, &d->stmt, FBVERSION, d->inda); if (d->isError(QT_TRANSLATE_NOOP("QIBaseResult", @@ -916,6 +932,10 @@ bool QIBaseResult::prepare(const QString& query) if (d->sqlda->sqld > d->sqlda->sqln) { // need more field descriptors enlargeDA(d->sqlda, d->sqlda->sqld); + if (d->sqlda == (XSQLDA*)0) { + qWarning()<<"QIOBaseResult: enlargeDA(): failed to allocate memory"; + return false; + } isc_dsql_describe(d->status, &d->stmt, FBVERSION, d->sqlda); if (d->isError(QT_TRANSLATE_NOOP("QIBaseResult", "Could not describe statement"), @@ -983,14 +1003,14 @@ bool QIBaseResult::exec() break; case SQL_LONG: if (d->inda->sqlvar[para].sqlscale < 0) - *((long*)d->inda->sqlvar[para].sqldata) = + *((long*)d->inda->sqlvar[para].sqldata) = (long)floor(0.5 + val.toDouble() * pow(10.0, d->inda->sqlvar[para].sqlscale * -1)); else *((long*)d->inda->sqlvar[para].sqldata) = (long)val.toLongLong(); break; case SQL_SHORT: if (d->inda->sqlvar[para].sqlscale < 0) - *((short*)d->inda->sqlvar[para].sqldata) = + *((short*)d->inda->sqlvar[para].sqldata) = (short)floor(0.5 + val.toDouble() * pow(10.0, d->inda->sqlvar[para].sqlscale * -1)); else *((short*)d->inda->sqlvar[para].sqldata) = (short)val.toInt(); @@ -1717,7 +1737,7 @@ static isc_callback qEventCallback(char *result, short length, char *updated) qMutex()->lock(); QIBaseDriver *driver = qBufferDriverMap()->value(result); qMutex()->unlock(); - + // We use an asynchronous call (i.e., queued connection) because the event callback // is executed in a different thread than the one in which the driver lives. if (driver) diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp index d197388..0c92013 100644 --- a/src/sql/drivers/psql/qsql_psql.cpp +++ b/src/sql/drivers/psql/qsql_psql.cpp @@ -831,7 +831,7 @@ bool QPSQLDriver::commitTransaction() if (d->pro == QPSQLDriver::Version8 || d->pro == QPSQLDriver::Version81 || d->pro == QPSQLDriver::Version82) { - transaction_failed = QByteArray(PQcmdStatus(res)) == QByteArray("ROLLBACK")?true:false; + transaction_failed = qstrcmp(PQcmdStatus(res), "ROLLBACK") == 0; } if (!res || PQresultStatus(res) != PGRES_COMMAND_OK || transaction_failed) { diff --git a/tests/auto/qmainwindow/tst_qmainwindow.cpp b/tests/auto/qmainwindow/tst_qmainwindow.cpp index 80ba198..e46c2e1 100644 --- a/tests/auto/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/qmainwindow/tst_qmainwindow.cpp @@ -1434,10 +1434,7 @@ void MoveSeparator::apply(QMainWindow *mw) const } QVERIFY(!path.isEmpty()); - QVector<QLayoutStruct> cache; - - l->layoutState.dockAreaLayout.separatorMove(path, QPoint(0, 0), QPoint(delta, delta), &cache); - + l->layoutState.dockAreaLayout.separatorMove(path, QPoint(0, 0), QPoint(delta, delta)); } QMap<QString, QRect> dockWidgetGeometries(QMainWindow *mw) diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index b63236e..68df392 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -101,6 +101,7 @@ private slots: void automaticSemicolonInsertion(); void abortEvaluation(); void isEvaluating(); + void printFunctionWithCustomHandler(); void printThrowsException(); void errorConstructors(); void argumentsProperty(); @@ -2473,6 +2474,33 @@ void tst_QScriptEngine::isEvaluating() } } +static QtMsgType theMessageType; +static QString theMessage; + +static void myMsgHandler(QtMsgType type, const char *msg) +{ + theMessageType = type; + theMessage = QString::fromLatin1(msg); +} + +void tst_QScriptEngine::printFunctionWithCustomHandler() +{ + QScriptEngine eng; + QtMsgHandler oldHandler = qInstallMsgHandler(myMsgHandler); + QVERIFY(eng.globalObject().property("print").isFunction()); + theMessageType = QtSystemMsg; + QVERIFY(theMessage.isEmpty()); + QVERIFY(eng.evaluate("print('test')").isUndefined()); + QCOMPARE(theMessageType, QtDebugMsg); + QCOMPARE(theMessage, QString::fromLatin1("test")); + theMessageType = QtSystemMsg; + theMessage.clear(); + QVERIFY(eng.evaluate("print(3, true, 'little pigs')").isUndefined()); + QCOMPARE(theMessageType, QtDebugMsg); + QCOMPARE(theMessage, QString::fromLatin1("3 true little pigs")); + qInstallMsgHandler(oldHandler); +} + void tst_QScriptEngine::printThrowsException() { QScriptEngine eng; diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index 795ce76..a11164f 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ - +#define QT_SHAREDPOINTER_TRACK_POINTERS #include "qsharedpointer.h" #include "externaltests.h" #include <QtTest/QtTest> @@ -995,6 +995,7 @@ void tst_QSharedPointer::invalidConstructs() test.setDebugMode(true); test.setQtModules(QTest::QExternalTest::QtCore); test.setProgramHeader( + "#define QT_SHAREDPOINTER_TRACK_POINTERS\n" "#include <QtCore/qsharedpointer.h>\n" "\n" "struct Data { int i; };\n" diff --git a/tools/designer/src/components/signalsloteditor/signalslot_utils.cpp b/tools/designer/src/components/signalsloteditor/signalslot_utils.cpp index 37269c5..c268d5f 100644 --- a/tools/designer/src/components/signalsloteditor/signalslot_utils.cpp +++ b/tools/designer/src/components/signalsloteditor/signalslot_utils.cpp @@ -275,7 +275,7 @@ namespace qdesigner_internal { const QDesignerMemberSheet *memberSheet = qobject_cast<QDesignerMemberSheet*>(core->extensionManager()->extension(object, Q_TYPEID(QDesignerMemberSheetExtension))); - return memberSheet->isQt3Signal(i); + return (memberSheet && memberSheet->isQt3Signal(i)); } } @@ -294,7 +294,7 @@ namespace qdesigner_internal { const QDesignerMemberSheet *memberSheet = qobject_cast<QDesignerMemberSheet*>(core->extensionManager()->extension(object, Q_TYPEID(QDesignerMemberSheetExtension))); - return memberSheet->isQt3Slot(i); + return (memberSheet && memberSheet->isQt3Slot(i)); } } return false; |