From 2c6fdd89086977708850043a075b2b880bd22c9e Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 30 Apr 2009 10:11:43 +0200 Subject: QApplication::setStyle() can cause a crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QApplication::setStyle() caused a crash if called before constructing the QApplication instance for custom styles. The reason was that polish tried to create a pixmap (which is not allowed before qApp is running). This fix checks that qApp exists. Polish will anyway be called again when qApp gets constructed. Task-number: 243697 Reviewed-by: Bjørn Erik Nilsen --- src/gui/styles/qmacstyle_mac.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 398e11d..c973b41 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -2146,8 +2146,11 @@ void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint /*! \reimp */ void QMacStyle::polish(QPalette &pal) { - if (qt_mac_backgroundPattern == 0) + if (!qt_mac_backgroundPattern) { + if (!qApp) + return; qt_mac_backgroundPattern = new QPixmap(d->generateBackgroundPattern()); + } QColor pc(Qt::black); pc = qcolorForTheme(kThemeBrushDialogBackgroundActive); -- cgit v0.12 From c70eae8288cccb92e54e3c73f0ca257af033178a Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 30 Apr 2009 12:07:59 +0200 Subject: Fixes a possible issue in itemviws where we would not scroll to the current item on show Task-number: 252534 Reviewed-by: ogoffart --- src/gui/itemviews/qabstractitemview.cpp | 26 ++++++++++++++++---------- src/gui/itemviews/qabstractitemview_p.h | 1 + 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 975decc..83e05b4 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -88,6 +88,7 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate() autoScroll(true), autoScrollMargin(16), autoScrollCount(0), + shouldScrollToCurrentOnShow(false), alternatingColors(false), textElideMode(Qt::ElideRight), verticalScrollMode(QAbstractItemView::ScrollPerItem), @@ -1380,8 +1381,9 @@ bool QAbstractItemView::event(QEvent *event) d->executePostedLayout(); //make sure we set the layout properly break; case QEvent::Show: - if (d->delayedPendingLayout) { - d->executePostedLayout(); //make sure we set the layout properly + d->executePostedLayout(); //make sure we set the layout properly + if (d->shouldScrollToCurrentOnShow) { + d->shouldScrollToCurrentOnShow = false; const QModelIndex current = currentIndex(); if (current.isValid() && (d->state == QAbstractItemView::EditingState || d->autoScroll)) scrollTo(current); @@ -3163,14 +3165,18 @@ void QAbstractItemView::currentChanged(const QModelIndex ¤t, const QModelI d->updateDirtyRegion(); } } - if (isVisible() && current.isValid() && !d->autoScrollTimer.isActive()) { - if (d->autoScroll) - scrollTo(current); - d->setDirtyRegion(visualRect(current)); - d->updateDirtyRegion(); - edit(current, CurrentChanged, 0); - if (current.row() == (d->model->rowCount(d->root) - 1)) - d->_q_fetchMore(); + if (current.isValid() && !d->autoScrollTimer.isActive()) { + if (isVisible()) { + if (d->autoScroll) + scrollTo(current); + d->setDirtyRegion(visualRect(current)); + d->updateDirtyRegion(); + edit(current, CurrentChanged, 0); + if (current.row() == (d->model->rowCount(d->root) - 1)) + d->_q_fetchMore(); + } else { + d->shouldScrollToCurrentOnShow = d->autoScroll; + } } } diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index 37fe4a2..16bd1ab 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -359,6 +359,7 @@ public: QBasicTimer autoScrollTimer; int autoScrollMargin; int autoScrollCount; + bool shouldScrollToCurrentOnShow; //used to know if we should scroll to current on show event bool alternatingColors; -- cgit v0.12 From db6f14776a298201e68e1d3646bb99b740c12867 Mon Sep 17 00:00:00 2001 From: jasplin Date: Thu, 30 Apr 2009 11:30:51 +0200 Subject: Fixed busy indicator for a QProgressBar with a style sheet applied to it. For a progress bar with a style sheet applied to it, this fix ensures that the timer event is passed to the event handler that updates the busy indicator animation state. Essentially, the bug was that the decision that the event was processed by the proxy style object (baseStyle()) was based only on the return value from the event() function. In this case it is necessary to check that the event was accepted as well. Reviewed-by: ogoffart Reviewed-by: brad Task-number: 252283 --- 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 49ac57a..058660e 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -5842,7 +5842,7 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c bool QStyleSheetStyle::event(QEvent *e) { - return baseStyle()->event(e) || ParentStyle::event(e); + return (baseStyle()->event(e) && e->isAccepted()) || ParentStyle::event(e); } void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const -- cgit v0.12 From 9cb0419bd9559b5c9e0a95711a81391556306e51 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 30 Apr 2009 13:10:04 +0200 Subject: Correcting typo Missed a whitespace - corrected it. No task --- doc/src/examples/flowlayout.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/examples/flowlayout.qdoc b/doc/src/examples/flowlayout.qdoc index 5fdafe2..3e7ec22 100644 --- a/doc/src/examples/flowlayout.qdoc +++ b/doc/src/examples/flowlayout.qdoc @@ -53,7 +53,7 @@ The Flowlayout class mainly uses QLayout and QWidgetItem, while the Window uses QWidget and QLabel. We will only document the definition - and implementation of \cFlowLayout below. + and implementation of \c FlowLayout below. \section1 FlowLayout Class Definition @@ -156,4 +156,4 @@ the parent is a QLayout, will be determined by querying the spacing of the parent layout. -*/ \ No newline at end of file +*/ -- cgit v0.12 From ea80a3dc8acdb95c0c217b3574718c88c7a36e9f Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 30 Apr 2009 15:31:55 +0200 Subject: New autotest for Windows Mobile: tst_windowsmobile This autotest tests some Windows Mobile 5.0 specific thing like the native menubar and the integration into the window manager by taking and comparing screenshots. This should prevent nasty regressions we had. This autotest makes only sense on Windows Mobile 5.0 in 480x640 Reviewed-by: maurice --- tests/auto/windowsmobile/test/ddhelper.cpp | 121 +++++++++++++ tests/auto/windowsmobile/test/ddhelper.h | 21 +++ tests/auto/windowsmobile/test/test.pro | 24 +++ .../windowsmobile/test/testQMenuBar_current.png | Bin 0 -> 23702 bytes .../test/testSimpleWidget_current.png | Bin 0 -> 21940 bytes .../auto/windowsmobile/test/tst_windowsmobile.cpp | 191 +++++++++++++++++++++ tests/auto/windowsmobile/test/windowsmobile.qrc | 6 + tests/auto/windowsmobile/testQMenuBar/main.cpp | 72 ++++++++ .../windowsmobile/testQMenuBar/testQMenuBar.pro | 2 + tests/auto/windowsmobile/windowsmobile.pro | 9 + 10 files changed, 446 insertions(+) create mode 100644 tests/auto/windowsmobile/test/ddhelper.cpp create mode 100644 tests/auto/windowsmobile/test/ddhelper.h create mode 100644 tests/auto/windowsmobile/test/test.pro create mode 100644 tests/auto/windowsmobile/test/testQMenuBar_current.png create mode 100644 tests/auto/windowsmobile/test/testSimpleWidget_current.png create mode 100644 tests/auto/windowsmobile/test/tst_windowsmobile.cpp create mode 100644 tests/auto/windowsmobile/test/windowsmobile.qrc create mode 100644 tests/auto/windowsmobile/testQMenuBar/main.cpp create mode 100644 tests/auto/windowsmobile/testQMenuBar/testQMenuBar.pro create mode 100644 tests/auto/windowsmobile/windowsmobile.pro diff --git a/tests/auto/windowsmobile/test/ddhelper.cpp b/tests/auto/windowsmobile/test/ddhelper.cpp new file mode 100644 index 0000000..5955cd3 --- /dev/null +++ b/tests/auto/windowsmobile/test/ddhelper.cpp @@ -0,0 +1,121 @@ + +#ifdef Q_OS_WINCE_WM + +#include +#include + +static LPDIRECTDRAW g_pDD = NULL; // DirectDraw object +static LPDIRECTDRAWSURFACE g_pDDSSurface = NULL; // DirectDraw primary surface + +static DDSCAPS ddsCaps; +static DDSURFACEDESC ddsSurfaceDesc; +static void *buffer = NULL; + +static int width = 0; +static int height = 0; +static int pitch = 0; +static int bitCount = 0; +static int windowId = 0; + +static bool initialized = false; +static bool locked = false; + +void q_lock() +{ + if (locked) { + qWarning("Direct Painter already locked (QDirectPainter::lock())"); + return; + } + locked = true; + + + memset(&ddsSurfaceDesc, 0, sizeof(ddsSurfaceDesc)); + ddsSurfaceDesc.dwSize = sizeof(ddsSurfaceDesc); + + HRESULT h = g_pDDSSurface->Lock(0, &ddsSurfaceDesc, DDLOCK_WRITEONLY, 0); + if (h != DD_OK) + qDebug() << "GetSurfaceDesc failed!"; + + width = ddsSurfaceDesc.dwWidth; + height = ddsSurfaceDesc.dwHeight; + bitCount = ddsSurfaceDesc.ddpfPixelFormat.dwRGBBitCount; + pitch = ddsSurfaceDesc.lPitch; + buffer = ddsSurfaceDesc.lpSurface; +} + +void q_unlock() +{ + if( !locked) { + qWarning("Direct Painter not locked (QDirectPainter::unlock()"); + return; + } + g_pDDSSurface->Unlock(0); + locked = false; +} + +void q_initDD() +{ + if (initialized) + return; + + DirectDrawCreate(NULL, &g_pDD, NULL); + + HRESULT h; + h = g_pDD->SetCooperativeLevel(0, DDSCL_NORMAL); + + if (h != DD_OK) + qDebug() << "cooperation level failed"; + + h = g_pDD->TestCooperativeLevel(); + if (h != DD_OK) + qDebug() << "cooperation level failed test"; + + DDSURFACEDESC ddsd; + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + + ddsd.dwFlags = DDSD_CAPS; + + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + + h = g_pDD->CreateSurface(&ddsd, &g_pDDSSurface, NULL); + + if (h != DD_OK) + qDebug() << "CreateSurface failed!"; + + if (g_pDDSSurface->GetCaps(&ddsCaps) != DD_OK) + qDebug() << "GetCaps failed"; + + q_lock(); + q_unlock(); + initialized = true; +} + +uchar* q_frameBuffer() +{ + return (uchar*) buffer; +} + +int q_screenDepth() +{ + return bitCount; +} + +int q_screenWidth() +{ + return width; +} + +int q_screenHeight() +{ + return height; +} + +int q_linestep() +{ + return pitch; +} + +#endif //Q_OS_WINCE_WM + + diff --git a/tests/auto/windowsmobile/test/ddhelper.h b/tests/auto/windowsmobile/test/ddhelper.h new file mode 100644 index 0000000..3dfa9e6 --- /dev/null +++ b/tests/auto/windowsmobile/test/ddhelper.h @@ -0,0 +1,21 @@ +#ifndef __DDHELPER__ +#define __DDHELPER__ + +extern uchar* q_frameBuffer(); + +extern int q_screenDepth(); + +extern int q_screenWidth(); + +extern int q_screenHeight(); + +extern int q_linestep(); + +extern void q_initDD(); + +extern void q_unlock(); + +extern void q_lock(); + +#endif //__DDHELPER__ + diff --git a/tests/auto/windowsmobile/test/test.pro b/tests/auto/windowsmobile/test/test.pro new file mode 100644 index 0000000..2420bf1 --- /dev/null +++ b/tests/auto/windowsmobile/test/test.pro @@ -0,0 +1,24 @@ + +load(qttest_p4) + +HEADERS += ddhelper.h +SOURCES += tst_windowsmobile.cpp ddhelper.cpp +RESOURCES += windowsmobile.qrc + +TARGET = tst_windowsmobile + +wincewm*: { + addFiles.sources = \ + ../testQMenuBar/*.exe + + + addFiles.path = "\Program Files\tst_windowsmobile" + DEPLOYMENT += addFiles +} + +wincewm*: { + LIBS += Ddraw.lib +} + + + diff --git a/tests/auto/windowsmobile/test/testQMenuBar_current.png b/tests/auto/windowsmobile/test/testQMenuBar_current.png new file mode 100644 index 0000000..d03e69a Binary files /dev/null and b/tests/auto/windowsmobile/test/testQMenuBar_current.png differ diff --git a/tests/auto/windowsmobile/test/testSimpleWidget_current.png b/tests/auto/windowsmobile/test/testSimpleWidget_current.png new file mode 100644 index 0000000..5cbc2bb Binary files /dev/null and b/tests/auto/windowsmobile/test/testSimpleWidget_current.png differ diff --git a/tests/auto/windowsmobile/test/tst_windowsmobile.cpp b/tests/auto/windowsmobile/test/tst_windowsmobile.cpp new file mode 100644 index 0000000..391e206 --- /dev/null +++ b/tests/auto/windowsmobile/test/tst_windowsmobile.cpp @@ -0,0 +1,191 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the test suite 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$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + + + +class tst_WindowsMobile : public QObject +{ + Q_OBJECT +public: + tst_WindowsMobile() + { +#ifdef Q_OS_WINCE_WM + q_initDD(); +#endif + } + +#ifdef Q_OS_WINCE_WM + private slots: + void testMainWindowAndMenuBar(); + void testSimpleWidget(); +#endif +}; + +#ifdef Q_OS_WINCE_WM + +bool qt_wince_is_platform(const QString &platformString) { + TCHAR tszPlatform[64]; + if (SystemParametersInfo(SPI_GETPLATFORMTYPE, + sizeof(tszPlatform)/sizeof(*tszPlatform),tszPlatform,0)) + if (0 == _tcsicmp(reinterpret_cast (platformString.utf16()), tszPlatform)) + return true; + return false; +} + +bool qt_wince_is_smartphone() { + return qt_wince_is_platform(QString::fromLatin1("Smartphone")); +} + +void openMenu() +{ + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,450,630,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,450,630,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,65535,65535,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,65535,65535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,55535,55535,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,55535,55535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,55535,58535,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,55535,58535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,40535,55535,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,40535,55535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,32535,55535,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,32535,55535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,65535,65535,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,65535,65535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,55535,50535,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,55535,50535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,55535,40535,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,55535,40535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,48535,45535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,48535,45535,0,0); +} + +void compareScreenshots(const QString &image1, const QString &image2) +{ + if (qt_wince_is_smartphone()) + QSKIP("This test is only for Windows Mobile", SkipAll); + QImage screenShot(image1); + QImage original(image2); + + //ignore the clock + QPainter p1(&screenShot); + QPainter p2(&original); + p1.fillRect(310, 6, 400, 34, Qt::black); + p2.fillRect(310, 6, 400, 34, Qt::black); + + QVERIFY(original == screenShot); +} + +void takeScreenShot(const QString filename) +{ + q_lock(); + QImage image = QImage(( uchar *) q_frameBuffer(), q_screenWidth(), + q_screenHeight(), q_screenWidth() * q_screenDepth() / 8, QImage::Format_RGB16); + image.save(filename, "PNG"); + q_unlock(); +} + +void tst_WindowsMobile::testMainWindowAndMenuBar() +{ + QProcess process; + process.start("testQMenuBar.exe"); + QCOMPARE(process.state(), QProcess::Running); + QTest::qWait(6000); + openMenu(); + QTest::qWait(1000); + takeScreenShot("testQMenuBar_current.png"); + process.close(); + compareScreenshots("testQMenuBar_current.png", ":/testQMenuBar_current.png"); +} + +void tst_WindowsMobile::testSimpleWidget() +{ + QMenuBar menubar; + menubar.show(); + QWidget maximized; + QPalette pal = maximized.palette(); + pal.setColor(QPalette::Background, Qt::red); + maximized.setPalette(pal); + maximized.showMaximized(); + QWidget widget; + widget.setGeometry(100, 100, 200, 200); + widget.setWindowTitle("Widget"); + widget.show(); + qApp->processEvents(); + QTest::qWait(1000); + + QWidget widget2; + widget2.setGeometry(100, 380, 300, 200); + widget2.setWindowTitle("Widget 2"); + widget2.setWindowFlags(Qt::Popup); + widget2.show(); + + qApp->processEvents(); + QTest::qWait(1000); + takeScreenShot("testSimpleWidget_current.png"); + compareScreenshots("testSimpleWidget_current.png", ":/testSimpleWidget_current.png"); +} + + +#endif //Q_OS_WINCE_WM + + +QTEST_MAIN(tst_WindowsMobile) +#include "tst_windowsmobile.moc" + diff --git a/tests/auto/windowsmobile/test/windowsmobile.qrc b/tests/auto/windowsmobile/test/windowsmobile.qrc new file mode 100644 index 0000000..5d6f614 --- /dev/null +++ b/tests/auto/windowsmobile/test/windowsmobile.qrc @@ -0,0 +1,6 @@ + + + testQMenuBar_current.png + testSimpleWidget_current.png + + diff --git a/tests/auto/windowsmobile/testQMenuBar/main.cpp b/tests/auto/windowsmobile/testQMenuBar/main.cpp new file mode 100644 index 0000000..4a3b3b2 --- /dev/null +++ b/tests/auto/windowsmobile/testQMenuBar/main.cpp @@ -0,0 +1,72 @@ +#include +#include +#include +#include +#include +#include + +int main(int argc, char * argv[]) +{ + int widgetNum = 20; + + QList widgets; + QApplication app(argc, argv); + + QMainWindow mainWindow; + mainWindow.setWindowTitle("Test"); + QMenu *fileMenu = mainWindow.menuBar()->addMenu("File"); + QMenu *editMenu = mainWindow.menuBar()->addMenu("Edit"); + QMenu *viewMenu = mainWindow.menuBar()->addMenu("View"); + QMenu *toolsMenu = mainWindow.menuBar()->addMenu("Tools"); + QMenu *optionsMenu = mainWindow.menuBar()->addMenu("Options"); + QMenu *helpMenu = mainWindow.menuBar()->addMenu("Help"); + + qApp->processEvents(); + + fileMenu->addAction("Open"); + QAction *close = fileMenu->addAction("Close"); + fileMenu->addSeparator(); + fileMenu->addAction("Exit"); + + close->setEnabled(false); + + editMenu->addAction("Cut"); + editMenu->addAction("Pase"); + editMenu->addAction("Copy"); + editMenu->addSeparator(); + editMenu->addAction("Find"); + + viewMenu->addAction("Hide"); + viewMenu->addAction("Show"); + viewMenu->addAction("Explore"); + QAction *visible = viewMenu->addAction("Visible"); + visible->setCheckable(true); + visible->setChecked(true); + + toolsMenu->addMenu("Hammer"); + toolsMenu->addMenu("Caliper"); + toolsMenu->addMenu("Helm"); + + optionsMenu->addMenu("Settings"); + optionsMenu->addMenu("Standard"); + optionsMenu->addMenu("Extended"); + + QMenu *subMenu = helpMenu->addMenu("Help"); + subMenu->addAction("Index"); + subMenu->addSeparator(); + subMenu->addAction("Vodoo Help"); + helpMenu->addAction("Contens"); + helpMenu->addSeparator(); + helpMenu->addAction("About"); + + QToolBar toolbar; + mainWindow.addToolBar(&toolbar); + toolbar.addAction(QIcon(qApp->style()->standardPixmap(QStyle::SP_FileIcon)), QString("textAction")); + + QTextEdit textEdit; + mainWindow.setCentralWidget(&textEdit); + + mainWindow.showMaximized(); + + app.exec(); +} diff --git a/tests/auto/windowsmobile/testQMenuBar/testQMenuBar.pro b/tests/auto/windowsmobile/testQMenuBar/testQMenuBar.pro new file mode 100644 index 0000000..6dd288b --- /dev/null +++ b/tests/auto/windowsmobile/testQMenuBar/testQMenuBar.pro @@ -0,0 +1,2 @@ +SOURCES += main.cpp +DESTDIR = ./ diff --git a/tests/auto/windowsmobile/windowsmobile.pro b/tests/auto/windowsmobile/windowsmobile.pro new file mode 100644 index 0000000..2e6b444 --- /dev/null +++ b/tests/auto/windowsmobile/windowsmobile.pro @@ -0,0 +1,9 @@ + +TEMPLATE = subdirs + +wincewm* { + SUBDIRS = testQMenuBar +} + SUBDIRS += test + + -- cgit v0.12 From 1a18308b311f031d001e3b3e98ffb61e840a6d8c Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Thu, 30 Apr 2009 14:35:46 +0200 Subject: QNetworkCookieJar: allow cookies with wrong domain attribute According to the (old) cookie RFC 2109, the domain attribute must always contain a leading dot. Some servers do not have that, but all browsers accept those cookies anyway, so we should do that as well. Reviewed-by: Olivier Reviewed-by: Denis Task-number: 228974 --- src/network/access/qnetworkcookie.cpp | 9 ++++----- tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 01a743b..aaa5075 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -976,14 +976,14 @@ QList QNetworkCookie::parseCookies(const QByteArray &cookieStrin cookie.setExpirationDate(dt); } else if (field.first == "domain") { QByteArray rawDomain = field.second; - QString maybeLeadingDot; if (rawDomain.startsWith('.')) { - maybeLeadingDot = QLatin1Char('.'); rawDomain = rawDomain.mid(1); } - QString normalizedDomain = QUrl::fromAce(QUrl::toAce(QString::fromUtf8(rawDomain))); - cookie.setDomain(maybeLeadingDot + normalizedDomain); + // always add the dot, there are some servers that forget the + // leading dot. This is actually forbidden according to RFC 2109, + // but all browsers accept it anyway so we do that as well + cookie.setDomain(QLatin1Char('.') + normalizedDomain); } else if (field.first == "max-age") { bool ok = false; int secs = field.second.toInt(&ok); @@ -1184,7 +1184,6 @@ bool QNetworkCookieJar::setCookiesFromUrl(const QList &cookieLis cookie.expirationDate() < now; // validate the cookie & set the defaults if unset - // (RFC 2965: "The request-URI MUST path-match the Path attribute of the cookie.") if (cookie.path().isEmpty()) cookie.setPath(defaultPath); else if (!isParentPath(pathAndFileName, cookie.path())) diff --git a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp index 36a4b45..4ee5b9f 100644 --- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp +++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp @@ -234,7 +234,7 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("path-with-utf8-2") << "a=b;path=/R%C3%A9sum%C3%A9" << cookie; cookie.setPath(QString()); - cookie.setDomain("trolltech.com"); + cookie.setDomain(".trolltech.com"); QTest::newRow("plain-domain1") << "a=b;domain=trolltech.com" << cookie; QTest::newRow("plain-domain2") << "a=b; domain=trolltech.com " << cookie; QTest::newRow("plain-domain3") << "a=b;domain=TROLLTECH.COM" << cookie; @@ -246,7 +246,7 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("dot-domain3") << "a=b; domain=.TROLLTECH.COM" << cookie; QTest::newRow("dot-domain4") << "a=b; Domain = .TROLLTECH.COM" << cookie; - cookie.setDomain(QString::fromUtf8("d\303\270gn\303\245pent.troll.no")); + cookie.setDomain(QString::fromUtf8(".d\303\270gn\303\245pent.troll.no")); QTest::newRow("idn-domain1") << "a=b;domain=xn--dgnpent-gxa2o.troll.no" << cookie; QTest::newRow("idn-domain2") << "a=b;domain=d\303\270gn\303\245pent.troll.no" << cookie; QTest::newRow("idn-domain3") << "a=b;domain=XN--DGNPENT-GXA2O.TROLL.NO" << cookie; @@ -259,7 +259,7 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("dot-idn-domain3") << "a=b;domain=.XN--DGNPENT-GXA2O.TROLL.NO" << cookie; QTest::newRow("dot-idn-domain4") << "a=b;domain=.D\303\230GN\303\205PENT.troll.NO" << cookie; - cookie.setDomain("trolltech.com"); + cookie.setDomain(".trolltech.com"); cookie.setPath("/"); QTest::newRow("two-fields") << "a=b;domain=trolltech.com;path=/" << cookie; QTest::newRow("two-fields2") << "a=b; domain=trolltech.com; path=/" << cookie; @@ -662,7 +662,7 @@ void tst_QNetworkCookie::parseMultipleCookies_data() QTest::newRow("complex-1") << "c=d, a=, foo=bar; path=/" << list; cookie.setName("baz"); - cookie.setDomain("trolltech.com"); + cookie.setDomain(".trolltech.com"); list.prepend(cookie); QTest::newRow("complex-2") << "baz=bar; path=/; domain=trolltech.com, c=d,a=,foo=bar; path=/" << list; -- cgit v0.12 From 5f7cd6ca85b2cb2dc996f260694255d31670766e Mon Sep 17 00:00:00 2001 From: Bill King Date: Fri, 1 May 2009 14:24:13 +1000 Subject: Apparently this is the best way to determine which to use Best as I can determine via trial and error. It should make vc6 compile again though. --- src/sql/drivers/odbc/qsql_odbc.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 4e90777..9932463 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -70,13 +70,12 @@ QT_BEGIN_NAMESPACE #endif // newer platform SDKs use SQLLEN instead of SQLINTEGER -//#if defined(SQLLEN) || defined(Q_OS_WIN64) -#if ODBCVER >= 0x0270 -# define QSQLLEN SQLLEN -# define QSQLULEN SQLULEN -#else +#if defined(WIN32) && (_MSC_VER < 1300) # define QSQLLEN SQLINTEGER # define QSQLULEN SQLUINTEGER +#else +# define QSQLLEN SQLLEN +# define QSQLULEN SQLULEN #endif -- cgit v0.12 From 1569eaba5eaf99c810d4f205e890b68d069f189b Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 1 May 2009 08:31:32 -0700 Subject: Fixed possible crash in QDirectFBPaintEngine::clip d->clip() might return 0 at this point so make sure we check before accessing it. 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 9e6f821..364c6e1 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -906,7 +906,7 @@ void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) { Q_D(QDirectFBPaintEngine); d->setClipDirty(); - if (!d->clip()->hasRectClip && d->clip()->enabled) { + if (d->clip() && !d->clip()->hasRectClip && d->clip()->enabled) { const QPoint bottom = d->transform.map(QPoint(0, rect.bottom())); if (bottom.y() >= d->lastLockedHeight) d->lock(); -- cgit v0.12 From ab03f0095a09fa961e53f741294ca8a890e1827f Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 1 May 2009 09:42:53 -0700 Subject: Improved readability of the flip code Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp index 257efeb..09b7a30 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp @@ -371,18 +371,13 @@ void QDirectFBSurface::flush(QWidget *widget, const QRegion ®ion, } else { if (region.numRects() > 1) { const QVector rects = region.rects(); - DFBSurfaceFlipFlags tmpFlags = flipFlags; - if (flipFlags & DSFLIP_WAIT) - tmpFlags = DFBSurfaceFlipFlags(flipFlags & ~DSFLIP_WAIT); + const DFBSurfaceFlipFlags nonWaitFlags = DFBSurfaceFlipFlags(flipFlags & ~DSFLIP_WAIT); for (int i=0; iFlip(dfbSurface, &dfbReg, - i + 1 < rects.size() - ? tmpFlags - : flipFlags); + dfbSurface->Flip(dfbSurface, &dfbReg, i + 1 < rects.size() ? nonWaitFlags : flipFlags); } } else { const QRect r = region.boundingRect(); -- cgit v0.12 From 793ea1535f131b4ada2e0049f60cf5e24ad35a7b Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 1 May 2009 10:08:44 -0700 Subject: Cleaned up surface creation code Since I am taking a copy of the description anyway it makes sense to just pass this light-weight object in as a copy rather than a const pointer. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 19 ++++------- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 39 +++++++++++----------- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 2 +- .../gfxdrivers/directfb/qdirectfbsurface.cpp | 2 +- 4 files changed, 28 insertions(+), 34 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 364c6e1..14d2146 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -189,11 +189,10 @@ CachedImage::CachedImage(const QImage &image) : s(0) { IDirectFBSurface *tmpSurface = 0; - DFBSurfaceDescription description; - description = QDirectFBScreen::getSurfaceDescription(image); + DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(image); QDirectFBScreen* screen = QDirectFBScreen::instance(); - tmpSurface = screen->createDFBSurface(&description, QDirectFBScreen::TrackSurface); + tmpSurface = screen->createDFBSurface(description, QDirectFBScreen::TrackSurface); if (!tmpSurface) { qWarning("CachedImage CreateSurface failed!"); return; @@ -205,7 +204,7 @@ CachedImage::CachedImage(const QImage &image) description.flags = DFBSurfaceDescriptionFlags(description.flags & ~DSDESC_PREALLOCATED); - s = screen->createDFBSurface(&description, QDirectFBScreen::TrackSurface); + s = screen->createDFBSurface(description, QDirectFBScreen::TrackSurface); if (!s) qWarning("QDirectFBPaintEngine failed caching image"); @@ -237,10 +236,8 @@ IDirectFBSurface* SurfaceCache::getSurface(const uint *buf, int size) clear(); - DFBSurfaceDescription description; - description = QDirectFBScreen::getSurfaceDescription(buf, size); - - surface = QDirectFBScreen::instance()->createDFBSurface(&description, QDirectFBScreen::TrackSurface); + const DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(buf, size); + surface = QDirectFBScreen::instance()->createDFBSurface(description, QDirectFBScreen::TrackSurface); if (!surface) qWarning("QDirectFBPaintEngine: SurfaceCache: Unable to create surface"); @@ -736,10 +733,8 @@ void QDirectFBPaintEnginePrivate::drawImage(const QRectF &dest, } if (!imgSurface) { - DFBSurfaceDescription description; - - description = QDirectFBScreen::getSurfaceDescription(image); - imgSurface = QDirectFBScreen::instance()->createDFBSurface(&description, + DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(image); + imgSurface = QDirectFBScreen::instance()->createDFBSurface(description, QDirectFBScreen::DontTrackSurface); if (!imgSurface) { qWarning("QDirectFBPaintEnginePrivate::drawImage"); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index a53b1c0..e2324ff 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -155,8 +155,7 @@ IDirectFBSurface* QDirectFBScreen::createDFBSurface(const QImage &img, SurfaceCr return surface; } - DFBSurfaceDescription desc = QDirectFBScreen::getSurfaceDescription(img); - IDirectFBSurface *surface = createDFBSurface(&desc, options); + IDirectFBSurface *surface = createDFBSurface(QDirectFBScreen::getSurfaceDescription(img), options); #ifdef QT_NO_DIRECTFB_PREALLOCATED if (surface) { int bpl; @@ -211,11 +210,11 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QSize &size, return 0; desc.width = size.width(); desc.height = size.height(); - return createDFBSurface(&desc, options); + return createDFBSurface(desc, options); } -IDirectFBSurface* QDirectFBScreen::createDFBSurface(const DFBSurfaceDescription *desc, SurfaceCreationOptions options) +IDirectFBSurface* QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, SurfaceCreationOptions options) { DFBResult result; IDirectFBSurface* newSurface = 0; @@ -225,39 +224,39 @@ IDirectFBSurface* QDirectFBScreen::createDFBSurface(const DFBSurfaceDescription return 0; } - if (d_ptr->directFBFlags & VideoOnly && !(desc->flags & DSDESC_PREALLOCATED)) { + if (d_ptr->directFBFlags & VideoOnly && !(desc.flags & DSDESC_PREALLOCATED)) { // Add the video only capability. This means the surface will be created in video ram - DFBSurfaceDescription voDesc = *desc; - if (!(voDesc.flags & DSDESC_CAPS)) { - voDesc.caps = DSCAPS_VIDEOONLY; - voDesc.flags = DFBSurfaceDescriptionFlags(voDesc.flags | DSDESC_CAPS); + if (!(desc.flags & DSDESC_CAPS)) { + desc.caps = DSCAPS_VIDEOONLY; + desc.flags = DFBSurfaceDescriptionFlags(desc.flags | DSDESC_CAPS); } else { - voDesc.caps = DFBSurfaceCapabilities(voDesc.caps | DSCAPS_VIDEOONLY); + desc.caps = DFBSurfaceCapabilities(desc.caps | DSCAPS_VIDEOONLY); } - result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &voDesc, &newSurface); + result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &desc, &newSurface); if (result != DFB_OK #ifdef QT_NO_DEBUG - && (desc->flags & DSDESC_CAPS) && (desc->caps & DSCAPS_PRIMARY) + && (desc.flags & DSDESC_CAPS) && (desc.caps & DSCAPS_PRIMARY) #endif ) { qWarning("QDirectFBScreen::createDFBSurface() Failed to create surface in video memory!\n" " Flags %0x Caps %0x width %d height %d pixelformat %0x %d preallocated %p %d\n%s", - desc->flags, desc->caps, desc->width, desc->height, - desc->pixelformat, DFB_PIXELFORMAT_INDEX(desc->pixelformat), - desc->preallocated[0].data, desc->preallocated[0].pitch, + desc.flags, desc.caps, desc.width, desc.height, + desc.pixelformat, DFB_PIXELFORMAT_INDEX(desc.pixelformat), + desc.preallocated[0].data, desc.preallocated[0].pitch, DirectFBErrorString(result)); } + desc.caps = DFBSurfaceCapabilities(desc.caps & ~DSCAPS_VIDEOONLY); } if (!newSurface) - result = d_ptr->dfb->CreateSurface(d_ptr->dfb, desc, &newSurface); + result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &desc, &newSurface); if (result != DFB_OK) { qWarning("QDirectFBScreen::createDFBSurface() Failed!\n" " Flags %0x Caps %0x width %d height %d pixelformat %0x %d preallocated %p %d\n%s", - desc->flags, desc->caps, desc->width, desc->height, - desc->pixelformat, DFB_PIXELFORMAT_INDEX(desc->pixelformat), - desc->preallocated[0].data, desc->preallocated[0].pitch, + desc.flags, desc.caps, desc.width, desc.height, + desc.pixelformat, DFB_PIXELFORMAT_INDEX(desc.pixelformat), + desc.preallocated[0].data, desc.preallocated[0].pitch, DirectFBErrorString(result)); return 0; } @@ -830,7 +829,7 @@ bool QDirectFBScreen::connect(const QString &displaySpec) description.caps = DFBSurfaceCapabilities(caps); // We don't track the primary surface as it's released in disconnect - d_ptr->dfbSurface = createDFBSurface(&description, DontTrackSurface); + d_ptr->dfbSurface = createDFBSurface(description, DontTrackSurface); if (!d_ptr->dfbSurface) { DirectFBError("QDirectFBScreen: error creating primary surface", result); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 8e75277..5e948ee 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -103,7 +103,7 @@ public: TrackSurface = 1 }; Q_DECLARE_FLAGS(SurfaceCreationOptions, SurfaceCreationOption); - IDirectFBSurface *createDFBSurface(const DFBSurfaceDescription *desc, + IDirectFBSurface *createDFBSurface(DFBSurfaceDescription desc, SurfaceCreationOptions options); IDirectFBSurface *createDFBSurface(const QImage &image, SurfaceCreationOptions options); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp index 09b7a30..6167980 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp @@ -184,7 +184,7 @@ void QDirectFBSurface::setGeometry(const QRect &rect, const QRegion &mask) description.height = rect.height(); QDirectFBScreen::initSurfaceDescriptionPixelFormat(&description, screen->pixelFormat()); - dfbSurface = screen->createDFBSurface(&description, false); + dfbSurface = screen->createDFBSurface(description, false); forceRaster = (dfbSurface && QDirectFBScreen::getImageFormat(dfbSurface) == QImage::Format_RGB32); } else { Q_ASSERT(dfbSurface); -- cgit v0.12 From a8692a079d0509fcfc45843dc68518007df27fbb Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 1 May 2009 10:20:53 -0700 Subject: Extended surface capabilities Clean up code and make it possible to set more DFBSurfaceCapabilities on the primary surface. Also allow users to force systemonly for the surfaces. --- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 34 ++++++++++++++++++---- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 3 +- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index e2324ff..858a958 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -214,10 +214,10 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QSize &size, } -IDirectFBSurface* QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, SurfaceCreationOptions options) +IDirectFBSurface *QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, SurfaceCreationOptions options) { - DFBResult result; - IDirectFBSurface* newSurface = 0; + DFBResult result = DFB_OK; + IDirectFBSurface *newSurface = 0; if (!d_ptr->dfb) { qWarning("QDirectFBScreen::createDFBSurface() - not connected"); @@ -247,6 +247,8 @@ IDirectFBSurface* QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, } desc.caps = DFBSurfaceCapabilities(desc.caps & ~DSCAPS_VIDEOONLY); } + if (d_ptr->directFBFlags & SystemOnly) + desc.caps = DFBSurfaceCapabilities(desc.caps | DSCAPS_SYSTEMONLY); if (!newSurface) result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &desc, &newSurface); @@ -805,6 +807,14 @@ bool QDirectFBScreen::connect(const QString &displaySpec) if (displayArgs.contains(QLatin1String("videoonly"), Qt::CaseInsensitive)) d_ptr->directFBFlags |= VideoOnly; + if (displayArgs.contains(QLatin1String("systemonly"), Qt::CaseInsensitive)) { + if (d_ptr->directFBFlags & VideoOnly) { + qWarning("QDirectFBScreen: error. videoonly and systemonly are mutually exclusive"); + } else { + d_ptr->directFBFlags |= SystemOnly; + } + } + if (displayArgs.contains(QLatin1String("ignoresystemclip"), Qt::CaseInsensitive)) d_ptr->directFBFlags |= IgnoreSystemClip; @@ -819,9 +829,23 @@ bool QDirectFBScreen::connect(const QString &displaySpec) description.flags = DFBSurfaceDescriptionFlags(description.flags | DSDESC_WIDTH); if (::setIntOption(displayArgs, QLatin1String("height"), &description.height)) description.flags = DFBSurfaceDescriptionFlags(description.flags | DSDESC_HEIGHT); + uint caps = DSCAPS_PRIMARY|DSCAPS_DOUBLE; - if (displayArgs.contains(QLatin1String("static_alloc"))) - caps |= DSCAPS_STATIC_ALLOC; + struct { + const char *name; + const DFBSurfaceCapabilities cap; + } const capabilities[] = { + { "static_alloc", DSCAPS_STATIC_ALLOC }, + { "triplebuffer", DSCAPS_TRIPLE }, + { "interlaced", DSCAPS_INTERLACED }, + { "separated", DSCAPS_SEPARATED }, +// { "depthbuffer", DSCAPS_DEPTH }, // only makes sense with TextureTriangles which are not supported + { 0, DSCAPS_NONE } + }; + for (int i=0; capabilities[i].name; ++i) { + if (displayArgs.contains(QString::fromLatin1(capabilities[i].name), Qt::CaseInsensitive)) + caps |= capabilities[i].cap; + } if (displayArgs.contains(QLatin1String("forcepremultiplied"), Qt::CaseInsensitive)) { caps |= DSCAPS_PREMULTIPLIED; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 5e948ee..6b3a975 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -62,7 +62,8 @@ public: enum DirectFBFlag { NoFlags = 0x00, VideoOnly = 0x01, - IgnoreSystemClip = 0x02 + SystemOnly = 0x02, + IgnoreSystemClip = 0x04 }; Q_DECLARE_FLAGS(DirectFBFlags, DirectFBFlag); -- cgit v0.12 From 8895643e1bd4b784a614bc8f275bb2e63dc2d9f8 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 1 May 2009 11:07:49 -0700 Subject: Improve debug output (in debug mode only) Print out detailed information about acceleration mask, blitting flags and drawing flags when passing debug. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 85 +++++++++++++++++++++- 1 file changed, 83 insertions(+), 2 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 858a958..4ce549d 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -739,6 +739,84 @@ QPixmapData* QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType typ return new QDirectFBPixmapData(type); } +#ifdef QT_NO_DEBUG +struct FlagDescription; +static const FlagDescription *accelerationDescriptions = 0; +static const FlagDescription *blitDescriptions = 0; +static const FlagDescription *drawDescriptions = 0; +#else +struct FlagDescription { + const char *name; + uint flag; +}; + +static const FlagDescription accelerationDescriptions[] = { + { "DFXL_NONE ", DFXL_NONE }, + { "DFXL_FILLRECTANGLE", DFXL_FILLRECTANGLE }, + { "DFXL_DRAWRECTANGLE", DFXL_DRAWRECTANGLE }, + { "DFXL_DRAWLINE", DFXL_DRAWLINE }, + { "DFXL_FILLTRIANGLE", DFXL_FILLTRIANGLE }, + { "DFXL_BLIT", DFXL_BLIT }, + { "DFXL_STRETCHBLIT", DFXL_STRETCHBLIT }, + { "DFXL_TEXTRIANGLES", DFXL_TEXTRIANGLES }, + { "DFXL_DRAWSTRING", DFXL_DRAWSTRING }, + { 0, 0 } +}; + +static const FlagDescription blitDescriptions[] = { + { "DSBLIT_NOFX", DSBLIT_NOFX }, + { "DSBLIT_BLEND_ALPHACHANNEL", DSBLIT_BLEND_ALPHACHANNEL }, + { "DSBLIT_BLEND_COLORALPHA", DSBLIT_BLEND_COLORALPHA }, + { "DSBLIT_COLORIZE", DSBLIT_COLORIZE }, + { "DSBLIT_SRC_COLORKEY", DSBLIT_SRC_COLORKEY }, + { "DSBLIT_DST_COLORKEY", DSBLIT_DST_COLORKEY }, + { "DSBLIT_SRC_PREMULTIPLY", DSBLIT_SRC_PREMULTIPLY }, + { "DSBLIT_DST_PREMULTIPLY", DSBLIT_DST_PREMULTIPLY }, + { "DSBLIT_DEMULTIPLY", DSBLIT_DEMULTIPLY }, + { "DSBLIT_DEINTERLACE", DSBLIT_DEINTERLACE }, + { "DSBLIT_SRC_PREMULTCOLOR", DSBLIT_SRC_PREMULTCOLOR }, + { "DSBLIT_XOR", DSBLIT_XOR }, + { "DSBLIT_INDEX_TRANSLATION", DSBLIT_INDEX_TRANSLATION }, + { 0, 0 } +}; + +static const FlagDescription drawDescriptions[] = { + { "DSDRAW_NOFX", DSDRAW_NOFX }, + { "DSDRAW_BLEND", DSDRAW_BLEND }, + { "DSDRAW_DST_COLORKEY", DSDRAW_DST_COLORKEY }, + { "DSDRAW_SRC_PREMULTIPLY", DSDRAW_SRC_PREMULTIPLY }, + { "DSDRAW_DST_PREMULTIPLY", DSDRAW_DST_PREMULTIPLY }, + { "DSDRAW_DEMULTIPLY", DSDRAW_DEMULTIPLY }, + { "DSDRAW_XOR", DSDRAW_XOR }, + { 0, 0 } +}; +#endif + + + +static const QByteArray flagDescriptions(uint mask, const FlagDescription *flags) +{ +#ifdef QT_NO_DEBUG + Q_UNUSED(mask); + Q_UNUSED(flags); + return QByteArray(""); +#else + if (!mask) + return flags[0].name; + + QStringList list; + for (int i=1; flags[i].name; ++i) { + if (mask & flags[i].flag) { + list.append(QString::fromLatin1(flags[i].name)); + } + } + Q_ASSERT(!list.isEmpty()); + return (QLatin1Char(' ') + list.join(QLatin1String("|"))).toLatin1(); +#endif +} + + + static void printDirectFBInfo(IDirectFB *fb) { DFBResult result; @@ -751,10 +829,13 @@ static void printDirectFBInfo(IDirectFB *fb) } qDebug("Device: %s (%s), Driver: %s v%i.%i (%s)\n" - " acceleration: 0x%x, blit: 0x%x, draw: 0x%0x video: %i\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.blitting_flags, dev.drawing_flags, dev.video_memory); + ::flagDescriptions(dev.acceleration_mask, accelerationDescriptions).constData(), + dev.blitting_flags, ::flagDescriptions(dev.blitting_flags, blitDescriptions).constData(), + dev.drawing_flags, ::flagDescriptions(dev.drawing_flags, drawDescriptions).constData(), + (dev.video_memory >> 10)); } static inline bool setIntOption(const QStringList &arguments, const QString &variable, int *value) -- cgit v0.12 From 111b2c3e40cc475d561d578663565e603963d6e3 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Sat, 2 May 2009 14:01:08 -0700 Subject: Beautified code Qt's coding style => Object *ptr, not Object* ptr Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 20 ++++++++++---------- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 14 +++++++------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 4ce549d..f8aaa5f 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -84,7 +84,7 @@ public: QImage::Format alphaPixmapFormat; }; -QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen* screen) +QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *screen) : QWSGraphicsSystem(screen), dfb(0), dfbSurface(0), flipFlags(DSFLIP_NONE) #ifndef QT_NO_DIRECTFB_LAYER , dfbLayer(0) @@ -113,7 +113,7 @@ QDirectFBScreenPrivate::~QDirectFBScreenPrivate() delete keyboard; #endif - foreach (IDirectFBSurface* surf, allocatedSurfaces) + foreach (IDirectFBSurface *surf, allocatedSurfaces) surf->Release(surf); allocatedSurfaces.clear(); @@ -137,7 +137,7 @@ QDirectFBScreenPrivate::~QDirectFBScreenPrivate() // creates a preallocated surface with the same format as the image if // possible. -IDirectFBSurface* QDirectFBScreen::createDFBSurface(const QImage &img, SurfaceCreationOptions options) +IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QImage &img, SurfaceCreationOptions options) { if (img.isNull()) // assert? return 0; @@ -350,18 +350,18 @@ QDirectFBScreen::DirectFBFlags QDirectFBScreen::directFBFlags() const { return d_ptr->directFBFlags; } -IDirectFB* QDirectFBScreen::dfb() +IDirectFB *QDirectFBScreen::dfb() { return d_ptr->dfb; } -IDirectFBSurface* QDirectFBScreen::dfbSurface() +IDirectFBSurface *QDirectFBScreen::dfbSurface() { return d_ptr->dfbSurface; } #ifndef QT_NO_DIRECTFB_LAYER -IDirectFBDisplayLayer* QDirectFBScreen::dfbDisplayLayer() +IDirectFBDisplayLayer *QDirectFBScreen::dfbDisplayLayer() { return d_ptr->dfbLayer; } @@ -731,7 +731,7 @@ void QDirectFBScreenPrivate::setFlipFlags(const QStringList &args) } } -QPixmapData* QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType type) const +QPixmapData *QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType type) const { if (type == QPixmapData::BitmapType) return QWSGraphicsSystem::createPixmapData(type); @@ -1025,7 +1025,7 @@ void QDirectFBScreen::disconnect() d_ptr->dfbSurface->Release(d_ptr->dfbSurface); d_ptr->dfbSurface = 0; - foreach (IDirectFBSurface* surf, d_ptr->allocatedSurfaces) + foreach (IDirectFBSurface *surf, d_ptr->allocatedSurfaces) surf->Release(surf); d_ptr->allocatedSurfaces.clear(); @@ -1094,7 +1094,7 @@ void QDirectFBScreen::blank(bool on) (on ? DSPM_ON : DSPM_SUSPEND)); } -QWSWindowSurface* QDirectFBScreen::createSurface(QWidget *widget) const +QWSWindowSurface *QDirectFBScreen::createSurface(QWidget *widget) const { #ifdef QT_NO_DIRECTFB_WM if (QApplication::type() == QApplication::GuiServer) { @@ -1107,7 +1107,7 @@ QWSWindowSurface* QDirectFBScreen::createSurface(QWidget *widget) const #endif } -QWSWindowSurface* QDirectFBScreen::createSurface(const QString &key) const +QWSWindowSurface *QDirectFBScreen::createSurface(const QString &key) const { if (key == QLatin1String("directfb")) { return new QDirectFBSurface(d_ptr->flipFlags, const_cast(this)); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 6b3a975..8859d58 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -83,19 +83,19 @@ public: void setMode(int width, int height, int depth); void blank(bool on); - QWSWindowSurface* createSurface(QWidget *widget) const; - QWSWindowSurface* createSurface(const QString &key) const; + QWSWindowSurface *createSurface(QWidget *widget) const; + QWSWindowSurface *createSurface(const QString &key) const; - static inline QDirectFBScreen* instance() { + static inline QDirectFBScreen *instance() { QScreen *inst = QScreen::instance(); Q_ASSERT(!inst || inst->classId() == QScreen::DirectFBClass); return static_cast(inst); } - IDirectFB* dfb(); - IDirectFBSurface* dfbSurface(); + IDirectFB *dfb(); + IDirectFBSurface *dfbSurface(); #ifndef QT_NO_DIRECTFB_LAYER - IDirectFBDisplayLayer* dfbDisplayLayer(); + IDirectFBDisplayLayer *dfbDisplayLayer(); #endif // Track surface creation/release so we can release all on exit @@ -117,7 +117,7 @@ public: IDirectFBSurface *copyToDFBSurface(const QImage &image, QImage::Format format, SurfaceCreationOptions options); - void releaseDFBSurface(IDirectFBSurface* surface); + void releaseDFBSurface(IDirectFBSurface *surface); static int depth(DFBSurfacePixelFormat format); -- cgit v0.12 From bdcdb798d2cc4dc48079622a9c3cbe61be82e80b Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Sun, 3 May 2009 17:34:21 -0700 Subject: Implemented an option to tune flipping export QWS_DISPLAY=directfb:boundingrectflip to enable calling Flip on the bounding rect of the dirtied area rather than each dirty rectangle. This could be faster if you update many small rectangles. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 4 ++++ src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 3 ++- src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp | 6 ++++-- src/plugins/gfxdrivers/directfb/qdirectfbsurface.h | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index f8aaa5f..c1b75c5 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -896,6 +896,10 @@ bool QDirectFBScreen::connect(const QString &displaySpec) } } + if (displayArgs.contains(QLatin1String("boundingrectflip"), Qt::CaseInsensitive)) { + d_ptr->directFBFlags |= BoundingRectFlip; + } + if (displayArgs.contains(QLatin1String("ignoresystemclip"), Qt::CaseInsensitive)) d_ptr->directFBFlags |= IgnoreSystemClip; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 8859d58..42d0ebe 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -63,7 +63,8 @@ public: NoFlags = 0x00, VideoOnly = 0x01, SystemOnly = 0x02, - IgnoreSystemClip = 0x04 + IgnoreSystemClip = 0x04, + BoundingRectFlip = 0x08 }; Q_DECLARE_FLAGS(DirectFBFlags, DirectFBFlag); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp index 6167980..beb9b5f 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp @@ -50,13 +50,14 @@ //#define QT_DIRECTFB_DEBUG_SURFACES 1 -QDirectFBSurface::QDirectFBSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen* scr) +QDirectFBSurface::QDirectFBSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr) : QDirectFBPaintDevice(scr) #ifndef QT_NO_DIRECTFB_WM , dfbWindow(0) #endif , engine(0) , flipFlags(flip) + , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) { setSurfaceFlags(Opaque | Buffered); #ifdef QT_DIRECTFB_TIMING @@ -72,6 +73,7 @@ QDirectFBSurface::QDirectFBSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *sc #endif , engine(0) , flipFlags(flip) + , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) { onscreen = widget->testAttribute(Qt::WA_PaintOnScreen); if (onscreen) @@ -369,7 +371,7 @@ void QDirectFBSurface::flush(QWidget *widget, const QRegion ®ion, if (!(flipFlags & DSFLIP_BLIT)) { dfbSurface->Flip(dfbSurface, 0, flipFlags); } else { - if (region.numRects() > 1) { + if (!boundingRectFlip && region.numRects() > 1) { const QVector rects = region.rects(); const DFBSurfaceFlipFlags nonWaitFlags = DFBSurfaceFlipFlags(flipFlags & ~DSFLIP_WAIT); for (int i=0; i bufferImages; DFBSurfaceFlipFlags flipFlags; + bool boundingRectFlip; #ifdef QT_DIRECTFB_TIMING int frames; QTime timer; -- cgit v0.12 From 279a45131ba60fad9f429c7c429271da5b9cc9ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Mon, 4 May 2009 09:44:08 +0200 Subject: Make comment explaning the Mac deployment target setting clearer. --- configure | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/configure b/configure index b582d85..07a9415 100755 --- a/configure +++ b/configure @@ -6004,10 +6004,11 @@ if [ "$CFG_EXCEPTIONS" = "no" ]; then QMAKE_CONFIG="$QMAKE_CONFIG exceptions_off" fi -# On Mac, set the minimum deployment target using Xarch when that is supported (10.5 and up). -# On 10.4 the deployment version is set to 10.3 globally using the QMAKE_MACOSX_DEPLOYMENT_TARGET env. variable -# "-cocoa" on the command line means Cocoa is used in 32-bit mode also, in this case fall back on -# QMAKE_MACOSX_DEPLOYMENT_TARGET which will be set to 10.5. +# On Mac, set the minimum deployment target for the different architechtures +# using the Xarch compiler option when supported (10.5 and up). On 10.4 the +# deployment version is set to 10.3 globally using the QMAKE_MACOSX_DEPLOYMENT_TARGET +# env. variable. "-cocoa" on the command line means Cocoa is used in 32-bit mode also, +# in this case fall back on QMAKE_MACOSX_DEPLOYMENT_TARGET which will be set to 10.5. if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_XARCH" != "no" ] && [ "$COMMANDLINE_MAC_COCOA" != "yes" ]; then if echo "$CFG_MAC_ARCHS" | grep '\' > /dev/null 2>&1; then QMakeVar add QMAKE_CFLAGS "-Xarch_i386 -mmacosx-version-min=10.4" -- cgit v0.12 From aa077a8bd3ee3a134629ef6ac2367b7f11593724 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 4 May 2009 10:44:53 +0200 Subject: Do not crash when passing wrong indexes to QSortFilterProxyModel::indexFomSource and *ToSource Show a warning instead Task-number: 252507 Reviewed-by: Marius Bugge Monsen --- src/gui/itemviews/qsortfilterproxymodel.cpp | 9 +++++++++ .../tst_qsortfilterproxymodel.cpp | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp index 91431c4..43feda8 100644 --- a/src/gui/itemviews/qsortfilterproxymodel.cpp +++ b/src/gui/itemviews/qsortfilterproxymodel.cpp @@ -144,6 +144,7 @@ public: const QModelIndex &proxy_index) const { Q_ASSERT(proxy_index.isValid()); + Q_ASSERT(proxy_index.model() == q_func()); const void *p = proxy_index.internalPointer(); Q_ASSERT(p); QMap::const_iterator it = @@ -311,6 +312,10 @@ QModelIndex QSortFilterProxyModelPrivate::proxy_to_source(const QModelIndex &pro { if (!proxy_index.isValid()) return QModelIndex(); // for now; we may want to be able to set a root index later + if (proxy_index.model() != q_func()) { + qWarning() << "QSortFilterProxyModel: index from wrong model passed to mapToSource"; + return QModelIndex(); + } IndexMap::const_iterator it = index_to_iterator(proxy_index); Mapping *m = it.value(); if ((proxy_index.row() >= m->source_rows.size()) || (proxy_index.column() >= m->source_columns.size())) @@ -324,6 +329,10 @@ QModelIndex QSortFilterProxyModelPrivate::source_to_proxy(const QModelIndex &sou { if (!source_index.isValid()) return QModelIndex(); // for now; we may want to be able to set a root index later + if (source_index.model() != model) { + qWarning() << "QSortFilterProxyModel: index from wrong model passed to mapFromSource"; + return QModelIndex(); + } QModelIndex source_parent = source_index.parent(); IndexMap::const_iterator it = create_mapping(source_parent); Mapping *m = it.value(); diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 18aa5fc..bd66fdf 100644 --- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -133,6 +133,7 @@ private slots: void task248868_dynamicSorting(); void task250023_fetchMore(); void task251296_hiddenChildren(); + void task252507_mapFromToSource(); protected: void buildHierarchy(const QStringList &data, QAbstractItemModel *model); @@ -2612,6 +2613,7 @@ class QtTestModel: public QAbstractItemModel return fetched.contains(parent) ? rows : 0; } int columnCount(const QModelIndex& parent = QModelIndex()) const { + Q_UNUSED(parent); return cols; } @@ -2717,6 +2719,22 @@ void tst_QSortFilterProxyModel::task251296_hiddenChildren() QCOMPARE(proxy.data(indexC).toString(), QString::fromLatin1("C VISIBLE")); } +void tst_QSortFilterProxyModel::task252507_mapFromToSource() +{ + QtTestModel source(10,10); + source.fetchMore(QModelIndex()); + QSortFilterProxyModel proxy; + proxy.setSourceModel(&source); + QCOMPARE(proxy.mapFromSource(source.index(5, 4)), proxy.index(5, 4)); + QCOMPARE(proxy.mapToSource(proxy.index(3, 2)), source.index(3, 2)); + QCOMPARE(proxy.mapFromSource(QModelIndex()), QModelIndex()); + QCOMPARE(proxy.mapToSource(QModelIndex()), QModelIndex()); + + QTest::ignoreMessage(QtWarningMsg, "QSortFilterProxyModel: index from wrong model passed to mapToSource "); + QCOMPARE(proxy.mapToSource(source.index(2, 3)), QModelIndex()); + QTest::ignoreMessage(QtWarningMsg, "QSortFilterProxyModel: index from wrong model passed to mapFromSource "); + QCOMPARE(proxy.mapFromSource(proxy.index(6, 2)), QModelIndex()); +} QTEST_MAIN(tst_QSortFilterProxyModel) #include "tst_qsortfilterproxymodel.moc" -- cgit v0.12 From e223a450ce57a7dc627e0eac14cea019f99fe601 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Mon, 4 May 2009 13:13:51 +0200 Subject: Added comment to clearify the use of indexes. Added a comment about the use of negative indexes. Task-number: 249344 Rev-by: Marius Storm-Olsen --- src/corelib/tools/qlistdata.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/corelib/tools/qlistdata.cpp b/src/corelib/tools/qlistdata.cpp index d7c39a7..d40b6b6 100644 --- a/src/corelib/tools/qlistdata.cpp +++ b/src/corelib/tools/qlistdata.cpp @@ -764,6 +764,10 @@ void **QListData::erase(void **xi) This function requires the value type to have an implementation of \c operator==(). + Note that QList uses 0-based indexes, just like C++ arrays. Negative + indexes are not supported with the exception of the value mentioned + above. + \sa lastIndexOf(), contains() */ @@ -780,6 +784,10 @@ void **QListData::erase(void **xi) This function requires the value type to have an implementation of \c operator==(). + Note that QList uses 0-based indexes, just like C++ arrays. Negative + indexes are not supported with the exception of the value mentioned + above. + \sa indexOf() */ -- cgit v0.12 From f51ce7c1b349b31f61df48786148c8b3525e2a2c Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Mon, 4 May 2009 13:30:07 +0200 Subject: Doc - Clarifying how to override a Widget's size hint in the Getting to Know Qt Designer document. Task-number: 165435 Reviewed-by: Friedemann Kleint --- doc/src/designer-manual.qdoc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/src/designer-manual.qdoc b/doc/src/designer-manual.qdoc index e10a5be..03b74e6 100644 --- a/doc/src/designer-manual.qdoc +++ b/doc/src/designer-manual.qdoc @@ -344,10 +344,14 @@ of a QLineEdit or the width and height of item view widgets. This is where the widget size constraints -- \l{QWidget::minimumSize()}{minimumSize} and \l{QWidget::maximumSize()}{maximumSize} constraints come into play. These - are properties you can set in the property editor. Alternatively, to use - the current size as a size constraint value, choose one of the - \gui{Size Constraint} options from the widget's context menu. The layout - will then ensure that those constraints are met. + are properties you can set in the property editor. For example, to override + the default \l{QWidget::}{sizeHint()}, simply set + \l{QWidget::minimumSize()}{minimumSize} and \l{QWidget::maximumSize()} + {maximumSize} to the same value. Alternatively, to use the current size as + a size constraint value, choose one of the \gui{Size Constraint} options + from the widget's context menu. The layout will then ensure that those + constraints are met. To control the size of your widgets via code, you can + reimplement \l{QWidget::}{sizeHint()} in your code. The screenshot below shows the breakdown of a basic user interface designed using a grid. The coordinates on the screenshot show the position of each -- cgit v0.12 From 80aef133fd2c8da3cc1a6607c1c044eaca768169 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 26 Apr 2009 17:21:24 +0200 Subject: Greatly reduced the complexity of the boilerplate function. I found out that all I needed to load the proper libraries was to add a string to the ".interp" section of the ELF executable containing the path to ld.so Reviewed-By: Marius Storm-Olsen --- src/corelib/global/qlibraryinfo.cpp | 107 ++++++------------------------------ 1 file changed, 17 insertions(+), 90 deletions(-) diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index ada08c7..29e356e 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -485,100 +485,27 @@ QT_END_NAMESPACE #if defined(Q_CC_GNU) && defined(Q_OS_LINUX) && !defined(QT_LINUXBASE) && !defined(QT_BOOTSTRAPPED) -# include -# include - -static const char boilerplate[] = - "This is the QtCore library version " QT_VERSION_STR "\n" - "Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).\n" - "Contact: Qt Software Information (qt-info@nokia.com)\n" - "\n" - "Build key: " QT_BUILD_KEY; - -extern "C" { -void qt_core_init_boilerplate() __attribute__((noreturn)); -} +# include +# include -# if defined(QT_ARCH_I386) -#define sysinit() (void)0 -#define syswrite(msg, len) \ - ({ int res; \ - asm volatile ("movl %%ebx, %%edi\n" \ - "movl $1, %%ebx\n" \ - "int $0x80\n" \ - "movl %%edi, %%ebx\n" \ - : "=a" (res) : "0" (SYS_write), "c" (msg), "d" (len) : "edi"); res; }) -#define sysexit(c) \ - asm ("xor %%ebx, %%ebx\n" \ - "int $0x80\n" \ - : : "a" (SYS_exit)); _exit(c) - -# elif defined(QT_ARCH_X86_64) -#define sysinit() (void)0 -#define syswrite(msg, len) \ - ({ int res; \ - asm volatile ("syscall\n" \ - : "=a" (res) : "0" (SYS_write), "D" (1), "S" (msg), "d" (len) : "rcx"); res; }) -#define sysexit(c) \ - asm ("syscall\n" \ - : : "a" (SYS_exit), "D" (0)); _exit(c) - -# elif defined(QT_ARCH_IA64) -#define sysinit() \ - asm volatile ("{.mlx\n" \ - " nop.m 0\n" \ - " movl r2 = @pcrel(boilerplate);;" \ - "}\n" \ - "{.mii\n" \ - " mov r10 = @ltoffx(boilerplate)\n" \ - " mov r1 = ip\n" \ - " adds r2 = -16, r2\n;;\n" \ - "}\n" \ - " add r1 = r2, r1;;\n" \ - " sub r1 = r1, r10;;\n" \ - : : : "r2", "r10") -#define syswrite(msg, len) \ - ({ const char *_msg = msg; \ - asm ("mov out0=%1\n" \ - "mov out1=%2\n" \ - "mov out2=%3\n" \ - ";;\n" \ - "mov r15=%0\n" \ - "break 0x100000;;\n" \ - : : "I" (SYS_write), "I" (1), "r" (_msg), "r" (len)); }) -#define sysexit(c) \ - asm ("mov out0=%1\n" \ - ";;\n" \ - "mov r15=%0\n" \ - "break 0x100000;;\n" \ - : : "I" (SYS_exit), "O" (0)); write(1, 0, 0); _exit(c) -# else -#define sysinit() (void)0 -#define syswrite(msg, len) (msg); (len) -#define sysexit(c) __builtin_exit(c) -# endif - -#define sysputs(msg) syswrite(msg, -1 + sizeof(msg)) -#define sysendl() syswrite("\n", 1) -#define print_qt_configure(_which) \ - ({const char *which = _which; \ - which += 12; \ - int len = 0; \ - while (which[len]) ++len; \ - syswrite(which, len); }) +extern const char qt_core_interpreter[] __attribute__((section(".interp"))) + = "/lib/ld-linux.so.2"; +extern "C" void qt_core_init_boilerplate() { - sysinit(); - sysputs(boilerplate); - sysputs("\nInstallation prefix: "); - print_qt_configure(qt_configure_prefix_path_str); - sysputs("\nLibrary path: "); - print_qt_configure(qt_configure_libraries_path_str); - sysputs("\nInclude path: "); - print_qt_configure(qt_configure_headers_path_str); - sysendl(); - sysexit(0); + printf("This is the QtCore library version " QT_VERSION_STR "\n" + "Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).\n" + "Contact: Qt Software Information (qt-info@nokia.com)\n" + "\n" + "Build key: " QT_BUILD_KEY "\n" + "Installation prefix: %s\n" + "Library path: %s\n" + "Include path: %s\n", + qt_configure_prefix_path_str + 12, + qt_configure_libraries_path_str + 12, + qt_configure_headers_path_str + 12); + exit(0); } #endif -- cgit v0.12 From 237b4b8c8e9b5184578b4776c5f1f554c0d8efb5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 4 May 2009 11:48:46 +0200 Subject: Fixed D-Bus socket write notifications, broken since d47c05b1 Shame on me: copy/paste from socketRead to socketWrite, I didn't change the DBUS_WATCH_READABLE to DBUS_WATCH_WRITABLE. Reviewed-by: Trust Me --- src/dbus/qdbusintegrator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 8c701f5..2c27381 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1102,7 +1102,7 @@ void QDBusConnectionPrivate::socketWrite(int fd) } for (int i = 0; i < pendingWatches.size(); ++i) - if (!q_dbus_watch_handle(pendingWatches[i], DBUS_WATCH_READABLE)) + if (!q_dbus_watch_handle(pendingWatches[i], DBUS_WATCH_WRITABLE)) qDebug("OUT OF MEM"); } -- cgit v0.12 From ea91eb38d81e37bd12d6abc2604f025ac1d254ce Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Mon, 4 May 2009 13:54:47 +0200 Subject: Ensure that we send the Apple Events even when Cocoa isn't ready. In general, Cocoa handles the the Apple Events for us. However, this is time between creating the NSApplication and Cocoa has set everything up, usually after the event loop is running. This means that until that time, the events are dropped on the floor :-/. The workaround is to use the same handler that we use for Carbon, but to only have it enabled for until Cocoa is ready to handle things. This will result in not stepping on the toes when used in a plugin (if it does, we can conditionalize it). Task-number: 252795 Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qapplication_mac.mm | 32 ++++++++++++++++--------- src/gui/kernel/qcocoaapplicationdelegate_mac.mm | 2 ++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index 5f8c572..69302ec 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -194,8 +194,8 @@ static bool appNoGrab = false; // mouse/keyboard grabbing #ifndef QT_MAC_USE_COCOA static EventHandlerRef app_proc_handler = 0; static EventHandlerUPP app_proc_handlerUPP = 0; -static AEEventHandlerUPP app_proc_ae_handlerUPP = NULL; #endif +static AEEventHandlerUPP app_proc_ae_handlerUPP = NULL; static EventHandlerRef tablet_proximity_handler = 0; static EventHandlerUPP tablet_proximity_UPP = 0; bool QApplicationPrivate::native_modal_dialog_active; @@ -951,7 +951,6 @@ void qt_mac_event_release(QWidget *w) } } -#ifndef QT_MAC_USE_COCOA struct QMacAppleEventTypeSpec { AEEventClass mac_class; AEEventID mac_id; @@ -959,6 +958,7 @@ struct QMacAppleEventTypeSpec { { kCoreEventClass, kAEQuitApplication }, { kCoreEventClass, kAEOpenDocuments } }; +#ifndef QT_MAC_USE_COCOA /* watched events */ static EventTypeSpec app_events[] = { { kEventClassQt, kEventQtRequestWindowChange }, @@ -1156,13 +1156,13 @@ void qt_init(QApplicationPrivate *priv, int) qt_init_app_proc_handler(); } +#endif if (!app_proc_ae_handlerUPP) { app_proc_ae_handlerUPP = AEEventHandlerUPP(QApplicationPrivate::globalAppleEventProcessor); for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i) AEInstallEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id, app_proc_ae_handlerUPP, SRefCon(qApp), true); } -#endif if (QApplicationPrivate::app_style) { QEvent ev(QEvent::Style); @@ -1210,6 +1210,17 @@ void qt_init(QApplicationPrivate *priv, int) } +void qt_release_apple_event_handler() +{ + if(app_proc_ae_handlerUPP) { + for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i) + AERemoveEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id, + app_proc_ae_handlerUPP, true); + DisposeAEEventHandlerUPP(app_proc_ae_handlerUPP); + app_proc_ae_handlerUPP = 0; + } +} + /***************************************************************************** qt_cleanup() - cleans up when the application is finished *****************************************************************************/ @@ -1223,15 +1234,8 @@ void qt_cleanup() DisposeEventHandlerUPP(app_proc_handlerUPP); app_proc_handlerUPP = 0; } - if(app_proc_ae_handlerUPP) { - for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i) - AERemoveEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id, - app_proc_ae_handlerUPP, true); - DisposeAEEventHandlerUPP(app_proc_ae_handlerUPP); - app_proc_ae_handlerUPP = NULL; - } #endif - + qt_release_apple_event_handler(); qt_release_tablet_proximity_handler(); if (tablet_proximity_UPP) DisposeEventHandlerUPP(tablet_proximity_UPP); @@ -2367,6 +2371,12 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event #endif } +// In Carbon this is your one stop for apple events. +// In Cocoa, it ISN'T. This is the catch-all Apple Event handler that exists +// for the time between instantiating the NSApplication, but before the +// NSApplication has installed it's OWN Apple Event handler. When Cocoa has +// that set up, we remove this. So, if you are debugging problems, you likely +// want to check out QCocoaApplicationDelegate instead. OSStatus QApplicationPrivate::globalAppleEventProcessor(const AppleEvent *ae, AppleEvent *, long handlerRefcon) { QApplication *app = (QApplication *)handlerRefcon; diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm index 6571068..dad15d9 100644 --- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm +++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm @@ -204,6 +204,8 @@ static void cleanupCocoaApplicationDelegate() { Q_UNUSED(aNotification); inLaunch = false; + extern void qt_release_apple_event_handler(); //qapplication_mac.mm + qt_release_apple_event_handler(); } - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames -- cgit v0.12 From c368a8ed6badab846c8e63c26d48b95788c12163 Mon Sep 17 00:00:00 2001 From: Trond Kjernaasen Date: Mon, 4 May 2009 14:01:07 +0200 Subject: Added an assert so that QColormap usage without a QApplication asserts. Task-number: 252668 Reviewed-by: Samuel --- src/gui/painting/qcolormap_win.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qcolormap_win.cpp b/src/gui/painting/qcolormap_win.cpp index d61b933..7d36582 100644 --- a/src/gui/painting/qcolormap_win.cpp +++ b/src/gui/painting/qcolormap_win.cpp @@ -138,7 +138,11 @@ void QColormap::cleanup() } QColormap QColormap::instance(int) -{ return QColormap(); } +{ + Q_ASSERT_X(screenMap, "QColormap", + "A QApplication object needs to be constructed before QColormap is used."); + return QColormap(); +} QColormap::QColormap() : d(screenMap) -- cgit v0.12