From 2d194009379a4e199ec246ca053ee97ee733482f Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 6 May 2009 10:31:28 +1000 Subject: Made tst_Selftests::checkXML actually test the new (Qt 4.6) test logger. Previously `-flush' was always passed to the child process, meaning the old (Qt 4.5) test logger was used exclusively in this test, hiding bugs. --- tests/auto/selftests/badxml/tst_badxml.cpp | 7 ++++ tests/auto/selftests/tst_selftests.cpp | 63 +++++++++++++++++------------- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/tests/auto/selftests/badxml/tst_badxml.cpp b/tests/auto/selftests/badxml/tst_badxml.cpp index 6b2e4c4..fa5b717 100644 --- a/tests/auto/selftests/badxml/tst_badxml.cpp +++ b/tests/auto/selftests/badxml/tst_badxml.cpp @@ -58,6 +58,8 @@ private slots: void badMessage() const; void badMessage_data() const; + void failWithNoFile() const; + public: static QList const& badStrings(); }; @@ -116,6 +118,11 @@ void tst_BadXml::badDataTag_data() const } } +void tst_BadXml::failWithNoFile() const +{ + QTest::qFail("failure message", 0, 0); +} + /* Outputs a message containing a bad string. */ diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index aa1048b..d4069b1 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -324,34 +324,41 @@ void tst_Selftests::checkXML() const if(m_checkXMLBlacklist.contains(subdir)) return; - arguments.prepend("-xml"); - arguments.prepend("-flush"); - - QProcess proc; - proc.setEnvironment(QStringList("")); - proc.start(subdir + "/" + subdir, arguments); - QVERIFY(proc.waitForFinished()); - - QByteArray out(proc.readAllStandardOutput()); - QByteArray err(proc.readAllStandardError()); - - /* Some platforms decides to output a message for uncaught exceptions. For instance, - * this is what windows platforms says: - * "This application has requested the Runtime to terminate it in an unusual way. - * Please contact the application's support team for more information." */ - if(subdir != QLatin1String("exception") && subdir != QLatin1String("fetchbogus")) - QVERIFY2(err.isEmpty(), err.constData()); - - QXmlStreamReader reader(out); - - while(!reader.atEnd()) - reader.readNext(); - - QVERIFY2(!reader.error(), qPrintable(QString("line %1, col %2: %3") - .arg(reader.lineNumber()) - .arg(reader.columnNumber()) - .arg(reader.errorString()) - )); + QStringList args; + /* Test both old (-flush) and new XML logger implementation */ + for (int i = 0; i < 2; ++i) { + bool flush = i; + args = arguments; + args.prepend("-xml"); + if (flush) args.prepend("-flush"); + + QProcess proc; + proc.setEnvironment(QStringList("")); + proc.start(subdir + "/" + subdir, args); + QVERIFY(proc.waitForFinished()); + + QByteArray out(proc.readAllStandardOutput()); + QByteArray err(proc.readAllStandardError()); + + /* Some platforms decides to output a message for uncaught exceptions. For instance, + * this is what windows platforms says: + * "This application has requested the Runtime to terminate it in an unusual way. + * Please contact the application's support team for more information." */ + if(subdir != QLatin1String("exception") && subdir != QLatin1String("fetchbogus")) + QVERIFY2(err.isEmpty(), err.constData()); + + QXmlStreamReader reader(out); + + while(!reader.atEnd()) + reader.readNext(); + + QVERIFY2(!reader.error(), qPrintable(QString("(flush %0) line %1, col %2: %3") + .arg(flush) + .arg(reader.lineNumber()) + .arg(reader.columnNumber()) + .arg(reader.errorString()) + )); + } } void tst_Selftests::checkXunitxml() const -- cgit v0.12 From 9a60df38330c8a37d48e4e3f8fbdfc067b320cb5 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 6 May 2009 10:34:40 +1000 Subject: Fixed invalid XML from testlib. Obvious typo in format string: `', closing tag should be `DataTag'. Autotest: 2d194009379a4e199ec246ca053ee97ee733482f --- src/testlib/qtestxmlstreamer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp index cf99b96..055abe0 100644 --- a/src/testlib/qtestxmlstreamer.cpp +++ b/src/testlib/qtestxmlstreamer.cpp @@ -54,7 +54,7 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char *formatted) QXmlTestLogger::xmlCdata(cdataTag, element->attributeValue(QTest::AI_Tag), sizeof(cdataTag)); QTest::qt_snprintf(formatted, 1024, "\n" - " \n" + " \n" " \n" "\n", element->attributeValue(QTest::AI_Result), location, cdataTag, cdataDesc); -- cgit v0.12 From 826bc847e6601f834a3ece8c001a8dd2bfa2fe97 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 6 May 2009 10:46:35 +1000 Subject: Fixed invalid XML from testlib: `addAttribute(QTest::AI_Result, typeBuf); - failureElement->addAttribute(QTest::AI_File, file); + if(file) + failureElement->addAttribute(QTest::AI_File, file); + else + failureElement->addAttribute(QTest::AI_File, ""); QTest::qt_snprintf(buf, sizeof(buf), "%i", line); failureElement->addAttribute(QTest::AI_Line, buf); failureElement->addAttribute(QTest::AI_Description, description); -- cgit v0.12 From 548da9a5434d615456a7a6efda3380b7138c6000 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 6 May 2009 11:00:59 +1000 Subject: Fixed failure of tst_Selftests::checkXML. A few tests use printf, which means they interfere with the XML test logging. Blacklist them for the XML test. Note that these tests happened to pass under the old test logger implementation. That was because the test logger always printed XML tags on a single line, and the printf calls contained no special XML characters. The test logs generated were technically valid XML but contained extraneous text. --- tests/auto/selftests/tst_selftests.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index d4069b1..603e730 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -307,13 +307,12 @@ void tst_Selftests::initTestCase() m_checkXMLBlacklist.append("qexecstringlist"); m_checkXMLBlacklist.append("benchliboptions"); + /* These tests use printf and therefore corrupt the testlog */ + m_checkXMLBlacklist.append("subtest"); + m_checkXMLBlacklist.append("globaldata"); + m_checkXMLBlacklist.append("warnings"); + m_checkXunitBlacklist = m_checkXMLBlacklist; - m_checkXunitBlacklist.append("benchlibwalltime"); - m_checkXunitBlacklist.append("benchlibeventcounter"); - m_checkXunitBlacklist.append("benchlibcallgrind"); - m_checkXunitBlacklist.append("subtest"); - m_checkXunitBlacklist.append("globaldata"); - m_checkXunitBlacklist.append("warnings"); } void tst_Selftests::checkXML() const -- cgit v0.12 From 244f5ee9c2c34ddee200e4d5cdc1345762a5901b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 29 Apr 2009 17:01:04 +0200 Subject: Fix QFormLayout which allowed fields to be smaller that their minimum size If the label's sizeHint is bigger than its minimumSizeHint, the field may be resized smaller than its minimum size. This also fix another problem where the field would 'jump' from one sizehint to the others. (This can happen if labels can word-wrap for example) Reviewed-by: Michael Goddard --- src/gui/kernel/qformlayout.cpp | 6 +++++- tests/auto/qformlayout/tst_qformlayout.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qformlayout.cpp b/src/gui/kernel/qformlayout.cpp index e2d6108..a665c89 100644 --- a/src/gui/kernel/qformlayout.cpp +++ b/src/gui/kernel/qformlayout.cpp @@ -689,12 +689,16 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) // are split. maxLabelWidth = 0; if (!wrapAllRows) { + int maxFieldMinWidth = 0; //the maximum minimum size of the field for (int i = 0; i < rr; ++i) { const QFormLayoutItem *label = m_matrix(i, 0); const QFormLayoutItem *field = m_matrix(i, 1); - if (label && (label->sizeHint.width() + (field ? field->minSize.width() : 0) <= width)) + if (label && field && label->sideBySide) maxLabelWidth = qMax(maxLabelWidth, label->sizeHint.width()); + if (field) + maxFieldMinWidth = qMax(maxFieldMinWidth, field->minSize.width() + field->sbsHSpace); } + maxLabelWidth = qMin(maxLabelWidth, width - maxFieldMinWidth); } else { maxLabelWidth = width; } diff --git a/tests/auto/qformlayout/tst_qformlayout.cpp b/tests/auto/qformlayout/tst_qformlayout.cpp index c4c6f70..242974d 100644 --- a/tests/auto/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/qformlayout/tst_qformlayout.cpp @@ -125,6 +125,7 @@ private slots: Qt::Orientations expandingDirections() const; */ + void fieldMinimumSize(); }; tst_QFormLayout::tst_QFormLayout() @@ -905,6 +906,35 @@ void tst_QFormLayout::layoutAlone() QTest::qWait(500); } + +void tst_QFormLayout::fieldMinimumSize() +{ + //check that the field with is bigger than its minimumSizeHint for any size of the widget + // even if the label with is not fixed + QWidget w; + QFormLayout layout; + layout.setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); + w.setLayout(&layout); + QLabel label1("Here is a strange test case"); + label1.setWordWrap(true); + QLabel label2("Here is another label"); + label2.setWordWrap(true); + QLabel shortLabel("short"); + QLabel longLabel("Quite long label"); + layout.addRow(&label1, &shortLabel); + layout.addRow(&label2, &longLabel); + w.show(); + int width = w.size().width() + 9; + + do { + w.resize(width, w.size().height()); + layout.activate(); + QVERIFY(shortLabel.size().width() >= shortLabel.minimumSizeHint().width()); + QVERIFY(longLabel.size().width() >= longLabel.minimumSizeHint().width()); + width -= 3; + } while(width >= w.minimumSizeHint().width()); +} + QTEST_MAIN(tst_QFormLayout) #include "tst_qformlayout.moc" -- cgit v0.12 From ffbb3c1a2aee4134dce80cd144a26bf32865b698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 6 May 2009 09:43:32 +0200 Subject: Fixed some inconsistencies for image drawing on non-integer coords. Don't use aliased coordinate delta for image drawing. Related to change fde7475bcf9c10522a8170e6eb8fb9a8fadc21cd. Task-number: 251561 Reviewed-by: Trond --- src/gui/painting/qblendfunctions.cpp | 12 ++---------- src/gui/painting/qpaintengine_raster.cpp | 6 +++++- tests/arthur/data/qps/borderimage.qps | 20 ++++++++++++++++++++ tests/arthur/data/qps/borderimage_qps.png | Bin 88788 -> 90704 bytes 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp index dd7b016..93f11e1 100644 --- a/src/gui/painting/qblendfunctions.cpp +++ b/src/gui/painting/qblendfunctions.cpp @@ -44,8 +44,6 @@ QT_BEGIN_NAMESPACE -static const qreal aliasedCoordinateDelta = 0.5 - 0.015625; - struct SourceOnlyAlpha { inline uchar alpha(uchar src) const { return src; } @@ -140,14 +138,11 @@ struct Blend_ARGB32_on_RGB16_SourceAndConstAlpha { template void qt_scale_image_16bit(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, - const QRectF &target, + const QRectF &targetRect, const QRectF &srcRect, const QRect &clip, T blender) { - const QRectF targetRect = target.translated(aliasedCoordinateDelta, - aliasedCoordinateDelta); - qreal sx = targetRect.width() / (qreal) srcRect.width(); qreal sy = targetRect.height() / (qreal) srcRect.height(); @@ -618,14 +613,11 @@ struct Blend_ARGB32_on_ARGB32_SourceAndConstAlpha { template void qt_scale_image_32bit(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, - const QRectF &target, + const QRectF &targetRect, const QRectF &srcRect, const QRect &clip, T blender) { - const QRectF targetRect = target.translated(aliasedCoordinateDelta, - aliasedCoordinateDelta); - qreal sx = targetRect.width() / (qreal) srcRect.width(); qreal sy = targetRect.height() / (qreal) srcRect.height(); diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 788b722..cbfd5e3 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2573,7 +2573,11 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe QRasterPaintEngineState *s = state(); const bool aa = s->flags.antialiased || s->flags.bilinear; if (!aa && sr.size() == QSize(1, 1)) { - fillRect(r, QColor::fromRgba(img.pixel(sr.x(), sr.y()))); + // as fillRect will apply the aliased coordinate delta we need to + // subtract it here as we don't use it for image drawing + const QRectF targetRect = r.translated(-aliasedCoordinateDelta, + -aliasedCoordinateDelta); + fillRect(targetRect, QColor::fromRgba(img.pixel(sr.x(), sr.y()))); return; } diff --git a/tests/arthur/data/qps/borderimage.qps b/tests/arthur/data/qps/borderimage.qps index 747a74d..14073fe 100644 --- a/tests/arthur/data/qps/borderimage.qps +++ b/tests/arthur/data/qps/borderimage.qps @@ -106,6 +106,23 @@ repeat_block draw_column resetMatrix setRenderHint Antialiasing off +translate 200.1 520.1 + +begin_block one_pixel_border +drawImage borderimage 0 0 16 16 0 0 16 16 +drawImage borderimage 16 0 64 16 16 0 1 1 +drawImage borderimage 80 0 16 16 48 0 16 16 + +drawImage borderimage 0 16 16 64 16 0 1 1 +drawImage borderimage 80 16 16 64 16 0 1 1 + +drawImage borderimage 0 80 16 16 0 48 16 16 +drawImage borderimage 16 80 64 16 16 0 1 1 +drawImage borderimage 80 80 16 16 48 48 16 16 +end_block one_pixel_border + +resetMatrix + setPen red drawRect 0 0 70 680 @@ -127,3 +144,6 @@ drawText 174 114 "smoothpixmaptransform off" drawRect 164 128 224 134 drawText 174 252 "smoothpixmaptransform on" + +drawRect 200 520 97 128 +drawText 210 638 "1x1 edges" diff --git a/tests/arthur/data/qps/borderimage_qps.png b/tests/arthur/data/qps/borderimage_qps.png index 89a8eba..a4ec6cb 100644 Binary files a/tests/arthur/data/qps/borderimage_qps.png and b/tests/arthur/data/qps/borderimage_qps.png differ -- cgit v0.12 From bd29efb125142c936a57a9e6ad35c3f9f76b8e17 Mon Sep 17 00:00:00 2001 From: mae Date: Wed, 6 May 2009 10:13:43 +0200 Subject: Fixed scrolling performance issue related to hidden blocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Due to a wrong lookup (confusing line and block number) the scroll optimization was broken, causing the entire view to be updated. Reviewed-by: Thorbjørn Lindeijer --- src/gui/widgets/qplaintextedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index 2e9201d..e563fa1 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -624,7 +624,7 @@ void QPlainTextEditPrivate::setTopBlock(int blockNumber, int lineNumber, int dx) if (viewport->updatesEnabled() && viewport->isVisible()) { int dy = 0; - if (doc->findBlockByLineNumber(control->topBlock).isValid()) { + if (doc->findBlockByNumber(control->topBlock).isValid()) { dy = (int)(-q->blockBoundingGeometry(block).y()) + verticalOffset() - verticalOffset(blockNumber, lineNumber); } -- cgit v0.12 From a78dba4353318efdf7b11116518650fd539a9fd9 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Wed, 6 May 2009 11:23:56 +0200 Subject: Doc: Updated QImageReader::supportedImageFormat() to include SVG Task-number: 252415 --- src/gui/image/qimagereader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 5de39d9..7f36be9 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -1337,6 +1337,7 @@ QByteArray QImageReader::imageFormat(QIODevice *device) \row \o TIFF \o Tagged Image File Format \row \o XBM \o X11 Bitmap \row \o XPM \o X11 Pixmap + \row \o SVG \o Scalable Vector Graphics \endtable Reading and writing SVG files is supported through Qt's -- cgit v0.12 From 384869482e2481685dd409208f583a1acc77bcc8 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 29 Apr 2009 10:01:24 +0200 Subject: Mac OS X QWidget::setMinimumSize locks. There was code for updating the size constrains inside setConstraints_sys. This is now added. Factored out the code that does this into a function, and since we never applied size constraines on a window upon creation, I also added an extra call from that code part Task-number: 219695 Reviewed-by: Trenton Schulz --- src/gui/kernel/qwidget_mac.mm | 86 ++++++++++++++++++++++--------------------- src/gui/kernel/qwidget_p.h | 3 +- 2 files changed, 46 insertions(+), 43 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 5abaaf8..3f89ff3 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -2162,6 +2162,7 @@ void QWidgetPrivate::finishCreateWindow_sys_Carbon(OSWindowRef windowRef) setWindowModified_sys(q->isWindowModified()); updateFrameStrut(); qt_mac_update_sizer(q); + applyMaxAndMinSizeOnWindow(); } #else // QT_MAC_USE_COCOA void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWindowRef) @@ -2247,6 +2248,7 @@ void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWin syncCocoaMask(); macUpdateIsOpaque(); qt_mac_update_sizer(q); + applyMaxAndMinSizeOnWindow(); } #endif // QT_MAC_USE_COCOA @@ -4001,7 +4003,7 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect) } } -void QWidgetPrivate::applyMaxAndMinSizeConstraints(int &w, int &h) +void QWidgetPrivate::adjustWithinMaxAndMinSize(int &w, int &h) { if (QWExtra *extra = extraData()) { w = qMin(w, extra->maxw); @@ -4028,6 +4030,26 @@ void QWidgetPrivate::applyMaxAndMinSizeConstraints(int &w, int &h) } } +void QWidgetPrivate::applyMaxAndMinSizeOnWindow() +{ + Q_Q(QWidget); + const float max_f(20000); +#ifndef QT_MAC_USE_COCOA +#define SF(x) ((x > max_f) ? max_f : x) + HISize max = CGSizeMake(SF(extra->maxw), SF(extra->maxh)); + HISize min = CGSizeMake(SF(extra->minw), SF(extra->minh)); +#undef SF + SetWindowResizeLimits(qt_mac_window_for(q), &min, &max); +#else +#define SF(x) ((x > max_f) ? max_f : x) + NSSize max = NSMakeSize(SF(extra->maxw), SF(extra->maxh)); + NSSize min = NSMakeSize(SF(extra->minw), SF(extra->minh)); +#undef SF + [qt_mac_window_for(q) setMinSize:min]; + [qt_mac_window_for(q) setMaxSize:max]; +#endif +} + void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) { Q_Q(QWidget); @@ -4039,17 +4061,18 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) QMacCocoaAutoReleasePool pool; bool realWindow = isRealWindow(); - if (realWindow && !q->testAttribute(Qt::WA_DontShowOnScreen) + if (realWindow && !q->testAttribute(Qt::WA_DontShowOnScreen)){ + adjustWithinMaxAndMinSize(w, h); #ifndef QT_MAC_USE_COCOA - && !(w == 0 && h == 0) -#endif - ){ - applyMaxAndMinSizeConstraints(w, h); - topData()->isSetGeometry = 1; - topData()->isMove = isMove; -#ifndef QT_MAC_USE_COCOA - Rect r; SetRect(&r, x, y, x + w, y + h); - SetWindowBounds(qt_mac_window_for(q), kWindowContentRgn, &r); + if (w != 0 && h != 0) { + topData()->isSetGeometry = 1; + topData()->isMove = isMove; + Rect r; SetRect(&r, x, y, x + w, y + h); + SetWindowBounds(qt_mac_window_for(q), kWindowContentRgn, &r); + topData()->isSetGeometry = 0; + } else { + setGeometry_sys_helper(x, y, w, h, isMove); + } #else NSWindow *window = qt_mac_window_for(q); const QRect &fStrut = frameStrut(); @@ -4077,7 +4100,6 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) [window setFrameOrigin:cocoaFrameRect.origin]; } #endif - topData()->isSetGeometry = 0; } else { setGeometry_sys_helper(x, y, w, h, isMove); } @@ -4102,40 +4124,19 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM data.crect = QRect(x, y, w, h); if (realWindow) { - if (QWExtra *extra = extraData()) { - applyMaxAndMinSizeConstraints(w, h); - qt_mac_update_sizer(q); + adjustWithinMaxAndMinSize(w, h); + qt_mac_update_sizer(q); - if (q->windowFlags() & Qt::WindowMaximizeButtonHint) { #ifndef QT_MAC_USE_COCOA - OSWindowRef window = qt_mac_window_for(q); - if(extra->maxw && extra->maxh && extra->maxw == extra->minw - && extra->maxh == extra->minh) { - ChangeWindowAttributes(window, kWindowNoAttributes, kWindowFullZoomAttribute); - } else { - ChangeWindowAttributes(window, kWindowFullZoomAttribute, kWindowNoAttributes); - } -#endif + if (q->windowFlags() & Qt::WindowMaximizeButtonHint) { + OSWindowRef window = qt_mac_window_for(q); + if (extra->maxw && extra->maxh && extra->maxw == extra->minw + && extra->maxh == extra->minh) { + ChangeWindowAttributes(window, kWindowNoAttributes, kWindowFullZoomAttribute); + } else { + ChangeWindowAttributes(window, kWindowFullZoomAttribute, kWindowNoAttributes); } - - // Update max and min constraints: - const float max_f(20000); -#ifndef QT_MAC_USE_COCOA -#define SF(x) ((x > max_f) ? max_f : x) - HISize max = CGSizeMake(SF(extra->maxw), SF(extra->maxh)); - HISize min = CGSizeMake(SF(extra->minw), SF(extra->minh)); -#undef SF - SetWindowResizeLimits(qt_mac_window_for(q), &min, &max); -#else -#define SF(x) ((x > max_f) ? max_f : x) - NSSize max = NSMakeSize(SF(extra->maxw), SF(extra->maxh)); - NSSize min = NSMakeSize(SF(extra->minw), SF(extra->minh)); -#undef SF - [qt_mac_window_for(q) setMinSize:min]; - [qt_mac_window_for(q) setMaxSize:max]; -#endif } -#ifndef QT_MAC_USE_COCOA HIRect bounds = CGRectMake(0, 0, w, h); HIViewSetFrame(qt_mac_nativeview_for(q), &bounds); #else @@ -4181,6 +4182,7 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM void QWidgetPrivate::setConstraints_sys() { updateMaximizeButton_sys(); + applyMaxAndMinSizeOnWindow(); } void QWidgetPrivate::updateMaximizeButton_sys() diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index db78682..2461820 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -257,7 +257,8 @@ public: void macUpdateIsOpaque(); void setEnabled_helper_sys(bool enable); bool isRealWindow() const; - void applyMaxAndMinSizeConstraints(int &w, int &h); + void adjustWithinMaxAndMinSize(int &w, int &h); + void applyMaxAndMinSizeOnWindow(); #endif void raise_sys(); -- cgit v0.12 From 6ba793ea76e72332786ee90022ee169fca311446 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 6 May 2009 11:11:32 +0200 Subject: QComboBox: Click-drag-release does not work for combo boxes using Cocoa The problem is that the mouse event was redirected to the active pop-up, while it should have been redirected to the widget under the mouse under the active popup. This patch does the correct redirection Task-number: 252259 Reviewed-by: Trenton Schulz --- src/gui/kernel/qt_cocoa_helpers_mac.mm | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index f000292..9165836 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -826,13 +826,28 @@ bool qt_mac_handleMouseEvent(void * /* NSView * */view, void * /* NSEvent * */ev QWidget *qwidget = [theView qt_qwidget]; QWidget *widgetToGetMouse = qwidget; QWidget *popup = qAppInstance()->activePopupWidget(); - if (popup && popup != qwidget->window()) - widgetToGetMouse = popup; NSView *tmpView = theView; - if (widgetToGetMouse != qwidget) { - tmpView = qt_mac_nativeview_for(widgetToGetMouse); + + if (popup && popup != qwidget->window()) { + widgetToGetMouse = popup; + tmpView = qt_mac_nativeview_for(popup); windowPoint = [[tmpView window] convertScreenToBase:globalPoint]; + + QPoint qWindowPoint(windowPoint.x, windowPoint.y); + if (widgetToGetMouse->rect().contains(qWindowPoint)) { + // Keeping the mouse pressed on a combobox button will make + // the popup pop in front of the mouse. But all mouse events + // will be sendt to the button. Since we want mouse events + // to be sendt to widgets inside the popup, we search for the + // widget in front of the mouse: + tmpView = [tmpView hitTest:windowPoint]; + if (!tmpView) + return false; + widgetToGetMouse = + [static_cast(tmpView) qt_qwidget]; + } } + NSPoint localPoint = [tmpView convertPoint:windowPoint fromView:nil]; QPoint qlocalPoint(localPoint.x, localPoint.y); -- cgit v0.12 From 54313dfcb36286916f5daa7df5d605f2d94b70ea Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Wed, 6 May 2009 11:35:37 +0200 Subject: Doc: Said that QTextCursor is an implicitly shared class in QTextCursor::operator= Task-number: 247955 --- src/gui/text/qtextcursor.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index c327b9f..48963bb 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -1074,7 +1074,10 @@ QTextCursor::QTextCursor(const QTextCursor &cursor) } /*! - Makes a copy of \a cursor and assigns it to this QTextCursor. + Makes a copy of \a cursor and assigns it to this QTextCursor. Note + that QTextCursor is an \l{Implicitly Shared Classes}{implicitly + shared} class. + */ QTextCursor &QTextCursor::operator=(const QTextCursor &cursor) { -- cgit v0.12 From 6586200d3043ba7915bc60695e2a1436a5cadfa3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 6 May 2009 12:11:59 +0200 Subject: Moved the QT_BEGIN_NAMESPACE macro to the right place in qsslcipher.cpp Task-number: 252298 Reviewed-by: Peter Hartmann --- src/network/ssl/qsslcipher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/ssl/qsslcipher.cpp b/src/network/ssl/qsslcipher.cpp index 505c662..7fec2df 100644 --- a/src/network/ssl/qsslcipher.cpp +++ b/src/network/ssl/qsslcipher.cpp @@ -64,9 +64,9 @@ #ifndef QT_NO_DEBUG_STREAM #include +#endif QT_BEGIN_NAMESPACE -#endif /*! Constructs an empty QSslCipher object. -- cgit v0.12 From b38874c55ec7d046c3ff3ba08599d52e004c0146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Wed, 6 May 2009 12:58:33 +0200 Subject: Optimize QCocoaView::registerDragTypes and mode switching in QtCreator. We were registering the types each time drag and drop was enabled, which caused slowdowns when for example switching between the Edit and Debug modes in QtCreator. Instead, register the types on first enable and also when the custom types change. Add check to draggingEntered() that disables the drag if WA_DropSiteRegistered is false. Reviewed-by: nrc --- src/gui/kernel/qcocoaview_mac.mm | 18 +++++++++++++----- src/gui/kernel/qcocoaview_mac_p.h | 3 ++- src/gui/kernel/qwidget_mac.mm | 4 ++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index ff36ca1..4ceae3f 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -198,6 +198,7 @@ extern "C" { } composing = false; sendKeyEvents = true; + currentCustomTypes = 0; [self setHidden:YES]; return self; } @@ -212,10 +213,16 @@ extern "C" { object:self]; } --(void)registerDragTypes:(bool)accept +-(void)registerDragTypes { QMacCocoaAutoReleasePool pool; - if (accept) { + // Calling registerForDraggedTypes is slow, so only do it once for each widget + // or when the custom types change. + const QStringList& customTypes = qEnabledDraggedTypes(); + if (currentCustomTypes == 0 || *currentCustomTypes != customTypes) { + if (currentCustomTypes == 0) + currentCustomTypes = new QStringList(); + *currentCustomTypes = customTypes; const NSString* mimeTypeGeneric = @"com.trolltech.qt.MimeTypeName"; NSMutableArray *supportedTypes = [NSMutableArray arrayWithObjects:NSColorPboardType, NSFilenamesPboardType, NSStringPboardType, @@ -227,13 +234,10 @@ extern "C" { NSFilesPromisePboardType, NSInkTextPboardType, NSMultipleTextSelectionPboardType, mimeTypeGeneric, nil]; // Add custom types supported by the application. - const QStringList& customTypes = qEnabledDraggedTypes(); for (int i = 0; i < customTypes.size(); i++) { [supportedTypes addObject:reinterpret_cast(QCFString::toCFStringRef(customTypes[i]))]; } [self registerForDraggedTypes:supportedTypes]; - } else { - [self unregisterDraggedTypes]; } } @@ -282,6 +286,8 @@ extern "C" { - (NSDragOperation)draggingEntered:(id )sender { + if (qwidget->testAttribute(Qt::WA_DropSiteRegistered) == false) + return NSDragOperationNone; [self addDropData:sender]; QMimeData *mimeData = dropData; if (QDragManager::self()->source()) @@ -414,6 +420,8 @@ extern "C" { - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; + delete currentCustomTypes; + [self unregisterDraggedTypes]; [super dealloc]; } diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/gui/kernel/qcocoaview_mac_p.h index 9de94d5..983c762 100644 --- a/src/gui/kernel/qcocoaview_mac_p.h +++ b/src/gui/kernel/qcocoaview_mac_p.h @@ -83,6 +83,7 @@ Q_GUI_EXPORT bool composing; int composingLength; bool sendKeyEvents; + QStringList *currentCustomTypes; } - (id)initWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate; - (void) finishInitWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate; @@ -91,7 +92,7 @@ Q_GUI_EXPORT - (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender; - (void)draggingExited:(id < NSDraggingInfo >)sender; - (BOOL)performDragOperation:(id )sender; -- (void)registerDragTypes:(bool)accept; +- (void)registerDragTypes; - (void)removeDropData; - (void)addDropData:(id )sender; - (void)setSupportedActions:(NSDragOperation)actions; diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 3f89ff3..b315eaf 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -4497,8 +4497,8 @@ void QWidgetPrivate::registerDropSite(bool on) SetControlDragTrackingEnabled(qt_mac_nativeview_for(q), on); #else NSView *view = qt_mac_nativeview_for(q); - if ([view isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaView) class]]) { - [static_cast(view) registerDragTypes:on]; + if (on && [view isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaView) class]]) { + [static_cast(view) registerDragTypes]; } #endif } -- cgit v0.12 From 7bfee916ec053fa0b4092c7f9ed635376e58abe1 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 6 May 2009 21:01:36 +1000 Subject: Track expression evaluation when debugging is enabled --- src/declarative/debugger/qmldebugger.cpp | 29 ++++++- src/declarative/qml/qmlengine.cpp | 138 ++++++++++++++++++++++++------- src/declarative/qml/qmlengine_p.h | 27 ++++++ src/declarative/qml/qmlexpression.h | 1 + 4 files changed, 162 insertions(+), 33 deletions(-) diff --git a/src/declarative/debugger/qmldebugger.cpp b/src/declarative/debugger/qmldebugger.cpp index 1f7fd68..033a15f 100644 --- a/src/declarative/debugger/qmldebugger.cpp +++ b/src/declarative/debugger/qmldebugger.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -98,13 +99,35 @@ public: int startLine; int endLine; QUrl url; + + QPointer bindableValue; }; void QmlDebugger::itemPressed(QTreeWidgetItem *i) { QmlDebuggerItem *item = static_cast(i); - if(item->url.scheme() == QLatin1String("file")) { + if(item->bindableValue) { + + QString str; + + QmlExpressionPrivate *p = item->bindableValue->d; + if(p->log) { + QString str; + QDebug d(&str); + for(int ii = 0; ii < p->log->count(); ++ii) { + d << p->log->at(ii).result() << "\n"; + QStringList warnings = p->log->at(ii).warnings(); + foreach(const QString &warning, warnings) + d << " " << warning << "\n"; + } + m_text->setPlainText(str); + + } else { + m_text->setPlainText("No history"); + } + + } else if(item->url.scheme() == QLatin1String("file")) { QString f = item->url.toLocalFile(); QFile file(f); file.open(QIODevice::ReadOnly); @@ -160,6 +183,7 @@ static bool makeItem(QObject *obj, QmlDebuggerItem *item) if(QmlBindableValue *bv = qobject_cast(obj)) { text = bv->property().name() + ": " + bv->expression(); item->setForeground(0, Qt::green); + item->bindableValue = bv; } else if(QmlBoundSignal *bs = qobject_cast(obj)) { QMetaMethod method = obj->parent()->metaObject()->method(bs->index()); QByteArray sig = method.signature(); @@ -203,6 +227,9 @@ static bool makeItem(QObject *obj, QmlDebuggerItem *item) } else { item->setExpanded(true); } + + if(!context) + item->setForeground(0, Qt::lightGray); } item->setText(0, text); diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 7dcab6f..be5226e 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -74,10 +74,7 @@ QT_BEGIN_NAMESPACE -DEFINE_BOOL_CONFIG_OPTION(bindValueDebug, QML_BINDVALUE_DEBUG); -#ifdef QT_SCRIPTTOOLS_LIB -DEFINE_BOOL_CONFIG_OPTION(debuggerEnabled, QML_DEBUGGER); -#endif +DEFINE_BOOL_CONFIG_OPTION(qmlDebugger, QML_DEBUGGER); Q_DECLARE_METATYPE(QmlMetaProperty); @@ -171,7 +168,7 @@ void QmlEnginePrivate::init() objectClass = new QmlObjectScriptClass(q); rootContext = new QmlContext(q); #ifdef QT_SCRIPTTOOLS_LIB - if (debuggerEnabled()){ + if (qmlDebugger()){ debugger = new QScriptEngineDebugger(q); debugger->attachTo(&scriptEngine); } @@ -723,17 +720,17 @@ QmlEngine *QmlEngine::activeEngine() QmlExpressionPrivate::QmlExpressionPrivate(QmlExpression *b) -: q(b), ctxt(0), sseData(0), proxy(0), me(0), trackChange(false) +: q(b), ctxt(0), sseData(0), proxy(0), me(0), trackChange(false), log(0) { } QmlExpressionPrivate::QmlExpressionPrivate(QmlExpression *b, void *expr, QmlRefCount *rc) -: q(b), ctxt(0), sse((const char *)expr, rc), sseData(0), proxy(0), me(0), trackChange(true) +: q(b), ctxt(0), sse((const char *)expr, rc), sseData(0), proxy(0), me(0), trackChange(true), log(0) { } QmlExpressionPrivate::QmlExpressionPrivate(QmlExpression *b, const QString &expr, bool ssecompile) -: q(b), ctxt(0), expression(expr), sseData(0), proxy(0), me(0), trackChange(true) +: q(b), ctxt(0), expression(expr), sseData(0), proxy(0), me(0), trackChange(true), log(0) { if (ssecompile) { #ifdef Q_ENABLE_PERFORMANCE_LOG @@ -748,6 +745,7 @@ QmlExpressionPrivate::~QmlExpressionPrivate() sse.deleteScriptState(sseData); sseData = 0; delete proxy; + delete log; } /*! @@ -884,8 +882,6 @@ void BindExpressionProxy::changed() */ QVariant QmlExpression::value() { - if (bindValueDebug()) - qWarning() << "QmlEngine: Evaluating:" << expression(); QVariant rv; if (!d->ctxt || (!d->sse.isValid() && d->expression.isEmpty())) return rv; @@ -990,34 +986,51 @@ QVariant QmlExpression::value() if (changedIndex == -1) changedIndex = BindExpressionProxy::staticMetaObject.indexOfSlot("changed()"); - if (bindValueDebug()) - qWarning() << " Depends on:"; - - for (int ii = 0; ii < ep->capturedProperties.count(); ++ii) { - const QmlMetaProperty &prop = - ep->capturedProperties.at(ii); - - if (prop.hasChangedNotifier()) { - prop.connectNotifier(d->proxy, changedIndex); - if (bindValueDebug()) - qWarning() << " property" - << prop.name() - << prop.object() - << prop.object()->metaObject()->superClass()->className(); - } else if (bindValueDebug()) { - qWarning() << " non-subscribable property" - << prop.name() - << prop.object() - << prop.object()->metaObject()->superClass()->className(); + if(qmlDebugger()) { + QmlExpressionLog log; + log.setExpression(expression()); + log.setResult(rv); + + for (int ii = 0; ii < ep->capturedProperties.count(); ++ii) { + const QmlMetaProperty &prop = + ep->capturedProperties.at(ii); + + if (prop.hasChangedNotifier()) { + prop.connectNotifier(d->proxy, changedIndex); + } else { + QString warn = QLatin1String("Expression depends on property without a NOTIFY signal: ") + QLatin1String(prop.object()->metaObject()->className()) + QLatin1String(".") + prop.name(); + log.addWarning(warn); + } + } + d->addLog(log); + + } else { + for (int ii = 0; ii < ep->capturedProperties.count(); ++ii) { + const QmlMetaProperty &prop = + ep->capturedProperties.at(ii); + + if (prop.hasChangedNotifier()) + prop.connectNotifier(d->proxy, changedIndex); } } + } else { + QmlExpressionLog log; + log.setExpression(expression()); + log.setResult(rv); + d->addLog(log); + } + + } else { + if(qmlDebugger()) { + QmlExpressionLog log; + log.setExpression(expression()); + log.setResult(rv); + d->addLog(log); } } + ep->capturedProperties.clear(); - if (bindValueDebug()) - qWarning() << " Result:" << rv - << "(SSE: " << d->sse.isValid() << ")"; return rv; } @@ -1396,4 +1409,65 @@ void QmlObjectScriptClass::setProperty(QScriptValue &object, scriptEngine->currentContext()->setActivationObject(oldact); } +void QmlExpressionPrivate::addLog(const QmlExpressionLog &l) +{ + if (!log) + log = new QList(); + log->append(l); +} + +QmlExpressionLog::QmlExpressionLog() +{ +} + +QmlExpressionLog::QmlExpressionLog(const QmlExpressionLog &o) +: m_expression(o.m_expression), + m_result(o.m_result), + m_warnings(o.m_warnings) +{ +} + +QmlExpressionLog::~QmlExpressionLog() +{ +} + +QmlExpressionLog &QmlExpressionLog::operator=(const QmlExpressionLog &o) +{ + m_expression = o.m_expression; + m_result = o.m_result; + m_warnings = o.m_warnings; + return *this; +} + + +QString QmlExpressionLog::expression() const +{ + return m_expression; +} + +void QmlExpressionLog::setExpression(const QString &e) +{ + m_expression = e; +} + +QStringList QmlExpressionLog::warnings() const +{ + return m_warnings; +} + +void QmlExpressionLog::addWarning(const QString &w) +{ + m_warnings << w; +} + +QVariant QmlExpressionLog::result() const +{ + return m_result; +} + +void QmlExpressionLog::setResult(const QVariant &r) +{ + m_result = r; +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index b72c680..7d5176e 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -192,6 +192,30 @@ public: const QScriptValue &value); }; +class QmlExpressionLog +{ +public: + QmlExpressionLog(); + QmlExpressionLog(const QmlExpressionLog &); + ~QmlExpressionLog(); + + QmlExpressionLog &operator=(const QmlExpressionLog &); + + QString expression() const; + void setExpression(const QString &); + + QStringList warnings() const; + void addWarning(const QString &); + + QVariant result() const; + void setResult(const QVariant &); + +private: + QString m_expression; + QVariant m_result; + QStringList m_warnings; +}; + class QmlExpressionPrivate { public: @@ -208,6 +232,9 @@ public: BindExpressionProxy *proxy; QObject *me; bool trackChange; + + void addLog(const QmlExpressionLog &); + QList *log; }; QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlexpression.h b/src/declarative/qml/qmlexpression.h index 4f9502b..0ab5d9c 100644 --- a/src/declarative/qml/qmlexpression.h +++ b/src/declarative/qml/qmlexpression.h @@ -85,6 +85,7 @@ protected: private: friend class BindExpressionProxy; + friend class QmlDebugger; QmlExpressionPrivate *d; }; -- cgit v0.12 From acd5ac35f26b075c48bc04a2db8064fe8bd4be90 Mon Sep 17 00:00:00 2001 From: kh Date: Wed, 6 May 2009 13:11:08 +0200 Subject: Fixes broken last tab page handling in case the search was hidden. --- tools/assistant/tools/assistant/centralwidget.cpp | 46 ++++++++++++++++------- tools/assistant/tools/assistant/centralwidget.h | 2 +- tools/assistant/tools/assistant/mainwindow.cpp | 8 +++- tools/assistant/tools/assistant/mainwindow.h | 1 + 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 4390a10..ec54d0c 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -262,8 +262,9 @@ CentralWidget::~CentralWidget() QString zoomCount; QString currentPages; QLatin1Char separator('|'); - int i = m_searchWidget->isAttached() ? 1 : 0; + bool searchAttached = m_searchWidget->isAttached(); + int i = searchAttached ? 1 : 0; for (; i < tabWidget->count(); ++i) { HelpViewer *viewer = qobject_cast(tabWidget->widget(i)); if (viewer && viewer->source().isValid()) { @@ -274,6 +275,7 @@ CentralWidget::~CentralWidget() engine.setCustomValue(QLatin1String("LastTabPage"), lastTabPage); engine.setCustomValue(QLatin1String("LastShownPages"), currentPages); + engine.setCustomValue(QLatin1String("SearchWasAttached"), searchAttached); #if !defined(QT_NO_WEBKIT) engine.setCustomValue(QLatin1String("LastPagesZoomWebView"), zoomCount); #else @@ -418,7 +420,18 @@ void CentralWidget::setLastShownPages() setSourceInNewTab((*it), (*zIt).toFloat()); const QLatin1String lastTab("LastTabPage"); - tabWidget->setCurrentIndex(helpEngine->customValue(lastTab, 1).toInt()); + int tab = helpEngine->customValue(lastTab, 1).toInt(); + + const QLatin1String searchKey("SearchWasAttached"); + const bool searchIsAttached = m_searchWidget->isAttached(); + const bool searchWasAttached = helpEngine->customValue(searchKey).toBool(); + + if (searchWasAttached && !searchIsAttached) + tabWidget->setCurrentIndex(--tab); + else if (!searchWasAttached && searchIsAttached) + tabWidget->setCurrentIndex(++tab); + else + tabWidget->setCurrentIndex(tab); } bool CentralWidget::hasSelection() const @@ -978,22 +991,29 @@ void CentralWidget::updateBrowserFont() void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine) { - if (!m_searchWidget) { - m_searchWidget = new SearchWidget(searchEngine, this); - connect(m_searchWidget, SIGNAL(requestShowLink(QUrl)), this, - SLOT(setSourceFromSearch(QUrl))); - connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)), this, - SLOT(setSourceFromSearchInNewTab(QUrl))); - } - tabWidget->insertTab(0, m_searchWidget, tr("Search")); - m_searchWidget->setAttached(true); + if (m_searchWidget) + return; + + m_searchWidget = new SearchWidget(searchEngine, this); + connect(m_searchWidget, SIGNAL(requestShowLink(QUrl)), this, + SLOT(setSourceFromSearch(QUrl))); + connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)), this, + SLOT(setSourceFromSearchInNewTab(QUrl))); } -void CentralWidget::activateSearchWidget() +void CentralWidget::activateSearchWidget(bool updateLastTabPage) { - if (!m_searchWidget->isAttached()) + if (!m_searchWidget) createSearchWidget(helpEngine->searchEngine()); + if (!m_searchWidget->isAttached()) { + tabWidget->insertTab(0, m_searchWidget, tr("Search")); + m_searchWidget->setAttached(true); + + if (updateLastTabPage) + lastTabPage++; + } + tabWidget->setCurrentWidget(m_searchWidget); m_searchWidget->setFocus(); } diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index 2c28091..e3ce200 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -118,7 +118,7 @@ public: void activateTab(bool onlyHelpViewer = false); void createSearchWidget(QHelpSearchEngine *searchEngine); - void activateSearchWidget(); + void activateSearchWidget(bool updateLastTabPage = false); void removeSearchWidget(); int availableHelpViewer() const; diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 426a828..52cbf45 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -126,6 +126,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished())); m_centralWidget->createSearchWidget(searchEngine); + m_centralWidget->activateSearchWidget(); QString defWindowTitle = tr("Qt Assistant"); setWindowTitle(defWindowTitle); @@ -461,7 +462,7 @@ void MainWindow::setupActions() QKeySequence(tr("ALT+I"))); m_viewMenu->addAction(tr("Bookmarks"), this, SLOT(showBookmarks()), QKeySequence(tr("ALT+O"))); - m_viewMenu->addAction(tr("Search"), this, SLOT(showSearch()), + m_viewMenu->addAction(tr("Search"), this, SLOT(showSearchWidget()), QKeySequence(tr("ALT+S"))); menu = menuBar()->addMenu(tr("&Go")); @@ -880,6 +881,11 @@ void MainWindow::showSearch() m_centralWidget->activateSearchWidget(); } +void MainWindow::showSearchWidget() +{ + m_centralWidget->activateSearchWidget(true); +} + void MainWindow::hideSearch() { m_centralWidget->removeSearchWidget(); diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h index 7d08a74..d7f5c69 100644 --- a/tools/assistant/tools/assistant/mainwindow.h +++ b/tools/assistant/tools/assistant/mainwindow.h @@ -92,6 +92,7 @@ public slots: void showIndex(); void showBookmarks(); void showSearch(); + void showSearchWidget(); void syncContents(); void activateCurrentCentralWidgetTab(); -- cgit v0.12 From 4258eb4c448f2e68fe5cd428f90e1af0c9268a00 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Wed, 6 May 2009 13:10:30 +0200 Subject: fixed a typo in QPrintDialog documentation --- src/gui/dialogs/qabstractprintdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/dialogs/qabstractprintdialog.cpp b/src/gui/dialogs/qabstractprintdialog.cpp index 0dc16c9..5ed8852 100644 --- a/src/gui/dialogs/qabstractprintdialog.cpp +++ b/src/gui/dialogs/qabstractprintdialog.cpp @@ -400,7 +400,7 @@ void QAbstractPrintDialogPrivate::setPrinter(QPrinter *newPrinter) QAbstractPrintDialog::setEnabledOptions() and QAbstractPrintDialog::addEnabledOption() have no effect. - In Qt 4.4, it was possible to use the satic functions to show a sheet on + In Qt 4.4, it was possible to use the static functions to show a sheet on Mac OS X. This is no longer supported in Qt 4.5. If you want this functionality, use QPrintDialog::open(). -- cgit v0.12 From 3dcbd944d90f6e2db9ab74078ccc4f6caf38a2bd Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Wed, 6 May 2009 13:30:42 +0200 Subject: Doc: Added links to Text Object Example in QTextDocument and QTextObject Task-number: 244858 --- src/gui/text/qtextdocument.cpp | 2 +- src/gui/text/qtextobject.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index e84b324..873f846 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -287,7 +287,7 @@ QTextCodec *Qt::codecForHtml(const QByteArray &ba) that inform connected editor widgets about the state of the undo/redo system. - \sa QTextCursor QTextEdit \link richtext.html Rich Text Processing\endlink + \sa QTextCursor, QTextEdit, \link richtext.html Rich Text Processing\endlink , {Text Object Example} */ /*! diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp index 3f4c8e5..71b68e0 100644 --- a/src/gui/text/qtextobject.cpp +++ b/src/gui/text/qtextobject.cpp @@ -76,7 +76,7 @@ QT_BEGIN_NAMESPACE objects, you will also need to reimplement QTextDocument::createObject() which acts as a factory method for creating text objects. - \sa QTextDocument + \sa QTextDocument, {Text Object Example} */ /*! -- cgit v0.12 From 8ca999b4e3bbb4c547a4e45095eb8fd14c6a62f1 Mon Sep 17 00:00:00 2001 From: kh Date: Wed, 6 May 2009 13:34:12 +0200 Subject: Put the Dochwidget tabs on top as this was often requested. --- tools/assistant/tools/assistant/mainwindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 52cbf45..b0c2c6b 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -235,6 +235,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) else checkInitState(); } + setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North); } MainWindow::~MainWindow() -- cgit v0.12 From a2a8773f8c226f79727b39d42c7796fc91c4d60e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 23 Feb 2009 15:29:26 +0100 Subject: test for queueing up pending connections --- tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index deabda6..785eab0 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -101,6 +101,8 @@ private slots: void recycleServer(); + void multiConnect(); + void debug(); }; @@ -842,6 +844,31 @@ void tst_QLocalSocket::recycleServer() QVERIFY(server.nextPendingConnection() != 0); } +void tst_QLocalSocket::multiConnect() +{ + QLocalServer server; + QLocalSocket client1; + QLocalSocket client2; + QLocalSocket client3; + + QVERIFY(server.listen("multiconnect")); + + client1.connectToServer("multiconnect"); + client2.connectToServer("multiconnect"); + client3.connectToServer("multiconnect"); + + QVERIFY(client1.waitForConnected(201)); + QVERIFY(client2.waitForConnected(202)); + QVERIFY(client3.waitForConnected(203)); + + QVERIFY(server.waitForNewConnection(201)); + QVERIFY(server.nextPendingConnection() != 0); + QVERIFY(server.waitForNewConnection(202)); + QVERIFY(server.nextPendingConnection() != 0); + QVERIFY(server.waitForNewConnection(203)); + QVERIFY(server.nextPendingConnection() != 0); +} + void tst_QLocalSocket::debug() { // Make sure this compiles -- cgit v0.12 From 3e89f8d598a677f004cb273dd2c3cc03d68f32eb Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 24 Apr 2009 10:07:00 +0200 Subject: rewrite QLocalServer native Windows implementation. this makes it much less arcane and buggy, specifically it resolves the internal thread-unsafety. Reviewed-by: thiago --- src/network/socket/qlocalserver.cpp | 6 +- src/network/socket/qlocalserver.h | 4 +- src/network/socket/qlocalserver_p.h | 59 ++------- src/network/socket/qlocalserver_win.cpp | 221 ++++++++++++++------------------ 4 files changed, 112 insertions(+), 178 deletions(-) diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp index d6b1507..1815d73 100644 --- a/src/network/socket/qlocalserver.cpp +++ b/src/network/socket/qlocalserver.cpp @@ -276,9 +276,11 @@ QLocalSocket *QLocalServer::nextPendingConnection() if (d->pendingConnections.isEmpty()) return 0; QLocalSocket *nextSocket = d->pendingConnections.dequeue(); + if (d->pendingConnections.size() <= d->maxPendingConnections) #ifndef Q_OS_WIN - d->socketNotifier->setEnabled(d->pendingConnections.size() - <= d->maxPendingConnections); + d->socketNotifier->setEnabled(true); +#else + d->connectionEventNotifier->setEnabled(true); #endif return nextSocket; } diff --git a/src/network/socket/qlocalserver.h b/src/network/socket/qlocalserver.h index 8e8babd..c745ccb 100644 --- a/src/network/socket/qlocalserver.h +++ b/src/network/socket/qlocalserver.h @@ -89,9 +89,7 @@ private: #if defined(QT_LOCALSOCKET_TCP) Q_PRIVATE_SLOT(d_func(), void _q_onNewConnection()) #elif defined(Q_OS_WIN) - Q_PRIVATE_SLOT(d_func(), void _q_openSocket(HANDLE handle)) - Q_PRIVATE_SLOT(d_func(), void _q_stoppedListening()) - Q_PRIVATE_SLOT(d_func(), void _q_setError(QAbstractSocket::SocketError error, const QString &errorString)) + Q_PRIVATE_SLOT(d_func(), void _q_onNewConnection()) #else Q_PRIVATE_SLOT(d_func(), void _q_socketActivated()) #endif diff --git a/src/network/socket/qlocalserver_p.h b/src/network/socket/qlocalserver_p.h index 8e96401..9af4a20 100644 --- a/src/network/socket/qlocalserver_p.h +++ b/src/network/socket/qlocalserver_p.h @@ -63,7 +63,7 @@ # include #elif defined(Q_OS_WIN) # include -# include +# include #else # include # include @@ -71,52 +71,13 @@ QT_BEGIN_NAMESPACE -#if defined(Q_OS_WIN) && !defined(QT_LOCALSOCKET_TCP) - -/*! - \internal - QLocalServerThread exists because Windows does not have a - way to provide notifications when there is a new connections to - the server. - */ -class QLocalServerThread : public QThread -{ - Q_OBJECT - -Q_SIGNALS: - void connected(HANDLE newSocket); - void error(QAbstractSocket::SocketError error, const QString &errorString); - -public: - QLocalServerThread(QObject *parent = 0); - ~QLocalServerThread(); - void closeServer(); - -public: - QString setName(const QString &name); - void run(); - void stop(); - bool makeHandle(); - - HANDLE gotConnectionEvent; - QQueue pendingHandles; - int maxPendingConnections; -private: - HANDLE stopEvent; - QString fullServerName; -}; - -#endif - class QLocalServerPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QLocalServer) public: QLocalServerPrivate() : -#if defined(Q_OS_WIN) && !defined(QT_LOCALSOCKET_TCP) - inWaitingFunction(false), -#elif !defined(QT_LOCALSOCKET_TCP) +#if !defined(QT_LOCALSOCKET_TCP) && !defined(Q_OS_WIN) listenSocket(-1), socketNotifier(0), #endif maxPendingConnections(30), error(QAbstractSocket::UnknownSocketError) @@ -135,12 +96,18 @@ public: QTcpServer tcpServer; QMap socketMap; #elif defined(Q_OS_WIN) - void _q_openSocket(HANDLE socket); - void _q_stoppedListening(); - void _q_setError(QAbstractSocket::SocketError error, const QString &errorString); + struct Listener { + HANDLE handle; + OVERLAPPED overlapped; + }; + + void setError(const QString &function); + bool addListener(); + void _q_onNewConnection(); - QLocalServerThread waitForConnection; - bool inWaitingFunction; + QList listeners; + HANDLE eventHandle; + QWinEventNotifier *connectionEventNotifier; #else void setError(const QString &function); void _q_socketActivated(); diff --git a/src/network/socket/qlocalserver_win.cpp b/src/network/socket/qlocalserver_win.cpp index 880cd7e..b14bbf7 100644 --- a/src/network/socket/qlocalserver_win.cpp +++ b/src/network/socket/qlocalserver_win.cpp @@ -44,68 +44,26 @@ #include "qlocalsocket.h" #include -#include -#include -#include // The buffer size need to be 0 otherwise data could be // lost if the socket that has written data closes the connection // before it is read. Pipewriter is used for write buffering. #define BUFSIZE 0 -QT_BEGIN_NAMESPACE - -QLocalServerThread::QLocalServerThread(QObject *parent) : QThread(parent), - maxPendingConnections(1) -{ - stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - gotConnectionEvent = CreateEvent(NULL, TRUE, FALSE, NULL); -} +// ###: This should be a property. Should replace the insane 50 on unix as well. +#define SYSTEM_MAX_PENDING_SOCKETS 8 -QLocalServerThread::~QLocalServerThread() -{ - stop(); - closeServer(); - CloseHandle(stopEvent); - CloseHandle(gotConnectionEvent); -} - -void QLocalServerThread::stop() -{ - if (isRunning()) { - SetEvent(stopEvent); - wait(); - ResetEvent(stopEvent); - } -} - -void QLocalServerThread::closeServer() -{ - while (!pendingHandles.isEmpty()) - CloseHandle(pendingHandles.dequeue()); -} - -QString QLocalServerThread::setName(const QString &name) -{ - QString pipePath = QLatin1String("\\\\.\\pipe\\"); - if (name.startsWith(pipePath)) - fullServerName = name; - else - fullServerName = pipePath + name; - for (int i = pendingHandles.count(); i < maxPendingConnections; ++i) - if (!makeHandle()) - break; - return fullServerName; -} +QT_BEGIN_NAMESPACE -bool QLocalServerThread::makeHandle() +bool QLocalServerPrivate::addListener() { - if (pendingHandles.count() >= maxPendingConnections) - return false; + // The object must not change its address once the + // contained OVERLAPPED struct is passed to Windows. + listeners << Listener(); + Listener &listener = listeners.last(); - HANDLE handle = INVALID_HANDLE_VALUE; QT_WA({ - handle = CreateNamedPipeW( + listener.handle = CreateNamedPipeW( (TCHAR*)fullServerName.utf16(), // pipe name PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, // read/write access PIPE_TYPE_MESSAGE | // message type pipe @@ -117,7 +75,7 @@ bool QLocalServerThread::makeHandle() 3000, // client time-out NULL); }, { - handle = CreateNamedPipeA( + listener.handle = CreateNamedPipeA( fullServerName.toLocal8Bit().constData(), // pipe name PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, // read/write access PIPE_TYPE_MESSAGE | // message type pipe @@ -129,68 +87,43 @@ bool QLocalServerThread::makeHandle() 3000, // client time-out NULL); }); - - if (INVALID_HANDLE_VALUE == handle) { + if (listener.handle == INVALID_HANDLE_VALUE) { + setError(QLatin1String("QLocalServerPrivate::addListener")); + listeners.removeLast(); return false; } - pendingHandles.enqueue(handle); + + memset(&listener.overlapped, 0, sizeof(listener.overlapped)); + listener.overlapped.hEvent = eventHandle; + if (!ConnectNamedPipe(listener.handle, &listener.overlapped)) { + switch (GetLastError()) { + case ERROR_IO_PENDING: + break; + case ERROR_PIPE_CONNECTED: + SetEvent(eventHandle); + break; + default: + CloseHandle(listener.handle); + setError(QLatin1String("QLocalServerPrivate::addListener")); + listeners.removeLast(); + return false; + } + } else { + Q_ASSERT_X(false, "QLocalServerPrivate::addListener", "The impossible happened"); + SetEvent(eventHandle); + } return true; } -void QLocalServerThread::run() +void QLocalServerPrivate::setError(const QString &function) { - OVERLAPPED op; - HANDLE handleArray[2]; - memset(&op, 0, sizeof(op)); - handleArray[0] = op.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - handleArray[1] = stopEvent; - HANDLE handle = INVALID_HANDLE_VALUE; - - forever { - if (INVALID_HANDLE_VALUE == handle) { - makeHandle(); - if (!pendingHandles.isEmpty()) - handle = pendingHandles.dequeue(); - } - if (INVALID_HANDLE_VALUE == handle) { - int windowsError = GetLastError(); - QString function = QLatin1String("QLocalServer::run"); - QString errorString = QLocalServer::tr("%1: Unknown error %2").arg(function).arg(windowsError); - emit error(QAbstractSocket::UnknownSocketError, errorString); - CloseHandle(handleArray[0]); - SetEvent(gotConnectionEvent); - return; - } - - BOOL isConnected = ConnectNamedPipe(handle, &op) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED); - if (!isConnected) { - switch (WaitForMultipleObjects(2, handleArray, FALSE, INFINITE)) - { - case WAIT_OBJECT_0 + 1: - CloseHandle(handle); - CloseHandle(handleArray[0]); - return; - } - } - emit connected(handle); - handle = INVALID_HANDLE_VALUE; - ResetEvent(handleArray[0]); - SetEvent(gotConnectionEvent); - } + int windowsError = GetLastError(); + errorString = QString::fromLatin1("%1: %2").arg(function).arg(qt_error_string(windowsError)); + error = QAbstractSocket::UnknownSocketError; } void QLocalServerPrivate::init() { - Q_Q(QLocalServer); - qRegisterMetaType("HANDLE"); - q->connect(&waitForConnection, SIGNAL(connected(HANDLE)), - q, SLOT(_q_openSocket(HANDLE)), Qt::QueuedConnection); - q->connect(&waitForConnection, SIGNAL(finished()), - q, SLOT(_q_stoppedListening()), Qt::QueuedConnection); - q->connect(&waitForConnection, SIGNAL(terminated()), - q, SLOT(_q_stoppedListening()), Qt::QueuedConnection); - q->connect(&waitForConnection, SIGNAL(error(QAbstractSocket::SocketError, const QString &)), - q, SLOT(_q_setError(QAbstractSocket::SocketError, const QString &))); } bool QLocalServerPrivate::removeServer(const QString &name) @@ -201,35 +134,71 @@ bool QLocalServerPrivate::removeServer(const QString &name) bool QLocalServerPrivate::listen(const QString &name) { - fullServerName = waitForConnection.setName(name); - serverName = name; - waitForConnection.start(); - return true; -} + Q_Q(QLocalServer); -void QLocalServerPrivate::_q_setError(QAbstractSocket::SocketError e, const QString &eString) -{ - error = e; - errorString = eString; -} + QString pipePath = QLatin1String("\\\\.\\pipe\\"); + if (name.startsWith(pipePath)) + fullServerName = name; + else + fullServerName = pipePath + name; -void QLocalServerPrivate::_q_stoppedListening() -{ - Q_Q(QLocalServer); - if (!inWaitingFunction) - q->close(); + // Use only one event for all listeners of one socket. + // The idea is that listener events are rare, so polling all listeners once in a while is + // cheap compared to waiting for N additional events in each iteration of the main loop. + eventHandle = CreateEvent(NULL, TRUE, FALSE, NULL); + connectionEventNotifier = new QWinEventNotifier(eventHandle , q); + q->connect(connectionEventNotifier, SIGNAL(activated(HANDLE)), q, SLOT(_q_onNewConnection())); + + for (int i = 0; i < SYSTEM_MAX_PENDING_SOCKETS; ++i) + if (!addListener()) + return false; + return true; } -void QLocalServerPrivate::_q_openSocket(HANDLE handle) +void QLocalServerPrivate::_q_onNewConnection() { Q_Q(QLocalServer); - q->incomingConnection((int)handle); + DWORD dummy; + + // Reset first, otherwise we could reset an event which was asserted + // immediately after we checked the conn status. + ResetEvent(eventHandle); + + // Testing shows that there is indeed absolutely no guarantee which listener gets + // a client connection first, so there is no way around polling all of them. + for (int i = 0; i < listeners.size(); ) { + HANDLE handle = listeners[i].handle; + if (GetOverlappedResult(handle, &listeners[i].overlapped, &dummy, FALSE)) { + listeners.removeAt(i); + + addListener(); + + if (pendingConnections.size() > maxPendingConnections) + connectionEventNotifier->setEnabled(false); + + // Make this the last thing so connected slots can wreak the least havoc + q->incomingConnection((quintptr)handle); + } else { + if (GetLastError() != ERROR_IO_INCOMPLETE) { + setError(QLatin1String("QLocalServerPrivate::_q_onNewConnection")); + closeServer(); + return; + } + + ++i; + } + } } void QLocalServerPrivate::closeServer() { - waitForConnection.stop(); - waitForConnection.closeServer(); + connectionEventNotifier->setEnabled(false); // Otherwise, closed handle is checked before deleter runs + connectionEventNotifier->deleteLater(); + connectionEventNotifier = 0; + CloseHandle(eventHandle); + for (int i = 0; i < listeners.size(); ++i) + CloseHandle(listeners[i].handle); + listeners.clear(); } void QLocalServerPrivate::waitForNewConnection(int msecs, bool *timedOut) @@ -238,14 +207,12 @@ void QLocalServerPrivate::waitForNewConnection(int msecs, bool *timedOut) if (!pendingConnections.isEmpty() || !q->isListening()) return; - DWORD result = WaitForSingleObject(waitForConnection.gotConnectionEvent, - (msecs == -1) ? INFINITE : msecs); + DWORD result = WaitForSingleObject(eventHandle, (msecs == -1) ? INFINITE : msecs); if (result == WAIT_TIMEOUT) { if (timedOut) *timedOut = true; } else { - ResetEvent(waitForConnection.gotConnectionEvent); - QCoreApplication::instance()->processEvents(); + _q_onNewConnection(); } } -- cgit v0.12 From e13aab33bc1aa68bcf5a18e2d77b2db7f9f44e1e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 6 May 2009 12:51:46 +0200 Subject: standardize on one name for the socket connection slot --- src/network/socket/qlocalserver.h | 6 ------ src/network/socket/qlocalserver_p.h | 4 +--- src/network/socket/qlocalserver_unix.cpp | 6 +++--- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/network/socket/qlocalserver.h b/src/network/socket/qlocalserver.h index c745ccb..1488a75 100644 --- a/src/network/socket/qlocalserver.h +++ b/src/network/socket/qlocalserver.h @@ -86,13 +86,7 @@ protected: private: Q_DISABLE_COPY(QLocalServer) -#if defined(QT_LOCALSOCKET_TCP) Q_PRIVATE_SLOT(d_func(), void _q_onNewConnection()) -#elif defined(Q_OS_WIN) - Q_PRIVATE_SLOT(d_func(), void _q_onNewConnection()) -#else - Q_PRIVATE_SLOT(d_func(), void _q_socketActivated()) -#endif }; #endif // QT_NO_LOCALSERVER diff --git a/src/network/socket/qlocalserver_p.h b/src/network/socket/qlocalserver_p.h index 9af4a20..7b31082 100644 --- a/src/network/socket/qlocalserver_p.h +++ b/src/network/socket/qlocalserver_p.h @@ -89,9 +89,9 @@ public: static bool removeServer(const QString &name); void closeServer(); void waitForNewConnection(int msec, bool *timedOut); + void _q_onNewConnection(); #if defined(QT_LOCALSOCKET_TCP) - void _q_onNewConnection(); QTcpServer tcpServer; QMap socketMap; @@ -103,14 +103,12 @@ public: void setError(const QString &function); bool addListener(); - void _q_onNewConnection(); QList listeners; HANDLE eventHandle; QWinEventNotifier *connectionEventNotifier; #else void setError(const QString &function); - void _q_socketActivated(); int listenSocket; QSocketNotifier *socketNotifier; diff --git a/src/network/socket/qlocalserver_unix.cpp b/src/network/socket/qlocalserver_unix.cpp index e7d2252..53ee6b6 100644 --- a/src/network/socket/qlocalserver_unix.cpp +++ b/src/network/socket/qlocalserver_unix.cpp @@ -132,7 +132,7 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName) socketNotifier = new QSocketNotifier(listenSocket, QSocketNotifier::Read, q); q->connect(socketNotifier, SIGNAL(activated(int)), - q, SLOT(_q_socketActivated())); + q, SLOT(_q_onNewConnection())); socketNotifier->setEnabled(maxPendingConnections > 0); return true; } @@ -164,7 +164,7 @@ void QLocalServerPrivate::closeServer() We have received a notification that we can read on the listen socket. Accept the new socket. */ -void QLocalServerPrivate::_q_socketActivated() +void QLocalServerPrivate::_q_onNewConnection() { Q_Q(QLocalServer); if (-1 == listenSocket) @@ -209,7 +209,7 @@ void QLocalServerPrivate::waitForNewConnection(int msec, bool *timedOut) break; } if (result > 0) - _q_socketActivated(); + _q_onNewConnection(); } if (timedOut) *timedOut = (result == 0); -- cgit v0.12 From 8cd19116ae81c99fe28fbf91aa7f4c1c08163fe0 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 6 May 2009 13:54:57 +0200 Subject: QTreeView could be not correctly updated when the 1st column is hidden. The problem was that we were not always storing the modelindex in column 0 for each QTreeViewItem. That was causing inconsistencies. Now it is always the case. It allowed to remove some calls to QModelIndex::sibling. Task-number: 239271 Reviewed-by: ogoffart --- src/gui/itemviews/qtreeview.cpp | 38 ++++++++++---------------------- tests/auto/qtreeview/tst_qtreeview.cpp | 40 ++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 26 deletions(-) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 61f1b5b..ab03fea 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -680,10 +680,9 @@ void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto // refresh the height cache here; we don't really lose anything by getting the size hint, // since QAbstractItemView::dataChanged() will get the visualRect for the items anyway - QModelIndex top = topLeft.sibling(topLeft.row(), 0); - int topViewIndex = d->viewIndex(top); + int topViewIndex = d->viewIndex(topLeft); if (topViewIndex == 0) - d->defaultItemHeight = indexRowSizeHint(top); + d->defaultItemHeight = indexRowSizeHint(topLeft); bool sizeChanged = false; if (topViewIndex != -1) { if (topLeft == bottomRight) { @@ -691,8 +690,7 @@ void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto d->invalidateHeightCache(topViewIndex); sizeChanged = (oldHeight != d->itemHeight(topViewIndex)); } else { - QModelIndex bottom = bottomRight.sibling(bottomRight.row(), 0); - int bottomViewIndex = d->viewIndex(bottom); + int bottomViewIndex = d->viewIndex(bottomRight); for (int i = topViewIndex; i <= bottomViewIndex; ++i) { int oldHeight = d->itemHeight(i); d->invalidateHeightCache(i); @@ -1815,10 +1813,10 @@ void QTreeView::mouseDoubleClickEvent(QMouseEvent *event) if (i == -1) return; // user clicked outside the items - const QModelIndex &index = d->viewItems.at(i).index; + const QPersistentModelIndex firstColumnIndex = d->viewItems.at(i).index; int column = d->header->logicalIndexAt(event->x()); - QPersistentModelIndex persistent = index.sibling(index.row(), column); + QPersistentModelIndex persistent = firstColumnIndex.sibling(firstColumnIndex.row(), column); if (d->pressedIndex != persistent) { mousePressEvent(event); @@ -1841,10 +1839,10 @@ void QTreeView::mouseDoubleClickEvent(QMouseEvent *event) if (d->itemsExpandable && d->expandsOnDoubleClick && d->hasVisibleChildren(persistent)) { - if (!((i < d->viewItems.count()) && (d->viewItems.at(i).index == persistent))) { + if (!((i < d->viewItems.count()) && (d->viewItems.at(i).index == firstColumnIndex))) { // find the new index of the item for (i = 0; i < d->viewItems.count(); ++i) { - if (d->viewItems.at(i).index == persistent) + if (d->viewItems.at(i).index == firstColumnIndex) break; } if (i == d->viewItems.count()) @@ -2422,14 +2420,10 @@ void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end) ? d->viewItems.count() : d->viewItems.at(parentItem).total) - 1; - int firstColumn = 0; - while (isColumnHidden(firstColumn) && firstColumn < header()->count() - 1) - ++firstColumn; - const int delta = end - start + 1; QVector insertedItems(delta); for (int i = 0; i < delta; ++i) { - insertedItems[i].index = d->model->index(i + start, firstColumn, parent); + insertedItems[i].index = d->model->index(i + start, 0, parent); insertedItems[i].level = childLevel; } if (d->viewItems.isEmpty()) @@ -2612,7 +2606,7 @@ void QTreeView::expandAll() d->viewItems[i].expanded = true; d->layout(i); QModelIndex idx = d->viewItems.at(i).index; - d->expandedIndexes.insert(idx.sibling(idx.row(), 0)); + d->expandedIndexes.insert(idx); } updateGeometries(); d->viewport->update(); @@ -3130,13 +3124,9 @@ void QTreeViewPrivate::layout(int i) int last = 0; int children = 0; - int firstColumn = 0; - while (header->isSectionHidden(firstColumn) && firstColumn < header->count()) - ++firstColumn; - for (int j = first; j < first + count; ++j) { - current = model->index(j - first, firstColumn, parent); - if (isRowHidden(current.sibling(current.row(), 0))) { + current = model->index(j - first, 0, parent); + if (isRowHidden(current)) { ++hidden; last = j - hidden + children; } else { @@ -3319,15 +3309,11 @@ int QTreeViewPrivate::itemAtCoordinate(int coordinate) const int QTreeViewPrivate::viewIndex(const QModelIndex &_index) const { - Q_Q(const QTreeView); if (!_index.isValid() || viewItems.isEmpty()) return -1; const int totalCount = viewItems.count(); - int firstColumn = 0; - while (q->isColumnHidden(firstColumn) && firstColumn < header->count()) - ++firstColumn; - const QModelIndex index = _index.sibling(_index.row(), firstColumn); + const QModelIndex index = _index.sibling(_index.row(), 0); // A quick check near the last item to see if we are just incrementing diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index 37cb5b0..71d7b4d 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -226,6 +226,7 @@ private slots: void task244304_clickOnDecoration(); void task246536_scrollbarsNotWorking(); void task250683_wrongSectionSize(); + void task239271_addRowsWithFirstColumnHidden(); }; class QtTestModel: public QAbstractItemModel @@ -3289,6 +3290,45 @@ void tst_QTreeView::task250683_wrongSectionSize() QCOMPARE(treeView.header()->sectionSize(0) + treeView.header()->sectionSize(1), treeView.viewport()->width()); } +void tst_QTreeView::task239271_addRowsWithFirstColumnHidden() +{ + class MyDelegate : public QStyledItemDelegate + { + public: + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const + { + paintedIndexes << index; + QStyledItemDelegate::paint(painter, option, index); + } + + mutable QSet paintedIndexes; + }; + + QTreeView view; + QStandardItemModel model; + view.setModel(&model); + MyDelegate delegate; + view.setItemDelegate(&delegate); + QStandardItem root0("root0"), root1("root1"); + model.invisibleRootItem()->appendRow(QList() << &root0 << &root1); + QStandardItem sub0("sub0"), sub00("sub00"); + root0.appendRow(QList() << &sub0 << &sub00); + view.expand(root0.index()); + + view.hideColumn(0); + view.show(); + QTest::qWait(200); + delegate.paintedIndexes.clear(); + QStandardItem sub1("sub1"), sub11("sub11"); + root0.appendRow(QList() << &sub1 << &sub11); + + QTest::qWait(200); + //items in the 2nd column should have been painted + QVERIFY(delegate.paintedIndexes.contains(sub00.index())); + QVERIFY(delegate.paintedIndexes.contains(sub11.index())); +} + + QTEST_MAIN(tst_QTreeView) #include "tst_qtreeview.moc" -- cgit v0.12 From 7c1093d3e8eba6b8ab92c6503fde0c941550125d Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 6 May 2009 22:27:17 +1000 Subject: Improve parser line/column tracking --- src/declarative/qml/qmlcompiledcomponent.cpp | 74 --------------------- src/declarative/qml/qmlcompiledcomponent_p.h | 3 - src/declarative/qml/qmlcompiler.cpp | 77 +++++++++++----------- src/declarative/qml/qmldom.cpp | 2 +- src/declarative/qml/qmlinstruction_p.h | 3 + src/declarative/qml/qmlparser.cpp | 88 ++++++++++++++++++++++--- src/declarative/qml/qmlparser_p.h | 31 ++++++--- src/declarative/qml/qmlscriptparser.cpp | 98 +++++++++++++++++++--------- 8 files changed, 210 insertions(+), 166 deletions(-) diff --git a/src/declarative/qml/qmlcompiledcomponent.cpp b/src/declarative/qml/qmlcompiledcomponent.cpp index 2c76f0c..c69af44 100644 --- a/src/declarative/qml/qmlcompiledcomponent.cpp +++ b/src/declarative/qml/qmlcompiledcomponent.cpp @@ -76,80 +76,6 @@ void QmlCompiledComponent::dumpInstructions() qWarning() << "-------------------------------------------------------------------------------"; } -void QmlCompiledComponent::dump(int indent, Property *p) -{ - QByteArray ba(indent * 4, ' '); - for (int ii = 0; ii < p->values.count(); ++ii) - dump(indent, p->values.at(ii)); - if (p->value) - dump(indent, p->value); -} - -void QmlCompiledComponent::dump(int indent, Object *o) -{ - QByteArray ba(indent * 4, ' '); - if (o->type != -1) { - qWarning() << ba.constData() << "Object:" << types.at(o->type).className; - } else { - qWarning() << ba.constData() << "Object: fetched"; - } - - for (QHash::ConstIterator iter = o->properties.begin(); - iter != o->properties.end(); - ++iter) { - qWarning() << ba.constData() << " Property" << iter.key(); - dump(indent + 1, *iter); - } - - if (o->defaultProperty) { - qWarning() << ba.constData() << " Default property"; - dump(indent + 1, o->defaultProperty); - } -} - -void QmlCompiledComponent::dump(int indent, Value *v) -{ - QByteArray type; - switch(v->type) { - default: - case Value::Unknown: - type = "Unknown"; - break; - case Value::Literal: - type = "Literal"; - break; - case Value::PropertyBinding: - type = "PropertyBinding"; - break; - case Value::ValueSource: - type = "ValueSource"; - break; - case Value::CreatedObject: - type = "CreatedObject"; - break; - case Value::SignalObject: - type = "SignalObject"; - break; - case Value::SignalExpression: - type = "SignalExpression"; - break; - case Value::Component: - type = "Component"; - break; - case Value::Id: - type = "Id"; - break; - }; - - QByteArray ba(indent * 4, ' '); - if (v->object) { - qWarning() << ba.constData() << "Value (" << type << "):"; - dump(indent + 1, v->object); - } else { - qWarning() << ba.constData() << "Value (" << type << "):" << v->primitive; - } -} - void QmlCompiledComponent::dumpPre() { if (!(dumpStatus & DumpPre)) { diff --git a/src/declarative/qml/qmlcompiledcomponent_p.h b/src/declarative/qml/qmlcompiledcomponent_p.h index 883ad64..c5e1226 100644 --- a/src/declarative/qml/qmlcompiledcomponent_p.h +++ b/src/declarative/qml/qmlcompiledcomponent_p.h @@ -67,9 +67,6 @@ public: private: enum DumpStatus { NoDump = 0x00, DumpPre = 0x01, DumpPost = 0x02 } dumpStatus; void dumpInstructions(); - void dump(int indent, QmlParser::Property *p); - void dump(int indent, QmlParser::Object *o); - void dump(int indent, QmlParser::Value *v); void dump(QmlInstruction *, int idx = -1); friend class QmlCompiler; friend class QmlDomDocument; diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 9ae1278..8eb5fa1 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -434,8 +434,8 @@ void QmlCompiler::reset(QmlCompiledComponent *cc, bool deleteMemory) #define COMPILE_EXCEPTION2(token, desc) \ { \ - exceptionLine = token->line; \ - exceptionColumn = token->column; \ + exceptionLine = token->location.start.line; \ + exceptionColumn = token->location.start.column; \ QDebug d(&exceptionDescription); \ d << desc; \ return false; \ @@ -443,8 +443,8 @@ void QmlCompiler::reset(QmlCompiledComponent *cc, bool deleteMemory) #define COMPILE_EXCEPTION(desc) \ { \ - exceptionLine = obj->line; \ - exceptionColumn = obj->column; \ + exceptionLine = obj->location.start.line; \ + exceptionColumn = obj->location.start.column; \ QDebug d(&exceptionDescription); \ d << desc; \ return false; \ @@ -541,7 +541,7 @@ bool QmlCompiler::compileObject(Object *obj, int ctxt) // Create the object QmlInstruction create; create.type = QmlInstruction::CreateObject; - create.line = obj->line; + create.line = obj->location.start.line; create.create.data = -1; create.create.type = obj->type; output->bytecode << create; @@ -552,7 +552,7 @@ bool QmlCompiler::compileObject(Object *obj, int ctxt) if (output->types.at(obj->type).component) { QmlInstruction begin; begin.type = QmlInstruction::TryBeginObject; - begin.line = obj->line; + begin.line = obj->location.start.line; output->bytecode << begin; } else { int cast = QmlMetaType::qmlParserStatusCast(QmlMetaType::type(output->types.at(obj->type).className)); @@ -560,7 +560,7 @@ bool QmlCompiler::compileObject(Object *obj, int ctxt) QmlInstruction begin; begin.type = QmlInstruction::BeginObject; begin.begin.castValue = cast; - begin.line = obj->line; + begin.line = obj->location.start.line; output->bytecode << begin; } } @@ -611,7 +611,7 @@ bool QmlCompiler::compileObject(Object *obj, int ctxt) if (output->types.at(obj->type).component) { QmlInstruction complete; complete.type = QmlInstruction::TryCompleteObject; - complete.line = obj->line; + complete.line = obj->location.start.line; output->bytecode << complete; } else { int cast = QmlMetaType::qmlParserStatusCast(QmlMetaType::type(output->types.at(obj->type).className)); @@ -619,7 +619,7 @@ bool QmlCompiler::compileObject(Object *obj, int ctxt) QmlInstruction complete; complete.type = QmlInstruction::CompleteObject; complete.complete.castValue = cast; - complete.line = obj->line; + complete.line = obj->location.start.line; output->bytecode << complete; } } @@ -661,7 +661,7 @@ bool QmlCompiler::compileComponent(Object *obj, int ctxt) int pref = output->indexForString(val); QmlInstruction id; id.type = QmlInstruction::SetId; - id.line = idProp->line; + id.line = idProp->location.start.line; id.setId.value = pref; id.setId.save = -1; output->bytecode << id; @@ -675,14 +675,14 @@ bool QmlCompiler::compileComponentFromRoot(Object *obj, int ctxt) output->bytecode.push_back(QmlInstruction()); QmlInstruction &create = output->bytecode.last(); create.type = QmlInstruction::CreateComponent; - create.line = obj->line; - create.createComponent.endLine = obj->endLine; + create.line = obj->location.start.line; + create.createComponent.endLine = obj->location.end.line; int count = output->bytecode.count(); QmlInstruction init; init.type = QmlInstruction::Init; init.init.dataSize = 0; - init.line = obj->line; + init.line = obj->location.start.line; output->bytecode << init; QSet oldIds = ids; @@ -732,7 +732,7 @@ bool QmlCompiler::compileSignal(Property *prop, Object *obj) if (rv) { QmlInstruction assign; assign.type = QmlInstruction::AssignSignalObject; - assign.line = prop->values.at(0)->line; + assign.line = prop->values.at(0)->location.start.line; assign.assignSignalObject.signal = pr; output->bytecode << assign; @@ -755,7 +755,7 @@ bool QmlCompiler::compileSignal(Property *prop, Object *obj) QmlInstruction assign; assign.type = QmlInstruction::AssignSignal; - assign.line = prop->values.at(0)->line; + assign.line = prop->values.at(0)->location.start.line; assign.assignSignal.signal = pr; assign.assignSignal.value = idx; @@ -878,7 +878,7 @@ bool QmlCompiler::compileIdProperty(QmlParser::Property *prop, assign.type = QmlInstruction::StoreString; assign.storeString.propertyIndex = prop->index; assign.storeString.value = pref; - assign.line = prop->values.at(0)->line; + assign.line = prop->values.at(0)->location.start.line; output->bytecode << assign; prop->values.at(0)->type = Value::Id; @@ -888,10 +888,9 @@ bool QmlCompiler::compileIdProperty(QmlParser::Property *prop, QmlInstruction id; id.type = QmlInstruction::SetId; - id.line = prop->values.at(0)->line; + id.line = prop->values.at(0)->location.start.line; id.setId.value = pref; id.setId.save = -1; - id.line = prop->values.at(0)->line; output->bytecode << id; obj->id = val.toLatin1(); @@ -909,7 +908,7 @@ bool QmlCompiler::compileAttachedProperty(QmlParser::Property *prop, QmlInstruction fetch; fetch.type = QmlInstruction::FetchAttached; - fetch.line = prop->line; + fetch.line = prop->location.start.line; int id = QmlMetaType::attachedPropertiesFuncId(prop->name); if (id == -1) COMPILE_EXCEPTION("Non-existant attached property object" << prop->name); @@ -920,7 +919,7 @@ bool QmlCompiler::compileAttachedProperty(QmlParser::Property *prop, QmlInstruction pop; pop.type = QmlInstruction::PopFetchedObject; - pop.line = prop->line; + pop.line = prop->location.start.line; output->bytecode << pop; return true; @@ -942,14 +941,14 @@ bool QmlCompiler::compileNestedProperty(QmlParser::Property *prop, fetch.type = QmlInstruction::ResolveFetchObject; fetch.fetch.property = output->indexForByteArray(prop->name); } - fetch.line = prop->line; + fetch.line = prop->location.start.line; output->bytecode << fetch; COMPILE_CHECK(compileFetchedObject(prop->value, ctxt + 1)); QmlInstruction pop; pop.type = QmlInstruction::PopFetchedObject; - pop.line = prop->line; + pop.line = prop->location.start.line; output->bytecode << pop; return true; @@ -962,7 +961,7 @@ bool QmlCompiler::compileListProperty(QmlParser::Property *prop, int t = prop->type; if (QmlMetaType::isQmlList(t)) { QmlInstruction fetch; - fetch.line = prop->line; + fetch.line = prop->location.start.line; fetch.type = QmlInstruction::FetchQmlList; fetch.fetchQmlList.property = prop->index; fetch.fetchQmlList.type = QmlMetaType::qmlListType(t); @@ -975,7 +974,7 @@ bool QmlCompiler::compileListProperty(QmlParser::Property *prop, COMPILE_CHECK(compileObject(v->object, ctxt)); QmlInstruction assign; assign.type = QmlInstruction::AssignObjectList; - assign.line = prop->line; + assign.line = prop->location.start.line; assign.assignObject.property = output->indexForByteArray(prop->name); assign.assignObject.castValue = 0; output->bytecode << assign; @@ -986,14 +985,14 @@ bool QmlCompiler::compileListProperty(QmlParser::Property *prop, QmlInstruction pop; pop.type = QmlInstruction::PopQList; - pop.line = prop->line; + pop.line = prop->location.start.line; output->bytecode << pop; } else { Q_ASSERT(QmlMetaType::isList(t)); QmlInstruction fetch; fetch.type = QmlInstruction::FetchQList; - fetch.line = prop->line; + fetch.line = prop->location.start.line; fetch.fetch.property = prop->index; output->bytecode << fetch; @@ -1005,7 +1004,7 @@ bool QmlCompiler::compileListProperty(QmlParser::Property *prop, COMPILE_CHECK(compileObject(v->object, ctxt)); QmlInstruction assign; assign.type = QmlInstruction::AssignObjectList; - assign.line = v->line; + assign.line = v->location.start.line; assign.assignObject.property = output->indexForByteArray(prop->name); assign.assignObject.castValue = 0; output->bytecode << assign; @@ -1013,7 +1012,7 @@ bool QmlCompiler::compileListProperty(QmlParser::Property *prop, if (assignedBinding) COMPILE_EXCEPTION("Can only assign one binding to lists"); - compileBinding(v->primitive, prop, ctxt, obj->metaObject(), v->line); + compileBinding(v->primitive, prop, ctxt, obj->metaObject(), v->location.start.line); v->type = Value::PropertyBinding; } else { COMPILE_EXCEPTION("Cannot assign primitives to lists"); @@ -1021,7 +1020,7 @@ bool QmlCompiler::compileListProperty(QmlParser::Property *prop, } QmlInstruction pop; - pop.line = prop->line; + pop.line = prop->location.start.line; pop.type = QmlInstruction::PopQList; output->bytecode << pop; } @@ -1086,7 +1085,7 @@ bool QmlCompiler::compilePropertyObjectAssignment(QmlParser::Property *prop, QmlInstruction assign; assign.type = QmlInstruction::AssignObject; - assign.line = v->object->line; + assign.line = v->object->location.start.line; assign.assignObject.castValue = 0; if (prop->isDefault) assign.assignObject.property = -1; @@ -1101,7 +1100,7 @@ bool QmlCompiler::compilePropertyObjectAssignment(QmlParser::Property *prop, QmlInstruction assign; assign.type = QmlInstruction::StoreObject; - assign.line = v->object->line; + assign.line = v->object->location.start.line; assign.storeObject.propertyIndex = prop->index; // XXX - this cast may not be 0 assign.storeObject.cast = 0; @@ -1114,7 +1113,7 @@ bool QmlCompiler::compilePropertyObjectAssignment(QmlParser::Property *prop, QmlInstruction assign; assign.type = QmlInstruction::StoreObject; - assign.line = v->object->line; + assign.line = v->object->location.start.line; assign.storeObject.propertyIndex = prop->index; // XXX - this cast may not be 0 assign.storeObject.cast = 0; @@ -1127,13 +1126,13 @@ bool QmlCompiler::compilePropertyObjectAssignment(QmlParser::Property *prop, if (prop->index != -1) { QmlInstruction assign; assign.type = QmlInstruction::StoreValueSource; - assign.line = v->object->line; + assign.line = v->object->location.start.line; assign.assignValueSource.property = prop->index; output->bytecode << assign; } else { QmlInstruction assign; assign.type = QmlInstruction::AssignValueSource; - assign.line = v->object->line; + assign.line = v->object->location.start.line; assign.assignValueSource.property = output->indexForByteArray(prop->name);; output->bytecode << assign; } @@ -1148,7 +1147,7 @@ bool QmlCompiler::compilePropertyObjectAssignment(QmlParser::Property *prop, QmlInstruction assign; assign.type = QmlInstruction::AssignObject; - assign.line = v->object->line; + assign.line = v->object->location.start.line; assign.assignObject.property = output->indexForByteArray(prop->name); assign.assignObject.castValue = 0; output->bytecode << assign; @@ -1166,14 +1165,14 @@ bool QmlCompiler::compilePropertyLiteralAssignment(QmlParser::Property *prop, { if (isBinding(v->primitive)) { - compileBinding(v->primitive, prop, ctxt, obj->metaObject(), v->line); + compileBinding(v->primitive, prop, ctxt, obj->metaObject(), v->location.start.line); v->type = Value::PropertyBinding; } else { QmlInstruction assign; - assign.line = v->line; + assign.line = v->location.start.line; bool doassign = true; if (prop->index != -1) { @@ -1286,7 +1285,7 @@ bool QmlCompiler::compileDynamicMeta(QmlParser::Object *obj) store.type = QmlInstruction::StoreMetaObject; store.storeMeta.data = output->mos.count() - 1; store.storeMeta.slotData = slotStart; - store.line = obj->line; + store.line = obj->location.start.line; output->bytecode << store; for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) { @@ -1301,7 +1300,7 @@ bool QmlCompiler::compileDynamicMeta(QmlParser::Object *obj) if (!p.onValueChanged.isEmpty()) { QmlInstruction assign; assign.type = QmlInstruction::AssignSignal; - assign.line = obj->line; + assign.line = obj->location.start.line; assign.assignSignal.signal = output->indexForByteArray(p.name + "Changed()"); assign.assignSignal.value = diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index 08755b1..689446b 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -181,7 +181,7 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data) } if (td->data.tree()) { - component.dump(0, td->data.tree()); + td->data.tree()->dump(); d->root = td->data.tree(); d->root->addref(); } diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h index e9c81d6..02e084d 100644 --- a/src/declarative/qml/qmlinstruction_p.h +++ b/src/declarative/qml/qmlinstruction_p.h @@ -165,6 +165,9 @@ public: // NoOp - Do nothing NoOp }; + QmlInstruction() + : type(NoOp), line(0) {} + Type type; unsigned short line; union { diff --git a/src/declarative/qml/qmlparser.cpp b/src/declarative/qml/qmlparser.cpp index a6cb2ca..2bd41e2 100644 --- a/src/declarative/qml/qmlparser.cpp +++ b/src/declarative/qml/qmlparser.cpp @@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE using namespace QmlParser; QmlParser::Object::Object() -: type(-1), metatype(0), extObjectData(0), defaultProperty(0), line(-1), column(-1), endLine(-1), endColumn(-1) +: type(-1), metatype(0), extObjectData(0), defaultProperty(0) { } @@ -132,13 +132,35 @@ QmlParser::Object::DynamicSlot::DynamicSlot(const DynamicSlot &o) { } +void QmlParser::Object::dump(int indent) const +{ + QByteArray ba(indent * 4, ' '); + if (type != -1) { + qWarning() << ba.constData() << "Object:" << typeName; + } else { + qWarning() << ba.constData() << "Object: fetched"; + } + + for (QHash::ConstIterator iter = properties.begin(); + iter != properties.end(); + ++iter) { + qWarning() << ba.constData() << " Property" << iter.key(); + (*iter)->dump(indent + 1); + } + + if (defaultProperty) { + qWarning() << ba.constData() << " Default property"; + defaultProperty->dump(indent + 1); + } +} + QmlParser::Property::Property() -: type(0), index(-1), value(0), isDefault(true), line(-1), column(-1) +: type(0), index(-1), value(0), isDefault(true) { } QmlParser::Property::Property(const QByteArray &n) -: type(0), index(-1), value(0), name(n), isDefault(false), line(-1), column(-1) +: type(0), index(-1), value(0), name(n), isDefault(false) { } @@ -157,17 +179,20 @@ Object *QmlParser::Property::getValue() void QmlParser::Property::addValue(Value *v) { - if (::getenv("DUI_DEBUG")) { - if (v->object) - qDebug() << "Property" << name << "addValue Object(" << v->object->typeName << ")"; - else - qDebug() << "Property" << name << "addValue" << v->primitive; - } values << v; } +void QmlParser::Property::dump(int indent) const +{ + QByteArray ba(indent * 4, ' '); + for (int ii = 0; ii < values.count(); ++ii) + values.at(ii)->dump(indent); + if (value) + value->dump(indent); +} + QmlParser::Value::Value() -: type(Unknown), object(0), line(-1), column(-1) +: type(Unknown), object(0) { } @@ -176,4 +201,47 @@ QmlParser::Value::~Value() if (object) object->release(); } +void QmlParser::Value::dump(int indent) const +{ + QByteArray type; + switch(this->type) { + default: + case Value::Unknown: + type = "Unknown"; + break; + case Value::Literal: + type = "Literal"; + break; + case Value::PropertyBinding: + type = "PropertyBinding"; + break; + case Value::ValueSource: + type = "ValueSource"; + break; + case Value::CreatedObject: + type = "CreatedObject"; + break; + case Value::SignalObject: + type = "SignalObject"; + break; + case Value::SignalExpression: + type = "SignalExpression"; + break; + case Value::Component: + type = "Component"; + break; + case Value::Id: + type = "Id"; + break; + }; + + QByteArray ba(indent * 4, ' '); + if (object) { + qWarning() << ba.constData() << "Value (" << type << "):"; + object->dump(indent + 1); + } else { + qWarning() << ba.constData() << "Value (" << type << "):" << primitive; + } +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h index aa22928..5910705 100644 --- a/src/declarative/qml/qmlparser_p.h +++ b/src/declarative/qml/qmlparser_p.h @@ -69,6 +69,19 @@ QT_MODULE(Declarative) */ namespace QmlParser { + struct Location + { + Location() : line(-1), column(-1) {} + int line; + int column; + }; + + struct LocationSpan + { + Location start; + Location end; + }; + class Property; class Object : public QmlRefCount { @@ -103,11 +116,7 @@ namespace QmlParser Property *defaultProperty; QHash properties; - qint64 line; - qint64 column; - - qint64 endLine; - qint64 endColumn; + LocationSpan location; struct DynamicProperty { DynamicProperty(); @@ -141,6 +150,8 @@ namespace QmlParser QList dynamicSignals; // The list of dynamic slots QList dynamicSlots; + + void dump(int = 0) const; }; class Value : public QmlRefCount @@ -176,8 +187,9 @@ namespace QmlParser // Object value Object *object; - qint64 line; - qint64 column; + LocationSpan location; + + void dump(int = 0) const; }; class Property : public QmlRefCount @@ -207,8 +219,9 @@ namespace QmlParser // True if this property was accessed as the default property. bool isDefault; - qint64 line; - qint64 column; + LocationSpan location; + + void dump(int = 0) const; }; } diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index 8be0e5a..94a5ad2 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -37,18 +37,19 @@ class ProcessAST: protected AST::Visitor push(State(obj)); } - void pushProperty(const QString &name, int lineNumber) + void pushProperty(const QString &name, const LocationSpan &location) { const State &state = top(); if (state.property) { State s(state.property->getValue(), state.property->getValue()->getProperty(name.toLatin1())); - s.property->line = lineNumber; + s.property->location = location; push(s); } else { State s(state.object, state.object->getProperty(name.toLatin1())); - s.property->line = lineNumber; + + s.property->location = location; push(s); } } @@ -65,14 +66,19 @@ protected: AST::UiQualifiedId *propertyName, const QString &objectType, AST::SourceLocation typeLocation, + LocationSpan location, AST::UiObjectInitializer *initializer = 0); Object *defineObjectBinding_helper(int line, AST::UiQualifiedId *propertyName, const QString &objectType, AST::SourceLocation typeLocation, + LocationSpan location, AST::UiObjectInitializer *initializer = 0); QString getPrimitive(const QByteArray &propertyName, AST::ExpressionNode *expr); - void defineProperty(const QString &propertyName, int line, const QString &primitive); + void defineProperty(const QString &propertyName, const LocationSpan &location, const QString &primitive); + + LocationSpan location(AST::SourceLocation start, AST::SourceLocation end); + LocationSpan location(AST::UiQualifiedId *); using AST::Visitor::visit; using AST::Visitor::endVisit; @@ -192,18 +198,21 @@ QString ProcessAST::asString(AST::UiQualifiedId *node) const return s; } -Object *ProcessAST::defineObjectBinding_helper(int line, - AST::UiQualifiedId *propertyName, - const QString &objectType, - AST::SourceLocation typeLocation, - AST::UiObjectInitializer *initializer) +Object * +ProcessAST::defineObjectBinding_helper(int line, + AST::UiQualifiedId *propertyName, + const QString &objectType, + AST::SourceLocation typeLocation, + LocationSpan location, + AST::UiObjectInitializer *initializer) { bool isType = !objectType.isEmpty() && objectType.at(0).isUpper() && !objectType.contains(QLatin1Char('.')); int propertyCount = 0; for (; propertyName; propertyName = propertyName->next){ ++propertyCount; - _stateStack.pushProperty(propertyName->name->asString(), propertyName->identifierToken.startLine); + _stateStack.pushProperty(propertyName->name->asString(), + this->location(propertyName)); } if (!isType) { @@ -217,7 +226,8 @@ Object *ProcessAST::defineObjectBinding_helper(int line, return 0; } - _stateStack.pushProperty(objectType, line); + _stateStack.pushProperty(objectType, + this->location(propertyName)); accept(initializer); _stateStack.pop(); @@ -233,18 +243,14 @@ Object *ProcessAST::defineObjectBinding_helper(int line, _scope.append(objectType); obj->typeName = qualifiedNameId().toLatin1(); _scope.removeLast(); - obj->line = line; - - if(initializer) { - obj->endLine = initializer->rbraceToken.startLine; - obj->endColumn = initializer->rbraceToken.startColumn; - } + obj->location = location; if (propertyCount) { + Property *prop = currentProperty(); Value *v = new Value; v->object = obj; - v->line = line; + v->location = obj->location; prop->addValue(v); while (propertyCount--) @@ -258,7 +264,7 @@ Object *ProcessAST::defineObjectBinding_helper(int line, const State state = _stateStack.top(); Value *v = new Value; v->object = obj; - v->line = line; + v->location = obj->location; if (state.property) state.property->addValue(v); else @@ -278,11 +284,12 @@ Object *ProcessAST::defineObjectBinding(int line, AST::UiQualifiedId *qualifiedId, const QString &objectType, AST::SourceLocation typeLocation, + LocationSpan location, AST::UiObjectInitializer *initializer) { if (objectType == QLatin1String("Connection")) { - Object *obj = defineObjectBinding_helper(line, 0, objectType, typeLocation); + Object *obj = defineObjectBinding_helper(line, 0, objectType, typeLocation, location); _stateStack.pushObject(obj); @@ -300,7 +307,10 @@ Object *ProcessAST::defineObjectBinding(int line, } else { script = asString(scriptBinding->statement); } - defineProperty(QLatin1String("script"), line, script); + + LocationSpan l = this->location(scriptBinding->statement->firstSourceLocation(), + scriptBinding->statement->lastSourceLocation()); + defineProperty(QLatin1String("script"), l, script); } else { accept(it->member); } @@ -311,15 +321,30 @@ Object *ProcessAST::defineObjectBinding(int line, return obj; } - return defineObjectBinding_helper(line, qualifiedId, objectType, typeLocation, initializer); + return defineObjectBinding_helper(line, qualifiedId, objectType, typeLocation, location, initializer); } -void ProcessAST::defineProperty(const QString &propertyName, int line, const QString &primitive) +LocationSpan ProcessAST::location(AST::UiQualifiedId *id) { - _stateStack.pushProperty(propertyName, line); + return location(id->identifierToken, id->identifierToken); +} + +LocationSpan ProcessAST::location(AST::SourceLocation start, AST::SourceLocation end) +{ + LocationSpan rv; + rv.start.line = start.startLine; + rv.start.column = start.startColumn; + rv.end.line = end.startLine; + rv.end.column = end.startColumn + end.length - 1; + return rv; +} + +void ProcessAST::defineProperty(const QString &propertyName, const LocationSpan &location, const QString &primitive) +{ + _stateStack.pushProperty(propertyName, location); Value *value = new Value; value->primitive = primitive; - value->line = line; + value->location = location; currentProperty()->addValue(value); _stateStack.pop(); } @@ -396,6 +421,8 @@ bool ProcessAST::visit(AST::UiPublicMember *node) if (node->expression) { // default value property.defaultValue = new Property; Value *value = new Value; + value->location = location(node->expression->firstSourceLocation(), + node->expression->lastSourceLocation()); value->primitive = getPrimitive("value", node->expression); property.defaultValue->values << value; } @@ -410,11 +437,14 @@ bool ProcessAST::visit(AST::UiPublicMember *node) // UiObjectMember: T_IDENTIFIER UiObjectInitializer ; bool ProcessAST::visit(AST::UiObjectDefinition *node) { + LocationSpan l = location(node->firstSourceLocation(), + node->lastSourceLocation());; defineObjectBinding(node->identifierToken.startLine, 0, node->name->asString(), node->identifierToken, + l, node->initializer); return false; @@ -424,10 +454,14 @@ bool ProcessAST::visit(AST::UiObjectDefinition *node) // UiObjectMember: UiQualifiedId T_COLON T_IDENTIFIER UiObjectInitializer ; bool ProcessAST::visit(AST::UiObjectBinding *node) { + LocationSpan l; + l = location(node->identifierToken, node->initializer->rbraceToken); + defineObjectBinding(node->identifierToken.startLine, node->qualifiedId, node->name->asString(), node->identifierToken, + l, node->initializer); return false; @@ -467,7 +501,8 @@ bool ProcessAST::visit(AST::UiScriptBinding *node) AST::UiQualifiedId *propertyName = node->qualifiedId; for (; propertyName; propertyName = propertyName->next){ ++propertyCount; - _stateStack.pushProperty(propertyName->name->asString(), propertyName->identifierToken.startLine); + _stateStack.pushProperty(propertyName->name->asString(), + location(propertyName)); } Property *prop = currentProperty(); @@ -490,8 +525,9 @@ bool ProcessAST::visit(AST::UiScriptBinding *node) Value *v = new Value; v->primitive = primitive; - v->line = node->statement->firstSourceLocation().startLine; - v->column = node->statement->firstSourceLocation().startColumn; + v->location = location(node->statement->firstSourceLocation(), + node->statement->lastSourceLocation()); + prop->addValue(v); while (propertyCount--) @@ -507,7 +543,8 @@ bool ProcessAST::visit(AST::UiArrayBinding *node) AST::UiQualifiedId *propertyName = node->qualifiedId; for (; propertyName; propertyName = propertyName->next){ ++propertyCount; - _stateStack.pushProperty(propertyName->name->asString(), propertyName->identifierToken.startLine); + _stateStack.pushProperty(propertyName->name->asString(), + location(propertyName)); } accept(node->members); @@ -564,8 +601,9 @@ bool ProcessAST::visit(AST::UiSourceElement *node) } Value *value = new Value; + value->location = location(node->firstSourceLocation(), + node->lastSourceLocation()); value->primitive = source; - value->line = line; obj->getDefaultProperty()->addValue(value); } -- cgit v0.12 From 2dc5bf5c17f5b07e1387796977c69d3354acfd06 Mon Sep 17 00:00:00 2001 From: Kenneth Rohde Christiansen Date: Thu, 30 Apr 2009 09:59:04 +0200 Subject: Fix focus issues in QX11EmbedContainer, affecting Flash plugin in QtWebKit. We are now moving focus to the XEmbed focus proxy when we accept a client and when we get window activation. Window activation did that before, but only when we were the active container, thus had focus in. Now we do it always. Due to race conditions with the window manager, the time stamt we used for XSetInputFocus was the same as that of the window manager. This broke it from time to time in Metacity and Xfce but always in KWin. With other tested window manager we didn't have this issue. Following Owen Tayler's advice (one of the authors of the XEmbed specification) we now use CurrentTime and not qt_x11Data->time when moving the input focus as there is no explicit user interaction involved. Reviewed-by: Denis Dzyubenko Reviewed-by: Bradley T. Hughes --- src/gui/kernel/qx11embed_x11.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/gui/kernel/qx11embed_x11.cpp b/src/gui/kernel/qx11embed_x11.cpp index 6329135..ae93efe 100644 --- a/src/gui/kernel/qx11embed_x11.cpp +++ b/src/gui/kernel/qx11embed_x11.cpp @@ -1297,9 +1297,6 @@ bool QX11EmbedContainer::eventFilter(QObject *o, QEvent *event) // focus is set to our focus proxy. We want to intercept all // keypresses. if (o == window() && d->client) { - if (!d->isEmbedded() && d->activeContainer == this) - d->moveInputToProxy(); - if (d->clientIsXEmbed) { sendXEmbedMessage(d->client, x11Info().display(), XEMBED_WINDOW_ACTIVATE); } else { @@ -1307,6 +1304,8 @@ bool QX11EmbedContainer::eventFilter(QObject *o, QEvent *event) if (hasFocus()) XSetInputFocus(x11Info().display(), d->client, XRevertToParent, x11Time()); } + if (!d->isEmbedded()) + d->moveInputToProxy(); } break; case QEvent::WindowDeactivate: @@ -1729,10 +1728,10 @@ void QX11EmbedContainerPrivate::acceptClient(WId window) checkGrab(); if (q->hasFocus()) { XSetInputFocus(q->x11Info().display(), client, XRevertToParent, x11Time()); - } else { - if (!isEmbedded()) - moveInputToProxy(); } + } else { + if (!isEmbedded()) + moveInputToProxy(); } emit q->clientIsEmbedded(); @@ -1749,11 +1748,9 @@ void QX11EmbedContainerPrivate::acceptClient(WId window) void QX11EmbedContainerPrivate::moveInputToProxy() { Q_Q(QX11EmbedContainer); - WId focus; - int revert_to; - XGetInputFocus(q->x11Info().display(), &focus, &revert_to); - if (focus != focusProxy->internalWinId()) - XSetInputFocus(q->x11Info().display(), focusProxy->internalWinId(), XRevertToParent, x11Time()); + // Following Owen Taylor's advice from the XEmbed specification to + // always use CurrentTime when no explicit user action is involved. + XSetInputFocus(q->x11Info().display(), focusProxy->internalWinId(), XRevertToParent, CurrentTime); } /*! \internal -- cgit v0.12 From 30559395ca73361ec4347fe04fb0eb34a373859a Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 6 May 2009 14:39:39 +0200 Subject: Fixing task 252319 This is still not a perfect solution since it breaks 245347 again Task-number: 252319 Reviewed-by: Maurice --- src/gui/widgets/qmainwindow.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 2abc9e8..502c1e9 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -480,9 +480,6 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar) oldMenuBar->hide(); oldMenuBar->deleteLater(); } -#ifdef Q_OS_WINCE - if (menuBar && menuBar->size().height() > 0) -#endif d->layout->setMenuBar(menuBar); } -- cgit v0.12 From 6d4c3c7fe561d472b34bfed1ab9d3665cee1f659 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 6 May 2009 22:49:47 +1000 Subject: Add an (unused) locations field to compiled data --- src/declarative/qml/qmlcompiler.cpp | 16 ++++++++++++++++ src/declarative/qml/qmlcompiler_p.h | 11 +++++------ src/declarative/qml/qmlparser_p.h | 4 +--- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 8eb5fa1..13fc332 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -136,6 +136,22 @@ int QmlCompiledData::indexForInt(int *data, int count) return idx; } +int QmlCompiledData::indexForLocation(const QmlParser::Location &l) +{ + // ### FIXME + int rv = locations.count(); + locations << l; + return rv; +} + +int QmlCompiledData::indexForLocation(const QmlParser::LocationSpan &l) +{ + // ### FIXME + int rv = locations.count(); + locations << l.start << l.end; + return rv; +} + QmlCompiler::QmlCompiler() : exceptionLine(-1), exceptionColumn(-1), output(0) { diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h index e2b8388..b885e7b 100644 --- a/src/declarative/qml/qmlcompiler_p.h +++ b/src/declarative/qml/qmlcompiler_p.h @@ -48,6 +48,8 @@ #include #include #include +#include + class QStringList; QT_BEGIN_NAMESPACE @@ -56,12 +58,6 @@ class QmlComponent; class QmlCompiledComponent; class QmlContext; -namespace QmlParser { - class Object; - class Property; - class Value; -}; - class QmlCompiledData { public: @@ -98,6 +94,7 @@ public: QList customTypeData; QList datas; QList mos; + QList locations; QList bytecode; private: @@ -106,6 +103,8 @@ private: int indexForByteArray(const QByteArray &); int indexForFloat(float *, int); int indexForInt(int *, int); + int indexForLocation(const QmlParser::Location &); + int indexForLocation(const QmlParser::LocationSpan &); }; class Q_DECLARATIVE_EXPORT QmlCompiler diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h index 5910705..31f8702 100644 --- a/src/declarative/qml/qmlparser_p.h +++ b/src/declarative/qml/qmlparser_p.h @@ -45,10 +45,8 @@ #include #include #include -#include "qmlcomponent_p.h" #include -#include "qmlcompiledcomponent_p.h" - +#include QT_BEGIN_HEADER -- cgit v0.12 From da1416cef6b1d24156739ded101df895ee4e80d9 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Wed, 6 May 2009 14:51:13 +0200 Subject: Added comment to QTextStream - clarification of the documentation Explained why you cannot use QTextStream::atEnd with stdin. Task-number:251171 --- src/corelib/io/qtextstream.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index ed9d0aa..2010008 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -67,7 +67,8 @@ static const int QTEXTSTREAM_BUFFERSIZE = 16384; \snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 1 Note that you cannot use QTextStream::atEnd(), which returns true when you - have reached the end of the data stream, with stdin. + have reached the end of the data stream, with stdin because as long as the + application is running, stdin has no end. Besides using QTextStream's constructors, you can also set the device or string QTextStream operates on by calling setDevice() or -- cgit v0.12 From 4395513385ed639e54b1ebf5c0f1a919f9a9622b Mon Sep 17 00:00:00 2001 From: jasplin Date: Wed, 6 May 2009 14:52:03 +0200 Subject: Fixed bug in QTabBar::setTabButton() for a scrolled tab bar. This fix ensures that the current tab is visible after calling setTabButton() on a scrolled tab bar. Reviewed-by: bnilsen Task-number: 252472 --- src/gui/widgets/qtabbar.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp index b562b1f..69221ba 100644 --- a/src/gui/widgets/qtabbar.cpp +++ b/src/gui/widgets/qtabbar.cpp @@ -1085,7 +1085,7 @@ void QTabBar::setTabData(int index, const QVariant & data) } /*! - Returns the datad of the tab at position \a index, or a null + Returns the data of the tab at position \a index, or a null variant if \a index is out of range. */ QVariant QTabBar::tabData(int index) const @@ -2222,6 +2222,7 @@ void QTabBar::setTabButton(int index, ButtonPosition position, QWidget *widget) d->tabList[index].rightWidget = widget; } d->layoutTabs(); + d->refresh(); update(); } -- cgit v0.12 From 3cec5ff3f0aa8d3eca0dfb325e83a8a3a18cb305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 6 May 2009 14:08:55 +0200 Subject: Prevented X server crash when calling XFillPolygon with >200000 points. Don't know why the X server crashes, but it's reproducible both by us and customers so we should fall back to the raster paint engine to avoid the crash. Task-number: 244362 Reviewed-by: Trond --- src/gui/painting/qpaintengine_x11.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index 4b2fbca..9cc9683 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -1543,6 +1543,8 @@ void QX11PaintEnginePrivate::fillPolygon_dev(const QPointF *polygonPoints, int p QX11PaintEnginePrivate::GCMode gcMode, QPaintEngine::PolygonDrawMode mode) { + Q_Q(QX11PaintEngine); + int clippedCount = 0; qt_float_point *clippedPoints = 0; @@ -1617,7 +1619,29 @@ void QX11PaintEnginePrivate::fillPolygon_dev(const QPointF *polygonPoints, int p } else #endif if (fill.style() != Qt::NoBrush) { - if (clippedCount > 0) { + if (clippedCount > 200000) { + QPolygon poly; + for (int i = 0; i < clippedCount; ++i) + poly << QPoint(qFloor(clippedPoints[i].x), qFloor(clippedPoints[i].y)); + + const QRect bounds = poly.boundingRect(); + const QRect aligned = bounds + & QRect(QPoint(), QSize(pdev->width(), pdev->height())); + + QImage img(aligned.size(), QImage::Format_ARGB32_Premultiplied); + img.fill(0); + + QPainter painter(&img); + painter.translate(-aligned.x(), -aligned.y()); + painter.setPen(Qt::NoPen); + painter.setBrush(fill); + if (gcMode == BrushGC) + painter.setBrushOrigin(q->painter()->brushOrigin()); + painter.drawPolygon(poly); + painter.end(); + + q->drawImage(aligned, img, img.rect(), Qt::AutoColor); + } else if (clippedCount > 0) { QVarLengthArray xpoints(clippedCount); for (int i = 0; i < clippedCount; ++i) { xpoints[i].x = qFloor(clippedPoints[i].x); -- cgit v0.12 From 2043637a4e17252062fcb483e2e63ce0cb0920dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 6 May 2009 11:58:56 +0200 Subject: Re-enabled antialiasing for large font sizes in OpenGL paint engine. In 4.4 alphaMapForGlyph() would return valid images for any font size, but this was changed in 4.5, forcing us to use the path fallback instead. This lead to non-antialiased fonts when not using a multisample-enabled GL format. This patch re-introduces the alphaMapForGlyph() fallback in QFontEngine from 4.4 which uses the raster paint engine to draw the glyph. Task-number: 247083 Reviewed-by: Trond --- src/gui/text/qfontengine.cpp | 39 ++++++++++++++++++++++++++++++++++++++ src/gui/text/qfontengine_ft.cpp | 8 +++++--- src/gui/text/qfontengine_p.h | 2 +- src/opengl/qpaintengine_opengl.cpp | 5 ++--- 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 47fe5c2..d7a9c23 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -624,6 +624,45 @@ QImage QFontEngine::alphaRGBMapForGlyph(glyph_t glyph, int /* margin */, const Q return rgbMask; } +QImage QFontEngine::alphaMapForGlyph(glyph_t glyph) +{ + glyph_metrics_t gm = boundingBox(glyph); + int glyph_x = qFloor(gm.x.toReal()); + int glyph_y = qFloor(gm.y.toReal()); + int glyph_width = qCeil((gm.x + gm.width).toReal()) - glyph_x; + int glyph_height = qCeil((gm.y + gm.height).toReal()) - glyph_y; + + if (glyph_width <= 0 || glyph_height <= 0) + return QImage(); + QFixedPoint pt; + pt.x = 0; + pt.y = -glyph_y; // the baseline + QPainterPath path; + QImage im(glyph_width + qAbs(glyph_x) + 4, glyph_height, QImage::Format_ARGB32_Premultiplied); + im.fill(Qt::transparent); + QPainter p(&im); + p.setRenderHint(QPainter::Antialiasing); + addGlyphsToPath(&glyph, &pt, 1, &path, 0); + p.setPen(Qt::NoPen); + p.setBrush(Qt::black); + p.drawPath(path); + p.end(); + + QImage indexed(im.width(), im.height(), QImage::Format_Indexed8); + QVector colors(256); + for (int i=0; i<256; ++i) + colors[i] = qRgba(0, 0, 0, i); + indexed.setColorTable(colors); + + for (int y=0; ywidth + 3) & ~3 : ((glyph->width + 31)/32) * 4; diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 176c728..dc18991 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -178,7 +178,7 @@ public: * Create a qimage with the alpha values for the glyph. * Returns an image indexed_8 with index values ranging from 0=fully transparant to 255=opaque */ - virtual QImage alphaMapForGlyph(glyph_t) = 0; + virtual QImage alphaMapForGlyph(glyph_t); virtual QImage alphaMapForGlyph(glyph_t, const QTransform &t); virtual QImage alphaRGBMapForGlyph(glyph_t, int margin, const QTransform &t); diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index ec6e33b..5a212f5 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -5068,9 +5068,8 @@ void QOpenGLPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte // fall back to drawing a polygon if the scale factor is large, or // we use a gradient pen - if (ti.fontEngine->fontDef.pixelSize >= 64 - || (d->matrix.det() > 1) || (d->pen_brush_style >= Qt::LinearGradientPattern - && d->pen_brush_style <= Qt::ConicalGradientPattern)) { + if ((d->matrix.det() > 1) || (d->pen_brush_style >= Qt::LinearGradientPattern + && d->pen_brush_style <= Qt::ConicalGradientPattern)) { QPaintEngine::drawTextItem(p, textItem); return; } -- cgit v0.12 From 3e6dbc962111228d9ff7a7afe11d69dabf97fff8 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 6 May 2009 23:06:01 +1000 Subject: Shift QmlBindableValue data into d-ptr --- src/declarative/qml/qml.pri | 1 + src/declarative/qml/qmlbindablevalue.cpp | 61 ++++++++++++++++++++----------- src/declarative/qml/qmlbindablevalue.h | 6 +-- src/declarative/qml/qmlbindablevalue_p.h | 63 ++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 25 deletions(-) create mode 100644 src/declarative/qml/qmlbindablevalue_p.h diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index 5198264..99e30e4 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -29,6 +29,7 @@ HEADERS += qml/qmlparser_p.h \ qml/qmlvmemetaobject_p.h \ qml/qml.h \ qml/qmlbindablevalue.h \ + qml/qmlbindablevalue_p.h \ qml/qmlmetaproperty.h \ qml/qmlcomponent.h \ qml/qmlcomponent_p.h \ diff --git a/src/declarative/qml/qmlbindablevalue.cpp b/src/declarative/qml/qmlbindablevalue.cpp index b312b40..3950f82 100644 --- a/src/declarative/qml/qmlbindablevalue.cpp +++ b/src/declarative/qml/qmlbindablevalue.cpp @@ -41,6 +41,7 @@ #include #include "qmlbindablevalue.h" +#include "qmlbindablevalue_p.h" #include #include #include @@ -50,20 +51,25 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(scriptWarnings, QML_SCRIPT_WARNINGS); +QmlBindableValuePrivate::QmlBindableValuePrivate() +: inited(false) +{ +} + QML_DEFINE_NOCREATE_TYPE(QmlBindableValue); QmlBindableValue::QmlBindableValue(QObject *parent) -: QmlPropertyValueSource(parent), _inited(false) +: QmlPropertyValueSource(*new QmlBindableValuePrivate, parent) { qFatal("QmlBindableValue: Default constructor not supported"); } QmlBindableValue::QmlBindableValue(void *data, QmlRefCount *rc, QObject *obj, QObject *parent) -: QmlPropertyValueSource(parent), QmlExpression(QmlContext::activeContext(), data, rc, obj), _inited(false) +: QmlPropertyValueSource(*new QmlBindableValuePrivate, parent), QmlExpression(QmlContext::activeContext(), data, rc, obj) { } QmlBindableValue::QmlBindableValue(const QString &str, QObject *obj, bool sse, QObject *parent) -: QmlPropertyValueSource(parent), QmlExpression(QmlContext::activeContext(), str, obj, sse), _inited(false) +: QmlPropertyValueSource(*new QmlBindableValuePrivate, parent), QmlExpression(QmlContext::activeContext(), str, obj, sse) { } @@ -73,16 +79,25 @@ QmlBindableValue::~QmlBindableValue() void QmlBindableValue::setTarget(const QmlMetaProperty &prop) { - _property = prop; + Q_D(QmlBindableValue); + d->property = prop; update(); } +QmlMetaProperty QmlBindableValue::property() const +{ + Q_D(const QmlBindableValue); + return d->property; +} + void QmlBindableValue::init() { - if (_inited) + Q_D(QmlBindableValue); + + if (d->inited) return; - _inited = true; + d->inited = true; update(); } @@ -95,20 +110,22 @@ void QmlBindableValue::setExpression(const QString &expr) Q_DECLARE_METATYPE(QList); void QmlBindableValue::update() { + Q_D(QmlBindableValue); + #ifdef Q_ENABLE_PERFORMANCE_LOG QFxPerfTimer bu; #endif - if (!_inited) + if (!d->inited) return; - if (_property.propertyCategory() == QmlMetaProperty::List) { + if (d->property.propertyCategory() == QmlMetaProperty::List) { QVariant value = this->value(); - int listType = QmlMetaType::listType(_property.propertyType()); + int listType = QmlMetaType::listType(d->property.propertyType()); if (value.userType() == qMetaTypeId >()) { const QList &list = qvariant_cast >(value); - QVariant listVar = _property.read(); + QVariant listVar = d->property.read(); QmlMetaType::clear(listVar); for (int ii = 0; ii < list.count(); ++ii) { QVariant v = QmlMetaType::fromObject(list.at(ii), listType); @@ -117,14 +134,14 @@ void QmlBindableValue::update() } else if (value.type() == uint(listType) || value.userType() == listType) { - QVariant listVar = _property.read(); + QVariant listVar = d->property.read(); QmlMetaType::clear(listVar); QmlMetaType::append(listVar, value); } - } else if (_property.propertyCategory() == QmlMetaProperty::QmlList) { + } else if (d->property.propertyCategory() == QmlMetaProperty::QmlList) { // XXX - optimize! QVariant value = this->value(); - QVariant list = _property.read(); + QVariant list = d->property.read(); QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)list.constData(); @@ -153,20 +170,20 @@ void QmlBindableValue::update() void *d = (void *)&obj; li->append(d); } - } else if (_property.propertyCategory() == QmlMetaProperty::Bindable) { + } else if (d->property.propertyCategory() == QmlMetaProperty::Bindable) { // NOTE: We assume that only core properties can have // propertyType == Bindable - int idx = _property.coreIndex(); + int idx = d->property.coreIndex(); Q_ASSERT(idx != -1); void *a[1]; QmlBindableValue *t = this; a[0] = (void *)&t; - _property.object()->qt_metacall(QMetaObject::WriteProperty, - idx, a); + d->property.object()->qt_metacall(QMetaObject::WriteProperty, + idx, a); - } else if (_property.propertyCategory() == QmlMetaProperty::Object) { + } else if (d->property.propertyCategory() == QmlMetaProperty::Object) { QVariant value = this->value(); if ((int)value.type() != qMetaTypeId()) { @@ -186,17 +203,17 @@ void QmlBindableValue::update() // NOTE: We assume that only core properties can have // propertyType == Object - int idx = _property.coreIndex(); + int idx = d->property.coreIndex(); Q_ASSERT(idx != -1); void *a[1]; a[0] = (void *)&obj; - _property.object()->qt_metacall(QMetaObject::WriteProperty, + d->property.object()->qt_metacall(QMetaObject::WriteProperty, idx, a); - } else if (_property.propertyCategory() == QmlMetaProperty::Normal) { + } else if (d->property.propertyCategory() == QmlMetaProperty::Normal) { QVariant value = this->value(); - _property.write(value); + d->property.write(value); } } diff --git a/src/declarative/qml/qmlbindablevalue.h b/src/declarative/qml/qmlbindablevalue.h index 578fc12..c4ef64a 100644 --- a/src/declarative/qml/qmlbindablevalue.h +++ b/src/declarative/qml/qmlbindablevalue.h @@ -56,6 +56,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QmlExpression; class QmlContext; +class QmlBindableValuePrivate; class Q_DECLARATIVE_EXPORT QmlBindableValue : public QmlPropertyValueSource, public QmlExpression { @@ -67,7 +68,7 @@ public: ~QmlBindableValue(); virtual void setTarget(const QmlMetaProperty &); - QmlMetaProperty property() const { return _property; } + QmlMetaProperty property() const; Q_CLASSINFO("DefaultProperty", "expression"); Q_PROPERTY(QString expression READ expression WRITE setExpression); @@ -82,8 +83,7 @@ protected: virtual void valueChanged(); private: - bool _inited; - QmlMetaProperty _property; + Q_DECLARE_PRIVATE(QmlBindableValue) }; QML_DECLARE_TYPE(QmlBindableValue); diff --git a/src/declarative/qml/qmlbindablevalue_p.h b/src/declarative/qml/qmlbindablevalue_p.h new file mode 100644 index 0000000..b6de5b7 --- /dev/null +++ b/src/declarative/qml/qmlbindablevalue_p.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative 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 QMLBINDABLEVALUE_P_H +#define QMLBINDABLEVALUE_P_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QmlBindableValuePrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QmlBindableValue); +public: + QmlBindableValuePrivate(); + + bool inited; + QmlMetaProperty property; +}; + +QT_END_NAMESPACE + +#endif // QMLBINDABLEVALUE_P_H -- cgit v0.12 From 2e3a5ea4434d19fbdb90996e71961f0791ea6487 Mon Sep 17 00:00:00 2001 From: Bjoern Erik Nilsen Date: Wed, 6 May 2009 13:40:25 +0200 Subject: QGraphicsItem::setOpacity(0.0) does not trigger an update. The problem was that we discarded update requests for fully transparent items, which is correct, but we even did that when the update was issued from QGraphicsItem::setOpacity. We don't have to, and shouldn't, consider the opacity in that case. Whenever we reach the fullUpdateHelper call in setOpacity it means we have to do an update regardless of the current opacity (oldOpacity was not 0.0 if the currentOpacity is 0.0). Auto-test included. Task-number: 252913 Reviewed-by: Andreas --- src/gui/graphicsview/qgraphicsitem.cpp | 16 ++--- src/gui/graphicsview/qgraphicsitem_p.h | 7 +- src/gui/graphicsview/qgraphicsview.cpp | 6 +- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 89 +++++++++++++++++++++++++- 4 files changed, 102 insertions(+), 16 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 3e8d38f..11ec24b 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1921,7 +1921,7 @@ void QGraphicsItem::setOpacity(qreal opacity) itemChange(ItemOpacityHasChanged, newOpacity); // Update. - d_ptr->fullUpdateHelper(); + d_ptr->fullUpdateHelper(/*childrenOnly=*/false, /*maybeDirtyClipPath=*/false, /*ignoreOpacity=*/true); } /*! @@ -3621,9 +3621,8 @@ void QGraphicsItem::setBoundingRegionGranularity(qreal granularity) \internal Returns true if we can discard an update request; otherwise false. */ -bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreClipping, - bool ignoreVisibleBit, - bool ignoreDirtyBit) const +bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreClipping, bool ignoreVisibleBit, + bool ignoreDirtyBit, bool ignoreOpacity) const { // No scene, or if the scene is updating everything, means we have nothing // to do. The only exception is if the scene tracks the growing scene rect. @@ -3632,7 +3631,7 @@ bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreClipping, || !scene || (scene->d_func()->updateAll && scene->d_func()->hasSceneRect) || (!ignoreClipping && (childrenClippedToShape() && isClippedAway())) - || (childrenCombineOpacity() && isFullyTransparent()); + || (!ignoreOpacity && childrenCombineOpacity() && isFullyTransparent()); } /*! @@ -3662,11 +3661,10 @@ void QGraphicsItemPrivate::updateHelper(const QRectF &rect, bool force, bool may Propagates updates to \a item and all its children. */ -void QGraphicsItemPrivate::fullUpdateHelper(bool childrenOnly, bool maybeDirtyClipPath) +void QGraphicsItemPrivate::fullUpdateHelper(bool childrenOnly, bool maybeDirtyClipPath, bool ignoreOpacity) { - if (discardUpdateRequest(/*ignoreClipping=*/maybeDirtyClipPath, - /*ignoreVisibleBit=*/false, - /*ignoreDirtyBit=*/true)) { + if (discardUpdateRequest(/*ignoreClipping=*/maybeDirtyClipPath, /*ignoreVisibleBit=*/false, + /*ignoreDirtyBit=*/true, ignoreOpacity)) { return; } diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index a5871a7..9ce1bbf 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -165,11 +165,10 @@ public: void setPosHelper(const QPointF &pos); void setVisibleHelper(bool newVisible, bool explicitly, bool update = true); void setEnabledHelper(bool newEnabled, bool explicitly, bool update = true); - bool discardUpdateRequest(bool ignoreClipping = false, - bool ignoreVisibleBit = false, - bool ignoreDirtyBit = false) const; + bool discardUpdateRequest(bool ignoreClipping = false, bool ignoreVisibleBit = false, + bool ignoreDirtyBit = false, bool ignoreOpacity = false) const; void updateHelper(const QRectF &rect = QRectF(), bool force = false, bool maybeDirtyClipPath = false); - void fullUpdateHelper(bool childrenOnly = false, bool maybeDirtyClipPath = false); + void fullUpdateHelper(bool childrenOnly = false, bool maybeDirtyClipPath = false, bool ignoreOpacity = false); void updateEffectiveOpacity(); void resolveEffectiveOpacity(qreal effectiveParentOpacity); void resolveDepth(int parentDepth); diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index b5a1bdf..05e4907 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -1071,8 +1071,12 @@ QList QGraphicsViewPrivate::findItems(const QRegion &exposedReg QList itemList(scene->items()); int i = 0; while (i < itemList.size()) { + const QGraphicsItem *item = itemList.at(i); // But we only want to include items that are visible - if (!itemList.at(i)->isVisible()) + // The following check is basically the same as item->d_ptr->isInvisible(), except + // that we don't check whether the item clips children to shape or propagates its + // opacity (we loop through all items, so those checks are wrong in this context). + if (!item->isVisible() || item->d_ptr->isClippedAway() || item->d_ptr->isFullyTransparent()) itemList.removeAt(i); else ++i; diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 77b7948..6d150cb 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -78,8 +78,7 @@ Q_DECLARE_METATYPE(QRectF) class EventTester : public QGraphicsItem { public: - EventTester() - : repaints(0) + EventTester(QGraphicsItem *parent = 0) : QGraphicsItem(parent), repaints(0) { br = QRectF(-10, -10, 20, 20); } void setGeometry(const QRectF &rect) @@ -207,6 +206,7 @@ private slots: void itemTransform_unrelated(); void opacity_data(); void opacity(); + void opacity2(); void itemStacksBehindParent(); void nestedClipping(); void nestedClippingTransforms(); @@ -5570,6 +5570,91 @@ void tst_QGraphicsItem::opacity() QCOMPARE(c3->effectiveOpacity(), c3_effectiveOpacity); } +void tst_QGraphicsItem::opacity2() +{ + EventTester *parent = new EventTester; + EventTester *child = new EventTester(parent); + EventTester *grandChild = new EventTester(child); + + QGraphicsScene scene; + scene.addItem(parent); + + class MyGraphicsView : public QGraphicsView + { public: + int repaints; + MyGraphicsView(QGraphicsScene *scene) : QGraphicsView(scene), repaints(0) {} + void paintEvent(QPaintEvent *e) { ++repaints; QGraphicsView::paintEvent(e); } + }; + + MyGraphicsView view(&scene); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(250); + +#define RESET_REPAINT_COUNTERS \ + parent->repaints = 0; \ + child->repaints = 0; \ + grandChild->repaints = 0; \ + view.repaints = 0; + + RESET_REPAINT_COUNTERS + + child->setOpacity(0.0); + QTest::qWait(100); + QCOMPARE(view.repaints, 1); + QCOMPARE(parent->repaints, 1); + QCOMPARE(child->repaints, 0); + QCOMPARE(grandChild->repaints, 0); + + RESET_REPAINT_COUNTERS + + child->setOpacity(1.0); + QTest::qWait(100); + QCOMPARE(view.repaints, 1); + QCOMPARE(parent->repaints, 1); + QCOMPARE(child->repaints, 1); + QCOMPARE(grandChild->repaints, 1); + + RESET_REPAINT_COUNTERS + + parent->setOpacity(0.0); + QTest::qWait(100); + QCOMPARE(view.repaints, 1); + QCOMPARE(parent->repaints, 0); + QCOMPARE(child->repaints, 0); + QCOMPARE(grandChild->repaints, 0); + + RESET_REPAINT_COUNTERS + + parent->setOpacity(1.0); + QTest::qWait(100); + QCOMPARE(view.repaints, 1); + QCOMPARE(parent->repaints, 1); + QCOMPARE(child->repaints, 1); + QCOMPARE(grandChild->repaints, 1); + + grandChild->setFlag(QGraphicsItem::ItemIgnoresParentOpacity); + RESET_REPAINT_COUNTERS + + child->setOpacity(0.0); + QTest::qWait(100); + QCOMPARE(view.repaints, 1); + QCOMPARE(parent->repaints, 1); + QCOMPARE(child->repaints, 0); + QCOMPARE(grandChild->repaints, 1); + + RESET_REPAINT_COUNTERS + + child->setOpacity(0.0); // Already 0.0; no change. + QTest::qWait(100); + QCOMPARE(view.repaints, 0); + QCOMPARE(parent->repaints, 0); + QCOMPARE(child->repaints, 0); + QCOMPARE(grandChild->repaints, 0); +} + void tst_QGraphicsItem::itemStacksBehindParent() { QGraphicsRectItem *parent1 = new QGraphicsRectItem(QRectF(0, 0, 100, 50)); -- cgit v0.12 From bcf7c498f0bd29f1ee9c7f226b3a656f1c05e35e Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 6 May 2009 15:17:03 +0200 Subject: Reduced the number of files in the WebKit import Exclude chromium files from the import. Reviewed-by: Trust me --- util/webkit/mkdist-webkit | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/util/webkit/mkdist-webkit b/util/webkit/mkdist-webkit index a7ecbc6..a2ef05b 100755 --- a/util/webkit/mkdist-webkit +++ b/util/webkit/mkdist-webkit @@ -46,6 +46,7 @@ excluded_directories="$excluded_directories JavaScriptCore/wtf/wx" excluded_directories="$excluded_directories JavaScriptCore/wtf/gtk" excluded_directories="$excluded_directories JavaScriptCore/wtf/mac" excluded_directories="$excluded_directories JavaScriptCore/wtf/win" +excluded_directories="$excluded_directories JavaScriptCore/wtf/chromium" excluded_directories="$excluded_directories WebCore/WebCore.vcproj" excluded_directories="$excluded_directories WebCore/DerivedSources.make" @@ -70,6 +71,7 @@ excluded_directories="$excluded_directories WebCore/loader/win" excluded_directories="$excluded_directories WebCore/page/gtk" excluded_directories="$excluded_directories WebCore/page/mac" excluded_directories="$excluded_directories WebCore/page/wx" +excluded_directories="$excluded_directories WebCore/page/chromium" excluded_directories="$excluded_directories WebCore/history/mac" @@ -78,6 +80,7 @@ excluded_directories="$excluded_directories WebCore/editing/wx" excluded_directories="$excluded_directories WebCore/platform/text/wx" excluded_directories="$excluded_directories WebCore/platform/text/gtk" +excluded_directories="$excluded_directories WebCore/platform/text/chromium" excluded_directories="$excluded_directories WebCore/manual-tests" @@ -87,6 +90,7 @@ excluded_directories="$excluded_directories WebCore/platform/network/curl" excluded_directories="$excluded_directories WebCore/platform/network/mac" excluded_directories="$excluded_directories WebCore/platform/network/win" excluded_directories="$excluded_directories WebCore/platform/network/soup" +excluded_directories="$excluded_directories WebCore/platform/network/chromium" excluded_directories="$excluded_directories WebCore/platform/graphics/cg" excluded_directories="$excluded_directories WebCore/platform/graphics/cairo" @@ -95,6 +99,7 @@ excluded_directories="$excluded_directories WebCore/platform/graphics/wx" excluded_directories="$excluded_directories WebCore/platform/graphics/mac" excluded_directories="$excluded_directories WebCore/platform/graphics/win" excluded_directories="$excluded_directories WebCore/platform/graphics/skia" +excluded_directories="$excluded_directories WebCore/platform/graphics/chromium" excluded_directories="$excluded_directories WebCore/platform/image-decoders/bmp" excluded_directories="$excluded_directories WebCore/platform/image-decoders/gif" @@ -105,6 +110,7 @@ excluded_directories="$excluded_directories WebCore/platform/image-decoders/jpeg excluded_directories="$excluded_directories WebCore/platform/image-decoders/xbm" excluded_directories="$excluded_directories WebCore/plugins/gtk" +excluded_directories="$excluded_directories WebCore/plugins/chromium" excluded_directories="$excluded_directories WebCore/platform/symbian WebCore/platform/wx" excluded_directories="$excluded_directories WebKit/gtk" -- cgit v0.12 From b35bde7308016bbf32f28940a27bb37c74343375 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 6 May 2009 15:39:33 +0200 Subject: Adds in documentation for RESOURCES Reviewed-by: Kavindra Palaraja --- doc/src/qmake-manual.qdoc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/src/qmake-manual.qdoc b/doc/src/qmake-manual.qdoc index 39581a2..172bc60 100644 --- a/doc/src/qmake-manual.qdoc +++ b/doc/src/qmake-manual.qdoc @@ -932,6 +932,7 @@ \o \l{qmake Variable Reference#QT}{QT} \o \l{qmake Variable Reference#RCC_DIR}{RCC_DIR} \o \l{qmake Variable Reference#REQUIRES}{REQUIRES} + \o \l{qmake Variable Reference#RESOURCES}{RESOURCES} \o \l{qmake Variable Reference#SOURCES}{SOURCES} \o \l{qmake Variable Reference#SUBDIRS}{SUBDIRS} \o \l{qmake Variable Reference#TARGET}{TARGET} @@ -2420,6 +2421,12 @@ This is mainly used in Qt's build system for building the examples. + \section1 RESOURCES + + This variable contains the name of the resource collection file (qrc) + for the application. Further information about the resource collection + file can be found at \l{The Qt Resource System}. + \section1 RES_FILE This variable contains the name of the resource file for the application. -- cgit v0.12 From 1560af4bca4a7ea2dd6b73ddef60cd012c4897b0 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Wed, 6 May 2009 14:48:03 +0200 Subject: Doc: Updated docs for collision between QGraphicsItems Task-number: 252287 --- src/gui/graphicsview/qgraphicsitem.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 3e8d38f..2ec1c44 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3235,10 +3235,16 @@ bool QGraphicsItem::contains(const QPointF &point) const } /*! - Returns true if this item collides with \a other; otherwise returns false. - The ways items collide is determined by \a mode. The default value for \a - mode is Qt::IntersectsItemShape; \a other collides with this item if it - either intersects, contains, or is contained by this item's shape. + + Returns true if this item collides with \a other; otherwise + returns false. + + The \a mode is applied to \a other, and the resulting shape or + bounding rectangle is then compared to this item's shape. The + default value for \a mode is Qt::IntersectsItemShape; \a other + collides with this item if it either intersects, contains, or is + contained by this item's shape (see Qt::ItemSelectionMode for + details). The default implementation is based on shape intersection, and it calls shape() on both items. Because the complexity of arbitrary shape-shape @@ -3293,6 +3299,11 @@ bool QGraphicsItem::collidesWithItem(const QGraphicsItem *other, Qt::ItemSelecti Qt::IntersectsItemShape; \a path collides with this item if it either intersects, contains, or is contained by this item's shape. + Note that this function checks whether the item's shape or + bounding rectangle (depending on \a mode) is contained within \a + path, and not whether \a path is contained within the items shape + or bounding rectangle. + \sa collidesWithItem(), contains(), shape() */ bool QGraphicsItem::collidesWithPath(const QPainterPath &path, Qt::ItemSelectionMode mode) const @@ -3333,11 +3344,12 @@ bool QGraphicsItem::collidesWithPath(const QPainterPath &path, Qt::ItemSelection /*! Returns a list of all items that collide with this item. - The way collisions are detected is determined by \a mode. The default - value for \a mode is Qt::IntersectsItemShape; All items whose shape - intersects or is contained by this item's shape are returned. + The way collisions are detected is determined by applying \a mode + to items that are compared to this item, i.e., each item's shape + or bounding rectangle is checked against this item's shape. The + default value for \a mode is Qt::IntersectsItemShape. - \sa QGraphicsScene::collidingItems(), collidesWithItem() + \sa collidesWithItem() */ QList QGraphicsItem::collidingItems(Qt::ItemSelectionMode mode) const { -- cgit v0.12 From 980256ac1012f236a600d2a613229c50258a1ed8 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 6 May 2009 15:58:27 +0200 Subject: fix compilation of QLocalServer when QT_LOCALSOCKET_TCP is defined When QT_LOCALSOCKET_TCP is defined we cannot call setEnabled on the socket notifier. Reviewed-by: ossi --- src/network/socket/qlocalserver.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp index 1815d73..77a999b 100644 --- a/src/network/socket/qlocalserver.cpp +++ b/src/network/socket/qlocalserver.cpp @@ -276,12 +276,14 @@ QLocalSocket *QLocalServer::nextPendingConnection() if (d->pendingConnections.isEmpty()) return 0; QLocalSocket *nextSocket = d->pendingConnections.dequeue(); +#ifndef QT_LOCALSOCKET_TCP if (d->pendingConnections.size() <= d->maxPendingConnections) #ifndef Q_OS_WIN d->socketNotifier->setEnabled(true); #else d->connectionEventNotifier->setEnabled(true); #endif +#endif return nextSocket; } -- cgit v0.12 From ec8fef8f17ac69bacc3d250a0d5932c336276bc5 Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Tue, 5 May 2009 20:00:12 -0400 Subject: QNetworkDiskCache: check if opening file succeeds In QNetworkDiskCache::prepare() When QTemporaryFile::open fails, delete the cache item and return 0 rather then returning a closed device. And a spelling mistake in a qWarning() Reviewed-by: Peter Hartmann --- src/network/access/qnetworkdiskcache.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp index 93360c8..892929e 100644 --- a/src/network/access/qnetworkdiskcache.cpp +++ b/src/network/access/qnetworkdiskcache.cpp @@ -191,7 +191,11 @@ QIODevice *QNetworkDiskCache::prepare(const QNetworkCacheMetaData &metaData) } else { QString templateName = d->tmpCacheFileName(); cacheItem->file = new QTemporaryFile(templateName, &cacheItem->data); - cacheItem->file->open(); + if (!cacheItem->file->open()) { + qWarning() << "QNetworkDiskCache::prepare() unable to open temporary file"; + delete cacheItem; + return 0; + } cacheItem->writeHeader(cacheItem->file); device = cacheItem->file; } @@ -229,7 +233,7 @@ void QNetworkDiskCachePrivate::storeItem(QCacheItem *cacheItem) if (QFile::exists(fileName)) { if (!QFile::remove(fileName)) { - qWarning() << "QNetworkDiskCache: could't remove the cache file " << fileName; + qWarning() << "QNetworkDiskCache: couldn't remove the cache file " << fileName; return; } } -- cgit v0.12 From 92f2815bf45a67ec8c6b94ca26fb8598a07a6de2 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Wed, 6 May 2009 16:48:55 +0200 Subject: Doc: Added info on NOTIFY to the Q_PROPERTY docs. Task-number: 248336 --- doc/src/properties.qdoc | 7 ++++++- doc/src/snippets/code/doc_src_properties.qdoc | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/src/properties.qdoc b/doc/src/properties.qdoc index 0775b12..d934f13 100644 --- a/doc/src/properties.qdoc +++ b/doc/src/properties.qdoc @@ -89,7 +89,12 @@ and QWidget::setCursor(), and it also has a \c RESET function, QWidget::unsetCursor(), since no call to QWidget::setCursor() can mean \e {reset to the context specific cursor}. The \c RESET - function musrt return void and take no parameters. + function must return void and take no parameters. + + \o A \c NOTIFY signal is optional. If defined, the signal will be + emitted whenever the value of the property changes. The signal must + take one parameter, which must be of the same type as the property; the + parameter will take the new value of the property. \o The \c DESIGNABLE attribute indicates whether the property should be visible in the property editor of GUI design tool (e.g., diff --git a/doc/src/snippets/code/doc_src_properties.qdoc b/doc/src/snippets/code/doc_src_properties.qdoc index ba7f79b..377cc9c 100644 --- a/doc/src/snippets/code/doc_src_properties.qdoc +++ b/doc/src/snippets/code/doc_src_properties.qdoc @@ -3,6 +3,7 @@ Q_PROPERTY(type name READ getFunction [WRITE setFunction] [RESET resetFunction] + [NOTIFY notifySignal] [DESIGNABLE bool] [SCRIPTABLE bool] [STORED bool] -- cgit v0.12 From 2eb0312c96ab828809158802d4cb7e0980227389 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 4 May 2009 14:29:39 +0200 Subject: Fix crash in QWebView when application has a style sheet Task: 252796 Rev-By: Tor Arne --- src/gui/styles/qstylesheetstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index ebddfd5..dcc11b8 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -4758,7 +4758,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op case CT_LineEdit: #ifndef QT_NO_SPINBOX // ### hopelessly broken QAbstractSpinBox (part 2) - if (QAbstractSpinBox *spinBox = qobject_cast(w->parentWidget())) { + if (QAbstractSpinBox *spinBox = qobject_cast(w ? w->parentWidget() : 0)) { QRenderRule rule = renderRule(spinBox, opt); if (rule.hasBox() || !rule.hasNativeBorder()) return csz; -- cgit v0.12 From 67c2b69d45eb43078b7e4193ced6cd513602483c Mon Sep 17 00:00:00 2001 From: Bjoern Erik Nilsen Date: Wed, 6 May 2009 16:32:01 +0200 Subject: Crash in QWidget::render when passing an untransformed QPixmap painter. The crash only occurred on Windows and X11 when running with -graphicssystem raster. The reason is that the actual paint device in QRasterPaintEngine::begin() is changed to pixmap->data->buffer(), which means QPaintEngine::paintDevice() returns something else than what it was told to paint on (see cb0c899b56b84154f69ddc545991bc6ded96ab01) The root of the problem, however, was that we used a weird condition (painter->worldMatrixEnabled(), added in 345072b9 for Qt 4.4) to find the target device. We did that because the shared painter was completely different in 4.4. We refactored it in 4.5.0, and we can only trust QPaintEngine::paintDevice to be the target device. Auto-test included. Task-number: 252837 Reviewed-by: Trond --- src/gui/kernel/qwidget.cpp | 2 +- tests/auto/qwidget/tst_qwidget.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index fb9c8cb..b96d8b3 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -4805,7 +4805,7 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset, Q_ASSERT(engine); QPaintEnginePrivate *enginePriv = engine->d_func(); Q_ASSERT(enginePriv); - QPaintDevice *target = painter->worldMatrixEnabled() ? engine->paintDevice() : painter->device(); + QPaintDevice *target = engine->paintDevice(); Q_ASSERT(target); // Render via a pixmap when dealing with non-opaque painters or printers. diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index dee48a3..5896df9 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -287,6 +287,7 @@ private slots: void render_systemClip2(); void render_systemClip3_data(); void render_systemClip3(); + void render_task252837(); void setContentsMargins(); @@ -7097,6 +7098,16 @@ void tst_QWidget::render_systemClip3() } } +void tst_QWidget::render_task252837() +{ + QWidget widget; + widget.resize(200, 200); + + QPixmap pixmap(widget.size()); + QPainter painter(&pixmap); + // Please do not crash. + widget.render(&painter); +} void tst_QWidget::setContentsMargins() { QLabel label("why does it always rain on me?"); -- cgit v0.12 From 9f7e8dcd408f8a082d6b8355c78c692d71becbb8 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 4 May 2009 14:29:39 +0200 Subject: Fix crash in QWebView when application has a style sheet Task: 252796 Rev-By: Tor Arne --- src/gui/styles/qstylesheetstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 058660e..714b8c5 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -4926,7 +4926,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op case CT_LineEdit: #ifndef QT_NO_SPINBOX // ### hopelessly broken QAbstractSpinBox (part 2) - if (QAbstractSpinBox *spinBox = qobject_cast(w->parentWidget())) { + if (QAbstractSpinBox *spinBox = qobject_cast(w ? w->parentWidget() : 0)) { QRenderRule rule = renderRule(spinBox, opt); if (rule.hasBox() || !rule.hasNativeBorder()) return csz; -- cgit v0.12 From a86c2b58d80b0688b98d0eaf243508a096f699b1 Mon Sep 17 00:00:00 2001 From: Nils Christian Roscher-Nielsen Date: Wed, 6 May 2009 17:42:51 +0200 Subject: Fixed typo in README file Reviewed-by: David Boddie --- examples/phonon/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/phonon/README b/examples/phonon/README index d0f4462..51213cb 100644 --- a/examples/phonon/README +++ b/examples/phonon/README @@ -1,4 +1,4 @@ -Qt usese the Phonon cross-platform multimedia framework to play common +Qt uses the Phonon cross-platform multimedia framework to play common multimedia formats. Applications can be written to take advantage of the native multimedia -- cgit v0.12 From 42e10c0dda9acfb3a5344bd20172898e7ed2846d Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 6 May 2009 10:50:02 -0700 Subject: Make Scale public Needed for fallback warnings Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 6d8f617..18e0d55 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -211,6 +211,8 @@ static QCache imageCache(4*1024*1024); // 4 MB class QDirectFBPaintEnginePrivate : public QRasterPaintEnginePrivate { public: + enum Scale { NoScale, Scaled, NegativeScale }; + QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p); ~QDirectFBPaintEnginePrivate(); @@ -266,7 +268,7 @@ private: bool simplePen; bool matrixRotShear; - enum Scale { NoScale, Scaled, NegativeScale } scale; + Scale scale; SurfaceCache *surfaceCache; QTransform transform; -- cgit v0.12 From df83ea844e2254723cbd9fabf91586cbad0756a3 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 6 May 2009 11:35:28 -0700 Subject: Pass the scale parameter as an int. We're just printout out the integer value anyway. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 18e0d55..91a60e7 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -80,7 +80,7 @@ template inline const T *ptr(const T &t) { return &t; } template <> inline const bool* ptr(const bool &) { return 0; } template static void rasterFallbackWarn(const char *msg, const char *func, const device *dev, - QDirectFBPaintEnginePrivate::Scale scale, bool matrixRotShear, bool simplePen, + int scale, bool matrixRotShear, bool simplePen, bool dfbHandledClip, bool forceRasterPrimitives, const char *nameOne, const T1 &one, const char *nameTwo, const T2 &two, -- cgit v0.12 From 311978919f63c2c23dd09b4743ff12cf2a8a47bb Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 6 May 2009 14:23:03 -0700 Subject: Improved debug output for directfb:debug Include info on the primary surface pixelformat. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 25e24fd..f571d1b 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -818,7 +818,7 @@ static const QByteArray flagDescriptions(uint mask, const FlagDescription *flags -static void printDirectFBInfo(IDirectFB *fb) +static void printDirectFBInfo(IDirectFB *fb, IDirectFBSurface *primarySurface) { DFBResult result; DFBGraphicsDeviceDescription dev; @@ -829,10 +829,14 @@ static void printDirectFBInfo(IDirectFB *fb) return; } - qDebug("Device: %s (%s), Driver: %s v%i.%i (%s)\n" + DFBSurfacePixelFormat pixelFormat; + primarySurface->GetPixelFormat(primarySurface, &pixelFormat); + + qDebug("Device: %s (%s), Driver: %s v%i.%i (%s) Pixelformat: %d (%d)\n" "acceleration: 0x%x%s\nblit: 0x%x%s\ndraw: 0x%0x%s\nvideo: %iKB\n", dev.name, dev.vendor, dev.driver.name, dev.driver.major, - dev.driver.minor, dev.driver.vendor, dev.acceleration_mask, + dev.driver.minor, dev.driver.vendor, DFB_PIXELFORMAT_INDEX(pixelFormat), + QDirectFBScreen::getImageFormat(primarySurface), dev.acceleration_mask, ::flagDescriptions(dev.acceleration_mask, accelerationDescriptions).constData(), dev.blitting_flags, ::flagDescriptions(dev.blitting_flags, blitDescriptions).constData(), dev.drawing_flags, ::flagDescriptions(dev.drawing_flags, drawDescriptions).constData(), @@ -883,9 +887,6 @@ bool QDirectFBScreen::connect(const QString &displaySpec) return false; } - if (displayArgs.contains(QLatin1String("debug"), Qt::CaseInsensitive)) - printDirectFBInfo(d_ptr->dfb); - if (displayArgs.contains(QLatin1String("videoonly"), Qt::CaseInsensitive)) d_ptr->directFBFlags |= VideoOnly; @@ -952,6 +953,9 @@ bool QDirectFBScreen::connect(const QString &displaySpec) return false; } + if (displayArgs.contains(QLatin1String("debug"), Qt::CaseInsensitive)) + printDirectFBInfo(d_ptr->dfb, d_ptr->dfbSurface); + // Work out what format we're going to use for surfaces with an alpha channel d_ptr->alphaPixmapFormat = QDirectFBScreen::getImageFormat(d_ptr->dfbSurface); setPixelFormat(d_ptr->alphaPixmapFormat); -- cgit v0.12 From f5a2f15fc9283ac8d2ed3cd642d56e223ad3f15c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 7 May 2009 09:25:28 +1000 Subject: Fix typo. --- src/declarative/fx/qfxpathview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp index ca6379f..715ae5a 100644 --- a/src/declarative/fx/qfxpathview.cpp +++ b/src/declarative/fx/qfxpathview.cpp @@ -700,7 +700,7 @@ void QFxPathView::itemsRemoved(int modelIndex, int count) } if (d->model->count() == 0) { - d->currentIndex == -1; + d->currentIndex = -1; d->moveOffset.setValue(0); return; } -- cgit v0.12 From 71601dfd3cf877e14796b7304f1bcc9e01248476 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 7 May 2009 10:32:34 +1000 Subject: Add simple menubar to qmlviewer. --- tools/qmlviewer/main.cpp | 1 - tools/qmlviewer/qmlviewer.cpp | 50 +++++++++++++++++++++++++++++++++++++------ tools/qmlviewer/qmlviewer.h | 6 ++++-- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp index 26ff213..b588111 100644 --- a/tools/qmlviewer/main.cpp +++ b/tools/qmlviewer/main.cpp @@ -18,7 +18,6 @@ #include "qfxtestengine.h" #include - void usage() { qWarning("Usage: qmlviewer [options] "); diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 094d779..dbbe233 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -32,10 +32,14 @@ #include #include #include +#include #include +#include +#include +#include QmlViewer::QmlViewer(QFxTestEngine::TestMode testMode, const QString &testDir, QWidget *parent, Qt::WindowFlags flags) - : QWidget(parent, flags), frame_stream(0) + : QMainWindow(parent, flags), frame_stream(0) { testEngine = 0; devicemode = false; @@ -44,10 +48,12 @@ QmlViewer::QmlViewer(QFxTestEngine::TestMode testMode, const QString &testDir, Q record_autotime = 0; record_period = 20; - int width=240; - int height=320; + int width = 240; + int height = 320; + setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_NoSystemBackground); + createMenuBar(); canvas = new QFxView(this); if(testMode != QFxTestEngine::NoTest) @@ -56,6 +62,27 @@ QmlViewer::QmlViewer(QFxTestEngine::TestMode testMode, const QString &testDir, Q QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize))); canvas->setFixedSize(width, height); resize(width, height); + setCentralWidget(canvas); +} + +void QmlViewer::createMenuBar() +{ + QMenu *fileMenu = menuBar()->addMenu(tr("&File")); + + QAction *openAction = new QAction(tr("&Open..."), this); + openAction->setShortcut(QKeySequence("Ctrl+O")); + connect(openAction, SIGNAL(triggered()), this, SLOT(open())); + fileMenu->addAction(openAction); + + QAction *reloadAction = new QAction(tr("&Reload"), this); + reloadAction->setShortcut(QKeySequence("Ctrl+R")); + connect(reloadAction, SIGNAL(triggered()), this, SLOT(reload())); + fileMenu->addAction(reloadAction); + + QMenu *helpMenu = menuBar()->addMenu(tr("&Help")); + QAction *aboutAction = new QAction(tr("&About Qt..."), this); + connect(aboutAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + helpMenu->addAction(aboutAction); } void QmlViewer::reload() @@ -63,6 +90,15 @@ void QmlViewer::reload() openQml(currentFileName); } +void QmlViewer::open() +{ + QString fileName = QFileDialog::getOpenFileName(this, tr("Open QML file"), "", tr("QML Files (*.qml)")); + if (!fileName.isEmpty()) { + openQml(fileName); + QTimer::singleShot(0, this, SLOT(reload())); + } +} + void QmlViewer::openQml(const QString& fileName) { setWindowTitle(tr("%1 - Qt Declarative UI Viewer").arg(fileName)); @@ -187,7 +223,6 @@ void PreviewDeviceSkin::populateContextMenu(QMenu *menu) connect(menu->addAction(tr("&Close")), SIGNAL(triggered()), parentWidget(), SLOT(close())); } - void QmlViewer::setSkin(const QString& skinDirectory) { DeviceSkinParameters parameters; @@ -239,10 +274,11 @@ void QmlViewer::sceneResized(QSize size) } } -void QmlViewer::resizeEvent(QResizeEvent *) +void QmlViewer::resizeEvent(QResizeEvent *e) { - if (!skin) - canvas->setFixedSize(width(),height()); + QMainWindow::resizeEvent(e); + //if (!skin) + //canvas->setFixedSize(width(),height()); } void QmlViewer::keyPressEvent(QKeyEvent *event) diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index fc65ebf..b4117a2 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -14,7 +14,7 @@ #ifndef QMLVIEWER_H #define QMLVIEWER_H -#include +#include #include #include #include @@ -25,12 +25,13 @@ class QFxView; class PreviewDeviceSkin; class QFxTestEngine; -class QmlViewer : public QWidget +class QmlViewer : public QMainWindow { Q_OBJECT public: QmlViewer(QFxTestEngine::TestMode = QFxTestEngine::NoTest, const QString &testDir = QString(), QWidget *parent=0, Qt::WindowFlags flags=0); + void createMenuBar(); void setRecordDither(const QString& s) { record_dither = s; } void setRecordPeriod(int ms); void setRecordFile(const QString&); @@ -45,6 +46,7 @@ public: public slots: void sceneResized(QSize size); void openQml(const QString& fileName); + void open(); void reload(); protected: -- cgit v0.12 From a0c5e46be1e1584e9731ad4766b256a6bb499b86 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 7 May 2009 10:50:56 +1000 Subject: Fix z handling to avoid uglyness --- demos/declarative/flickr/flickr.qml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml index 0ff539d..5caffb9 100644 --- a/demos/declarative/flickr/flickr.qml +++ b/demos/declarative/flickr/flickr.qml @@ -74,8 +74,9 @@ Item { states: [ State { name: "Details" + SetProperties { target: ImageDetails; z: 2 } ParentChange { target: Wrapper; parent: ImageDetails.frontContainer } - SetProperties { target: Wrapper; x: 45; y: 35; scale: 1 } + SetProperties { target: Wrapper; x: 45; y: 35; scale: 1; z: 1000 } SetProperties { target: Rotation; angle: 0 } SetProperties { target: Shadows; opacity: 0 } SetProperties { target: ImageDetails; y: 20 } @@ -89,11 +90,20 @@ Item { transitions: [ Transition { - fromState: "*"; toState: "*" + fromState: "*"; toState: "Details" ParentChangeAction { } NumericAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } + }, + Transition { + fromState: "Details"; toState: "*" + SequentialAnimation { + ParentChangeAction { } + NumericAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } + SetPropertyAction { filter: Wrapper; properties: "z" } + } } ] + } } ] @@ -105,12 +115,12 @@ Item { GridView { id: PhotoGridView; model: FeedModel; delegate: PhotoDelegate - cellWidth: 105; cellHeight: 105; x:32; y: 80; width: 800; height: 330 + cellWidth: 105; cellHeight: 105; x:32; y: 80; width: 800; height: 330; z: 1 } PathView { id: PhotoPathView; model: FeedModel; delegate: PhotoDelegate - y: -380; width: 800; height: 330; pathItemCount: 10 + y: -380; width: 800; height: 330; pathItemCount: 10; z: 1 path: Path { startX: -50; startY: 40; -- cgit v0.12