From 9736f27a0a6c3dde4d1493e5129557e05160e546 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 8 Jun 2009 16:37:48 +0200 Subject: Make sure that indexes in the autogenerated locale info do not exceed 16bit range. Reviewed-By: TrustMe --- util/local_database/qlocalexml2cpp.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/util/local_database/qlocalexml2cpp.py b/util/local_database/qlocalexml2cpp.py index a9abe22..af6da33 100755 --- a/util/local_database/qlocalexml2cpp.py +++ b/util/local_database/qlocalexml2cpp.py @@ -237,7 +237,17 @@ class StringData: return self.hash[s] lst = map(lambda x: hex(ord(x)), s) - token = StringDataToken(len(self.data), len(lst)) + index = len(self.data) + if index >= 65535: + print "\n\n\n#error Data index is too big!" + sys.stderr.write ("\n\n\nERROR: index exceeds the uint16 range! index = %d\n" % index) + sys.exit(1) + size = len(lst) + if size >= 65535: + print "\n\n\n#error Data is too big!" + sys.stderr.write ("\n\n\nERROR: data size exceeds the uint16 range! size = %d\n" % size) + sys.exit(1) + token = StringDataToken(index, size) self.hash[s] = token self.data += lst return token -- cgit v0.12 From 3fdc5e9ca07c8058aef29d1a1e434b3ebf7815ae Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 8 Jun 2009 16:55:14 +0200 Subject: Reduce the members in QLocale to 16bit integer instea of 32 bits. That reduces memory usage. Reviewed-by: denis --- src/corelib/tools/qlocale_p.h | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index b07b948..ed7fc10 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -140,29 +140,29 @@ public: QString dateTimeToString(const QString &format, const QDate *date, const QTime *time, const QLocale *q) const; - quint32 m_language_id, m_country_id; + quint16 m_language_id, m_country_id; quint16 m_decimal, m_group, m_list, m_percent, m_zero, m_minus, m_plus, m_exponential; - quint32 m_short_date_format_idx, m_short_date_format_size; - quint32 m_long_date_format_idx, m_long_date_format_size; - quint32 m_short_time_format_idx, m_short_time_format_size; - quint32 m_long_time_format_idx, m_long_time_format_size; - quint32 m_standalone_short_month_names_idx, m_standalone_short_month_names_size; - quint32 m_standalone_long_month_names_idx, m_standalone_long_month_names_size; - quint32 m_standalone_narrow_month_names_idx, m_standalone_narrow_month_names_size; - quint32 m_short_month_names_idx, m_short_month_names_size; - quint32 m_long_month_names_idx, m_long_month_names_size; - quint32 m_narrow_month_names_idx, m_narrow_month_names_size; - quint32 m_standalone_short_day_names_idx, m_standalone_short_day_names_size; - quint32 m_standalone_long_day_names_idx, m_standalone_long_day_names_size; - quint32 m_standalone_narrow_day_names_idx, m_standalone_narrow_day_names_size; - quint32 m_short_day_names_idx, m_short_day_names_size; - quint32 m_long_day_names_idx, m_long_day_names_size; - quint32 m_narrow_day_names_idx, m_narrow_day_names_size; - quint32 m_am_idx, m_am_size; - quint32 m_pm_idx, m_pm_size; + quint16 m_short_date_format_idx, m_short_date_format_size; + quint16 m_long_date_format_idx, m_long_date_format_size; + quint16 m_short_time_format_idx, m_short_time_format_size; + quint16 m_long_time_format_idx, m_long_time_format_size; + quint16 m_standalone_short_month_names_idx, m_standalone_short_month_names_size; + quint16 m_standalone_long_month_names_idx, m_standalone_long_month_names_size; + quint16 m_standalone_narrow_month_names_idx, m_standalone_narrow_month_names_size; + quint16 m_short_month_names_idx, m_short_month_names_size; + quint16 m_long_month_names_idx, m_long_month_names_size; + quint16 m_narrow_month_names_idx, m_narrow_month_names_size; + quint16 m_standalone_short_day_names_idx, m_standalone_short_day_names_size; + quint16 m_standalone_long_day_names_idx, m_standalone_long_day_names_size; + quint16 m_standalone_narrow_day_names_idx, m_standalone_narrow_day_names_size; + quint16 m_short_day_names_idx, m_short_day_names_size; + quint16 m_long_day_names_idx, m_long_day_names_size; + quint16 m_narrow_day_names_idx, m_narrow_day_names_size; + quint16 m_am_idx, m_am_size; + quint16 m_pm_idx, m_pm_size; }; inline char QLocalePrivate::digitToCLocale(const QChar &in) const -- cgit v0.12 From 917d812013b3c34bfe71e2edfd8caa7ebd958e55 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 8 Jun 2009 17:21:00 +0200 Subject: Reduce binary size by using 16bits integers in static data over 32 bits. Reviewed-by: ogoffart --- src/corelib/xml/qxmlstream_p.h | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/corelib/xml/qxmlstream_p.h b/src/corelib/xml/qxmlstream_p.h index cf1d228..26509ff 100644 --- a/src/corelib/xml/qxmlstream_p.h +++ b/src/corelib/xml/qxmlstream_p.h @@ -127,27 +127,22 @@ public: GOTO_CHECK_OFFSET = 1017 }; - static const char *const spell []; - static const int lhs []; - static const int rhs []; - static const int goto_default []; - static const int action_default []; - static const int action_index []; - static const int action_info []; - static const int action_check []; + static const char *const spell []; + static const qint16 lhs []; + static const qint16 rhs []; + static const qint16 goto_default []; + static const qint16 action_default []; + static const qint16 action_index []; + static const qint16 action_info []; + static const qint16 action_check []; static inline int nt_action (int state, int nt) { - const int *const goto_index = &action_index [GOTO_INDEX_OFFSET]; - const int *const goto_check = &action_check [GOTO_CHECK_OFFSET]; - - const int yyn = goto_index [state] + nt; - - if (yyn < 0 || goto_check [yyn] != nt) + const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt; + if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt) return goto_default [nt]; - const int *const goto_info = &action_info [GOTO_INFO_OFFSET]; - return goto_info [yyn]; + return action_info [GOTO_INFO_OFFSET + yyn]; } static inline int t_action (int state, int token) @@ -170,7 +165,7 @@ const char *const QXmlStreamReader_Table::spell [] = { "EMPTY", "ANY", "PCDATA", 0, 0, 0, 0, "CDATA", "ID", "IDREF", "IDREFS", "ENTITIES", "NMTOKEN", "NMTOKENS", " Date: Mon, 8 Jun 2009 18:38:51 +0200 Subject: openUrl("mailto:") fails to open Thunderbird on windows. Thunderbird sets only the user level shell association for mailto. This is now being read before the default mail application registry. The registry crawling could have been avoided by using the ShellExecute() but it supports only around 2KBytes of data as parameter, so we will continue using CreateProcess(). Task-number: 251554 Reviewed-by: Jens Bache-Wiig --- src/gui/util/qdesktopservices_win.cpp | 64 +++++++++++++++-------------------- 1 file changed, 28 insertions(+), 36 deletions(-) diff --git a/src/gui/util/qdesktopservices_win.cpp b/src/gui/util/qdesktopservices_win.cpp index 0449cba..8d2701c 100644 --- a/src/gui/util/qdesktopservices_win.cpp +++ b/src/gui/util/qdesktopservices_win.cpp @@ -98,32 +98,35 @@ static bool launchWebBrowser(const QUrl &url) { if (url.scheme() == QLatin1String("mailto")) { //Retrieve the commandline for the default mail client - //the key used below is the command line for the mailto: shell command + //the default key used below is the command line for the mailto: shell command DWORD bufferSize = 2 * MAX_PATH; long returnValue = -1; QString command; HKEY handle; LONG res; - QT_WA ({ - res = RegOpenKeyExW(HKEY_CLASSES_ROOT, L"mailto\\Shell\\Open\\Command", 0, KEY_READ, &handle); - if (res != ERROR_SUCCESS) - return false; - - wchar_t keyValue[2 * MAX_PATH] = {0}; - returnValue = RegQueryValueExW(handle, L"", 0, 0, reinterpret_cast(keyValue), &bufferSize); - if (!returnValue) - command = QString::fromRawData((QChar*)keyValue, bufferSize); - }, { - res = RegOpenKeyExA(HKEY_CLASSES_ROOT, "mailto\\Shell\\Open\\Command", 0, KEY_READ, &handle); - if (res != ERROR_SUCCESS) - return false; - - char keyValue[2 * MAX_PATH] = {0}; - returnValue = RegQueryValueExA(handle, "", 0, 0, reinterpret_cast(keyValue), &bufferSize); + wchar_t keyValue[2 * MAX_PATH] = {0}; + QString keyName(QLatin1String("mailto")); + + //Check if user has set preference, otherwise use default. + res = RegOpenKeyExW(HKEY_CURRENT_USER, + L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\mailto\\UserChoice", + 0, KEY_READ, &handle); + if (res == ERROR_SUCCESS) { + returnValue = RegQueryValueEx(handle, L"Progid", 0, 0, reinterpret_cast(keyValue), &bufferSize); if (!returnValue) - command = QString::fromLocal8Bit(keyValue); - }); + keyName = QString::fromUtf16(keyValue); + RegCloseKey(handle); + } + keyName += QLatin1String("\\Shell\\Open\\Command"); + res = RegOpenKeyExW(HKEY_CLASSES_ROOT, keyName.utf16(), 0, KEY_READ, &handle); + if (res != ERROR_SUCCESS) + return false; + + bufferSize = 2 * MAX_PATH; + returnValue = RegQueryValueExW(handle, L"", 0, 0, reinterpret_cast(keyValue), &bufferSize); + if (!returnValue) + command = QString::fromRawData((QChar*)keyValue, bufferSize); RegCloseKey(handle); if(returnValue) @@ -145,19 +148,11 @@ static bool launchWebBrowser(const QUrl &url) //start the process PROCESS_INFORMATION pi; ZeroMemory(&pi, sizeof(pi)); - QT_WA ({ - STARTUPINFO si; - ZeroMemory(&si, sizeof(si)); - si.cb = sizeof(si); - - returnValue = CreateProcess(NULL, (TCHAR*)command.utf16(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); - }, { - STARTUPINFOA si; - ZeroMemory(&si, sizeof(si)); - si.cb = sizeof(si); + STARTUPINFO si; + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); - returnValue = CreateProcessA(NULL, command.toLocal8Bit().data(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); - }); + returnValue = CreateProcess(NULL, (TCHAR*)command.utf16(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); if (!returnValue) return false; @@ -171,11 +166,8 @@ static bool launchWebBrowser(const QUrl &url) return false; quintptr returnValue; - QT_WA ({ - returnValue = (quintptr)ShellExecute(0, 0, (TCHAR *) QString::fromUtf8(url.toEncoded().constData()).utf16(), 0, 0, SW_SHOWNORMAL); - } , { - returnValue = (quintptr)ShellExecuteA(0, 0, url.toEncoded().constData(), 0, 0, SW_SHOWNORMAL); - }); + returnValue = (quintptr)ShellExecute(0, 0, (TCHAR *) QString::fromUtf8(url.toEncoded().constData()).utf16(), + 0, 0, SW_SHOWNORMAL); return (returnValue > 32); } -- cgit v0.12 From 3ac9b6bdeb9f7522fa857fbc25a9da48e6d82186 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 9 Jun 2009 10:50:10 +1000 Subject: Fixed compile with MinGW 3.4. This compiler doesn't seem to follow the same rule as others for implicit conversions to/from wchar_t. Add the necessary casts, keeping in mind that sizeof(wchar_t) == 2 on Windows. --- src/gui/util/qdesktopservices_win.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/util/qdesktopservices_win.cpp b/src/gui/util/qdesktopservices_win.cpp index 8d2701c..9f8efb4 100644 --- a/src/gui/util/qdesktopservices_win.cpp +++ b/src/gui/util/qdesktopservices_win.cpp @@ -115,11 +115,11 @@ static bool launchWebBrowser(const QUrl &url) if (res == ERROR_SUCCESS) { returnValue = RegQueryValueEx(handle, L"Progid", 0, 0, reinterpret_cast(keyValue), &bufferSize); if (!returnValue) - keyName = QString::fromUtf16(keyValue); + keyName = QString::fromUtf16((const ushort*)keyValue); RegCloseKey(handle); } keyName += QLatin1String("\\Shell\\Open\\Command"); - res = RegOpenKeyExW(HKEY_CLASSES_ROOT, keyName.utf16(), 0, KEY_READ, &handle); + res = RegOpenKeyExW(HKEY_CLASSES_ROOT, (const wchar_t*)keyName.utf16(), 0, KEY_READ, &handle); if (res != ERROR_SUCCESS) return false; -- cgit v0.12 From a359abb4ccf5a2dc3bd1fac9836231677b3dc14f Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 9 Jun 2009 10:53:25 +1000 Subject: Protect EGL property names that only exist in some versions with #ifdefs Reviewed-by: trustme --- src/opengl/qegl.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/opengl/qegl.cpp b/src/opengl/qegl.cpp index f1ae4ed..290f77c 100644 --- a/src/opengl/qegl.cpp +++ b/src/opengl/qegl.cpp @@ -413,12 +413,18 @@ int QEglProperties::value(int name) const case EGL_RED_SIZE: return 0; case EGL_GREEN_SIZE: return 0; case EGL_BLUE_SIZE: return 0; - case EGL_LUMINANCE_SIZE: return 0; case EGL_ALPHA_SIZE: return 0; +#if defined(EGL_LUMINANCE_SIZE) + case EGL_LUMINANCE_SIZE: return 0; +#endif +#if defined(EGL_ALPHA_MASK_SIZE) case EGL_ALPHA_MASK_SIZE: return 0; +#endif case EGL_BIND_TO_TEXTURE_RGB: return EGL_DONT_CARE; case EGL_BIND_TO_TEXTURE_RGBA: return EGL_DONT_CARE; +#if defined(EGL_COLOR_BUFFER_TYPE) case EGL_COLOR_BUFFER_TYPE: return EGL_RGB_BUFFER; +#endif case EGL_CONFIG_CAVEAT: return EGL_DONT_CARE; case EGL_CONFIG_ID: return EGL_DONT_CARE; case EGL_DEPTH_SIZE: return 0; @@ -427,7 +433,9 @@ int QEglProperties::value(int name) const case EGL_NATIVE_VISUAL_TYPE: return EGL_DONT_CARE; case EGL_MAX_SWAP_INTERVAL: return EGL_DONT_CARE; case EGL_MIN_SWAP_INTERVAL: return EGL_DONT_CARE; +#if defined(EGL_RENDERABLE_TYPE) case EGL_RENDERABLE_TYPE: return EGL_OPENGL_ES_BIT; +#endif case EGL_SAMPLE_BUFFERS: return 0; case EGL_SAMPLES: return 0; case EGL_STENCIL_SIZE: return 0; -- cgit v0.12 From 1bbe23c5814dfda4cc6154c49e5bbf7c6ead7eba Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 9 Jun 2009 10:54:37 +1000 Subject: Make OpenGL/ES 1.1 work again for Qt/Embedded Reviewed-by: trustme --- src/opengl/qgl.cpp | 15 +++++++++++++++ src/opengl/qgl_p.h | 3 +-- src/opengl/qglframebufferobject.cpp | 2 ++ src/opengl/qglpixelbuffer.cpp | 5 +++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 2e72851..37a9916 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -65,12 +65,19 @@ #include "qimage.h" #include "qgl_p.h" +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) #include "gl2paintengineex/qpaintengineex_opengl2_p.h" +#endif #ifndef QT_OPENGL_ES_2 #include #endif +#ifdef Q_WS_QWS +#include +#include +#endif + #include #include @@ -4428,7 +4435,11 @@ void QGLDrawable::swapBuffers() void QGLDrawable::makeCurrent() { previous_fbo = 0; +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) if (!pixmapData && !fbo) { +#else +#endif + if (!fbo) { QGLContext *ctx = context(); previous_fbo = ctx->d_ptr->current_fbo; ctx->d_ptr->current_fbo = 0; @@ -4561,8 +4572,10 @@ QColor QGLDrawable::backgroundColor() const { if (widget) return widget->palette().brush(widget->backgroundRole()).color(); +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) else if (pixmapData) return pixmapData->fillColor(); +#endif return QApplication::palette().brush(QPalette::Background).color(); } @@ -4590,8 +4603,10 @@ bool QGLDrawable::autoFillBackground() const { if (widget) return widget->autoFillBackground(); +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) else if (pixmapData) return pixmapData->needsFill(); +#endif else return false; } diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index b3523d4..4af8598 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -428,8 +428,7 @@ private: extern Q_OPENGL_EXPORT QGLShareRegister* qgl_share_reg(); #ifdef Q_WS_QWS -class QOpenGLPaintEngine; -extern QOpenGLPaintEngine* qt_qgl_paint_engine(); +extern QPaintEngine* qt_qgl_paint_engine(); extern EGLDisplay qt_qgl_egl_display(); #endif diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 3e7ca0a..fb16107 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -43,7 +43,9 @@ #include #include +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) #include +#endif #ifndef QT_OPENGL_ES_2 #include diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index 483856a..0af97e3 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -76,12 +76,13 @@ \sa {opengl/pbuffers}{Pbuffers Example} */ -#include - #include #include #include +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) +#include +#endif #ifndef QT_OPENGL_ES_2 #include #endif -- cgit v0.12 From 6d4fe549e7a258913b19f52e29bcfb84cc8a97ad Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 9 Jun 2009 12:58:10 +1000 Subject: Fix build breakage from 1bbe23c5 - endif in the wrong place Reviewed-by: trustme --- src/opengl/qgl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 37a9916..146d088 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4438,8 +4438,8 @@ void QGLDrawable::makeCurrent() #if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) if (!pixmapData && !fbo) { #else -#endif if (!fbo) { +#endif QGLContext *ctx = context(); previous_fbo = ctx->d_ptr->current_fbo; ctx->d_ptr->current_fbo = 0; -- cgit v0.12 From cea87b08520888feff2f10d1bbf71bc8c2f1d780 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 9 Jun 2009 13:20:51 +1000 Subject: Another breakage in 1bbe23c5 - move qpaintengineex_opengl2_p.h include up Moving qpaintengineex_opengl2_p.h down caused it to come after an include of , which causes problems on some platforms. Move it back up again. Reviewed-by: trustme --- src/opengl/qglpixelbuffer.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index 0af97e3..9b7a506 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -76,13 +76,16 @@ \sa {opengl/pbuffers}{Pbuffers Example} */ -#include -#include -#include +#include #if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) #include #endif + +#include +#include +#include + #ifndef QT_OPENGL_ES_2 #include #endif -- cgit v0.12 From ebcf875d90d940103e409de9127bb592d7336afe Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 9 Jun 2009 09:10:53 +0200 Subject: qdoc: Inserted
between summary sections. Also added the left and right borders to the function headers in the detail sections. --- tools/qdoc3/htmlgenerator.cpp | 3 ++- tools/qdoc3/test/classic.css | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 90d3b04..0c21534 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1073,6 +1073,7 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, if (!s->inherited.isEmpty()) needOtherSection = true; } else { + out() << "
\n"; out() << "\n"; @@ -2335,7 +2336,7 @@ void HtmlGenerator::generateSynopsis(const Node *node, QString HtmlGenerator::highlightedCode(const QString& markedCode, CodeMarker *marker, const Node *relative, - CodeMarker::SynopsisStyle style, + CodeMarker::SynopsisStyle , bool nameAlignment) { QString src = markedCode; diff --git a/tools/qdoc3/test/classic.css b/tools/qdoc3/test/classic.css index 3e2370d..85bb348 100644 --- a/tools/qdoc3/test/classic.css +++ b/tools/qdoc3/test/classic.css @@ -17,7 +17,7 @@ h3.fn,span.fn background-color: #e0eff6; border-width: 1px; border-style: solid; - border-color: #3388be #e0eff6 #e9f8ff #e0eff6; + border-color: #3388be #3388be #e9f8ff #3388be; font-weight: bold; padding: 6px 0px 6px 10px; } -- cgit v0.12 From 662d1db6ee1a78c298acc11e7528e73c0415fc75 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 9 Jun 2009 10:32:20 +0200 Subject: doc: Corrected the rich text page wrt smallcaps. Task-number: 254912 --- doc/src/richtext.qdoc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/src/richtext.qdoc b/doc/src/richtext.qdoc index fbd8adb..6ea82f8 100644 --- a/doc/src/richtext.qdoc +++ b/doc/src/richtext.qdoc @@ -1058,8 +1058,11 @@ Ideas for other sections: \o Specifies where an image or a text will be placed in another element. Note that the \c float property is only supported for tables and images. \row \o \c text-transform - \o [ uppercase | lowercase | smallcaps ] + \o [ uppercase | lowercase ] \o Select the transformation that will be performed on the text prior to displaying it. + \row \o \c font-variant + \o small-caps + \o Perform the smallcaps transformation on the text prior to displaying it. \row \o \c word-spacing \o px \o Specifies an alternate spacing between each word. -- cgit v0.12 From 91ceb21d1d5f6447a47853b6625fb51d2f21cf16 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 9 Jun 2009 10:51:26 +0200 Subject: small refactoring to reduce memory usage of static data --- src/corelib/codecs/qisciicodec.cpp | 2 +- src/corelib/tools/qlocale.cpp | 2 +- src/corelib/tools/qlocale_data_p.h | 10 +++++----- src/corelib/xml/qxmlstream.cpp | 7 +++---- util/local_database/qlocalexml2cpp.py | 6 +++--- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/corelib/codecs/qisciicodec.cpp b/src/corelib/codecs/qisciicodec.cpp index dd2bc8d..de1e477 100644 --- a/src/corelib/codecs/qisciicodec.cpp +++ b/src/corelib/codecs/qisciicodec.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE struct Codecs { - const char *name; + const char name[10]; ushort base; }; diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 00132d7..4898e10 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -772,7 +772,7 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const Instead it can return a "Windows code". This maps windows codes to ISO country names. */ struct WindowsToISOListElt { - int windows_code; + ushort windows_code; char iso_name[6]; }; diff --git a/src/corelib/tools/qlocale_data_p.h b/src/corelib/tools/qlocale_data_p.h index 37f59a4..e0eecf3 100644 --- a/src/corelib/tools/qlocale_data_p.h +++ b/src/corelib/tools/qlocale_data_p.h @@ -60,8 +60,8 @@ QT_BEGIN_NAMESPACE */ struct CountryLanguage { - quint32 languageId; - quint32 countryId; + quint16 languageId; + quint16 countryId; }; static const CountryLanguage ImperialMeasurementSystems[] = { { 31, 225 }, @@ -83,7 +83,7 @@ static const int ImperialMeasurementSystemsCount = */ -static const uint locale_index[] = { +static const quint16 locale_index[] = { 0, // unused 0, // C 0, // Abkhazian @@ -2313,7 +2313,7 @@ static const char language_name_list[] = "Chewa\0" ; -static const uint language_name_index[] = { +static const quint16 language_name_index[] = { 0, // Unused 8, // C 10, // Abkhazian @@ -2727,7 +2727,7 @@ static const char country_name_list[] = "SerbiaAndMontenegro\0" ; -static const uint country_name_index[] = { +static const quint16 country_name_index[] = { 0, // AnyCountry 8, // Afghanistan 20, // Albania diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp index 5e1fec3..fddcecf 100644 --- a/src/corelib/xml/qxmlstream.cpp +++ b/src/corelib/xml/qxmlstream.cpp @@ -629,7 +629,7 @@ while () { $sizes[$i++] = $counter; $counter += length 1 + $_; } -print " \"\\0\";\n\nstatic const int QXmlStreamReader_tokenTypeString_indices[] = {\n "; +print " \"\\0\";\n\nstatic const short QXmlStreamReader_tokenTypeString_indices[] = {\n "; for ($j = 0; $j < $i; ++$j) { printf "$sizes[$j], "; } @@ -660,10 +660,9 @@ static const char QXmlStreamReader_tokenTypeString_string[] = "Comment\0" "DTD\0" "EntityReference\0" - "ProcessingInstruction\0" - "\0"; + "ProcessingInstruction\0"; -static const int QXmlStreamReader_tokenTypeString_indices[] = { +static const short QXmlStreamReader_tokenTypeString_indices[] = { 0, 8, 16, 30, 42, 55, 66, 77, 85, 89, 105, 0 }; diff --git a/util/local_database/qlocalexml2cpp.py b/util/local_database/qlocalexml2cpp.py index af6da33..d625cfd 100755 --- a/util/local_database/qlocalexml2cpp.py +++ b/util/local_database/qlocalexml2cpp.py @@ -318,7 +318,7 @@ def main(): print # Locale index - print "static const uint locale_index[] = {" + print "static const quint16 locale_index[] = {" print " 0, // unused" index = 0 for key in language_map.keys(): @@ -454,7 +454,7 @@ def main(): print # Language name index - print "static const uint language_name_index[] = {" + print "static const quint16 language_name_index[] = {" print " 0, // Unused" index = 8 for key in language_map.keys(): @@ -477,7 +477,7 @@ def main(): print # Country name index - print "static const uint country_name_index[] = {" + print "static const quint16 country_name_index[] = {" print " 0, // AnyCountry" index = 8 for key in country_map.keys(): -- cgit v0.12 From b1658783099b75097f02bef85c4ea2a469826d37 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 4 Jun 2009 19:49:41 +0200 Subject: make bic test works in shadow build --- tests/auto/bic/bic.pro | 6 ++++++ tests/auto/bic/tst_bic.cpp | 33 +++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/tests/auto/bic/bic.pro b/tests/auto/bic/bic.pro index a168d77..82711c9 100644 --- a/tests/auto/bic/bic.pro +++ b/tests/auto/bic/bic.pro @@ -2,3 +2,9 @@ load(qttest_p4) SOURCES += tst_bic.cpp qbic.cpp QT = core +wince*:{ + DEFINES += SRCDIR=\\\"\\\" +} else { + DEFINES += SRCDIR=\\\"$$PWD/\\\" +} + diff --git a/tests/auto/bic/tst_bic.cpp b/tests/auto/bic/tst_bic.cpp index 181c275..8bc8d4f 100644 --- a/tests/auto/bic/tst_bic.cpp +++ b/tests/auto/bic/tst_bic.cpp @@ -165,30 +165,30 @@ void tst_Bic::sizesAndVTables_data() #if defined Q_OS_LINUX && defined Q_WS_X11 # if defined(__powerpc__) && !defined(__powerpc64__) - archFileName400 = "data/%1.4.0.0.linux-gcc-ppc32.txt"; - archFileName410 = "data/%1.4.1.0.linux-gcc-ppc32.txt"; - archFileName420 = "data/%1.4.2.0.linux-gcc-ppc32.txt"; + archFileName400 = SRCDIR "data/%1.4.0.0.linux-gcc-ppc32.txt"; + archFileName410 = SRCDIR "data/%1.4.1.0.linux-gcc-ppc32.txt"; + archFileName420 = SRCDIR "data/%1.4.2.0.linux-gcc-ppc32.txt"; # elif defined(__amd64__) - archFileName400 = "data/%1.4.0.0.linux-gcc-amd64.txt"; + archFileName400 = SRCDIR "data/%1.4.0.0.linux-gcc-amd64.txt"; # elif defined(__i386__) - archFileName400 = "data/%1.4.0.0.linux-gcc-ia32.txt"; - archFileName410 = "data/%1.4.1.0.linux-gcc-ia32.txt"; - archFileName420 = "data/%1.4.2.0.linux-gcc-ia32.txt"; - archFileName430 = "data/%1.4.3.0.linux-gcc-ia32.txt"; + archFileName400 = SRCDIR "data/%1.4.0.0.linux-gcc-ia32.txt"; + archFileName410 = SRCDIR "data/%1.4.1.0.linux-gcc-ia32.txt"; + archFileName420 = SRCDIR "data/%1.4.2.0.linux-gcc-ia32.txt"; + archFileName430 = SRCDIR "data/%1.4.3.0.linux-gcc-ia32.txt"; # endif #elif defined Q_OS_AIX if (sizeof(void*) == 4) - archFileName400 = "data/%1.4.0.0.aix-gcc-power32.txt"; + archFileName400 = SRCDIR "data/%1.4.0.0.aix-gcc-power32.txt"; #elif defined Q_OS_MAC && defined(__powerpc__) - archFileName400 = "data/%1.4.0.0.macx-gcc-ppc32.txt"; - archFileName410 = "data/%1.4.1.0.macx-gcc-ppc32.txt"; - archFileName420 = "data/%1.4.2.0.macx-gcc-ppc32.txt"; + archFileName400 = SRCDIR "data/%1.4.0.0.macx-gcc-ppc32.txt"; + archFileName410 = SRCDIR "data/%1.4.1.0.macx-gcc-ppc32.txt"; + archFileName420 = SRCDIR "data/%1.4.2.0.macx-gcc-ppc32.txt"; #elif defined Q_OS_MAC && defined(__i386__) - archFileName410 = "data/%1.4.1.0.macx-gcc-ia32.txt"; - archFileName420 = "data/%1.4.2.0.macx-gcc-ia32.txt"; + archFileName410 = SRCDIR "data/%1.4.1.0.macx-gcc-ia32.txt"; + archFileName420 = SRCDIR "data/%1.4.2.0.macx-gcc-ia32.txt"; #elif defined Q_OS_WIN && defined Q_CC_GNU - archFileName410 = "data/%1.4.1.0.win32-gcc-ia32.txt"; - archFileName420 = "data/%1.4.2.0.win32-gcc-ia32.txt"; + archFileName410 = SRCDIR "data/%1.4.1.0.win32-gcc-ia32.txt"; + archFileName420 = SRCDIR "data/%1.4.2.0.win32-gcc-ia32.txt"; #endif if (archFileName400.isEmpty() && archFileName410.isEmpty() @@ -293,6 +293,7 @@ void tst_Bic::sizesAndVTables() bool isFailed = false; + qDebug() << oldLib.arg(libName); if (oldLib.isEmpty() || !QFile::exists(oldLib.arg(libName))) QSKIP("No platform spec found for this platform/version.", SkipSingle); -- cgit v0.12 From c5a9996213a535ad6b1e183ed258913082213073 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 9 Jun 2009 11:10:46 +0200 Subject: Fix focus frame on combobox on non-Windows styles State_KeyboardFocusChange only makes sens on Windows. Follow the logic on the combobox as in PE_FrameFocusRect in the QWindowsStyle Task-number: 255482 Reviewed-by: jbache --- src/gui/styles/qcleanlooksstyle.cpp | 3 ++- src/gui/styles/qgtkstyle.cpp | 2 +- src/gui/styles/qplastiquestyle.cpp | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index b33dfc1..805cd05 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -3305,7 +3305,8 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp } } // Draw the focus rect - if ((focus && (option->state & State_KeyboardFocusChange)) && !comboBox->editable) { + if (focus && !comboBox->editable + && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget))) { QStyleOptionFocusRect focus; focus.rect = subControlRect(CC_ComboBox, &comboBoxCopy, SC_ComboBoxEditField, widget) .adjusted(0, 2, option->direction == Qt::RightToLeft ? 1 : -1, -2); diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 1fe4627..ab81d97 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -1426,7 +1426,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom QGtk::gtk_widget_style_get(gtkToggleButton, "interior-focus", &interiorFocus, NULL); int xt = interiorFocus ? gtkToggleButton->style->xthickness : 0; int yt = interiorFocus ? gtkToggleButton->style->ythickness : 0; - if ((focus && (option->state & State_KeyboardFocusChange))) + if (focus && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget))) gtkCachedPainter.paintFocus(gtkToggleButton, "button", option->rect.adjusted(xt, yt, -xt, -yt), option->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL, diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp index 01c0e44..0a56213 100644 --- a/src/gui/styles/qplastiquestyle.cpp +++ b/src/gui/styles/qplastiquestyle.cpp @@ -4568,7 +4568,8 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt } // Draw the focus rect - if (((option->state & State_HasFocus) && (option->state & State_KeyboardFocusChange)) && !comboBox->editable) { + if ((option->state & State_HasFocus) && !comboBox->editable + && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget))) { QStyleOptionFocusRect focus; focus.rect = subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget) .adjusted(-2, 0, 2, 0); -- cgit v0.12 From 9b88c6f485016b53d394a88106a048495cf79294 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Tue, 9 Jun 2009 11:58:45 +0200 Subject: Fix QImageReader autotest compilation --- tests/auto/qimagereader/qimagereader.qrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qimagereader/qimagereader.qrc b/tests/auto/qimagereader/qimagereader.qrc index 3c674ad..c6b963b 100644 --- a/tests/auto/qimagereader/qimagereader.qrc +++ b/tests/auto/qimagereader/qimagereader.qrc @@ -30,7 +30,7 @@ images/image.pgm images/image.png images/image.ppm - images/image.tif + images/image_100dpi.tif images/kollada.png images/marble.xpm images/namedcolors.xpm -- cgit v0.12 From d826a08add652314bb22bee44e0d43bbd672f272 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Tue, 9 Jun 2009 12:02:59 +0200 Subject: Fix floating point exception in QImageReader::setScaledSize(QSize(0, 0)) Avoid a division by 0 when doing QImageReader::setScaledSize(QSize(0, 0)) for jpeg formats. Reviewed-by: thierry Task-number: 255627 --- src/plugins/imageformats/jpeg/qjpeghandler.cpp | 3 ++- tests/auto/qimagereader/tst_qimagereader.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp index 6d0bc1f..088ef97 100644 --- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp +++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp @@ -781,7 +781,8 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage, #ifndef QT_NO_IMAGE_SMOOTHSCALE // If high quality not required, shrink image during decompression - if (scaledSize.isValid() && quality < HIGH_QUALITY_THRESHOLD && !params.contains(QLatin1String("GetHeaderInformation")) ) { + if (scaledSize.isValid() && !scaledSize.isEmpty() && quality < HIGH_QUALITY_THRESHOLD + && !params.contains(QLatin1String("GetHeaderInformation")) ) { cinfo.scale_denom = qMin(cinfo.image_width / scaledSize.width(), cinfo.image_width / scaledSize.height()); if (cinfo.scale_denom < 2) { diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index f5313eb..0b32f0a 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -156,6 +156,9 @@ private slots: void pixelCompareWithBaseline_data(); void pixelCompareWithBaseline(); + + void task255627_setNullScaledSize_data(); + void task255627_setNullScaledSize(); }; static const QLatin1String prefix(SRCDIR "/images/"); @@ -333,6 +336,29 @@ void tst_QImageReader::setScaledSize() QCOMPARE(image.size(), newSize); } +void tst_QImageReader::task255627_setNullScaledSize_data() +{ + setScaledSize_data(); +} + +void tst_QImageReader::task255627_setNullScaledSize() +{ + QFETCH(QString, fileName); + QFETCH(QByteArray, format); + + if (!format.isEmpty() && !QImageReader::supportedImageFormats().contains(format)) + QSKIP("Qt does not support reading the \"" + format + "\" format", SkipSingle); + + QImageReader reader(prefix + fileName); + + // set a null size + reader.setScaledSize(QSize(0, 0)); + reader.setQuality(0); + QImage image = reader.read(); + QVERIFY(image.isNull()); + QCOMPARE(image.size(), QSize(0, 0)); +} + void tst_QImageReader::setClipRect_data() { QTest::addColumn("fileName"); -- cgit v0.12 From 2de2018a33ea45b32963378bb4f7ef24cd181485 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 9 Jun 2009 12:32:05 +0200 Subject: WinCE doesn't have time() function, use QTime --- examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp b/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp index d360de9..2368608 100644 --- a/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp +++ b/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp @@ -42,13 +42,12 @@ #include "random_ai_plugin.h" #include +#include #include -#include - QState *RandomAiPlugin::create(QState *parentState, QObject *tank) { - qsrand(uint(time(NULL))); + qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); QState *topLevel = new QState(parentState); -- cgit v0.12 From d6f171c9baa61858aea0db36fd8b1bd3219ffd0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 5 Jun 2009 11:47:32 +0200 Subject: Improved clipping in GL2 paint engine. Use the stencil method to draw clip paths and regions to the Z-buffer instead of using glClear / glScissor. Using different depth values for the various clip parts also makes restore() very cheap when only IntersectClip is used. As an additional bonus this patch gives antialiased clip in the GL 2 paint engine. Task-number: 254658 Reviewed-by: Trond --- src/gui/painting/qpaintengineex.cpp | 80 ++++- src/gui/painting/qpaintengineex_p.h | 32 +- src/gui/painting/qpainter.h | 1 + .../gl2paintengineex/qglengineshadermanager.cpp | 3 +- .../gl2paintengineex/qglengineshadersource_p.h | 14 + .../gl2paintengineex/qpaintengineex_opengl2.cpp | 374 ++++++++++++--------- .../gl2paintengineex/qpaintengineex_opengl2_p.h | 25 +- 7 files changed, 343 insertions(+), 186 deletions(-) diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 28f9220..3cf5ff9 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -138,6 +138,76 @@ QPaintEngineExPrivate::~QPaintEngineExPrivate() } +void QPaintEngineExPrivate::replayClipOperations() +{ + Q_Q(QPaintEngineEx); + + QPainter *p = q->painter(); + if (!p || !p->d_ptr) + return; + + QPainterPrivate *pp = p->d_ptr; + QList clipInfo = pp->state->clipInfo; + + QTransform transform = q->state()->matrix; + + QTransform redirection; + redirection.translate(-q->state()->redirection_offset.x(), -q->state()->redirection_offset.y()); + + for (int i = 0; i < clipInfo.size(); ++i) { + const QPainterClipInfo &info = clipInfo.at(i); + + QTransform combined = info.matrix * redirection; + + if (combined != q->state()->matrix) { + q->state()->matrix = combined; + q->transformChanged(); + } + + switch (info.clipType) { + case QPainterClipInfo::RegionClip: + q->clip(info.region, info.operation); + break; + case QPainterClipInfo::PathClip: + q->clip(info.path, info.operation); + break; + case QPainterClipInfo::RectClip: + q->clip(info.rect, info.operation); + break; + case QPainterClipInfo::RectFClip: { + qreal right = info.rectf.x() + info.rectf.width(); + qreal bottom = info.rectf.y() + info.rectf.height(); + qreal pts[] = { info.rectf.x(), info.rectf.y(), + right, info.rectf.y(), + right, bottom, + info.rectf.x(), bottom }; + QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint); + q->clip(vp, info.operation); + break; + } + } + } + + if (transform != q->state()->matrix) { + q->state()->matrix = transform; + q->transformChanged(); + } +} + + +bool QPaintEngineExPrivate::hasClipOperations() const +{ + Q_Q(const QPaintEngineEx); + + QPainter *p = q->painter(); + if (!p || !p->d_ptr) + return false; + + QPainterPrivate *pp = p->d_ptr; + QList clipInfo = pp->state->clipInfo; + + return !clipInfo.isEmpty(); +} /******************************************************************************* * @@ -244,13 +314,18 @@ static void qpaintengineex_cubicTo(qreal c1x, qreal c1y, qreal c2x, qreal c2y, q ((StrokeHandler *) data)->types.add(QPainterPath::CurveToDataElement); } +QPaintEngineEx::QPaintEngineEx() + : QPaintEngine(*new QPaintEngineExPrivate, AllFeatures) +{ + extended = true; +} + QPaintEngineEx::QPaintEngineEx(QPaintEngineExPrivate &data) : QPaintEngine(data, AllFeatures) { extended = true; } - QPainterState *QPaintEngineEx::createState(QPainterState *orig) const { if (!orig) @@ -483,6 +558,9 @@ void QPaintEngineEx::clip(const QRect &r, Qt::ClipOperation op) void QPaintEngineEx::clip(const QRegion ®ion, Qt::ClipOperation op) { + if (region.numRects() == 1) + clip(region.boundingRect(), op); + QVector rects = region.rects(); if (rects.size() <= 32) { qreal pts[2*32*4]; diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h index 1c55242..3f64260 100644 --- a/src/gui/painting/qpaintengineex_p.h +++ b/src/gui/painting/qpaintengineex_p.h @@ -139,27 +139,13 @@ public: QDebug Q_GUI_EXPORT &operator<<(QDebug &, const QVectorPath &path); #endif -class Q_GUI_EXPORT QPaintEngineExPrivate : public QPaintEnginePrivate -{ -public: - QPaintEngineExPrivate(); - ~QPaintEngineExPrivate(); - - QStroker stroker; - QDashStroker dasher; - StrokeHandler *strokeHandler; - QStrokerOps *activeStroker; - QPen strokerPen; -}; - class QPixmapFilter; class Q_GUI_EXPORT QPaintEngineEx : public QPaintEngine { Q_DECLARE_PRIVATE(QPaintEngineEx) public: - inline QPaintEngineEx() - : QPaintEngine(*new QPaintEngineExPrivate, AllFeatures) { extended = true; } + QPaintEngineEx(); virtual QPainterState *createState(QPainterState *orig) const; @@ -224,6 +210,22 @@ protected: QPaintEngineEx(QPaintEngineExPrivate &data); }; +class Q_GUI_EXPORT QPaintEngineExPrivate : public QPaintEnginePrivate +{ + Q_DECLARE_PUBLIC(QPaintEngineEx) +public: + QPaintEngineExPrivate(); + ~QPaintEngineExPrivate(); + + void replayClipOperations(); + bool hasClipOperations() const; + + QStroker stroker; + QDashStroker dasher; + StrokeHandler *strokeHandler; + QStrokerOps *activeStroker; + QPen strokerPen; +}; inline uint QVectorPath::polygonFlags(QPaintEngine::PolygonDrawMode mode) { switch (mode) { diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h index f3df7a3..78cd713 100644 --- a/src/gui/painting/qpainter.h +++ b/src/gui/painting/qpainter.h @@ -507,6 +507,7 @@ private: friend class QFontEngineXLFD; friend class QWSManager; friend class QPaintEngine; + friend class QPaintEngineExPrivate; friend class QOpenGLPaintEngine; friend class QX11PaintEngine; friend class QX11PaintEnginePrivate; diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index ea57fdf..5c541d0 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -157,6 +157,7 @@ QGLEngineShaderManager::QGLEngineShaderManager(QGLContext* context) simpleShaderProg->addShader(compiledShaders[PositionOnlyVertexShader]); simpleShaderProg->addShader(compiledShaders[MainFragmentShader]); simpleShaderProg->addShader(compiledShaders[ShockingPinkSrcFragmentShader]); + simpleShaderProg->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); simpleShaderProg->link(); if (!simpleShaderProg->isLinked()) { qCritical() << "Errors linking simple shader:" @@ -444,7 +445,7 @@ bool QGLEngineShaderManager::useCorrectShaderProg() requiredProgram.program->addShader(requiredProgram.compositionFragShader); // We have to bind the vertex attribute names before the program is linked: - requiredProgram.program->bindAttributeLocation("inputVertex", QT_VERTEX_COORDS_ATTR); + requiredProgram.program->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); if (useTextureCoords) requiredProgram.program->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR); diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index 920d0bc..70cc67e 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -84,16 +84,20 @@ 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 @@ -104,9 +108,11 @@ 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; \ @@ -136,9 +142,11 @@ 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; \ @@ -166,10 +174,12 @@ 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; \ @@ -205,10 +215,12 @@ 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; \ @@ -242,9 +254,11 @@ 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 868adcf..fae3045 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -183,8 +183,8 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) pex->transferMode(BrushDrawingMode); - glDisable(GL_SCISSOR_TEST); glDisable(GL_DEPTH_TEST); + glDisable(GL_SCISSOR_TEST); glViewport(0, 0, oldWidth, oldHeight); @@ -217,7 +217,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo); glViewport(0, 0, pex->width, pex->height); - pex->updateDepthClip(); + pex->updateDepthScissorTest(); } void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) @@ -297,6 +297,11 @@ void QGL2PaintEngineExPrivate::useSimpleShader() shaderManager->simpleProgram()->setUniformValue("pmvMatrix", pmvMatrix); simpleShaderMatrixUniformDirty = false; } + + if (simpleShaderDepthUniformDirty) { + shaderManager->simpleProgram()->setUniformValue("depth", (GLfloat)q->state()->currentDepth); + simpleShaderDepthUniformDirty = false; + } } @@ -709,6 +714,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) if (path.shape() == QVectorPath::RectangleHint) { QGLRect rect(points[0].x(), points[0].y(), points[2].x(), points[2].y()); prepareForDraw(currentBrush->isOpaque()); + composite(rect); } else if (path.shape() == QVectorPath::EllipseHint) { @@ -739,13 +745,13 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(QGL2PEXVertexArray& vertexArray, bool useWindingFill) { // qDebug("QGL2PaintEngineExPrivate::fillStencilWithVertexArray()"); - if (stencilBuferDirty) { + if (stencilBufferDirty) { // Clear the stencil buffer to zeros glDisable(GL_STENCIL_TEST); glStencilMask(0xFFFF); // Enable writing to stencil buffer, otherwise glClear wont do anything. glClearStencil(0); // Clear to zero glClear(GL_STENCIL_BUFFER_BIT); - stencilBuferDirty = false; + stencilBufferDirty = false; } glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // Disable color writes @@ -843,6 +849,7 @@ void QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque) // The shader program has changed so mark all uniforms as dirty: brushUniformsDirty = true; shaderMatrixUniformDirty = true; + depthUniformDirty = true; } if (brushUniformsDirty && mode != ImageDrawingMode) @@ -853,6 +860,11 @@ void QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque) shaderMatrixUniformDirty = false; } + if (depthUniformDirty) { + shaderManager->currentProgram()->setUniformValue("depth", (GLfloat)q->state()->currentDepth); + depthUniformDirty = false; + } + if (useGlobalOpacityUniform) shaderManager->currentProgram()->setUniformValue("globalOpacity", (GLfloat)q->state()->opacity); } @@ -1062,7 +1074,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextIte matrix.translate(p.x(), p.y()); ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); - QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0 ? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat) : QFontEngineGlyphCache::Raster_A8; @@ -1146,6 +1157,7 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) } d->ctx->d_ptr->active_engine = this; + d->last_created_state = 0; d->drawable.makeCurrent(); QSize sz = d->drawable.size(); @@ -1172,12 +1184,16 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->brushUniformsDirty = true; d->matrixDirty = true; d->compositionModeDirty = true; - d->stencilBuferDirty = true; + d->stencilBufferDirty = true; + d->simpleShaderDepthUniformDirty = true; + d->depthUniformDirty = true; d->use_system_clip = !systemClip().isEmpty(); glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); + glDepthFunc(GL_LEQUAL); + glDepthMask(false); QGLPixmapData *source = d->drawable.copyOnBegin(); if (d->drawable.context()->d_func()->clear_on_painter_begin && d->drawable.autoFillBackground()) { @@ -1201,7 +1217,7 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->drawTexture(QRectF(rect), QRectF(rect), rect.size(), true); } - updateClipRegion(QRegion(), Qt::NoClip); + d->systemStateChanged(); return true; } @@ -1245,260 +1261,296 @@ void QGL2PaintEngineEx::ensureActive() ctx->d_ptr->active_engine = this; glDisable(GL_DEPTH_TEST); - glDisable(GL_SCISSOR_TEST); glViewport(0, 0, d->width, d->height); + setState(state()); - d->updateDepthClip(); } } +void QGL2PaintEngineExPrivate::updateDepthScissorTest() +{ + Q_Q(QGL2PaintEngineEx); + if (q->state()->depthTestEnabled) + glEnable(GL_DEPTH_TEST); + else + glDisable(GL_DEPTH_TEST); -/////////////////////////////////// State/Clipping stolen from QOpenGLPaintEngine ////////////////////////////////////////// + if (q->state()->scissorTestEnabled) + glEnable(GL_SCISSOR_TEST); + else + glDisable(GL_SCISSOR_TEST); +} void QGL2PaintEngineEx::clipEnabledChanged() { Q_D(QGL2PaintEngineEx); - d->updateDepthClip(); + d->simpleShaderDepthUniformDirty = true; + d->depthUniformDirty = true; + + if (painter()->hasClipping()) { + d->regenerateDepthClip(); + } else { + if (d->use_system_clip) { + state()->currentDepth = -0.5f; + } else { + glDisable(GL_DEPTH_TEST); + state()->depthTestEnabled = false; + } + } } -void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) +void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, float depth) { -// qDebug("QGL2PaintEngineEx::clip()"); - const qreal *points = path.points(); - const QPainterPath::ElementType *types = path.elements(); - if (!types && path.shape() == QVectorPath::RectangleHint) { - QRectF r(points[0], points[1], points[4]-points[0], points[5]-points[1]); - updateClipRegion(QRegion(r.toRect()), op); - return; - } + transferMode(BrushDrawingMode); - QPainterPath p; - if (types) { - int id = 0; - for (int i=0; istate()->needsDepthBufferClear) { + glDepthMask(true); + glClearDepth(0.5); + glClear(GL_DEPTH_BUFFER_BIT); + q->state()->needsDepthBufferClear = false; + glDepthMask(false); } - if (path.hints() & QVectorPath::WindingFill) - p.setFillRule(Qt::WindingFill); - updateClipRegion(QRegion(p.toFillPolygon().toPolygon(), p.fillRule()), op); - return; + if (path.isEmpty()) + return; + + glDisable(GL_BLEND); + glDepthMask(false); + + vertexCoordinateArray.clear(); + vertexCoordinateArray.addPath(path, inverseScale); + + glDepthMask(GL_FALSE); + fillStencilWithVertexArray(vertexCoordinateArray, path.hasWindingFill()); + + // Stencil the clip onto the clip buffer + glColorMask(false, false, false, false); + glDepthMask(true); + + shaderManager->simpleProgram()->setUniformValue("depth", depth); + simpleShaderDepthUniformDirty = true; + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_ALWAYS); + + glStencilFunc(GL_NOTEQUAL, 0, 0xFFFF); // Pass if stencil buff value != 0 + + glEnable(GL_STENCIL_TEST); + composite(vertexCoordinateArray.boundingRect()); + glDisable(GL_STENCIL_TEST); + + glColorMask(true, true, true, true); + glDepthMask(false); + + cleanStencilBuffer(vertexCoordinateArray.boundingRect()); } -void QGL2PaintEngineEx::updateClipRegion(const QRegion &clipRegion, Qt::ClipOperation op) +void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) { -// qDebug("QGL2PaintEngineEx::updateClipRegion()"); +// qDebug("QGL2PaintEngineEx::clip()"); Q_D(QGL2PaintEngineEx); - QRegion sysClip = systemClip(); - if (op == Qt::NoClip && !d->use_system_clip) { - state()->hasClipping = false; - state()->clipRegion = QRegion(); - d->updateDepthClip(); - return; - } + if (op == Qt::ReplaceClip && !d->hasClipOperations()) + op = Qt::IntersectClip; - bool isScreenClip = false; - if (!d->use_system_clip) { - QVector untransformedRects = clipRegion.rects(); + if (!path.isEmpty() && op == Qt::IntersectClip && (path.hints() & QVectorPath::RectangleHint)) { + const QPointF* const points = reinterpret_cast(path.points()); + QRectF rect(points[0], points[2]); - if (untransformedRects.size() == 1) { - QPainterPath path; - path.addRect(untransformedRects[0]); - //path = d->matrix.map(path); - path = state()->matrix.map(path); - -// if (path.contains(QRectF(QPointF(), d->drawable.size()))) -// isScreenClip = true; - if (path.contains(QRectF(0.0, 0.0, d->width, d->height))) - isScreenClip = true; + if (state()->matrix.type() <= QTransform::TxScale) { + rect = state()->matrix.mapRect(rect); + + if (d->use_system_clip && rect.contains(d->systemClip.boundingRect()) + || rect.contains(QRect(0, 0, d->width, d->height))) + return; } } -// QRegion region = isScreenClip ? QRegion() : clipRegion * d->matrix; - QRegion region = isScreenClip ? QRegion() : clipRegion * state()->matrix; switch (op) { case Qt::NoClip: - if (!d->use_system_clip) - break; - state()->clipRegion = sysClip; + if (d->use_system_clip) { + glEnable(GL_DEPTH_TEST); + state()->depthTestEnabled = true; + state()->currentDepth = -0.5; + } else { + glDisable(GL_DEPTH_TEST); + state()->depthTestEnabled = false; + } + state()->canRestoreClip = false; break; case Qt::IntersectClip: - if (isScreenClip) - return; - if (state()->hasClipping) { - state()->clipRegion &= region; - break; - } - // fall through + state()->maxDepth = (1.0f + state()->maxDepth) * 0.5; + d->writeClip(path, state()->maxDepth); + state()->currentDepth = 1.5 * state()->maxDepth - 0.5f; + state()->depthTestEnabled = true; + break; case Qt::ReplaceClip: - if (d->use_system_clip && !sysClip.isEmpty()) - state()->clipRegion = region & sysClip; - else - state()->clipRegion = region; + d->systemStateChanged(); + state()->maxDepth = 0.5f; + glDepthFunc(GL_ALWAYS); + d->writeClip(path, state()->maxDepth); + state()->currentDepth = 0.25f; + state()->canRestoreClip = false; + state()->depthTestEnabled = true; break; case Qt::UniteClip: - state()->clipRegion |= region; - if (d->use_system_clip && !sysClip.isEmpty()) - state()->clipRegion &= sysClip; - break; - default: + glDepthFunc(GL_ALWAYS); + d->writeClip(path, state()->maxDepth); + state()->canRestoreClip = false; + state()->depthTestEnabled = true; break; } - if (isScreenClip) { - state()->hasClipping = false; - state()->clipRegion = QRegion(); - } else { - state()->hasClipping = op != Qt::NoClip || d->use_system_clip; + glDepthFunc(GL_LEQUAL); + if (state()->depthTestEnabled) { + glEnable(GL_DEPTH_TEST); + d->simpleShaderDepthUniformDirty = true; + d->depthUniformDirty = true; } - - d->updateDepthClip(); } -void QGL2PaintEngineExPrivate::systemStateChanged() +void QGL2PaintEngineExPrivate::regenerateDepthClip() { - Q_Q(QGL2PaintEngineEx); - use_system_clip = !systemClip.isEmpty(); - - if (q->painter()->hasClipping()) - q->updateClipRegion(q->painter()->clipRegion(), Qt::ReplaceClip); - else - q->updateClipRegion(QRegion(), Qt::NoClip); + systemStateChanged(); + replayClipOperations(); } -void QGL2PaintEngineExPrivate::updateDepthClip() +void QGL2PaintEngineExPrivate::systemStateChanged() { -// qDebug("QGL2PaintEngineExPrivate::updateDepthClip()"); - Q_Q(QGL2PaintEngineEx); + use_system_clip = !systemClip.isEmpty(); - q->ensureActive(); glDisable(GL_DEPTH_TEST); + q->state()->depthTestEnabled = false; + q->state()->scissorTestEnabled = false; + q->state()->needsDepthBufferClear = true; + glDisable(GL_SCISSOR_TEST); - if (!q->state()->hasClipping) - return; + q->state()->currentDepth = -0.5f; + q->state()->maxDepth = 0.5f; - const QVector rects = q->state()->clipEnabled ? q->state()->clipRegion.rects() : q->systemClip().rects(); - if (rects.size() == 1) { - QRect fastClip = rects.at(0); + if (use_system_clip) { + QRect bounds = systemClip.boundingRect(); + if (systemClip.numRects() == 1 + && bounds == QRect(0, 0, width, height)) + { + q->state()->needsDepthBufferClear = true; + } else { + glEnable(GL_SCISSOR_TEST); - glEnable(GL_SCISSOR_TEST); + const int left = bounds.left(); + const int width = bounds.width(); + const int bottom = height - (bounds.top() + bounds.height()); + const int height = bounds.height(); - const int left = fastClip.left(); - const int width = fastClip.width(); - const int bottom = height - (fastClip.bottom() + 1); - const int height = fastClip.height(); + glScissor(left, bottom, width, height); - glScissor(left, bottom, width, height); - return; - } + QTransform transform = q->state()->matrix; + q->state()->matrix = QTransform(); + q->transformChanged(); - glClearDepth(0x0); - glDepthMask(true); - glClear(GL_DEPTH_BUFFER_BIT); - glClearDepth(0x1); + q->state()->needsDepthBufferClear = false; - glEnable(GL_SCISSOR_TEST); - for (int i = 0; i < rects.size(); ++i) { - QRect rect = rects.at(i); + glDepthMask(true); - const int left = rect.left(); - const int width = rect.width(); - const int bottom = height - (rect.bottom() + 1); - const int height = rect.height(); + glClearDepth(0); + glClear(GL_DEPTH_BUFFER_BIT); - glScissor(left, bottom, width, height); + QPainterPath path; + path.addRegion(systemClip); - glClear(GL_DEPTH_BUFFER_BIT); - } - glDisable(GL_SCISSOR_TEST); + glDepthFunc(GL_ALWAYS); + writeClip(qtVectorPathForPath(path), 0.0f); + glDepthFunc(GL_LEQUAL); - glDepthMask(false); - glDepthFunc(GL_LEQUAL); - glEnable(GL_DEPTH_TEST); -} + glEnable(GL_DEPTH_TEST); + q->state()->depthTestEnabled = true; + q->state()->scissorTestEnabled = true; + q->state()->matrix = transform; + q->transformChanged(); + } + q->state()->currentDepth = -0.5f; + simpleShaderDepthUniformDirty = true; + depthUniformDirty = true; + } +} void QGL2PaintEngineEx::setState(QPainterState *new_state) { -// qDebug("QGL2PaintEngineEx::setState()"); + // qDebug("QGL2PaintEngineEx::setState()"); Q_D(QGL2PaintEngineEx); QOpenGL2PaintEngineState *s = static_cast(new_state); - QOpenGL2PaintEngineState *old_state = state(); - const bool needsDepthClipUpdate = !old_state - || s->clipEnabled != old_state->clipEnabled - || (s->clipEnabled && s->clipRegion != old_state->clipRegion); QPaintEngineEx::setState(s); - if (needsDepthClipUpdate) - d->updateDepthClip(); + if (s == d->last_created_state) { + d->last_created_state = 0; + return; + } d->matrixDirty = true; d->compositionModeDirty = true; d->brushTextureDirty = true; d->brushUniformsDirty = true; + d->simpleShaderDepthUniformDirty = true; + d->depthUniformDirty = true; d->simpleShaderMatrixUniformDirty = true; d->shaderMatrixUniformDirty = true; + + if (old_state && old_state != s && old_state->canRestoreClip) { + d->updateDepthScissorTest(); + glDepthMask(false); + glDepthFunc(GL_LEQUAL); + s->maxDepth = old_state->maxDepth; + } else { + d->regenerateDepthClip(); + } } QPainterState *QGL2PaintEngineEx::createState(QPainterState *orig) const { + Q_D(const QGL2PaintEngineEx); + QOpenGL2PaintEngineState *s; if (!orig) s = new QOpenGL2PaintEngineState(); else s = new QOpenGL2PaintEngineState(*static_cast(orig)); + d->last_created_state = s; return s; } QOpenGL2PaintEngineState::QOpenGL2PaintEngineState(QOpenGL2PaintEngineState &other) : QPainterState(other) { - clipRegion = other.clipRegion; - hasClipping = other.hasClipping; + needsDepthBufferClear = other.needsDepthBufferClear; + depthTestEnabled = other.depthTestEnabled; + scissorTestEnabled = other.scissorTestEnabled; + currentDepth = other.currentDepth; + maxDepth = other.maxDepth; + canRestoreClip = other.canRestoreClip; } QOpenGL2PaintEngineState::QOpenGL2PaintEngineState() { - hasClipping = false; + needsDepthBufferClear = true; + depthTestEnabled = false; + scissorTestEnabled = false; + currentDepth = -0.5f; + maxDepth = 0.5f; + canRestoreClip = true; } QOpenGL2PaintEngineState::~QOpenGL2PaintEngineState() diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 7213474..2cea8d6 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -77,8 +77,15 @@ public: QOpenGL2PaintEngineState(); ~QOpenGL2PaintEngineState(); - QRegion clipRegion; - bool hasClipping; + bool needsDepthBufferClear; + qreal depthBufferClearValue; + + bool depthTestEnabled; + bool scissorTestEnabled; + qreal currentDepth; + qreal maxDepth; + + bool canRestoreClip; }; @@ -116,7 +123,6 @@ public: Type type() const { return OpenGL; } - // State stuff is just for clipping and ripped off from QGLPaintEngine void setState(QPainterState *s); QPainterState *createState(QPainterState *orig) const; inline QOpenGL2PaintEngineState *state() { @@ -125,7 +131,6 @@ public: inline const QOpenGL2PaintEngineState *state() const { return static_cast(QPaintEngineEx::state()); } - void updateClipRegion(const QRegion &clipRegion, Qt::ClipOperation op); virtual void sync(); private: @@ -180,9 +185,10 @@ public: QGLDrawable drawable; int width, height; QGLContext *ctx; - EngineMode mode; + mutable QOpenGL2PaintEngineState *last_created_state; + // Dirty flags bool matrixDirty; // Implies matrix uniforms are also dirty bool compositionModeDirty; @@ -190,7 +196,9 @@ public: bool brushUniformsDirty; bool simpleShaderMatrixUniformDirty; bool shaderMatrixUniformDirty; - bool stencilBuferDirty; + bool stencilBufferDirty; + bool depthUniformDirty; + bool simpleShaderDepthUniformDirty; const QBrush* currentBrush; // May not be the state's brush! @@ -206,8 +214,9 @@ public: QGLEngineShaderManager* shaderManager; - // Clipping & state stuff stolen from QOpenGLPaintEngine: - void updateDepthClip(); + void writeClip(const QVectorPath &path, float depth); + void updateDepthScissorTest(); + void regenerateDepthClip(); void systemStateChanged(); uint use_system_clip : 1; }; -- cgit v0.12 From 73ea2f5766d2c0925af1bee7037610c2c75e89c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 9 Jun 2009 10:54:42 +0200 Subject: Resolved FBO extensions as well when resolving GL 2 extensions. The new GL 2 text drawing requries the FBO function pointers to be resolved. --- src/opengl/qglextensions.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/opengl/qglextensions.cpp b/src/opengl/qglextensions.cpp index 3c198fb..10ca613 100644 --- a/src/opengl/qglextensions.cpp +++ b/src/opengl/qglextensions.cpp @@ -337,6 +337,9 @@ bool qt_resolve_version_2_0_functions(QGLContext *ctx) if (!qt_resolve_version_1_3_functions(ctx)) gl2supported = false; + if (!qt_resolve_framebufferobject_extensions(ctx)) + gl2supported = false; + if (glStencilOpSeparate) return gl2supported; -- cgit v0.12 From 6495eb4953c5fca93d8cfe91c66b50ce82ce24cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 9 Jun 2009 13:02:47 +0200 Subject: Optimized stencil buffer clearing in GL 2 paint engine. Based on Zack's patch, 17e1bca1ce366395f8331e16aa96b7176ca1abac. Instead of manually clearing the stencil buffer after drawing we simply do the clearing and drawing in one go. Reviewed-by: Trond --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 50 ++++------------------ .../gl2paintengineex/qpaintengineex_opengl2_p.h | 1 - 2 files changed, 9 insertions(+), 42 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index fae3045..bdea187 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -732,12 +732,14 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) // Stencil the brush onto the dest buffer glStencilFunc(GL_NOTEQUAL, 0, 0xFFFF); // Pass if stencil buff value != 0 + glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); + glEnable(GL_STENCIL_TEST); prepareForDraw(currentBrush->isOpaque()); composite(vertexCoordinateArray.boundingRect()); glDisable(GL_STENCIL_TEST); - cleanStencilBuffer(vertexCoordinateArray.boundingRect()); + glStencilMask(0); } } @@ -745,17 +747,17 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(QGL2PEXVertexArray& vertexArray, bool useWindingFill) { // qDebug("QGL2PaintEngineExPrivate::fillStencilWithVertexArray()"); + glStencilMask(0xFFFF); // Enable stencil writes + if (stencilBufferDirty) { // Clear the stencil buffer to zeros glDisable(GL_STENCIL_TEST); - glStencilMask(0xFFFF); // Enable writing to stencil buffer, otherwise glClear wont do anything. glClearStencil(0); // Clear to zero glClear(GL_STENCIL_BUFFER_BIT); stencilBufferDirty = false; } glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // Disable color writes - glStencilMask(0xFFFF); // Enable stencil writes glStencilFunc(GL_ALWAYS, 0, 0xFFFF); // Always pass the stencil test // Setup the stencil op: @@ -765,7 +767,7 @@ void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(QGL2PEXVertexArray& ve } else glStencilOp(GL_KEEP, GL_KEEP, GL_INVERT); // Simply invert the stencil bit - // No point in using a fancy gradiant shader for writing into the stencil buffer! + // No point in using a fancy gradient shader for writing into the stencil buffer! useSimpleShader(); glEnable(GL_STENCIL_TEST); // For some reason, this has to happen _after_ the simple shader is use()'d @@ -776,41 +778,6 @@ void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(QGL2PEXVertexArray& ve // Enable color writes & disable stencil writes glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - glStencilMask(0); -} - -void QGL2PaintEngineExPrivate::cleanStencilBuffer(const QGLRect& area) -{ -// qDebug("QGL2PaintEngineExPrivate::cleanStencilBuffer()"); - useSimpleShader(); - - GLfloat rectVerts[] = { - area.left, area.top, - area.left, area.bottom, - area.right, area.bottom, - area.right, area.top - }; - - glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); - glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, rectVerts); - - glEnable(GL_STENCIL_TEST); - glStencilFunc(GL_ALWAYS, 0, 0xFFFF); // Always pass the stencil test - - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // Disable color writes - glStencilMask(0xFFFF); // Enable writing to stencil buffer - glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO); // Write 0's to stencil buffer - - glDisable(GL_BLEND); - - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - - glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR); - - // Enable color writes & disable stencil writes - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - glStencilMask(0); - glDisable(GL_STENCIL_TEST); } void QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque) @@ -1339,15 +1306,16 @@ void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, float depth) glDepthFunc(GL_ALWAYS); glStencilFunc(GL_NOTEQUAL, 0, 0xFFFF); // Pass if stencil buff value != 0 + glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); glEnable(GL_STENCIL_TEST); composite(vertexCoordinateArray.boundingRect()); glDisable(GL_STENCIL_TEST); + glStencilMask(0); + glColorMask(true, true, true, true); glDepthMask(false); - - cleanStencilBuffer(vertexCoordinateArray.boundingRect()); } void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 2cea8d6..db39ced 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -174,7 +174,6 @@ public: // ^ Composites the bounding rect onto dest buffer void fillStencilWithVertexArray(QGL2PEXVertexArray& vertexArray, bool useWindingFill); // ^ Calls drawVertexArrays to render into stencil buffer - void cleanStencilBuffer(const QGLRect& area); void prepareForDraw(bool srcPixelsAreOpaque); -- cgit v0.12 From 923cadc12b993a0b41200750f151d73662856482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 9 Jun 2009 13:23:08 +0200 Subject: Prevented pixmap FBOs from growing too big. If we're painting to very wide and then very tall pixmaps we don't want the FBO to grow to max_width * max_height, instead we should recreate the FBO if it grows too large compared to what's being painted. Reviewed-by: Trond --- src/opengl/qpixmapdata_gl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index 8d94c8b..98c406b 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -389,6 +389,11 @@ QPaintEngine* QGLPixmapData::paintEngine() const sz.setWidth(qMax(m_width, qRound(sz.width() * 1.5))); if (sz.height() < m_height) sz.setHeight(qMax(m_height, qRound(sz.height() * 1.5))); + + // wasting too much space? + if (sz.width() * sz.height() > m_width * m_height * 2.5) + sz = QSize(m_width, m_height); + delete textureBufferStack.at(currentTextureBuffer).fbo; textureBufferStack[currentTextureBuffer] = createTextureBuffer(sz, textureBufferStack.at(currentTextureBuffer).engine); -- cgit v0.12 From 7cd3e8233090f2937e38aff846a30635bcd14eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 9 Jun 2009 14:05:03 +0200 Subject: Removed background caching in embeddeddialogs demo. No point in caching a background that is already a pixmap. When maximizing the window this pixmap gets huge, and it doesn't help performance either. Reviewed-by: Trond --- demos/embeddeddialogs/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/demos/embeddeddialogs/main.cpp b/demos/embeddeddialogs/main.cpp index cfb31c4..c9b6ee1 100644 --- a/demos/embeddeddialogs/main.cpp +++ b/demos/embeddeddialogs/main.cpp @@ -76,7 +76,6 @@ int main(int argc, char *argv[]) view.scale(0.5, 0.5); view.setRenderHints(view.renderHints() | QPainter::Antialiasing | QPainter::SmoothPixmapTransform); view.setBackgroundBrush(QPixmap(":/No-Ones-Laughing-3.jpg")); - view.setCacheMode(QGraphicsView::CacheBackground); view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); view.show(); view.setWindowTitle("Embedded Dialogs Demo"); -- cgit v0.12 From 5039d39f3af42d23bba1f1c0ae10365ebcd82b4a Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 9 Jun 2009 12:17:03 +0200 Subject: small change to reduce static data size --- src/corelib/kernel/qvariant.cpp | 2 +- src/gui/text/qtexthtmlparser.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 2ff9818..e6f1c48 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1823,7 +1823,7 @@ QVariant::Type QVariant::nameToType(const char *name) #ifndef QT_NO_DATASTREAM enum { MapFromThreeCount = 35 }; -static const uint map_from_three[MapFromThreeCount] = +static const ushort map_from_three[MapFromThreeCount] = { QVariant::Invalid, QVariant::Map, diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index ee743dc..76c59c3 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -343,7 +343,7 @@ static QChar resolveEntity(const QString &entity) return e->code; } -static const uint windowsLatin1ExtendedCharacters[0xA0 - 0x80] = { +static const ushort windowsLatin1ExtendedCharacters[0xA0 - 0x80] = { 0x20ac, // 0x80 0x0081, // 0x81 direct mapping 0x201a, // 0x82 -- cgit v0.12 From b9f5e151b3c0bca74136720c5b42c9a93c8f25a8 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 9 Jun 2009 14:04:55 +0200 Subject: small improvement/refactor to cssparser --- src/gui/text/qcssparser.cpp | 42 +----------------------------- src/gui/text/qcssparser_p.h | 1 - tests/auto/qcssparser/tst_cssparser.cpp | 45 +++++++++++++++++++++++++++++++-- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 0494b72..a05e5a1 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -57,46 +57,6 @@ QT_BEGIN_NAMESPACE using namespace QCss; -const char *Scanner::tokenName(QCss::TokenType t) -{ - switch (t) { - case NONE: return "NONE"; - case S: return "S"; - case CDO: return "CDO"; - case CDC: return "CDC"; - case INCLUDES: return "INCLUDES"; - case DASHMATCH: return "DASHMATCH"; - case LBRACE: return "LBRACE"; - case PLUS: return "PLUS"; - case GREATER: return "GREATER"; - case COMMA: return "COMMA"; - case STRING: return "STRING"; - case INVALID: return "INVALID"; - case IDENT: return "IDENT"; - case HASH: return "HASH"; - case ATKEYWORD_SYM: return "ATKEYWORD_SYM"; - case EXCLAMATION_SYM: return "EXCLAMATION_SYM"; - case LENGTH: return "LENGTH"; - case PERCENTAGE: return "PERCENTAGE"; - case NUMBER: return "NUMBER"; - case FUNCTION: return "FUNCTION"; - case COLON: return "COLON"; - case SEMICOLON: return "SEMICOLON"; - case RBRACE: return "RBRACE"; - case SLASH: return "SLASH"; - case MINUS: return "MINUS"; - case DOT: return "DOT"; - case STAR: return "STAR"; - case LBRACKET: return "LBRACKET"; - case RBRACKET: return "RBRACKET"; - case EQUAL: return "EQUAL"; - case LPAREN: return "LPAREN"; - case RPAREN: return "RPAREN"; - case OR: return "OR"; - } - return ""; -} - struct QCssKnownValue { const char *name; @@ -279,7 +239,7 @@ static const QCssKnownValue values[NumKnownValues - 1] = { }; //Map id to strings as they appears in the 'values' array above -static const int indexOfId[NumKnownValues] = { 0, 40, 47, 41, 48, 53, 34, 26, 68, 69, 25, 42, 5, 62, 46, +static const short indexOfId[NumKnownValues] = { 0, 40, 47, 41, 48, 53, 34, 26, 68, 69, 25, 42, 5, 62, 46, 29, 57, 58, 27, 50, 60, 6, 10, 38, 55, 19, 13, 17, 18, 20, 21, 49, 24, 45, 65, 36, 3, 2, 39, 61, 16, 11, 56, 14, 32, 63, 54, 64, 33, 67, 8, 28, 37, 12, 35, 59, 7, 9, 4, 66, 52, 22, 23, 30, 31, 1, 15, 0, 51, 44, 43 }; diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index 72bd637..81f306d 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -731,7 +731,6 @@ class Q_AUTOTEST_EXPORT Scanner public: static QString preprocess(const QString &input, bool *hasEscapeSequences = 0); static void scan(const QString &preprocessedInput, QVector *symbols); - static const char *tokenName(TokenType t); }; class Q_GUI_EXPORT Parser diff --git a/tests/auto/qcssparser/tst_cssparser.cpp b/tests/auto/qcssparser/tst_cssparser.cpp index b41a745..27258b7 100644 --- a/tests/auto/qcssparser/tst_cssparser.cpp +++ b/tests/auto/qcssparser/tst_cssparser.cpp @@ -114,11 +114,52 @@ void tst_CssParser::scanner_data() } } + +static char *tokenName(QCss::TokenType t) +{ + switch (t) { + case QCss::NONE: return "NONE"; + case QCss::S: return "S"; + case QCss::CDO: return "CDO"; + case QCss::CDC: return "CDC"; + case QCss::INCLUDES: return "INCLUDES"; + case QCss::DASHMATCH: return "DASHMATCH"; + case QCss::LBRACE: return "LBRACE"; + case QCss::PLUS: return "PLUS"; + case QCss::GREATER: return "GREATER"; + case QCss::COMMA: return "COMMA"; + case QCss::STRING: return "STRING"; + case QCss::INVALID: return "INVALID"; + case QCss::IDENT: return "IDENT"; + case QCss::HASH: return "HASH"; + case QCss::ATKEYWORD_SYM: return "ATKEYWORD_SYM"; + case QCss::EXCLAMATION_SYM: return "EXCLAMATION_SYM"; + case QCss::LENGTH: return "LENGTH"; + case QCss::PERCENTAGE: return "PERCENTAGE"; + case QCss::NUMBER: return "NUMBER"; + case QCss::FUNCTION: return "FUNCTION"; + case QCss::COLON: return "COLON"; + case QCss::SEMICOLON: return "SEMICOLON"; + case QCss::RBRACE: return "RBRACE"; + case QCss::SLASH: return "SLASH"; + case QCss::MINUS: return "MINUS"; + case QCss::DOT: return "DOT"; + case QCss::STAR: return "STAR"; + case QCss::LBRACKET: return "LBRACKET"; + case QCss::RBRACKET: return "RBRACKET"; + case QCss::EQUAL: return "EQUAL"; + case QCss::LPAREN: return "LPAREN"; + case QCss::RPAREN: return "RPAREN"; + case QCss::OR: return "OR"; + } + return ""; +} + static void debug(const QVector &symbols, int index = -1) { qDebug() << "all symbols:"; for (int i = 0; i < symbols.count(); ++i) - qDebug() << "(" << i << "); Token:" << QCss::Scanner::tokenName(symbols.at(i).token) << "; Lexem:" << symbols.at(i).lexem(); + qDebug() << "(" << i << "); Token:" << tokenName(symbols.at(i).token) << "; Lexem:" << symbols.at(i).lexem(); if (index != -1) qDebug() << "failure at index" << index; } @@ -160,7 +201,7 @@ void tst_CssParser::scanner() QCOMPARE(l.count(), 2); const QString expectedToken = l.at(0); const QString expectedLexem = l.at(1); - QString actualToken = QString::fromLatin1(QCss::Scanner::tokenName(symbols.at(i).token)); + QString actualToken = QString::fromLatin1(tokenName(symbols.at(i).token)); if (actualToken != expectedToken) { debug(symbols, i); QCOMPARE(actualToken, expectedToken); -- cgit v0.12 From d367ee08d1a07f1a30665b77ec11acec96e65a65 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 9 Jun 2009 15:23:59 +0200 Subject: Doc: Fixed QWebPage::forwardUnsupportedContent documentation and added more information about Web plugins. Reviewed-by: Trust Me --- src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 8 +++++--- src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp | 22 +++++++++++++++------- src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc | 3 ++- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp index 01b68eb..77add54 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp @@ -1986,10 +1986,12 @@ bool QWebPage::isContentEditable() const /*! \property QWebPage::forwardUnsupportedContent - \brief whether QWebPage should forward unsupported content through the - unsupportedContent signal + \brief whether QWebPage should forward unsupported content - If disabled the download of such content is aborted immediately. + If enabled, the unsupportedContent() signal is emitted with a network reply that + can be used to read the content. + + If disabled, the download of such content is aborted immediately. By default unsupported content is not forwarded. */ diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp index 1ad23f6..b516263 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp @@ -213,17 +213,25 @@ QWebSettings *QWebSettings::globalSettings() Each QWebPage object has its own QWebSettings object, which configures the settings for that page. If a setting is not configured, then it is looked up in the global settings object, which can be accessed using - QWebSettings::globalSettings(). + globalSettings(). - QWebSettings allows configuring font properties such as font size and font - family, the location of a custom stylesheet, and generic attributes like java - script, plugins, etc. The \l{QWebSettings::WebAttribute}{WebAttribute} - enum further describes this. + QWebSettings allows configuration of browser properties, such as font sizes and + families, the location of a custom style sheet, and generic attributes like + JavaScript and plugins. Individual attributes are set using the setAttribute() + function. The \l{QWebSettings::WebAttribute}{WebAttribute} enum further describes + each attribute. - QWebSettings also configures global properties such as the web page memory - cache and the web page icon database, local database storage and offline + QWebSettings also configures global properties such as the Web page memory + cache and the Web page icon database, local database storage and offline applications storage. + \section1 Enabling Plugins + + Support for browser plugins can enabled by setting the + \l{QWebSettings::PluginsEnabled}{PluginsEnabled} attribute. For many applications, + this attribute is enabled for all pages by setting it on the + \l{globalSettings()}{global settings object}. + \section1 Web Application Support WebKit provides support for features specified in \l{HTML 5} that improve the diff --git a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc index 06305e0..119c126 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc +++ b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc @@ -96,7 +96,8 @@ Since WebKit supports the Netscape Plugin API, Qt applications can display Web pages that embed common plugins, as long as the user has the appropriate - binary files for those plugins installed. + binary files for those plugins installed and the \l{QWebSettings::PluginsEnabled} + attribute is set for the application. The following locations are searched for plugins: -- cgit v0.12 From 4d7a1cbb060a7fe933f674e1a9ebaa9e81fe2896 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 9 Jun 2009 15:54:19 +0200 Subject: qdoc: The gray version. --- src/corelib/kernel/qtimer.cpp | 2 +- tools/qdoc3/htmlgenerator.cpp | 2 -- tools/qdoc3/test/classic.css | 49 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp index 8ca53b9..29bdf7e 100644 --- a/src/corelib/kernel/qtimer.cpp +++ b/src/corelib/kernel/qtimer.cpp @@ -251,7 +251,7 @@ void QTimer::stop() /*! - \reimp + \reimp */ void QTimer::timerEvent(QTimerEvent *e) { diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 0c21534..fb33de4 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -2349,8 +2349,6 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, // replace all <@link> tags: "(<@link node=\"([^\"]+)\">).*()" static const QString linkTag("link"); - if (src.contains("setAcceptDrops")) - qDebug() << "SRC:" << src; bool done = false; for (int i = 0, n = src.size(); i < n;) { if (src.at(i) == charLangle && src.at(i + 1).unicode() == '@') { diff --git a/tools/qdoc3/test/classic.css b/tools/qdoc3/test/classic.css index 85bb348..9c59c81 100644 --- a/tools/qdoc3/test/classic.css +++ b/tools/qdoc3/test/classic.css @@ -14,12 +14,49 @@ H3 { h3.fn,span.fn { - background-color: #e0eff6; + background-color: #eee; border-width: 1px; border-style: solid; - border-color: #3388be #3388be #e9f8ff #3388be; + border-color: #ddd #ddd #ddd #ddd ; font-weight: bold; padding: 6px 0px 6px 10px; + margin: 42px 0px 0px 0px; +} + +hr { + border: 0; + color: #9E9E9E; + background-color: #ccc; + height: 1px; + width: 100%; + text-align: left; + margin: 34px 0px 34px 0px; +} + +table { + border-width: 1px 1px 1px 1px; + border-style: solid; + border-color: #dddddd; + border-collapse: collapse; + background-color: #f0f0f0; + margin-left: 1.5%; + width: 97% +} + +table th { + border-width: 1px 1px 1px 2px; + padding: 4px; + border-style: solid; + border-color: #444; + color:white; + background-color:#444; +} + +p { + margin-left: 1.5%; + margin-top: 8px; + width: 97% + margin-bottom: 8px; } a:link @@ -66,7 +103,7 @@ body table td.memItemLeft { width: 200px; - padding: 1px 0px 0px 8px; + padding: 2px 0px 0px 8px; margin: 4px; border-top-width: 1px; border-right-width: 1px; @@ -76,7 +113,7 @@ table td.memItemLeft { border-right-color: #E0E0E0; border-bottom-color: #E0E0E0; border-left-color: #E0E0E0; - border-top-style: solid; + border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; @@ -85,7 +122,7 @@ table td.memItemLeft { white-space: nowrap } table td.memItemRight { - padding: 1px 8px 0px 8px; + padding: 2px 8px 0px 8px; margin: 4px; border-top-width: 1px; border-right-width: 1px; @@ -95,7 +132,7 @@ table td.memItemRight { border-right-color: #E0E0E0; border-bottom-color: #E0E0E0; border-left-color: #E0E0E0; - border-top-style: solid; + border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; -- cgit v0.12 From a15cce3256e57464720ea7fe7cf663c973f43c7b Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 9 Jun 2009 16:46:18 +0200 Subject: small changes in private headers --- src/gui/image/qpicture_p.h | 2 +- src/gui/painting/qtextureglyphcache_p.h | 2 +- src/gui/text/qfontengine.cpp | 6 ------ src/gui/text/qfontengine_p.h | 1 - src/gui/text/qfontengineglyphcache_p.h | 4 ++-- 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/gui/image/qpicture_p.h b/src/gui/image/qpicture_p.h index a3fd34f..3e8391f 100644 --- a/src/gui/image/qpicture_p.h +++ b/src/gui/image/qpicture_p.h @@ -69,7 +69,7 @@ class QPaintEngine; extern const char *qt_mfhdr_tag; -class Q_GUI_EXPORT QPicturePrivate +class QPicturePrivate { Q_DECLARE_PUBLIC(QPicture) friend class QPicturePaintEngine; diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h index cb5be75..689c091 100644 --- a/src/gui/painting/qtextureglyphcache_p.h +++ b/src/gui/painting/qtextureglyphcache_p.h @@ -121,7 +121,7 @@ protected: }; -class Q_GUI_EXPORT QImageTextureGlyphCache : public QTextureGlyphCache +class QImageTextureGlyphCache : public QTextureGlyphCache { public: QImageTextureGlyphCache(QFontEngineGlyphCache::Type type, const QTransform &matrix) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 6e8adcf..79e341a 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -70,12 +70,6 @@ static inline bool qtransform_equals_no_translate(const QTransform &a, const QTr } } - - -QFontEngineGlyphCache::~QFontEngineGlyphCache() -{ -} - // Harfbuzz helper functions static HB_Bool hb_stringToGlyphs(HB_Font font, const HB_UChar16 *string, hb_uint32 length, HB_Glyph *glyphs, hb_uint32 *numGlyphs, HB_Bool rightToLeft) diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 0f8d81c..3ef9d5f 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -93,7 +93,6 @@ struct QGlyphLayout; class Q_GUI_EXPORT QFontEngine : public QObject { - Q_OBJECT public: enum Type { Box, diff --git a/src/gui/text/qfontengineglyphcache_p.h b/src/gui/text/qfontengineglyphcache_p.h index 8589cc6..ca67e3f 100644 --- a/src/gui/text/qfontengineglyphcache_p.h +++ b/src/gui/text/qfontengineglyphcache_p.h @@ -72,7 +72,7 @@ QT_BEGIN_NAMESPACE -class Q_GUI_EXPORT QFontEngineGlyphCache +class QFontEngineGlyphCache { public: QFontEngineGlyphCache(const QTransform &matrix) : m_transform(matrix) { } @@ -83,7 +83,7 @@ public: Raster_Mono }; - virtual ~QFontEngineGlyphCache(); + virtual ~QFontEngineGlyphCache() { } QTransform m_transform; }; -- cgit v0.12 From df7d44d9e826e608d280270125b2d376c33c66ad Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 9 Jun 2009 17:02:32 +0200 Subject: removed foreach usage from animation API --- src/corelib/animation/qparallelanimationgroup.cpp | 33 +++++++++++++---------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/corelib/animation/qparallelanimationgroup.cpp b/src/corelib/animation/qparallelanimationgroup.cpp index c148cb5d..6ec4679 100644 --- a/src/corelib/animation/qparallelanimationgroup.cpp +++ b/src/corelib/animation/qparallelanimationgroup.cpp @@ -135,13 +135,14 @@ void QParallelAnimationGroup::updateCurrentTime(int) // simulate completion of the loop int dura = duration(); if (dura > 0) { - foreach (QAbstractAnimation *animation, d->animations) { - animation->setCurrentTime(dura); // will stop + for (int i = 0; i < d->animations.size(); ++i) { + d->animations.at(i)->setCurrentTime(dura); // will stop } } } else if (d->currentLoop < d->lastLoop) { // simulate completion of the loop seeking backwards - foreach (QAbstractAnimation *animation, d->animations) { + for (int i = 0; i < d->animations.size(); ++i) { + QAbstractAnimation *animation = d->animations.at(i); animation->setCurrentTime(0); animation->stop(); } @@ -154,7 +155,8 @@ void QParallelAnimationGroup::updateCurrentTime(int) __LINE__, d->currentTime, d->currentLoop, d->lastLoop, timeFwd, d->lastCurrentTime, state()); #endif // finally move into the actual time of the current loop - foreach (QAbstractAnimation *animation, d->animations) { + for (int i = 0; i < d->animations.size(); ++i) { + QAbstractAnimation *animation = d->animations.at(i); const int dura = animation->totalDuration(); if (dura == -1 && d->isUncontrolledAnimationFinished(animation)) continue; @@ -200,17 +202,18 @@ void QParallelAnimationGroup::updateState(QAbstractAnimation::State oldState, switch (newState) { case Stopped: - foreach (QAbstractAnimation *animation, d->animations) - animation->stop(); + for (int i = 0; i < d->animations.size(); ++i) + d->animations.at(i)->stop(); d->disconnectUncontrolledAnimations(); break; case Paused: - foreach (QAbstractAnimation *animation, d->animations) - animation->pause(); + for (int i = 0; i < d->animations.size(); ++i) + d->animations.at(i)->pause(); break; case Running: d->connectUncontrolledAnimations(); - foreach (QAbstractAnimation *animation, d->animations) { + for (int i = 0; i < d->animations.size(); ++i) { + QAbstractAnimation *animation = d->animations.at(i); animation->stop(); animation->setDirection(d->direction); animation->start(); @@ -243,8 +246,8 @@ void QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished() return; int maxDuration = 0; - foreach (QAbstractAnimation *a, animations) - maxDuration = qMax(maxDuration, a->totalDuration()); + for (int i = 0; i < animations.size(); ++i) + maxDuration = qMax(maxDuration, animations.at(i)->totalDuration()); if (currentTime >= maxDuration) q->stop(); @@ -267,7 +270,8 @@ void QParallelAnimationGroupPrivate::connectUncontrolledAnimations() { Q_Q(QParallelAnimationGroup); - foreach (QAbstractAnimation *animation, animations) { + for (int i = 0; i < animations.size(); ++i) { + QAbstractAnimation *animation = animations.at(i); if (animation->duration() == -1 || animation->loopCount() < 0) { uncontrolledFinishTime[animation] = -1; QObject::connect(animation, SIGNAL(finished()), q, SLOT(_q_uncontrolledAnimationFinished())); @@ -288,8 +292,9 @@ void QParallelAnimationGroup::updateDirection(QAbstractAnimation::Direction dire Q_D(QParallelAnimationGroup); //we need to update the direction of the current animation if (state() != Stopped) { - foreach(QAbstractAnimation *anim, d->animations) { - anim->setDirection(direction); + for (int i = 0; i < d->animations.size(); ++i) { + QAbstractAnimation *animation = d->animations.at(i); + animation->setDirection(direction); } } else { if (direction == Forward) { -- cgit v0.12 From 861bf225fedc452ab5b18c12e18e38c4172a5f1a Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 9 Jun 2009 17:04:33 +0200 Subject: Improves the documentation of QHeaderView::setResizeMode to specify that the section indicated by the parameter logicalIndex should exist Task-number: 255541 --- src/gui/itemviews/qheaderview.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index d28c08a..7ad825a 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -1153,7 +1153,8 @@ void QHeaderView::setResizeMode(ResizeMode mode) \overload Sets the constraints on how the section specified by \a logicalIndex in - the header can be resized to those described by the given \a mode. + the header can be resized to those described by the given \a mode. The logical + index should exist at the time this function is called. \note This setting will be ignored for the last section if the stretchLastSection property is set to true. This is the default for the horizontal headers provided -- cgit v0.12 From 2312b121131774a84d01854b3e47d3d2a035a6a1 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Thu, 4 Jun 2009 12:10:06 +0200 Subject: Implemented the NET_WM_SYNC protocol on X11. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Done with Thorbjørn Lindeijer Task-number: 220550 Reviewed-by: Thorbjørn Lindeijer Reviewed-by: mae --- src/gui/kernel/qapplication_x11.cpp | 87 ++++++++++++++++++++++++++++++++++++- src/gui/kernel/qt_x11_p.h | 6 +++ src/gui/kernel/qwidget_p.h | 8 ++++ src/gui/kernel/qwidget_x11.cpp | 28 +++++++++++- 4 files changed, 127 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 1473421..8ebea19 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -157,6 +157,8 @@ static const char * x11_atomnames = { "WM_TAKE_FOCUS\0" "_NET_WM_PING\0" "_NET_WM_CONTEXT_HELP\0" + "_NET_WM_SYNC_REQUEST\0" + "_NET_WM_SYNC_REQUEST_COUNTER\0" // ICCCM window state "WM_STATE\0" @@ -508,6 +510,7 @@ static Bool qt_xfixes_scanner(Display*, XEvent *event, XPointer arg) class QETWidget : public QWidget // event translator widget { public: + QWidgetPrivate* d_func() { return QWidget::d_func(); } bool translateMouseEvent(const XEvent *); void translatePaintEvent(const XEvent *); bool translateConfigEvent(const XEvent *); @@ -718,6 +721,44 @@ static int qt_xio_errhandler(Display *) } #endif +#ifndef QT_NO_XSYNC +struct qt_sync_request_event_data +{ + WId window; +}; + +#if defined(Q_C_CALLBACKS) +extern "C" { +#endif + +static Bool qt_sync_request_scanner(Display*, XEvent *event, XPointer arg) +{ + qt_sync_request_event_data *data = + reinterpret_cast(arg); + if (event->type == ClientMessage && + event->xany.window == data->window && + event->xclient.message_type == ATOM(WM_PROTOCOLS) && + (Atom)event->xclient.data.l[0] == ATOM(_NET_WM_SYNC_REQUEST)) { + QWidget *w = QWidget::find(event->xany.window); + if (QTLWExtra *tlw = ((QETWidget*)w)->d_func()->maybeTopData()) { + const ulong timestamp = (const ulong) event->xclient.data.l[1]; + if (timestamp > X11->time) + X11->time = timestamp; + if (timestamp == CurrentTime || timestamp > tlw->syncRequestTimestamp) { + tlw->syncRequestTimestamp = timestamp; + tlw->newCounterValueLo = event->xclient.data.l[2]; + tlw->newCounterValueHi = event->xclient.data.l[3]; + } + } + return true; + } + return false; +} + +#if defined(Q_C_CALLBACKS) +} +#endif +#endif // QT_NO_XSYNC static void qt_x11_create_intern_atoms() { @@ -2090,6 +2131,13 @@ void qt_init(QApplicationPrivate *priv, int, #endif // QT_RUNTIME_XCURSOR #endif // QT_NO_XCURSOR +#ifndef QT_NO_XSYNC + int xsync_evbase, xsync_errbase; + int major, minor; + if (XSyncQueryExtension(X11->display, &xsync_evbase, &xsync_errbase)) + XSyncInitialize(X11->display, &major, &minor); +#endif // QT_NO_XSYNC + #ifndef QT_NO_XINERAMA #ifdef QT_RUNTIME_XINERAMA X11->ptrXineramaQueryExtension = 0; @@ -3116,6 +3164,19 @@ int QApplication::x11ClientMessage(QWidget* w, XEvent* event, bool passive_only) XSendEvent(event->xclient.display, event->xclient.window, False, SubstructureNotifyMask|SubstructureRedirectMask, event); } +#ifndef QT_NO_XSYNC + } else if (a == ATOM(_NET_WM_SYNC_REQUEST)) { + const ulong timestamp = (const ulong) event->xclient.data.l[1]; + if (timestamp > X11->time) + X11->time = timestamp; + if (QTLWExtra *tlw = w->d_func()->maybeTopData()) { + if (timestamp == CurrentTime || timestamp > tlw->syncRequestTimestamp) { + tlw->syncRequestTimestamp = timestamp; + tlw->newCounterValueLo = event->xclient.data.l[2]; + tlw->newCounterValueHi = event->xclient.data.l[3]; + } + } +#endif } } else if (event->xclient.message_type == ATOM(_QT_SCROLL_DONE)) { widget->translateScrollDoneEvent(event); @@ -4144,7 +4205,9 @@ bool QETWidget::translateMouseEvent(const XEvent *event) || ((nextEvent.type == EnterNotify || nextEvent.type == LeaveNotify) && qt_button_down == this) || (nextEvent.type == ClientMessage - && nextEvent.xclient.message_type == ATOM(_QT_SCROLL_DONE))) { + && (nextEvent.xclient.message_type == ATOM(_QT_SCROLL_DONE) || + (nextEvent.xclient.message_type == ATOM(WM_PROTOCOLS) && + (Atom)nextEvent.xclient.data.l[0] == ATOM(_NET_WM_SYNC_REQUEST))))) { qApp->x11ProcessEvent(&nextEvent); continue; } else if (nextEvent.type != MotionNotify || @@ -5200,6 +5263,14 @@ bool QETWidget::translateConfigEvent(const XEvent *event) otherEvent.xconfigure.border_width; } } +#ifndef QT_NO_XSYNC + qt_sync_request_event_data sync_event; + sync_event.window = internalWinId(); + for (XEvent ev;;) { + if (!XCheckIfEvent(X11->display, &ev, &qt_sync_request_scanner, (XPointer)&sync_event)) + break; + } +#endif // QT_NO_XSYNC } QRect cr (geometry()); @@ -5285,6 +5356,20 @@ bool QETWidget::translateConfigEvent(const XEvent *event) if (d->extra && d->extra->topextra) d->extra->topextra->inTopLevelResize = false; } +#ifndef QT_NO_XSYNC + if (QTLWExtra *tlwExtra = d->maybeTopData()) { + if (tlwExtra->newCounterValueLo != 0 || tlwExtra->newCounterValueHi != 0) { + XSyncValue value; + XSyncIntsToValue(&value, + tlwExtra->newCounterValueLo, + tlwExtra->newCounterValueHi); + + XSyncSetCounter(X11->display, tlwExtra->syncUpdateCounter, value); + tlwExtra->newCounterValueHi = 0; + tlwExtra->newCounterValueLo = 0; + } + } +#endif return true; } diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h index b9ace9d..21bb550 100644 --- a/src/gui/kernel/qt_x11_p.h +++ b/src/gui/kernel/qt_x11_p.h @@ -154,6 +154,10 @@ extern "C" { # include #endif // QT_NO_XRENDER +#ifndef QT_NO_XSYNC +# include "X11/extensions/sync.h" +#endif + // #define QT_NO_XKB #ifndef QT_NO_XKB # include @@ -514,6 +518,8 @@ struct QX11Data WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_CONTEXT_HELP, + _NET_WM_SYNC_REQUEST, + _NET_WM_SYNC_REQUEST_COUNTER, // ICCCM window state WM_STATE, diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index bf4f091..ff194f7 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -131,6 +131,10 @@ struct QTLWExtra { uint embedded : 1; // *************************** Platform specific values (bit fields first) ********** +#ifndef QT_NO_XSYNC + int newCounterValueHi : 32; + uint newCounterValueLo : 32; +#endif #if defined(Q_WS_X11) // <----------------------------------------------------------- X11 uint spont_unmapped: 1; // window was spontaneously unmapped uint dnd : 1; // DND properties installed @@ -156,6 +160,10 @@ struct QTLWExtra { QWSManager *qwsManager; #endif #endif +#ifndef QT_NO_XSYNC + WId syncUpdateCounter; + ulong syncRequestTimestamp; +#endif }; struct QWExtra { diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 4e34045..8159f8e 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -754,11 +754,14 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO qBound(1, data.crect.width(), XCOORD_MAX), qBound(1, data.crect.height(), XCOORD_MAX)); XStoreName(dpy, id, appName.data()); - Atom protocols[4]; + Atom protocols[5]; int n = 0; protocols[n++] = ATOM(WM_DELETE_WINDOW); // support del window protocol protocols[n++] = ATOM(WM_TAKE_FOCUS); // support take focus window protocol protocols[n++] = ATOM(_NET_WM_PING); // support _NET_WM_PING protocol +#ifndef QT_NO_XSYNC + protocols[n++] = ATOM(_NET_WM_SYNC_REQUEST); // support _NET_WM_SYNC_REQUEST protocol +#endif // QT_NO_XSYNC if (flags & Qt::WindowContextHelpButtonHint) protocols[n++] = ATOM(_NET_WM_CONTEXT_HELP); XSetWMProtocols(dpy, id, protocols, n); @@ -1877,6 +1880,23 @@ void QWidgetPrivate::show_sys() if (setUserTime) qt_net_update_user_time(q, userTime); +#ifndef QT_NO_XSYNC + if (!topData()->syncUpdateCounter) { + XSyncValue value; + XSyncIntToValue(&value, 0); + topData()->syncUpdateCounter = XSyncCreateCounter(X11->display, value); + + XChangeProperty(X11->display, q->internalWinId(), + ATOM(_NET_WM_SYNC_REQUEST_COUNTER), + XA_CARDINAL, + 32, PropModeReplace, + (uchar *) &topData()->syncUpdateCounter, 1); + + topData()->newCounterValueHi = 0; + topData()->newCounterValueLo = 0; + } +#endif + if (!topData()->embedded && (topData()->validWMState || topData()->waitingForMapNotify) && !q->isMinimized()) { @@ -2687,6 +2707,12 @@ void QWidgetPrivate::createTLSysExtra() extra->topextra->waitingForMapNotify = 0; extra->topextra->parentWinId = 0; extra->topextra->userTimeWindow = 0; +#ifndef QT_NO_XSYNC + extra->topextra->syncUpdateCounter = 0; + extra->topextra->syncRequestTimestamp = 0; + extra->topextra->newCounterValueHi = 0; + extra->topextra->newCounterValueLo = 0; +#endif } void QWidgetPrivate::deleteTLSysExtra() -- cgit v0.12 From 2dc47ad36f235ba053a329179be4ed87d0b4d484 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Tue, 9 Jun 2009 18:48:16 +0200 Subject: Add support for TIFF formats (Mono and indexed) Add support for reading and writing for Mono, MonoLSB and Indexed images in the tiff format. Previously, the images were always written in RGB32, dismissing the input format. Task-number: 254317 Reviewed-by: Samuel --- src/plugins/imageformats/tiff/qtiffhandler.cpp | 342 +++++++++++++++++++------ tests/auto/qimagewriter/tst_qimagewriter.cpp | 26 ++ 2 files changed, 285 insertions(+), 83 deletions(-) diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp index 77dfeb3..791aeaa 100644 --- a/src/plugins/imageformats/tiff/qtiffhandler.cpp +++ b/src/plugins/imageformats/tiff/qtiffhandler.cpp @@ -131,58 +131,138 @@ bool QTiffHandler::read(QImage *image) if (!canRead()) return false; - TIFF *tiff = TIFFClientOpen("foo", - "r", - this, - qtiffReadProc, - qtiffWriteProc, - qtiffSeekProc, - qtiffCloseProc, - qtiffSizeProc, - qtiffMapProc, - qtiffUnmapProc); - - if (tiff) { - uint32 width = 0; - uint32 height = 0; - TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &width); - TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &height); - if (image->size() != QSize(width, height) || image->format() != QImage::Format_ARGB32) - *image = QImage(width, height, QImage::Format_ARGB32); + TIFF *const tiff = TIFFClientOpen("foo", + "r", + this, + qtiffReadProc, + qtiffWriteProc, + qtiffSeekProc, + qtiffCloseProc, + qtiffSizeProc, + qtiffMapProc, + qtiffUnmapProc); + + if (!tiff) { + return false; + } + uint32 width; + uint32 height; + uint16 photometric; + if (!TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &width) + || !TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &height) + || !TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric)) { + TIFFClose(tiff); + return false; + } + + if (photometric == PHOTOMETRIC_MINISBLACK || photometric == PHOTOMETRIC_MINISWHITE) { + if (image->size() != QSize(width, height) || image->format() != QImage::Format_Mono) + *image = QImage(width, height, QImage::Format_Mono); + QVector colortable(2); + if (photometric == PHOTOMETRIC_MINISBLACK) { + colortable[0] = 0xff000000; + colortable[1] = 0xffffffff; + } else { + colortable[0] = 0xffffffff; + colortable[1] = 0xff000000; + } + image->setColorTable(colortable); + if (!image->isNull()) { - if (TIFFReadRGBAImageOriented(tiff, width, height, reinterpret_cast(image->bits()), ORIENTATION_TOPLEFT, 0)) { - uint16 resUnit = RESUNIT_NONE; - float resX = 0; - float resY = 0; - TIFFGetField(tiff, TIFFTAG_RESOLUTIONUNIT, &resUnit); - TIFFGetField(tiff, TIFFTAG_XRESOLUTION, &resX); - TIFFGetField(tiff, TIFFTAG_YRESOLUTION, &resY); - switch(resUnit) { - case RESUNIT_CENTIMETER: - image->setDotsPerMeterX(qRound(resX * 100)); - image->setDotsPerMeterY(qRound(resY * 100)); - break; - case RESUNIT_INCH: - image->setDotsPerMeterX(qRound(resX * (100 / 2.54))); - image->setDotsPerMeterY(qRound(resY * (100 / 2.54))); - break; - default: - // do nothing as defaults have already - // been set within the QImage class - break; + for (uint32 y=0; yscanLine(y), y, 0) < 0) { + TIFFClose(tiff); + return false; + } + } + } + } else { + uint16 bitPerSample; + if (!TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE, &bitPerSample)) { + TIFFClose(tiff); + return false; + } + if (photometric == PHOTOMETRIC_PALETTE && bitPerSample == 8) { + if (image->size() != QSize(width, height) || image->format() != QImage::Format_Indexed8) + *image = QImage(width, height, QImage::Format_Indexed8); + if (!image->isNull()) { + // create the color table + const uint16 tableSize = 256; + uint16 *redTable = static_cast(qMalloc(tableSize * sizeof(uint16))); + uint16 *greenTable = static_cast(qMalloc(tableSize * sizeof(uint16))); + uint16 *blueTable = static_cast(qMalloc(tableSize * sizeof(uint16))); + if (!redTable || !greenTable || !blueTable) { + TIFFClose(tiff); + return false; + } + if (!TIFFGetField(tiff, TIFFTAG_COLORMAP, &redTable, &greenTable, &blueTable)) { + TIFFClose(tiff); + return false; + } + + QVector qtColorTable(tableSize); + for (int i = 0; isetColorTable(qtColorTable); + for (uint32 y=0; yscanLine(y), y, 0) < 0) { + TIFFClose(tiff); + return false; + } + } + + // free redTable, greenTable and greenTable done by libtiff + } + } else { + if (image->size() != QSize(width, height) || image->format() != QImage::Format_ARGB32) + *image = QImage(width, height, QImage::Format_ARGB32); + if (!image->isNull()) { + if (TIFFReadRGBAImageOriented(tiff, width, height, reinterpret_cast(image->bits()), ORIENTATION_TOPLEFT, 0)) { + for (uint32 y=0; yscanLine(y), width); + } else { + TIFFClose(tiff); + return false; } - for (uint32 y=0; yscanLine(y), width); - } else { - *image = QImage(); } } - TIFFClose(tiff); } - if (image->isNull()) + if (image->isNull()) { + TIFFClose(tiff); return false; + } + + float resX = 0; + float resY = 0; + uint16 resUnit = RESUNIT_NONE; + if (TIFFGetField(tiff, TIFFTAG_RESOLUTIONUNIT, &resUnit) + && TIFFGetField(tiff, TIFFTAG_XRESOLUTION, &resX) + && TIFFGetField(tiff, TIFFTAG_YRESOLUTION, &resY)) { + + switch(resUnit) { + case RESUNIT_CENTIMETER: + image->setDotsPerMeterX(qRound(resX * 100)); + image->setDotsPerMeterY(qRound(resY * 100)); + break; + case RESUNIT_INCH: + image->setDotsPerMeterX(qRound(resX * (100 / 2.54))); + image->setDotsPerMeterY(qRound(resY * (100 / 2.54))); + break; + default: + // do nothing as defaults have already + // been set within the QImage class + break; + } + } + TIFFClose(tiff); return true; } @@ -191,48 +271,145 @@ bool QTiffHandler::write(const QImage &image) if (!device()->isWritable()) return false; - TIFF *tiff = TIFFClientOpen("foo", - "w", - this, - qtiffReadProc, - qtiffWriteProc, - qtiffSeekProc, - qtiffCloseProc, - qtiffSizeProc, - qtiffMapProc, - qtiffUnmapProc); - - if (tiff) { - int width = image.width(); - int height = image.height(); - int depth = 32; - - if (!TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, width) - || !TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, height) - || !TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB) - || !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_LZW) - || !TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, depth/8) - || !TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG) - || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8)) { + TIFF *const tiff = TIFFClientOpen("foo", + "w", + this, + qtiffReadProc, + qtiffWriteProc, + qtiffSeekProc, + qtiffCloseProc, + qtiffSizeProc, + qtiffMapProc, + qtiffUnmapProc); + if (!tiff) + return false; + + const int width = image.width(); + const int height = image.height(); + + if (!TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, width) + || !TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, height) + || !TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)) { + TIFFClose(tiff); + return false; + } + + // set the resolution + bool resolutionSet = false; + const int dotPerMeterX = image.dotsPerMeterX(); + const int dotPerMeterY = image.dotsPerMeterY(); + if ((dotPerMeterX % 100) == 0 + && (dotPerMeterY % 100) == 0) { + resolutionSet = TIFFSetField(tiff, TIFFTAG_RESOLUTIONUNIT, RESUNIT_CENTIMETER) + && TIFFSetField(tiff, TIFFTAG_XRESOLUTION, dotPerMeterX/100.0) + && TIFFSetField(tiff, TIFFTAG_YRESOLUTION, dotPerMeterY/100.0); + } else { + resolutionSet = TIFFSetField(tiff, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH) + && TIFFSetField(tiff, TIFFTAG_XRESOLUTION, static_cast(image.logicalDpiX())) + && TIFFSetField(tiff, TIFFTAG_YRESOLUTION, static_cast(image.logicalDpiY())); + } + if (!resolutionSet) { + TIFFClose(tiff); + return false; + } + + // configure image depth + const QImage::Format format = image.format(); + if (format == QImage::Format_Mono || format == QImage::Format_MonoLSB) { + uint16 photometric = PHOTOMETRIC_MINISBLACK; + if (image.colorTable().at(0) == 0xffffffff) + photometric = PHOTOMETRIC_MINISWHITE; + if (!TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, photometric) + || !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_CCITTRLE)) { TIFFClose(tiff); return false; } - // set the resolution - bool resolutionSet = false; - const int dotPerMeterX = image.dotsPerMeterX(); - const int dotPerMeterY = image.dotsPerMeterY(); - if ((dotPerMeterX % 100) == 0 - && (dotPerMeterY % 100) == 0) { - resolutionSet = TIFFSetField(tiff, TIFFTAG_RESOLUTIONUNIT, RESUNIT_CENTIMETER) - && TIFFSetField(tiff, TIFFTAG_XRESOLUTION, dotPerMeterX/100.0) - && TIFFSetField(tiff, TIFFTAG_YRESOLUTION, dotPerMeterY/100.0); - } else { - resolutionSet = TIFFSetField(tiff, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH) - && TIFFSetField(tiff, TIFFTAG_XRESOLUTION, static_cast(image.logicalDpiX())) - && TIFFSetField(tiff, TIFFTAG_YRESOLUTION, static_cast(image.logicalDpiY())); + // try to do the conversion in chunks no greater than 16 MB + int chunks = (width * height / (1024 * 1024 * 16)) + 1; + int chunkHeight = qMax(height / chunks, 1); + + int y = 0; + while (y < height) { + QImage chunk = image.copy(0, y, width, qMin(chunkHeight, height - y)).convertToFormat(QImage::Format_Mono); + + int chunkStart = y; + int chunkEnd = y + chunk.height(); + while (y < chunkEnd) { + if (TIFFWriteScanline(tiff, reinterpret_cast(chunk.scanLine(y - chunkStart)), y) != 1) { + TIFFClose(tiff); + return false; + } + ++y; + } + } + TIFFClose(tiff); + } else if (format == QImage::Format_Indexed8) { + if (!TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE) + || !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_PACKBITS) + || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8)) { + TIFFClose(tiff); + return false; + } + //// write the color table + // allocate the color tables + uint16 *redTable = static_cast(qMalloc(256 * sizeof(uint16))); + uint16 *greenTable = static_cast(qMalloc(256 * sizeof(uint16))); + uint16 *blueTable = static_cast(qMalloc(256 * sizeof(uint16))); + if (!redTable || !greenTable || !blueTable) { + TIFFClose(tiff); + return false; + } + + // set the color table + const QVector colorTable = image.colorTable(); + + const int tableSize = colorTable.size(); + Q_ASSERT(tableSize <= 256); + for (int i = 0; i(chunk.scanLine(y - chunkStart)), y) != 1) { + TIFFClose(tiff); + return false; + } + ++y; + } } - if (!resolutionSet) { + TIFFClose(tiff); + + } else { + if (!TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB) + || !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_LZW) + || !TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 4) + || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8)) { TIFFClose(tiff); return false; } @@ -260,9 +437,8 @@ bool QTiffHandler::write(const QImage &image) } } TIFFClose(tiff); - } else { - return false; } + return true; } diff --git a/tests/auto/qimagewriter/tst_qimagewriter.cpp b/tests/auto/qimagewriter/tst_qimagewriter.cpp index 349afa5..3ceb2c2 100644 --- a/tests/auto/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/qimagewriter/tst_qimagewriter.cpp @@ -59,6 +59,7 @@ Q_DECLARE_METATYPE(QStringMap) Q_DECLARE_METATYPE(QIntList) Q_DECLARE_METATYPE(QImageWriter::ImageWriterError) Q_DECLARE_METATYPE(QIODevice *) +Q_DECLARE_METATYPE(QImage::Format) //TESTED_FILES= @@ -82,6 +83,9 @@ private slots: void writeImage2(); void supportedFormats(); + void readWriteNonDestructive_data(); + void readWriteNonDestructive(); + #if defined QTEST_HAVE_TIFF void largeTiff(); #endif @@ -376,6 +380,28 @@ void tst_QImageWriter::supportedFormats() QCOMPARE(formatSet.size(), formats.size()); } +void tst_QImageWriter::readWriteNonDestructive_data() +{ + QTest::addColumn("format"); + QTest::addColumn("expectedFormat"); + QTest::newRow("tiff mono") << QImage::Format_Mono << QImage::Format_Mono; + QTest::newRow("tiff indexed") << QImage::Format_Indexed8 << QImage::Format_Indexed8; + QTest::newRow("tiff rgb32") << QImage::Format_ARGB32 << QImage::Format_ARGB32; +} + +void tst_QImageWriter::readWriteNonDestructive() +{ + QFETCH(QImage::Format, format); + QFETCH(QImage::Format, expectedFormat); + QImage image = QImage(prefix + "colorful.bmp").convertToFormat(format); + QVERIFY(image.save(prefix + "gen-readWriteNonDestructive.tiff")); + + QImage image2 = QImage(prefix + "gen-readWriteNonDestructive.tiff"); + QImage::Format readFormat = image2.format(); + QCOMPARE(readFormat, expectedFormat); + QCOMPARE(image, image2); +} + void tst_QImageWriter::setDescription_data() { QTest::addColumn("fileName"); -- cgit v0.12 From 5b24c5793607c809b1bac82c7cc3696001ee9217 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 9 Jun 2009 18:49:40 +0200 Subject: Opening links with cyrillic file names does not work in QLabel. QDestopServices was converting the file names to percentage encoding before calling ShellExecute. This will not work with URLs without a scheme. These are now being treated similar to a file. Task-number: 254501 Reviewed-by: Jens Bache-Wiig --- src/gui/util/qdesktopservices_win.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/util/qdesktopservices_win.cpp b/src/gui/util/qdesktopservices_win.cpp index 9f8efb4..a8aa11c 100644 --- a/src/gui/util/qdesktopservices_win.cpp +++ b/src/gui/util/qdesktopservices_win.cpp @@ -165,6 +165,9 @@ static bool launchWebBrowser(const QUrl &url) if (!url.isValid()) return false; + if (url.scheme().isEmpty()) + return openDocument(url); + quintptr returnValue; returnValue = (quintptr)ShellExecute(0, 0, (TCHAR *) QString::fromUtf8(url.toEncoded().constData()).utf16(), 0, 0, SW_SHOWNORMAL); -- cgit v0.12 From 73fa8dd86f14ab161c84fa9224cd4335f352ba75 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 10 Jun 2009 16:10:21 +1000 Subject: Fix license headers for QStringBuilder. Only release branches are allowed to have the Commercial usage header. All other branches must have the No Commercial Usage header. Reviewed-by: Trust Me --- src/corelib/tools/qstringbuilder.cpp | 12 ++++++------ src/corelib/tools/qstringbuilder.h | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp index 03d8160..740deb4 100644 --- a/src/corelib/tools/qstringbuilder.cpp +++ b/src/corelib/tools/qstringbuilder.cpp @@ -3,14 +3,14 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtCore module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 2c31476..30a7c67 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -3,14 +3,14 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtCore module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -- cgit v0.12 From b2edf6ee037decf53c7d2698863ba63742317acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 10 Jun 2009 10:21:19 +0200 Subject: Fixed clipping bug in raster paint engine causing rendering artifacts. The artifacts were visible in the mainwindow demo when dragging the top toolbar separator left and right. We need to check that rect clipping is actually activated before we compare the new clip rect with the old, otherwise the clip type and clip bound flags won't get updated. --- src/gui/painting/qpaintengine_raster.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 0810bb9..7ed2dfd 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -4311,7 +4311,7 @@ QClipData::QClipData(int height) clipSpanHeight = height; m_clipLines = 0; - allocated = height; + allocated = 0; m_spans = 0; xmin = xmax = ymin = ymax = 0; count = 0; @@ -4479,7 +4479,7 @@ void QClipData::fixup() */ void QClipData::setClipRect(const QRect &rect) { - if (rect == clipRect) + if (hasRectClip && rect == clipRect) return; // qDebug() << "setClipRect" << clipSpanHeight << count << allocated << rect; -- cgit v0.12 From f0f12f3d1ad2041c57095edaa7683c5d3599a3e6 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 10 Jun 2009 18:47:49 +1000 Subject: Fix some incorrect license headers. The MODULE placeholder shouldn't be used anymore, and neither should the old Trolltech license header. Reviewed-by: Trust Me --- doc/src/diagrams/programs/easingcurve/main.cpp | 36 +++++++++++++++++++++-- src/gui/math3d/qgenericmatrix.cpp | 2 +- src/gui/math3d/qgenericmatrix.h | 2 +- src/gui/math3d/qmatrix4x4.cpp | 2 +- src/gui/math3d/qmatrix4x4.h | 2 +- src/gui/math3d/qquaternion.cpp | 2 +- src/gui/math3d/qquaternion.h | 2 +- src/gui/math3d/qvector2d.cpp | 2 +- src/gui/math3d/qvector2d.h | 2 +- src/gui/math3d/qvector3d.cpp | 2 +- src/gui/math3d/qvector3d.h | 2 +- src/gui/math3d/qvector4d.cpp | 2 +- src/gui/math3d/qvector4d.h | 2 +- tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp | 2 +- tests/auto/math3d/qquaternion/tst_qquaternion.cpp | 2 +- tests/auto/math3d/qvectornd/tst_qvectornd.cpp | 2 +- tests/auto/math3d/shared/math3dincludes.h | 2 +- 17 files changed, 49 insertions(+), 19 deletions(-) diff --git a/doc/src/diagrams/programs/easingcurve/main.cpp b/doc/src/diagrams/programs/easingcurve/main.cpp index 98e9d37..8d399a3 100644 --- a/doc/src/diagrams/programs/easingcurve/main.cpp +++ b/doc/src/diagrams/programs/easingcurve/main.cpp @@ -1,11 +1,41 @@ /**************************************************************************** ** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the examples of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/math3d/qgenericmatrix.cpp b/src/gui/math3d/qgenericmatrix.cpp index 6ecd878..19a0f6e 100644 --- a/src/gui/math3d/qgenericmatrix.cpp +++ b/src/gui/math3d/qgenericmatrix.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h index b4d3707..330ded2 100644 --- a/src/gui/math3d/qgenericmatrix.h +++ b/src/gui/math3d/qgenericmatrix.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index 8ef4da3..a69b9df 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index ba7f67f..da1bcba 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp index 96659ea..03f626a 100644 --- a/src/gui/math3d/qquaternion.cpp +++ b/src/gui/math3d/qquaternion.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h index c05c641..b17cf73 100644 --- a/src/gui/math3d/qquaternion.h +++ b/src/gui/math3d/qquaternion.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/gui/math3d/qvector2d.cpp b/src/gui/math3d/qvector2d.cpp index c3aaa42..df2519d 100644 --- a/src/gui/math3d/qvector2d.cpp +++ b/src/gui/math3d/qvector2d.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h index b027df4..2be0a11 100644 --- a/src/gui/math3d/qvector2d.h +++ b/src/gui/math3d/qvector2d.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp index c83cd60..a5f5c5b 100644 --- a/src/gui/math3d/qvector3d.cpp +++ b/src/gui/math3d/qvector3d.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h index 02873f2..480667a 100644 --- a/src/gui/math3d/qvector3d.h +++ b/src/gui/math3d/qvector3d.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/gui/math3d/qvector4d.cpp b/src/gui/math3d/qvector4d.cpp index 010fa53..c5124e2 100644 --- a/src/gui/math3d/qvector4d.cpp +++ b/src/gui/math3d/qvector4d.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h index 8e673f3..e38f4e5 100644 --- a/src/gui/math3d/qvector4d.h +++ b/src/gui/math3d/qvector4d.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index 4d51e89..dd3e396 100644 --- a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/tests/auto/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/math3d/qquaternion/tst_qquaternion.cpp index f25f858..5d70e4d 100644 --- a/tests/auto/math3d/qquaternion/tst_qquaternion.cpp +++ b/tests/auto/math3d/qquaternion/tst_qquaternion.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/tests/auto/math3d/qvectornd/tst_qvectornd.cpp b/tests/auto/math3d/qvectornd/tst_qvectornd.cpp index a092fb0..f7d2411 100644 --- a/tests/auto/math3d/qvectornd/tst_qvectornd.cpp +++ b/tests/auto/math3d/qvectornd/tst_qvectornd.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/tests/auto/math3d/shared/math3dincludes.h b/tests/auto/math3d/shared/math3dincludes.h index 1ac0c08..a77090b 100644 --- a/tests/auto/math3d/shared/math3dincludes.h +++ b/tests/auto/math3d/shared/math3dincludes.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage -- cgit v0.12 From f2c4d2fe8a846cfce457512ef1806a7276745590 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 10 Jun 2009 12:10:33 +0200 Subject: qdoc: Added new class names for different tables. class="valuelist" is for the table used for enum types. class="alignedsummary" is for summary sections aligned on the name. class="propsummary" is for the property summary section. class="toc" is used for tables of contents. class="generic" is used for all other tables. We might need to break this down more. --- tools/qdoc3/htmlgenerator.cpp | 53 +++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index fb33de4..44401ed 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -678,13 +678,17 @@ int HtmlGenerator::generateAtom(const Atom *atom, else if (atom->string() == ATOM_LIST_VALUE) { threeColumnEnumValueTable = isThreeColumnEnumValueTable(atom); if (threeColumnEnumValueTable) { - out() << "

\n" - "" - "\n"; + out() << "

ConstantValueDescription
\n" + << "" + << "" + << "\n"; } else { - out() << "

ConstantValueDescription
\n" - << "\n"; + out() << "

ConstantValue
\n" + << "\n"; } } else { @@ -858,14 +862,17 @@ int HtmlGenerator::generateAtom(const Atom *atom, } if (!atom->string().isEmpty()) { if (atom->string().contains("%")) - out() << "

ConstantValue
string() << "\" " + out() << "

string() << "\" " << "align=\"center\" cellpadding=\"2\" " << "cellspacing=\"1\" border=\"0\">\n"; - else - out() << "

\n"; + else { + out() << "

\n"; + } } else { - out() << "

\n"; + out() << "

\n"; } numTableRows = 0; break; @@ -1577,7 +1584,8 @@ void HtmlGenerator::generateTableOfContents(const Node *node, QString tdTag; if (numColumns > 1) { tdTag = "
"; - out() << "

\n" << tdTag << "\n"; + out() << "

\n" + << tdTag << "\n"; } // disable nested links in table of contents @@ -1596,7 +1604,8 @@ void HtmlGenerator::generateTableOfContents(const Node *node, out() << "
    "; sectionNumber.append("1"); } while (sectionNumber.size() < nextLevel); - } else { + } + else { while (sectionNumber.size() > nextLevel) { out() << "
\n"; sectionNumber.removeLast(); @@ -1804,10 +1813,13 @@ void HtmlGenerator::generateClassHierarchy(const Node *relative, } } -void HtmlGenerator::generateAnnotatedList(const Node *relative, CodeMarker *marker, - const QMap &nodeMap) +void +HtmlGenerator::generateAnnotatedList(const Node *relative, + CodeMarker *marker, + const QMap&nodeMap) { - out() << "

\n"; + out() << "

\n"; int row = 0; foreach (const QString &name, nodeMap.keys()) { @@ -1960,7 +1972,7 @@ void HtmlGenerator::generateCompactList(const Node *relative, CodeMarker *marker } firstOffset[NumColumns] = classMap.count(); - out() << "

\n"; + out() << "

\n"; for (k = 0; k < numRows; k++) { out() << "\n"; for (i = 0; i < NumColumns; i++) { @@ -2213,12 +2225,12 @@ void HtmlGenerator::generateSectionList(const Section& section, name_alignment = false; } if (name_alignment) { - out() << "
\n"; } else { if (twoColumn) - out() << "

\n" << "
"; @@ -2513,12 +2525,13 @@ void HtmlGenerator::generateSectionList(const Section& section, bool twoColumn = false; if (style == CodeMarker::SeparateList) { twoColumn = (section.members.count() >= 16); - } else if (section.members.first()->type() == Node::Property) { + } + else if (section.members.first()->type() == Node::Property) { twoColumn = (section.members.count() >= 5); } if (twoColumn) - out() << "

\n" + out() << "

\n" << "
"; out() << "
    \n"; -- cgit v0.12 From 8179a9e2cd52b24c70b194106dd170ed1bb677e4 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 10 Jun 2009 12:54:53 +0200 Subject: small code cleanup that improves some loops it uses les foreach --- src/gui/itemviews/qabstractitemview.cpp | 4 ++-- src/gui/itemviews/qsortfilterproxymodel.cpp | 7 ++++--- src/gui/itemviews/qstandarditemmodel.cpp | 4 ++-- src/gui/itemviews/qtreeview.cpp | 6 ++++-- src/gui/kernel/qaction.cpp | 25 +++++++++++++++++-------- src/gui/kernel/qwidgetaction.cpp | 4 ++-- src/gui/widgets/qdockarealayout.cpp | 8 ++++---- src/gui/widgets/qdockwidget.cpp | 7 ++++--- src/gui/widgets/qmenubar.cpp | 6 ++++-- 9 files changed, 43 insertions(+), 28 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index c90216b..d353c2d 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -2398,8 +2398,8 @@ void QAbstractItemView::updateEditorGeometries() //we release the editor outside of the loop because it might change the focus and try //to change the d->editors list. - foreach(QWidget *editor, editorsToRelease) { - d->releaseEditor(editor); + for (int i = 0; i < editorsToRelease.count(); ++i) { + d->releaseEditor(editorsToRelease.at(i)); } } diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp index 96eb6f0..4021c83 100644 --- a/src/gui/itemviews/qsortfilterproxymodel.cpp +++ b/src/gui/itemviews/qsortfilterproxymodel.cpp @@ -884,8 +884,8 @@ void QSortFilterProxyModelPrivate::proxy_item_range( { proxy_low = INT_MAX; proxy_high = INT_MIN; - foreach (int source_item, source_items) { - int proxy_item = source_to_proxy.at(source_item); + for (int i = 0; i < source_items.count(); ++i) { + int proxy_item = source_to_proxy.at(source_items.at(i)); Q_ASSERT(proxy_item != -1); if (proxy_item < proxy_low) proxy_low = proxy_item; @@ -985,7 +985,8 @@ QSet QSortFilterProxyModelPrivate::handle_filter_changed( Q_Q(QSortFilterProxyModel); // Figure out which mapped items to remove QVector source_items_remove; - foreach (int source_item, proxy_to_source) { + for (int i = 0; i < proxy_to_source.count(); ++i) { + const int source_item = proxy_to_source.at(i); if ((orient == Qt::Vertical) ? !q->filterAcceptsRow(source_item, source_parent) : !q->filterAcceptsColumn(source_item, source_parent)) { diff --git a/src/gui/itemviews/qstandarditemmodel.cpp b/src/gui/itemviews/qstandarditemmodel.cpp index d8adbd2..9d0f796 100644 --- a/src/gui/itemviews/qstandarditemmodel.cpp +++ b/src/gui/itemviews/qstandarditemmodel.cpp @@ -2907,8 +2907,8 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const QStack stack; itemsSet.reserve(indexes.count()); stack.reserve(indexes.count()); - foreach (const QModelIndex &index, indexes) { - QStandardItem *item = itemFromIndex(index); + for (int i = 0; i < indexes.count(); ++i) { + QStandardItem *item = itemFromIndex(indexes.at(i)); itemsSet << item; stack.push(item); } diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 7837700..965a5c7 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -2072,7 +2072,8 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie const bool useTopIndex = (cursorAction == MoveUp || cursorAction == MovePrevious); int index = useTopIndex ? INT_MAX : INT_MIN; const QItemSelection selection = d->selectionModel->selection(); - foreach (const QItemSelectionRange &range, selection) { + for (int i = 0; i < selection.count(); ++i) { + const QItemSelectionRange &range = selection.at(i); int candidate = d->viewIndex(useTopIndex ? range.topLeft() : range.bottomRight()); if (candidate >= 0) index = useTopIndex ? qMin(index, candidate) : qMax(index, candidate); @@ -3558,7 +3559,8 @@ QList > QTreeViewPrivate::columnRanges(const QModelIndex &topInd QPair current; current.first = -2; // -1 is not enough because -1+1 = 0 current.second = -2; - foreach (int logicalColumn, logicalIndexes) { + for(int i = 0; i < logicalIndexes.count(); ++i) { + const int logicalColumn = logicalIndexes.at(i); if (current.second + 1 != logicalColumn) { if (current.first != -2) { //let's save the current one diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp index 051b6a6..f44d207 100644 --- a/src/gui/kernel/qaction.cpp +++ b/src/gui/kernel/qaction.cpp @@ -136,25 +136,31 @@ void QActionPrivate::redoGrab(QShortcutMap &map) void QActionPrivate::redoGrabAlternate(QShortcutMap &map) { Q_Q(QAction); - foreach (int id, alternateShortcutIds) - if (id) + for(int i = 0; i < alternateShortcutIds.count(); ++i) { + if (const int id = alternateShortcutIds.at(i)) map.removeShortcut(id, q); + } alternateShortcutIds.clear(); if (alternateShortcuts.isEmpty()) return; - foreach (const QKeySequence& alternate, alternateShortcuts) { + for(int i = 0; i < alternateShortcuts.count(); ++i) { + const QKeySequence& alternate = alternateShortcuts.at(i); if (!alternate.isEmpty()) alternateShortcutIds.append(map.addShortcut(q, alternate, shortcutContext)); else alternateShortcutIds.append(0); } if (!enabled) { - foreach (int id, alternateShortcutIds) + for(int i = 0; i < alternateShortcutIds.count(); ++i) { + const int id = alternateShortcutIds.at(i); map.setShortcutEnabled(false, id, q); + } } if (!autorepeat) { - foreach (int id, alternateShortcutIds) + for(int i = 0; i < alternateShortcutIds.count(); ++i) { + const int id = alternateShortcutIds.at(i); map.setShortcutAutoRepeat(false, id, q); + } } } @@ -163,9 +169,10 @@ void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map) Q_Q(QAction); if (shortcutId) map.setShortcutEnabled(enable, shortcutId, q); - foreach (int id, alternateShortcutIds) - if (id) + for(int i = 0; i < alternateShortcutIds.count(); ++i) { + if (const int id = alternateShortcutIds.at(i)) map.setShortcutEnabled(enable, id, q); + } } #endif // QT_NO_SHORTCUT @@ -615,8 +622,10 @@ QAction::~QAction() #ifndef QT_NO_SHORTCUT if (d->shortcutId && qApp) { qApp->d_func()->shortcutMap.removeShortcut(d->shortcutId, this); - foreach (int id, d->alternateShortcutIds) + for(int i = 0; i < d->alternateShortcutIds.count(); ++i) { + const int id = d->alternateShortcutIds.at(i); qApp->d_func()->shortcutMap.removeShortcut(id, this); + } } #endif } diff --git a/src/gui/kernel/qwidgetaction.cpp b/src/gui/kernel/qwidgetaction.cpp index efdde5e..cd12029 100644 --- a/src/gui/kernel/qwidgetaction.cpp +++ b/src/gui/kernel/qwidgetaction.cpp @@ -228,8 +228,8 @@ bool QWidgetAction::event(QEvent *event) if (event->type() == QEvent::ActionChanged) { if (d->defaultWidget) d->defaultWidget->setEnabled(isEnabled()); - foreach (QWidget *w, d->createdWidgets) - w->setEnabled(isEnabled()); + for (int i = 0; i < d->createdWidgets.count(); ++i) + d->createdWidgets.at(i)->setEnabled(isEnabled()); } return QAction::event(event); } diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index 4f0ec1e..58e8f9c 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -2202,8 +2202,8 @@ QSet QDockAreaLayoutInfo::usedSeparatorWidgets() const { QSet result; - foreach (QWidget *sepWidget, separatorWidgets) - result << sepWidget; + for (int i = 0; i < separatorWidgets.count(); ++i) + result << separatorWidgets.at(i); for (int i = 0; i < item_list.count(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); @@ -3244,8 +3244,8 @@ QSet QDockAreaLayout::usedSeparatorWidgets() const { QSet result; - foreach (QWidget *sepWidget, separatorWidgets) - result << sepWidget; + for (int i = 0; i < separatorWidgets.count(); ++i) + result << separatorWidgets.at(i); for (int i = 0; i < QInternal::DockCount; ++i) { const QDockAreaLayoutInfo &dock = docks[i]; result += dock.usedSeparatorWidgets(); diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp index d573b8b..6a0c879 100644 --- a/src/gui/widgets/qdockwidget.cpp +++ b/src/gui/widgets/qdockwidget.cpp @@ -221,7 +221,8 @@ void QDockWidgetLayout::addItem(QLayoutItem*) QLayoutItem *QDockWidgetLayout::itemAt(int index) const { int cnt = 0; - foreach (QLayoutItem *item, item_list) { + for (int i = 0; i < item_list.count(); ++i) { + QLayoutItem *item = item_list.at(i); if (item == 0) continue; if (index == cnt++) @@ -250,8 +251,8 @@ QLayoutItem *QDockWidgetLayout::takeAt(int index) int QDockWidgetLayout::count() const { int result = 0; - foreach (QLayoutItem *item, item_list) { - if (item != 0) + for (int i = 0; i < item_list.count(); ++i) { + if (item_list.at(i)) ++result; } return result; diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index cffc3d5..fc7e901 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -220,7 +220,8 @@ void QMenuBarPrivate::updateGeometries() //we try to see if the actions will fit there bool hasHiddenActions = false; - foreach(QAction *action, actionList) { + for (int i = 0; i < actionList.count(); ++i) { + QAction *action = actionList.at(i); if (!menuRect.contains(actionRect(action))) { hasHiddenActions = true; break; @@ -230,7 +231,8 @@ void QMenuBarPrivate::updateGeometries() //...and if not, determine the ones that fit on the menu with the extension visible if (hasHiddenActions) { menuRect = this->menuRect(true); - foreach(QAction *action, actionList) { + for (int i = 0; i < actionList.count(); ++i) { + QAction *action = actionList.at(i); if (!menuRect.contains(actionRect(action))) { hiddenActions.append(action); } -- cgit v0.12 From 62725a02652cee576efe055d1371765945045026 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 10 Jun 2009 13:31:06 +0200 Subject: add some api docs to clarify what collate does --- src/gui/painting/qprinter.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/painting/qprinter.cpp b/src/gui/painting/qprinter.cpp index ba208fd..ce33893 100644 --- a/src/gui/painting/qprinter.cpp +++ b/src/gui/painting/qprinter.cpp @@ -1308,6 +1308,9 @@ void QPrinter::setNumCopies(int numCopies) Returns true if collation is turned on when multiple copies is selected. Returns false if it is turned off when multiple copies is selected. + When collating is turned off the printing of each individual page will be repeated + the numCopies() amount before the next page is started. With collating turned on + all pages are printed before the next copy of those pages is started. \sa setCollateCopies() */ -- cgit v0.12 From 08618c4d4e7b3d99ffa2b56ea03fa4e25de101bd Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 10 Jun 2009 14:41:33 +0200 Subject: Fix some possible double connected signals Task-number: 250147 Reviewed-by: Thierry --- src/gui/itemviews/qtableview.cpp | 6 +++--- src/gui/itemviews/qtreeview.cpp | 9 ++------- src/gui/widgets/qtoolbarlayout.cpp | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index 0bded54..454b1f5 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -1844,14 +1844,14 @@ void QTableView::setSortingEnabled(bool enable) disconnect(horizontalHeader(), SIGNAL(sectionPressed(int)), this, SLOT(selectColumn(int))); connect(horizontalHeader(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), - this, SLOT(sortByColumn(int))); + this, SLOT(sortByColumn(int)), Qt::UniqueConnection); sortByColumn(horizontalHeader()->sortIndicatorSection(), horizontalHeader()->sortIndicatorOrder()); } else { connect(d->horizontalHeader, SIGNAL(sectionEntered(int)), - this, SLOT(_q_selectColumn(int))); + this, SLOT(_q_selectColumn(int)), Qt::UniqueConnection); connect(horizontalHeader(), SIGNAL(sectionPressed(int)), - this, SLOT(selectColumn(int))); + this, SLOT(selectColumn(int)), Qt::UniqueConnection); disconnect(horizontalHeader(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortByColumn(int))); } diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 965a5c7..9910118 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -238,11 +238,6 @@ void QTreeView::setModel(QAbstractItemModel *model) connect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int))); - connect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(_q_columnsAboutToBeRemoved(QModelIndex,int,int))); - connect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)), - this, SLOT(_q_columnsRemoved(QModelIndex,int,int))); - connect(d->model, SIGNAL(modelAboutToBeReset()), SLOT(_q_modelAboutToBeReset())); if (d->sortingEnabled) @@ -3072,16 +3067,16 @@ void QTreeViewPrivate::_q_modelAboutToBeReset() void QTreeViewPrivate::_q_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end) { - Q_UNUSED(parent); if (start <= 0 && 0 <= end) viewItems.clear(); + QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(parent, start, end); } void QTreeViewPrivate::_q_columnsRemoved(const QModelIndex &parent, int start, int end) { - Q_UNUSED(parent); if (start <= 0 && 0 <= end) doDelayedItemsLayout(); + QAbstractItemViewPrivate::_q_columnsRemoved(parent, start, end); } void QTreeViewPrivate::layout(int i) diff --git a/src/gui/widgets/qtoolbarlayout.cpp b/src/gui/widgets/qtoolbarlayout.cpp index 0bfa493..0af2b65 100644 --- a/src/gui/widgets/qtoolbarlayout.cpp +++ b/src/gui/widgets/qtoolbarlayout.cpp @@ -128,7 +128,7 @@ void QToolBarLayout::setUsePopupMenu(bool set) invalidate(); if (!set) { QObject::connect(extension, SIGNAL(clicked(bool)), - this, SLOT(setExpanded(bool))); + this, SLOT(setExpanded(bool)), Qt::UniqueConnection); extension->setPopupMode(QToolButton::DelayedPopup); extension->setMenu(0); delete popupMenu; -- cgit v0.12 From 686700203aa9deeafba3bae826c7caec6d6916fd Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 10 Jun 2009 14:44:52 +0200 Subject: Move declaration of QFileInfoPrivate in a separate file _p and add an auto-test when we copy file infos. Reviewed-by: ogoffart --- src/corelib/io/io.pri | 1 + src/corelib/io/qfileinfo.cpp | 65 +---------------- src/corelib/io/qfileinfo_p.h | 126 +++++++++++++++++++++++++++++++++ tests/auto/qfileinfo/tst_qfileinfo.cpp | 56 +++++++++++++++ 4 files changed, 184 insertions(+), 64 deletions(-) create mode 100644 src/corelib/io/qfileinfo_p.h diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 8f37e25..5033b21 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -10,6 +10,7 @@ HEADERS += \ io/qdiriterator.h \ io/qfile.h \ io/qfileinfo.h \ + io/qfileinfo_p.h \ io/qiodevice.h \ io/qiodevice_p.h \ io/qnoncontiguousbytedevice_p.h \ diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 36b1ed8..4f1b943 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -48,73 +48,10 @@ #include "qatomic.h" #include "qhash.h" #include "qdir.h" +#include "qfileinfo_p.h" QT_BEGIN_NAMESPACE -class QFileInfoPrivate -{ -public: - QFileInfoPrivate(const QFileInfo *copy=0); - ~QFileInfoPrivate(); - - void initFileEngine(const QString &); - - enum Access { - ReadAccess, - WriteAccess, - ExecuteAccess - }; - bool hasAccess(Access access) const; - - uint getFileFlags(QAbstractFileEngine::FileFlags) const; - QDateTime &getFileTime(QAbstractFileEngine::FileTime) const; - QString getFileName(QAbstractFileEngine::FileName) const; - - enum { CachedFileFlags=0x01, CachedLinkTypeFlag=0x02, CachedBundleTypeFlag=0x04, - CachedMTime=0x10, CachedCTime=0x20, CachedATime=0x40, - CachedSize =0x08 }; - struct Data { - inline Data() - : ref(1), fileEngine(0), cache_enabled(1) - { clear(); } - inline Data(const Data ©) - : ref(1), fileEngine(QAbstractFileEngine::create(copy.fileName)), - fileName(copy.fileName), cache_enabled(copy.cache_enabled) - { clear(); } - inline ~Data() { delete fileEngine; } - inline void clearFlags() { - fileFlags = 0; - cachedFlags = 0; - if (fileEngine) - (void)fileEngine->fileFlags(QFSFileEngine::Refresh); - } - inline void clear() { - fileNames.clear(); - clearFlags(); - } - mutable QAtomicInt ref; - - QAbstractFileEngine *fileEngine; - mutable QString fileName; - mutable QHash fileNames; - - mutable uint cachedFlags : 31; - mutable uint cache_enabled : 1; - mutable uint fileFlags; - mutable qint64 fileSize; - mutable QDateTime fileTimes[3]; - inline bool getCachedFlag(uint c) const - { return cache_enabled ? (cachedFlags & c) : 0; } - inline void setCachedFlag(uint c) - { if (cache_enabled) cachedFlags |= c; } - } *data; - inline void reset() { - detach(); - data->clear(); - } - void detach(); -}; - QFileInfoPrivate::QFileInfoPrivate(const QFileInfo *copy) { if(copy) { diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h new file mode 100644 index 0000000..8155bcb --- /dev/null +++ b/src/corelib/io/qfileinfo_p.h @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFILEINFO_P_H +#define QFILEINFO_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qfileinfo.h" + +QT_BEGIN_NAMESPACE + +class QFileInfoPrivate +{ +public: + QFileInfoPrivate(const QFileInfo *copy=0); + ~QFileInfoPrivate(); + + void initFileEngine(const QString &); + + enum Access { + ReadAccess, + WriteAccess, + ExecuteAccess + }; + bool hasAccess(Access access) const; + + uint getFileFlags(QAbstractFileEngine::FileFlags) const; + QDateTime &getFileTime(QAbstractFileEngine::FileTime) const; + QString getFileName(QAbstractFileEngine::FileName) const; + + enum { CachedFileFlags=0x01, CachedLinkTypeFlag=0x02, CachedBundleTypeFlag=0x04, + CachedMTime=0x10, CachedCTime=0x20, CachedATime=0x40, + CachedSize =0x08 }; + struct Data { + inline Data() + : ref(1), fileEngine(0), cache_enabled(1) + { clear(); } + inline Data(const Data ©) + : ref(1), fileEngine(QAbstractFileEngine::create(copy.fileName)), + fileName(copy.fileName), cache_enabled(copy.cache_enabled) + { clear(); } + inline ~Data() { delete fileEngine; } + inline void clearFlags() { + fileFlags = 0; + cachedFlags = 0; + if (fileEngine) + (void)fileEngine->fileFlags(QFSFileEngine::Refresh); + } + inline void clear() { + fileNames.clear(); + clearFlags(); + } + mutable QAtomicInt ref; + + QAbstractFileEngine *fileEngine; + mutable QString fileName; + mutable QHash fileNames; + + mutable uint cachedFlags : 31; + mutable uint cache_enabled : 1; + mutable uint fileFlags; + mutable qint64 fileSize; + mutable QDateTime fileTimes[3]; + inline bool getCachedFlag(uint c) const + { return cache_enabled ? (cachedFlags & c) : 0; } + inline void setCachedFlag(uint c) + { if (cache_enabled) cachedFlags |= c; } + } *data; + inline void reset() { + detach(); + data->clear(); + } + void detach(); +}; + +QT_END_NAMESPACE + +#endif // QFILEINFO_P_H diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 3d7e6f8..cccdd64 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -61,6 +61,7 @@ #include #include "../network-settings.h" +#include //TESTED_CLASS= //TESTED_FILES= @@ -75,6 +76,9 @@ public: private slots: void getSetCheck(); + + void copy(); + void isFile_data(); void isFile(); @@ -178,6 +182,58 @@ void tst_QFileInfo::getSetCheck() QCOMPARE(true, obj1.caching()); } +static QFileInfoPrivate* getPrivate(QFileInfo &info) +{ + return (*reinterpret_cast(&info)); +} + +void tst_QFileInfo::copy() +{ + QTemporaryFile *t; + t = new QTemporaryFile; + t->open(); + QFileInfo info(t->fileName()); + QVERIFY(info.exists()); + + //copy constructor + QFileInfo info2(info); + QFileInfoPrivate *privateInfo = getPrivate(info); + QFileInfoPrivate *privateInfo2 = getPrivate(info2); + QCOMPARE(privateInfo->data, privateInfo2->data); + + //operator = + QFileInfo info3 = info; + QFileInfoPrivate *privateInfo3 = getPrivate(info3); + QCOMPARE(privateInfo->data, privateInfo3->data); + QCOMPARE(privateInfo2->data, privateInfo3->data); + + //refreshing info3 will detach it + QFile file(info.absoluteFilePath()); + QVERIFY(file.open(QFile::WriteOnly)); + QCOMPARE(file.write("JAJAJAA"), qint64(7)); + file.flush(); + + QTest::qWait(250); +#if defined(Q_OS_WIN) || defined(Q_OS_WINCE) + if (QSysInfo::windowsVersion() & QSysInfo::WV_VISTA || + QSysInfo::windowsVersion() & QSysInfo::WV_CE_based) + file.close(); +#endif +#if defined(Q_OS_WINCE) + // On Windows CE we need to close the file. + // Otherwise the content will be cached and not + // flushed to the storage, although we flushed it + // manually!!! CE has interim cache, we cannot influence. + QTest::qWait(5000); +#endif + info3.refresh(); + QVERIFY(privateInfo->data != privateInfo3->data); + QVERIFY(privateInfo2->data != privateInfo3->data); + QCOMPARE(privateInfo->data, privateInfo2->data); + + +} + tst_QFileInfo::tst_QFileInfo() { } -- cgit v0.12 From a66525c2e4c760f8ceda344cd7252431ed263654 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 29 May 2009 11:16:20 +0200 Subject: Use a linked list for the senders list inside QObject Speed up the disconnection and object destruction Reviewed-by: Brad --- src/corelib/kernel/qobject.cpp | 67 +++++++++++++++++++++++------------------- src/corelib/kernel/qobject_p.h | 5 +++- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 5e33a71..e953bcb 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -123,7 +123,7 @@ extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *) } QObjectPrivate::QObjectPrivate(int version) - : threadData(0), currentSender(0), currentChildBeingDeleted(0), connectionLists(0) + : threadData(0), currentSender(0), currentChildBeingDeleted(0), connectionLists(0), senders(0) { if (version != QObjectPrivateVersion) qFatal("Cannot mix incompatible Qt libraries"); @@ -287,8 +287,8 @@ QObjectList QObjectPrivate::senderList() const { QObjectList returnValue; QMutexLocker locker(signalSlotLock(q_func())); - for (int i = 0; i < senders.count(); ++i) - returnValue << senders.at(i)->sender; + for (Connection *c = senders; c; c = c->next) + returnValue << c->sender; return returnValue; } @@ -756,8 +756,10 @@ QObject::~QObject() QMutex *m = signalSlotLock(c->receiver); bool needToUnlock = QOrderedMutexLocker::relock(locker.mutex(), m); c = connectionList[i]; - if (c->receiver) - c->receiver->d_func()->senders.removeOne(c); + if (c->receiver) { + *c->prev = c->next; + if (c->next) c->next->prev = c->prev; + } if (needToUnlock) m->unlock(); @@ -774,29 +776,25 @@ QObject::~QObject() } // disconnect all senders - for (int i = 0; i < d->senders.count(); ) { - QObjectPrivate::Connection *s = d->senders[i]; - - QMutex *m = signalSlotLock(s->sender); + QObjectPrivate::Connection *node = d->senders; + while (node) { + QMutex *m = signalSlotLock(node->sender); + node->prev = &node; bool needToUnlock = QOrderedMutexLocker::relock(locker.mutex(), m); - if (m < locker.mutex()) { - if (i >= d->senders.count() || s != d->senders[i]) { - if (needToUnlock) - m->unlock(); - continue; - } + //the node has maybe been removed while the mutex was unlocked in relock? + if (!node || signalSlotLock(node->sender) != m) { + m->unlock(); + continue; } - s->receiver = 0; - QObjectConnectionListVector *senderLists = s->sender->d_func()->connectionLists; + node->receiver = 0; + QObjectConnectionListVector *senderLists = node->sender->d_func()->connectionLists; if (senderLists) senderLists->dirty = true; if (needToUnlock) m->unlock(); - ++i; + node = node->next; } - - d->senders.clear(); } if (d->pendTimer) { @@ -2281,8 +2279,8 @@ QObject *QObject::sender() const // Return 0 if d->currentSender isn't in d->senders bool found = false; - for (int i = 0; !found && i < d->senders.count(); ++i) - found = (d->senders.at(i)->sender == d->currentSender->sender); + for (QObjectPrivate::Connection *c = d->senders; c && !found; c = c->next) + found = (c->sender == d->currentSender->sender); if (!found) return 0; return d->currentSender->sender; @@ -2799,9 +2797,13 @@ bool QMetaObject::connect(const QObject *sender, int signal_index, c->method = method_index; c->connectionType = type; c->argumentTypes = types; + c->prev = &r->d_func()->senders; + c->next = *c->prev; + *c->prev = c; + if (c->next) + c->next->prev = &c->next; s->d_func()->addConnection(signal_index, c); - r->d_func()->senders.append(c); if (signal_index < 0) sender->d_func()->connectedSignals = ~0u; @@ -2851,8 +2853,10 @@ bool QMetaObject::disconnect(const QObject *sender, int signal_index, needToUnlock = QOrderedMutexLocker::relock(senderMutex, m); c = connectionList[i]; } - if (c->receiver) - c->receiver->d_func()->senders.removeOne(c); + if (c->receiver) { + *c->prev = c->next; + if (c->next) c->next->prev = c->prev; + } if (needToUnlock) m->unlock(); @@ -2878,8 +2882,10 @@ bool QMetaObject::disconnect(const QObject *sender, int signal_index, needToUnlock = QOrderedMutexLocker::relock(senderMutex, m); c = connectionList[i]; } - if (c->receiver) - c->receiver->d_func()->senders.removeOne(c); + if (c->receiver) { + *c->prev = c->next; + if (c->next) c->next->prev = c->prev; + } if (needToUnlock) m->unlock(); @@ -3417,9 +3423,8 @@ void QObject::dumpObjectInfo() // now look for connections where this object is the receiver qDebug(" SIGNALS IN"); - if (!d->senders.isEmpty()) { - for (int i = 0; i < d->senders.count(); ++i) { - const QObjectPrivate::Connection *s = d->senders.at(i); + if (d->senders) { + for (QObjectPrivate::Connection *s = d->senders; s; s = s->next) const QMetaMethod slot = metaObject()->method(s->method); qDebug(" <-- %s::%s %s", s->sender->metaObject()->className(), @@ -3427,7 +3432,7 @@ void QObject::dumpObjectInfo() slot.signature()); } } else { - qDebug(" "); + qDebug(" "); } #endif } diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 96d79af..d699061 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -152,6 +152,9 @@ public: int method; uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking QBasicAtomicPointer argumentTypes; + //senders linked list + Connection *next; + Connection **prev; ~Connection(); }; typedef QList ConnectionList; @@ -160,7 +163,7 @@ public: void addConnection(int signal, Connection *c); void cleanConnectionLists(); - ConnectionList senders; + Connection *senders; //linked list; static Sender *setCurrentSender(QObject *receiver, Sender *sender); -- cgit v0.12 From 1a5e7171b9da383ca5f6be92b7cb6e502fd79fc4 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 3 Jun 2009 20:47:06 +0200 Subject: Avoid locking and search on the global hash if there is no QPointer As less than 10% of the object have QPointers, we can avoid locking if we know there is no QPointer. And keeping track of which object has a QPointer is easy. Reviewed-by: Brad --- src/corelib/kernel/qobject.cpp | 22 +++++++++++++++++++--- src/corelib/kernel/qobject.h | 3 ++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index e953bcb..a095e0a 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -143,6 +143,7 @@ QObjectPrivate::QObjectPrivate(int version) inEventHandler = false; inThreadChangeEvent = false; deleteWatch = 0; + hasGuards = false; } QObjectPrivate::~QObjectPrivate() @@ -359,6 +360,7 @@ void QMetaObject::addGuard(QObject **ptr) return; } QMutexLocker locker(guardHashLock()); + QObjectPrivate::get(*ptr)->hasGuards = true; hash->insert(*ptr, ptr); } @@ -374,12 +376,17 @@ void QMetaObject::removeGuard(QObject **ptr) QMutexLocker locker(guardHashLock()); GuardHash::iterator it = hash->find(*ptr); const GuardHash::iterator end = hash->end(); + bool more = false; //if the QObject has more pointer attached to it. for (; it.key() == *ptr && it != end; ++it) { if (it.value() == ptr) { - (void) hash->erase(it); + it = hash->erase(it); + if (!more) more = (it != end && it.key() == *ptr); break; } + more = true; } + if (!more) + QObjectPrivate::get(*ptr)->hasGuards = false; } /*!\internal @@ -393,24 +400,33 @@ void QMetaObject::changeGuard(QObject **ptr, QObject *o) } QMutexLocker locker(guardHashLock()); if (*ptr) { + bool more = false; //if the QObject has more pointer attached to it. GuardHash::iterator it = hash->find(*ptr); const GuardHash::iterator end = hash->end(); for (; it.key() == *ptr && it != end; ++it) { if (it.value() == ptr) { - (void) hash->erase(it); + it = hash->erase(it); + if (!more) more = (it != end && it.key() == *ptr); break; } + more = true; } + if (!more) + QObjectPrivate::get(*ptr)->hasGuards = false; } *ptr = o; - if (*ptr) + if (*ptr) { hash->insert(*ptr, ptr); + QObjectPrivate::get(*ptr)->hasGuards = true; + } } /*! \internal */ void QObjectPrivate::clearGuards(QObject *object) { + if (!QObjectPrivate::get(object)->hasGuards) + return; GuardHash *hash = guardHash(); if (hash) { QMutexLocker locker(guardHashLock()); diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index dbec0a6..b1f41ad 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -106,7 +106,8 @@ public: uint receiveChildEvents : 1; uint inEventHandler : 1; uint inThreadChangeEvent : 1; - uint unused : 23; + uint hasGuards : 1; //true iff there is one or more QPointer attached to this object + uint unused : 22; int postedEvents; }; -- cgit v0.12