From 31f1ff91028dd7f90925d5b3737e4d88b5fb07aa Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 16 Oct 2009 16:18:36 +0200 Subject: Send posted events in response to WM_QT_SENDPOSTEDEVENTS (which is just WM_USER+1) Delay the next WM_QT_SENDPOSTEDEVENTS iff there is a WM_TIMER or input event pending We also need to break out of processEvents() after seeing this message, to prevent livelocking in the prescence of fast timers. I also took the liberty of defining WM_QT_SOCKETNOTIFIER (WM_USER) at the same time (to give clear meaning to what WM_USER and WM_USER+1 are used for). Reviewed-by: Prasanth Ullattil --- src/corelib/kernel/qeventdispatcher_win.cpp | 178 +++++++++++++++------------- 1 file changed, 94 insertions(+), 84 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 1e6402f..f7de29d 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -64,6 +64,11 @@ extern uint qGlobalPostedEventsCount(); # define TIME_KILL_SYNCHRONOUS 0x0100 #endif +enum { + WM_QT_SOCKETNOTIFIER = WM_USER, + WM_QT_SENDPOSTEDEVENTS = WM_USER + 1 +}; + #if defined(Q_OS_WINCE) QT_BEGIN_INCLUDE_NAMESPACE #include @@ -327,6 +332,11 @@ public: // internal window handle used for socketnotifiers/timers/etc HWND internalHwnd; + // for controlling when to send posted events + QAtomicInt serialNumber; + int lastSerialNumber; + QAtomicInt wakeUps; + // timers WinTimerVec timerVec; WinTimerDict timerDict; @@ -340,9 +350,6 @@ public: QSNDict sn_except; void doWsaAsyncSelect(int socket); - // event notifier - QWinEventNotifier wakeUpNotifier; - QList winEventNotifierList; void activateEventNotifier(QWinEventNotifier * wen); @@ -351,19 +358,13 @@ public: }; QEventDispatcherWin32Private::QEventDispatcherWin32Private() - : threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0) + : threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0), serialNumber(0), lastSerialNumber(0), wakeUps(0) { resolveTimerAPI(); - - wakeUpNotifier.setHandle(CreateEvent(0, FALSE, FALSE, 0)); - if (!wakeUpNotifier.handle()) - qWarning("QEventDispatcher: Creating QEventDispatcherWin32Private wakeup event failed"); } QEventDispatcherWin32Private::~QEventDispatcherWin32Private() { - wakeUpNotifier.setEnabled(false); - CloseHandle(wakeUpNotifier.handle()); if (internalHwnd) DestroyWindow(internalHwnd); QString className = QLatin1String("QEventDispatcherWin32_Internal_Widget") + QString::number(quintptr(qt_internal_proc)); @@ -408,22 +409,35 @@ void WINAPI CALLBACK qt_fast_timer_proc(uint timerId, uint /*reserved*/, DWORD_P LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp) { - if (message == WM_NCCREATE) { - return true; - } else if (message == WM_USER) { + if (message == WM_NCCREATE) + return true; - // socket notifier message - MSG msg; - msg.hwnd = hwnd; - msg.message = message; - msg.wParam = wp; - msg.lParam = lp; + MSG msg; + msg.hwnd = hwnd; + msg.message = message; + msg.wParam = wp; + msg.lParam = lp; + QCoreApplication *app = QCoreApplication::instance(); + long result; + if (!app) { + if (message == WM_TIMER) + KillTimer(hwnd, wp); + return 0; + } else if (app->filterEvent(&msg, &result)) { + return result; + } - QCoreApplication *app = QCoreApplication::instance(); - long result; - if (app && app->filterEvent(&msg, &result)) - return result; +#ifdef GWLP_USERDATA + QEventDispatcherWin32 *q = (QEventDispatcherWin32 *) GetWindowLongPtr(hwnd, GWLP_USERDATA); +#else + QEventDispatcherWin32 *q = (QEventDispatcherWin32 *) GetWindowLong(hwnd, GWL_USERDATA); +#endif + QEventDispatcherWin32Private *d = 0; + if (q != 0) + d = q->d_func(); + if (message == WM_QT_SOCKETNOTIFIER) { + // socket notifier message int type = -1; switch (WSAGETSELECTEVENT(lp)) { case FD_READ: @@ -440,56 +454,52 @@ LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp) break; } if (type >= 0) { - - #ifdef GWLP_USERDATA - QEventDispatcherWin32 *eventDispatcher = - (QEventDispatcherWin32 *) GetWindowLongPtr(hwnd, GWLP_USERDATA); - #else - QEventDispatcherWin32 *eventDispatcher = - (QEventDispatcherWin32 *) GetWindowLong(hwnd, GWL_USERDATA); - #endif - if (eventDispatcher) { - QEventDispatcherWin32Private *d = eventDispatcher->d_func(); - QSNDict *sn_vec[3] = { &d->sn_read, &d->sn_write, &d->sn_except }; - QSNDict *dict = sn_vec[type]; - - QSockNot *sn = dict ? dict->value(wp) : 0; - if (sn) { - QEvent event(QEvent::SockAct); - QCoreApplication::sendEvent(sn->obj, &event); - } + Q_ASSERT(d != 0); + QSNDict *sn_vec[3] = { &d->sn_read, &d->sn_write, &d->sn_except }; + QSNDict *dict = sn_vec[type]; + + QSockNot *sn = dict ? dict->value(wp) : 0; + if (sn) { + QEvent event(QEvent::SockAct); + QCoreApplication::sendEvent(sn->obj, &event); } } return 0; - - } else if (message == WM_TIMER) { - - MSG msg; - msg.hwnd = hwnd; - msg.message = message; - msg.wParam = wp; - msg.lParam = lp; - - QCoreApplication *app = QCoreApplication::instance(); - Q_ASSERT_X(app, "qt_interal_proc", "Timer fired, but no QCoreApplication"); - if (!app) { - KillTimer(hwnd, wp); - return 0; + } else if (message == WM_TIMER) { + if (wp == ~0u) { + KillTimer(d->internalHwnd, wp); + int localSerialNumber = d->serialNumber; + (void) d->wakeUps.fetchAndStoreRelease(0); + if (localSerialNumber != d->lastSerialNumber) { + PostMessage(d->internalHwnd, WM_QT_SENDPOSTEDEVENTS, 0, 0); + } + } else { + Q_ASSERT(d != 0); + d->sendTimerEvent(wp); + } + return 0; + } else if (message == WM_QT_SENDPOSTEDEVENTS) { + int localSerialNumber = d->serialNumber; + + MSG peeked; + if (PeekMessage(&peeked, d->internalHwnd, WM_TIMER, WM_TIMER, PM_NOREMOVE) + || PeekMessage(&peeked, NULL, 0, 0, PM_NOREMOVE | PM_QS_INPUT)) { + // delay the next pass of sendPostedEvents() until we get the special + // WM_TIMER, which allows all pending Windows messages to be processed + SetTimer(d->internalHwnd, ~0u, 0, 0); + } else { + // nothing pending in the queue, let sendPostedEvents go through + d->wakeUps.fetchAndStoreRelease(0); } - long result; - if (app->filterEvent(&msg, &result)) - return result; - - QEventDispatcherWin32 *eventDispatcher = - qobject_cast(QAbstractEventDispatcher::instance()); - Q_ASSERT(eventDispatcher != 0); - QEventDispatcherWin32Private *d = eventDispatcher->d_func(); - d->sendTimerEvent(wp); + if (localSerialNumber != d->lastSerialNumber) { + d->lastSerialNumber = localSerialNumber; + QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData); + } return 0; } - return DefWindowProc(hwnd, message, wp, lp); + return DefWindowProc(hwnd, message, wp, lp); } static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatcher) @@ -538,11 +548,6 @@ void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t) Q_Q(QEventDispatcherWin32); int ok = 0; - - //in the animation api, we delay the start of the animation - //for the dock widgets, we need to use a system timer because dragging a native window - //makes Windows start its own event loop. - //So if this threshold changes, please change STARTSTOP_TIMER_DELAY in qabstractanimation.cpp accordingly. if (t->interval > 15 || !t->interval || !qtimeSetEvent) { ok = 1; if (!t->interval) // optimization for single-shot-zero-timer @@ -608,7 +613,7 @@ void QEventDispatcherWin32Private::doWsaAsyncSelect(int socket) sn_event |= FD_OOB; // BoundsChecker may emit a warning for WSAAsyncSelect when sn_event == 0 // This is a BoundsChecker bug and not a Qt bug - WSAAsyncSelect(socket, internalHwnd, sn_event ? WM_USER : 0, sn_event); + WSAAsyncSelect(socket, internalHwnd, sn_event ? WM_QT_SOCKETNOTIFIER : 0, sn_event); } void QEventDispatcherWin32::createInternalHwnd() @@ -630,6 +635,9 @@ void QEventDispatcherWin32::createInternalHwnd() // start all normal timers for (int i = 0; i < d->timerVec.count(); ++i) d->registerTimer(d->timerVec.at(i)); + + // trigger a call to sendPostedEvents() + wakeUp(); } QEventDispatcherWin32::QEventDispatcherWin32(QObject *parent) @@ -654,11 +662,10 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) bool canWait; bool retVal = false; do { - QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData); - DWORD waitRet = 0; HANDLE pHandles[MAXIMUM_WAIT_OBJECTS - 1]; QVarLengthArray processedTimers; + bool seenWM_QT_SENDPOSTEDEVENTS = false; while (!d->interrupt) { DWORD nCount = d->winEventNotifierList.count(); Q_ASSERT(nCount < MAXIMUM_WAIT_OBJECTS - 1); @@ -689,7 +696,7 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) d->queuedUserInputEvents.append(msg); } if (haveMessage && (flags & QEventLoop::ExcludeSocketNotifiers) - && (msg.message == WM_USER && msg.hwnd == d->internalHwnd)) { + && (msg.message == WM_QT_SOCKETNOTIFIER && msg.hwnd == d->internalHwnd)) { // queue socket events for later processing haveMessage = false; d->queuedSocketEvents.append(msg); @@ -706,7 +713,13 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) } } if (haveMessage) { - if (msg.message == WM_TIMER) { + if (msg.message == WM_QT_SENDPOSTEDEVENTS && !(flags & QEventLoop::EventLoopExec)) { + if (seenWM_QT_SENDPOSTEDEVENTS) { + PostMessage(d->internalHwnd, WM_QT_SENDPOSTEDEVENTS, 0, 0); + break; + } + seenWM_QT_SENDPOSTEDEVENTS = true; + } else if (msg.message == WM_TIMER) { // avoid live-lock by keeping track of the timers we've already sent bool found = false; for (int i = 0; !found && i < processedTimers.count(); ++i) { @@ -736,9 +749,7 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) } // still nothing - wait for message or signalled objects - QThreadData *data = d->threadData; canWait = (!retVal - && data->canWait && !d->interrupt && (flags & QEventLoop::WaitForMoreEvents)); if (canWait) { @@ -990,7 +1001,11 @@ void QEventDispatcherWin32::activateEventNotifiers() void QEventDispatcherWin32::wakeUp() { Q_D(QEventDispatcherWin32); - SetEvent(d->wakeUpNotifier.handle()); + d->serialNumber.ref(); + if (d->internalHwnd && d->wakeUps.testAndSetAcquire(0, 1)) { + // post a WM_QT_SENDPOSTEDEVENTS to this thread if there isn't one already pending + PostMessage(d->internalHwnd, WM_QT_SENDPOSTEDEVENTS, 0, 0); + } } void QEventDispatcherWin32::interrupt() @@ -1003,13 +1018,8 @@ void QEventDispatcherWin32::interrupt() void QEventDispatcherWin32::flush() { } - void QEventDispatcherWin32::startingUp() -{ - Q_D(QEventDispatcherWin32); - - if (d->wakeUpNotifier.handle()) d->wakeUpNotifier.setEnabled(true); -} +{ } void QEventDispatcherWin32::closingDown() { -- cgit v0.12 From 4e22238ac86eb7ddb88b7dec73d419767da72323 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Mon, 19 Oct 2009 16:14:13 +0200 Subject: Remove workarounds for Win32 event dispatcher bugs This includes the startstop timer delay in QAbstractAnimation, and the inSizeMove workaround for paint events. Reviewed-by: Prasanth Ullattil --- src/corelib/animation/qabstractanimation.cpp | 12 ------------ src/gui/kernel/qapplication.cpp | 3 --- src/gui/kernel/qapplication_p.h | 3 --- src/gui/kernel/qapplication_win.cpp | 2 -- src/gui/painting/qbackingstore.cpp | 12 ------------ 5 files changed, 32 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index c775a00..df8b548 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -157,19 +157,7 @@ #ifndef QT_NO_ANIMATION #define DEFAULT_TIMER_INTERVAL 16 - -#ifdef Q_WS_WIN - /// Fix for Qt 4.7 - //on windows if you're currently dragging a widget an inner eventloop was started by the system - //to make sure that this timer is getting fired, we need to make sure to use the system timers - //that will send a WM_TIMER event. We do that by settings the timer interval to 11 - //It is 16 because QEventDispatcherWin32Private::registerTimer specifically checks if the interval - //is greater than 11 to determine if it should use a system timer (or the multimedia timer). -#define STARTSTOP_TIMER_DELAY 16 -#else #define STARTSTOP_TIMER_DELAY 0 -#endif - QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index f48c551..9658f5e 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -474,9 +474,6 @@ bool QApplicationPrivate::fade_tooltip = false; bool QApplicationPrivate::animate_toolbox = false; bool QApplicationPrivate::widgetCount = false; bool QApplicationPrivate::load_testability = false; -#if defined(Q_WS_WIN) && !defined(Q_WS_WINCE) -bool QApplicationPrivate::inSizeMove = false; -#endif #ifdef QT_KEYPAD_NAVIGATION # ifdef Q_OS_SYMBIAN Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional; diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 2d3d18c..92b07c7 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -441,9 +441,6 @@ public: #ifdef Q_WS_MAC static bool native_modal_dialog_active; #endif -#if defined(Q_WS_WIN) && !defined(Q_WS_WINCE) - static bool inSizeMove; -#endif static void setSystemPalette(const QPalette &pal); static void setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash); diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 5bb25fa..522f1ac 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -1916,11 +1916,9 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam #ifndef Q_WS_WINCE case WM_ENTERSIZEMOVE: autoCaptureWnd = hwnd; - QApplicationPrivate::inSizeMove = true; break; case WM_EXITSIZEMOVE: autoCaptureWnd = 0; - QApplicationPrivate::inSizeMove = false; break; #endif case WM_MOVE: // move window diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index 7c07df8..7facd91 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -497,18 +497,6 @@ static inline void sendUpdateRequest(QWidget *widget, bool updateImmediately) if (!widget) return; -#if defined(Q_WS_WIN) && !defined(Q_OS_WINCE) - if (QApplicationPrivate::inSizeMove && widget->internalWinId() && !updateImmediately - && !widget->testAttribute(Qt::WA_DontShowOnScreen)) { - // Tell Windows to send us a paint event if we're in WM_SIZE/WM_MOVE; posted events - // are blocked until the mouse button is released. See task 146849. - const QRegion rgn(qt_dirtyRegion(widget)); - InvalidateRgn(widget->internalWinId(), rgn.handle(), false); - qt_widget_private(widget)->dirty = QRegion(); - return; - } -#endif - if (updateImmediately) { QEvent event(QEvent::UpdateRequest); QApplication::sendEvent(widget, &event); -- cgit v0.12 From e28e6772e79df9b2adf70e21969af8cac28dc9cf Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 21 Oct 2009 12:33:35 +0200 Subject: Use GetStatusQueue() to look for timer and input messages This function works more reliably than PeekMessage() with different flags. --- src/corelib/kernel/qeventdispatcher_win.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index f7de29d..eca94fc 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -482,8 +482,7 @@ LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp) int localSerialNumber = d->serialNumber; MSG peeked; - if (PeekMessage(&peeked, d->internalHwnd, WM_TIMER, WM_TIMER, PM_NOREMOVE) - || PeekMessage(&peeked, NULL, 0, 0, PM_NOREMOVE | PM_QS_INPUT)) { + if (GetQueueStatus(QS_INPUT | QS_RAWINPUT | QS_TIMER) != 0) { // delay the next pass of sendPostedEvents() until we get the special // WM_TIMER, which allows all pending Windows messages to be processed SetTimer(d->internalHwnd, ~0u, 0, 0); -- cgit v0.12 From 4279889ebebb9fdd026fc107f60f825fb2ad565e Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 21 Oct 2009 14:02:32 +0200 Subject: Compile on Windows when QS_RAWINPUT is not defined. --- src/corelib/kernel/qeventdispatcher_win.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index eca94fc..df4c02d 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -64,6 +64,10 @@ extern uint qGlobalPostedEventsCount(); # define TIME_KILL_SYNCHRONOUS 0x0100 #endif +#ifndef QS_RAWINPUT +# define QS_RAWINPUT 0x0400 +#endif + enum { WM_QT_SOCKETNOTIFIER = WM_USER, WM_QT_SENDPOSTEDEVENTS = WM_USER + 1 @@ -481,7 +485,6 @@ LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp) } else if (message == WM_QT_SENDPOSTEDEVENTS) { int localSerialNumber = d->serialNumber; - MSG peeked; if (GetQueueStatus(QS_INPUT | QS_RAWINPUT | QS_TIMER) != 0) { // delay the next pass of sendPostedEvents() until we get the special // WM_TIMER, which allows all pending Windows messages to be processed -- cgit v0.12 From 3481db791c3b48e28f1a9531b247adf6562edb71 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 22 Oct 2009 16:39:14 +0200 Subject: Remove internal widgets from QApplication::topLevelWidgets() We have some internal hidden widgets which should not come up in the QApplication::topLevelWidgets() list. So the known ones are being removed from the QWidgetPrivate::allWidgets set. Task-number: QTBUG-739 Reviewed-by: Denis Dzyubenko Reviewed-by: Bradley T. Hughes --- src/gui/kernel/qclipboard_win.cpp | 4 ++++ src/gui/kernel/qclipboard_x11.cpp | 9 +++++++++ src/gui/kernel/qwidget_win.cpp | 3 +++ src/gui/styles/qwindowsxpstyle.cpp | 5 +++++ src/opengl/qwindowsurface_gl.cpp | 5 ++++- tests/auto/qapplication/tst_qapplication.cpp | 22 ++++++++++++++++++++++ 6 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qclipboard_win.cpp b/src/gui/kernel/qclipboard_win.cpp index 7f7ef0c..0157052 100644 --- a/src/gui/kernel/qclipboard_win.cpp +++ b/src/gui/kernel/qclipboard_win.cpp @@ -51,6 +51,7 @@ #include "qmime.h" #include "qt_windows.h" #include "qdnd_p.h" +#include QT_BEGIN_NAMESPACE @@ -140,6 +141,9 @@ public: clipBoardViewer = new QWidget(); clipBoardViewer->createWinId(); clipBoardViewer->setObjectName(QLatin1String("internal clipboard owner")); + // We dont need this internal widget to appear in QApplication::topLevelWidgets() + if (QWidgetPrivate::allWidgets) + QWidgetPrivate::allWidgets->remove(clipBoardViewer); } ~QClipboardData() diff --git a/src/gui/kernel/qclipboard_x11.cpp b/src/gui/kernel/qclipboard_x11.cpp index 9621944..22d7c9e 100644 --- a/src/gui/kernel/qclipboard_x11.cpp +++ b/src/gui/kernel/qclipboard_x11.cpp @@ -78,6 +78,7 @@ #include "qimagewriter.h" #include "qvariant.h" #include "qdnd_p.h" +#include #ifndef QT_NO_XFIXES #include @@ -131,6 +132,11 @@ void setupOwner() requestor = new QWidget(0); requestor->createWinId(); requestor->setObjectName(QLatin1String("internal clipboard requestor")); + // We dont need this internal widgets to appear in QApplication::topLevelWidgets() + if (QWidgetPrivate::allWidgets) { + QWidgetPrivate::allWidgets->remove(owner); + QWidgetPrivate::allWidgets->remove(requestor); + } qAddPostRoutine(cleanup); } @@ -769,6 +775,9 @@ QByteArray QX11Data::clipboardReadIncrementalProperty(Window win, Atom property, delete requestor; requestor = new QWidget(0); requestor->setObjectName(QLatin1String("internal clipboard requestor")); + // We dont need this internal widget to appear in QApplication::topLevelWidgets() + if (QWidgetPrivate::allWidgets) + QWidgetPrivate::allWidgets->remove(requestor); return QByteArray(); } diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 2b11bec..0672fee 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -161,6 +161,9 @@ static void qt_tablet_init() qt_tablet_widget = new QWidget(0); qt_tablet_widget->createWinId(); qt_tablet_widget->setObjectName(QLatin1String("Qt internal tablet widget")); + // We dont need this internal widget to appear in QApplication::topLevelWidgets() + if (QWidgetPrivate::allWidgets) + QWidgetPrivate::allWidgets->remove(qt_tablet_widget); LOGCONTEXT lcMine; qAddPostRoutine(qt_tablet_cleanup); struct tagAXIS tpOri[3]; diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index 9ef30e5..2f00f07 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -299,7 +300,11 @@ HWND QWindowsXPStylePrivate::winId(const QWidget *widget) if (!limboWidget) { limboWidget = new QWidget(0); + limboWidget->createWinId(); limboWidget->setObjectName(QLatin1String("xp_limbo_widget")); + // We dont need this internal widget to appear in QApplication::topLevelWidgets() + if (QWidgetPrivate::allWidgets) + QWidgetPrivate::allWidgets->remove(limboWidget); } return limboWidget->winId(); diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 4547416..dcbf021 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -49,12 +49,12 @@ #include #include #include +#include #include "qdebug.h" #ifdef Q_WS_X11 #include #include -#include #ifndef QT_OPENGL_ES #include @@ -195,6 +195,9 @@ public: if (!initializing && !widget && !cleanedUp) { initializing = true; widget = new QGLWidget; + // We dont need this internal widget to appear in QApplication::topLevelWidgets() + if (QWidgetPrivate::allWidgets) + QWidgetPrivate::allWidgets->remove(widget); initializing = false; } return widget; diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index 97aa092..e8e1ef0 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -129,6 +129,7 @@ private slots: void style(); void allWidgets(); + void topLevelWidgets(); void setAttribute(); @@ -1792,6 +1793,27 @@ void tst_QApplication::allWidgets() QVERIFY(!app.allWidgets().contains(w)); // removal test } +void tst_QApplication::topLevelWidgets() +{ + int argc = 1; + QApplication app(argc, &argv0, QApplication::GuiServer); + QWidget *w = new QWidget; + w->show(); +#ifndef QT_NO_CLIPBOARD + QClipboard *clipboard = QApplication::clipboard(); + QString originalText = clipboard->text(); + clipboard->setText(QString("newText")); +#endif + app.processEvents(); + QVERIFY(QApplication::topLevelWidgets().contains(w)); + QCOMPARE(QApplication::topLevelWidgets().count(), 1); + delete w; + w = 0; + app.processEvents(); + QCOMPARE(QApplication::topLevelWidgets().count(), 0); +} + + void tst_QApplication::setAttribute() { -- cgit v0.12 From 706c3f846b97c74c5e15395b6e2d306c522ba769 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Thu, 22 Oct 2009 22:09:03 +0200 Subject: Optimisation for filtering events for gestures in graphics view. We shouldn't add several graphicsobject contexts for the same gesture type when looking for the gesture-enabled QGraphicsObject under a hotspot. Reviewed-by: Thomas Zander --- src/gui/kernel/qgesturemanager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index ed8e744..0601457 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -352,8 +352,10 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) for (ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.begin(), e = item->QGraphicsItem::d_func()->gestureContext.end(); it != e; ++it) { if (it.value() == Qt::ItemWithChildrenGesture) { - if (!types.contains(it.key())) + if (!types.contains(it.key())) { + types.insert(it.key()); contexts.insertMulti(item, it.key()); + } } } item = item->parentObject(); -- cgit v0.12 From dc54674e9f8998b4aee3a58d06f6b5533ccd3cfe Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Thu, 22 Oct 2009 22:41:43 +0200 Subject: Implemented QGestureEvent::activeGestures and canceledGestures. Reviewed-by: Thomas Zander --- src/gui/kernel/qevent.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 065bd09..74dfa53 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4262,7 +4262,12 @@ QGesture *QGestureEvent::gesture(Qt::GestureType type) const */ QList QGestureEvent::activeGestures() const { - return d_func()->gestures; + QList gestures; + foreach (QGesture *gesture, d_func()->gestures) { + if (gesture->state() != Qt::GestureCanceled) + gestures.append(gesture); + } + return gestures; } /*! @@ -4270,7 +4275,12 @@ QList QGestureEvent::activeGestures() const */ QList QGestureEvent::canceledGestures() const { - return d_func()->gestures; + QList gestures; + foreach (QGesture *gesture, d_func()->gestures) { + if (gesture->state() == Qt::GestureCanceled) + gestures.append(gesture); + } + return gestures; } /*! -- cgit v0.12 From f3cbbd7b8388b4c7445a5fa56d59abdae6c532cb Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Thu, 22 Oct 2009 22:39:24 +0200 Subject: Added convenience functions QGestureEvent::setAccepted with a gesture type argument. Reviewed-by: Thomas Zander --- src/gui/kernel/qevent.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++---- src/gui/kernel/qevent.h | 5 ++++ 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 74dfa53..ea05869 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4298,9 +4298,8 @@ QList QGestureEvent::canceledGestures() const */ void QGestureEvent::setAccepted(QGesture *gesture, bool value) { - setAccepted(false); if (gesture) - d_func()->accepted[gesture->gestureType()] = value; + setAccepted(gesture->gestureType(), value); } /*! @@ -4314,7 +4313,8 @@ void QGestureEvent::setAccepted(QGesture *gesture, bool value) */ void QGestureEvent::accept(QGesture *gesture) { - setAccepted(gesture, true); + if (gesture) + setAccepted(gesture->gestureType(), true); } /*! @@ -4328,7 +4328,8 @@ void QGestureEvent::accept(QGesture *gesture) */ void QGestureEvent::ignore(QGesture *gesture) { - setAccepted(gesture, false); + if (gesture) + setAccepted(gesture->gestureType(), false); } /*! @@ -4336,7 +4337,64 @@ void QGestureEvent::ignore(QGesture *gesture) */ bool QGestureEvent::isAccepted(QGesture *gesture) const { - return gesture ? d_func()->accepted.value(gesture->gestureType(), true) : false; + return gesture ? isAccepted(gesture->gestureType()) : false; +} + +/*! + Sets the accept flag of the given \a gestureType object to the specified + \a value. + + Setting the accept flag indicates that the event receiver wants the \a gesture. + Unwanted gestures may be propagated to the parent widget. + + By default, gestures in events of type QEvent::Gesture are accepted, and + gestures in QEvent::GestureOverride events are ignored. + + For convenience, the accept flag can also be set with + \l{QGestureEvent::accept()}{accept(gestureType)}, and cleared with + \l{QGestureEvent::ignore()}{ignore(gestureType)}. +*/ +void QGestureEvent::setAccepted(Qt::GestureType gestureType, bool value) +{ + setAccepted(false); + d_func()->accepted[gestureType] = value; +} + +/*! + Sets the accept flag of the given \a gestureType, the equivalent of calling + \l{QGestureEvent::setAccepted()}{setAccepted(gestureType, true)}. + + Setting the accept flag indicates that the event receiver wants the + gesture. Unwanted gestures may be propagated to the parent widget. + + \sa QGestureEvent::ignore() +*/ +void QGestureEvent::accept(Qt::GestureType gestureType) +{ + setAccepted(gestureType, true); +} + +/*! + Clears the accept flag parameter of the given \a gestureType, the equivalent + of calling \l{QGestureEvent::setAccepted()}{setAccepted(gesture, false)}. + + Clearing the accept flag indicates that the event receiver does not + want the gesture. Unwanted gestures may be propgated to the parent widget. + + \sa QGestureEvent::accept() +*/ +void QGestureEvent::ignore(Qt::GestureType gestureType) +{ + setAccepted(gestureType, false); +} + +/*! + Returns true if the gesture of type \a gestureType is accepted; otherwise + returns false. +*/ +bool QGestureEvent::isAccepted(Qt::GestureType gestureType) const +{ + return d_func()->accepted.value(gestureType, true); } /*! diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index b7370fd..fb245c0 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -851,6 +851,11 @@ public: void ignore(QGesture *); bool isAccepted(QGesture *) const; + void setAccepted(Qt::GestureType, bool); + void accept(Qt::GestureType); + void ignore(Qt::GestureType); + bool isAccepted(Qt::GestureType) const; + void setWidget(QWidget *widget); QWidget *widget() const; -- cgit v0.12 From 20cddedfe5f422eb0607a5ac85870267b2788117 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 23 Oct 2009 13:04:19 +0200 Subject: Unregister the temporary gesture recognizer in the gestures autotest. Reviewed-by: trustme --- tests/auto/gestures/tst_gestures.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 92f979f..800af1b 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -341,6 +341,7 @@ void tst_Gestures::initTestCase() void tst_Gestures::cleanupTestCase() { + qApp->unregisterGestureRecognizer(CustomGesture::GestureType); } void tst_Gestures::init() @@ -547,6 +548,8 @@ void tst_Gestures::conflictingGestures() QCOMPARE(child->events.all.count(), TotalGestureEventsCount + ContinuousGestureEventsCount); QCOMPARE(parent.gestureOverrideEventsReceived, 0); QCOMPARE(parent.gestureEventsReceived, 0); + + qApp->unregisterGestureRecognizer(ContinuousGesture); } void tst_Gestures::finishedWithoutStarted() @@ -978,6 +981,8 @@ void tst_Gestures::twoGesturesOnDifferentLevel() QCOMPARE(parent.events.all.size(), TotalGestureEventsCount); for(int i = 0; i < child->events.all.size(); ++i) QCOMPARE(parent.events.all.at(i), CustomGesture::GestureType); + + qApp->unregisterGestureRecognizer(SecondGesture); } void tst_Gestures::multipleGesturesInTree() @@ -1046,6 +1051,9 @@ void tst_Gestures::multipleGesturesInTree() QCOMPARE(A->events.all.count(FirstGesture), TotalGestureEventsCount); QCOMPARE(A->events.all.count(SecondGesture), 0); QCOMPARE(A->events.all.count(ThirdGesture), TotalGestureEventsCount); + + qApp->unregisterGestureRecognizer(SecondGesture); + qApp->unregisterGestureRecognizer(ThirdGesture); } void tst_Gestures::multipleGesturesInComplexTree() @@ -1139,6 +1147,13 @@ void tst_Gestures::multipleGesturesInComplexTree() QCOMPARE(A->events.all.count(FifthGesture), 0); QCOMPARE(A->events.all.count(SixthGesture), 0); QCOMPARE(A->events.all.count(SeventhGesture), 0); + + qApp->unregisterGestureRecognizer(SecondGesture); + qApp->unregisterGestureRecognizer(ThirdGesture); + qApp->unregisterGestureRecognizer(FourthGesture); + qApp->unregisterGestureRecognizer(FifthGesture); + qApp->unregisterGestureRecognizer(SixthGesture); + qApp->unregisterGestureRecognizer(SeventhGesture); } void tst_Gestures::testMapToScene() -- cgit v0.12 From 92d8b0e1d6ecce8214b24a08b8a199af4321bd88 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 21 Oct 2009 12:40:59 +0200 Subject: Implement QApplication::unregisterGestureRecognizer Reviewed-by: Denis Dzyubenko --- src/gui/kernel/qapplication.cpp | 4 +++- src/gui/kernel/qgesturemanager.cpp | 42 +++++++++++++++++++++++++++++++++++--- src/gui/kernel/qgesturemanager_p.h | 9 ++++++-- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 202d450..e64dfd2 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -5642,7 +5642,9 @@ Qt::GestureType QApplication::registerGestureRecognizer(QGestureRecognizer *reco */ void QApplication::unregisterGestureRecognizer(Qt::GestureType type) { - QGestureManager::instance()->unregisterGestureRecognizer(type); + QApplicationPrivate *d = qApp->d_func(); + if (d->gestureManager) + d->gestureManager->unregisterGestureRecognizer(type); } QT_END_NAMESPACE diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 0601457..dc76c3f 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -104,9 +104,29 @@ Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *r return type; } -void QGestureManager::unregisterGestureRecognizer(Qt::GestureType) +void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) { + QList list = recognizers.values(type); + recognizers.remove(type); + foreach (QGesture* g, gestureToRecognizer.keys()) { + QGestureRecognizer *recognizer = gestureToRecognizer.value(g); + if (list.contains(recognizer)) { + m_deletedRecognizers.insert(g, recognizer); + gestureToRecognizer.remove(g); + } + } + foreach (QGestureRecognizer *recognizer, list) { + QList obsoleteGestures; + QMap::Iterator iter = objectGestures.begin(); + while (iter != objectGestures.end()) { + ObjectGesture objectGesture = iter.key(); + if (objectGesture.gesture == type) + obsoleteGestures << iter.value(); + ++iter; + } + m_obsoleteGestures.insert(recognizer, obsoleteGestures); + } } QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type) @@ -290,14 +310,28 @@ bool QGestureManager::filterEventThroughContexts(const QMap endedGestures = finishedGestures + canceledGestures + undeliveredGestures; foreach (QGesture *gesture, endedGestures) { - if (QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0)) { + if (QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0)) recognizer->reset(gesture); - } + else + cleanupGesturesForRemovedRecognizer(gesture); gestureTargets.remove(gesture); } return false; } +void QGestureManager::cleanupGesturesForRemovedRecognizer(QGesture *gesture) +{ + QGestureRecognizer *recognizer = m_deletedRecognizers.value(gesture); + Q_ASSERT(recognizer); + m_deletedRecognizers.remove(gesture); + if (m_deletedRecognizers.keys(recognizer).isEmpty()) { + // no more active gestures, cleanup! + qDeleteAll(m_obsoleteGestures.value(recognizer)); + m_obsoleteGestures.remove(recognizer); + delete recognizer; + } +} + bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) { QSet types; @@ -534,6 +568,8 @@ void QGestureManager::timerEvent(QTimerEvent *event) QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0); if (recognizer) recognizer->reset(gesture); + else + cleanupGesturesForRemovedRecognizer(gesture); } else { ++it; } diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index f0e7225..eef45d2 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -104,7 +104,7 @@ private: Qt::GestureType gesture; ObjectGesture(QObject *o, const Qt::GestureType &g) : object(o), gesture(g) { } - inline bool operator<(const ObjectGesture& rhs) const + inline bool operator<(const ObjectGesture &rhs) const { if (object.data() < rhs.object.data()) return true; @@ -114,7 +114,8 @@ private: } }; - QMap objectGestures; + // TODO rename all member vars to be m_ + QMap objectGestures; // TODO rename widgetGestures QMap gestureToRecognizer; QHash gestureOwners; @@ -122,6 +123,10 @@ private: int lastCustomGestureId; + QHash > m_obsoleteGestures; + QMap m_deletedRecognizers; + void cleanupGesturesForRemovedRecognizer(QGesture *gesture); + QGesture *getState(QObject *widget, Qt::GestureType gesture); void deliverEvents(const QSet &gestures, QSet *undeliveredGestures); -- cgit v0.12 From 25bc5c29db866d5abc3f9fbae7b5211e2e6b1f25 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 21 Oct 2009 13:58:24 +0200 Subject: Add QWidget::ungrabGesture Reviewed-by: Denis Dzyubenko --- src/gui/kernel/qgesturemanager.cpp | 16 ++++++++ src/gui/kernel/qgesturemanager_p.h | 2 + src/gui/kernel/qwidget.cpp | 16 ++++++++ src/gui/kernel/qwidget.h | 1 + tests/auto/gestures/tst_gestures.cpp | 71 ++++++++++++++++++++++++++++++++++++ 5 files changed, 106 insertions(+) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index dc76c3f..df88f9e 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -129,6 +129,21 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) } } +void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType type) +{ + QMap::Iterator iter = objectGestures.begin(); + while (iter != objectGestures.end()) { + ObjectGesture objectGesture = iter.key(); + if (objectGesture.gesture == type && target == objectGesture.object.data()) { + delete iter.value(); + iter = objectGestures.erase(iter); + } else { + ++iter; + } + } +} + +// get or create a QGesture object that will represent the state for a given object, used by the recognizer QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type) { // if the widget is being deleted we should be carefull and not to @@ -332,6 +347,7 @@ void QGestureManager::cleanupGesturesForRemovedRecognizer(QGesture *gesture) } } +// return true if accepted (consumed) bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) { QSet types; diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index eef45d2..96c2fb7 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -79,6 +79,8 @@ public: // declared in qapplication.cpp static QGestureManager* instance(); + void cleanupCachedGestures(QObject *target, Qt::GestureType type); + protected: void timerEvent(QTimerEvent *event); bool filterEventThroughContexts(const QMap &contexts, diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 5fa9a92..c10db90 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -11708,6 +11708,22 @@ void QWidget::grabGesture(Qt::GestureType gesture, Qt::GestureContext context) (void)QGestureManager::instance(); // create a gesture manager } +/*! + Unsubscribes the widget to a given \a gesture type + + \sa QGestureEvent + \since 4.6 +*/ +void QWidget::ungrabGesture(Qt::GestureType gesture) +{ + Q_D(QWidget); + if (d->gestureContext.remove(gesture)) { + QGestureManager *manager = QGestureManager::instance(); + manager->cleanupCachedGestures(this, gesture); + } +} + + QT_END_NAMESPACE #include "moc_qwidget.cpp" diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index e603a1a..fce3f09 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -355,6 +355,7 @@ public: void setGraphicsEffect(QGraphicsEffect *effect); void grabGesture(Qt::GestureType type, Qt::GestureContext context = Qt::WidgetWithChildrenGesture); + void ungrabGesture(Qt::GestureType type); public Q_SLOTS: void setWindowTitle(const QString &); diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 800af1b..6e52de3 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -280,6 +280,7 @@ protected: } }; +// TODO rename to sendGestureSequence static void sendCustomGesture(CustomEvent *event, QObject *object, QGraphicsScene *scene = 0) { for (int i = CustomGesture::SerialMaybeThreshold; @@ -322,6 +323,7 @@ private slots: void multipleGesturesInTree(); void multipleGesturesInComplexTree(); void testMapToScene(); + void ungrabGesture(); }; tst_Gestures::tst_Gestures() @@ -1181,5 +1183,74 @@ void tst_Gestures::testMapToScene() QCOMPARE(event.mapToScene(origin + QPoint(100, 200)), view.mapToScene(QPoint(100, 200))); } +void tst_Gestures::ungrabGesture() // a method on QWidget +{ + class MockGestureWidget : public GestureWidget { + public: + MockGestureWidget(const char *name = 0, QWidget *parent = 0) + : GestureWidget(name, parent) { } + + + QSet gestures; + protected: + bool event(QEvent *event) + { + if (event->type() == QEvent::Gesture) { + QGestureEvent *gestureEvent = static_cast(event); + if (gestureEvent) + foreach (QGesture *g, gestureEvent->allGestures()) + gestures.insert(g); + } + return GestureWidget::event(event); + } + }; + + MockGestureWidget parent("A"); + MockGestureWidget *a = &parent; + MockGestureWidget *b = new MockGestureWidget("B", a); + + a->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + b->grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture); + b->ignoredGestures << CustomGesture::GestureType; + + CustomEvent event; + // sending an event will cause the QGesture objects to be instantiated for the widgets + sendCustomGesture(&event, b); + + QCOMPARE(a->gestures.count(), 1); + QPointer customGestureA; + customGestureA = *(a->gestures.begin()); + QVERIFY(!customGestureA.isNull()); + QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType); + + QCOMPARE(b->gestures.count(), 1); + QPointer customGestureB; + customGestureB = *(b->gestures.begin()); + QVERIFY(!customGestureB.isNull()); + QVERIFY(customGestureA.data() == customGestureB.data()); + QCOMPARE(customGestureB->gestureType(), CustomGesture::GestureType); + + a->gestures.clear(); + // sending an event will cause the QGesture objects to be instantiated for the widget + sendCustomGesture(&event, a); + + QCOMPARE(a->gestures.count(), 1); + customGestureA = *(a->gestures.begin()); + QVERIFY(!customGestureA.isNull()); + QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType); + QVERIFY(customGestureA.data() != customGestureB.data()); + + a->ungrabGesture(CustomGesture::GestureType); + QVERIFY(customGestureA.isNull()); + QVERIFY(!customGestureB.isNull()); + + a->gestures.clear(); + a->reset(); + // send again to 'b' and make sure a never gets it. + sendCustomGesture(&event, b); + QCOMPARE(a->gestureEventsReceived, 0); + QCOMPARE(a->gestureOverrideEventsReceived, 0); +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" -- cgit v0.12 From 487570340062a1165e0473e2557f844b097db526 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Fri, 23 Oct 2009 15:43:50 +0200 Subject: Fix memory leaks in the gesture manager Reviewed-by: Denis Dzyubenko --- src/gui/kernel/qgesturemanager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index df88f9e..0139533 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -82,7 +82,7 @@ QGestureManager::QGestureManager(QObject *parent) QGestureManager::~QGestureManager() { - + qDeleteAll(recognizers.values()); } Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *recognizer) @@ -166,6 +166,7 @@ QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type) state = recognizer->createGesture(object); if (!state) return 0; + state->setParent(this); if (state->gestureType() == Qt::CustomGesture) { // if the recognizer didn't fill in the gesture type, then this // is a custom gesture with autogenerated it and we fill it. -- cgit v0.12 From 293ee52fce78b74fcfa2effbccf6df6f12e9daa5 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Fri, 23 Oct 2009 15:44:37 +0200 Subject: Fix the debug output to be correct again after refactoring Reviewed-by: Denis Dzyubenko --- src/gui/kernel/qgesturemanager.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 0139533..9890a12 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -212,21 +212,21 @@ bool QGestureManager::filterEventThroughContexts(const QMapfilterEvent(state, target, event); QGestureRecognizer::Result type = result & QGestureRecognizer::ResultState_Mask; if (type == QGestureRecognizer::GestureTriggered) { - DEBUG() << "QGestureManager: gesture triggered: " << state; + DEBUG() << "QGestureManager:Recognizer: gesture triggered: " << state; triggeredGestures << state; } else if (type == QGestureRecognizer::GestureFinished) { - DEBUG() << "QGestureManager: gesture finished: " << state; + DEBUG() << "QGestureManager:Recognizer: gesture finished: " << state; finishedGestures << state; } else if (type == QGestureRecognizer::MaybeGesture) { - DEBUG() << "QGestureManager: maybe gesture: " << state; + DEBUG() << "QGestureManager:Recognizer: maybe gesture: " << state; newMaybeGestures << state; } else if (type == QGestureRecognizer::NotGesture) { - DEBUG() << "QGestureManager: not gesture: " << state; + DEBUG() << "QGestureManager:Recognizer: not gesture: " << state; notGestures << state; } else if (type == QGestureRecognizer::Ignore) { - DEBUG() << "QGestureManager: gesture ignored the event: " << state; + DEBUG() << "QGestureManager:Recognizer: ignored the event: " << state; } else { - DEBUG() << "QGestureManager: hm, lets assume the recognizer" + DEBUG() << "QGestureManager:Recognizer: hm, lets assume the recognizer" << "ignored the event: " << state; } if (result & QGestureRecognizer::ConsumeEventHint) { @@ -307,7 +307,7 @@ bool QGestureManager::filterEventThroughContexts(const QMap Date: Mon, 26 Oct 2009 13:36:30 +0100 Subject: Removed the obsolete documentation reference from the QGesture. Reviewed-by: trustme --- src/gui/kernel/qgesture.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index ecdd661..a161876 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -142,12 +142,6 @@ QGesture::~QGesture() \brief whether the gesture has a hot-spot */ -/*! - \property QGesture::targetObject - \brief the target object which will receive the gesture event if the hotSpot is - not set -*/ - Qt::GestureType QGesture::gestureType() const { return d_func()->gestureType; -- cgit v0.12 From 3bc088fad760bd50eec05b323a056641247a9a59 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 27 Oct 2009 10:56:39 +0100 Subject: QTabbar is not behaving (painting) like native ones on Mac. When a tab is clicked and mouse is moved outside that tab, it should be drawn as normal (not in sunken state). Reviewed-by: MortenS --- src/gui/widgets/qtabbar.cpp | 18 +++++++++++++++++- src/gui/widgets/qtabbar_p.h | 10 ++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp index 6c9761c..4dffbdc 100644 --- a/src/gui/widgets/qtabbar.cpp +++ b/src/gui/widgets/qtabbar.cpp @@ -1694,6 +1694,9 @@ void QTabBar::mousePressEvent(QMouseEvent *event) d->moveTabFinished(d->pressedIndex); d->pressedIndex = d->indexAtPos(event->pos()); +#ifdef Q_WS_MAC + d->previousPressedIndex = d->pressedIndex; +#endif if (d->validIndex(d->pressedIndex)) { QStyleOptionTabBarBaseV2 optTabBase; optTabBase.init(this); @@ -1774,6 +1777,17 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event) update(); } +#ifdef Q_WS_MAC + } else if (!d->documentMode && event->buttons() == Qt::LeftButton && d->previousPressedIndex != -1) { + int newPressedIndex = d->indexAtPos(event->pos()); + if (d->pressedIndex == -1 && d->previousPressedIndex == newPressedIndex) { + d->pressedIndex = d->previousPressedIndex; + update(tabRect(d->pressedIndex)); + } else if(d->pressedIndex != newPressedIndex) { + d->pressedIndex = -1; + update(tabRect(d->previousPressedIndex)); + } +#endif } if (event->buttons() != Qt::LeftButton) { @@ -1865,7 +1879,9 @@ void QTabBar::mouseReleaseEvent(QMouseEvent *event) event->ignore(); return; } - +#ifdef Q_WS_MAC + d->previousPressedIndex = -1; +#endif if (d->movable && d->dragInProgress && d->validIndex(d->pressedIndex)) { int length = d->tabList[d->pressedIndex].dragOffset; int width = verticalTabs(d->shape) diff --git a/src/gui/widgets/qtabbar_p.h b/src/gui/widgets/qtabbar_p.h index 494a340..9f3285b 100644 --- a/src/gui/widgets/qtabbar_p.h +++ b/src/gui/widgets/qtabbar_p.h @@ -77,7 +77,11 @@ public: :currentIndex(-1), pressedIndex(-1), shape(QTabBar::RoundedNorth), layoutDirty(false), drawBase(true), scrollOffset(0), expanding(true), closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), - dragInProgress(false), documentMode(false), movingTab(0) {} + dragInProgress(false), documentMode(false), movingTab(0) +#ifdef Q_WS_MAC + , previousPressedIndex(-1) +#endif + {} int currentIndex; int pressedIndex; @@ -195,7 +199,9 @@ public: bool documentMode; QWidget *movingTab; - +#ifdef Q_WS_MAC + int previousPressedIndex; +#endif // shared by tabwidget and qtabbar static void initStyleBaseOption(QStyleOptionTabBarBaseV2 *optTabBase, QTabBar *tabbar, QSize size) { -- cgit v0.12 From 124df35db0be3ae7578635735b4e64c589d07cba Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 27 Oct 2009 14:01:58 +0100 Subject: Selected tab is drawn incorrectly on Snow Leopard. The default height of tab bar is 22 pixels in Snow Leopard. We used to draw tabs taller than 21 pixels to a pixmap and stretch to the required size. The limit is now changed to 22 pixels (which is the most common use case). The stretched drawing is not perfect in Snow Leopard due to some changes in how HITheme draws tabs. Reviewed-by: Jens Bache-Wiig --- src/gui/styles/qmacstyle_mac.mm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 63ba641..4dcb469 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -3637,17 +3637,19 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter break; } } + bool stretchTabs = (!verticalTabs && tabRect.height() > 22 || verticalTabs && tabRect.width() > 22); + switch (tp) { case QStyleOptionTab::Beginning: tdi.position = kHIThemeTabPositionFirst; - if (sp != QStyleOptionTab::NextIsSelected) + if (sp != QStyleOptionTab::NextIsSelected || stretchTabs) tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator; break; case QStyleOptionTab::Middle: tdi.position = kHIThemeTabPositionMiddle; if (selected) tdi.adornment |= kHIThemeTabAdornmentLeadingSeparator; - if (sp != QStyleOptionTab::NextIsSelected) // Also when we're selected. + if (sp != QStyleOptionTab::NextIsSelected || stretchTabs) // Also when we're selected. tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator; break; case QStyleOptionTab::End: @@ -3659,9 +3661,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter tdi.position = kHIThemeTabPositionOnly; break; } - // HITheme doesn't stretch its tabs. Therefore we have to cheat and do the job ourselves. - if ((!verticalTabs && tabRect.height() > 21 || verticalTabs && tabRect.width() > 21)) { + if (stretchTabs) { HIRect hirect = CGRectMake(0, 0, 23, 23); QPixmap pm(23, 23); pm.fill(Qt::transparent); -- cgit v0.12 From e5c87d92fa6380c13ff47ce1fe6d85a02dc92794 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 27 Oct 2009 15:05:22 +0100 Subject: Improved gesture autotest reliability on X11. Reviewed-by: trustme --- tests/auto/gestures/tst_gestures.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 6e52de3..edfbf32 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -715,6 +715,7 @@ void tst_Gestures::graphicsItemGesture() { QGraphicsScene scene; QGraphicsView view(&scene); + view.setWindowFlags(Qt::X11BypassWindowManagerHint); GestureItem *item = new GestureItem("item"); scene.addItem(item); @@ -777,6 +778,7 @@ void tst_Gestures::graphicsItemTreeGesture() { QGraphicsScene scene; QGraphicsView view(&scene); + view.setWindowFlags(Qt::X11BypassWindowManagerHint); GestureItem *item1 = new GestureItem("item1"); item1->setPos(100, 100); @@ -834,6 +836,7 @@ void tst_Gestures::explicitGraphicsObjectTarget() { QGraphicsScene scene; QGraphicsView view(&scene); + view.setWindowFlags(Qt::X11BypassWindowManagerHint); GestureItem *item1 = new GestureItem("item1"); scene.addItem(item1); @@ -887,6 +890,7 @@ void tst_Gestures::gestureOverChildGraphicsItem() { QGraphicsScene scene; QGraphicsView view(&scene); + view.setWindowFlags(Qt::X11BypassWindowManagerHint); GestureItem *item0 = new GestureItem("item0"); scene.addItem(item0); @@ -1168,6 +1172,7 @@ void tst_Gestures::testMapToScene() QGraphicsScene scene; QGraphicsView view(&scene); + view.setWindowFlags(Qt::X11BypassWindowManagerHint); GestureItem *item0 = new GestureItem; scene.addItem(item0); -- cgit v0.12 From fcd8edaf6e17463603d81525f2b57fc11f20216b Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 27 Oct 2009 10:41:32 +0100 Subject: Implemented QGestureRecognizer::ConsumeEventHint Reviewed-By: trustme --- src/gui/kernel/qgesturemanager.cpp | 6 ++++-- tests/auto/gestures/tst_gestures.cpp | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 9890a12..52f8eef 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -196,6 +196,8 @@ bool QGestureManager::filterEventThroughContexts(const QMap::const_iterator ContextIterator; for (ContextIterator cit = contexts.begin(), ce = contexts.end(); cit != ce; ++cit) { @@ -232,7 +234,7 @@ bool QGestureManager::filterEventThroughContexts(const QMaptype() == CustomEvent::EventType) { - QGestureRecognizer::Result result = QGestureRecognizer::ConsumeEventHint; + QGestureRecognizer::Result result = 0; + if (CustomGestureRecognizer::ConsumeEvents) + result |= QGestureRecognizer::ConsumeEventHint; CustomGesture *g = static_cast(state); CustomEvent *e = static_cast(event); g->serial = e->serial; @@ -143,6 +147,7 @@ public: QGestureRecognizer::reset(state); } }; +bool CustomGestureRecognizer::ConsumeEvents = false; // same as CustomGestureRecognizer but triggers early without the maybe state class CustomContinuousGestureRecognizer : public QGestureRecognizer @@ -324,6 +329,7 @@ private slots: void multipleGesturesInComplexTree(); void testMapToScene(); void ungrabGesture(); + void consumeEventHint(); }; tst_Gestures::tst_Gestures() @@ -375,6 +381,19 @@ void tst_Gestures::customGesture() QCOMPARE(widget.events.canceled.size(), 0); } +void tst_Gestures::consumeEventHint() +{ + GestureWidget widget; + widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + + CustomGestureRecognizer::ConsumeEvents = true; + CustomEvent event; + sendCustomGesture(&event, &widget); + CustomGestureRecognizer::ConsumeEvents = false; + + QCOMPARE(widget.customEventsReceived, 0); +} + void tst_Gestures::autoCancelingGestures() { GestureWidget widget; -- cgit v0.12 From 6efa1085b6a61cf2883b460e5b76bde9576dc4a7 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 27 Oct 2009 15:18:07 +0100 Subject: Renamed QGestureRecognizer::ResultFlags to ResultFlag Decided after review by David Boddie. Reviewed-by: trustme --- src/gui/kernel/qgesturerecognizer.cpp | 2 +- src/gui/kernel/qgesturerecognizer.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qgesturerecognizer.cpp b/src/gui/kernel/qgesturerecognizer.cpp index ba3a750..c2b26f0 100644 --- a/src/gui/kernel/qgesturerecognizer.cpp +++ b/src/gui/kernel/qgesturerecognizer.cpp @@ -100,7 +100,7 @@ QT_BEGIN_NAMESPACE */ /*! - \enum QGestureRecognizer::ResultFlags + \enum QGestureRecognizer::ResultFlag This enum describes the result of the current event filtering step in a gesture recognizer state machine. diff --git a/src/gui/kernel/qgesturerecognizer.h b/src/gui/kernel/qgesturerecognizer.h index efd8565..a3c990d 100644 --- a/src/gui/kernel/qgesturerecognizer.h +++ b/src/gui/kernel/qgesturerecognizer.h @@ -56,7 +56,7 @@ class QGesture; class Q_GUI_EXPORT QGestureRecognizer { public: - enum ResultFlags + enum ResultFlag { Ignore = 0x0001, NotGesture = 0x0002, @@ -73,7 +73,7 @@ public: ResultHint_Mask = 0xff00 }; - Q_DECLARE_FLAGS(Result, ResultFlags) + Q_DECLARE_FLAGS(Result, ResultFlag) QGestureRecognizer(); virtual ~QGestureRecognizer(); -- cgit v0.12 From 6c8c1c5322a26d789165783d7df3e29c672690cb Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Tue, 27 Oct 2009 18:07:56 +0100 Subject: Fill gap of X.org/XFree multimedia/special/launcher keys Qt up to 4.5.x is missing whole setup of multimedia keys already defined by X Merge-request: 1742 Reviewed-by: Denis Dzyubenko --- src/corelib/global/qnamespace.h | 97 ++++++++++++- src/corelib/global/qnamespace.qdoc | 92 ++++++++++++ src/gui/kernel/qkeymapper_x11.cpp | 286 ++++++++++++++++++++++++++++++------- src/gui/kernel/qkeysequence.cpp | 174 ++++++++++++++++------ 4 files changed, 553 insertions(+), 96 deletions(-) diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 2b62c6b..aeaca54 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -909,12 +909,10 @@ public: Key_Dead_Horn = 0x01001262, // multimedia/internet keys - ignored by default - see QKeyEvent c'tor - Key_Back = 0x01000061, Key_Forward = 0x01000062, Key_Stop = 0x01000063, Key_Refresh = 0x01000064, - Key_VolumeDown = 0x01000070, Key_VolumeMute = 0x01000071, Key_VolumeUp = 0x01000072, @@ -923,7 +921,6 @@ public: Key_BassDown = 0x01000075, Key_TrebleUp = 0x01000076, Key_TrebleDown = 0x01000077, - Key_MediaPlay = 0x01000080, Key_MediaStop = 0x01000081, Key_MediaPrevious = 0x01000082, @@ -932,13 +929,11 @@ public: #endif Key_MediaNext = 0x01000083, Key_MediaRecord = 0x01000084, - Key_HomePage = 0x01000090, Key_Favorites = 0x01000091, Key_Search = 0x01000092, Key_Standby = 0x01000093, Key_OpenUrl = 0x01000094, - Key_LaunchMail = 0x010000a0, Key_LaunchMedia = 0x010000a1, Key_Launch0 = 0x010000a2, @@ -957,6 +952,98 @@ public: Key_LaunchD = 0x010000af, Key_LaunchE = 0x010000b0, Key_LaunchF = 0x010000b1, + Key_MonBrightnessUp = 0x010000b2, + Key_MonBrightnessDown = 0x010000b3, + Key_KeyboardLightOnOff = 0x010000b4, + Key_KeyboardBrightnessUp = 0x010000b5, + Key_KeyboardBrightnessDown = 0x010000b6, + Key_PowerOff = 0x010000b7, + Key_WakeUp = 0x010000b8, + Key_Eject = 0x010000b9, + Key_ScreenSaver = 0x010000ba, + Key_WWW = 0x010000bb, + Key_Memo = 0x010000bc, + Key_LightBulb = 0x010000bd, + Key_Shop = 0x010000be, + Key_History = 0x010000bf, + Key_AddFavorite = 0x010000c0, + Key_HotLinks = 0x010000c1, + Key_BrightnessAdjust = 0x010000c2, + Key_Finance = 0x010000c3, + Key_Community = 0x010000c4, + Key_AudioRewind = 0x010000c5, + Key_BackForward = 0x010000c6, + Key_ApplicationLeft = 0x010000c7, + Key_ApplicationRight = 0x010000c8, + Key_Book = 0x010000c9, + Key_CD = 0x010000ca, + Key_Calculator = 0x010000cb, + Key_ToDoList = 0x010000cc, + Key_ClearGrab = 0x010000cd, + Key_Close = 0x010000ce, + Key_Copy = 0x010000cf, + Key_Cut = 0x010000d0, + Key_Display = 0x010000d1, + Key_DOS = 0x010000d2, + Key_Documents = 0x010000d3, + Key_Excel = 0x010000d4, + Key_Explorer = 0x010000d5, + Key_Game = 0x010000d6, + Key_Go = 0x010000d7, + Key_iTouch = 0x010000d8, + Key_LogOff = 0x010000d9, + Key_Market = 0x010000da, + Key_Meeting = 0x010000db, + Key_MenuKB = 0x010000dc, + Key_MenuPB = 0x010000dd, + Key_MySites = 0x010000de, + Key_News = 0x010000df, + Key_OfficeHome = 0x010000e0, + Key_Option = 0x010000e1, + Key_Paste = 0x010000e2, + Key_Phone = 0x010000e3, + Key_Calendar = 0x010000e4, + Key_Reply = 0x010000e5, + Key_Reload = 0x010000e6, + Key_RotateWindows = 0x010000e7, + Key_RotationPB = 0x010000e8, + Key_RotationKB = 0x010000e9, + Key_Save = 0x010000ea, + Key_Send = 0x010000eb, + Key_Spell = 0x010000ec, + Key_SplitScreen = 0x010000ed, + Key_Support = 0x010000ee, + Key_TaskPane = 0x010000ef, + Key_Terminal = 0x010000f0, + Key_Tools = 0x010000f1, + Key_Travel = 0x010000f2, + Key_Video = 0x010000f3, + Key_Word = 0x010000f4, + Key_Xfer = 0x010000f5, + Key_ZoomIn = 0x010000f6, + Key_ZoomOut = 0x010000f7, + Key_Away = 0x010000f8, + Key_Messenger = 0x010000f9, + Key_WebCam = 0x010000fa, + Key_MailForward = 0x010000fb, + Key_Pictures = 0x010000fc, + Key_Music = 0x010000fd, + Key_Battery = 0x010000fe, + Key_Bluetooth = 0x010000ff, + Key_WLAN = 0x01000100, + Key_UWB = 0x01000101, + Key_AudioForward = 0x01000102, + Key_AudioRepeat = 0x01000103, + Key_AudioRandomPlay = 0x01000104, + Key_Subtitle = 0x01000105, + Key_AudioCycleTrack = 0x01000106, + Key_Time = 0x01000107, + Key_Hibernate = 0x01000108, + Key_View = 0x01000109, + Key_TopMenu = 0x0100010a, + Key_PowerDown = 0x0100010b, + Key_Suspend = 0x0100010c, + Key_ContrastAdjust = 0x0100010d, Key_MediaLast = 0x0100ffff, diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index e8d6df0..4a48a8f 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -1609,6 +1609,98 @@ \value Key_LaunchD \value Key_LaunchE \value Key_LaunchF + \value Key_MonBrightnessUp + \value Key_MonBrightnessDown + \value Key_KeyboardLightOnOff + \value Key_KeyboardBrightnessUp + \value Key_KeyboardBrightnessDown + \value Key_PowerOff + \value Key_WakeUp + \value Key_Eject + \value Key_ScreenSaver + \value Key_WWW + \value Key_Memo + \value Key_LightBulb + \value Key_Shop + \value Key_History + \value Key_AddFavorite + \value Key_HotLinks + \value Key_BrightnessAdjust + \value Key_Finance + \value Key_Community + \value Key_AudioRewind + \value Key_BackForward + \value Key_ApplicationLeft + \value Key_ApplicationRight + \value Key_Book + \value Key_CD + \value Key_Calculator + \value Key_ToDoList + \value Key_ClearGrab + \value Key_Close + \value Key_Copy + \value Key_Cut + \value Key_Display + \value Key_DOS + \value Key_Documents + \value Key_Excel + \value Key_Explorer + \value Key_Game + \value Key_Go + \value Key_iTouch + \value Key_LogOff + \value Key_Market + \value Key_Meeting + \value Key_MenuKB + \value Key_MenuPB + \value Key_MySites + \value Key_News + \value Key_OfficeHome + \value Key_Option + \value Key_Paste + \value Key_Phone + \value Key_Calendar + \value Key_Reply + \value Key_Reload + \value Key_RotateWindows + \value Key_RotationPB + \value Key_RotationKB + \value Key_Save + \value Key_Send + \value Key_Spell + \value Key_SplitScreen + \value Key_Support + \value Key_TaskPane + \value Key_Terminal + \value Key_Tools + \value Key_Travel + \value Key_Video + \value Key_Word + \value Key_Xfer + \value Key_ZoomIn + \value Key_ZoomOut + \value Key_Away + \value Key_Messenger + \value Key_WebCam + \value Key_MailForward + \value Key_Pictures + \value Key_Music + \value Key_Battery + \value Key_Bluetooth + \value Key_WLAN + \value Key_UWB + \value Key_AudioForward + \value Key_AudioRepeat + \value Key_AudioRandomPlay + \value Key_Subtitle + \value Key_AudioCycleTrack + \value Key_Time + \value Key_Hibernate + \value Key_View + \value Key_TopMenu + \value Key_PowerDown + \value Key_Suspend + \value Key_ContrastAdjust \value Key_MediaLast \value Key_unknown diff --git a/src/gui/kernel/qkeymapper_x11.cpp b/src/gui/kernel/qkeymapper_x11.cpp index 0ce77fe..8164589 100644 --- a/src/gui/kernel/qkeymapper_x11.cpp +++ b/src/gui/kernel/qkeymapper_x11.cpp @@ -714,47 +714,144 @@ extern bool qt_sm_blockUserInput; #define XK_KP_Delete 0xFF9F #endif -// the next lines are taken from XFree > 4.0 (X11/XF86keysyms.h), defining some special +// the next lines are taken on 10/2009 from X.org (X11/XF86keysym.h), defining some special // multimedia keys. They are included here as not every system has them. -#define XF86XK_Standby 0x1008FF10 -#define XF86XK_AudioLowerVolume 0x1008FF11 -#define XF86XK_AudioMute 0x1008FF12 -#define XF86XK_AudioRaiseVolume 0x1008FF13 -#define XF86XK_AudioPlay 0x1008FF14 -#define XF86XK_AudioStop 0x1008FF15 -#define XF86XK_AudioPrev 0x1008FF16 -#define XF86XK_AudioNext 0x1008FF17 -#define XF86XK_HomePage 0x1008FF18 -#define XF86XK_Calculator 0x1008FF1D -#define XF86XK_Mail 0x1008FF19 -#define XF86XK_Start 0x1008FF1A -#define XF86XK_Search 0x1008FF1B -#define XF86XK_AudioRecord 0x1008FF1C -#define XF86XK_Back 0x1008FF26 -#define XF86XK_Forward 0x1008FF27 -#define XF86XK_Stop 0x1008FF28 -#define XF86XK_Refresh 0x1008FF29 -#define XF86XK_Favorites 0x1008FF30 -#define XF86XK_AudioPause 0x1008FF31 -#define XF86XK_AudioMedia 0x1008FF32 -#define XF86XK_MyComputer 0x1008FF33 -#define XF86XK_OpenURL 0x1008FF38 -#define XF86XK_Launch0 0x1008FF40 -#define XF86XK_Launch1 0x1008FF41 -#define XF86XK_Launch2 0x1008FF42 -#define XF86XK_Launch3 0x1008FF43 -#define XF86XK_Launch4 0x1008FF44 -#define XF86XK_Launch5 0x1008FF45 -#define XF86XK_Launch6 0x1008FF46 -#define XF86XK_Launch7 0x1008FF47 -#define XF86XK_Launch8 0x1008FF48 -#define XF86XK_Launch9 0x1008FF49 -#define XF86XK_LaunchA 0x1008FF4A -#define XF86XK_LaunchB 0x1008FF4B -#define XF86XK_LaunchC 0x1008FF4C -#define XF86XK_LaunchD 0x1008FF4D -#define XF86XK_LaunchE 0x1008FF4E -#define XF86XK_LaunchF 0x1008FF4F +#define XF86XK_MonBrightnessUp 0x1008FF02 +#define XF86XK_MonBrightnessDown 0x1008FF03 +#define XF86XK_KbdLightOnOff 0x1008FF04 +#define XF86XK_KbdBrightnessUp 0x1008FF05 +#define XF86XK_KbdBrightnessDown 0x1008FF06 +#define XF86XK_Standby 0x1008FF10 +#define XF86XK_AudioLowerVolume 0x1008FF11 +#define XF86XK_AudioMute 0x1008FF12 +#define XF86XK_AudioRaiseVolume 0x1008FF13 +#define XF86XK_AudioPlay 0x1008FF14 +#define XF86XK_AudioStop 0x1008FF15 +#define XF86XK_AudioPrev 0x1008FF16 +#define XF86XK_AudioNext 0x1008FF17 +#define XF86XK_HomePage 0x1008FF18 +#define XF86XK_Mail 0x1008FF19 +#define XF86XK_Start 0x1008FF1A +#define XF86XK_Search 0x1008FF1B +#define XF86XK_AudioRecord 0x1008FF1C +#define XF86XK_Calculator 0x1008FF1D +#define XF86XK_Memo 0x1008FF1E +#define XF86XK_ToDoList 0x1008FF1F +#define XF86XK_Calendar 0x1008FF20 +#define XF86XK_PowerDown 0x1008FF21 +#define XF86XK_ContrastAdjust 0x1008FF22 +#define XF86XK_Back 0x1008FF26 +#define XF86XK_Forward 0x1008FF27 +#define XF86XK_Stop 0x1008FF28 +#define XF86XK_Refresh 0x1008FF29 +#define XF86XK_PowerOff 0x1008FF2A +#define XF86XK_WakeUp 0x1008FF2B +#define XF86XK_Eject 0x1008FF2C +#define XF86XK_ScreenSaver 0x1008FF2D +#define XF86XK_WWW 0x1008FF2E +#define XF86XK_Sleep 0x1008FF2F +#define XF86XK_Favorites 0x1008FF30 +#define XF86XK_AudioPause 0x1008FF31 +#define XF86XK_AudioMedia 0x1008FF32 +#define XF86XK_MyComputer 0x1008FF33 +#define XF86XK_LightBulb 0x1008FF35 +#define XF86XK_Shop 0x1008FF36 +#define XF86XK_History 0x1008FF37 +#define XF86XK_OpenURL 0x1008FF38 +#define XF86XK_AddFavorite 0x1008FF39 +#define XF86XK_HotLinks 0x1008FF3A +#define XF86XK_BrightnessAdjust 0x1008FF3B +#define XF86XK_Finance 0x1008FF3C +#define XF86XK_Community 0x1008FF3D +#define XF86XK_AudioRewind 0x1008FF3E +#define XF86XK_BackForward 0x1008FF3F +#define XF86XK_Launch0 0x1008FF40 +#define XF86XK_Launch1 0x1008FF41 +#define XF86XK_Launch2 0x1008FF42 +#define XF86XK_Launch3 0x1008FF43 +#define XF86XK_Launch4 0x1008FF44 +#define XF86XK_Launch5 0x1008FF45 +#define XF86XK_Launch6 0x1008FF46 +#define XF86XK_Launch7 0x1008FF47 +#define XF86XK_Launch8 0x1008FF48 +#define XF86XK_Launch9 0x1008FF49 +#define XF86XK_LaunchA 0x1008FF4A +#define XF86XK_LaunchB 0x1008FF4B +#define XF86XK_LaunchC 0x1008FF4C +#define XF86XK_LaunchD 0x1008FF4D +#define XF86XK_LaunchE 0x1008FF4E +#define XF86XK_LaunchF 0x1008FF4F +#define XF86XK_ApplicationLeft 0x1008FF50 +#define XF86XK_ApplicationRight 0x1008FF51 +#define XF86XK_Book 0x1008FF52 +#define XF86XK_CD 0x1008FF53 +#define XF86XK_Calculater 0x1008FF54 +#define XF86XK_Clear 0x1008FF55 +#define XF86XK_ClearGrab 0x1008FE21 +#define XF86XK_Close 0x1008FF56 +#define XF86XK_Copy 0x1008FF57 +#define XF86XK_Cut 0x1008FF58 +#define XF86XK_Display 0x1008FF59 +#define XF86XK_DOS 0x1008FF5A +#define XF86XK_Documents 0x1008FF5B +#define XF86XK_Excel 0x1008FF5C +#define XF86XK_Explorer 0x1008FF5D +#define XF86XK_Game 0x1008FF5E +#define XF86XK_Go 0x1008FF5F +#define XF86XK_iTouch 0x1008FF60 +#define XF86XK_LogOff 0x1008FF61 +#define XF86XK_Market 0x1008FF62 +#define XF86XK_Meeting 0x1008FF63 +#define XF86XK_MenuKB 0x1008FF65 +#define XF86XK_MenuPB 0x1008FF66 +#define XF86XK_MySites 0x1008FF67 +#define XF86XK_News 0x1008FF69 +#define XF86XK_OfficeHome 0x1008FF6A +#define XF86XK_Option 0x1008FF6C +#define XF86XK_Paste 0x1008FF6D +#define XF86XK_Phone 0x1008FF6E +#define XF86XK_Reply 0x1008FF72 +#define XF86XK_Reload 0x1008FF73 +#define XF86XK_RotateWindows 0x1008FF74 +#define XF86XK_RotationPB 0x1008FF75 +#define XF86XK_RotationKB 0x1008FF76 +#define XF86XK_Save 0x1008FF77 +#define XF86XK_Send 0x1008FF7B +#define XF86XK_Spell 0x1008FF7C +#define XF86XK_SplitScreen 0x1008FF7D +#define XF86XK_Support 0x1008FF7E +#define XF86XK_TaskPane 0x1008FF7F +#define XF86XK_Terminal 0x1008FF80 +#define XF86XK_Tools 0x1008FF81 +#define XF86XK_Travel 0x1008FF82 +#define XF86XK_Video 0x1008FF87 +#define XF86XK_Word 0x1008FF89 +#define XF86XK_Xfer 0x1008FF8A +#define XF86XK_ZoomIn 0x1008FF8B +#define XF86XK_ZoomOut 0x1008FF8C +#define XF86XK_Away 0x1008FF8D +#define XF86XK_Messenger 0x1008FF8E +#define XF86XK_WebCam 0x1008FF8F +#define XF86XK_MailForward 0x1008FF90 +#define XF86XK_Pictures 0x1008FF91 +#define XF86XK_Music 0x1008FF92 +#define XF86XK_Battery 0x1008FF93 +#define XF86XK_Bluetooth 0x1008FF94 +#define XF86XK_WLAN 0x1008FF95 +#define XF86XK_UWB 0x1008FF96 +#define XF86XK_AudioForward 0x1008FF97 +#define XF86XK_AudioRepeat 0x1008FF98 +#define XF86XK_AudioRandomPlay 0x1008FF99 +#define XF86XK_Subtitle 0x1008FF9A +#define XF86XK_AudioCycleTrack 0x1008FF9B +#define XF86XK_Time 0x1008FF9F +#define XF86XK_Select 0x1008FFA0 +#define XF86XK_View 0x1008FFA1 +#define XF86XK_TopMenu 0x1008FFA2 +#define XF86XK_Suspend 0x1008FFA7 +#define XF86XK_Hibernate 0x1008FFA8 + + // end of XF86keysyms.h // Special keys used by Qtopia, mapped into the X11 private keypad range. @@ -942,10 +1039,8 @@ static const unsigned int KeyTbl[] = { XK_dead_hook, Qt::Key_Dead_Hook, XK_dead_horn, Qt::Key_Dead_Horn, - // Special multimedia keys - // currently only tested with MS internet keyboard - - // browsing keys + // Special keys from X.org - This include multimedia keys, + // wireless/bluetooth/uwb keys, special launcher keys, etc. XF86XK_Back, Qt::Key_Back, XF86XK_Forward, Qt::Key_Forward, XF86XK_Stop, Qt::Key_Stop, @@ -955,8 +1050,6 @@ static const unsigned int KeyTbl[] = { XF86XK_OpenURL, Qt::Key_OpenUrl, XF86XK_HomePage, Qt::Key_HomePage, XF86XK_Search, Qt::Key_Search, - - // media keys XF86XK_AudioLowerVolume, Qt::Key_VolumeDown, XF86XK_AudioMute, Qt::Key_VolumeMute, XF86XK_AudioRaiseVolume, Qt::Key_VolumeUp, @@ -965,13 +1058,106 @@ static const unsigned int KeyTbl[] = { XF86XK_AudioPrev, Qt::Key_MediaPrevious, XF86XK_AudioNext, Qt::Key_MediaNext, XF86XK_AudioRecord, Qt::Key_MediaRecord, - - // launch keys XF86XK_Mail, Qt::Key_LaunchMail, XF86XK_MyComputer, Qt::Key_Launch0, - XF86XK_Calculator, Qt::Key_Launch1, + XF86XK_Calculator, Qt::Key_Calculator, + XF86XK_Memo, Qt::Key_Memo, + XF86XK_ToDoList, Qt::Key_ToDoList, + XF86XK_Calendar, Qt::Key_Calendar, + XF86XK_PowerDown, Qt::Key_PowerDown, + XF86XK_ContrastAdjust, Qt::Key_ContrastAdjust, XF86XK_Standby, Qt::Key_Standby, - + XF86XK_MonBrightnessUp, Qt::Key_MonBrightnessUp, + XF86XK_MonBrightnessDown, Qt::Key_MonBrightnessDown, + XF86XK_KbdLightOnOff, Qt::Key_KeyboardLightOnOff, + XF86XK_KbdBrightnessUp, Qt::Key_KeyboardBrightnessUp, + XF86XK_KbdBrightnessDown, Qt::Key_KeyboardBrightnessDown, + XF86XK_PowerOff, Qt::Key_PowerOff, + XF86XK_WakeUp, Qt::Key_WakeUp, + XF86XK_Eject, Qt::Key_Eject, + XF86XK_ScreenSaver, Qt::Key_ScreenSaver, + XF86XK_WWW, Qt::Key_WWW, + XF86XK_Sleep, Qt::Key_Sleep, + XF86XK_LightBulb, Qt::Key_LightBulb, + XF86XK_Shop, Qt::Key_Shop, + XF86XK_History, Qt::Key_History, + XF86XK_AddFavorite, Qt::Key_AddFavorite, + XF86XK_HotLinks, Qt::Key_HotLinks, + XF86XK_BrightnessAdjust, Qt::Key_BrightnessAdjust, + XF86XK_Finance, Qt::Key_Finance, + XF86XK_Community, Qt::Key_Community, + XF86XK_AudioRewind, Qt::Key_AudioRewind, + XF86XK_BackForward, Qt::Key_BackForward, + XF86XK_ApplicationLeft, Qt::Key_ApplicationLeft, + XF86XK_ApplicationRight, Qt::Key_ApplicationRight, + XF86XK_Book, Qt::Key_Book, + XF86XK_CD, Qt::Key_CD, + XF86XK_Calculater, Qt::Key_Calculator, + XF86XK_Clear, Qt::Key_Clear, + XF86XK_ClearGrab, Qt::Key_ClearGrab, + XF86XK_Close, Qt::Key_Close, + XF86XK_Copy, Qt::Key_Copy, + XF86XK_Cut, Qt::Key_Cut, + XF86XK_Display, Qt::Key_Display, + XF86XK_DOS, Qt::Key_DOS, + XF86XK_Documents, Qt::Key_Documents, + XF86XK_Excel, Qt::Key_Excel, + XF86XK_Explorer, Qt::Key_Explorer, + XF86XK_Game, Qt::Key_Game, + XF86XK_Go, Qt::Key_Go, + XF86XK_iTouch, Qt::Key_iTouch, + XF86XK_LogOff, Qt::Key_LogOff, + XF86XK_Market, Qt::Key_Market, + XF86XK_Meeting, Qt::Key_Meeting, + XF86XK_MenuKB, Qt::Key_MenuKB, + XF86XK_MenuPB, Qt::Key_MenuPB, + XF86XK_MySites, Qt::Key_MySites, + XF86XK_News, Qt::Key_News, + XF86XK_OfficeHome, Qt::Key_OfficeHome, + XF86XK_Option, Qt::Key_Option, + XF86XK_Paste, Qt::Key_Paste, + XF86XK_Phone, Qt::Key_Phone, + XF86XK_Reply, Qt::Key_Reply, + XF86XK_Reload, Qt::Key_Reload, + XF86XK_RotateWindows, Qt::Key_RotateWindows, + XF86XK_RotationPB, Qt::Key_RotationPB, + XF86XK_RotationKB, Qt::Key_RotationKB, + XF86XK_Save, Qt::Key_Save, + XF86XK_Send, Qt::Key_Send, + XF86XK_Spell, Qt::Key_Spell, + XF86XK_SplitScreen, Qt::Key_SplitScreen, + XF86XK_Support, Qt::Key_Support, + XF86XK_TaskPane, Qt::Key_TaskPane, + XF86XK_Terminal, Qt::Key_Terminal, + XF86XK_Tools, Qt::Key_Tools, + XF86XK_Travel, Qt::Key_Travel, + XF86XK_Video, Qt::Key_Video, + XF86XK_Word, Qt::Key_Word, + XF86XK_Xfer, Qt::Key_Xfer, + XF86XK_ZoomIn, Qt::Key_ZoomIn, + XF86XK_ZoomOut, Qt::Key_ZoomOut, + XF86XK_Away, Qt::Key_Away, + XF86XK_Messenger, Qt::Key_Messenger, + XF86XK_WebCam, Qt::Key_WebCam, + XF86XK_MailForward, Qt::Key_MailForward, + XF86XK_Pictures, Qt::Key_Pictures, + XF86XK_Music, Qt::Key_Music, + XF86XK_Battery, Qt::Key_Battery, + XF86XK_Bluetooth, Qt::Key_Bluetooth, + XF86XK_WLAN, Qt::Key_WLAN, + XF86XK_UWB, Qt::Key_UWB, + XF86XK_AudioForward, Qt::Key_AudioForward, + XF86XK_AudioRepeat, Qt::Key_AudioRepeat, + XF86XK_AudioRandomPlay, Qt::Key_AudioRandomPlay, + XF86XK_Subtitle, Qt::Key_Subtitle, + XF86XK_AudioCycleTrack, Qt::Key_AudioCycleTrack, + XF86XK_Time, Qt::Key_Time, + XF86XK_Select, Qt::Key_Select, + XF86XK_View, Qt::Key_View, + XF86XK_TopMenu, Qt::Key_TopMenu, + XF86XK_Bluetooth, Qt::Key_Bluetooth, + XF86XK_Suspend, Qt::Key_Suspend, + XF86XK_Hibernate, Qt::Key_Hibernate, XF86XK_Launch0, Qt::Key_Launch2, XF86XK_Launch1, Qt::Key_Launch3, XF86XK_Launch2, Qt::Key_Launch4, diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index b44ef7f..1a76083 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -416,47 +416,139 @@ static const struct { { Qt::Key_Menu, QT_TRANSLATE_NOOP("QShortcut", "Menu") }, { Qt::Key_Help, QT_TRANSLATE_NOOP("QShortcut", "Help") }, - // Multimedia keys - { Qt::Key_Back, QT_TRANSLATE_NOOP("QShortcut", "Back") }, - { Qt::Key_Forward, QT_TRANSLATE_NOOP("QShortcut", "Forward") }, - { Qt::Key_Stop, QT_TRANSLATE_NOOP("QShortcut", "Stop") }, - { Qt::Key_Refresh, QT_TRANSLATE_NOOP("QShortcut", "Refresh") }, - { Qt::Key_VolumeDown, QT_TRANSLATE_NOOP("QShortcut", "Volume Down") }, - { Qt::Key_VolumeMute, QT_TRANSLATE_NOOP("QShortcut", "Volume Mute") }, - { Qt::Key_VolumeUp, QT_TRANSLATE_NOOP("QShortcut", "Volume Up") }, - { Qt::Key_BassBoost, QT_TRANSLATE_NOOP("QShortcut", "Bass Boost") }, - { Qt::Key_BassUp, QT_TRANSLATE_NOOP("QShortcut", "Bass Up") }, - { Qt::Key_BassDown, QT_TRANSLATE_NOOP("QShortcut", "Bass Down") }, - { Qt::Key_TrebleUp, QT_TRANSLATE_NOOP("QShortcut", "Treble Up") }, - { Qt::Key_TrebleDown, QT_TRANSLATE_NOOP("QShortcut", "Treble Down") }, - { Qt::Key_MediaPlay, QT_TRANSLATE_NOOP("QShortcut", "Media Play") }, - { Qt::Key_MediaStop, QT_TRANSLATE_NOOP("QShortcut", "Media Stop") }, - { Qt::Key_MediaPrevious,QT_TRANSLATE_NOOP("QShortcut", "Media Previous") }, - { Qt::Key_MediaNext, QT_TRANSLATE_NOOP("QShortcut", "Media Next") }, - { Qt::Key_MediaRecord, QT_TRANSLATE_NOOP("QShortcut", "Media Record") }, - { Qt::Key_HomePage, QT_TRANSLATE_NOOP("QShortcut", "Home Page") }, - { Qt::Key_Favorites, QT_TRANSLATE_NOOP("QShortcut", "Favorites") }, - { Qt::Key_Search, QT_TRANSLATE_NOOP("QShortcut", "Search") }, - { Qt::Key_Standby, QT_TRANSLATE_NOOP("QShortcut", "Standby") }, - { Qt::Key_OpenUrl, QT_TRANSLATE_NOOP("QShortcut", "Open URL") }, - { Qt::Key_LaunchMail, QT_TRANSLATE_NOOP("QShortcut", "Launch Mail") }, - { Qt::Key_LaunchMedia, QT_TRANSLATE_NOOP("QShortcut", "Launch Media") }, - { Qt::Key_Launch0, QT_TRANSLATE_NOOP("QShortcut", "Launch (0)") }, - { Qt::Key_Launch1, QT_TRANSLATE_NOOP("QShortcut", "Launch (1)") }, - { Qt::Key_Launch2, QT_TRANSLATE_NOOP("QShortcut", "Launch (2)") }, - { Qt::Key_Launch3, QT_TRANSLATE_NOOP("QShortcut", "Launch (3)") }, - { Qt::Key_Launch4, QT_TRANSLATE_NOOP("QShortcut", "Launch (4)") }, - { Qt::Key_Launch5, QT_TRANSLATE_NOOP("QShortcut", "Launch (5)") }, - { Qt::Key_Launch6, QT_TRANSLATE_NOOP("QShortcut", "Launch (6)") }, - { Qt::Key_Launch7, QT_TRANSLATE_NOOP("QShortcut", "Launch (7)") }, - { Qt::Key_Launch8, QT_TRANSLATE_NOOP("QShortcut", "Launch (8)") }, - { Qt::Key_Launch9, QT_TRANSLATE_NOOP("QShortcut", "Launch (9)") }, - { Qt::Key_LaunchA, QT_TRANSLATE_NOOP("QShortcut", "Launch (A)") }, - { Qt::Key_LaunchB, QT_TRANSLATE_NOOP("QShortcut", "Launch (B)") }, - { Qt::Key_LaunchC, QT_TRANSLATE_NOOP("QShortcut", "Launch (C)") }, - { Qt::Key_LaunchD, QT_TRANSLATE_NOOP("QShortcut", "Launch (D)") }, - { Qt::Key_LaunchE, QT_TRANSLATE_NOOP("QShortcut", "Launch (E)") }, - { Qt::Key_LaunchF, QT_TRANSLATE_NOOP("QShortcut", "Launch (F)") }, + // Special keys + // Includes multimedia, launcher, lan keys ( bluetooth, wireless ) + // window navigation + { Qt::Key_Back, QT_TRANSLATE_NOOP("QShortcut", "Back") }, + { Qt::Key_Forward, QT_TRANSLATE_NOOP("QShortcut", "Forward") }, + { Qt::Key_Stop, QT_TRANSLATE_NOOP("QShortcut", "Stop") }, + { Qt::Key_Refresh, QT_TRANSLATE_NOOP("QShortcut", "Refresh") }, + { Qt::Key_VolumeDown, QT_TRANSLATE_NOOP("QShortcut", "Volume Down") }, + { Qt::Key_VolumeMute, QT_TRANSLATE_NOOP("QShortcut", "Volume Mute") }, + { Qt::Key_VolumeUp, QT_TRANSLATE_NOOP("QShortcut", "Volume Up") }, + { Qt::Key_BassBoost, QT_TRANSLATE_NOOP("QShortcut", "Bass Boost") }, + { Qt::Key_BassUp, QT_TRANSLATE_NOOP("QShortcut", "Bass Up") }, + { Qt::Key_BassDown, QT_TRANSLATE_NOOP("QShortcut", "Bass Down") }, + { Qt::Key_TrebleUp, QT_TRANSLATE_NOOP("QShortcut", "Treble Up") }, + { Qt::Key_TrebleDown, QT_TRANSLATE_NOOP("QShortcut", "Treble Down") }, + { Qt::Key_MediaPlay, QT_TRANSLATE_NOOP("QShortcut", "Media Play") }, + { Qt::Key_MediaStop, QT_TRANSLATE_NOOP("QShortcut", "Media Stop") }, + { Qt::Key_MediaPrevious, QT_TRANSLATE_NOOP("QShortcut", "Media Previous") }, + { Qt::Key_MediaNext, QT_TRANSLATE_NOOP("QShortcut", "Media Next") }, + { Qt::Key_MediaRecord, QT_TRANSLATE_NOOP("QShortcut", "Media Record") }, + { Qt::Key_HomePage, QT_TRANSLATE_NOOP("QShortcut", "Home Page") }, + { Qt::Key_Favorites, QT_TRANSLATE_NOOP("QShortcut", "Favorites") }, + { Qt::Key_Search, QT_TRANSLATE_NOOP("QShortcut", "Search") }, + { Qt::Key_Standby, QT_TRANSLATE_NOOP("QShortcut", "Standby") }, + { Qt::Key_OpenUrl, QT_TRANSLATE_NOOP("QShortcut", "Open URL") }, + { Qt::Key_LaunchMail, QT_TRANSLATE_NOOP("QShortcut", "Launch Mail") }, + { Qt::Key_LaunchMedia, QT_TRANSLATE_NOOP("QShortcut", "Launch Media") }, + { Qt::Key_Launch0, QT_TRANSLATE_NOOP("QShortcut", "Launch (0)") }, + { Qt::Key_Launch1, QT_TRANSLATE_NOOP("QShortcut", "Launch (1)") }, + { Qt::Key_Launch2, QT_TRANSLATE_NOOP("QShortcut", "Launch (2)") }, + { Qt::Key_Launch3, QT_TRANSLATE_NOOP("QShortcut", "Launch (3)") }, + { Qt::Key_Launch4, QT_TRANSLATE_NOOP("QShortcut", "Launch (4)") }, + { Qt::Key_Launch5, QT_TRANSLATE_NOOP("QShortcut", "Launch (5)") }, + { Qt::Key_Launch6, QT_TRANSLATE_NOOP("QShortcut", "Launch (6)") }, + { Qt::Key_Launch7, QT_TRANSLATE_NOOP("QShortcut", "Launch (7)") }, + { Qt::Key_Launch8, QT_TRANSLATE_NOOP("QShortcut", "Launch (8)") }, + { Qt::Key_Launch9, QT_TRANSLATE_NOOP("QShortcut", "Launch (9)") }, + { Qt::Key_LaunchA, QT_TRANSLATE_NOOP("QShortcut", "Launch (A)") }, + { Qt::Key_LaunchB, QT_TRANSLATE_NOOP("QShortcut", "Launch (B)") }, + { Qt::Key_LaunchC, QT_TRANSLATE_NOOP("QShortcut", "Launch (C)") }, + { Qt::Key_LaunchD, QT_TRANSLATE_NOOP("QShortcut", "Launch (D)") }, + { Qt::Key_LaunchE, QT_TRANSLATE_NOOP("QShortcut", "Launch (E)") }, + { Qt::Key_LaunchF, QT_TRANSLATE_NOOP("QShortcut", "Launch (F)") }, + { Qt::Key_MonBrightnessUp, QT_TRANSLATE_NOOP("QShortcut", "Monitor Brightness Up") }, + { Qt::Key_MonBrightnessDown, QT_TRANSLATE_NOOP("QShortcut", "Monitor Brightness Down") }, + { Qt::Key_KeyboardLightOnOff, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Light On/Off") }, + { Qt::Key_KeyboardBrightnessUp, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Brightness Up") }, + { Qt::Key_KeyboardBrightnessDown, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Brightness Down") }, + { Qt::Key_PowerOff, QT_TRANSLATE_NOOP("QShortcut", "Power Off") }, + { Qt::Key_WakeUp, QT_TRANSLATE_NOOP("QShortcut", "Wake Up") }, + { Qt::Key_Eject, QT_TRANSLATE_NOOP("QShortcut", "Eject") }, + { Qt::Key_ScreenSaver, QT_TRANSLATE_NOOP("QShortcut", "Screensaver") }, + { Qt::Key_WWW, QT_TRANSLATE_NOOP("QShortcut", "WWW") }, + { Qt::Key_Sleep, QT_TRANSLATE_NOOP("QShortcut", "Sleep") }, + { Qt::Key_LightBulb, QT_TRANSLATE_NOOP("QShortcut", "LightBulb") }, + { Qt::Key_Shop, QT_TRANSLATE_NOOP("QShortcut", "Shop") }, + { Qt::Key_History, QT_TRANSLATE_NOOP("QShortcut", "History") }, + { Qt::Key_AddFavorite, QT_TRANSLATE_NOOP("QShortcut", "Add Favorite") }, + { Qt::Key_HotLinks, QT_TRANSLATE_NOOP("QShortcut", "Hot Links") }, + { Qt::Key_BrightnessAdjust, QT_TRANSLATE_NOOP("QShortcut", "Adjust Brightness") }, + { Qt::Key_Finance, QT_TRANSLATE_NOOP("QShortcut", "Finance") }, + { Qt::Key_Community, QT_TRANSLATE_NOOP("QShortcut", "Community") }, + { Qt::Key_AudioRewind, QT_TRANSLATE_NOOP("QShortcut", "Audio Rewind") }, + { Qt::Key_BackForward, QT_TRANSLATE_NOOP("QShortcut", "Back Forward") }, + { Qt::Key_ApplicationLeft, QT_TRANSLATE_NOOP("QShortcut", "Application Left") }, + { Qt::Key_ApplicationRight, QT_TRANSLATE_NOOP("QShortcut", "Application Right") }, + { Qt::Key_Book, QT_TRANSLATE_NOOP("QShortcut", "Book") }, + { Qt::Key_CD, QT_TRANSLATE_NOOP("QShortcut", "CD") }, + { Qt::Key_Calculator, QT_TRANSLATE_NOOP("QShortcut", "Calculator") }, + { Qt::Key_Clear, QT_TRANSLATE_NOOP("QShortcut", "Clear") }, + { Qt::Key_ClearGrab, QT_TRANSLATE_NOOP("QShortcut", "Clear Grab") }, + { Qt::Key_Close, QT_TRANSLATE_NOOP("QShortcut", "Close") }, + { Qt::Key_Copy, QT_TRANSLATE_NOOP("QShortcut", "Copy") }, + { Qt::Key_Cut, QT_TRANSLATE_NOOP("QShortcut", "Cut") }, + { Qt::Key_Display, QT_TRANSLATE_NOOP("QShortcut", "Display") }, + { Qt::Key_DOS, QT_TRANSLATE_NOOP("QShortcut", "DOS") }, + { Qt::Key_Documents, QT_TRANSLATE_NOOP("QShortcut", "Documents") }, + { Qt::Key_Excel, QT_TRANSLATE_NOOP("QShortcut", "Spreadsheet") }, + { Qt::Key_Explorer, QT_TRANSLATE_NOOP("QShortcut", "Browser") }, + { Qt::Key_Game, QT_TRANSLATE_NOOP("QShortcut", "Game") }, + { Qt::Key_Go, QT_TRANSLATE_NOOP("QShortcut", "Go") }, + { Qt::Key_iTouch, QT_TRANSLATE_NOOP("QShortcut", "iTouch") }, + { Qt::Key_LogOff, QT_TRANSLATE_NOOP("QShortcut", "Logoff") }, + { Qt::Key_Market, QT_TRANSLATE_NOOP("QShortcut", "Market") }, + { Qt::Key_Meeting, QT_TRANSLATE_NOOP("QShortcut", "Meeting") }, + { Qt::Key_MenuKB, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Menu") }, + { Qt::Key_MenuPB, QT_TRANSLATE_NOOP("QShortcut", "Menu PB") }, + { Qt::Key_MySites, QT_TRANSLATE_NOOP("QShortcut", "My Sites") }, + { Qt::Key_News, QT_TRANSLATE_NOOP("QShortcut", "News") }, + { Qt::Key_OfficeHome, QT_TRANSLATE_NOOP("QShortcut", "Home Office") }, + { Qt::Key_Option, QT_TRANSLATE_NOOP("QShortcut", "Option") }, + { Qt::Key_Paste, QT_TRANSLATE_NOOP("QShortcut", "Paste") }, + { Qt::Key_Phone, QT_TRANSLATE_NOOP("QShortcut", "Phone") }, + { Qt::Key_Reply, QT_TRANSLATE_NOOP("QShortcut", "Reply") }, + { Qt::Key_Reload, QT_TRANSLATE_NOOP("QShortcut", "Reload") }, + { Qt::Key_RotateWindows, QT_TRANSLATE_NOOP("QShortcut", "Rotate Windows") }, + { Qt::Key_RotationPB, QT_TRANSLATE_NOOP("QShortcut", "Rotation PB") }, + { Qt::Key_RotationKB, QT_TRANSLATE_NOOP("QShortcut", "Rotation KB") }, + { Qt::Key_Save, QT_TRANSLATE_NOOP("QShortcut", "Save") }, + { Qt::Key_Send, QT_TRANSLATE_NOOP("QShortcut", "Send") }, + { Qt::Key_Spell, QT_TRANSLATE_NOOP("QShortcut", "Spellchecker") }, + { Qt::Key_SplitScreen, QT_TRANSLATE_NOOP("QShortcut", "Split Screen") }, + { Qt::Key_Support, QT_TRANSLATE_NOOP("QShortcut", "Support") }, + { Qt::Key_TaskPane, QT_TRANSLATE_NOOP("QShortcut", "Task Panel") }, + { Qt::Key_Terminal, QT_TRANSLATE_NOOP("QShortcut", "Terminal") }, + { Qt::Key_Tools, QT_TRANSLATE_NOOP("QShortcut", "Tools") }, + { Qt::Key_Travel, QT_TRANSLATE_NOOP("QShortcut", "Travel") }, + { Qt::Key_Video, QT_TRANSLATE_NOOP("QShortcut", "Video") }, + { Qt::Key_Word, QT_TRANSLATE_NOOP("QShortcut", "Word Processor") }, + { Qt::Key_Xfer, QT_TRANSLATE_NOOP("QShortcut", "XFer") }, + { Qt::Key_ZoomIn, QT_TRANSLATE_NOOP("QShortcut", "Zoom In") }, + { Qt::Key_ZoomOut, QT_TRANSLATE_NOOP("QShortcut", "Zoom Out") }, + { Qt::Key_Away, QT_TRANSLATE_NOOP("QShortcut", "Away") }, + { Qt::Key_Messenger, QT_TRANSLATE_NOOP("QShortcut", "Messenger") }, + { Qt::Key_WebCam, QT_TRANSLATE_NOOP("QShortcut", "WebCam") }, + { Qt::Key_MailForward, QT_TRANSLATE_NOOP("QShortcut", "Mail Forward") }, + { Qt::Key_Pictures, QT_TRANSLATE_NOOP("QShortcut", "Pictures") }, + { Qt::Key_Music, QT_TRANSLATE_NOOP("QShortcut", "Music") }, + { Qt::Key_Battery, QT_TRANSLATE_NOOP("QShortcut", "Battery") }, + { Qt::Key_Bluetooth, QT_TRANSLATE_NOOP("QShortcut", "Bluetooth") }, + { Qt::Key_WLAN, QT_TRANSLATE_NOOP("QShortcut", "Wireless") }, + { Qt::Key_UWB, QT_TRANSLATE_NOOP("QShortcut", "Ultra Wide Band") }, + { Qt::Key_AudioForward, QT_TRANSLATE_NOOP("QShortcut", "Audio Forward") }, + { Qt::Key_AudioRepeat, QT_TRANSLATE_NOOP("QShortcut", "Audio Repeat") }, + { Qt::Key_AudioRandomPlay, QT_TRANSLATE_NOOP("QShortcut", "Audio Random Play") }, + { Qt::Key_Subtitle, QT_TRANSLATE_NOOP("QShortcut", "Subtitle") }, + { Qt::Key_AudioCycleTrack, QT_TRANSLATE_NOOP("QShortcut", "Audio Cycle Track") }, + { Qt::Key_Time, QT_TRANSLATE_NOOP("QShortcut", "Time") }, + { Qt::Key_Select, QT_TRANSLATE_NOOP("QShortcut", "Select") }, + { Qt::Key_View, QT_TRANSLATE_NOOP("QShortcut", "View") }, + { Qt::Key_TopMenu, QT_TRANSLATE_NOOP("QShortcut", "Top Menu") }, + { Qt::Key_Suspend, QT_TRANSLATE_NOOP("QShortcut", "Suspend") }, + { Qt::Key_Hibernate, QT_TRANSLATE_NOOP("QShortcut", "Hibernate") }, // -------------------------------------------------------------- // More consistent namings -- cgit v0.12 From 0313ccbfaff690c5a8fc18a3a2c7d976a4a55aaf Mon Sep 17 00:00:00 2001 From: Gustavo Pichorim Boiko Date: Tue, 27 Oct 2009 18:16:11 +0100 Subject: Emit workAreaResized() in X11 when it changes Emit the QDesktopWidget::workAreaResized() signal when the _NET_WORKAREA property of the root window changes. Merge-request: 1111 Reviewed-by: Denis Dzyubenko --- src/gui/kernel/qapplication_x11.cpp | 6 ++++++ src/gui/kernel/qdesktopwidget_x11.cpp | 9 --------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index bf95684..c6d188b 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -3750,6 +3750,12 @@ int QApplication::x11ProcessEvent(XEvent* event) qt_get_net_virtual_roots(); } else if (event->xproperty.atom == ATOM(_NET_WORKAREA)) { qt_desktopwidget_update_workarea(); + + // emit the workAreaResized() signal + QDesktopWidget *desktop = QApplication::desktop(); + int numScreens = desktop->numScreens(); + for (int i = 0; i < numScreens; ++i) + emit desktop->workAreaResized(i); } } else if (widget) { widget->translatePropertyEvent(event); diff --git a/src/gui/kernel/qdesktopwidget_x11.cpp b/src/gui/kernel/qdesktopwidget_x11.cpp index 02a2c82..14eb976 100644 --- a/src/gui/kernel/qdesktopwidget_x11.cpp +++ b/src/gui/kernel/qdesktopwidget_x11.cpp @@ -384,10 +384,8 @@ void QDesktopWidget::resizeEvent(QResizeEvent *event) Q_D(QDesktopWidget); int oldScreenCount = d->screenCount; QVector oldRects(oldScreenCount); - QVector oldWorks(oldScreenCount); for (int i = 0; i < oldScreenCount; ++i) { oldRects[i] = d->rects[i]; - oldWorks[i] = d->workareas[i]; } d->init(); @@ -397,13 +395,6 @@ void QDesktopWidget::resizeEvent(QResizeEvent *event) emit resized(i); } - // ### workareas are just reset by init, not filled with new values - // ### so this will not work correctly - for (int j = 0; j < qMin(oldScreenCount, d->screenCount); ++j) { - if (oldWorks.at(j) != d->workareas[j]) - emit workAreaResized(j); - } - if (oldScreenCount != d->screenCount) { emit screenCountChanged(d->screenCount); } -- cgit v0.12 From 0444453661df0f56fd034778028c7abdc0b621cc Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 28 Oct 2009 09:42:09 +0100 Subject: Don't stop event processing at the second WM_QT_SENDPOSTEDEVENTS We should continue processing as much as we can, and report the WM_QT_SENDPOSTEDEVENTS at the end of processEvents(). --- src/corelib/kernel/qeventdispatcher_win.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index df4c02d..d13e1d1 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -663,11 +663,12 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) bool canWait; bool retVal = false; + bool seenWM_QT_SENDPOSTEDEVENTS = false; + bool needWM_QT_SENDPOSTEDEVENTS = false; do { DWORD waitRet = 0; HANDLE pHandles[MAXIMUM_WAIT_OBJECTS - 1]; QVarLengthArray processedTimers; - bool seenWM_QT_SENDPOSTEDEVENTS = false; while (!d->interrupt) { DWORD nCount = d->winEventNotifierList.count(); Q_ASSERT(nCount < MAXIMUM_WAIT_OBJECTS - 1); @@ -717,8 +718,8 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) if (haveMessage) { if (msg.message == WM_QT_SENDPOSTEDEVENTS && !(flags & QEventLoop::EventLoopExec)) { if (seenWM_QT_SENDPOSTEDEVENTS) { - PostMessage(d->internalHwnd, WM_QT_SENDPOSTEDEVENTS, 0, 0); - break; + needWM_QT_SENDPOSTEDEVENTS = true; + continue; } seenWM_QT_SENDPOSTEDEVENTS = true; } else if (msg.message == WM_TIMER) { @@ -770,6 +771,9 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) } } while (canWait); + if (needWM_QT_SENDPOSTEDEVENTS) + PostMessage(d->internalHwnd, WM_QT_SENDPOSTEDEVENTS, 0, 0); + return retVal; } -- cgit v0.12 From 9a9cd7765bfe879b53488fe18bba75425e4c5c61 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 26 Oct 2009 14:20:49 +0100 Subject: add empty test method, should implement it fully when more important things are done --- tests/auto/gestures/tst_gestures.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index eba2616..6acfe70 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -330,6 +330,7 @@ private slots: void testMapToScene(); void ungrabGesture(); void consumeEventHint(); + void unregisterRecognizer(); }; tst_Gestures::tst_Gestures() @@ -1276,5 +1277,20 @@ void tst_Gestures::ungrabGesture() // a method on QWidget QCOMPARE(a->gestureOverrideEventsReceived, 0); } +void tst_Gestures::unregisterRecognizer() // a method on QApplication +{ + /* + The hardest usecase to get right is when we remove a recognizer while several + of the gestures it created are in active state and we immediately add a new recognizer + for the same type (thus replacing the old one). + The expected result is that all old gestures continue till they are finished/cancelled + and the new recognizer starts creating gestures immediately at registration. + + This implies that deleting of the recognizer happens only when there are no more gestures + that it created. (since gestures might have a pointer to the recognizer) + */ + +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" -- cgit v0.12 From 4470801f73b86d3ee06a866fbbdafcaeb9f294a6 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Tue, 27 Oct 2009 15:31:16 +0100 Subject: Introduce QGesture::GestureCancelPolicy, a way to auto-cancel gestures On accepting one gesture Qt can automatically cancel other gestures that belong to other targets. The policy is normally set to not cancel any other gestures and can be set to cancel all active gestures in the context. For example for all child widgets. Reviewed-By: Denis Dzyubenko --- src/gui/kernel/qgesture.cpp | 33 ++++++++++++++ src/gui/kernel/qgesture.h | 10 +++++ src/gui/kernel/qgesture_p.h | 10 +++-- src/gui/kernel/qgesturemanager.cpp | 85 ++++++++++++++++++++++++++++++++++-- src/gui/kernel/qgesturemanager_p.h | 2 + tests/auto/gestures/tst_gestures.cpp | 62 ++++++++++++++++++++++++++ 6 files changed, 195 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index a161876..c302c51 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -175,6 +175,29 @@ void QGesture::unsetHotSpot() } /*! + \enum QGesture::GestureCancelPolicy + + This enum describes how accepting a gesture can cancel other gestures + automatically. + + \value CancelNone On accepting this gesture no other gestures will be affected. + \value CancelAllInContext On accepting this gesture all gestures that are active + in the context (Qt::GestureContext) will be cancelled. +*/ + +void QGesture::setGestureCancelPolicy(GestureCancelPolicy policy) +{ + Q_D(QGesture); + d->gestureCancelPolicy = static_cast(policy); +} + +QGesture::GestureCancelPolicy QGesture::gestureCancelPolicy() const +{ + Q_D(const QGesture); + return static_cast(d->gestureCancelPolicy); +} + +/*! \class QPanGesture \since 4.6 \brief The QPanGesture class describes a panning gesture made by the user. @@ -195,6 +218,16 @@ void QGesture::unsetHotSpot() */ /*! + \property QGesture::GestureCancelPolicy + \brief the policy for deciding what happens on accepting a gesture + + On accepting one gesture Qt can automatically cancel other gestures + that belong to other targets. The policy is normally set to not cancel + any other gestures and can be set to cancel all active gestures in the + context. For example for all child widgets. +*/ + +/*! \property QPanGesture::lastOffset \brief the last offset recorded for this gesture diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h index 6469959..524d26e 100644 --- a/src/gui/kernel/qgesture.h +++ b/src/gui/kernel/qgesture.h @@ -65,6 +65,7 @@ class Q_GUI_EXPORT QGesture : public QObject Q_PROPERTY(Qt::GestureState state READ state) Q_PROPERTY(Qt::GestureType gestureType READ gestureType) + Q_PROPERTY(QGesture::GestureCancelPolicy gestureCancelPolicy READ gestureCancelPolicy WRITE setGestureCancelPolicy) Q_PROPERTY(QPointF hotSpot READ hotSpot WRITE setHotSpot RESET unsetHotSpot) Q_PROPERTY(bool hasHotSpot READ hasHotSpot) @@ -81,6 +82,14 @@ public: bool hasHotSpot() const; void unsetHotSpot(); + enum GestureCancelPolicy { + CancelNone = 0, + CancelAllInContext + }; + + void setGestureCancelPolicy(GestureCancelPolicy policy); + GestureCancelPolicy gestureCancelPolicy() const; + protected: QGesture(QGesturePrivate &dd, QObject *parent); @@ -208,6 +217,7 @@ public: QT_END_NAMESPACE +Q_DECLARE_METATYPE(QGesture::GestureCancelPolicy) QT_END_HEADER #endif // QGESTURE_H diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h index 975c0c9..d2ef8a7 100644 --- a/src/gui/kernel/qgesture_p.h +++ b/src/gui/kernel/qgesture_p.h @@ -67,16 +67,20 @@ class QGesturePrivate : public QObjectPrivate public: QGesturePrivate() - : gestureType(Qt::CustomGesture), state(Qt::NoGesture), isHotSpotSet(false), - targetObject(0) + : gestureType(Qt::CustomGesture), state(Qt::NoGesture), + targetObject(0), + isHotSpotSet(false), + gestureCancelPolicy(0) + { } Qt::GestureType gestureType; Qt::GestureState state; QPointF hotSpot; - bool isHotSpotSet; QObject *targetObject; + uint isHotSpotSet : 1; + uint gestureCancelPolicy : 2; }; class QPanGesturePrivate : public QGesturePrivate diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 52f8eef..fc7c8b2 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -322,21 +322,96 @@ bool QGestureManager::filterEventThroughContexts(const QMapgestureCancelPolicy() == QGesture::CancelAllInContext) { + DEBUG() << "lets try to cancel some"; + // find gestures in context in Qt::GestureStarted or Qt::GestureUpdated state and cancel them + cancelGesturesForChildren(g); + } + } + activeGestures -= undeliveredGestures; // reset gestures that ended QSet endedGestures = finishedGestures + canceledGestures + undeliveredGestures; foreach (QGesture *gesture, endedGestures) { - if (QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0)) + if (QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0)) { + gesture->setGestureCancelPolicy(QGesture::CancelNone); recognizer->reset(gesture); - else + } else { cleanupGesturesForRemovedRecognizer(gesture); + } gestureTargets.remove(gesture); } return ret; } +// Cancel all gestures of children of the widget that original is associated with +void QGestureManager::cancelGesturesForChildren(QGesture *original) +{ + Q_ASSERT(original); + QWidget *originatingWidget = gestureTargets.value(original); + Q_ASSERT(originatingWidget); + + // iterate over all active gestures and all maybe gestures + // for each find the owner + // if the owner is part of our sub-hierarchy, cancel it. + + QSet cancelledGestures; + QSet::Iterator iter = activeGestures.begin(); + while (iter != activeGestures.end()) { + QWidget *widget = gestureTargets.value(*iter); + // note that we don't touch the gestures for our originatingWidget + if (widget != originatingWidget && originatingWidget->isAncestorOf(widget)) { + DEBUG() << " found a gesture to cancel" << (*iter); + (*iter)->d_func()->state = Qt::GestureCanceled; + cancelledGestures << *iter; + iter = activeGestures.erase(iter); + } else { + ++iter; + } + } + + // TODO handle 'maybe' gestures too + + // sort them per target widget by cherry picking from almostCanceledGestures and delivering + QSet almostCanceledGestures = cancelledGestures; + while (!almostCanceledGestures.isEmpty()) { + QWidget *target = 0; + QSet gestures; + iter = almostCanceledGestures.begin(); + // sort per target widget + while (iter != almostCanceledGestures.end()) { + QWidget *widget = gestureTargets.value(*iter); + if (target == 0) + target = widget; + if (target == widget) { + gestures << *iter; + iter = almostCanceledGestures.erase(iter); + } else { + ++iter; + } + } + Q_ASSERT(target); + + QSet undeliveredGestures; + deliverEvents(gestures, &undeliveredGestures); + } + + for (iter = cancelledGestures.begin(); iter != cancelledGestures.end(); ++iter) { + QGestureRecognizer *recognizer = gestureToRecognizer.value(*iter, 0); + if (recognizer) { + (*iter)->setGestureCancelPolicy(QGesture::CancelNone); + recognizer->reset(*iter); + } else { + cleanupGesturesForRemovedRecognizer(*iter); + } + } +} + void QGestureManager::cleanupGesturesForRemovedRecognizer(QGesture *gesture) { QGestureRecognizer *recognizer = m_deletedRecognizers.value(gesture); @@ -585,10 +660,12 @@ void QGestureManager::timerEvent(QTimerEvent *event) DEBUG() << "QGestureManager::timerEvent: gesture stopped due to timeout:" << gesture; QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0); - if (recognizer) + if (recognizer) { + gesture->setGestureCancelPolicy(QGesture::CancelNone); recognizer->reset(gesture); - else + } else { cleanupGesturesForRemovedRecognizer(gesture); + } } else { ++it; } diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index 96c2fb7..e6a1d50 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -135,6 +135,8 @@ private: void getGestureTargets(const QSet &gestures, QMap > *conflicts, QMap > *normal); + + void cancelGesturesForChildren(QGesture *originatingGesture); }; QT_END_NAMESPACE diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 6acfe70..39cdf63 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -331,6 +331,7 @@ private slots: void ungrabGesture(); void consumeEventHint(); void unregisterRecognizer(); + void autoCancelGestures(); }; tst_Gestures::tst_Gestures() @@ -1292,5 +1293,66 @@ void tst_Gestures::unregisterRecognizer() // a method on QApplication } +void tst_Gestures::autoCancelGestures() +{ + class MockRecognizer : public QGestureRecognizer { + public: + QGestureRecognizer::Result filterEvent(QGesture *gesture, QObject *watched, QEvent *event) + { + Q_UNUSED(gesture); + Q_UNUSED(watched); + if (event->type() == QEvent::MouseButtonPress) + return QGestureRecognizer::GestureTriggered; + if (event->type() == QEvent::MouseButtonRelease) + return QGestureRecognizer::GestureFinished; + return QGestureRecognizer::Ignore; + } + }; + + class MockWidget : public GestureWidget { + public: + MockWidget(const char *name) : GestureWidget(name) { } + + bool event(QEvent *event) + { + if (event->type() == QEvent::Gesture) { + QGestureEvent *ge = static_cast(event); + Q_ASSERT(ge->allGestures().count() == 1); // can't use QCOMPARE here... + ge->allGestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext); + } + return GestureWidget::event(event); + } + }; + + MockWidget parent("parent"); // this one sets the cancel policy to CancelAllInContext + parent.resize(300, 100); + GestureWidget *child = new GestureWidget("child", &parent); + child->setGeometry(10, 10, 100, 80); + + Qt::GestureType type = qApp->registerGestureRecognizer(new MockRecognizer()); + parent.grabGesture(type, Qt::WidgetWithChildrenGesture); + child->grabGesture(type, Qt::WidgetWithChildrenGesture); + + /* + An event is send to both the child and the parent, when the child gets it a gesture is triggered + and send to the child. + When the parent gets the event a new gesture is triggered and delivered to the parent. When the + parent gets it he accepts it and that causes the cancel policy to activate. + The cause of that is the gesture for the child is cancelled and send to the child as such. + */ + QMouseEvent event(QEvent::MouseButtonPress, QPoint(20,20), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + QApplication::sendEvent(child, &event); + QCOMPARE(child->events.started.count(), 1); + QCOMPARE(child->events.all.count(), 1); + QCOMPARE(parent.events.all.count(), 0); + child->reset(); + QApplication::sendEvent(&parent, &event); + QCOMPARE(parent.events.all.count(), 1); + QCOMPARE(parent.events.started.count(), 1); + QCOMPARE(child->events.started.count(), 0); + QCOMPARE(child->events.all.count(), 1); + QCOMPARE(child->events.canceled.count(), 1); +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" -- cgit v0.12 From 3c2c1c21b41f600eeaa056b66fe44d5017f9b500 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 28 Oct 2009 10:55:19 +0100 Subject: Drag and drop of plain text doesnot work on Mac. While querying for the text in the pasteboard, it was looking in the wrong place. The helper function qt_mac_get_pasteboardString() always searched in generalPasteboard instead of the pasteboard referred by the QMacPasteboard. Reviewed-by: MortenS --- src/gui/kernel/qclipboard_mac.cpp | 2 +- src/gui/kernel/qt_cocoa_helpers_mac.mm | 19 +++++++++++++------ src/gui/kernel/qt_cocoa_helpers_mac_p.h | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/gui/kernel/qclipboard_mac.cpp b/src/gui/kernel/qclipboard_mac.cpp index 3db647b..8892269 100644 --- a/src/gui/kernel/qclipboard_mac.cpp +++ b/src/gui/kernel/qclipboard_mac.cpp @@ -532,7 +532,7 @@ QMacPasteboard::retrieveData(const QString &format, QVariant::Type) const // Try to get the NSStringPboardType from NSPasteboard, newlines are mapped // correctly (as '\n') in this data. The 'public.utf16-plain-text' type // usually maps newlines to '\r' instead. - QString str = qt_mac_get_pasteboardString(); + QString str = qt_mac_get_pasteboardString(paste); if (!str.isEmpty()) return str; } diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index 2b2259c..c0fb8aa 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -1152,16 +1152,23 @@ CGFloat qt_mac_get_scalefactor() #endif } -QString qt_mac_get_pasteboardString() +QString qt_mac_get_pasteboardString(OSPasteboardRef paste) { QMacCocoaAutoReleasePool pool; - NSPasteboard *pb = [NSPasteboard generalPasteboard]; - NSString *text = [pb stringForType:NSStringPboardType]; - if (text) { - return qt_mac_NSStringToQString(text); + NSPasteboard *pb = nil; + CFStringRef pbname; + if (PasteboardCopyName (paste, &pbname)) { + pb = [NSPasteboard generalPasteboard]; } else { - return QString(); + pb = [NSPasteboard pasteboardWithName:reinterpret_cast(pbname)]; + CFRelease (pbname); } + if (pb) { + NSString *text = [pb stringForType:NSStringPboardType]; + if (text) + return qt_mac_NSStringToQString(text); + } + return QString(); } QPixmap qt_mac_convert_iconref(const IconRef icon, int width, int height) diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/gui/kernel/qt_cocoa_helpers_mac_p.h index 62db064..ea35fb6 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac_p.h +++ b/src/gui/kernel/qt_cocoa_helpers_mac_p.h @@ -170,7 +170,7 @@ void *qt_mac_QStringListToNSMutableArrayVoid(const QStringList &list); void qt_syncCocoaTitleBarButtons(OSWindowRef window, QWidget *widgetForWindow); CGFloat qt_mac_get_scalefactor(); -QString qt_mac_get_pasteboardString(); +QString qt_mac_get_pasteboardString(OSPasteboardRef paste); #ifdef __OBJC__ inline NSMutableArray *qt_mac_QStringListToNSMutableArray(const QStringList &qstrlist) -- cgit v0.12 From 7f2d0fdf064f1e5625b784a5712d21545cf79ba1 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 28 Oct 2009 12:49:38 +0100 Subject: Rename private member variables to begin with m_ Reviewed-By: TrustMe --- src/gui/kernel/qgesturemanager.cpp | 116 ++++++++++++++++++------------------- src/gui/kernel/qgesturemanager_p.h | 17 +++--- 2 files changed, 66 insertions(+), 67 deletions(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index fc7c8b2..a90c299 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE QGestureManager::QGestureManager(QObject *parent) - : QObject(parent), state(NotGesture), lastCustomGestureId(0) + : QObject(parent), state(NotGesture), m_lastCustomGestureId(0) { qRegisterMetaType(); @@ -82,7 +82,7 @@ QGestureManager::QGestureManager(QObject *parent) QGestureManager::~QGestureManager() { - qDeleteAll(recognizers.values()); + qDeleteAll(m_recognizers.values()); } Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *recognizer) @@ -96,30 +96,30 @@ Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *r Qt::GestureType type = dummy->gestureType(); if (type == Qt::CustomGesture) { // generate a new custom gesture id - ++lastCustomGestureId; - type = Qt::GestureType(Qt::CustomGesture + lastCustomGestureId); + ++m_lastCustomGestureId; + type = Qt::GestureType(Qt::CustomGesture + m_lastCustomGestureId); } - recognizers.insertMulti(type, recognizer); + m_recognizers.insertMulti(type, recognizer); delete dummy; return type; } void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) { - QList list = recognizers.values(type); - recognizers.remove(type); - foreach (QGesture* g, gestureToRecognizer.keys()) { - QGestureRecognizer *recognizer = gestureToRecognizer.value(g); + QList list = m_recognizers.values(type); + m_recognizers.remove(type); + foreach (QGesture* g, m_gestureToRecognizer.keys()) { + QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g); if (list.contains(recognizer)) { m_deletedRecognizers.insert(g, recognizer); - gestureToRecognizer.remove(g); + m_gestureToRecognizer.remove(g); } } foreach (QGestureRecognizer *recognizer, list) { QList obsoleteGestures; - QMap::Iterator iter = objectGestures.begin(); - while (iter != objectGestures.end()) { + QMap::Iterator iter = m_objectGestures.begin(); + while (iter != m_objectGestures.end()) { ObjectGesture objectGesture = iter.key(); if (objectGesture.gesture == type) obsoleteGestures << iter.value(); @@ -131,12 +131,12 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType type) { - QMap::Iterator iter = objectGestures.begin(); - while (iter != objectGestures.end()) { + QMap::Iterator iter = m_objectGestures.begin(); + while (iter != m_objectGestures.end()) { ObjectGesture objectGesture = iter.key(); if (objectGesture.gesture == type && target == objectGesture.object.data()) { delete iter.value(); - iter = objectGestures.erase(iter); + iter = m_objectGestures.erase(iter); } else { ++iter; } @@ -159,9 +159,9 @@ QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type) } QGesture *state = - objectGestures.value(QGestureManager::ObjectGesture(object, type)); + m_objectGestures.value(QGestureManager::ObjectGesture(object, type)); if (!state) { - QGestureRecognizer *recognizer = recognizers.value(type); + QGestureRecognizer *recognizer = m_recognizers.value(type); if (recognizer) { state = recognizer->createGesture(object); if (!state) @@ -175,9 +175,9 @@ QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type) state->setObjectName(QString::number((int)type)); #endif } - objectGestures.insert(QGestureManager::ObjectGesture(object, type), state); - gestureToRecognizer[state] = recognizer; - gestureOwners[state] = object; + m_objectGestures.insert(QGestureManager::ObjectGesture(object, type), state); + m_gestureToRecognizer[state] = recognizer; + m_gestureOwners[state] = object; } } return state; @@ -203,8 +203,8 @@ bool QGestureManager::filterEventThroughContexts(const QMap::const_iterator - rit = recognizers.lowerBound(gestureType), - re = recognizers.upperBound(gestureType); + rit = m_recognizers.lowerBound(gestureType), + re = m_recognizers.upperBound(gestureType); for (; rit != re; ++rit) { QGestureRecognizer *recognizer = rit.value(); QObject *target = cit.key(); @@ -239,20 +239,20 @@ bool QGestureManager::filterEventThroughContexts(const QMap startedGestures = triggeredGestures - activeGestures; - triggeredGestures &= activeGestures; + QSet startedGestures = triggeredGestures - m_activeGestures; + triggeredGestures &= m_activeGestures; // check if a running gesture switched back to maybe state - QSet activeToMaybeGestures = activeGestures & newMaybeGestures; + QSet activeToMaybeGestures = m_activeGestures & newMaybeGestures; // check if a running gesture switched back to not gesture state, // i.e. were canceled - QSet activeToCancelGestures = activeGestures & notGestures; + QSet activeToCancelGestures = m_activeGestures & notGestures; canceledGestures += activeToCancelGestures; // start timers for new gestures in maybe state foreach (QGesture *state, newMaybeGestures) { - QBasicTimer &timer = maybeGestures[state]; + QBasicTimer &timer = m_maybeGestures[state]; if (!timer.isActive()) timer.start(3000, this); } @@ -262,10 +262,10 @@ bool QGestureManager::filterEventThroughContexts(const QMap::iterator it = - maybeGestures.find(gesture); - if (it != maybeGestures.end()) { + m_maybeGestures.find(gesture); + if (it != m_maybeGestures.end()) { it.value().stop(); - maybeGestures.erase(it); + m_maybeGestures.erase(it); } } @@ -276,7 +276,7 @@ bool QGestureManager::filterEventThroughContexts(const QMap notStarted = finishedGestures - activeGestures; + QSet notStarted = finishedGestures - m_activeGestures; if (!notStarted.isEmpty()) { // there are some gestures that claim to be finished, but never started. // probably those are "singleshot" gestures so we'll fake the started state. @@ -287,12 +287,12 @@ bool QGestureManager::filterEventThroughContexts(const QMapd_func()->state = Qt::GestureFinished; - if (!activeGestures.isEmpty() || !maybeGestures.isEmpty() || + if (!m_activeGestures.isEmpty() || !m_maybeGestures.isEmpty() || !startedGestures.isEmpty() || !triggeredGestures.isEmpty() || !finishedGestures.isEmpty() || !canceledGestures.isEmpty()) { DEBUG() << "QGestureManager::filterEventThroughContexts:" - << "\n\tactiveGestures:" << activeGestures - << "\n\tmaybeGestures:" << maybeGestures.keys() + << "\n\tactiveGestures:" << m_activeGestures + << "\n\tmaybeGestures:" << m_maybeGestures.keys() << "\n\tstarted:" << startedGestures << "\n\ttriggered:" << triggeredGestures << "\n\tfinished:" << finishedGestures @@ -332,19 +332,19 @@ bool QGestureManager::filterEventThroughContexts(const QMap endedGestures = finishedGestures + canceledGestures + undeliveredGestures; foreach (QGesture *gesture, endedGestures) { - if (QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0)) { + if (QGestureRecognizer *recognizer = m_gestureToRecognizer.value(gesture, 0)) { gesture->setGestureCancelPolicy(QGesture::CancelNone); recognizer->reset(gesture); } else { cleanupGesturesForRemovedRecognizer(gesture); } - gestureTargets.remove(gesture); + m_gestureTargets.remove(gesture); } return ret; } @@ -353,7 +353,7 @@ bool QGestureManager::filterEventThroughContexts(const QMap cancelledGestures; - QSet::Iterator iter = activeGestures.begin(); - while (iter != activeGestures.end()) { - QWidget *widget = gestureTargets.value(*iter); + QSet::Iterator iter = m_activeGestures.begin(); + while (iter != m_activeGestures.end()) { + QWidget *widget = m_gestureTargets.value(*iter); // note that we don't touch the gestures for our originatingWidget if (widget != originatingWidget && originatingWidget->isAncestorOf(widget)) { DEBUG() << " found a gesture to cancel" << (*iter); (*iter)->d_func()->state = Qt::GestureCanceled; cancelledGestures << *iter; - iter = activeGestures.erase(iter); + iter = m_activeGestures.erase(iter); } else { ++iter; } @@ -385,7 +385,7 @@ void QGestureManager::cancelGesturesForChildren(QGesture *original) iter = almostCanceledGestures.begin(); // sort per target widget while (iter != almostCanceledGestures.end()) { - QWidget *widget = gestureTargets.value(*iter); + QWidget *widget = m_gestureTargets.value(*iter); if (target == 0) target = widget; if (target == widget) { @@ -402,7 +402,7 @@ void QGestureManager::cancelGesturesForChildren(QGesture *original) } for (iter = cancelledGestures.begin(); iter != cancelledGestures.end(); ++iter) { - QGestureRecognizer *recognizer = gestureToRecognizer.value(*iter, 0); + QGestureRecognizer *recognizer = m_gestureToRecognizer.value(*iter, 0); if (recognizer) { (*iter)->setGestureCancelPolicy(QGesture::CancelNone); recognizer->reset(*iter); @@ -507,7 +507,7 @@ void QGestureManager::getGestureTargets(const QSet &gestures, // sort gestures by types foreach (QGesture *gesture, gestures) { - QWidget *receiver = gestureTargets.value(gesture, 0); + QWidget *receiver = m_gestureTargets.value(gesture, 0); Q_ASSERT(receiver); gestureByTypes[gesture->gestureType()].insert(receiver, gesture); } @@ -556,7 +556,7 @@ void QGestureManager::deliverEvents(const QSet &gestures, for (QSet::const_iterator it = gestures.begin(), e = gestures.end(); it != e; ++it) { QGesture *gesture = *it; - QWidget *target = gestureTargets.value(gesture, 0); + QWidget *target = m_gestureTargets.value(gesture, 0); if (!target) { // the gesture has just started and doesn't have a target yet. Q_ASSERT(gesture->state() == Qt::GestureStarted); @@ -568,12 +568,12 @@ void QGestureManager::deliverEvents(const QSet &gestures, } } else { // or use the context of the gesture - QObject *context = gestureOwners.value(gesture, 0); + QObject *context = m_gestureOwners.value(gesture, 0); if (context->isWidgetType()) target = static_cast(context); } if (target) - gestureTargets.insert(gesture, target); + m_gestureTargets.insert(gesture, target); } Qt::GestureType gestureType = gesture->gestureType(); @@ -625,7 +625,7 @@ void QGestureManager::deliverEvents(const QSet &gestures, QList &gestures = normalStartedGestures[w]; gestures.append(gesture); // override the target - gestureTargets[gesture] = w; + m_gestureTargets[gesture] = w; } else { DEBUG() << "override event: gesture wasn't accepted. putting back:" << gesture; QList &gestures = normalStartedGestures[receiver]; @@ -648,18 +648,18 @@ void QGestureManager::deliverEvents(const QSet &gestures, void QGestureManager::timerEvent(QTimerEvent *event) { - QMap::iterator it = maybeGestures.begin(), - e = maybeGestures.end(); + QMap::iterator it = m_maybeGestures.begin(), + e = m_maybeGestures.end(); for (; it != e; ) { QBasicTimer &timer = it.value(); Q_ASSERT(timer.isActive()); if (timer.timerId() == event->timerId()) { timer.stop(); QGesture *gesture = it.key(); - it = maybeGestures.erase(it); + it = m_maybeGestures.erase(it); DEBUG() << "QGestureManager::timerEvent: gesture stopped due to timeout:" << gesture; - QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0); + QGestureRecognizer *recognizer = m_gestureToRecognizer.value(gesture, 0); if (recognizer) { gesture->setGestureCancelPolicy(QGesture::CancelNone); recognizer->reset(gesture); diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index e6a1d50..5a2816c 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -87,10 +87,10 @@ protected: QEvent *event); private: - QMultiMap recognizers; + QMultiMap m_recognizers; - QSet activeGestures; - QMap maybeGestures; + QSet m_activeGestures; + QMap m_maybeGestures; enum State { Gesture, @@ -116,14 +116,13 @@ private: } }; - // TODO rename all member vars to be m_ - QMap objectGestures; // TODO rename widgetGestures - QMap gestureToRecognizer; - QHash gestureOwners; + QMap m_objectGestures; + QMap m_gestureToRecognizer; + QHash m_gestureOwners; - QHash gestureTargets; + QHash m_gestureTargets; - int lastCustomGestureId; + int m_lastCustomGestureId; QHash > m_obsoleteGestures; QMap m_deletedRecognizers; -- cgit v0.12 From 0dc77406ae05c6ad27406e91b230b177b97fbc7c Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 28 Oct 2009 12:56:59 +0100 Subject: Make the un/registerGestureRecognizer methods static As QApplication is a singleton this makes usage of these easier and also in line with many other methods on the class. --- src/gui/kernel/qapplication.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h index 5a8e325..5877ba4 100644 --- a/src/gui/kernel/qapplication.h +++ b/src/gui/kernel/qapplication.h @@ -288,8 +288,8 @@ public: static Qt::NavigationMode navigationMode(); #endif - Qt::GestureType registerGestureRecognizer(QGestureRecognizer *recognizer); - void unregisterGestureRecognizer(Qt::GestureType type); + static Qt::GestureType registerGestureRecognizer(QGestureRecognizer *recognizer); + static void unregisterGestureRecognizer(Qt::GestureType type); Q_SIGNALS: void lastWindowClosed(); -- cgit v0.12 From 603d3fb41601e9c69e0f2f3afe4b3717b33f75e4 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 28 Oct 2009 12:59:51 +0100 Subject: Mark the QGestureEvent::setWidget as internal The widget() getter is still publicly documented, follow the lead of other events to make the setter internal. --- src/gui/kernel/qevent.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index ea05869..ab43e79 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4398,6 +4398,8 @@ bool QGestureEvent::isAccepted(Qt::GestureType gestureType) const } /*! + \internal + Sets the widget for this event. */ void QGestureEvent::setWidget(QWidget *widget) -- cgit v0.12 From 244d8993c4aac6746306e58b1b766f804e2566f4 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 28 Oct 2009 13:36:43 +0100 Subject: Follow refactor; use QApplication:: instead of qApp-> Our tests now call the recently converted registerRecognizer using a proper static method. --- tests/auto/gestures/tst_gestures.cpp | 46 ++++++++++++++--------------- tests/manual/gestures/graphicsview/main.cpp | 4 +-- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 39cdf63..02c8232 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -344,14 +344,14 @@ tst_Gestures::~tst_Gestures() void tst_Gestures::initTestCase() { - CustomGesture::GestureType = qApp->registerGestureRecognizer(new CustomGestureRecognizer); + CustomGesture::GestureType = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); QVERIFY(CustomGesture::GestureType != Qt::GestureType(0)); QVERIFY(CustomGesture::GestureType != Qt::CustomGesture); } void tst_Gestures::cleanupTestCase() { - qApp->unregisterGestureRecognizer(CustomGesture::GestureType); + QApplication::unregisterGestureRecognizer(CustomGesture::GestureType); } void tst_Gestures::init() @@ -558,7 +558,7 @@ void tst_Gestures::conflictingGestures() parent.reset(); child->reset(); - Qt::GestureType ContinuousGesture = qApp->registerGestureRecognizer(new CustomContinuousGestureRecognizer); + Qt::GestureType ContinuousGesture = QApplication::registerGestureRecognizer(new CustomContinuousGestureRecognizer); static const int ContinuousGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; child->grabGesture(ContinuousGesture); // child accepts override. And it also receives another custom gesture. @@ -572,7 +572,7 @@ void tst_Gestures::conflictingGestures() QCOMPARE(parent.gestureOverrideEventsReceived, 0); QCOMPARE(parent.gestureEventsReceived, 0); - qApp->unregisterGestureRecognizer(ContinuousGesture); + QApplication::unregisterGestureRecognizer(ContinuousGesture); } void tst_Gestures::finishedWithoutStarted() @@ -981,7 +981,7 @@ void tst_Gestures::twoGesturesOnDifferentLevel() GestureWidget *child = new GestureWidget("child"); l->addWidget(child); - Qt::GestureType SecondGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType SecondGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); parent.grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture); child->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture); @@ -1009,7 +1009,7 @@ void tst_Gestures::twoGesturesOnDifferentLevel() for(int i = 0; i < child->events.all.size(); ++i) QCOMPARE(parent.events.all.at(i), CustomGesture::GestureType); - qApp->unregisterGestureRecognizer(SecondGesture); + QApplication::unregisterGestureRecognizer(SecondGesture); } void tst_Gestures::multipleGesturesInTree() @@ -1021,8 +1021,8 @@ void tst_Gestures::multipleGesturesInTree() GestureWidget *D = new GestureWidget("D", C); Qt::GestureType FirstGesture = CustomGesture::GestureType; - Qt::GestureType SecondGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType ThirdGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType SecondGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType ThirdGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); A->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // A [1 3] A->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // | @@ -1079,8 +1079,8 @@ void tst_Gestures::multipleGesturesInTree() QCOMPARE(A->events.all.count(SecondGesture), 0); QCOMPARE(A->events.all.count(ThirdGesture), TotalGestureEventsCount); - qApp->unregisterGestureRecognizer(SecondGesture); - qApp->unregisterGestureRecognizer(ThirdGesture); + QApplication::unregisterGestureRecognizer(SecondGesture); + QApplication::unregisterGestureRecognizer(ThirdGesture); } void tst_Gestures::multipleGesturesInComplexTree() @@ -1092,12 +1092,12 @@ void tst_Gestures::multipleGesturesInComplexTree() GestureWidget *D = new GestureWidget("D", C); Qt::GestureType FirstGesture = CustomGesture::GestureType; - Qt::GestureType SecondGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType ThirdGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType FourthGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType FifthGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType SixthGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType SeventhGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType SecondGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType ThirdGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType FourthGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType FifthGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType SixthGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType SeventhGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); A->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // A [1,3,4] A->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // | @@ -1175,12 +1175,12 @@ void tst_Gestures::multipleGesturesInComplexTree() QCOMPARE(A->events.all.count(SixthGesture), 0); QCOMPARE(A->events.all.count(SeventhGesture), 0); - qApp->unregisterGestureRecognizer(SecondGesture); - qApp->unregisterGestureRecognizer(ThirdGesture); - qApp->unregisterGestureRecognizer(FourthGesture); - qApp->unregisterGestureRecognizer(FifthGesture); - qApp->unregisterGestureRecognizer(SixthGesture); - qApp->unregisterGestureRecognizer(SeventhGesture); + QApplication::unregisterGestureRecognizer(SecondGesture); + QApplication::unregisterGestureRecognizer(ThirdGesture); + QApplication::unregisterGestureRecognizer(FourthGesture); + QApplication::unregisterGestureRecognizer(FifthGesture); + QApplication::unregisterGestureRecognizer(SixthGesture); + QApplication::unregisterGestureRecognizer(SeventhGesture); } void tst_Gestures::testMapToScene() @@ -1329,7 +1329,7 @@ void tst_Gestures::autoCancelGestures() GestureWidget *child = new GestureWidget("child", &parent); child->setGeometry(10, 10, 100, 80); - Qt::GestureType type = qApp->registerGestureRecognizer(new MockRecognizer()); + Qt::GestureType type = QApplication::registerGestureRecognizer(new MockRecognizer()); parent.grabGesture(type, Qt::WidgetWithChildrenGesture); child->grabGesture(type, Qt::WidgetWithChildrenGesture); diff --git a/tests/manual/gestures/graphicsview/main.cpp b/tests/manual/gestures/graphicsview/main.cpp index e9065eb..de92afe 100644 --- a/tests/manual/gestures/graphicsview/main.cpp +++ b/tests/manual/gestures/graphicsview/main.cpp @@ -152,8 +152,8 @@ private: MainWindow::MainWindow() { - (void)qApp->registerGestureRecognizer(new MousePanGestureRecognizer); - ThreeFingerSlideGesture::Type = qApp->registerGestureRecognizer(new ThreeFingerSlideGestureRecognizer); + (void)QApplication::registerGestureRecognizer(new MousePanGestureRecognizer); + ThreeFingerSlideGesture::Type = QApplication::registerGestureRecognizer(new ThreeFingerSlideGestureRecognizer); tabWidget = new QTabWidget; -- cgit v0.12 From 4f4c4fda9925f585128175796d04926863943dad Mon Sep 17 00:00:00 2001 From: dka Date: Mon, 19 Oct 2009 12:21:02 +0300 Subject: QLocale: AM/PM symbol support for symbian platform Reviewed-by: Denis Dzyubenko --- src/corelib/tools/qlocale_symbian.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp index 1660e95..1273d06 100644 --- a/src/corelib/tools/qlocale_symbian.cpp +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -873,9 +873,11 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const } case NegativeSign: case PositiveSign: + break; case AMText: + return qt_TDes2QString(TAmPmName(TAmPm(EAm))); case PMText: - break; + return qt_TDes2QString(TAmPmName(TAmPm(EPm))); default: break; } -- cgit v0.12 From 7a215265994bca72bbc7fcc198048c2f6bb7527a Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 28 Oct 2009 12:05:26 +0100 Subject: Removed obsolete private field from the QGesture and fixed the doc. Reviewed-by: Thomas Zander --- src/gui/kernel/qgesture.cpp | 11 +++++------ src/gui/kernel/qgesture_p.h | 5 +---- src/gui/kernel/qgesturerecognizer.cpp | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index c302c51..b72fae0 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -69,10 +69,9 @@ QT_BEGIN_NAMESPACE \section1 Lifecycle of a Gesture Object - A QGesture instance is created when the application calls QWidget::grabGesture() - or QGraphicsObject::grabGesture() to configure a widget or graphics object (the - target object) for gesture input. One gesture object is created for each target - object. + A QGesture instance is implicitely created when needed and is owned by Qt, + so application developer should never destroy them or store a pointer to a + QGesture object. The registered gesture recognizer monitors the input events for the target object via its \l{QGestureRecognizer::}{filterEvent()} function, updating the @@ -133,8 +132,8 @@ QGesture::~QGesture() QWidget::mapFromGlobal() or QGestureEvent::mapToScene() to get a local hot-spot. - If the hot-spot is not set, the targetObject is used as the receiver of the - gesture event. + The hot-spot should be set by the gesture recognizer to allow gesture event + delivery to a QGraphicsObject. */ /*! diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h index d2ef8a7..34fbb26 100644 --- a/src/gui/kernel/qgesture_p.h +++ b/src/gui/kernel/qgesture_p.h @@ -68,9 +68,7 @@ class QGesturePrivate : public QObjectPrivate public: QGesturePrivate() : gestureType(Qt::CustomGesture), state(Qt::NoGesture), - targetObject(0), - isHotSpotSet(false), - gestureCancelPolicy(0) + isHotSpotSet(false), gestureCancelPolicy(0) { } @@ -78,7 +76,6 @@ public: Qt::GestureType gestureType; Qt::GestureState state; QPointF hotSpot; - QObject *targetObject; uint isHotSpotSet : 1; uint gestureCancelPolicy : 2; }; diff --git a/src/gui/kernel/qgesturerecognizer.cpp b/src/gui/kernel/qgesturerecognizer.cpp index c2b26f0..2673be3 100644 --- a/src/gui/kernel/qgesturerecognizer.cpp +++ b/src/gui/kernel/qgesturerecognizer.cpp @@ -178,7 +178,7 @@ void QGestureRecognizer::reset(QGesture *gesture) QGesturePrivate *d = gesture->d_func(); d->state = Qt::NoGesture; d->hotSpot = QPointF(); - d->targetObject = 0; + d->isHotSpotSet = false; } } -- cgit v0.12 From a2b12363c96d4307444552eefc21eebf430dba5d Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 28 Oct 2009 13:05:20 +0100 Subject: Fixed the scrollarea gesture manual test. Reviewed-by: trustme --- tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp | 2 +- tests/manual/gestures/scrollarea/mousepangesturerecognizer.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp index 5f94dbc..63d3e76 100644 --- a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp +++ b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp @@ -49,7 +49,7 @@ MousePanGestureRecognizer::MousePanGestureRecognizer() { } -QGesture* MousePanGestureRecognizer::createGesture(QObject *) const +QGesture* MousePanGestureRecognizer::createGesture(QObject *) { return new QPanGesture; } diff --git a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h index c92d477..b062fd0 100644 --- a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h +++ b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h @@ -49,7 +49,7 @@ class MousePanGestureRecognizer : public QGestureRecognizer public: MousePanGestureRecognizer(); - QGesture* createGesture(QObject *target) const; + QGesture* createGesture(QObject *target); QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event); void reset(QGesture *state); }; -- cgit v0.12 From 3ce8fb5e754014ed29cabf9e33b71dabecb02e46 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 28 Oct 2009 13:06:03 +0100 Subject: Fixed the gesture event filtering through multiple gesture recognizers. When there are several gesture recognizers registered for the same gesture type, we need to know which recognizer we need to get a state object for since those QGesture objects are tied to the recognizer that created them. Reviewed-by: Thomas Zander --- src/gui/kernel/qgesturemanager.cpp | 49 ++++++++++++++++++++------------------ src/gui/kernel/qgesturemanager_p.h | 5 ++-- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index a90c299..04dcfe3 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -118,7 +118,7 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) foreach (QGestureRecognizer *recognizer, list) { QList obsoleteGestures; - QMap::Iterator iter = m_objectGestures.begin(); + QMap >::Iterator iter = m_objectGestures.begin(); while (iter != m_objectGestures.end()) { ObjectGesture objectGesture = iter.key(); if (objectGesture.gesture == type) @@ -131,11 +131,11 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType type) { - QMap::Iterator iter = m_objectGestures.begin(); + QMap >::Iterator iter = m_objectGestures.begin(); while (iter != m_objectGestures.end()) { ObjectGesture objectGesture = iter.key(); if (objectGesture.gesture == type && target == objectGesture.object.data()) { - delete iter.value(); + qDeleteAll(iter.value()); iter = m_objectGestures.erase(iter); } else { ++iter; @@ -144,7 +144,7 @@ void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType typ } // get or create a QGesture object that will represent the state for a given object, used by the recognizer -QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type) +QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recognizer, Qt::GestureType type) { // if the widget is being deleted we should be carefull and not to // create a new state, as it will create QWeakPointer which doesnt work @@ -158,28 +158,31 @@ QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type) Q_ASSERT(qobject_cast(object)); } - QGesture *state = + QList states = m_objectGestures.value(QGestureManager::ObjectGesture(object, type)); - if (!state) { - QGestureRecognizer *recognizer = m_recognizers.value(type); - if (recognizer) { - state = recognizer->createGesture(object); - if (!state) - return 0; - state->setParent(this); - if (state->gestureType() == Qt::CustomGesture) { - // if the recognizer didn't fill in the gesture type, then this - // is a custom gesture with autogenerated it and we fill it. - state->d_func()->gestureType = type; + // check if the QGesture for this recognizer has already been created + foreach (QGesture *state, states) { + if (m_gestureToRecognizer.value(state) == recognizer) + return state; + } + + Q_ASSERT(recognizer); + QGesture *state = recognizer->createGesture(object); + if (!state) + return 0; + state->setParent(this); + if (state->gestureType() == Qt::CustomGesture) { + // if the recognizer didn't fill in the gesture type, then this + // is a custom gesture with autogenerated id and we fill it. + state->d_func()->gestureType = type; #if defined(GESTURE_DEBUG) - state->setObjectName(QString::number((int)type)); + state->setObjectName(QString::number((int)type)); #endif - } - m_objectGestures.insert(QGestureManager::ObjectGesture(object, type), state); - m_gestureToRecognizer[state] = recognizer; - m_gestureOwners[state] = object; - } } + m_objectGestures[QGestureManager::ObjectGesture(object, type)].append(state); + m_gestureToRecognizer[state] = recognizer; + m_gestureOwners[state] = object; + return state; } @@ -208,7 +211,7 @@ bool QGestureManager::filterEventThroughContexts(const QMapfilterEvent(state, target, event); diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index 5a2816c..f128273 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -116,7 +116,7 @@ private: } }; - QMap m_objectGestures; + QMap > m_objectGestures; QMap m_gestureToRecognizer; QHash m_gestureOwners; @@ -128,7 +128,8 @@ private: QMap m_deletedRecognizers; void cleanupGesturesForRemovedRecognizer(QGesture *gesture); - QGesture *getState(QObject *widget, Qt::GestureType gesture); + QGesture *getState(QObject *widget, QGestureRecognizer *recognizer, + Qt::GestureType gesture); void deliverEvents(const QSet &gestures, QSet *undeliveredGestures); void getGestureTargets(const QSet &gestures, -- cgit v0.12 From 96b8e9f824daaf88cb8c153caa774a92b0261580 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 28 Oct 2009 13:11:49 +0100 Subject: Delete all gesture objects and recognizers when gesture manager is deleted. When application closes and we haven't deleted the unregistered gestures and gesture recognizer, we should delete them. Reviewed-by: Thomas Zander --- src/gui/kernel/qgesturemanager.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 04dcfe3..3eb15cf 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -83,6 +83,11 @@ QGestureManager::QGestureManager(QObject *parent) QGestureManager::~QGestureManager() { qDeleteAll(m_recognizers.values()); + foreach (QGestureRecognizer *recognizer, m_obsoleteGestures.keys()) { + qDeleteAll(m_obsoleteGestures.value(recognizer)); + delete recognizer; + } + m_obsoleteGestures.clear(); } Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *recognizer) -- cgit v0.12 From 6efb1b7df725c74f265d0f315993542b0bd19b97 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 28 Oct 2009 14:07:53 +0100 Subject: Tiny doc change by David Boddie. Reviewed-by: David Boddie --- src/gui/kernel/qgesture.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index b72fae0..850f22c 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -69,9 +69,9 @@ QT_BEGIN_NAMESPACE \section1 Lifecycle of a Gesture Object - A QGesture instance is implicitely created when needed and is owned by Qt, - so application developer should never destroy them or store a pointer to a - QGesture object. + A QGesture instance is implicitly created when needed and is owned by Qt. + Developers should never destroy them or store them for later use as Qt may + destroy particular instances of them and create new ones to replace them. The registered gesture recognizer monitors the input events for the target object via its \l{QGestureRecognizer::}{filterEvent()} function, updating the -- cgit v0.12 From 4b3ef85b499d9ec508acdf83d250e022161defbb Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 28 Oct 2009 14:30:11 +0100 Subject: Replaced QMap with QHash where possible in the gesture manager implementation. There is no reason to use QMap when the key is a pointer. Reviewed-by: Thomas Zander --- src/gui/kernel/qgesturemanager.cpp | 18 +++++++++--------- src/gui/kernel/qgesturemanager_p.h | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 3eb15cf..f1abc89 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -113,7 +113,7 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) { QList list = m_recognizers.values(type); m_recognizers.remove(type); - foreach (QGesture* g, m_gestureToRecognizer.keys()) { + foreach (QGesture *g, m_gestureToRecognizer.keys()) { QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g); if (list.contains(recognizer)) { m_deletedRecognizers.insert(g, recognizer); @@ -191,7 +191,7 @@ QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recogni return state; } -bool QGestureManager::filterEventThroughContexts(const QMap &contexts, QEvent *event) { @@ -207,7 +207,7 @@ bool QGestureManager::filterEventThroughContexts(const QMap::const_iterator ContextIterator; + typedef QHash::const_iterator ContextIterator; for (ContextIterator cit = contexts.begin(), ce = contexts.end(); cit != ce; ++cit) { Qt::GestureType gestureType = cit.value(); QMap::const_iterator @@ -269,7 +269,7 @@ bool QGestureManager::filterEventThroughContexts(const QMap::iterator it = + QHash::iterator it = m_maybeGestures.find(gesture); if (it != m_maybeGestures.end()) { it.value().stop(); @@ -437,7 +437,7 @@ void QGestureManager::cleanupGesturesForRemovedRecognizer(QGesture *gesture) bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) { QSet types; - QMap contexts; + QMultiHash contexts; QWidget *w = receiver; typedef QMap::const_iterator ContextIterator; if (!w->d_func()->gestureContext.isEmpty()) { @@ -470,7 +470,7 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) { QSet types; - QMap contexts; + QMultiHash contexts; QGraphicsObject *item = receiver; if (!item->QGraphicsItem::d_func()->gestureContext.isEmpty()) { typedef QMap::const_iterator ContextIterator; @@ -501,7 +501,7 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) bool QGestureManager::filterEvent(QGesture *state, QEvent *event) { - QMap contexts; + QMultiHash contexts; contexts.insert(state, state->gestureType()); return filterEventThroughContexts(contexts, event); } @@ -656,8 +656,8 @@ void QGestureManager::deliverEvents(const QSet &gestures, void QGestureManager::timerEvent(QTimerEvent *event) { - QMap::iterator it = m_maybeGestures.begin(), - e = m_maybeGestures.end(); + QHash::iterator it = m_maybeGestures.begin(), + e = m_maybeGestures.end(); for (; it != e; ) { QBasicTimer &timer = it.value(); Q_ASSERT(timer.isActive()); diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index f128273..4958cdb 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -83,14 +83,14 @@ public: protected: void timerEvent(QTimerEvent *event); - bool filterEventThroughContexts(const QMap &contexts, + bool filterEventThroughContexts(const QMultiHash &contexts, QEvent *event); private: QMultiMap m_recognizers; QSet m_activeGestures; - QMap m_maybeGestures; + QHash m_maybeGestures; enum State { Gesture, @@ -117,7 +117,7 @@ private: }; QMap > m_objectGestures; - QMap m_gestureToRecognizer; + QHash m_gestureToRecognizer; QHash m_gestureOwners; QHash m_gestureTargets; @@ -125,7 +125,7 @@ private: int m_lastCustomGestureId; QHash > m_obsoleteGestures; - QMap m_deletedRecognizers; + QHash m_deletedRecognizers; void cleanupGesturesForRemovedRecognizer(QGesture *gesture); QGesture *getState(QObject *widget, QGestureRecognizer *recognizer, -- cgit v0.12 From e4606e2d6491bd7020e8bfb12665c3addc24b7e3 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 28 Oct 2009 14:47:28 +0100 Subject: Wrong font used when moving a tab in document mode. Dragging is handled by a seperate window in document mode. The currently selected tabbar item is drawn to a pixmap for this purpose. That paintdevice was not initialized correctly. (e.g. font) Reviewed-by: Trond --- src/gui/widgets/qtabbar.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp index 4dffbdc..3935c55 100644 --- a/src/gui/widgets/qtabbar.cpp +++ b/src/gui/widgets/qtabbar.cpp @@ -1812,6 +1812,7 @@ void QTabBarPrivate::setupMovableTab() QPixmap grabImage(grabRect.size()); grabImage.fill(Qt::transparent); QStylePainter p(&grabImage, q); + p.initFrom(q); QStyleOptionTabV3 tab; q->initStyleOption(&tab, pressedIndex); -- cgit v0.12 From dbaa856d4d20840394baf8f4c9abf78051a6693a Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 7 Oct 2009 16:15:43 +0200 Subject: Fix split tool button drawing on Vista when not in a tool bar When a tool button is not in a tool bar on XP and Vista it will get a slightly different appearance from normal tool buttons. I resolved this by drawing a normal tool button with a divider line on top if the autoraise property is not set on the button. (which is by default enabled only for buttons in a tool bar). Task-number: QTBUG-5061 Reviewed-by: prasanth --- src/gui/styles/qwindowsxpstyle.cpp | 46 +++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index 2f00f07..b5dc647 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -2841,8 +2841,8 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo State bflags = toolbutton->state & ~State_Sunken; State mflags = bflags; - - if (bflags & State_AutoRaise) { + bool autoRaise = flags & State_AutoRaise; + if (autoRaise) { if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) { bflags &= ~State_Raised; } @@ -2861,8 +2861,8 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo QStyleOption tool(0); tool.palette = toolbutton->palette; if (toolbutton->subControls & SC_ToolButton) { - if (flags & (State_Sunken | State_On | State_Raised) || !(flags & State_AutoRaise)) { - if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup) { + if (flags & (State_Sunken | State_On | State_Raised) || !autoRaise) { + if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup && autoRaise) { XPThemeData theme(widget, p, QLatin1String("TOOLBAR")); theme.partId = TP_SPLITBUTTON; theme.rect = button; @@ -2881,13 +2881,12 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo theme.stateId = stateId; d->drawBackground(theme); } else { - tool.rect = button; + tool.rect = option->rect; tool.state = bflags; - if (widget && !qobject_cast(widget->parentWidget()) - && !(bflags & State_AutoRaise)) - proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, widget); - else + if (autoRaise) // for tool bars proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); + else + proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, widget); } } } @@ -2904,13 +2903,40 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo QStyleOptionToolButton label = *toolbutton; label.state = bflags; int fw = 2; + if (!autoRaise) + label.state &= ~State_Sunken; label.rect = button.adjusted(fw, fw, -fw, -fw); proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget); if (toolbutton->subControls & SC_ToolButtonMenu) { tool.rect = menuarea; tool.state = mflags; - proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); + if (autoRaise) { + proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); + } else { + tool.state = mflags; + menuarea.adjust(-2, 0, 0, 0); + // Draw menu button + if ((bflags & State_Sunken) != (mflags & State_Sunken)){ + p->save(); + p->setClipRect(menuarea); + tool.rect = option->rect; + proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, 0); + p->restore(); + } + // Draw arrow + p->save(); + p->setPen(option->palette.dark()); + p->drawLine(menuarea.left(), menuarea.top() + 3, + menuarea.left(), menuarea.bottom() - 3); + p->setPen(option->palette.light()); + p->drawLine(menuarea.left() - 1, menuarea.top() + 3, + menuarea.left() - 1, menuarea.bottom() - 3); + + tool.rect = menuarea.adjusted(2, 3, -2, -1); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget); + p->restore(); + } } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) { int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget); QRect ir = toolbutton->rect; -- cgit v0.12 From 5eb2f63acda335aaf06e302ee4564259bc60222a Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 7 Oct 2009 18:29:46 +0200 Subject: Fix a combobox autotest on Vista The subcontrol rect offset was correctly reporting not to work on Vista style. The problem was that we were getting the size of the arrow by subtracting the xoffset. But this would mean that the Reviewed-by: ogoffart --- src/gui/styles/qwindowsvistastyle.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp index 6cb8b40..974bce1 100644 --- a/src/gui/styles/qwindowsvistastyle.cpp +++ b/src/gui/styles/qwindowsvistastyle.cpp @@ -2217,14 +2217,15 @@ QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOpt int xpos = x; int margin = cb->frame ? 3 : 0; int bmarg = cb->frame ? 2 : 0; - xpos += wi - bmarg - 16; + int arrowButtonWidth = bmarg + 16; + xpos += wi - arrowButtonWidth; switch (subControl) { case SC_ComboBoxFrame: rect = cb->rect; break; case SC_ComboBoxArrow: - rect.setRect(xpos, y , wi - xpos, he); + rect.setRect(xpos, y , arrowButtonWidth, he); break; case SC_ComboBoxEditField: rect.setRect(x + margin, y + margin, wi - 2 * margin - 16, he - 2 * margin); -- cgit v0.12 From b1f9882fa52745c922eb0109daa011908214dcf7 Mon Sep 17 00:00:00 2001 From: Dean Dettman Date: Thu, 29 Oct 2009 11:29:08 +0100 Subject: Ensure that button returns 0 for mouse move events This was a platform regression for the cocoa platform Reviewed-by: Prasanth --- src/gui/kernel/qcocoaview_mac.mm | 7 ++- tests/auto/qmouseevent/tst_qmouseevent.cpp | 75 ++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index ecc6bc9..a16d1f8 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -745,7 +745,7 @@ extern "C" { { qMacDnDParams()->view = self; qMacDnDParams()->theEvent = theEvent; - bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::LeftButton); + bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton); if (!mouseOK) [super mouseDragged:theEvent]; @@ -755,7 +755,7 @@ extern "C" { { qMacDnDParams()->view = self; qMacDnDParams()->theEvent = theEvent; - bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::RightButton); + bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton); if (!mouseOK) [super rightMouseDragged:theEvent]; @@ -765,8 +765,7 @@ extern "C" { { qMacDnDParams()->view = self; qMacDnDParams()->theEvent = theEvent; - Qt::MouseButton mouseButton = cocoaButton2QtButton([theEvent buttonNumber]); - bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, mouseButton); + bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton); if (!mouseOK) [super otherMouseDragged:theEvent]; diff --git a/tests/auto/qmouseevent/tst_qmouseevent.cpp b/tests/auto/qmouseevent/tst_qmouseevent.cpp index b961851..d700181 100644 --- a/tests/auto/qmouseevent/tst_qmouseevent.cpp +++ b/tests/auto/qmouseevent/tst_qmouseevent.cpp @@ -62,6 +62,7 @@ public: } bool mousePressEventRecieved; bool mouseReleaseEventRecieved; + bool mouseMoveEventRecieved; #ifdef QT3_SUPPORT int mousePressStateBefore; int mousePressStateAfter; @@ -76,6 +77,13 @@ public: int mouseReleaseButton; int mouseReleaseButtons; int mouseReleaseModifiers; +#ifdef QT3_SUPPORT + int mouseMoveStateBefore; + int mouseMoveStateAfter; +#endif + int mouseMoveButton; + int mouseMoveButtons; + int mouseMoveModifiers; protected: void mousePressEvent(QMouseEvent *e) { @@ -103,6 +111,19 @@ protected: mouseReleaseEventRecieved = TRUE; e->accept(); } + void mouseMoveEvent(QMouseEvent *e) + { + QWidget::mouseMoveEvent(e); +#ifdef QT3_SUPPORT + mouseMoveStateBefore = e->state(); + mouseMoveStateAfter = e->stateAfter(); +#endif + mouseMoveButton = e->button(); + mouseMoveButtons = e->buttons(); + mouseMoveModifiers = e->modifiers(); + mouseMoveEventRecieved = TRUE; + e->accept(); + } }; class tst_QMouseEvent : public QObject @@ -124,6 +145,8 @@ private slots: void checkMousePressEvent(); void checkMouseReleaseEvent_data(); void checkMouseReleaseEvent(); + void checkMouseMoveEvent_data(); + void checkMouseMoveEvent(); void qt3supportConstructors(); @@ -157,11 +180,14 @@ void tst_QMouseEvent::init() { testMouseWidget->mousePressEventRecieved = FALSE; testMouseWidget->mouseReleaseEventRecieved = FALSE; + testMouseWidget->mouseMoveEventRecieved = FALSE; #ifdef QT3_SUPPORT testMouseWidget->mousePressStateBefore = 0; testMouseWidget->mousePressStateAfter = 0; testMouseWidget->mouseReleaseStateBefore = 0; testMouseWidget->mouseReleaseStateAfter = 0; + testMouseWidget->mouseMoveStateBefore = 0; + testMouseWidget->mouseMoveStateAfter = 0; #endif testMouseWidget->mousePressButton = 0; testMouseWidget->mousePressButtons = 0; @@ -169,6 +195,9 @@ void tst_QMouseEvent::init() testMouseWidget->mouseReleaseButton = 0; testMouseWidget->mouseReleaseButtons = 0; testMouseWidget->mouseReleaseModifiers = 0; + testMouseWidget->mouseMoveButton = 0; + testMouseWidget->mouseMoveButtons = 0; + testMouseWidget->mouseMoveModifiers = 0; } void tst_QMouseEvent::cleanup() @@ -265,6 +294,52 @@ void tst_QMouseEvent::checkMouseReleaseEvent() #endif } +void tst_QMouseEvent::checkMouseMoveEvent_data() +{ + QTest::addColumn("buttonMoved"); + QTest::addColumn("keyPressed"); + + QTest::newRow("leftButton-nokey") << int(Qt::LeftButton) << int(Qt::NoButton); + QTest::newRow("leftButton-shiftkey") << int(Qt::LeftButton) << int(Qt::ShiftModifier); + QTest::newRow("leftButton-controlkey") << int(Qt::LeftButton) << int(Qt::ControlModifier); + QTest::newRow("leftButton-altkey") << int(Qt::LeftButton) << int(Qt::AltModifier); + QTest::newRow("leftButton-metakey") << int(Qt::LeftButton) << int(Qt::MetaModifier); + QTest::newRow("rightButton-nokey") << int(Qt::RightButton) << int(Qt::NoButton); + QTest::newRow("rightButton-shiftkey") << int(Qt::RightButton) << int(Qt::ShiftModifier); + QTest::newRow("rightButton-controlkey") << int(Qt::RightButton) << int(Qt::ControlModifier); + QTest::newRow("rightButton-altkey") << int(Qt::RightButton) << int(Qt::AltModifier); + QTest::newRow("rightButton-metakey") << int(Qt::RightButton) << int(Qt::MetaModifier); + QTest::newRow("midButton-nokey") << int(Qt::MidButton) << int(Qt::NoButton); + QTest::newRow("midButton-shiftkey") << int(Qt::MidButton) << int(Qt::ShiftModifier); + QTest::newRow("midButton-controlkey") << int(Qt::MidButton) << int(Qt::ControlModifier); + QTest::newRow("midButton-altkey") << int(Qt::MidButton) << int(Qt::AltModifier); + QTest::newRow("midButton-metakey") << int(Qt::MidButton) << int(Qt::MetaModifier); +} + +void tst_QMouseEvent::checkMouseMoveEvent() +{ + QFETCH(int,buttonMoved); + QFETCH(int,keyPressed); + int button = (int)Qt::NoButton; + int buttons = buttonMoved; + int modifiers = keyPressed; + + QTest::mousePress(testMouseWidget, Qt::MouseButton(buttonMoved), Qt::KeyboardModifiers(keyPressed)); + QTest::mouseMove(testMouseWidget, QPoint(10,10)); + QVERIFY(testMouseWidget->mouseMoveEventRecieved); + QCOMPARE(testMouseWidget->mouseMoveButton, button); + QCOMPARE(testMouseWidget->mouseMoveButtons, buttons); + QCOMPARE(testMouseWidget->mouseMoveModifiers, modifiers); +#ifdef QT3_SUPPORT + int stateAfter = buttons|modifiers; + int stateBefore = stateAfter|button; + + QCOMPARE(testMouseWidget->mouseMoveStateBefore, stateBefore); + QCOMPARE(testMouseWidget->mouseMoveStateAfter, stateAfter); +#endif + QTest::mouseRelease(testMouseWidget, Qt::MouseButton(buttonMoved), Qt::KeyboardModifiers(keyPressed)); +} + void tst_QMouseEvent::qt3supportConstructors() { #if !defined(QT3_SUPPORT) -- cgit v0.12 From 9551b8c349ce4e15a57c24a2408ee1b73c2b7510 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 29 Oct 2009 13:46:45 +0100 Subject: Tabs with corner widgets are drawn incorrectly in document mode on Mac. While drawing the tabbar frame, mac style needs the QTabBar pointer to calculate the correct size. Since the QTabWidget also uses the PE_FrameTabBarBase to draw background of the corner widgets, the mac style has to use position passed with the style option. This only works with horizontal tabs. Reviewed-by: Jens Bache-Wiig --- src/gui/styles/qmacstyle_mac.mm | 10 +++++----- src/gui/widgets/qtabwidget.cpp | 4 ++-- tools/assistant/tools/assistant/centralwidget.cpp | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 4dcb469..38c3feb 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -342,12 +342,12 @@ void drawTabBase(QPainter *p, const QStyleOptionTabBarBaseV2 *tbb, const QWidget borderHighlightTop = QColor(207, 207, 207); } p->setPen(borderHighlightTop); - p->drawLine(0, 0, width, 0); + p->drawLine(tabRect.x(), 0, width, 0); p->setPen(borderTop); - p->drawLine(0, 1, width, 1); + p->drawLine(tabRect.x(), 1, width, 1); // center block - QRect centralRect(0, 2, width, height - 2); + QRect centralRect(tabRect.x(), 2, width, height - 2); if (active) { QColor mainColor = QColor(120, 120, 120); p->fillRect(centralRect, mainColor); @@ -370,9 +370,9 @@ void drawTabBase(QPainter *p, const QStyleOptionTabBarBaseV2 *tbb, const QWidget borderBottom = QColor(127, 127, 127); } p->setPen(borderHighlightBottom); - p->drawLine(0, height - 2, width, height - 2); + p->drawLine(tabRect.x(), height - 2, width, height - 2); p->setPen(borderBottom); - p->drawLine(0, height - 1, width, height - 1); + p->drawLine(tabRect.x(), height - 1, width, height - 1); } /* diff --git a/src/gui/widgets/qtabwidget.cpp b/src/gui/widgets/qtabwidget.cpp index 9aeb033..0c89a72 100644 --- a/src/gui/widgets/qtabwidget.cpp +++ b/src/gui/widgets/qtabwidget.cpp @@ -1167,8 +1167,8 @@ void QTabWidget::tabRemoved(int index) void QTabWidget::paintEvent(QPaintEvent *) { Q_D(QTabWidget); - QStylePainter p(this); if (documentMode()) { + QStylePainter p(this, tabBar()); if (QWidget *w = cornerWidget(Qt::TopLeftCorner)) { QStyleOptionTabBarBaseV2 opt; QTabBarPrivate::initStyleBaseOption(&opt, tabBar(), w->size()); @@ -1185,7 +1185,7 @@ void QTabWidget::paintEvent(QPaintEvent *) } return; } - + QStylePainter p(this); QStyleOptionTabWidgetFrame opt; initStyleOption(&opt); opt.rect = d->panelRect; diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 04739d4..2722b2f 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -230,6 +230,7 @@ CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent) #endif tabWidget = new QTabWidget(this); + tabWidget->setDocumentMode(true); connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentPageChanged(int))); -- cgit v0.12 From 8c4edbd04f350294462fd689748de2dd7cc84d47 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 8 Oct 2009 21:10:01 +0200 Subject: Fix tab widget painting in QGtkStyle with reverse This also adds QStyleOptionTabWidgetFrameV2 so that we do not have to do ugly hacks in the style to obtain it. Task-number: QTBUG-5187 Reviewed-by: ogoffart --- src/gui/styles/qgtkstyle.cpp | 43 ++++++-------- src/gui/styles/qstyleoption.cpp | 113 ++++++++++++++++++++++++++++++++++++ src/gui/styles/qstyleoption.h | 20 +++++++ src/gui/styles/qstylesheetstyle.cpp | 2 +- src/gui/styles/qwindowsxpstyle.cpp | 2 +- src/gui/widgets/qtabwidget.cpp | 14 ++++- 6 files changed, 166 insertions(+), 28 deletions(-) diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index d315c98..a7c291b 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -1004,32 +1004,27 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, gtkPainter.setAlphaSupport(false); GtkShadowType shadow = GTK_SHADOW_OUT; GtkStateType state = GTK_STATE_NORMAL; // Only state supported by gtknotebook - if (const QTabWidget *tabwidget = qobject_cast(widget)) { - // We should introduce QStyleOptionTabWidgetFrameV2 to obtain this information - // No gap if we do not show the actual tabs - QTabBar *tabBar = tabwidget->findChild(); - if (tabwidget->count() > 0 && tabBar->isVisible()) { - QRect tabRect = tabBar->tabRect(tabBar->currentIndex()); - int begin = 0, size = 0; - GtkPositionType frameType = GTK_POS_TOP; - QTabBar::Shape shape = frame->shape; - if (shape == QTabBar::RoundedNorth || shape == QTabBar::RoundedSouth) { - begin = option->direction == Qt::LeftToRight ? - frame->leftCornerWidgetSize.width() + tabRect.left() : - frame->rect.width() - frame->tabBarSize.width() + tabRect.left() - - frame->rightCornerWidgetSize.width(); - size = tabRect.width(); - frameType = (shape == QTabBar::RoundedNorth) ? GTK_POS_TOP : GTK_POS_BOTTOM; - } else { - begin = frame->leftCornerWidgetSize.height() + tabRect.top(); - size = tabRect.height(); - frameType = (shape == QTabBar::RoundedWest) ? GTK_POS_LEFT : GTK_POS_RIGHT; - } - gtkPainter.paintBoxGap(gtkNotebook, "notebook", option->rect, state, shadow, frameType, - begin, size, style); - break; // done + bool reverse = (option->direction == Qt::RightToLeft); + QGtk::gtk_widget_set_direction(gtkNotebook, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); + if (const QStyleOptionTabWidgetFrameV2 *tabframe = qstyleoption_cast(option)) { + GtkPositionType frameType = GTK_POS_TOP; + QTabBar::Shape shape = frame->shape; + int gapStart = 0; + int gapSize = 0; + if (shape == QTabBar::RoundedNorth || shape == QTabBar::RoundedSouth) { + frameType = (shape == QTabBar::RoundedNorth) ? GTK_POS_TOP : GTK_POS_BOTTOM; + gapStart = tabframe->selectedTabRect.left(); + gapSize = tabframe->selectedTabRect.width(); + } else { + frameType = (shape == QTabBar::RoundedWest) ? GTK_POS_LEFT : GTK_POS_RIGHT; + gapStart = tabframe->selectedTabRect.y(); + gapSize = tabframe->selectedTabRect.height(); } + gtkPainter.paintBoxGap(gtkNotebook, "notebook", option->rect, state, shadow, frameType, + gapStart, gapSize, style); + break; // done } + // Note this is only the fallback option gtkPainter.paintBox(gtkNotebook, "notebook", option->rect, state, shadow, style); } diff --git a/src/gui/styles/qstyleoption.cpp b/src/gui/styles/qstyleoption.cpp index 061afcc..f5a2b94 100644 --- a/src/gui/styles/qstyleoption.cpp +++ b/src/gui/styles/qstyleoption.cpp @@ -4654,6 +4654,119 @@ QStyleOptionTabWidgetFrame::QStyleOptionTabWidgetFrame(int version) The default value is QSize(-1, -1), i.e. an invalid size. */ + + +/*! + + \class QStyleOptionTabWidgetFrameV2 + \brief The QStyleOptionTabWidgetFrameV2 class is used to describe the + parameters for drawing the frame around a tab widget. + + QStyleOptionTabWidgetFrameV2 contains all the information that + QStyle functions need to draw the frame around QTabWidget. + + For performance reasons, the access to the member variables is + direct (i.e., using the \c . or \c -> operator). This low-level feel + makes the structures straightforward to use and emphasizes that + these are simply parameters used by the style functions. + + For an example demonstrating how style options can be used, see + the \l {widgets/styles}{Styles} example. + + \sa QStyleOption, QTabWidget +*/ + + +/*! + \variable QStyleOptionTabWidgetFrameV2::tabBarRect + \brief the rectangle containing all the tabs + + The default value is a null rectangle, i.e. a rectangle with both + the width and the height set to 0. +*/ + +/*! + \variable QStyleOptionTabWidgetFrameV2::selectedTabRect + \brief the rectangle containing the selected tab + + This rectangle is contained within the tabBarRect. The default + value is a null rectangle, i.e. a rectangle with both the width + and the height set to 0. +*/ + + +/*! + Constructs a QStyleOptionTabWidgetFrameV2, initializing the members + variables to their default values. +*/ + +QStyleOptionTabWidgetFrameV2::QStyleOptionTabWidgetFrameV2() + : QStyleOptionTabWidgetFrame(Version) +{ +} + + +/*! \internal */ +QStyleOptionTabWidgetFrameV2::QStyleOptionTabWidgetFrameV2(int version) + : QStyleOptionTabWidgetFrame(version) +{ +} + + +/*! + Constructs a QStyleOptionTabWidgetFrameV2 copy of the \a other style option + which can be either of the QStyleOptionTabWidgetFrameV2 or + QStyleOptionTabWidgetFrame types. + + If the \a other style option's version is 1, the new style option's \l + selectedTabRect and tabBarRect will contain null rects + + \sa version +*/ +QStyleOptionTabWidgetFrameV2::QStyleOptionTabWidgetFrameV2(const QStyleOptionTabWidgetFrame &other) +{ + QStyleOptionTabWidgetFrameV2::operator=(other); + +} + + +/*! + Assigns the \a other style option to this style option. The \a + other style option can be either of the QStyleOptionFrameV2 or + QStyleOptionFrame types. + + If the \a{other} style option's version is 1, this style option's + \l FrameFeature value is set to \l QStyleOptionFrameV2::None. If + its version is 2, its \l FrameFeature value is simply copied to + this style option. +*/ +QStyleOptionTabWidgetFrameV2 &QStyleOptionTabWidgetFrameV2::operator=(const QStyleOptionTabWidgetFrame &other) +{ + QStyleOptionTabWidgetFrame::operator=(other); + if (const QStyleOptionTabWidgetFrameV2 *f2 = qstyleoption_cast(&other)) { + selectedTabRect = f2->selectedTabRect; + tabBarRect = f2->tabBarRect; + } + return *this; +} + + +/*! + \enum QStyleOptionTabWidgetFrameV2::StyleOptionVersion + + This enum is used to hold information about the version of the style option, and + is defined for each QStyleOption subclass. + + \value Version 2 + + The version is used by QStyleOption subclasses to implement + extensions without breaking compatibility. If you use + qstyleoption_cast(), you normally do not need to check it. + + \sa StyleOptionType +*/ + + #endif // QT_NO_TABWIDGET #ifndef QT_NO_TABBAR diff --git a/src/gui/styles/qstyleoption.h b/src/gui/styles/qstyleoption.h index bf8b479..abd52bf 100644 --- a/src/gui/styles/qstyleoption.h +++ b/src/gui/styles/qstyleoption.h @@ -192,8 +192,28 @@ public: protected: QStyleOptionTabWidgetFrame(int version); }; + +class Q_GUI_EXPORT QStyleOptionTabWidgetFrameV2 : public QStyleOptionTabWidgetFrame +{ +public: + enum StyleOptionVersion { Version = 2 }; + + QRect tabBarRect; + QRect selectedTabRect; + + QStyleOptionTabWidgetFrameV2(); + QStyleOptionTabWidgetFrameV2(const QStyleOptionTabWidgetFrameV2 &other) : + QStyleOptionTabWidgetFrame(Version) { *this = other; } + QStyleOptionTabWidgetFrameV2(const QStyleOptionTabWidgetFrame &other); + QStyleOptionTabWidgetFrameV2 &operator=(const QStyleOptionTabWidgetFrame &other); + +protected: + QStyleOptionTabWidgetFrameV2(int version); +}; + #endif + #ifndef QT_NO_TABBAR class Q_GUI_EXPORT QStyleOptionTabBarBase : public QStyleOption { diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 2d90aa1..ae1d33a 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -4325,7 +4325,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op QRenderRule subRule = renderRule(w, opt, PseudoElement_TabWidgetPane); if (subRule.hasNativeBorder()) { subRule.drawBackground(p, opt->rect); - QStyleOptionTabWidgetFrame frmCopy(*frm); + QStyleOptionTabWidgetFrameV2 frmCopy(*frm); subRule.configurePalette(&frmCopy.palette, QPalette::WindowText, QPalette::Window); baseStyle()->drawPrimitive(pe, &frmCopy, p, w); } else { diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index b5dc647..9fd9ce9 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -1582,7 +1582,7 @@ case PE_Frame: // This should work, but currently there's an error in the ::drawBackgroundDirectly() // code, when using the HDC directly.. if (useGradient) { - QStyleOptionTabWidgetFrame frameOpt = *tab; + QStyleOptionTabWidgetFrameV2 frameOpt = *tab; frameOpt.rect = widget->rect(); QRect contentsRect = subElementRect(SE_TabWidgetTabContents, &frameOpt, widget); QRegion reg = option->rect; diff --git a/src/gui/widgets/qtabwidget.cpp b/src/gui/widgets/qtabwidget.cpp index 0c89a72..d22bd54 100644 --- a/src/gui/widgets/qtabwidget.cpp +++ b/src/gui/widgets/qtabwidget.cpp @@ -313,7 +313,16 @@ void QTabWidget::initStyleOption(QStyleOptionTabWidgetFrame *option) const : QTabBar::TriangularEast; break; } + option->tabBarSize = t; + + if (QStyleOptionTabWidgetFrameV2 *tabframe = qstyleoption_cast(option)) { + QRect tbRect = tabBar()->geometry(); + QRect selectedTabRect = tabBar()->tabRect(tabBar()->currentIndex()); + tabframe->tabBarRect = tbRect; + selectedTabRect.moveTopLeft(selectedTabRect.topLeft() + tbRect.topLeft()); + tabframe->selectedTabRect = selectedTabRect; + } } /*! @@ -756,7 +765,7 @@ void QTabWidget::setUpLayout(bool onlyCheck) if (onlyCheck && !d->dirty) return; // nothing to do - QStyleOptionTabWidgetFrame option; + QStyleOptionTabWidgetFrameV2 option; initStyleOption(&option); // this must be done immediately, because QWidgetItem relies on it (even if !isVisible()) @@ -1186,7 +1195,8 @@ void QTabWidget::paintEvent(QPaintEvent *) return; } QStylePainter p(this); - QStyleOptionTabWidgetFrame opt; + + QStyleOptionTabWidgetFrameV2 opt; initStyleOption(&opt); opt.rect = d->panelRect; p.drawPrimitive(QStyle::PE_FrameTabWidget, opt); -- cgit v0.12 From e1f691d84dad17c5ee47c97c31ae743093ad8bc9 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 8 Oct 2009 09:15:20 +0200 Subject: Ensure that qmake doesn't lose the error code when processing subdirs When processing a project in a subdirs template failed for whatever reason then qmake would lose the result of that and would return an error code of 0 if the subdirs project file itself was processed fine. So now it ensures that any errors arising from processing a project referenced in a subdirs project file are not lost so that the error code returned from qmake will indicate an error actually occured. Task-number: QTBUG-4065 Reviewed-by: mariusSO Original-commit: c15b370c9db16fdbfd9e7bec89ee9bf8c1110827 --- qmake/generators/metamakefile.cpp | 17 ++++++++++++----- qmake/generators/metamakefile.h | 2 +- qmake/main.cpp | 6 +++++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/qmake/generators/metamakefile.cpp b/qmake/generators/metamakefile.cpp index 5915fcf..819cdaf 100644 --- a/qmake/generators/metamakefile.cpp +++ b/qmake/generators/metamakefile.cpp @@ -291,6 +291,7 @@ SubdirsMetaMakefileGenerator::init() if(init_flag) return false; init_flag = true; + bool hasError = false; if(Option::recursive) { QString old_output_dir = Option::output_dir; @@ -336,14 +337,18 @@ SubdirsMetaMakefileGenerator::init() } qmake_setpwd(sub->input_dir); Option::output_dir = sub->output_dir; - sub_proj->read(subdir.fileName()); + bool tmpError = !sub_proj->read(subdir.fileName()); if(!sub_proj->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { fprintf(stderr, "Project file(%s) not recursed because all requirements not met:\n\t%s\n", subdir.fileName().toLatin1().constData(), sub_proj->values("QMAKE_FAILED_REQUIREMENTS").join(" ").toLatin1().constData()); delete sub; delete sub_proj; + Option::output_dir = old_output_dir; + qmake_setpwd(oldpwd); continue; + } else { + hasError |= tmpError; } sub->makefile = MetaMakefileGenerator::createMetaGenerator(sub_proj, sub_name); if(0 && sub->makefile->type() == SUBDIRSMETATYPE) { @@ -351,7 +356,7 @@ SubdirsMetaMakefileGenerator::init() } else { const QString output_name = Option::output.fileName(); Option::output.setFileName(sub->output_file); - sub->makefile->write(sub->output_dir); + hasError |= !sub->makefile->write(sub->output_dir); delete sub; qmakeClearCaches(); sub = 0; @@ -376,7 +381,7 @@ SubdirsMetaMakefileGenerator::init() self->makefile->init(); subs.append(self); - return true; + return !hasError; } bool @@ -482,7 +487,7 @@ MetaMakefileGenerator::createMakefileGenerator(QMakeProject *proj, bool noIO) } MetaMakefileGenerator * -MetaMakefileGenerator::createMetaGenerator(QMakeProject *proj, const QString &name, bool op) +MetaMakefileGenerator::createMetaGenerator(QMakeProject *proj, const QString &name, bool op, bool *success) { MetaMakefileGenerator *ret = 0; if ((Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || @@ -492,7 +497,9 @@ MetaMakefileGenerator::createMetaGenerator(QMakeProject *proj, const QString &na } if (!ret) ret = new BuildsMetaMakefileGenerator(proj, name, op); - ret->init(); + bool res = ret->init(); + if (success) + *success = res; return ret; } diff --git a/qmake/generators/metamakefile.h b/qmake/generators/metamakefile.h index e69304a..f74f4a2 100644 --- a/qmake/generators/metamakefile.h +++ b/qmake/generators/metamakefile.h @@ -62,7 +62,7 @@ public: virtual ~MetaMakefileGenerator(); - static MetaMakefileGenerator *createMetaGenerator(QMakeProject *proj, const QString &name, bool op=true); + static MetaMakefileGenerator *createMetaGenerator(QMakeProject *proj, const QString &name, bool op=true, bool *success = 0); static MakefileGenerator *createMakefileGenerator(QMakeProject *proj, bool noIO = false); inline QMakeProject *projectFile() const { return project; } diff --git a/qmake/main.cpp b/qmake/main.cpp index 73fdda9..a0346c5 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp @@ -168,7 +168,11 @@ int runQMake(int argc, char **argv) continue; } - MetaMakefileGenerator *mkfile = MetaMakefileGenerator::createMetaGenerator(&project, QString(), false); + bool success = true; + MetaMakefileGenerator *mkfile = MetaMakefileGenerator::createMetaGenerator(&project, QString(), false, &success); + if (!success) + exit_val = 3; + if(mkfile && !mkfile->write(oldpwd)) { if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) fprintf(stderr, "Unable to generate project file.\n"); -- cgit v0.12 From 2a293f91a6b550cd72851d08616b4a8199faabdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 7 Oct 2009 20:33:25 +0200 Subject: Introducing QT_MMAP In platforms with Large File Support, we use mmap64, to be able to handle offsets (and therefore files) larger than 2Gb. Reviewed-by: Thiago Macieira --- mkspecs/aix-g++-64/qplatformdefs.h | 2 ++ mkspecs/aix-g++/qplatformdefs.h | 2 ++ mkspecs/aix-xlc-64/qplatformdefs.h | 2 ++ mkspecs/aix-xlc/qplatformdefs.h | 2 ++ mkspecs/common/symbian/qplatformdefs.h | 2 ++ mkspecs/common/wince/qplatformdefs.h | 1 + mkspecs/cygwin-g++/qplatformdefs.h | 1 + mkspecs/darwin-g++/qplatformdefs.h | 1 + mkspecs/freebsd-g++/qplatformdefs.h | 1 + mkspecs/hpux-acc-64/qplatformdefs.h | 2 ++ mkspecs/hpux-acc-o64/qplatformdefs.h | 2 ++ mkspecs/hpux-acc/qplatformdefs.h | 2 ++ mkspecs/hpux-g++-64/qplatformdefs.h | 2 ++ mkspecs/hpux-g++/qplatformdefs.h | 2 ++ mkspecs/hpuxi-acc-32/qplatformdefs.h | 2 ++ mkspecs/hpuxi-acc-64/qplatformdefs.h | 2 ++ mkspecs/hpuxi-g++-64/qplatformdefs.h | 2 ++ mkspecs/hurd-g++/qplatformdefs.h | 1 + mkspecs/irix-cc-64/qplatformdefs.h | 2 ++ mkspecs/irix-cc/qplatformdefs.h | 2 ++ mkspecs/irix-g++/qplatformdefs.h | 2 ++ mkspecs/linux-cxx/qplatformdefs.h | 2 ++ mkspecs/linux-ecc-64/qplatformdefs.h | 2 ++ mkspecs/linux-g++-gles2-experimental/qplatformdefs.h | 2 ++ mkspecs/linux-g++/qplatformdefs.h | 2 ++ mkspecs/linux-kcc/qplatformdefs.h | 2 ++ mkspecs/linux-llvm/qplatformdefs.h | 2 ++ mkspecs/linux-lsb-g++/qplatformdefs.h | 2 ++ mkspecs/linux-pgcc/qplatformdefs.h | 2 ++ mkspecs/lynxos-g++/qplatformdefs.h | 1 + mkspecs/macx-g++/qplatformdefs.h | 1 + mkspecs/macx-g++40/qplatformdefs.h | 1 + mkspecs/macx-g++42/qplatformdefs.h | 1 + mkspecs/macx-llvm/qplatformdefs.h | 1 + mkspecs/macx-pbuilder/qplatformdefs.h | 1 + mkspecs/macx-xcode/qplatformdefs.h | 1 + mkspecs/macx-xlc/qplatformdefs.h | 1 + mkspecs/netbsd-g++/qplatformdefs.h | 1 + mkspecs/openbsd-g++/qplatformdefs.h | 1 + mkspecs/sco-cc/qplatformdefs.h | 1 + mkspecs/sco-g++/qplatformdefs.h | 1 + mkspecs/solaris-cc-64/qplatformdefs.h | 2 ++ mkspecs/solaris-cc/qplatformdefs.h | 2 ++ mkspecs/solaris-g++-64/qplatformdefs.h | 2 ++ mkspecs/solaris-g++/qplatformdefs.h | 2 ++ mkspecs/tru64-cxx/qplatformdefs.h | 1 + mkspecs/tru64-g++/qplatformdefs.h | 1 + mkspecs/unixware-cc/qplatformdefs.h | 1 + mkspecs/unixware-g++/qplatformdefs.h | 1 + mkspecs/unsupported/qnx-g++/qplatformdefs.h | 2 ++ mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h | 2 ++ 51 files changed, 81 insertions(+) diff --git a/mkspecs/aix-g++-64/qplatformdefs.h b/mkspecs/aix-g++-64/qplatformdefs.h index 5a1cda8..25c86a2 100644 --- a/mkspecs/aix-g++-64/qplatformdefs.h +++ b/mkspecs/aix-g++-64/qplatformdefs.h @@ -109,6 +109,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -117,6 +118,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/aix-g++/qplatformdefs.h b/mkspecs/aix-g++/qplatformdefs.h index 5a1cda8..25c86a2 100644 --- a/mkspecs/aix-g++/qplatformdefs.h +++ b/mkspecs/aix-g++/qplatformdefs.h @@ -109,6 +109,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -117,6 +118,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/aix-xlc-64/qplatformdefs.h b/mkspecs/aix-xlc-64/qplatformdefs.h index 0a0d11f..a25ea42 100644 --- a/mkspecs/aix-xlc-64/qplatformdefs.h +++ b/mkspecs/aix-xlc-64/qplatformdefs.h @@ -105,6 +105,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -113,6 +114,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/aix-xlc/qplatformdefs.h b/mkspecs/aix-xlc/qplatformdefs.h index b162513..3856600 100644 --- a/mkspecs/aix-xlc/qplatformdefs.h +++ b/mkspecs/aix-xlc/qplatformdefs.h @@ -105,6 +105,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -113,6 +114,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/common/symbian/qplatformdefs.h b/mkspecs/common/symbian/qplatformdefs.h index 2d0e6e8..e1d8f6a 100644 --- a/mkspecs/common/symbian/qplatformdefs.h +++ b/mkspecs/common/symbian/qplatformdefs.h @@ -112,6 +112,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -120,6 +121,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/common/wince/qplatformdefs.h b/mkspecs/common/wince/qplatformdefs.h index f00ed71..eecbd1e 100644 --- a/mkspecs/common/wince/qplatformdefs.h +++ b/mkspecs/common/wince/qplatformdefs.h @@ -111,6 +111,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long diff --git a/mkspecs/cygwin-g++/qplatformdefs.h b/mkspecs/cygwin-g++/qplatformdefs.h index 78f7398..6cf02f2 100644 --- a/mkspecs/cygwin-g++/qplatformdefs.h +++ b/mkspecs/cygwin-g++/qplatformdefs.h @@ -119,6 +119,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long diff --git a/mkspecs/darwin-g++/qplatformdefs.h b/mkspecs/darwin-g++/qplatformdefs.h index 31e32f1..8ae5606 100644 --- a/mkspecs/darwin-g++/qplatformdefs.h +++ b/mkspecs/darwin-g++/qplatformdefs.h @@ -79,6 +79,7 @@ #define QT_FTELL ::ftello #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/freebsd-g++/qplatformdefs.h b/mkspecs/freebsd-g++/qplatformdefs.h index 470923a..8b07cdc 100644 --- a/mkspecs/freebsd-g++/qplatformdefs.h +++ b/mkspecs/freebsd-g++/qplatformdefs.h @@ -81,6 +81,7 @@ #define QT_FTELL ::ftello #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/hpux-acc-64/qplatformdefs.h b/mkspecs/hpux-acc-64/qplatformdefs.h index a8025d0..7ef3d51 100644 --- a/mkspecs/hpux-acc-64/qplatformdefs.h +++ b/mkspecs/hpux-acc-64/qplatformdefs.h @@ -104,6 +104,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -112,6 +113,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/hpux-acc-o64/qplatformdefs.h b/mkspecs/hpux-acc-o64/qplatformdefs.h index 4927cf9..e082d9d 100644 --- a/mkspecs/hpux-acc-o64/qplatformdefs.h +++ b/mkspecs/hpux-acc-o64/qplatformdefs.h @@ -105,6 +105,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -113,6 +114,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/hpux-acc/qplatformdefs.h b/mkspecs/hpux-acc/qplatformdefs.h index ec416cd..7b540a1 100644 --- a/mkspecs/hpux-acc/qplatformdefs.h +++ b/mkspecs/hpux-acc/qplatformdefs.h @@ -107,6 +107,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -115,6 +116,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/hpux-g++-64/qplatformdefs.h b/mkspecs/hpux-g++-64/qplatformdefs.h index 31aa7ff..a8d06d8 100644 --- a/mkspecs/hpux-g++-64/qplatformdefs.h +++ b/mkspecs/hpux-g++-64/qplatformdefs.h @@ -104,6 +104,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -112,6 +113,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/hpux-g++/qplatformdefs.h b/mkspecs/hpux-g++/qplatformdefs.h index 2c46b7d..d89a026 100644 --- a/mkspecs/hpux-g++/qplatformdefs.h +++ b/mkspecs/hpux-g++/qplatformdefs.h @@ -106,6 +106,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -114,6 +115,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/hpuxi-acc-32/qplatformdefs.h b/mkspecs/hpuxi-acc-32/qplatformdefs.h index f02de1f..466f27e 100644 --- a/mkspecs/hpuxi-acc-32/qplatformdefs.h +++ b/mkspecs/hpuxi-acc-32/qplatformdefs.h @@ -105,6 +105,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -113,6 +114,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/hpuxi-acc-64/qplatformdefs.h b/mkspecs/hpuxi-acc-64/qplatformdefs.h index f02de1f..466f27e 100644 --- a/mkspecs/hpuxi-acc-64/qplatformdefs.h +++ b/mkspecs/hpuxi-acc-64/qplatformdefs.h @@ -105,6 +105,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -113,6 +114,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/hpuxi-g++-64/qplatformdefs.h b/mkspecs/hpuxi-g++-64/qplatformdefs.h index 546a7b5..d351af3 100644 --- a/mkspecs/hpuxi-g++-64/qplatformdefs.h +++ b/mkspecs/hpuxi-g++-64/qplatformdefs.h @@ -104,6 +104,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -112,6 +113,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/hurd-g++/qplatformdefs.h b/mkspecs/hurd-g++/qplatformdefs.h index d5aaf66..611252c 100644 --- a/mkspecs/hurd-g++/qplatformdefs.h +++ b/mkspecs/hurd-g++/qplatformdefs.h @@ -87,6 +87,7 @@ #define QT_FTELL ::ftello #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/irix-cc-64/qplatformdefs.h b/mkspecs/irix-cc-64/qplatformdefs.h index 6d436a1..bfb19ca 100644 --- a/mkspecs/irix-cc-64/qplatformdefs.h +++ b/mkspecs/irix-cc-64/qplatformdefs.h @@ -103,6 +103,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -111,6 +112,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/irix-cc/qplatformdefs.h b/mkspecs/irix-cc/qplatformdefs.h index 6d436a1..bfb19ca 100644 --- a/mkspecs/irix-cc/qplatformdefs.h +++ b/mkspecs/irix-cc/qplatformdefs.h @@ -103,6 +103,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -111,6 +112,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/irix-g++/qplatformdefs.h b/mkspecs/irix-g++/qplatformdefs.h index 8191c15..4e2fda2 100644 --- a/mkspecs/irix-g++/qplatformdefs.h +++ b/mkspecs/irix-g++/qplatformdefs.h @@ -103,6 +103,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -111,6 +112,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/linux-cxx/qplatformdefs.h b/mkspecs/linux-cxx/qplatformdefs.h index 5bf9686..0c3a07e 100644 --- a/mkspecs/linux-cxx/qplatformdefs.h +++ b/mkspecs/linux-cxx/qplatformdefs.h @@ -110,6 +110,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -118,6 +119,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/linux-ecc-64/qplatformdefs.h b/mkspecs/linux-ecc-64/qplatformdefs.h index 5bf9686..0c3a07e 100644 --- a/mkspecs/linux-ecc-64/qplatformdefs.h +++ b/mkspecs/linux-ecc-64/qplatformdefs.h @@ -110,6 +110,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -118,6 +119,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/linux-g++-gles2-experimental/qplatformdefs.h b/mkspecs/linux-g++-gles2-experimental/qplatformdefs.h index 1430916..ecfbc73 100644 --- a/mkspecs/linux-g++-gles2-experimental/qplatformdefs.h +++ b/mkspecs/linux-g++-gles2-experimental/qplatformdefs.h @@ -110,6 +110,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -118,6 +119,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/linux-g++/qplatformdefs.h b/mkspecs/linux-g++/qplatformdefs.h index 1430916..ecfbc73 100644 --- a/mkspecs/linux-g++/qplatformdefs.h +++ b/mkspecs/linux-g++/qplatformdefs.h @@ -110,6 +110,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -118,6 +119,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/linux-kcc/qplatformdefs.h b/mkspecs/linux-kcc/qplatformdefs.h index 48a289b..65278c8 100644 --- a/mkspecs/linux-kcc/qplatformdefs.h +++ b/mkspecs/linux-kcc/qplatformdefs.h @@ -113,6 +113,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -121,6 +122,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/linux-llvm/qplatformdefs.h b/mkspecs/linux-llvm/qplatformdefs.h index 1430916..ecfbc73 100644 --- a/mkspecs/linux-llvm/qplatformdefs.h +++ b/mkspecs/linux-llvm/qplatformdefs.h @@ -110,6 +110,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -118,6 +119,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/linux-lsb-g++/qplatformdefs.h b/mkspecs/linux-lsb-g++/qplatformdefs.h index dc48a089..0928b71 100644 --- a/mkspecs/linux-lsb-g++/qplatformdefs.h +++ b/mkspecs/linux-lsb-g++/qplatformdefs.h @@ -114,6 +114,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -122,6 +123,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/linux-pgcc/qplatformdefs.h b/mkspecs/linux-pgcc/qplatformdefs.h index 5bf9686..0c3a07e 100644 --- a/mkspecs/linux-pgcc/qplatformdefs.h +++ b/mkspecs/linux-pgcc/qplatformdefs.h @@ -110,6 +110,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -118,6 +119,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/lynxos-g++/qplatformdefs.h b/mkspecs/lynxos-g++/qplatformdefs.h index e362676..96764a3 100644 --- a/mkspecs/lynxos-g++/qplatformdefs.h +++ b/mkspecs/lynxos-g++/qplatformdefs.h @@ -80,6 +80,7 @@ #define QT_FTELL ::ftello #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/macx-g++/qplatformdefs.h b/mkspecs/macx-g++/qplatformdefs.h index 98e5eaf..3a9288b 100644 --- a/mkspecs/macx-g++/qplatformdefs.h +++ b/mkspecs/macx-g++/qplatformdefs.h @@ -80,6 +80,7 @@ #define QT_FTELL ::ftello #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/macx-g++40/qplatformdefs.h b/mkspecs/macx-g++40/qplatformdefs.h index 98e5eaf..3a9288b 100644 --- a/mkspecs/macx-g++40/qplatformdefs.h +++ b/mkspecs/macx-g++40/qplatformdefs.h @@ -80,6 +80,7 @@ #define QT_FTELL ::ftello #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/macx-g++42/qplatformdefs.h b/mkspecs/macx-g++42/qplatformdefs.h index 98e5eaf..3a9288b 100644 --- a/mkspecs/macx-g++42/qplatformdefs.h +++ b/mkspecs/macx-g++42/qplatformdefs.h @@ -80,6 +80,7 @@ #define QT_FTELL ::ftello #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/macx-llvm/qplatformdefs.h b/mkspecs/macx-llvm/qplatformdefs.h index 98e5eaf..3a9288b 100644 --- a/mkspecs/macx-llvm/qplatformdefs.h +++ b/mkspecs/macx-llvm/qplatformdefs.h @@ -80,6 +80,7 @@ #define QT_FTELL ::ftello #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/macx-pbuilder/qplatformdefs.h b/mkspecs/macx-pbuilder/qplatformdefs.h index 04aaab7..05ee441 100644 --- a/mkspecs/macx-pbuilder/qplatformdefs.h +++ b/mkspecs/macx-pbuilder/qplatformdefs.h @@ -80,6 +80,7 @@ #define QT_FTELL ::ftello #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/macx-xcode/qplatformdefs.h b/mkspecs/macx-xcode/qplatformdefs.h index 98e5eaf..3a9288b 100644 --- a/mkspecs/macx-xcode/qplatformdefs.h +++ b/mkspecs/macx-xcode/qplatformdefs.h @@ -80,6 +80,7 @@ #define QT_FTELL ::ftello #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/macx-xlc/qplatformdefs.h b/mkspecs/macx-xlc/qplatformdefs.h index e701217..bc2cfb6 100644 --- a/mkspecs/macx-xlc/qplatformdefs.h +++ b/mkspecs/macx-xlc/qplatformdefs.h @@ -80,6 +80,7 @@ #define QT_FTELL ::ftello #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/netbsd-g++/qplatformdefs.h b/mkspecs/netbsd-g++/qplatformdefs.h index 6e0fee7..40f83a2 100644 --- a/mkspecs/netbsd-g++/qplatformdefs.h +++ b/mkspecs/netbsd-g++/qplatformdefs.h @@ -80,6 +80,7 @@ #define QT_FTELL ::ftello #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/openbsd-g++/qplatformdefs.h b/mkspecs/openbsd-g++/qplatformdefs.h index ef313aa..90e4c21 100644 --- a/mkspecs/openbsd-g++/qplatformdefs.h +++ b/mkspecs/openbsd-g++/qplatformdefs.h @@ -81,6 +81,7 @@ #define QT_FTELL ::ftello #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/sco-cc/qplatformdefs.h b/mkspecs/sco-cc/qplatformdefs.h index 4c53c18..41f4f0f 100644 --- a/mkspecs/sco-cc/qplatformdefs.h +++ b/mkspecs/sco-cc/qplatformdefs.h @@ -81,6 +81,7 @@ #define QT_FTELL ::ftello #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/sco-g++/qplatformdefs.h b/mkspecs/sco-g++/qplatformdefs.h index 3ecb86d..613f22e 100644 --- a/mkspecs/sco-g++/qplatformdefs.h +++ b/mkspecs/sco-g++/qplatformdefs.h @@ -85,6 +85,7 @@ #define QT_FTELL ::ftello #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/solaris-cc-64/qplatformdefs.h b/mkspecs/solaris-cc-64/qplatformdefs.h index 3d1ddeb..f344ffc 100644 --- a/mkspecs/solaris-cc-64/qplatformdefs.h +++ b/mkspecs/solaris-cc-64/qplatformdefs.h @@ -111,6 +111,7 @@ static inline int qt_socket_connect(int s, struct sockaddr *addr, QT_SOCKLEN_T a #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -119,6 +120,7 @@ static inline int qt_socket_connect(int s, struct sockaddr *addr, QT_SOCKLEN_T a #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/solaris-cc/qplatformdefs.h b/mkspecs/solaris-cc/qplatformdefs.h index 6c5fd5f..8b2104a 100644 --- a/mkspecs/solaris-cc/qplatformdefs.h +++ b/mkspecs/solaris-cc/qplatformdefs.h @@ -119,6 +119,7 @@ static inline int qt_socket_connect(int s, struct sockaddr *addr, QT_SOCKLEN_T a #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -127,6 +128,7 @@ static inline int qt_socket_connect(int s, struct sockaddr *addr, QT_SOCKLEN_T a #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/solaris-g++-64/qplatformdefs.h b/mkspecs/solaris-g++-64/qplatformdefs.h index 09aabfd..a6f9c8a 100644 --- a/mkspecs/solaris-g++-64/qplatformdefs.h +++ b/mkspecs/solaris-g++-64/qplatformdefs.h @@ -128,6 +128,7 @@ static inline int qt_socket_bind(int s, struct sockaddr *addr, QT_SOCKLEN_T addr #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -136,6 +137,7 @@ static inline int qt_socket_bind(int s, struct sockaddr *addr, QT_SOCKLEN_T addr #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/solaris-g++/qplatformdefs.h b/mkspecs/solaris-g++/qplatformdefs.h index 01b551d..c37b366 100644 --- a/mkspecs/solaris-g++/qplatformdefs.h +++ b/mkspecs/solaris-g++/qplatformdefs.h @@ -132,6 +132,7 @@ static inline int qt_socket_bind(int s, struct sockaddr *addr, QT_SOCKLEN_T addr #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -140,6 +141,7 @@ static inline int qt_socket_bind(int s, struct sockaddr *addr, QT_SOCKLEN_T addr #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif diff --git a/mkspecs/tru64-cxx/qplatformdefs.h b/mkspecs/tru64-cxx/qplatformdefs.h index 7c25fa0..aa3a909 100644 --- a/mkspecs/tru64-cxx/qplatformdefs.h +++ b/mkspecs/tru64-cxx/qplatformdefs.h @@ -83,6 +83,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/tru64-g++/qplatformdefs.h b/mkspecs/tru64-g++/qplatformdefs.h index 63eea44..0e8b345 100644 --- a/mkspecs/tru64-g++/qplatformdefs.h +++ b/mkspecs/tru64-g++/qplatformdefs.h @@ -83,6 +83,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/unixware-cc/qplatformdefs.h b/mkspecs/unixware-cc/qplatformdefs.h index ea523fb..3a6b314 100644 --- a/mkspecs/unixware-cc/qplatformdefs.h +++ b/mkspecs/unixware-cc/qplatformdefs.h @@ -81,6 +81,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/unixware-g++/qplatformdefs.h b/mkspecs/unixware-g++/qplatformdefs.h index ea523fb..3a6b314 100644 --- a/mkspecs/unixware-g++/qplatformdefs.h +++ b/mkspecs/unixware-g++/qplatformdefs.h @@ -81,6 +81,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t diff --git a/mkspecs/unsupported/qnx-g++/qplatformdefs.h b/mkspecs/unsupported/qnx-g++/qplatformdefs.h index f309f81..3abdc92 100644 --- a/mkspecs/unsupported/qnx-g++/qplatformdefs.h +++ b/mkspecs/unsupported/qnx-g++/qplatformdefs.h @@ -87,6 +87,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -95,6 +96,7 @@ #define QT_FTELL ::ftello #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T off_t #endif diff --git a/mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h b/mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h index 5cec788..d16fa8a 100644 --- a/mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h +++ b/mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h @@ -76,6 +76,7 @@ #define QT_FTELL ::ftello64 #define QT_FGETPOS ::fgetpos64 #define QT_FSETPOS ::fsetpos64 +#define QT_MMAP ::mmap64 #define QT_FPOS_T fpos64_t #define QT_OFF_T off64_t #else @@ -84,6 +85,7 @@ #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos +#define QT_MMAP ::mmap #define QT_FPOS_T fpos_t #define QT_OFF_T long #endif -- cgit v0.12 From 0689a85ca20a36808b388efc452892606d47b34d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 7 Oct 2009 14:48:50 +0200 Subject: Fix 32/64-bit issues with QFile::map/unmap() on *nix systems We would previously silently ignore overflows in 32-bit systems and not properly support 64-bit offsets in systems that support it because of integer overflow. There was also a problem that could prevent unmap from succeeding, because we were passing the wrong length argument. Task-number: QT-1594 Reviewed-by: Thiago Macieira --- src/corelib/io/qfsfileengine_p.h | 2 +- src/corelib/io/qfsfileengine_unix.cpp | 31 +++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index 66e0219..ee127c1 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -114,7 +114,7 @@ public: mutable int cachedFd; mutable DWORD fileAttrib; #else - QHash > maps; + QHash > maps; mutable QT_STATBUF st; #endif int fd; diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index b0cddaa..d346685 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -1243,34 +1243,45 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla q->setError(QFile::PermissionsError, qt_error_string(int(EACCES))); return 0; } - if (offset < 0) { + + if (offset < 0 || offset != qint64(QT_OFF_T(offset)) + || size < 0 || size > (size_t)-1) { q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL))); return 0; } + int access = 0; if (openMode & QIODevice::ReadOnly) access |= PROT_READ; if (openMode & QIODevice::WriteOnly) access |= PROT_WRITE; - int pagesSize = getpagesize(); - int realOffset = offset / pagesSize; - int extra = offset % pagesSize; + int pageSize = getpagesize(); + int extra = offset % pageSize; + + if (size + extra > (size_t)-1) { + q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL))); + return 0; + } + + size_t realSize = (size_t)size + extra; + QT_OFF_T realOffset = QT_OFF_T(offset); + realOffset &= ~(QT_OFF_T(pageSize)); #ifdef Q_OS_SYMBIAN void *mapAddress; - TRAPD(err, mapAddress = mmap((void*)0, (size_t)size + extra, - access, MAP_SHARED, nativeHandle(), realOffset * pagesSize)); + TRAPD(err, mapAddress = QT_MMAP((void*)0, realSize, + access, MAP_SHARED, nativeHandle(), realOffset)); if (err != KErrNone) { qWarning("OpenC bug: leave from mmap %d", err); mapAddress = MAP_FAILED; errno = EINVAL; } #else - void *mapAddress = mmap((void*)0, (size_t)size + extra, - access, MAP_SHARED, nativeHandle(), realOffset * pagesSize); + void *mapAddress = QT_MMAP((void*)0, realSize, + access, MAP_SHARED, nativeHandle(), realOffset); #endif if (MAP_FAILED != mapAddress) { uchar *address = extra + static_cast(mapAddress); - maps[address] = QPair(extra, size); + maps[address] = QPair(extra, realSize); return address; } @@ -1300,7 +1311,7 @@ bool QFSFileEnginePrivate::unmap(uchar *ptr) } uchar *start = ptr - maps[ptr].first; - int len = maps[ptr].second; + size_t len = maps[ptr].second; if (-1 == munmap(start, len)) { q->setError(QFile::UnspecifiedError, qt_error_string(errno)); return false; -- cgit v0.12 From 512c2284cafb3eb23d06fc5cdc4e424b711a04b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 7 Oct 2009 17:42:39 +0200 Subject: (Windows) Don't create a file mapping for each view that is mapped Creating a file mapping for each view mapped to memory is sub-optimal and slow. With this change, a single mapping is created and reused when mapping subsequent views of the file. The handle returned from CreateFileForMapping (used in WinCE 5) is now discarded, since the kernel manages it automatically with the file mapping. This simplifies use of the deprecated map API. Reviewed-by: Maurice Kalinowski Reviewed-by: Marius Storm-Olsen --- src/corelib/io/qfsfileengine.cpp | 4 +- src/corelib/io/qfsfileengine_p.h | 8 +--- src/corelib/io/qfsfileengine_win.cpp | 84 +++++++++++++----------------------- 3 files changed, 34 insertions(+), 62 deletions(-) diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index fb096a7..2c5451d 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -122,11 +122,9 @@ void QFSFileEnginePrivate::init() #ifdef Q_OS_WIN fileAttrib = INVALID_FILE_ATTRIBUTES; fileHandle = INVALID_HANDLE_VALUE; + mapHandle = INVALID_HANDLE_VALUE; cachedFd = -1; #endif -#ifdef Q_USE_DEPRECATED_MAP_API - fileMapHandle = INVALID_HANDLE_VALUE; -#endif } /*! diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index ee127c1..87f0737 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -110,7 +110,8 @@ public: FILE *fh; #ifdef Q_WS_WIN HANDLE fileHandle; - QHash > maps; + HANDLE mapHandle; + QHash maps; mutable int cachedFd; mutable DWORD fileAttrib; #else @@ -119,11 +120,6 @@ public: #endif int fd; -#ifdef Q_USE_DEPRECATED_MAP_API - void mapHandleClose(); - HANDLE fileMapHandle; -#endif - enum LastIOCommand { IOFlushCommand, diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 898447c..151eabd 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -455,17 +455,10 @@ bool QFSFileEnginePrivate::nativeClose() // Windows native mode. bool ok = true; - if ((fileHandle == INVALID_HANDLE_VALUE || !CloseHandle(fileHandle)) -#ifdef Q_USE_DEPRECATED_MAP_API - && (fileMapHandle == INVALID_HANDLE_VALUE || !CloseHandle(fileMapHandle)) -#endif - ) { + if ((fileHandle == INVALID_HANDLE_VALUE || !::CloseHandle(fileHandle))) { q->setError(QFile::UnspecifiedError, qt_error_string()); ok = false; } -#ifdef Q_USE_DEPRECATED_MAP_API - fileMapHandle = INVALID_HANDLE_VALUE; -#endif fileHandle = INVALID_HANDLE_VALUE; cachedFd = -1; // gets closed by CloseHandle above @@ -1931,42 +1924,42 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, return 0; } + if (mapHandle == INVALID_HANDLE_VALUE) { + // get handle to the file + HANDLE handle = fileHandle; - // get handle to the file - HANDLE handle = fileHandle; #ifndef Q_OS_WINCE - if (handle == INVALID_HANDLE_VALUE && fh) - handle = (HANDLE)_get_osfhandle(QT_FILENO(fh)); + if (handle == INVALID_HANDLE_VALUE && fh) + handle = (HANDLE)::_get_osfhandle(QT_FILENO(fh)); #endif #ifdef Q_USE_DEPRECATED_MAP_API - if (fileMapHandle == INVALID_HANDLE_VALUE) { nativeClose(); - fileMapHandle = CreateFileForMapping((const wchar_t*)nativeFilePath.constData(), + // handle automatically closed by kernel with mapHandle (below). + handle = ::CreateFileForMapping((const wchar_t*)nativeFilePath.constData(), GENERIC_READ | (openMode & QIODevice::WriteOnly ? GENERIC_WRITE : 0), 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - } - handle = fileMapHandle; #endif - if (handle == INVALID_HANDLE_VALUE) { - q->setError(QFile::PermissionsError, qt_error_string(ERROR_ACCESS_DENIED)); - return 0; - } + if (handle == INVALID_HANDLE_VALUE) { + q->setError(QFile::PermissionsError, qt_error_string(ERROR_ACCESS_DENIED)); + return 0; + } - // first create the file mapping handle - DWORD protection = (openMode & QIODevice::WriteOnly) ? PAGE_READWRITE : PAGE_READONLY; - HANDLE mapHandle = ::CreateFileMapping(handle, 0, protection, 0, 0, 0); - if (mapHandle == NULL) { - q->setError(QFile::PermissionsError, qt_error_string()); + // first create the file mapping handle + DWORD protection = (openMode & QIODevice::WriteOnly) ? PAGE_READWRITE : PAGE_READONLY; + mapHandle = ::CreateFileMapping(handle, 0, protection, 0, 0, 0); + if (mapHandle == INVALID_HANDLE_VALUE) { + q->setError(QFile::PermissionsError, qt_error_string()); #ifdef Q_USE_DEPRECATED_MAP_API - mapHandleClose(); + ::CloseHandle(handle); #endif - return 0; + return 0; + } } // setup args to map @@ -1978,17 +1971,17 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, DWORD offsetLo = offset & Q_UINT64_C(0xffffffff); SYSTEM_INFO sysinfo; ::GetSystemInfo(&sysinfo); - int mask = sysinfo.dwAllocationGranularity - 1; - int extra = offset & mask; + DWORD mask = sysinfo.dwAllocationGranularity - 1; + DWORD extra = offset & mask; if (extra) offsetLo &= ~mask; // attempt to create the map - LPVOID mapAddress = MapViewOfFile(mapHandle, access, + LPVOID mapAddress = ::MapViewOfFile(mapHandle, access, offsetHi, offsetLo, size + extra); if (mapAddress) { uchar *address = extra + static_cast(mapAddress); - maps[address] = QPair(extra, mapHandle); + maps[address] = extra; return address; } @@ -2001,10 +1994,8 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, default: q->setError(QFile::UnspecifiedError, qt_error_string()); } - CloseHandle(mapHandle); -#ifdef Q_USE_DEPRECATED_MAP_API - mapHandleClose(); -#endif + + ::CloseHandle(mapHandle); return 0; } @@ -2015,32 +2006,19 @@ bool QFSFileEnginePrivate::unmap(uchar *ptr) q->setError(QFile::PermissionsError, qt_error_string(ERROR_ACCESS_DENIED)); return false; } - uchar *start = ptr - maps[ptr].first; + uchar *start = ptr - maps[ptr]; if (!UnmapViewOfFile(start)) { q->setError(QFile::PermissionsError, qt_error_string()); return false; } - if (!CloseHandle((HANDLE)maps[ptr].second)) { - q->setError(QFile::UnspecifiedError, qt_error_string()); - return false; - } maps.remove(ptr); - -#ifdef Q_USE_DEPRECATED_MAP_API - mapHandleClose(); -#endif - return true; -} - -#ifdef Q_USE_DEPRECATED_MAP_API -void QFSFileEnginePrivate::mapHandleClose() -{ if (maps.isEmpty()) { - CloseHandle(fileMapHandle); - fileMapHandle = INVALID_HANDLE_VALUE; + ::CloseHandle(mapHandle); + mapHandle = INVALID_HANDLE_VALUE; } + + return true; } -#endif QT_END_NAMESPACE -- cgit v0.12 From badfa3435f740ec7120b2ed3367fa2be50382136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 16 Oct 2009 18:10:47 +0200 Subject: Fixes some issues with large files in 32-bit systems Reviewed-by: Thiago Macieira --- src/corelib/io/qfile.cpp | 2 +- src/corelib/io/qfsfileengine.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 134c4b8..64d8ef3 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -1064,7 +1064,7 @@ bool QFile::open(FILE *fh, OpenMode mode) if (mode & Append) { seek(size()); } else { - long pos = ftell(fh); + qint64 pos = (qint64)QT_FTELL(fh); if (pos != -1) seek(pos); } diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 2c5451d..c34f8ad 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -564,6 +564,9 @@ bool QFSFileEnginePrivate::seekFdFh(qint64 pos) if (lastIOCommand != QFSFileEnginePrivate::IOFlushCommand && !q->flush()) return false; + if (pos < 0 || pos != qint64(QT_OFF_T(pos))) + return false; + if (fh) { // Buffered stdlib mode. int ret; @@ -577,7 +580,7 @@ bool QFSFileEnginePrivate::seekFdFh(qint64 pos) } } else { // Unbuffered stdio mode. - if (QT_LSEEK(fd, pos, SEEK_SET) == -1) { + if (QT_LSEEK(fd, QT_OFF_T(pos), SEEK_SET) == -1) { qWarning() << "QFile::at: Cannot set file position" << pos; q->setError(QFile::PositionError, qt_error_string(errno)); return false; -- cgit v0.12 From 6f52892206b155451e7b24cdbb1b4ab6569153e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 20 Oct 2009 15:39:06 +0200 Subject: Get file position when attaching an open file descriptor to QFile This was already being done when attaching to FILE* streams. Doing the same here makes the API consistent and more usable. Namely, one can use QFile::pos() to obtain the file position. Test case verifies this doesn't break support for sequential files. More thorough test case included in large file support test. Reviewed-by: Thiago Macieira --- src/corelib/io/qfile.cpp | 7 +++++- tests/auto/qfile/tst_qfile.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 64d8ef3..4dd6185 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -1120,8 +1120,13 @@ bool QFile::open(int fd, OpenMode mode) } if(d->openExternalFile(mode, fd)) { QIODevice::open(mode); - if (mode & Append) + if (mode & Append) { seek(size()); + } else { + qint64 pos = (qint64)QT_LSEEK(fd, QT_OFF_T(0), SEEK_CUR); + if (pos != -1) + seek(pos); + } return true; } return false; diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 19fbecd..bbb6280 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -187,6 +187,8 @@ private slots: void mapOpenMode_data(); void mapOpenMode(); + void openStandardStreams(); + // --- Task related tests below this line void task167217(); @@ -2634,5 +2636,58 @@ void tst_QFile::openDirectory() QVERIFY(!f1.open(QIODevice::ReadOnly|QIODevice::Unbuffered)); } +void tst_QFile::openStandardStreams() +{ + // Using file descriptors + { + QFile in; + in.open(STDIN_FILENO, QIODevice::ReadOnly); + QCOMPARE( in.pos(), (qint64)0 ); + QCOMPARE( in.size(), (qint64)0 ); + QVERIFY( in.isSequential() ); + } + + { + QFile out; + out.open(STDOUT_FILENO, QIODevice::WriteOnly); + QCOMPARE( out.pos(), (qint64)0 ); + QCOMPARE( out.size(), (qint64)0 ); + QVERIFY( out.isSequential() ); + } + + { + QFile err; + err.open(STDERR_FILENO, QIODevice::WriteOnly); + QCOMPARE( err.pos(), (qint64)0 ); + QCOMPARE( err.size(), (qint64)0 ); + QVERIFY( err.isSequential() ); + } + + // Using streams + { + QFile in; + in.open(stdin, QIODevice::ReadOnly); + QCOMPARE( in.pos(), (qint64)0 ); + QCOMPARE( in.size(), (qint64)0 ); + QVERIFY( in.isSequential() ); + } + + { + QFile out; + out.open(stdout, QIODevice::WriteOnly); + QCOMPARE( out.pos(), (qint64)0 ); + QCOMPARE( out.size(), (qint64)0 ); + QVERIFY( out.isSequential() ); + } + + { + QFile err; + err.open(stderr, QIODevice::WriteOnly); + QCOMPARE( err.pos(), (qint64)0 ); + QCOMPARE( err.size(), (qint64)0 ); + QVERIFY( err.isSequential() ); + } +} + QTEST_MAIN(tst_QFile) #include "tst_qfile.moc" -- cgit v0.12 From c6651f91b8f31d94ef37aa41cc2fd76d97e990e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 20 Oct 2009 16:28:22 +0200 Subject: Adding a test case for large file support The test case creates a (tentatively sparse) very large file with scattered data and uses it to test various aspects of large file support in QFile. Reviewed-by: Thiago Macieira --- tests/auto/qfile/largefile/largefile.pro | 4 + tests/auto/qfile/largefile/tst_largefile.cpp | 492 +++++++++++++++++++++++++++ tests/auto/qfile/qfile.pro | 2 +- 3 files changed, 497 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qfile/largefile/largefile.pro create mode 100644 tests/auto/qfile/largefile/tst_largefile.cpp diff --git a/tests/auto/qfile/largefile/largefile.pro b/tests/auto/qfile/largefile/largefile.pro new file mode 100644 index 0000000..0f96865 --- /dev/null +++ b/tests/auto/qfile/largefile/largefile.pro @@ -0,0 +1,4 @@ +load(qttest_p4) + +QT = core +SOURCES += tst_largefile.cpp diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp new file mode 100644 index 0000000..398ca3f --- /dev/null +++ b/tests/auto/qfile/largefile/tst_largefile.cpp @@ -0,0 +1,492 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include + +#include +#include + +#ifdef Q_OS_WIN + +#include +#include + +#ifndef FSCTL_SET_SPARSE +// MinGW doesn't define this. +#define FSCTL_SET_SPARSE (0x900C4) +#endif + +#endif // Q_OS_WIN + +class tst_LargeFile + : public QObject +{ + Q_OBJECT + +public: + tst_LargeFile() + : blockSize(1 << 12) + , maxSizeBits() + , largeFile("qt_largefile.tmp") + , fd_(-1) + , stream_(0) + { + #if defined(QT_LARGEFILE_SUPPORT) && !defined(Q_OS_MAC) + maxSizeBits = 36; // 64 GiB + #elif defined(Q_OS_MAC) + // HFS+ does not support sparse files, so we limit file size for the test + // on Mac OS. + maxSizeBits = 32; // 4 GiB + #else + maxSizeBits = 24; // 16 MiB + #endif + } + +private: + void sparseFileData(); + QByteArray const &getDataBlock(int index, qint64 position); + +private slots: + // The LargeFile test case was designed to be run in order as a single unit + + void initTestCase(); + void cleanupTestCase(); + + void init(); + void cleanup(); + + // Create and fill large file + void createSparseFile(); + void fillFileSparsely(); + void closeSparseFile(); + + // Verify file was created + void fileCreated(); + + // Positioning in large files + void filePositioning(); + void fdPositioning(); + void streamPositioning(); + + // Read data from file + void openFileForReading(); + void readFile(); + + // Map/unmap large file + void mapFile(); + void mapOffsetOverflow(); + + void closeFile() { largeFile.close(); } + + // Test data + void fillFileSparsely_data() { sparseFileData(); } + void filePositioning_data() { sparseFileData(); } + void fdPositioning_data() { sparseFileData(); } + void streamPositioning_data() { sparseFileData(); } + void readFile_data() { sparseFileData(); } + void mapFile_data() { sparseFileData(); } + +private: + const int blockSize; + int maxSizeBits; + + QFile largeFile; + + QVector generatedBlocks; + + int fd_; + FILE *stream_; +}; + +/* + Convenience function to hide reinterpret_cast when copying a POD directly + into a QByteArray. + */ +template +static inline void appendRaw(QByteArray &array, T data) +{ + array.append(reinterpret_cast(&data), sizeof(T)); +} + +/* + Pad array with filler up to size. On return, array.size() returns size. + */ +static inline void topUpWith(QByteArray &array, QByteArray filler, int size) +{ + Q_ASSERT(filler.size() > 0); + + for (int i = (size - array.size()) / filler.size(); i > 0; --i) + array.append(filler); + + if (array.size() < size) { + Q_ASSERT(size - array.size() < filler.size()); + array.append(filler.left(size - array.size())); + } +} + +/* + Generate a unique data block containing identifiable data. Unaligned, + overlapping and partial blocks should not compare equal. + */ +static inline QByteArray generateDataBlock(int blockSize, QString text, qint64 userBits = -1) +{ + QByteArray block; + block.reserve(blockSize); + + // Use of counter and randomBits means content of block will be dependent + // on the generation order. For (file-)systems that do not support sparse + // files, these can be removed so the test file can be reused and doesn't + // have to be generated for every run. + + static qint64 counter = 0; + + qint64 randomBits = ((qint64)qrand() << 32) + | ((qint64)qrand() & 0x00000000ffffffff); + + appendRaw(block, randomBits); + appendRaw(block, userBits); + appendRaw(block, counter); + appendRaw(block, (qint32)0xdeadbeef); + appendRaw(block, blockSize); + + QByteArray userContent = text.toUtf8(); + appendRaw(block, userContent.size()); + block.append(userContent); + appendRaw(block, (qint64)0); + + // size, so far + appendRaw(block, block.size()); + + QByteArray filler("0123456789"); + block.append(filler.right(10 - block.size() % 10)); + topUpWith(block, filler, blockSize - 2 * sizeof(qint64)); + + appendRaw(block, counter); + appendRaw(block, userBits); + appendRaw(block, randomBits); + + Q_ASSERT( block.size() >= blockSize ); + block.resize(blockSize); + + ++counter; + return block; +} + +/* + Generates data blocks the first time they are requested. Keeps copies for reuse. + */ +QByteArray const &tst_LargeFile::getDataBlock(int index, qint64 position) +{ + if (index >= generatedBlocks.size()) + generatedBlocks.resize(index + 1); + + if (generatedBlocks[index].isNull()) { + QString text = QString("Current %1-byte block (index = %2) " + "starts %3 bytes into the file '%4'.") + .arg(blockSize) + .arg(index) + .arg(position) + .arg(largeFile.fileName()); + + generatedBlocks[index] = generateDataBlock(blockSize, text, (qint64)1 << index); + } + + return generatedBlocks[index]; +} + +void tst_LargeFile::initTestCase() +{ + QVERIFY( !largeFile.exists() || largeFile.remove() ); +} + +void tst_LargeFile::cleanupTestCase() +{ + largeFile.close(); + QVERIFY( !largeFile.exists() || largeFile.remove() ); +} + +void tst_LargeFile::init() +{ + fd_ = -1; + stream_ = 0; +} + +void tst_LargeFile::cleanup() +{ + if (-1 != fd_) + QT_CLOSE(fd_); + if (stream_) + ::fclose(stream_); +} + +void tst_LargeFile::sparseFileData() +{ + QTest::addColumn("index"); + QTest::addColumn("position"); + QTest::addColumn("block"); + + QTest::newRow(QString("block[%1] @%2)") + .arg(0).arg(0) + .toLocal8Bit().constData()) + << 0 << (qint64)0 << getDataBlock(0, 0); + + // While on Linux sparse files scale well, on Windows, testing at every + // power of 2 leads to very large files. i += 4 gives us a good coverage + // without taxing too much on resources. + for (int index = 12; index <= maxSizeBits; index += 4) { + qint64 position = (qint64)1 << index; + QByteArray block = getDataBlock(index, position); + + QTest::newRow( + QString("block[%1] @%2)") + .arg(index).arg(position) + .toLocal8Bit().constData()) + << index << position << block; + } +} + +void tst_LargeFile::createSparseFile() +{ +#if defined(Q_OS_WIN) + // On Windows platforms, we must explicitly set the file to be sparse, + // so disk space is not allocated for the full file when writing to it. + HANDLE handle = ::CreateFileA(largeFile.fileName().toLocal8Bit().constData(), + GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0); + QVERIFY( INVALID_HANDLE_VALUE != handle ); + + DWORD bytes; + if (!::DeviceIoControl(handle, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, + &bytes, NULL)) { + QWARN("Unable to set test file as sparse. " + "Limiting test file to 16MiB."); + maxSizeBits = 24; + } + + int fd = ::_open_osfhandle((intptr_t)handle, 0); + QVERIFY( -1 != fd ); + QVERIFY( largeFile.open(fd, QIODevice::WriteOnly) ); +#else // !Q_OS_WIN + QVERIFY( largeFile.open(QIODevice::WriteOnly) ); +#endif +} + +void tst_LargeFile::closeSparseFile() +{ +#if defined(Q_OS_WIN) + int fd = largeFile.handle(); +#endif + + largeFile.close(); + +#if defined(Q_OS_WIN) + if (-1 != fd) + ::_close(fd); +#endif +} + +void tst_LargeFile::fillFileSparsely() +{ + QFETCH( qint64, position ); + QFETCH( QByteArray, block ); + QCOMPARE( block.size(), blockSize ); + + QVERIFY( largeFile.seek(position) ); + QCOMPARE( largeFile.pos(), position ); + + QCOMPARE( largeFile.write(block), (qint64)blockSize ); + QCOMPARE( largeFile.pos(), position + blockSize ); + QVERIFY( largeFile.flush() ); +} + +void tst_LargeFile::fileCreated() +{ + QFileInfo info(largeFile); + + QVERIFY( info.exists() ); + QVERIFY( info.isFile() ); + QVERIFY( info.size() >= ((qint64)1 << maxSizeBits) + blockSize ); +} + +void tst_LargeFile::filePositioning() +{ + QFETCH( qint64, position ); + + QFile file(largeFile.fileName()); + QVERIFY( file.open(QIODevice::ReadOnly) ); + + QVERIFY( file.seek(position) ); + QCOMPARE( file.pos(), position ); +} + +void tst_LargeFile::fdPositioning() +{ + QFETCH( qint64, position ); + + fd_ = QT_OPEN(largeFile.fileName().toLocal8Bit().constData(), + QT_OPEN_RDONLY | QT_OPEN_LARGEFILE); + QVERIFY( -1 != fd_ ); + + QFile file; + QVERIFY( file.open(fd_, QIODevice::ReadOnly) ); + QCOMPARE( file.pos(), (qint64)0 ); + QVERIFY( file.seek(position) ); + QCOMPARE( file.pos(), position ); + + file.close(); + + QCOMPARE( QT_LSEEK(fd_, QT_OFF_T(0), SEEK_SET), QT_OFF_T(0) ); + QCOMPARE( QT_LSEEK(fd_, QT_OFF_T(position), SEEK_SET), QT_OFF_T(position) ); + + QVERIFY( file.open(fd_, QIODevice::ReadOnly) ); + QCOMPARE( QT_LSEEK(fd_, QT_OFF_T(0), SEEK_CUR), QT_OFF_T(position) ); + QCOMPARE( file.pos(), position ); + QVERIFY( file.seek(0) ); + QCOMPARE( file.pos(), (qint64)0 ); + + file.close(); + + QVERIFY( !QT_CLOSE(fd_) ); + fd_ = -1; +} + +void tst_LargeFile::streamPositioning() +{ + QFETCH( qint64, position ); + + stream_ = QT_FOPEN(largeFile.fileName().toLocal8Bit().constData(), "rb"); + QVERIFY( 0 != stream_ ); + + QFile file; + QVERIFY( file.open(stream_, QIODevice::ReadOnly) ); + QCOMPARE( file.pos(), (qint64)0 ); + QVERIFY( file.seek(position) ); + QCOMPARE( file.pos(), position ); + + file.close(); + + QVERIFY( !QT_FSEEK(stream_, QT_OFF_T(0), SEEK_SET) ); + QCOMPARE( QT_FTELL(stream_), QT_OFF_T(0) ); + QVERIFY( !QT_FSEEK(stream_, QT_OFF_T(position), SEEK_SET) ); + QCOMPARE( QT_FTELL(stream_), QT_OFF_T(position) ); + + QVERIFY( file.open(stream_, QIODevice::ReadOnly) ); + QCOMPARE( QT_FTELL(stream_), QT_OFF_T(position) ); + QCOMPARE( file.pos(), position ); + QVERIFY( file.seek(0) ); + QCOMPARE( file.pos(), (qint64)0 ); + + file.close(); + + QVERIFY( !::fclose(stream_) ); + stream_ = 0; +} + +void tst_LargeFile::openFileForReading() +{ + QVERIFY( largeFile.open(QIODevice::ReadOnly) ); +} + +void tst_LargeFile::readFile() +{ + QFETCH( qint64, position ); + QFETCH( QByteArray, block ); + QCOMPARE( block.size(), blockSize ); + + QVERIFY( largeFile.size() >= position + blockSize ); + + QVERIFY( largeFile.seek(position) ); + QCOMPARE( largeFile.pos(), position ); + + QCOMPARE( largeFile.read(blockSize), block ); + QCOMPARE( largeFile.pos(), position + blockSize ); +} + +void tst_LargeFile::mapFile() +{ + QFETCH( qint64, position ); + QFETCH( QByteArray, block ); + QCOMPARE( block.size(), blockSize ); + + // Keep full block mapped to facilitate OS and/or internal reuse by Qt. + uchar *baseAddress = largeFile.map(position, blockSize); + QVERIFY( baseAddress ); + QVERIFY( qEqual(block.begin(), block.end(), reinterpret_cast(baseAddress)) ); + + for (int offset = 1; offset < blockSize; ++offset) { + uchar *address = largeFile.map(position + offset, blockSize - offset); + + QVERIFY( address ); + if ( !qEqual(block.begin() + offset, block.end(), reinterpret_cast(address)) ) { + qDebug() << "Expected:" << block.toHex(); + qDebug() << "Actual :" << QByteArray(reinterpret_cast(address), blockSize).toHex(); + QVERIFY(false); + } + + QVERIFY( largeFile.unmap( address ) ); + } + + QVERIFY( largeFile.unmap( baseAddress ) ); +} + +void tst_LargeFile::mapOffsetOverflow() +{ + // Out-of-range mappings should fail, and not silently clip the offset + for (int i = 50; i < 63; ++i) { + uchar *address = 0; + + address = largeFile.map(((qint64)1 << i), blockSize); + QVERIFY( !address ); + + address = largeFile.map(((qint64)1 << i) + blockSize, blockSize); + QVERIFY( !address ); + } +} + +QTEST_APPLESS_MAIN(tst_LargeFile) +#include "tst_largefile.moc" + diff --git a/tests/auto/qfile/qfile.pro b/tests/auto/qfile/qfile.pro index eebfcda..f70f750 100644 --- a/tests/auto/qfile/qfile.pro +++ b/tests/auto/qfile/qfile.pro @@ -5,5 +5,5 @@ wince*:{ SUBDIRS = test stdinprocess } - +SUBDIRS += largefile -- cgit v0.12 From d5b4afa7b63bb5e0d6afb3491e5fd62e7bf2e890 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 20 Oct 2009 17:50:11 +0100 Subject: When creating a Symbian WId for a visible widget, make the control visible after activating the window. This change was required in order to be able to run the test case for the below task; however, it is more generally required. Without it, the contents of the descendents of this widget will not be visible, until they are explicitly hidden and then re-shown. Task-number: QTBUG-4787 Reviewed-by: axis --- src/gui/kernel/qwidget_s60.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index abf5ba5..2cc3d3f 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -434,8 +434,10 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de drawableWindow->PointerFilter(EPointerFilterEnterExit | EPointerFilterMove | EPointerFilterDrag, 0); - if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) + if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) { activateSymbianWindow(control.data()); + control->MakeVisible(true); + } // We wait until the control is fully constructed before calling setWinId, because // this generates a WinIdChanged event. -- cgit v0.12 From ffb1006aaf1ee03ff28864d0165ddf0fddb759d7 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 21 Oct 2009 15:41:21 +0100 Subject: Video screen region is updated in response to ancestors of video widget being moved. Because QWidget::moveEvent is only called when a widget moves relative to its parent, a widget's absolute screen position may change without it receiving a moveEvent (for example, as a result of its parent being moved). The MMF video playback API on Symbian v9.4 requires, in addition to a window handle, an absolute screen rectangle. Changes in the video widget's absolute screen position therefore need to be propagated into the MMF. This change introduces a new object, AncestorMoveMonitor, which installs an event filter on the QCoreApplication instance. A VideoOutput object registers with the AncestorMoveMonitor, which listens on its behalf for MoveEvents and ParentChangeEvents directed at any of the ancestors of the VideoOutput. MoveEvents trigger a callback to the VideoOutput instance, which then notifies the MMF of the new screen rectangle. ParentChangeEvents cause the AncestorMoveMonitor to update the ancestor list associated with the target VideoOutput instance. The video position now tracks that of the associated widget, but there are two problems which require further investigation: 1. The video window lags behind. This may be an unavoidable consequence of the fact that setting a new screen rectangle causes the MMF to tear down its DSA session and start a new one; this is known to block the window server and take some time to complete. 2. Artifacts are visible around the edges of the moving video widget. Task-number: QTBUG-4787 Reviewed-by: Frans Englich --- src/3rdparty/phonon/mmf/ancestormovemonitor.cpp | 175 ++++++++++++++++++++++++ src/3rdparty/phonon/mmf/ancestormovemonitor.h | 95 +++++++++++++ src/3rdparty/phonon/mmf/backend.cpp | 7 +- src/3rdparty/phonon/mmf/backend.h | 7 + src/3rdparty/phonon/mmf/videooutput.cpp | 30 +++- src/3rdparty/phonon/mmf/videooutput.h | 15 +- src/3rdparty/phonon/mmf/videowidget.cpp | 5 +- src/3rdparty/phonon/mmf/videowidget.h | 3 +- src/plugins/phonon/mmf/plugin/plugin.pro | 2 + 9 files changed, 328 insertions(+), 11 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/ancestormovemonitor.cpp create mode 100644 src/3rdparty/phonon/mmf/ancestormovemonitor.h diff --git a/src/3rdparty/phonon/mmf/ancestormovemonitor.cpp b/src/3rdparty/phonon/mmf/ancestormovemonitor.cpp new file mode 100644 index 0000000..876499c --- /dev/null +++ b/src/3rdparty/phonon/mmf/ancestormovemonitor.cpp @@ -0,0 +1,175 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include "ancestormovemonitor.h" +#include "utils.h" +#include "videooutput.h" + +#include + +QT_BEGIN_NAMESPACE + +using namespace Phonon::MMF; + +/*! \class MMF::AncestorMoveMonitor + \internal + \brief Class which installs a global event filter, and listens for move + events which may affect the absolute position of widgets registered with + the monitor + See QTBUG-4956 +*/ + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +AncestorMoveMonitor::AncestorMoveMonitor(QObject *parent) + : QObject(parent) +{ + QCoreApplication::instance()->installEventFilter(this); +} + +AncestorMoveMonitor::~AncestorMoveMonitor() +{ + QCoreApplication::instance()->removeEventFilter(this); +} + + +//----------------------------------------------------------------------------- +// Public functions +//----------------------------------------------------------------------------- + +void AncestorMoveMonitor::registerTarget(VideoOutput *target) +{ + TRACE_CONTEXT(AncestorMoveMonitor::registerTarget, EVideoInternal); + TRACE_ENTRY("target 0x%08x", target); + + // First un-register the target, in case this is being called as a result + // of re-parenting. This is not the most efficient way to update the + // target hash, but since this is not likely to be a frequent operation, + // simplicity is preferred over outright speed. In any case, re-parenting + // of the video widget leads to re-creation of native windows, which is + // likely to take far more processing than any implementation of this + // function. + unRegisterTarget(target); + + QWidget *ancestor = target->parentWidget(); + while(ancestor) { + const Hash::iterator it = m_hash.find(ancestor); + if(m_hash.end() == it) { + TargetList targetList; + targetList.append(target); + m_hash.insert(ancestor, targetList); + } else { + TargetList& targetList = it.value(); + Q_ASSERT(targetList.indexOf(target) == -1); + targetList.append(target); + } + ancestor = ancestor->parentWidget(); + } + + dump(); + + TRACE_EXIT_0(); +} + +void AncestorMoveMonitor::unRegisterTarget(VideoOutput *target) +{ + TRACE_CONTEXT(AncestorMoveMonitor::unRegisterTarget, EVideoInternal); + TRACE_ENTRY("target 0x%08x", target); + + Hash::iterator it = m_hash.begin(); + while(it != m_hash.end()) { + TargetList& targetList = it.value(); + const int index = targetList.indexOf(target); + if(index != -1) + targetList.removeAt(index); + if(targetList.count()) + ++it; + else + it = m_hash.erase(it); + } + + dump(); + + TRACE_EXIT_0(); +} + +bool AncestorMoveMonitor::eventFilter(QObject *watched, QEvent *event) +{ + TRACE_CONTEXT(AncestorMoveMonitor::eventFilter, EVideoInternal); + + if(event->type() == QEvent::Move || event->type() == QEvent::ParentChange) { + + TRACE_ENTRY("watched 0x%08x event.type %d", watched, event->type()); + + const Hash::const_iterator it = m_hash.find(watched); + if(it != m_hash.end()) { + const TargetList& targetList = it.value(); + VideoOutput* target = 0; + foreach(target, targetList) { + switch (event->type()) { + + case QEvent::Move: + // Notify the target that its ancestor has moved + target->ancestorMoved(); + break; + + case QEvent::ParentChange: + // Update ancestor list for the target + registerTarget(target); + break; + + default: + Q_ASSERT(false); + } + } + } + + TRACE_EXIT_0(); + } + + // The event is never consumed by this filter + return false; +} + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +void AncestorMoveMonitor::dump() +{ +#ifndef QT_NO_DEBUG + TRACE_CONTEXT(AncestorMoveMonitor::dump, EVideoInternal); + for(Hash::const_iterator it = m_hash.begin(); + it != m_hash.end(); ++it) { + const QObject *ancestor = it.key(); + TRACE("ancestor 0x%08x", ancestor); + const TargetList& targetList = it.value(); + VideoOutput* target = 0; + foreach(target, targetList) { + TRACE(" target 0x%08x", target); + } + } +#endif +} + + + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/ancestormovemonitor.h b/src/3rdparty/phonon/mmf/ancestormovemonitor.h new file mode 100644 index 0000000..0e681aa --- /dev/null +++ b/src/3rdparty/phonon/mmf/ancestormovemonitor.h @@ -0,0 +1,95 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_ANCESTORMOVEMONITOR_H +#define PHONON_MMF_ANCESTORMOVEMONITOR_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ +class VideoOutput; + +class AncestorMoveMonitor : public QObject +{ + Q_OBJECT + +public: + explicit AncestorMoveMonitor(QObject *parent); + ~AncestorMoveMonitor(); + + /** + * Register target widget for notification. + * + * The widget receives an ancestorMoveEvent callback when a move event + * is delivered to any of its ancestors: + * + * If the target is already registered, this function causes its + * ancestor list to be updated - therefore it should be called when + * the target receives a ParentChange event. + */ + void registerTarget(VideoOutput *target); + + /** + * Remove target from the monitor. + * + * The target will no longer receive notification when move events are + * delivered to its ancestors. + */ + void unRegisterTarget(VideoOutput *target); + +protected: + /** + * Function which receives events from the global event filter. + */ + bool eventFilter(QObject *watched, QEvent *event); + + void dump(); + +private: + /** + * List of registered target widgets which descend from a given + * ancestor. + * + * Note that the members of the list should be non-redundant; this + * invariant is checked in debug builds. Semantically, the value is + * therefore a set, however we use QList rather than QSet for + * efficiency of iteration. + */ + typedef QList TargetList; + + /** + * Map from widget on which the move event occurs, to widgets which + * descend from it and therefore need to be notified. + */ + typedef QHash Hash; + Hash m_hash; + +}; +} +} + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index f542ec9..cac27e3 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -24,6 +24,7 @@ along with this library. If not, see . #include // for TDataType #include "abstractaudioeffect.h" +#include "ancestormovemonitor.h" #include "audiooutput.h" #include "audioplayer.h" #include "backend.h" @@ -45,7 +46,9 @@ using namespace Phonon::MMF; \internal */ -Backend::Backend(QObject *parent) : QObject(parent) +Backend::Backend(QObject *parent) + : QObject(parent) + , m_ancestorMoveMonitor(new AncestorMoveMonitor(this)) { TRACE_CONTEXT(Backend::Backend, EBackend); TRACE_ENTRY_0(); @@ -87,7 +90,7 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const return EffectFactory::createAudioEffect(effect, parent); } case VideoWidgetClass: - result = new VideoWidget(qobject_cast(parent)); + result = new VideoWidget(m_ancestorMoveMonitor.data(), qobject_cast(parent)); break; default: diff --git a/src/3rdparty/phonon/mmf/backend.h b/src/3rdparty/phonon/mmf/backend.h index 1886ae6..9e3d3b3 100644 --- a/src/3rdparty/phonon/mmf/backend.h +++ b/src/3rdparty/phonon/mmf/backend.h @@ -19,8 +19,11 @@ along with this library. If not, see . #ifndef PHONON_MMF_BACKEND_H #define PHONON_MMF_BACKEND_H +#include "ancestormovemonitor.h" + #include #include +#include QT_BEGIN_NAMESPACE @@ -47,6 +50,10 @@ public: Q_SIGNALS: void objectDescriptionChanged(ObjectDescriptionType); + +private: + QScopedPointer m_ancestorMoveMonitor; + }; } } diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index f0393a7..5288b4d 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -16,6 +16,7 @@ along with this library. If not, see . */ +#include "ancestormovemonitor.h" #include "utils.h" #include "videooutput.h" #include "videooutputobserver.h" @@ -44,8 +45,10 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::VideoOutput::VideoOutput(QWidget* parent) +MMF::VideoOutput::VideoOutput + (AncestorMoveMonitor* ancestorMoveMonitor, QWidget* parent) : QWidget(parent) + , m_ancestorMoveMonitor(ancestorMoveMonitor) , m_observer(0) { TRACE_CONTEXT(VideoOutput::VideoOutput, EVideoInternal); @@ -63,6 +66,8 @@ MMF::VideoOutput::VideoOutput(QWidget* parent) // to be invisible when running on the target device. qt_widget_private(this)->extraData()->disableBlit = true; + registerForAncestorMoved(); + dump(); TRACE_EXIT_0(); @@ -73,6 +78,8 @@ MMF::VideoOutput::~VideoOutput() TRACE_CONTEXT(VideoOutput::~VideoOutput, EVideoInternal); TRACE_ENTRY_0(); + m_ancestorMoveMonitor->unRegisterTarget(this); + TRACE_EXIT_0(); } @@ -97,6 +104,15 @@ void MMF::VideoOutput::setObserver(VideoOutputObserver* observer) m_observer = observer; } +void MMF::VideoOutput::ancestorMoved() +{ + TRACE_CONTEXT(VideoOutput::ancestorMoved, EVideoInternal); + TRACE_ENTRY_0(); + + videoOutputRegionChanged(); + + TRACE_EXIT_0(); +} //----------------------------------------------------------------------------- // QWidget @@ -154,8 +170,11 @@ bool MMF::VideoOutput::event(QEvent* event) TRACE_0("WinIdChange"); videoOutputRegionChanged(); return true; - } - else + } else if (event->type() == QEvent::ParentChange) { + // Tell ancestor move monitor to update ancestor list for this widget + registerForAncestorMoved(); + return true; + } else return QWidget::event(event); } @@ -171,6 +190,11 @@ void MMF::VideoOutput::videoOutputRegionChanged() m_observer->videoOutputRegionChanged(); } +void MMF::VideoOutput::registerForAncestorMoved() +{ + m_ancestorMoveMonitor->registerTarget(this); +} + void MMF::VideoOutput::dump() const { #ifndef QT_NO_DEBUG diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h index 7bc0b52..db4d127 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -30,6 +30,7 @@ namespace Phonon { namespace MMF { +class AncestorMoveMonitor; class VideoOutputObserver; class VideoOutput : public QWidget @@ -37,12 +38,14 @@ class VideoOutput : public QWidget Q_OBJECT public: - explicit VideoOutput(QWidget* parent); + VideoOutput(AncestorMoveMonitor* ancestorMoveMonitor, QWidget* parent); ~VideoOutput(); void setFrameSize(const QSize& size); void setObserver(VideoOutputObserver* observer); + void ancestorMoved(); + protected: // Override QWidget functions QSize sizeHint() const; @@ -55,11 +58,17 @@ private: void dump() const; void videoOutputRegionChanged(); + void registerForAncestorMoved(); + private: - QSize m_frameSize; + // Not owned + AncestorMoveMonitor* m_ancestorMoveMonitor; // Not owned - VideoOutputObserver* m_observer; + VideoOutputObserver* m_observer; + + QSize m_frameSize; + }; } } diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index 8a5c9ff..7d7abf1 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -49,9 +49,10 @@ static const qreal DefaultSaturation = 1.0; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::VideoWidget::VideoWidget(QWidget* parent) +MMF::VideoWidget::VideoWidget + (AncestorMoveMonitor* ancestorMoveMonitor, QWidget* parent) : MediaNode(parent) - , m_widget(new VideoOutput(parent)) + , m_widget(new VideoOutput(ancestorMoveMonitor, parent)) , m_aspectRatio(DefaultAspectRatio) , m_brightness(DefaultBrightness) , m_scaleMode(DefaultScaleMode) diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h index 970f749..318dfae 100644 --- a/src/3rdparty/phonon/mmf/videowidget.h +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -31,6 +31,7 @@ namespace Phonon { namespace MMF { +class AncestorMoveMonitor; class VideoOutput; class VideoWidget : public MediaNode @@ -40,7 +41,7 @@ class VideoWidget : public MediaNode Q_INTERFACES(Phonon::VideoWidgetInterface) public: - VideoWidget(QWidget* parent); + VideoWidget(AncestorMoveMonitor* ancestorMoveMonitor, QWidget* parent); ~VideoWidget(); // VideoWidgetInterface diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro index eb7fd27..793c307 100644 --- a/src/plugins/phonon/mmf/plugin/plugin.pro +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -26,6 +26,7 @@ HEADERS += \ $$PHONON_MMF_DIR/abstractaudioeffect.h \ $$PHONON_MMF_DIR/abstractmediaplayer.h \ $$PHONON_MMF_DIR/abstractplayer.h \ + $$PHONON_MMF_DIR/ancestormovemonitor.h \ $$PHONON_MMF_DIR/audiooutput.h \ $$PHONON_MMF_DIR/audioequalizer.h \ $$PHONON_MMF_DIR/audioplayer.h \ @@ -47,6 +48,7 @@ SOURCES += \ $$PHONON_MMF_DIR/abstractaudioeffect.cpp \ $$PHONON_MMF_DIR/abstractmediaplayer.cpp \ $$PHONON_MMF_DIR/abstractplayer.cpp \ + $$PHONON_MMF_DIR/ancestormovemonitor.cpp \ $$PHONON_MMF_DIR/audiooutput.cpp \ $$PHONON_MMF_DIR/audioequalizer.cpp \ $$PHONON_MMF_DIR/audioplayer.cpp \ -- cgit v0.12 From e4954731369d9b339a79ec9fe737d70ef6dc4755 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 22 Oct 2009 15:38:25 +0200 Subject: In Vista style, renaming Animation, Transition and Pulse There is a name clash, so we prefixed them with QWindowsVista Reviewed-by: Benjamin Poulain --- src/gui/styles/qwindowsvistastyle.cpp | 50 +++++++++++++++++------------------ src/gui/styles/qwindowsvistastyle_p.h | 24 ++++++++--------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp index 6cb8b40..aafd087 100644 --- a/src/gui/styles/qwindowsvistastyle.cpp +++ b/src/gui/styles/qwindowsvistastyle.cpp @@ -159,7 +159,7 @@ QWindowsVistaStyle::QWindowsVistaStyle() } //convert Qt state flags to uxtheme button states -int buttonStateId(int flags, int partId) +static int buttonStateId(int flags, int partId) { int stateId = 0; if (partId == BP_RADIOBUTTON || partId == BP_CHECKBOX) { @@ -190,7 +190,7 @@ int buttonStateId(int flags, int partId) return stateId; } -void Animation::paint(QPainter *painter, const QStyleOption *option) +void QWindowsVistaAnimation::paint(QPainter *painter, const QStyleOption *option) { Q_UNUSED(option); Q_UNUSED(painter); @@ -205,7 +205,7 @@ void Animation::paint(QPainter *painter, const QStyleOption *option) + ((1-alpha)*_secondaryImage) */ -void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) { +void QWindowsVistaAnimation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) { if (_secondaryImage.isNull() || _primaryImage.isNull()) return; @@ -251,7 +251,7 @@ void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) { initial and final state of the transition, depending on the time difference between _startTime and current time. */ -void Transition::paint(QPainter *painter, const QStyleOption *option) +void QWindowsVistaTransition::paint(QPainter *painter, const QStyleOption *option) { float alpha = 1.0; if (_duration > 0) { @@ -278,7 +278,7 @@ void Transition::paint(QPainter *painter, const QStyleOption *option) secondary pulse images depending on the time difference between _startTime and current time. */ -void Pulse::paint(QPainter *painter, const QStyleOption *option) +void QWindowsVistaPulse::paint(QPainter *painter, const QStyleOption *option) { float alpha = 1.0; if (_duration > 0) { @@ -393,8 +393,8 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt startImage.fill(0); QPainter startPainter(&startImage); - Animation *anim = d->widgetAnimation(widget); - Transition *t = new Transition; + QWindowsVistaAnimation *anim = d->widgetAnimation(widget); + QWindowsVistaTransition *t = new QWindowsVistaTransition; t->setWidget(w); // If we have a running animation on the widget already, we will use that to paint the initial @@ -531,7 +531,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt case PE_IndicatorCheckBox: case PE_IndicatorRadioButton: { - if (Animation *a = d->widgetAnimation(widget)) { + if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) { a->paint(painter, option); } else { QWindowsXPStyle::drawPrimitive(element, option, painter, widget); @@ -644,7 +644,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt break; case PE_FrameLineEdit: - if (Animation *anim = d->widgetAnimation(widget)) { + if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) { anim->paint(painter, option); } else { QPainter *p = painter; @@ -929,13 +929,13 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (doTransition) { QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); - Animation *anim = d->widgetAnimation(widget); + QWindowsVistaAnimation *anim = d->widgetAnimation(widget); QStyleOptionButton opt = *button; opt.state = (QStyle::State)oldState; startImage.fill(0); - Transition *t = new Transition; + QWindowsVistaTransition *t = new QWindowsVistaTransition; t->setWidget(w); QPainter startPainter(&startImage); @@ -972,7 +972,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (const QStyleOptionButton *btn = qstyleoption_cast(option)) { - if (Animation *anim = d->widgetAnimation(widget)) { + if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) { anim->paint(painter, option); } else { name = QLatin1String("BUTTON"); @@ -999,14 +999,14 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption !(state & (State_Sunken | State_On)) && !(state & State_MouseOver) && (state & State_Enabled) && (state & State_Active)) { - Animation *anim = d->widgetAnimation(widget); + QWindowsVistaAnimation *anim = d->widgetAnimation(widget); if (!anim && widget) { QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); startImage.fill(0); QImage alternateImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); alternateImage.fill(0); - Pulse *pulse = new Pulse; + QWindowsVistaPulse *pulse = new QWindowsVistaPulse; pulse->setWidget(const_cast(widget)); QPainter startPainter(&startImage); @@ -1079,7 +1079,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (const QProgressBar *progressbar = qobject_cast(widget)) { if (((progressbar->value() > 0 && d->transitionsEnabled()) || isIndeterminate)) { if (!d->widgetAnimation(progressbar) && progressbar->value() < progressbar->maximum()) { - Animation *a = new Animation; + QWindowsVistaAnimation *a = new QWindowsVistaAnimation; a->setWidget(const_cast(widget)); a->setStartTime(QTime::currentTime()); d->startAnimation(a); @@ -1095,7 +1095,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QTime current = QTime::currentTime(); if (isIndeterminate) { - if (Animation *a = d->widgetAnimation(widget)) { + if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) { int glowSize = 120; int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width()); int animOffset = a->startTime().msecsTo(current) / 4; @@ -1165,7 +1165,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption } d->drawBackground(theme); - if (Animation *a = d->widgetAnimation(widget)) { + if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) { int glowSize = 140; int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width()); int animOffset = a->startTime().msecsTo(current) / 4; @@ -1603,8 +1603,8 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle if (doTransition) { QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); - Animation *anim = d->widgetAnimation(widget); - Transition *t = new Transition; + QWindowsVistaAnimation *anim = d->widgetAnimation(widget); + QWindowsVistaTransition *t = new QWindowsVistaTransition; t->setWidget(w); if (!anim) { if (const QStyleOptionComboBox *combo = qstyleoption_cast(option)) { @@ -1651,7 +1651,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle t->setDuration(500); } - if (Animation *anim = d->widgetAnimation(widget)) { + if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) { anim->paint(painter, option); return; } @@ -2533,7 +2533,7 @@ void QWindowsVistaStylePrivate::timerEvent() !animations[i]->running() || !QWindowsVistaStylePrivate::useVista()) { - Animation *a = animations.takeAt(i); + QWindowsVistaAnimation *a = animations.takeAt(i); delete a; } } @@ -2546,14 +2546,14 @@ void QWindowsVistaStylePrivate::stopAnimation(const QWidget *w) { for (int i = animations.size() - 1 ; i >= 0 ; --i) { if (animations[i]->widget() == w) { - Animation *a = animations.takeAt(i); + QWindowsVistaAnimation *a = animations.takeAt(i); delete a; break; } } } -void QWindowsVistaStylePrivate::startAnimation(Animation *t) +void QWindowsVistaStylePrivate::startAnimation(QWindowsVistaAnimation *t) { Q_Q(QWindowsVistaStyle); stopAnimation(t->widget()); @@ -2575,11 +2575,11 @@ bool QWindowsVistaStylePrivate::transitionsEnabled() const } -Animation * QWindowsVistaStylePrivate::widgetAnimation(const QWidget *widget) const +QWindowsVistaAnimation * QWindowsVistaStylePrivate::widgetAnimation(const QWidget *widget) const { if (!widget) return 0; - foreach (Animation *a, animations) { + foreach (QWindowsVistaAnimation *a, animations) { if (a->widget() == widget) return a; } diff --git a/src/gui/styles/qwindowsvistastyle_p.h b/src/gui/styles/qwindowsvistastyle_p.h index e9bbb77..04823c1 100644 --- a/src/gui/styles/qwindowsvistastyle_p.h +++ b/src/gui/styles/qwindowsvistastyle_p.h @@ -136,11 +136,11 @@ QT_BEGIN_NAMESPACE #define TDLG_SECONDARYPANEL 8 #endif -class Animation +class QWindowsVistaAnimation { public : - Animation() : _running(true) { } - virtual ~Animation() { } + QWindowsVistaAnimation() : _running(true) { } + virtual ~QWindowsVistaAnimation() { } QWidget * widget() const { return _widget; } bool running() const { return _running; } const QTime &startTime() const { return _startTime; } @@ -161,11 +161,11 @@ protected: // Handles state transition animations -class Transition : public Animation +class QWindowsVistaTransition : public QWindowsVistaAnimation { public : - Transition() : Animation() {} - virtual ~Transition() { } + QWindowsVistaTransition() : QWindowsVistaAnimation() {} + virtual ~QWindowsVistaTransition() { } void setDuration(int duration) { _duration = duration; } void setStartImage(const QImage &image) { _primaryImage = image; } void setEndImage(const QImage &image) { _secondaryImage = image; } @@ -176,11 +176,11 @@ public : // Handles pulse animations (default buttons) -class Pulse: public Animation +class QWindowsVistaPulse: public QWindowsVistaAnimation { public : - Pulse() : Animation() {} - virtual ~Pulse() { } + QWindowsVistaPulse() : QWindowsVistaAnimation() {} + virtual ~QWindowsVistaPulse() { } void setDuration(int duration) { _duration = duration; } void setPrimaryImage(const QImage &image) { _primaryImage = image; } void setAlternateImage(const QImage &image) { _secondaryImage = image; } @@ -199,15 +199,15 @@ public: ~QWindowsVistaStylePrivate(); static bool resolveSymbols(); static inline bool useVista(); - void startAnimation(Animation *); + void startAnimation(QWindowsVistaAnimation *); void stopAnimation(const QWidget *); - Animation* widgetAnimation(const QWidget *) const; + QWindowsVistaAnimation* widgetAnimation(const QWidget *) const; void timerEvent(); bool transitionsEnabled() const; QWidget *treeViewHelper(); private: - QList animations; + QList animations; QBasicTimer animationTimer; QWidget *m_treeViewHelper; }; -- cgit v0.12 From 63b8a706c57ed292d82fc16a446daa543cf12a38 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 22 Oct 2009 15:21:29 +0200 Subject: stabilize QListView test --- tests/auto/qlistview/tst_qlistview.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 6e211ae..3968529 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -1132,6 +1132,7 @@ void tst_QListView::selection() #endif v.show(); + QTest::qWaitForWindowShown(&v); QApplication::processEvents(); v.setSelection(selectionRect, QItemSelectionModel::ClearAndSelect); @@ -1184,6 +1185,7 @@ void tst_QListView::scrollTo() lv.setModel(&model); lv.setFixedSize(100, 200); lv.show(); + QTest::qWaitForWindowShown(&lv); //by default, the list view scrolls per item and has no wrapping QModelIndex index = model.index(6,0); @@ -1782,12 +1784,13 @@ void tst_QListView::task262152_setModelColumnNavigate() view.setModelColumn(1); view.show(); - QTest::qWait(100); + QTest::qWaitForWindowShown(&view); + QTest::qWait(10); QTest::keyClick(&view, Qt::Key_Down); - QTest::qWait(100); + QTest::qWait(10); QCOMPARE(view.currentIndex(), model.index(1,1)); QTest::keyClick(&view, Qt::Key_Down); - QTest::qWait(100); + QTest::qWait(10); QCOMPARE(view.currentIndex(), model.index(2,1)); } -- cgit v0.12 From 44aa15a08dd8e7e1ea428fd8868a8e531f5ba4d9 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 22 Oct 2009 16:04:34 +0200 Subject: Autotest fix for parallel animation group On macos (as on symbian), we need to leave some time for the application to become responsive. --- .../tst_qparallelanimationgroup.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index 8578d36..8d937e9 100644 --- a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -56,8 +56,7 @@ public: virtual ~tst_QParallelAnimationGroup(); public Q_SLOTS: - void init(); - void cleanup(); + void initTestCase(); private slots: void construction(); @@ -86,13 +85,13 @@ tst_QParallelAnimationGroup::~tst_QParallelAnimationGroup() { } -void tst_QParallelAnimationGroup::init() +void tst_QParallelAnimationGroup::initTestCase() { qRegisterMetaType("QAbstractAnimation::State"); -} - -void tst_QParallelAnimationGroup::cleanup() -{ +#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAC) || defined(Q_WS_WINCE) + // give the Symbian and mac app start event queue time to clear + QTest::qWait(1000); +#endif } void tst_QParallelAnimationGroup::construction() @@ -486,10 +485,6 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup() void tst_QParallelAnimationGroup::deleteChildrenWithRunningGroup() { -#if defined(Q_OS_SYMBIAN) - // give the Symbian app start event queue time to clear - QTest::qWait(1000); -#endif // test if children can be activated when their group is stopped QParallelAnimationGroup group; -- cgit v0.12 From 82caa7b3f97c6cda0ebceb477856442653a83699 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 22 Oct 2009 18:11:19 +0200 Subject: Warning -- Reviewed-by:TrustMe --- src/gui/graphicsview/qgraphicsproxywidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp index 64c51ad..e9173a9 100644 --- a/src/gui/graphicsview/qgraphicsproxywidget.cpp +++ b/src/gui/graphicsview/qgraphicsproxywidget.cpp @@ -397,7 +397,7 @@ QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) do { if (child->isEnabled() && child->isVisibleTo(widget) - && (child->focusPolicy() & focus_flag == focus_flag) + && ((child->focusPolicy() & focus_flag) == focus_flag) && !(child->d_func()->extra && child->d_func()->extra->focus_proxy)) { return child; } -- cgit v0.12 From a5f7f88932c6911fb65552d65d62efdcf496beec Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 22 Oct 2009 18:11:34 +0200 Subject: Fix crash in QGraphicsView BSP discovered in Amarok. Basically some items were not properly remove in the BSP which means that if you delete one of items, the BSP tree may contain dangling pointers. The problem was in removeItemHelper in QGraphicsScene were the child were removed after reparenting to 0 the topmost parent. The sceneBoundingRect for children was invalid which means that we were removing them in the wrong position inside the BSP. Reparenting to 0 means that the sceneBoundingRect will be the boundingRect but wasn't the case before (for the topmost parent). Reviewed-by:bnilsen --- src/gui/graphicsview/qgraphicsscene.cpp | 14 +++--- .../tst_qgraphicssceneindex.cpp | 58 ++++++++++++++++++++++ 2 files changed, 66 insertions(+), 6 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index a624b10..03c8a97 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -518,6 +518,14 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) item->d_func()->scene = 0; + //We need to remove all children first because they might use their parent + //attributes (e.g. sceneTransform). + if (!item->d_ptr->inDestructor) { + // Remove all children recursively + for (int i = 0; i < item->d_ptr->children.size(); ++i) + q->removeItem(item->d_ptr->children.at(i)); + } + // Unregister focus proxy. item->d_ptr->resetFocusProxy(); @@ -564,12 +572,6 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) ++iterator; } - if (!item->d_ptr->inDestructor) { - // Remove all children recursively - for (int i = 0; i < item->d_ptr->children.size(); ++i) - q->removeItem(item->d_ptr->children.at(i)); - } - if (item->isPanel() && item->isVisible() && item->panelModality() != QGraphicsItem::NonModal) leaveModal(item); diff --git a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp index 1109e5e..9dfd486 100644 --- a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp +++ b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp @@ -66,6 +66,7 @@ private slots: void movingItems(); void connectedToSceneRectChanged(); void items(); + void removeItems(); void clear(); private: @@ -268,6 +269,63 @@ void tst_QGraphicsSceneIndex::items() QCOMPARE(scene.items().size(), 3); } +class RectWidget : public QGraphicsWidget +{ + Q_OBJECT +public: + RectWidget(QGraphicsItem *parent = 0) : QGraphicsWidget(parent) + { + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + { + painter->setBrush(brush); + painter->drawRect(boundingRect()); + } +public: + QBrush brush; +}; + +void tst_QGraphicsSceneIndex::removeItems() +{ + QGraphicsScene scene; + + RectWidget *parent = new RectWidget; + parent->brush = QBrush(QColor(Qt::magenta)); + parent->setGeometry(250, 250, 400, 400); + + RectWidget *widget = new RectWidget(parent); + widget->brush = QBrush(QColor(Qt::blue)); + widget->setGeometry(10, 10, 200, 200); + + RectWidget *widgetChild1 = new RectWidget(widget); + widgetChild1->brush = QBrush(QColor(Qt::green)); + widgetChild1->setGeometry(20, 20, 100, 100); + + RectWidget *widgetChild2 = new RectWidget(widgetChild1); + widgetChild2->brush = QBrush(QColor(Qt::yellow)); + widgetChild2->setGeometry(25, 25, 50, 50); + + scene.addItem(parent); + + QGraphicsView view(&scene); + view.resize(600, 600); + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + + QApplication::processEvents(); + + scene.removeItem(widgetChild1); + + delete widgetChild1; + + //We move the parent + scene.items(295, 295, 50, 50); + + //This should not crash +} + void tst_QGraphicsSceneIndex::clear() { class MyItem : public QGraphicsItem -- cgit v0.12 From d576d770b9b8251f1b5b4808a84045af33e62dba Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 23 Oct 2009 09:30:26 +0200 Subject: Removed pixelize, bloom and grayscale filter This is new API and we don't want to add several items that are not strictly needed. This is a new set of features and we can grow them once we have more input from users on what is needed. The Bloom filter was added based on input from designers, but is not implemented according to how designers think of blook, so the effect doesn't meet the requirements. The Grayscale filter is functionally a duplicate of the colorize filter and is therefore not needed. The Pixelize filter has no genuine usecase. Reviewed-by: Samuel --- src/gui/effects/qgraphicseffect.cpp | 453 +----------------------------------- src/gui/effects/qgraphicseffect.h | 88 ------- src/gui/effects/qgraphicseffect_p.h | 37 --- 3 files changed, 4 insertions(+), 574 deletions(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 96d35b0..e25b40b 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -65,9 +65,6 @@ \o QGraphicsDropShadowEffect - renders a dropshadow behind the item \o QGraphicsColorizeEffect - renders the item in shades of any given color \o QGraphicsOpacityEffect - renders the item with an opacity - \o QGraphicsPixelizeEffect - pixelizes the item with any pixel size - \o QGraphicsGrayscaleEffect - renders the item in shades of gray - \o QGraphicsBloomEffect - applies a blooming / glowing effect \endlist \img graphicseffect-effects.png @@ -458,96 +455,6 @@ void QGraphicsEffect::sourceChanged(ChangeFlags flags) } /*! - \class QGraphicsGrayscaleEffect - \brief The QGraphicsGrayscaleEffect class provides a grayscale effect. - \since 4.6 - - A grayscale effect renders the source in shades of gray. - - \img graphicseffect-grayscale.png - - \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsPixelizeEffect, - QGraphicsColorizeEffect, QGraphicsOpacityEffect -*/ - -/*! - Constructs a new QGraphicsGrayscale instance. - The \a parent parameter is passed to QGraphicsEffect's constructor. -*/ -QGraphicsGrayscaleEffect::QGraphicsGrayscaleEffect(QObject *parent) - : QGraphicsEffect(*new QGraphicsGrayscaleEffectPrivate, parent) -{ -} - -/*! - Destroys the effect. -*/ -QGraphicsGrayscaleEffect::~QGraphicsGrayscaleEffect() -{ -} - - -/*! - \property QGraphicsGrayscaleEffect::strength - \brief the strength of the effect. - - By default, the strength is 1.0. - A strength 0.0 equals to no effect, while 1.0 means full grayscale. -*/ -qreal QGraphicsGrayscaleEffect::strength() const -{ - Q_D(const QGraphicsGrayscaleEffect); - return d->filter->strength(); -} - -void QGraphicsGrayscaleEffect::setStrength(qreal strength) -{ - Q_D(QGraphicsGrayscaleEffect); - if (qFuzzyCompare(d->filter->strength(), strength)) - return; - - d->filter->setStrength(strength); - d->opaque = !qFuzzyIsNull(strength); - update(); - emit strengthChanged(strength); -} - -/*! \fn void QGraphicsGrayscaleEffect::strengthChanged(qreal strength) - This signal is emitted whenever setStrength() changes the grayscale - strength property. \a strength contains the new strength value of - the grayscale effect. - */ - -/*! - \reimp -*/ -void QGraphicsGrayscaleEffect::draw(QPainter *painter, QGraphicsEffectSource *source) -{ - Q_D(QGraphicsGrayscaleEffect); - - if (!d->opaque) { - source->draw(painter); - return; - } - - QPoint offset; - if (source->isPixmap()) { - // No point in drawing in device coordinates (pixmap will be scaled anyways). - const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset); - d->filter->draw(painter, offset, pixmap); - return; - } - - // Draw pixmap in device coordinates to avoid pixmap scaling; - const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); - QTransform restoreTransform = painter->worldTransform(); - painter->setWorldTransform(QTransform()); - d->filter->draw(painter, offset, pixmap); - painter->setWorldTransform(restoreTransform); - -} - -/*! \class QGraphicsColorizeEffect \brief The QGraphicsColorizeEffect class provides a colorize effect. \since 4.6 @@ -559,8 +466,7 @@ void QGraphicsGrayscaleEffect::draw(QPainter *painter, QGraphicsEffectSource *so \img graphicseffect-colorize.png - \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsPixelizeEffect, - QGraphicsGrayscaleEffect, QGraphicsOpacityEffect + \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsOpacityEffect */ /*! @@ -669,126 +575,6 @@ void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *sou } /*! - \class QGraphicsPixelizeEffect - \brief The QGraphicsPixelizeEffect class provides a pixelize effect. - \since 4.6 - - A pixelize effect renders the source in lower resolution. This effect is - useful for reducing details, like censorship. The resolution can be - modified using the setPixelSize() function. - - By default, the pixel size is 3. - - \img graphicseffect-pixelize.png - - \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsGrayscaleEffect, - QGraphicsColorizeEffect, QGraphicsOpacityEffect -*/ - -/*! - Constructs a new QGraphicsPixelizeEffect instance. - The \a parent parameter is passed to QGraphicsEffect's constructor. -*/ -QGraphicsPixelizeEffect::QGraphicsPixelizeEffect(QObject *parent) - : QGraphicsEffect(*new QGraphicsPixelizeEffectPrivate, parent) -{ -} - -/*! - Destroys the effect. -*/ -QGraphicsPixelizeEffect::~QGraphicsPixelizeEffect() -{ -} - -/*! - \property QGraphicsPixelizeEffect::pixelSize - \brief the size of a pixel in the effect. - - Setting the pixel size to 2 means two pixels in the source will be used to - represent one pixel. Using a bigger size results in lower resolution. - - By default, the pixel size is 3. -*/ -int QGraphicsPixelizeEffect::pixelSize() const -{ - Q_D(const QGraphicsPixelizeEffect); - return d->pixelSize; -} - -void QGraphicsPixelizeEffect::setPixelSize(int size) -{ - Q_D(QGraphicsPixelizeEffect); - if (d->pixelSize == size) - return; - - d->pixelSize = size; - update(); - emit pixelSizeChanged(size); -} - -/*! - \fn void QGraphicsPixelizeEffect::pixelSizeChanged(int size) - - This signal is emitted whenever the effect's pixel size changes. - The \a size parameter holds the effect's new pixel size. -*/ - -static inline void pixelize(QImage *image, int pixelSize) -{ - Q_ASSERT(pixelSize > 0); - Q_ASSERT(image); - int width = image->width(); - int height = image->height(); - for (int y = 0; y < height; y += pixelSize) { - int ys = qMin(height - 1, y + pixelSize / 2); - QRgb *sbuf = reinterpret_cast(image->scanLine(ys)); - for (int x = 0; x < width; x += pixelSize) { - int xs = qMin(width - 1, x + pixelSize / 2); - QRgb color = sbuf[xs]; - for (int yi = 0; yi < qMin(pixelSize, height - y); ++yi) { - QRgb *buf = reinterpret_cast(image->scanLine(y + yi)); - for (int xi = 0; xi < qMin(pixelSize, width - x); ++xi) - buf[x + xi] = color; - } - } - } -} - -/*! - \reimp -*/ -void QGraphicsPixelizeEffect::draw(QPainter *painter, QGraphicsEffectSource *source) -{ - Q_D(QGraphicsPixelizeEffect); - if (d->pixelSize <= 0) { - source->draw(painter); - return; - } - - QPoint offset; - if (source->isPixmap()) { - const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset); - QImage image = pixmap.toImage().convertToFormat(QImage::Format_ARGB32); - pixelize(&image, d->pixelSize); - painter->drawImage(offset, image); - return; - } - - // Draw pixmap in device coordinates to avoid pixmap scaling. - const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); - - // pixelize routine - QImage image = pixmap.toImage().convertToFormat(QImage::Format_ARGB32); - pixelize(&image, d->pixelSize); - - QTransform restoreTransform = painter->worldTransform(); - painter->setWorldTransform(QTransform()); - painter->drawImage(offset, image); - painter->setWorldTransform(restoreTransform); -} - -/*! \class QGraphicsBlurEffect \brief The QGraphicsBlurEffect class provides a blur effect. \since 4.6 @@ -802,8 +588,7 @@ void QGraphicsPixelizeEffect::draw(QPainter *painter, QGraphicsEffectSource *sou \img graphicseffect-blur.png - \sa QGraphicsDropShadowEffect, QGraphicsPixelizeEffect, QGraphicsGrayscaleEffect, - QGraphicsColorizeEffect, QGraphicsOpacityEffect + \sa QGraphicsDropShadowEffect, QGraphicsColorizeEffect, QGraphicsOpacityEffect */ /*! @@ -937,8 +722,7 @@ void QGraphicsBlurEffect::draw(QPainter *painter, QGraphicsEffectSource *source) \img graphicseffect-drop-shadow.png - \sa QGraphicsBlurEffect, QGraphicsPixelizeEffect, QGraphicsGrayscaleEffect, - QGraphicsColorizeEffect, QGraphicsOpacityEffect + \sa QGraphicsBlurEffect, QGraphicsColorizeEffect, QGraphicsOpacityEffect */ /*! @@ -1117,8 +901,7 @@ void QGraphicsDropShadowEffect::draw(QPainter *painter, QGraphicsEffectSource *s \img graphicseffect-opacity.png - \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsPixelizeEffect, - QGraphicsGrayscaleEffect, QGraphicsColorizeEffect + \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsColorizeEffect */ /*! @@ -1296,234 +1079,6 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour painter->restore(); } -/*! - \class QGraphicsBloomEffect - \brief The QGraphicsBloomEffect class provides a bloom/glow effect. - \since 4.6 - - A bloom/glow effect adds fringes of light around bright areas in the source. - - \img graphicseffect-bloom.png - - \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsPixelizeEffect, - QGraphicsGrayscaleEffect, QGraphicsColorizeEffect -*/ - -/*! - Constructs a new QGraphicsBloomEffect instance. - The \a parent parameter is passed to QGraphicsEffect's constructor. -*/ -QGraphicsBloomEffect::QGraphicsBloomEffect(QObject *parent) - : QGraphicsEffect(*new QGraphicsBloomEffectPrivate, parent) -{ - Q_D(QGraphicsBloomEffect); - for (int i = 0; i < 256; ++i) - d->colorTable[i] = qMin(i + d->brightness, 255); -} - -/*! - Destroys the effect. -*/ -QGraphicsBloomEffect::~QGraphicsBloomEffect() -{ -} - -/*! - \reimp -*/ -QRectF QGraphicsBloomEffect::boundingRectFor(const QRectF &rect) const -{ - Q_D(const QGraphicsBloomEffect); - const qreal delta = d->blurFilter.radius() * 2; - return rect.adjusted(-delta, -delta, delta, delta); -} - -/*! - \property QGraphicsBloomEffect::blurRadius - \brief the blur radius in pixels of the effect. - - Using a smaller radius results in a sharper appearance, whereas a bigger - radius results in a more blurred appearance. - - By default, the blur radius is 5 pixels. - - \sa strength(), brightness() -*/ -int QGraphicsBloomEffect::blurRadius() const -{ - Q_D(const QGraphicsBloomEffect); - return d->blurFilter.radius(); -} - -void QGraphicsBloomEffect::setBlurRadius(int radius) -{ - Q_D(QGraphicsBloomEffect); - if (d->blurFilter.radius() == radius) - return; - - d->blurFilter.setRadius(radius); - updateBoundingRect(); - emit blurRadiusChanged(radius); -} - -/*! - \fn void QGraphicsBloomEffect::blurRadiusChanged(int blurRadius) - - This signal is emitted whenever the effect's blur radius changes. - The \a blurRadius parameter holds the effect's new blur radius. -*/ - -/*! - \property QGraphicsBloomEffect::blurHint - \brief the blur hint of the effect. - - Use the Qt::PerformanceHint hint to say that you want a faster blur, - and the Qt::QualityHint hint to say that you prefer a higher quality blur. - - When animating the blur radius it's recommended to use Qt::PerformanceHint. - - By default, the blur hint is Qt::PerformanceHint. -*/ -Qt::RenderHint QGraphicsBloomEffect::blurHint() const -{ - Q_D(const QGraphicsBloomEffect); - return d->blurFilter.blurHint(); -} - -void QGraphicsBloomEffect::setBlurHint(Qt::RenderHint hint) -{ - Q_D(QGraphicsBloomEffect); - if (d->blurFilter.blurHint() == hint) - return; - - d->blurFilter.setBlurHint(hint); - emit blurHintChanged(hint); -} - -/*! - \fn void QGraphicsBloomEffect::blurHintChanged(Qt::RenderHint hint) - - This signal is emitted whenever the effect's blur hint changes. - The \a hint parameter holds the effect's new blur hint. -*/ - -/*! - \property QGraphicsBloomEffect::brightness - \brief the brightness of the glow. - - The value should be in the range of 0 to 255, where 0 is dark - and 255 is bright. - - By default, the brightness is 70. - - \sa strength(), blurRadius() -*/ -int QGraphicsBloomEffect::brightness() const -{ - Q_D(const QGraphicsBloomEffect); - return d->brightness; -} - -void QGraphicsBloomEffect::setBrightness(int brightness) -{ - Q_D(QGraphicsBloomEffect); - brightness = qBound(0, brightness, 255); - if (d->brightness == brightness) - return; - - d->brightness = brightness; - for (int i = 0; i < 256; ++i) - d->colorTable[i] = qMin(i + brightness, 255); - - update(); - emit brightnessChanged(brightness); -} - -/*! - \fn void QGraphicsBloomEffect::brightnessChanged(int brightness) - - This signal is emitted whenever the effect's brightness changes. - The \a brightness parameter holds the effect's new brightness. -*/ - -/*! - \property QGraphicsBloomEffect::strength - \brief the strength of the effect. - - A strength 0.0 equals to no effect, while 1.0 means maximum glow. - - By default, the strength is 0.7. -*/ -qreal QGraphicsBloomEffect::strength() const -{ - Q_D(const QGraphicsBloomEffect); - return d->strength; -} - -void QGraphicsBloomEffect::setStrength(qreal strength) -{ - Q_D(QGraphicsBloomEffect); - strength = qBound(qreal(0.0), strength, qreal(1.0)); - if (qFuzzyCompare(d->strength, strength)) - return; - - d->strength = strength; - update(); - emit strengthChanged(strength); -} - -/*! - \fn void QGraphicsBloomEffect::strengthChanged(qreal strength) - - This signal is emitted whenever the effect's strength changes. - The \a strength parameter holds the effect's new strength. -*/ - -extern QPixmap qt_toRasterPixmap(const QPixmap &pixmap); - -/*! - \reimp -*/ -void QGraphicsBloomEffect::draw(QPainter *painter, QGraphicsEffectSource *source) -{ - Q_D(QGraphicsBloomEffect); - if (d->strength < 0.001) { - source->draw(painter); - return; - } - - QPoint offset; - QPixmap pixmap = qt_toRasterPixmap(source->pixmap(Qt::DeviceCoordinates, &offset)); - - // Blur. - QImage overlay(pixmap.size(), QImage::Format_ARGB32_Premultiplied); - overlay.fill(0); - - QPainter blurPainter(&overlay); - d->blurFilter.draw(&blurPainter, QPointF(), pixmap); - blurPainter.end(); - - // Brighten. - const int numBits = overlay.width() * overlay.height(); - QRgb *bits = reinterpret_cast(overlay.bits()); - for (int i = 0; i < numBits; ++i) { - const QRgb pixel = INV_PREMUL(bits[i]); - bits[i] = PREMUL(qRgba(d->colorTable[qRed(pixel)], d->colorTable[qGreen(pixel)], - d->colorTable[qBlue(pixel)], qAlpha(pixel))); - } - - // Composite. - QPainter compPainter(&pixmap); - compPainter.setCompositionMode(QPainter::CompositionMode_Overlay); - compPainter.setOpacity(d->strength); - compPainter.drawImage(0, 0, overlay); - compPainter.end(); - - QTransform restoreTransform = painter->worldTransform(); - painter->setWorldTransform(QTransform()); - painter->drawPixmap(offset, pixmap); - painter->setWorldTransform(restoreTransform); -} QT_END_NAMESPACE diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h index c89851e..019e808 100644 --- a/src/gui/effects/qgraphicseffect.h +++ b/src/gui/effects/qgraphicseffect.h @@ -141,31 +141,6 @@ private: }; Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsEffect::ChangeFlags) -class QGraphicsGrayscaleEffectPrivate; -class Q_GUI_EXPORT QGraphicsGrayscaleEffect: public QGraphicsEffect -{ - Q_OBJECT - Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged) -public: - QGraphicsGrayscaleEffect(QObject *parent = 0); - ~QGraphicsGrayscaleEffect(); - - qreal strength() const; - -protected: - void draw(QPainter *painter, QGraphicsEffectSource *source); - -public Q_SLOTS: - void setStrength(qreal strength); - -Q_SIGNALS: - void strengthChanged(qreal strength); - -private: - Q_DECLARE_PRIVATE(QGraphicsGrayscaleEffect) - Q_DISABLE_COPY(QGraphicsGrayscaleEffect) -}; - class QGraphicsColorizeEffectPrivate; class Q_GUI_EXPORT QGraphicsColorizeEffect: public QGraphicsEffect { @@ -195,31 +170,6 @@ private: Q_DISABLE_COPY(QGraphicsColorizeEffect) }; -class QGraphicsPixelizeEffectPrivate; -class Q_GUI_EXPORT QGraphicsPixelizeEffect: public QGraphicsEffect -{ - Q_OBJECT - Q_PROPERTY(int pixelSize READ pixelSize WRITE setPixelSize NOTIFY pixelSizeChanged) -public: - QGraphicsPixelizeEffect(QObject *parent = 0); - ~QGraphicsPixelizeEffect(); - - int pixelSize() const; - -public Q_SLOTS: - void setPixelSize(int pixelSize); - -Q_SIGNALS: - void pixelSizeChanged(int pixelSize); - -protected: - void draw(QPainter *painter, QGraphicsEffectSource *source); - -private: - Q_DECLARE_PRIVATE(QGraphicsPixelizeEffect) - Q_DISABLE_COPY(QGraphicsPixelizeEffect) -}; - class QGraphicsBlurEffectPrivate; class Q_GUI_EXPORT QGraphicsBlurEffect: public QGraphicsEffect { @@ -335,44 +285,6 @@ private: Q_DISABLE_COPY(QGraphicsOpacityEffect) }; -class QGraphicsBloomEffectPrivate; -class Q_GUI_EXPORT QGraphicsBloomEffect: public QGraphicsEffect -{ - Q_OBJECT - Q_PROPERTY(int blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) - Q_PROPERTY(Qt::RenderHint blurHint READ blurHint WRITE setBlurHint NOTIFY blurHintChanged) - Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged) - Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged) -public: - QGraphicsBloomEffect(QObject *parent = 0); - ~QGraphicsBloomEffect(); - - QRectF boundingRectFor(const QRectF &rect) const; - int blurRadius() const; - Qt::RenderHint blurHint() const; - int brightness() const; - qreal strength() const; - -public Q_SLOTS: - void setBlurRadius(int blurRadius); - void setBlurHint(Qt::RenderHint hint); - void setBrightness(int brightness); - void setStrength(qreal strength); - -Q_SIGNALS: - void blurRadiusChanged(int blurRadius); - void blurHintChanged(Qt::RenderHint hint); - void brightnessChanged(int brightness); - void strengthChanged(qreal strength); - -protected: - void draw(QPainter *painter, QGraphicsEffectSource *source); - -private: - Q_DECLARE_PRIVATE(QGraphicsBloomEffect) - Q_DISABLE_COPY(QGraphicsBloomEffect) -}; - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h index 8fb55d8..87abbbc 100644 --- a/src/gui/effects/qgraphicseffect_p.h +++ b/src/gui/effects/qgraphicseffect_p.h @@ -118,22 +118,6 @@ public: quint32 padding : 31; // feel free to use }; -class QGraphicsGrayscaleEffectPrivate : public QGraphicsEffectPrivate -{ - Q_DECLARE_PUBLIC(QGraphicsGrayscaleEffect) -public: - QGraphicsGrayscaleEffectPrivate() - : opaque(true) - { - filter = new QPixmapColorizeFilter; - filter->setColor(Qt::black); - } - ~QGraphicsGrayscaleEffectPrivate() { delete filter; } - - QPixmapColorizeFilter *filter; - quint32 opaque : 1; - quint32 padding : 31; -}; class QGraphicsColorizeEffectPrivate : public QGraphicsEffectPrivate { @@ -151,15 +135,6 @@ public: quint32 padding : 31; }; -class QGraphicsPixelizeEffectPrivate : public QGraphicsEffectPrivate -{ - Q_DECLARE_PUBLIC(QGraphicsPixelizeEffect) -public: - QGraphicsPixelizeEffectPrivate() : pixelSize(3) {} - - int pixelSize; -}; - class QGraphicsBlurEffectPrivate : public QGraphicsEffectPrivate { Q_DECLARE_PUBLIC(QGraphicsBlurEffect) @@ -195,18 +170,6 @@ public: uint hasOpacityMask : 1; }; -class QGraphicsBloomEffectPrivate : public QGraphicsEffectPrivate -{ - Q_DECLARE_PUBLIC(QGraphicsBlurEffect) -public: - QGraphicsBloomEffectPrivate() : brightness(70), strength(qreal(0.7)) {} - - QPixmapBlurFilter blurFilter; - int colorTable[256]; - int brightness; - qreal strength; -}; - QT_END_NAMESPACE #endif // QGRAPHICSEFFECT_P_H -- cgit v0.12 From a95883e90fadeddd2f49da6765fb2d79f7ce77bd Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 23 Oct 2009 09:14:39 +0200 Subject: Added visual DnD indicator for left to right flow in QListView Extended the behaviour already present in QAbstractItemView into QListView. This means some code duplication which should maybe be refactored at some point. (Seems to be the price to pay when some delegate does almost the same thing as the base class). No auto-test, as it's a drag-and-drop related task. Reviewed-by: Thierry Task-number: QTBUG-3730 --- src/gui/itemviews/qabstractitemview.h | 1 + src/gui/itemviews/qabstractitemview_p.h | 3 +- src/gui/itemviews/qlistview.cpp | 109 +++++++++++++++++++++++++++++++- src/gui/itemviews/qlistview_p.h | 9 +++ 4 files changed, 119 insertions(+), 3 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview.h b/src/gui/itemviews/qabstractitemview.h index b4f0957..f438148 100644 --- a/src/gui/itemviews/qabstractitemview.h +++ b/src/gui/itemviews/qabstractitemview.h @@ -361,6 +361,7 @@ private: friend class QTreeViewPrivate; // needed to compile with MSVC friend class QAccessibleItemRow; + friend class QListModeViewBase; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractItemView::EditTriggers) diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index fcf381a..66b7662 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -164,7 +164,8 @@ public: } #ifndef QT_NO_DRAGANDDROP - QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const; + virtual QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const; + inline bool canDecode(QDropEvent *e) const { QStringList modelTypes = model->mimeTypes(); const QMimeData *mime = e->mimeData(); diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index f58f458..109d760 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -853,8 +853,13 @@ void QListView::resizeEvent(QResizeEvent *e) */ void QListView::dragMoveEvent(QDragMoveEvent *e) { - if (!d_func()->commonListView->filterDragMoveEvent(e)) - QAbstractItemView::dragMoveEvent(e); + Q_D(QListView); + if (!d->commonListView->filterDragMoveEvent(e)) { + if (viewMode() == QListView::ListMode && flow() == QListView::LeftToRight) + static_cast(d->commonListView)->dragMoveEvent(e); + else + QAbstractItemView::dragMoveEvent(e); + } } @@ -1804,6 +1809,16 @@ QItemSelection QListViewPrivate::selection(const QRect &rect) const return selection; } +#ifndef QT_NO_DRAGANDDROP +QAbstractItemView::DropIndicatorPosition QListViewPrivate::position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const +{ + if (viewMode == QListView::ListMode && flow == QListView::LeftToRight) + return static_cast(commonListView)->position(pos, rect, idx); + else + return QAbstractItemViewPrivate::position(pos, rect, idx); +} +#endif + /* * Common ListView Implementation */ @@ -1893,6 +1908,96 @@ void QListModeViewBase::paintDragDrop(QPainter *painter) // in IconMode, it makes no sense to show it dd->paintDropIndicator(painter); } + +QAbstractItemView::DropIndicatorPosition QListModeViewBase::position(const QPoint &pos, const QRect &rect, const QModelIndex &index) const +{ + QAbstractItemView::DropIndicatorPosition r = QAbstractItemView::OnViewport; + if (!dd->overwrite) { + const int margin = 2; + if (pos.x() - rect.left() < margin) { + r = QAbstractItemView::AboveItem; // Visually, on the left + } else if (rect.right() - pos.x() < margin) { + r = QAbstractItemView::BelowItem; // Visually, on the right + } else if (rect.contains(pos, true)) { + r = QAbstractItemView::OnItem; + } + } else { + QRect touchingRect = rect; + touchingRect.adjust(-1, -1, 1, 1); + if (touchingRect.contains(pos, false)) { + r = QAbstractItemView::OnItem; + } + } + + if (r == QAbstractItemView::OnItem && (!(dd->model->flags(index) & Qt::ItemIsDropEnabled))) + r = pos.x() < rect.center().x() ? QAbstractItemView::AboveItem : QAbstractItemView::BelowItem; + + return r; +} + +void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event) +{ + if (qq->dragDropMode() == QAbstractItemView::InternalMove + && (event->source() != qq || !(event->possibleActions() & Qt::MoveAction))) + return; + + // ignore by default + event->ignore(); + + QModelIndex index = qq->indexAt(event->pos()); + dd->hover = index; + if (!dd->droppingOnItself(event, index) + && dd->canDecode(event)) { + + if (index.isValid() && dd->showDropIndicator) { + QRect rect = qq->visualRect(index); + dd->dropIndicatorPosition = position(event->pos(), rect, index); + switch (dd->dropIndicatorPosition) { + case QAbstractItemView::AboveItem: + if (dd->isIndexDropEnabled(index.parent())) { + dd->dropIndicatorRect = QRect(rect.left(), rect.top(), 0, rect.height()); + event->accept(); + } else { + dd->dropIndicatorRect = QRect(); + } + break; + case QAbstractItemView::BelowItem: + if (dd->isIndexDropEnabled(index.parent())) { + dd->dropIndicatorRect = QRect(rect.right(), rect.top(), 0, rect.height()); + event->accept(); + } else { + dd->dropIndicatorRect = QRect(); + } + break; + case QAbstractItemView::OnItem: + if (dd->isIndexDropEnabled(index)) { + dd->dropIndicatorRect = rect; + event->accept(); + } else { + dd->dropIndicatorRect = QRect(); + } + break; + case QAbstractItemView::OnViewport: + dd->dropIndicatorRect = QRect(); + if (dd->isIndexDropEnabled(qq->rootIndex())) { + event->accept(); // allow dropping in empty areas + } + break; + } + } else { + dd->dropIndicatorRect = QRect(); + dd->dropIndicatorPosition = QAbstractItemView::OnViewport; + if (dd->isIndexDropEnabled(qq->rootIndex())) { + event->accept(); // allow dropping in empty areas + } + } + dd->viewport->update(); + } // can decode + + if (dd->shouldAutoScroll(event->pos())) + qq->startAutoScroll(); +} + #endif //QT_NO_DRAGANDDROP void QListModeViewBase::updateVerticalScrollBar(const QSize &step) diff --git a/src/gui/itemviews/qlistview_p.h b/src/gui/itemviews/qlistview_p.h index de4c7f3..3f8f9db 100644 --- a/src/gui/itemviews/qlistview_p.h +++ b/src/gui/itemviews/qlistview_p.h @@ -231,6 +231,11 @@ public: #ifndef QT_NO_DRAGANDDROP void paintDragDrop(QPainter *painter); + + // The next two methods are to be used on LefToRight flow only. + // WARNING: Plenty of duplicated code from QAbstractItemView{,Private}. + QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const; + void dragMoveEvent(QDragMoveEvent *e); #endif private: @@ -356,6 +361,10 @@ public: QItemSelection selection(const QRect &rect) const; void selectAll(QItemSelectionModel::SelectionFlags command); +#ifndef QT_NO_DRAGANDDROP + virtual QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const; +#endif + inline void setGridSize(const QSize &size) { grid = size; } inline QSize gridSize() const { return grid; } inline void setWrapping(bool b) { wrap = b; } -- cgit v0.12 From cc4d3fbc317bc9044c3ce23569f0225b29af4fd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 22 Oct 2009 14:49:40 +0200 Subject: QGraphicsLineItem leave traces when moving around (reg. against 4.5) The problem was that QGraphicsLineItem's bounding rect is an empty rect (either width is 0 or height is 0), and when updating the item's old occupied area, we explicitly checked whether the rect was empty() or not. In case of being empty (rect.isEmpty()) we did nothing, which was the root of the problem. We can safely remove the rect.isEmpty() check without any significant loss of performance since the common case is that the rect is non-empty. And in the case of being empty, we'll bail out from QGraphicsViewPrivate::updateRect's highly optimized rect intersection. Auto test included. Task: QTBUG-4877 Reviewed-by: alexis --- src/gui/graphicsview/qgraphicsscene.cpp | 2 +- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 34 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 03c8a97..9736c3e 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4888,7 +4888,7 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool continue; } - if (item->d_ptr->paintedViewBoundingRectsNeedRepaint && !paintedViewBoundingRect.isEmpty()) { + if (item->d_ptr->paintedViewBoundingRectsNeedRepaint) { paintedViewBoundingRect.translate(viewPrivate->dirtyScrollOffset); if (!viewPrivate->updateRect(paintedViewBoundingRect)) paintedViewBoundingRect = QRect(-1, -1, -1, -1); // Outside viewport. diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index dcad8e1..4fae911 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -372,6 +372,7 @@ private slots: void itemUsesExtendedStyleOption(); void itemSendsGeometryChanges(); void moveItem(); + void moveLineItem(); void sorting_data(); void sorting(); void itemHasNoContents(); @@ -7438,6 +7439,39 @@ void tst_QGraphicsItem::moveItem() COMPARE_REGIONS(view.paintedRegion, expectedParentRegion); } +void tst_QGraphicsItem::moveLineItem() +{ + QGraphicsScene scene; + scene.setSceneRect(0, 0, 200, 200); + QGraphicsLineItem *item = new QGraphicsLineItem(0, 0, 100, 0); + item->setPos(50, 50); + scene.addItem(item); + + MyGraphicsView view(&scene); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(200); + view.reset(); + + const QRect itemDeviceBoundingRect = item->deviceTransform(view.viewportTransform()) + .mapRect(item->boundingRect()).toRect(); + QRegion expectedRegion = itemDeviceBoundingRect.adjusted(-2, -2, 2, 2); // antialiasing + + // Make sure the calculated region is correct. + item->update(); + QTest::qWait(10); + QCOMPARE(view.paintedRegion, expectedRegion); + view.reset(); + + // Old position: (50, 50) + item->setPos(50, 100); + expectedRegion += expectedRegion.translated(0, 50); + QTest::qWait(10); + QCOMPARE(view.paintedRegion, expectedRegion); +} + void tst_QGraphicsItem::sorting_data() { QTest::addColumn("index"); -- cgit v0.12 From e751b8e9b0fdc1e23084a102ca6d86fea7f530d4 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 23 Oct 2009 12:05:30 +0200 Subject: MAke sure we call setCurrentTime when an animation is started This could be prevented by a pause animation currently running. Reviewed-by: Leo --- src/corelib/animation/qabstractanimation.cpp | 19 ++++++++----------- src/corelib/animation/qabstractanimation_p.h | 2 +- tests/auto/qpauseanimation/tst_qpauseanimation.cpp | 9 +++++++++ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index f83c2a1..b8b9214 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -194,15 +194,10 @@ QUnifiedTimer *QUnifiedTimer::instance() return inst; } -void QUnifiedTimer::ensureTimerUpdate(QAbstractAnimation *animation) +void QUnifiedTimer::ensureTimerUpdate() { - if (isPauseTimerActive) { + if (isPauseTimerActive) updateAnimationsTime(); - } else { - // this code is needed when ensureTimerUpdate is called from setState because we update - // the currentTime when an animation starts running (otherwise we could remove it) - animation->setCurrentTime(animation->currentTime()); - } } void QUnifiedTimer::updateAnimationsTime() @@ -381,7 +376,7 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) case QAbstractAnimation::Paused: if (hasRegisteredTimer) // currentTime needs to be updated if pauseTimer is active - QUnifiedTimer::instance()->ensureTimerUpdate(q); + QUnifiedTimer::instance()->ensureTimerUpdate(); if (!guard) return; //here we're sure that we were in running state before and that the @@ -395,9 +390,11 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) // this ensures that the value is updated now that the animation is running if (oldState == QAbstractAnimation::Stopped) { - if (isTopLevel) + if (isTopLevel) { // currentTime needs to be updated if pauseTimer is active - QUnifiedTimer::instance()->ensureTimerUpdate(q); + QUnifiedTimer::instance()->ensureTimerUpdate(); + q->setCurrentTime(totalCurrentTime); + } } } break; @@ -558,7 +555,7 @@ void QAbstractAnimation::setDirection(Direction direction) // the commands order below is important: first we need to setCurrentTime with the old direction, // then update the direction on this and all children and finally restart the pauseTimer if needed if (d->hasRegisteredTimer) - QUnifiedTimer::instance()->ensureTimerUpdate(this); + QUnifiedTimer::instance()->ensureTimerUpdate(); d->direction = direction; updateDirection(direction); diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index bef0499..f989bce 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -142,7 +142,7 @@ public: this is used for updating the currentTime of all animations in case the pause timer is active or, otherwise, only of the animation passed as parameter. */ - void ensureTimerUpdate(QAbstractAnimation *animation); + void ensureTimerUpdate(); /* this will evaluate the need of restarting the pause timer in case there is still diff --git a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp index b11efa0..2546163 100644 --- a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp +++ b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp @@ -260,6 +260,9 @@ void tst_QPauseAnimation::sequentialPauseGroup() animation3.setDuration(200); group.start(); + QCOMPARE(animation1.m_updateCurrentTimeCount, 1); + QCOMPARE(animation2.m_updateCurrentTimeCount, 0); + QCOMPARE(animation3.m_updateCurrentTimeCount, 0); QVERIFY(group.state() == QAbstractAnimation::Running); QVERIFY(animation1.state() == QAbstractAnimation::Running); @@ -267,6 +270,9 @@ void tst_QPauseAnimation::sequentialPauseGroup() QVERIFY(animation3.state() == QAbstractAnimation::Stopped); group.setCurrentTime(250); + QCOMPARE(animation1.m_updateCurrentTimeCount, 2); + QCOMPARE(animation2.m_updateCurrentTimeCount, 1); + QCOMPARE(animation3.m_updateCurrentTimeCount, 0); QVERIFY(group.state() == QAbstractAnimation::Running); QVERIFY(animation1.state() == QAbstractAnimation::Stopped); @@ -275,6 +281,9 @@ void tst_QPauseAnimation::sequentialPauseGroup() QVERIFY(animation3.state() == QAbstractAnimation::Stopped); group.setCurrentTime(500); + QCOMPARE(animation1.m_updateCurrentTimeCount, 2); + QCOMPARE(animation2.m_updateCurrentTimeCount, 2); + QCOMPARE(animation3.m_updateCurrentTimeCount, 1); QVERIFY(group.state() == QAbstractAnimation::Running); QVERIFY(animation1.state() == QAbstractAnimation::Stopped); -- cgit v0.12 From a1301736c3fdc25bdf6f35bf67747804adb83ac3 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Fri, 23 Oct 2009 12:08:54 +0200 Subject: Increase realiability of pauseanimation autotests on win Reviewed-by: thierry --- tests/auto/qpauseanimation/tst_qpauseanimation.cpp | 44 ++++++++++++---------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp index 2546163..4d0a7a7 100644 --- a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp +++ b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp @@ -93,8 +93,7 @@ public: virtual ~tst_QPauseAnimation(); public Q_SLOTS: - void init(); - void cleanup(); + void initTestCase(); private slots: void changeDirectionWhileRunning(); @@ -117,20 +116,15 @@ tst_QPauseAnimation::~tst_QPauseAnimation() { } -void tst_QPauseAnimation::init() +void tst_QPauseAnimation::initTestCase() { qRegisterMetaType("QAbstractAnimation::State"); qRegisterMetaType("QAbstractAnimation::DeletionPolicy"); } -void tst_QPauseAnimation::cleanup() -{ -} - void tst_QPauseAnimation::changeDirectionWhileRunning() { - QUnifiedTimer *timer = QUnifiedTimer::instance(); - timer->setConsistentTiming(true); + EnableConsistentTiming enabled; TestablePauseAnimation animation; animation.setDuration(400); @@ -140,8 +134,6 @@ void tst_QPauseAnimation::changeDirectionWhileRunning() animation.setDirection(QAbstractAnimation::Backward); QTest::qWait(animation.totalDuration() + 50); QVERIFY(animation.state() == QAbstractAnimation::Stopped); - - timer->setConsistentTiming(false); } void tst_QPauseAnimation::noTimerUpdates_data() @@ -157,8 +149,7 @@ void tst_QPauseAnimation::noTimerUpdates_data() void tst_QPauseAnimation::noTimerUpdates() { - QUnifiedTimer *timer = QUnifiedTimer::instance(); - timer->setConsistentTiming(true); + EnableConsistentTiming enabled; QFETCH(int, duration); QFETCH(int, loopCount); @@ -168,16 +159,19 @@ void tst_QPauseAnimation::noTimerUpdates() animation.setLoopCount(loopCount); animation.start(); QTest::qWait(animation.totalDuration() + 100); + +#ifdef Q_OS_WIN + if (animation.state() != QAbstractAnimation::Stopped) + QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort); +#endif + QVERIFY(animation.state() == QAbstractAnimation::Stopped); QCOMPARE(animation.m_updateCurrentTimeCount, 1 + loopCount); - - timer->setConsistentTiming(false); } void tst_QPauseAnimation::mulitplePauseAnimations() { - QUnifiedTimer *timer = QUnifiedTimer::instance(); - timer->setConsistentTiming(true); + EnableConsistentTiming enabled; TestablePauseAnimation animation; animation.setDuration(200); @@ -188,16 +182,26 @@ void tst_QPauseAnimation::mulitplePauseAnimations() animation.start(); animation2.start(); QTest::qWait(animation.totalDuration() + 100); + +#ifdef Q_OS_WIN + if (animation.state() != QAbstractAnimation::Stopped) + QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort); +#endif + QVERIFY(animation.state() == QAbstractAnimation::Stopped); QVERIFY(animation2.state() == QAbstractAnimation::Running); QCOMPARE(animation.m_updateCurrentTimeCount, 2); QCOMPARE(animation2.m_updateCurrentTimeCount, 2); QTest::qWait(550); + +#ifdef Q_OS_WIN + if (animation2.state() != QAbstractAnimation::Stopped) + QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort); +#endif + QVERIFY(animation2.state() == QAbstractAnimation::Stopped); QCOMPARE(animation2.m_updateCurrentTimeCount, 3); - - timer->setConsistentTiming(false); } void tst_QPauseAnimation::pauseAndPropertyAnimations() @@ -243,7 +247,7 @@ void tst_QPauseAnimation::pauseResume() animation.pause(); QVERIFY(animation.state() == QAbstractAnimation::Paused); animation.start(); - QTest::qWait(250); + QTest::qWait(300); QVERIFY(animation.state() == QAbstractAnimation::Stopped); QCOMPARE(animation.m_updateCurrentTimeCount, 3); } -- cgit v0.12 From 72fb0f2637db401efd178b9d4139fc2b6ef59112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Fri, 23 Oct 2009 13:17:06 +0200 Subject: Wrong worldTransform() on the painter in QGraphicsScene::drawForeground. The painter's worldTransform() is updated for each item we draw, and when the DontSavePainterState optimization flag is set, this change is not protected by save() and restore(). After all the items are drawn, it means the painter is left with the last drawn item's transform. We therefore have to make sure it is reset back to whatever it was before the items were drawn. Auto-test included. Task-number: QTBUG-4973 Reviewed-by: alexis Reviewed-by: andreas --- src/gui/graphicsview/qgraphicsview.cpp | 8 +++++ tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 49 ++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 32747cc..49348de 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -3306,6 +3306,14 @@ void QGraphicsView::paintEvent(QPaintEvent *event) if (!(d->optimizationFlags & IndirectPainting)) { d->scene->d_func()->drawItems(&painter, viewTransformed ? &viewTransform : 0, &d->exposedRegion, viewport()); + // Make sure the painter's world transform is restored correctly when + // drawing without painter state protection (DontSavePainterState). + // We only change the worldTransform() so there's no need to do a full-blown + // save() and restore(). Also note that we don't have to do this in case of + // IndirectPainting (the else branch), because in that case we always save() + // and restore() in QGraphicsScene::drawItems(). + if (!d->scene->d_func()->painterStateProtection) + painter.setWorldTransform(viewTransform); } else { // Find all exposed items bool allItems = false; diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index dc08d0e..092f81d 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -194,6 +194,8 @@ private slots: void acceptDrops(); void optimizationFlags(); void optimizationFlags_dontSavePainterState(); + void optimizationFlags_dontSavePainterState2_data(); + void optimizationFlags_dontSavePainterState2(); void levelOfDetail_data(); void levelOfDetail(); void scrollBarRanges_data(); @@ -2455,6 +2457,53 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState() QTest::qWaitForWindowShown(&painter2); } +void tst_QGraphicsView::optimizationFlags_dontSavePainterState2_data() +{ + QTest::addColumn("savePainter"); + QTest::newRow("With painter state protection") << true; + QTest::newRow("Without painter state protection") << false; +} + +void tst_QGraphicsView::optimizationFlags_dontSavePainterState2() +{ + QFETCH(bool, savePainter); + + class MyScene : public QGraphicsScene + { + public: + void drawBackground(QPainter *p, const QRectF &) + { transformInDrawBackground = p->worldTransform(); } + + void drawForeground(QPainter *p, const QRectF &) + { transformInDrawForeground = p->worldTransform(); } + + QTransform transformInDrawBackground; + QTransform transformInDrawForeground; + }; + + MyScene scene; + // Add transformed dummy items to make sure the painter's worldTransform() is changed in drawItems. + scene.addRect(0, 0, 20, 20)->setTransform(QTransform::fromScale(2, 2)); + scene.addRect(50, 50, 20, 20)->setTransform(QTransform::fromTranslate(200, 200)); + + QGraphicsView view(&scene); + if (!savePainter) + view.setOptimizationFlag(QGraphicsView::DontSavePainterState); + view.rotate(45); + view.scale(1.5, 1.5); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(150); + + // Make sure the painter's world transform is preserved after drawItems. + const QTransform expectedTransform = view.viewportTransform(); + QVERIFY(!expectedTransform.isIdentity()); + QCOMPARE(scene.transformInDrawForeground, expectedTransform); + QCOMPARE(scene.transformInDrawBackground, expectedTransform); +} + class LodItem : public QGraphicsRectItem { public: -- cgit v0.12 From d0fa7d4b30fa34fe2a684c331213528c193da85f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 22 Oct 2009 20:18:21 +0200 Subject: Windows doesn't #define STD{IN,OUT,ERR}_FILENO Reviewed-by: Markus Goetz --- tests/auto/qfile/tst_qfile.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index bbb6280..4971762 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -79,6 +79,18 @@ # define SRCDIR "" #endif +#ifndef STDIN_FILENO +#define STDIN_FILENO 0 +#endif + +#ifndef STDOUT_FILENO +#define STDOUT_FILENO 1 +#endif + +#ifndef STDERR_FILENO +#define STDERR_FILENO 2 +#endif + Q_DECLARE_METATYPE(QFile::FileError) //TESTED_CLASS= -- cgit v0.12 From 3be1b879c9fbe37b71cce3c95ec4a3753a25a641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 23 Oct 2009 11:15:56 +0200 Subject: Check for non-zero return from fseek While POSIX specifies a -1 return on error, on Windows only non-zero is documented for error conditions. All platforms agree that zero is returned on success so we check for that instead. Reviewed-by: Markus Goetz --- src/corelib/io/qfsfileengine.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index c34f8ad..a7de896 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -317,9 +317,9 @@ bool QFSFileEnginePrivate::openFh(QIODevice::OpenMode openMode, FILE *fh) int ret; do { ret = QT_FSEEK(fh, 0, SEEK_END); - } while (ret == -1 && errno == EINTR); + } while (ret != 0 && errno == EINTR); - if (ret == -1) { + if (ret != 0) { q->setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError, qt_error_string(int(errno))); @@ -572,9 +572,9 @@ bool QFSFileEnginePrivate::seekFdFh(qint64 pos) int ret; do { ret = QT_FSEEK(fh, QT_OFF_T(pos), SEEK_SET); - } while (ret == -1 && errno == EINTR); + } while (ret != 0 && errno == EINTR); - if (ret == -1) { + if (ret != 0) { q->setError(QFile::ReadError, qt_error_string(int(errno))); return false; } -- cgit v0.12 From 2ad49361eeb1ad14a2b9c6c95a9d20d20f9aa851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 23 Oct 2009 11:23:55 +0200 Subject: On Windows, report a 0 file size for streams and other funny files Obtain file size directly, instead of relying on fseek/ftell and messing with the file position. Also changed the return value on errors to 0. This is mostly relevant on streams and pipes, where we used to return whatever error value ftell returned (usually -1). This change also makes the return value consistent with what is returned on Unix platforms and what we document for Windows CE. Nevertheless, documentation of this and related issues is misleading and needs to be updated. Reviewed-by: Markus Goetz --- src/corelib/io/qfsfileengine_win.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 151eabd..b8a16fa 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -499,11 +499,8 @@ qint64 QFSFileEnginePrivate::nativeSize() const // Buffered stdlib mode. if (fh) { - QT_OFF_T oldPos = QT_FTELL(fh); - QT_FSEEK(fh, 0, SEEK_END); - QT_OFF_T fileSize = QT_FTELL(fh); - QT_FSEEK(fh, oldPos, SEEK_SET); - return qint64(fileSize); + qint64 fileSize = _filelengthi64(QT_FILENO(fh)); + return (fileSize == -1) ? 0 : fileSize; } // Not-open mode, where the file name is known: We'll check the -- cgit v0.12 From b402b8c4216ebb2d7db1e7e6cd33a45d1af422e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 23 Oct 2009 11:48:51 +0200 Subject: Fix the LargeFile test for Windows The test assumed fileName was stable, but it is documented behaviour that this can be reset when a file descriptor or FILE* stream is associated with a QFile. This was the case on Windows. --- tests/auto/qfile/largefile/tst_largefile.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp index 398ca3f..d2bbffe 100644 --- a/tests/auto/qfile/largefile/tst_largefile.cpp +++ b/tests/auto/qfile/largefile/tst_largefile.cpp @@ -72,7 +72,6 @@ public: tst_LargeFile() : blockSize(1 << 12) , maxSizeBits() - , largeFile("qt_largefile.tmp") , fd_(-1) , stream_(0) { @@ -231,7 +230,7 @@ QByteArray const &tst_LargeFile::getDataBlock(int index, qint64 position) .arg(blockSize) .arg(index) .arg(position) - .arg(largeFile.fileName()); + .arg("qt_largefile.tmp"); generatedBlocks[index] = generateDataBlock(blockSize, text, (qint64)1 << index); } @@ -241,13 +240,17 @@ QByteArray const &tst_LargeFile::getDataBlock(int index, qint64 position) void tst_LargeFile::initTestCase() { - QVERIFY( !largeFile.exists() || largeFile.remove() ); + QFile file("qt_largefile.tmp"); + QVERIFY( !file.exists() || file.remove() ); } void tst_LargeFile::cleanupTestCase() { - largeFile.close(); - QVERIFY( !largeFile.exists() || largeFile.remove() ); + if (largeFile.isOpen()) + largeFile.close(); + + QFile file("qt_largefile.tmp"); + QVERIFY( !file.exists() || file.remove() ); } void tst_LargeFile::init() @@ -295,7 +298,7 @@ void tst_LargeFile::createSparseFile() #if defined(Q_OS_WIN) // On Windows platforms, we must explicitly set the file to be sparse, // so disk space is not allocated for the full file when writing to it. - HANDLE handle = ::CreateFileA(largeFile.fileName().toLocal8Bit().constData(), + HANDLE handle = ::CreateFileA("qt_largefile.tmp", GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0); QVERIFY( INVALID_HANDLE_VALUE != handle ); @@ -311,6 +314,7 @@ void tst_LargeFile::createSparseFile() QVERIFY( -1 != fd ); QVERIFY( largeFile.open(fd, QIODevice::WriteOnly) ); #else // !Q_OS_WIN + largeFile.setFileName("qt_largefile.tmp"); QVERIFY( largeFile.open(QIODevice::WriteOnly) ); #endif } @@ -345,7 +349,7 @@ void tst_LargeFile::fillFileSparsely() void tst_LargeFile::fileCreated() { - QFileInfo info(largeFile); + QFileInfo info("qt_largefile.tmp"); QVERIFY( info.exists() ); QVERIFY( info.isFile() ); @@ -356,7 +360,7 @@ void tst_LargeFile::filePositioning() { QFETCH( qint64, position ); - QFile file(largeFile.fileName()); + QFile file("qt_largefile.tmp"); QVERIFY( file.open(QIODevice::ReadOnly) ); QVERIFY( file.seek(position) ); @@ -367,7 +371,7 @@ void tst_LargeFile::fdPositioning() { QFETCH( qint64, position ); - fd_ = QT_OPEN(largeFile.fileName().toLocal8Bit().constData(), + fd_ = QT_OPEN("qt_largefile.tmp", QT_OPEN_RDONLY | QT_OPEN_LARGEFILE); QVERIFY( -1 != fd_ ); @@ -398,7 +402,7 @@ void tst_LargeFile::streamPositioning() { QFETCH( qint64, position ); - stream_ = QT_FOPEN(largeFile.fileName().toLocal8Bit().constData(), "rb"); + stream_ = QT_FOPEN("qt_largefile.tmp", "rb"); QVERIFY( 0 != stream_ ); QFile file; @@ -428,6 +432,7 @@ void tst_LargeFile::streamPositioning() void tst_LargeFile::openFileForReading() { + largeFile.setFileName("qt_largefile.tmp"); QVERIFY( largeFile.open(QIODevice::ReadOnly) ); } -- cgit v0.12 From f808fe435dc00398775fe8040d3c811aed6332a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 23 Oct 2009 13:44:23 +0200 Subject: Fix QFile::isSequential on Windows When not using native HANDLEs, the return of isSequential was hardcoded to true for files with a fd, and for the standard FILE* streams stdin, stdout and stderr; false for all other FILE* streams. We now use the native GetFileType call for all files by obtaining a native handle where required. We also treat files of type FILE_TYPE_CHAR as sequential, as is the case for the standard streams in console applications. When standard streams are redirected to/from files, GetFileType will return FILE_TYPE_DISK for them and they won't be considered sequential. This is alright since in this mode they behave like regular files and QFile::seek() will work for random offsets. Reviewed-by: Marius Storm-Olsen --- src/corelib/io/qfsfileengine_win.cpp | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index b8a16fa..9fc4500 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -789,27 +789,18 @@ int QFSFileEnginePrivate::nativeHandle() const bool QFSFileEnginePrivate::nativeIsSequential() const { #if !defined(Q_OS_WINCE) - // stdlib / Windows native mode. - if (fh || fileHandle != INVALID_HANDLE_VALUE) { - if (fh == stdin || fh == stdout || fh == stderr) - return true; - - HANDLE handle = fileHandle; - if (fileHandle == INVALID_HANDLE_VALUE) { - // Rare case: using QFile::open(FILE*) to open a pipe. - handle = (HANDLE)_get_osfhandle(QT_FILENO(fh)); - return false; - } - - DWORD fileType = GetFileType(handle); - return fileType == FILE_TYPE_PIPE; - } + HANDLE handle = fileHandle; + if (fh || fd != -1) + handle = (HANDLE)_get_osfhandle(fh ? QT_FILENO(fh) : fd); + if (handle == INVALID_HANDLE_VALUE) + return false; - // stdio mode. - if (fd != -1) - return isSequentialFdFh(); -#endif + DWORD fileType = GetFileType(handle); + return (fileType == FILE_TYPE_CHAR) + || (fileType == FILE_TYPE_PIPE); +#else return false; +#endif } bool QFSFileEngine::remove() -- cgit v0.12 From 45a09e31ebb25d3ad4f63ae02f0a0b464577761e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 23 Oct 2009 15:02:05 +0200 Subject: Extending QFile::size test to cover files opened with fd and FILE* Also changed tested type from int to qint64, so we'll be able to see clipping issues, although there are no large files in this test, yet. Reviewed-by: Markus Goetz --- tests/auto/qfile/tst_qfile.cpp | 51 +++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 4971762..55cc286 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -117,6 +117,7 @@ private slots: void openUnbuffered(); void size_data(); void size(); + void sizeNoExist(); void seek(); void setSize(); void setSizeSeek(); @@ -452,23 +453,57 @@ void tst_QFile::openUnbuffered() void tst_QFile::size_data() { QTest::addColumn("filename"); - QTest::addColumn("size"); + QTest::addColumn("size"); - QTest::newRow( "exist01" ) << QString(SRCDIR "testfile.txt") << 245; - QTest::newRow( "nonexist01" ) << QString("foo.txt") << 0; + QTest::newRow( "exist01" ) << QString(SRCDIR "testfile.txt") << (qint64)245; #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) // Only test UNC on Windows./ - QTest::newRow("unc") << "//" + QString(QtNetworkSettings::winServerName() + "/testsharewritable/test.pri") << 34; + QTest::newRow("unc") << "//" + QString(QtNetworkSettings::winServerName() + "/testsharewritable/test.pri") << (qint64)34; #endif } void tst_QFile::size() { QFETCH( QString, filename ); - QFile f( filename ); - QTEST( (int)f.size(), "size" ); - if (f.open(QFile::ReadOnly)) - QTEST( (int)f.size(), "size" ); + QFETCH( qint64, size ); + + { + QFile f( filename ); + QCOMPARE( f.size(), size ); + + QVERIFY( f.open(QIODevice::ReadOnly) ); + QCOMPARE( f.size(), size ); + } + + { + QFile f; + int fd = QT_OPEN(filename.toLocal8Bit().constData(), QT_OPEN_RDONLY); + QVERIFY( fd != -1 ); + QVERIFY( f.open(fd, QIODevice::ReadOnly) ); + QCOMPARE( f.size(), size ); + + f.close(); + QT_CLOSE(fd); + } + + { + QFile f; + FILE* stream = QT_FOPEN(filename.toLocal8Bit().constData(), "rb"); + QVERIFY( stream ); + QVERIFY( f.open(stream, QIODevice::ReadOnly) ); + QCOMPARE( f.size(), size ); + + f.close(); + fclose(stream); + } +} + +void tst_QFile::sizeNoExist() +{ + QFile file("nonexist01"); + QVERIFY( !file.exists() ); + QCOMPARE( file.size(), (qint64)0 ); + QVERIFY( !file.open(QIODevice::ReadOnly) ); } void tst_QFile::seek() -- cgit v0.12 From b2cc784cbba9c790c2cc083cf99d9a2a112a9c27 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 23 Oct 2009 15:36:30 +0200 Subject: Phonon: allows to stream wave files from QIODevice Reviewed-by: trust Me --- src/3rdparty/phonon/ds9/iodevicereader.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/phonon/ds9/iodevicereader.cpp b/src/3rdparty/phonon/ds9/iodevicereader.cpp index e0c505c..695af59 100644 --- a/src/3rdparty/phonon/ds9/iodevicereader.cpp +++ b/src/3rdparty/phonon/ds9/iodevicereader.cpp @@ -36,17 +36,20 @@ namespace Phonon //these mediatypes define a stream, its type will be autodetected by DirectShow static QVector getMediaTypes() { - AM_MEDIA_TYPE mt = { MEDIATYPE_Stream, MEDIASUBTYPE_NULL, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0}; + //the order here is important because otherwise, + //directshow might not be able to detect the stream type correctly + + AM_MEDIA_TYPE mt = { MEDIATYPE_Stream, MEDIASUBTYPE_Avi, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0}; QVector ret; - //normal auto-detect stream - ret << mt; //AVI stream - mt.subtype = MEDIASUBTYPE_Avi; ret << mt; //WAVE stream mt.subtype = MEDIASUBTYPE_WAVE; ret << mt; + //normal auto-detect stream (must be at the end!) + mt.subtype = MEDIASUBTYPE_NULL; + ret << mt; return ret; } -- cgit v0.12 From 7177618fd8ae91e553573263d5dd78a99c64e118 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Wed, 21 Oct 2009 11:27:22 +0200 Subject: Listen to hasVideoChanged() signal instead, such that we're more robust. This covers cases where the backend knows about video capability in a state other than the LoadingState. Patch by Adookkattil Saleem, slightly modified. Reviewed-by: Gareth Stockwell --- demos/qmediaplayer/mediaplayer.h | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/qmediaplayer/mediaplayer.h b/demos/qmediaplayer/mediaplayer.h index 83f14e8..f3af7cc 100644 --- a/demos/qmediaplayer/mediaplayer.h +++ b/demos/qmediaplayer/mediaplayer.h @@ -109,6 +109,7 @@ private slots: void bufferStatus(int percent); void openUrl(); void configureEffect(); + void hasVideoChanged(bool); private: QIcon playIcon; -- cgit v0.12 From df0f099b7ae0ffbea46411276a239d152f36a7e2 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 20 Oct 2009 17:50:11 +0100 Subject: When creating a Symbian WId for a visible widget, make the control visible after activating the window. This change was required in order to be able to run the test case for the below task; however, it is more generally required. Without it, the contents of the descendents of this widget will not be visible, until they are explicitly hidden and then re-shown. Task-number: QTBUG-4787 Reviewed-by: axis --- src/gui/kernel/qwidget_s60.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index cb615fe..3e332a3 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -434,8 +434,10 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de drawableWindow->PointerFilter(EPointerFilterEnterExit | EPointerFilterMove | EPointerFilterDrag, 0); - if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) + if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) { activateSymbianWindow(control.data()); + control->MakeVisible(true); + } // We wait until the control is fully constructed before calling setWinId, because // this generates a WinIdChanged event. -- cgit v0.12 From d54bc7379de145995534058dd2f6b400c9ab160e Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 21 Oct 2009 15:41:21 +0100 Subject: Video screen region is updated in response to ancestors of video widget being moved. Because QWidget::moveEvent is only called when a widget moves relative to its parent, a widget's absolute screen position may change without it receiving a moveEvent (for example, as a result of its parent being moved). The MMF video playback API on Symbian v9.4 requires, in addition to a window handle, an absolute screen rectangle. Changes in the video widget's absolute screen position therefore need to be propagated into the MMF. This change introduces a new object, AncestorMoveMonitor, which installs an event filter on the QCoreApplication instance. A VideoOutput object registers with the AncestorMoveMonitor, which listens on its behalf for MoveEvents and ParentChangeEvents directed at any of the ancestors of the VideoOutput. MoveEvents trigger a callback to the VideoOutput instance, which then notifies the MMF of the new screen rectangle. ParentChangeEvents cause the AncestorMoveMonitor to update the ancestor list associated with the target VideoOutput instance. The video position now tracks that of the associated widget, but there are two problems which require further investigation: 1. The video window lags behind. This may be an unavoidable consequence of the fact that setting a new screen rectangle causes the MMF to tear down its DSA session and start a new one; this is known to block the window server and take some time to complete. 2. Artifacts are visible around the edges of the moving video widget. Task-number: QTBUG-4787 Reviewed-by: Frans Englich --- src/3rdparty/phonon/mmf/ancestormovemonitor.cpp | 175 ++++++++++++++++++++++++ src/3rdparty/phonon/mmf/ancestormovemonitor.h | 95 +++++++++++++ src/3rdparty/phonon/mmf/backend.cpp | 7 +- src/3rdparty/phonon/mmf/backend.h | 7 + src/3rdparty/phonon/mmf/videooutput.cpp | 30 +++- src/3rdparty/phonon/mmf/videooutput.h | 15 +- src/3rdparty/phonon/mmf/videowidget.cpp | 5 +- src/3rdparty/phonon/mmf/videowidget.h | 3 +- src/plugins/phonon/mmf/plugin/plugin.pro | 2 + 9 files changed, 328 insertions(+), 11 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/ancestormovemonitor.cpp create mode 100644 src/3rdparty/phonon/mmf/ancestormovemonitor.h diff --git a/src/3rdparty/phonon/mmf/ancestormovemonitor.cpp b/src/3rdparty/phonon/mmf/ancestormovemonitor.cpp new file mode 100644 index 0000000..876499c --- /dev/null +++ b/src/3rdparty/phonon/mmf/ancestormovemonitor.cpp @@ -0,0 +1,175 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include "ancestormovemonitor.h" +#include "utils.h" +#include "videooutput.h" + +#include + +QT_BEGIN_NAMESPACE + +using namespace Phonon::MMF; + +/*! \class MMF::AncestorMoveMonitor + \internal + \brief Class which installs a global event filter, and listens for move + events which may affect the absolute position of widgets registered with + the monitor + See QTBUG-4956 +*/ + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +AncestorMoveMonitor::AncestorMoveMonitor(QObject *parent) + : QObject(parent) +{ + QCoreApplication::instance()->installEventFilter(this); +} + +AncestorMoveMonitor::~AncestorMoveMonitor() +{ + QCoreApplication::instance()->removeEventFilter(this); +} + + +//----------------------------------------------------------------------------- +// Public functions +//----------------------------------------------------------------------------- + +void AncestorMoveMonitor::registerTarget(VideoOutput *target) +{ + TRACE_CONTEXT(AncestorMoveMonitor::registerTarget, EVideoInternal); + TRACE_ENTRY("target 0x%08x", target); + + // First un-register the target, in case this is being called as a result + // of re-parenting. This is not the most efficient way to update the + // target hash, but since this is not likely to be a frequent operation, + // simplicity is preferred over outright speed. In any case, re-parenting + // of the video widget leads to re-creation of native windows, which is + // likely to take far more processing than any implementation of this + // function. + unRegisterTarget(target); + + QWidget *ancestor = target->parentWidget(); + while(ancestor) { + const Hash::iterator it = m_hash.find(ancestor); + if(m_hash.end() == it) { + TargetList targetList; + targetList.append(target); + m_hash.insert(ancestor, targetList); + } else { + TargetList& targetList = it.value(); + Q_ASSERT(targetList.indexOf(target) == -1); + targetList.append(target); + } + ancestor = ancestor->parentWidget(); + } + + dump(); + + TRACE_EXIT_0(); +} + +void AncestorMoveMonitor::unRegisterTarget(VideoOutput *target) +{ + TRACE_CONTEXT(AncestorMoveMonitor::unRegisterTarget, EVideoInternal); + TRACE_ENTRY("target 0x%08x", target); + + Hash::iterator it = m_hash.begin(); + while(it != m_hash.end()) { + TargetList& targetList = it.value(); + const int index = targetList.indexOf(target); + if(index != -1) + targetList.removeAt(index); + if(targetList.count()) + ++it; + else + it = m_hash.erase(it); + } + + dump(); + + TRACE_EXIT_0(); +} + +bool AncestorMoveMonitor::eventFilter(QObject *watched, QEvent *event) +{ + TRACE_CONTEXT(AncestorMoveMonitor::eventFilter, EVideoInternal); + + if(event->type() == QEvent::Move || event->type() == QEvent::ParentChange) { + + TRACE_ENTRY("watched 0x%08x event.type %d", watched, event->type()); + + const Hash::const_iterator it = m_hash.find(watched); + if(it != m_hash.end()) { + const TargetList& targetList = it.value(); + VideoOutput* target = 0; + foreach(target, targetList) { + switch (event->type()) { + + case QEvent::Move: + // Notify the target that its ancestor has moved + target->ancestorMoved(); + break; + + case QEvent::ParentChange: + // Update ancestor list for the target + registerTarget(target); + break; + + default: + Q_ASSERT(false); + } + } + } + + TRACE_EXIT_0(); + } + + // The event is never consumed by this filter + return false; +} + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +void AncestorMoveMonitor::dump() +{ +#ifndef QT_NO_DEBUG + TRACE_CONTEXT(AncestorMoveMonitor::dump, EVideoInternal); + for(Hash::const_iterator it = m_hash.begin(); + it != m_hash.end(); ++it) { + const QObject *ancestor = it.key(); + TRACE("ancestor 0x%08x", ancestor); + const TargetList& targetList = it.value(); + VideoOutput* target = 0; + foreach(target, targetList) { + TRACE(" target 0x%08x", target); + } + } +#endif +} + + + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/ancestormovemonitor.h b/src/3rdparty/phonon/mmf/ancestormovemonitor.h new file mode 100644 index 0000000..0e681aa --- /dev/null +++ b/src/3rdparty/phonon/mmf/ancestormovemonitor.h @@ -0,0 +1,95 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_ANCESTORMOVEMONITOR_H +#define PHONON_MMF_ANCESTORMOVEMONITOR_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ +class VideoOutput; + +class AncestorMoveMonitor : public QObject +{ + Q_OBJECT + +public: + explicit AncestorMoveMonitor(QObject *parent); + ~AncestorMoveMonitor(); + + /** + * Register target widget for notification. + * + * The widget receives an ancestorMoveEvent callback when a move event + * is delivered to any of its ancestors: + * + * If the target is already registered, this function causes its + * ancestor list to be updated - therefore it should be called when + * the target receives a ParentChange event. + */ + void registerTarget(VideoOutput *target); + + /** + * Remove target from the monitor. + * + * The target will no longer receive notification when move events are + * delivered to its ancestors. + */ + void unRegisterTarget(VideoOutput *target); + +protected: + /** + * Function which receives events from the global event filter. + */ + bool eventFilter(QObject *watched, QEvent *event); + + void dump(); + +private: + /** + * List of registered target widgets which descend from a given + * ancestor. + * + * Note that the members of the list should be non-redundant; this + * invariant is checked in debug builds. Semantically, the value is + * therefore a set, however we use QList rather than QSet for + * efficiency of iteration. + */ + typedef QList TargetList; + + /** + * Map from widget on which the move event occurs, to widgets which + * descend from it and therefore need to be notified. + */ + typedef QHash Hash; + Hash m_hash; + +}; +} +} + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index f542ec9..cac27e3 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -24,6 +24,7 @@ along with this library. If not, see . #include // for TDataType #include "abstractaudioeffect.h" +#include "ancestormovemonitor.h" #include "audiooutput.h" #include "audioplayer.h" #include "backend.h" @@ -45,7 +46,9 @@ using namespace Phonon::MMF; \internal */ -Backend::Backend(QObject *parent) : QObject(parent) +Backend::Backend(QObject *parent) + : QObject(parent) + , m_ancestorMoveMonitor(new AncestorMoveMonitor(this)) { TRACE_CONTEXT(Backend::Backend, EBackend); TRACE_ENTRY_0(); @@ -87,7 +90,7 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const return EffectFactory::createAudioEffect(effect, parent); } case VideoWidgetClass: - result = new VideoWidget(qobject_cast(parent)); + result = new VideoWidget(m_ancestorMoveMonitor.data(), qobject_cast(parent)); break; default: diff --git a/src/3rdparty/phonon/mmf/backend.h b/src/3rdparty/phonon/mmf/backend.h index 1886ae6..9e3d3b3 100644 --- a/src/3rdparty/phonon/mmf/backend.h +++ b/src/3rdparty/phonon/mmf/backend.h @@ -19,8 +19,11 @@ along with this library. If not, see . #ifndef PHONON_MMF_BACKEND_H #define PHONON_MMF_BACKEND_H +#include "ancestormovemonitor.h" + #include #include +#include QT_BEGIN_NAMESPACE @@ -47,6 +50,10 @@ public: Q_SIGNALS: void objectDescriptionChanged(ObjectDescriptionType); + +private: + QScopedPointer m_ancestorMoveMonitor; + }; } } diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index f0393a7..5288b4d 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -16,6 +16,7 @@ along with this library. If not, see . */ +#include "ancestormovemonitor.h" #include "utils.h" #include "videooutput.h" #include "videooutputobserver.h" @@ -44,8 +45,10 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::VideoOutput::VideoOutput(QWidget* parent) +MMF::VideoOutput::VideoOutput + (AncestorMoveMonitor* ancestorMoveMonitor, QWidget* parent) : QWidget(parent) + , m_ancestorMoveMonitor(ancestorMoveMonitor) , m_observer(0) { TRACE_CONTEXT(VideoOutput::VideoOutput, EVideoInternal); @@ -63,6 +66,8 @@ MMF::VideoOutput::VideoOutput(QWidget* parent) // to be invisible when running on the target device. qt_widget_private(this)->extraData()->disableBlit = true; + registerForAncestorMoved(); + dump(); TRACE_EXIT_0(); @@ -73,6 +78,8 @@ MMF::VideoOutput::~VideoOutput() TRACE_CONTEXT(VideoOutput::~VideoOutput, EVideoInternal); TRACE_ENTRY_0(); + m_ancestorMoveMonitor->unRegisterTarget(this); + TRACE_EXIT_0(); } @@ -97,6 +104,15 @@ void MMF::VideoOutput::setObserver(VideoOutputObserver* observer) m_observer = observer; } +void MMF::VideoOutput::ancestorMoved() +{ + TRACE_CONTEXT(VideoOutput::ancestorMoved, EVideoInternal); + TRACE_ENTRY_0(); + + videoOutputRegionChanged(); + + TRACE_EXIT_0(); +} //----------------------------------------------------------------------------- // QWidget @@ -154,8 +170,11 @@ bool MMF::VideoOutput::event(QEvent* event) TRACE_0("WinIdChange"); videoOutputRegionChanged(); return true; - } - else + } else if (event->type() == QEvent::ParentChange) { + // Tell ancestor move monitor to update ancestor list for this widget + registerForAncestorMoved(); + return true; + } else return QWidget::event(event); } @@ -171,6 +190,11 @@ void MMF::VideoOutput::videoOutputRegionChanged() m_observer->videoOutputRegionChanged(); } +void MMF::VideoOutput::registerForAncestorMoved() +{ + m_ancestorMoveMonitor->registerTarget(this); +} + void MMF::VideoOutput::dump() const { #ifndef QT_NO_DEBUG diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h index 7bc0b52..db4d127 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -30,6 +30,7 @@ namespace Phonon { namespace MMF { +class AncestorMoveMonitor; class VideoOutputObserver; class VideoOutput : public QWidget @@ -37,12 +38,14 @@ class VideoOutput : public QWidget Q_OBJECT public: - explicit VideoOutput(QWidget* parent); + VideoOutput(AncestorMoveMonitor* ancestorMoveMonitor, QWidget* parent); ~VideoOutput(); void setFrameSize(const QSize& size); void setObserver(VideoOutputObserver* observer); + void ancestorMoved(); + protected: // Override QWidget functions QSize sizeHint() const; @@ -55,11 +58,17 @@ private: void dump() const; void videoOutputRegionChanged(); + void registerForAncestorMoved(); + private: - QSize m_frameSize; + // Not owned + AncestorMoveMonitor* m_ancestorMoveMonitor; // Not owned - VideoOutputObserver* m_observer; + VideoOutputObserver* m_observer; + + QSize m_frameSize; + }; } } diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index 8a5c9ff..7d7abf1 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -49,9 +49,10 @@ static const qreal DefaultSaturation = 1.0; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::VideoWidget::VideoWidget(QWidget* parent) +MMF::VideoWidget::VideoWidget + (AncestorMoveMonitor* ancestorMoveMonitor, QWidget* parent) : MediaNode(parent) - , m_widget(new VideoOutput(parent)) + , m_widget(new VideoOutput(ancestorMoveMonitor, parent)) , m_aspectRatio(DefaultAspectRatio) , m_brightness(DefaultBrightness) , m_scaleMode(DefaultScaleMode) diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h index 970f749..318dfae 100644 --- a/src/3rdparty/phonon/mmf/videowidget.h +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -31,6 +31,7 @@ namespace Phonon { namespace MMF { +class AncestorMoveMonitor; class VideoOutput; class VideoWidget : public MediaNode @@ -40,7 +41,7 @@ class VideoWidget : public MediaNode Q_INTERFACES(Phonon::VideoWidgetInterface) public: - VideoWidget(QWidget* parent); + VideoWidget(AncestorMoveMonitor* ancestorMoveMonitor, QWidget* parent); ~VideoWidget(); // VideoWidgetInterface diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro index eb7fd27..793c307 100644 --- a/src/plugins/phonon/mmf/plugin/plugin.pro +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -26,6 +26,7 @@ HEADERS += \ $$PHONON_MMF_DIR/abstractaudioeffect.h \ $$PHONON_MMF_DIR/abstractmediaplayer.h \ $$PHONON_MMF_DIR/abstractplayer.h \ + $$PHONON_MMF_DIR/ancestormovemonitor.h \ $$PHONON_MMF_DIR/audiooutput.h \ $$PHONON_MMF_DIR/audioequalizer.h \ $$PHONON_MMF_DIR/audioplayer.h \ @@ -47,6 +48,7 @@ SOURCES += \ $$PHONON_MMF_DIR/abstractaudioeffect.cpp \ $$PHONON_MMF_DIR/abstractmediaplayer.cpp \ $$PHONON_MMF_DIR/abstractplayer.cpp \ + $$PHONON_MMF_DIR/ancestormovemonitor.cpp \ $$PHONON_MMF_DIR/audiooutput.cpp \ $$PHONON_MMF_DIR/audioequalizer.cpp \ $$PHONON_MMF_DIR/audioplayer.cpp \ -- cgit v0.12 From 1c6bd7f61d2cbe0b8c0fa451f5f9a7efdfaf04c7 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Fri, 23 Oct 2009 14:16:38 +0300 Subject: Fixed softkey autotest build after 5370e5ff. Reviewed-by: axis --- tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp | 25 ++++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp index 6efa85b..87e0533 100644 --- a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp +++ b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp @@ -47,6 +47,10 @@ #include "qdialogbuttonbox.h" #include "private/qsoftkeymanager_p.h" +#ifdef Q_OS_SYMBIAN +#include "qsymbianevent.h" +#endif + #ifdef Q_WS_S60 static const int s60CommandStart = 6000; #endif @@ -69,6 +73,13 @@ private slots: void updateSoftKeysCompressed(); void handleCommand(); void checkSoftkeyEnableStates(); + +private: // utils + inline void simulateSymbianCommand(int command) + { + QSymbianEvent event1(QSymbianEvent::CommandEvent, command); + qApp->symbianProcessEvent(&event1); + }; }; class EventListener : public QObject @@ -167,8 +178,8 @@ void tst_QSoftKeyManager::handleCommand() // QTest::keyPress(&w, Qt::Key_Context1); // QTest::keyPress(&w, Qt::Key_Context2); - qApp->symbianHandleCommand(6000); - qApp->symbianHandleCommand(6001); + simulateSymbianCommand(6000); + simulateSymbianCommand(6001); QApplication::processEvents(); @@ -200,9 +211,9 @@ void tst_QSoftKeyManager::checkSoftkeyEnableStates() //disabled button gets none. for (int i = 0; i < 10; i++) { //simulate "Restore Defaults" softkey press - qApp->symbianHandleCommand(s60CommandStart); + simulateSymbianCommand(s60CommandStart); //simulate "help" softkey press - qApp->symbianHandleCommand(s60CommandStart + 1); + simulateSymbianCommand(s60CommandStart + 1); } QApplication::processEvents(); QCOMPARE(spy0.count(), 10); @@ -212,16 +223,16 @@ void tst_QSoftKeyManager::checkSoftkeyEnableStates() for (int i = 0; i < 10; i++) { //simulate "Restore Defaults" softkey press - qApp->symbianHandleCommand(s60CommandStart); + simulateSymbianCommand(s60CommandStart); //simulate "help" softkey press - qApp->symbianHandleCommand(s60CommandStart + 1); + simulateSymbianCommand(s60CommandStart + 1); //switch enabled button to disabled and vice versa pBHelp->setEnabled(!pBHelp->isEnabled()); pBDefaults->setEnabled(!pBDefaults->isEnabled()); } QApplication::processEvents(); QCOMPARE(spy0.count(), 5); - QCOMPARE(spy1.count(), 5); + QCOMPARE(spy1.count(), 5); } QTEST_MAIN(tst_QSoftKeyManager) -- cgit v0.12 From 58efa8aa5e845af2e3db840a8a654bd55fb98fb0 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Fri, 23 Oct 2009 11:52:05 +0200 Subject: Improve error handling. Errors reported via: * the DummyPlayer didn't work due to it not doing the usual state transitions/emission * MediaObject::setSource() due to errors being emitted before connections being set up. * A general state bug. Task-number: QTBUG-4752 Reviewed-by: Gareth Stockwell --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 36 +++++++++---------------- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 4 --- src/3rdparty/phonon/mmf/abstractplayer.cpp | 32 +++++++++++++++++++--- src/3rdparty/phonon/mmf/abstractplayer.h | 9 +++++-- src/3rdparty/phonon/mmf/dummyplayer.cpp | 9 ------- src/3rdparty/phonon/mmf/dummyplayer.h | 4 --- src/3rdparty/phonon/mmf/mediaobject.cpp | 14 ++++++---- 7 files changed, 57 insertions(+), 51 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index af2c31e..998e861 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -359,26 +359,27 @@ qint64 MMF::AbstractMediaPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds return in.Int64() / 1000; } +//----------------------------------------------------------------------------- +// Slots +//----------------------------------------------------------------------------- + +void MMF::AbstractMediaPlayer::tick() +{ + // For the MWC compiler, we need to qualify the base class. + emit MMF::AbstractPlayer::tick(currentTime()); +} + void MMF::AbstractMediaPlayer::changeState(PrivateState newState) { - TRACE_CONTEXT(AbstractPlayer::changeState, EAudioInternal); - TRACE_ENTRY("state %d newState %d", privateState(), newState); + TRACE_CONTEXT(AbstractMediaPlayer::changeState, EAudioInternal); // TODO: add some invariants to check that the transition is valid + AbstractPlayer::changeState(newState); const Phonon::State oldPhononState = phononState(privateState()); const Phonon::State newPhononState = phononState(newState); - if (oldPhononState != newPhononState) { - TRACE("emit stateChanged(%d, %d)", newPhononState, oldPhononState); - emit stateChanged(newPhononState, oldPhononState); - } - - setState(newState); - if ( - LoadingState == oldPhononState - and StoppedState == newPhononState - ) { + if (LoadingState == oldPhononState && StoppedState == newPhononState) { // Ensure initial volume is set on MMF API before starting playback doVolumeChanged(); @@ -391,17 +392,6 @@ void MMF::AbstractMediaPlayer::changeState(PrivateState newState) } } - TRACE_EXIT_0(); -} - -//----------------------------------------------------------------------------- -// Slots -//----------------------------------------------------------------------------- - -void MMF::AbstractMediaPlayer::tick() -{ - // For the MWC compiler, we need to qualify the base class. - emit MMF::AbstractPlayer::tick(currentTime()); } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 698b899..1ea236b 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -71,10 +71,6 @@ protected: virtual int setDeviceVolume(int mmfVolume) = 0; virtual int openFile(RFile& file) = 0; virtual void close() = 0; - - /** - * Changes state and emits stateChanged() - */ virtual void changeState(PrivateState newState); protected: diff --git a/src/3rdparty/phonon/mmf/abstractplayer.cpp b/src/3rdparty/phonon/mmf/abstractplayer.cpp index e3c0ecb..de2722d 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractplayer.cpp @@ -118,12 +118,14 @@ void MMF::AbstractPlayer::videoOutputChanged() // Default behaviour is empty - overridden by VideoPlayer } -void MMF::AbstractPlayer::setError(Phonon::ErrorType error) +void MMF::AbstractPlayer::setError(Phonon::ErrorType error, + const QString &errorMessage) { TRACE_CONTEXT(AbstractPlayer::setError, EAudioInternal); TRACE_ENTRY("state %d error %d", m_state, error); m_error = error; + m_errorString = errorMessage; changeState(ErrorState); TRACE_EXIT_0(); @@ -138,9 +140,7 @@ Phonon::ErrorType MMF::AbstractPlayer::errorType() const QString MMF::AbstractPlayer::errorString() const { - // TODO: put in proper error strings - QString result; - return result; + return m_errorString; } Phonon::State MMF::AbstractPlayer::phononState() const @@ -173,5 +173,29 @@ void MMF::AbstractPlayer::setState(PrivateState newState) m_state = newState; } +void MMF::AbstractPlayer::changeState(PrivateState newState) +{ + TRACE_CONTEXT(AbstractPlayer::changeState, EAudioInternal); + TRACE_ENTRY("state %d newState %d", privateState(), newState); + + // TODO: add some invariants to check that the transition is valid + + const Phonon::State oldPhononState = phononState(privateState()); + + // We need to change the state before we emit stateChanged(), because + // some user code, for instance the mediaplayer, switch on MediaObject's + // state. + setState(newState); + + const Phonon::State newPhononState = phononState(newState); + + if (oldPhononState != newPhononState) { + TRACE("emit stateChanged(%d, %d)", newPhononState, oldPhononState); + emit stateChanged(newPhononState, oldPhononState); + } + + TRACE_EXIT_0(); +} + QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 08558cf..1c4ea02 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -93,7 +93,8 @@ public: /** * Records error and changes state to ErrorState */ - void setError(Phonon::ErrorType error); + void setError(Phonon::ErrorType error, + const QString &errorMessage = QString()); Phonon::State state() const; Q_SIGNALS: @@ -132,7 +133,10 @@ protected: PrivateState privateState() const; - virtual void changeState(PrivateState newState) = 0; + /** + * Changes state and emits stateChanged() + */ + virtual void changeState(PrivateState newState); /** * Modifies m_state directly. Typically you want to call changeState(), @@ -152,6 +156,7 @@ protected: private: PrivateState m_state; Phonon::ErrorType m_error; + QString m_errorString; qint32 m_tickInterval; qint32 m_transitionTime; qint32 m_prefinishMark; diff --git a/src/3rdparty/phonon/mmf/dummyplayer.cpp b/src/3rdparty/phonon/mmf/dummyplayer.cpp index bd21d20..e6f3855 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.cpp +++ b/src/3rdparty/phonon/mmf/dummyplayer.cpp @@ -87,11 +87,6 @@ qint64 MMF::DummyPlayer::currentTime() const return 0; } -QString MMF::DummyPlayer::errorString() const -{ - return QString(); -} - Phonon::ErrorType MMF::DummyPlayer::errorType() const { return Phonon::NoError; @@ -127,9 +122,5 @@ void MMF::DummyPlayer::doSetTickInterval(qint32) } -void MMF::DummyPlayer::changeState(PrivateState) -{ -} - QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/dummyplayer.h b/src/3rdparty/phonon/mmf/dummyplayer.h index 9ff9f78..c6270c9 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.h +++ b/src/3rdparty/phonon/mmf/dummyplayer.h @@ -54,7 +54,6 @@ public: virtual bool isSeekable() const; virtual qint64 currentTime() const; virtual Phonon::State state() const; - virtual QString errorString() const; virtual Phonon::ErrorType errorType() const; virtual qint64 totalTime() const; virtual MediaSource source() const; @@ -64,9 +63,6 @@ public: // AbstractPlayer virtual void doSetTickInterval(qint32 interval); - -protected: - virtual void changeState(PrivateState newState); }; } } diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 29ac2df..74aaa58 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -239,6 +239,7 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) const bool oldPlayerSeekable = oldPlayer->isSeekable(); Phonon::ErrorType error = NoError; + QString errorMessage; // Determine media type switch (source.type()) { @@ -253,7 +254,7 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) mediaType = fileMediaType(url.toLocalFile()); } else { - TRACE_0("Network streaming not supported yet"); + errorMessage = QLatin1String("Network streaming not supported yet"); error = NormalError; } } @@ -286,7 +287,8 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) newPlayer = new DummyPlayer(); } - newPlayer->setError(NormalError); + error = NormalError; + errorMessage = tr("Media type could not be determined"); break; case MediaTypeAudio: @@ -321,9 +323,11 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished())); connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64))); - if (error != NoError ) { - newPlayer = new DummyPlayer(); - newPlayer->setError(error); + // We need to call setError() after doing the connects, otherwise the + // error won't be received. + if (error != NoError) { + Q_ASSERT(m_player); + m_player->setError(error, errorMessage); } TRACE_EXIT_0(); -- cgit v0.12 From 7ee0143a417678f7108838230c5ada3bbd62c6cc Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Fri, 23 Oct 2009 16:56:58 +0200 Subject: Fix build caused by merge error. --- demos/qmediaplayer/mediaplayer.h | 1 - 1 file changed, 1 deletion(-) diff --git a/demos/qmediaplayer/mediaplayer.h b/demos/qmediaplayer/mediaplayer.h index f3af7cc..08db0e5 100644 --- a/demos/qmediaplayer/mediaplayer.h +++ b/demos/qmediaplayer/mediaplayer.h @@ -93,7 +93,6 @@ public slots: void playPause(); void scaleChanged(QAction *); void aspectChanged(QAction *); - void hasVideoChanged(bool); private slots: void setAspect(int); -- cgit v0.12 From b14338cce8cb13003a4943d134502e085f36ab08 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Mon, 26 Oct 2009 09:07:39 +0100 Subject: Fix buglet in QGraphicsItem::stackBefore(). Reported by Alan. The stackBefore() implementation did not alter the insertion order if the two items' current Z values were different. The fix is to ensure it is updated, so that the stackBefore() operation takes effect should the Z values become equal in the future. Example: Current order: A-B-C-D A->setZValue(1); Current order: B-C-D-A (A moves to the end) D->stackBefore(A); Current order: B-C-D-A (unchanged, D is already before A) A->setZValue(0); Current order: D-A-B-C (now A moves back, and D moves in front) Reviewed-by: Aaron Kennedy --- src/gui/graphicsview/qgraphicsitem.cpp | 2 +- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 56 +++++++++++++------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 4b2ff52..ad672a3 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -4261,7 +4261,7 @@ void QGraphicsItem::stackBefore(const QGraphicsItem *sibling) // Only move items with the same Z value, and that need moving. int siblingIndex = sibling->d_ptr->siblingIndex; int myIndex = d_ptr->siblingIndex; - if (myIndex >= siblingIndex && d_ptr->z == sibling->d_ptr->z) { + if (myIndex >= siblingIndex) { siblings->move(myIndex, siblingIndex); // Fixup the insertion ordering. for (int i = 0; i < siblings->size(); ++i) { diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 4fae911..dabf64c 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -8569,24 +8569,24 @@ void tst_QGraphicsItem::stackBefore() QCOMPARE(parent.childItems(), (QList() << child1 << child3 << child4 << child2)); // Move child2 before child1 - child2->stackBefore(child1); + child2->stackBefore(child1); // 2134 QCOMPARE(parent.childItems(), (QList() << child2 << child1 << child3 << child4)); - child2->stackBefore(child2); + child2->stackBefore(child2); // 2134 QCOMPARE(parent.childItems(), (QList() << child2 << child1 << child3 << child4)); - child1->setZValue(1); + child1->setZValue(1); // 2341 QCOMPARE(parent.childItems(), (QList() << child2 << child3 << child4 << child1)); - child1->stackBefore(child2); // no effect + child1->stackBefore(child2); // 2341 QCOMPARE(parent.childItems(), (QList() << child2 << child3 << child4 << child1)); - child1->setZValue(0); - QCOMPARE(parent.childItems(), (QList() << child2 << child1 << child3 << child4)); - child4->stackBefore(child1); - QCOMPARE(parent.childItems(), (QList() << child2 << child4 << child1 << child3)); - child4->setZValue(1); - QCOMPARE(parent.childItems(), (QList() << child2 << child1 << child3 << child4)); - child3->stackBefore(child1); - QCOMPARE(parent.childItems(), (QList() << child2 << child3 << child1 << child4)); - child4->setZValue(0); - QCOMPARE(parent.childItems(), (QList() << child2 << child4 << child3 << child1)); + child1->setZValue(0); // 1234 + QCOMPARE(parent.childItems(), (QList() << child1 << child2 << child3 << child4)); + child4->stackBefore(child1); // 4123 + QCOMPARE(parent.childItems(), (QList() << child4 << child1 << child2 << child3)); + child4->setZValue(1); // 1234 (4123) + QCOMPARE(parent.childItems(), (QList() << child1 << child2 << child3 << child4)); + child3->stackBefore(child1); // 3124 (4312) + QCOMPARE(parent.childItems(), (QList() << child3 << child1 << child2 << child4)); + child4->setZValue(0); // 4312 + QCOMPARE(parent.childItems(), (QList() << child4 << child3 << child1 << child2)); // Make them all toplevels child1->setParentItem(0); @@ -8608,24 +8608,24 @@ void tst_QGraphicsItem::stackBefore() QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList() << child1 << child3 << child4 << child2)); // Move child2 before child1 - child2->stackBefore(child1); + child2->stackBefore(child1); // 2134 QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList() << child2 << child1 << child3 << child4)); - child2->stackBefore(child2); + child2->stackBefore(child2); // 2134 QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList() << child2 << child1 << child3 << child4)); - child1->setZValue(1); + child1->setZValue(1); // 2341 QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList() << child2 << child3 << child4 << child1)); - child1->stackBefore(child2); // no effect + child1->stackBefore(child2); // 2341 QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList() << child2 << child3 << child4 << child1)); - child1->setZValue(0); - QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList() << child2 << child1 << child3 << child4)); - child4->stackBefore(child1); - QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList() << child2 << child4 << child1 << child3)); - child4->setZValue(1); - QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList() << child2 << child1 << child3 << child4)); - child3->stackBefore(child1); - QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList() << child2 << child3 << child1 << child4)); - child4->setZValue(0); - QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList() << child2 << child4 << child3 << child1)); + child1->setZValue(0); // 1234 + QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList() << child1 << child2 << child3 << child4)); + child4->stackBefore(child1); // 4123 + QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList() << child4 << child1 << child2 << child3)); + child4->setZValue(1); // 1234 (4123) + QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList() << child1 << child2 << child3 << child4)); + child3->stackBefore(child1); // 3124 (4312) + QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList() << child3 << child1 << child2 << child4)); + child4->setZValue(0); // 4312 + QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList() << child4 << child3 << child1 << child2)); } void tst_QGraphicsItem::QTBUG_4233_updateCachedWithSceneRect() -- cgit v0.12 From 6c83dadea241f2e52d0cbcfa5c81e43c7eaeb90f Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 26 Oct 2009 08:36:38 +0100 Subject: Kill a tiny few sin/cos/sqrt calls in the new stroker Reviewed-by: Eskil --- src/opengl/gl2paintengineex/qtriangulatingstroker.cpp | 4 ++-- src/opengl/gl2paintengineex/qtriangulatingstroker_p.h | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp index a3c8266..a5a743f 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp @@ -130,8 +130,8 @@ void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen) if (m_roundness > 24) m_roundness = 24; - m_sin_theta = qSin(Q_PI / m_roundness); // ### Use qFastSin - m_cos_theta = qCos(Q_PI / m_roundness); + m_sin_theta = qFastSin(Q_PI / m_roundness); + m_cos_theta = qFastCos(Q_PI / m_roundness); const qreal *endPts = pts + (count<<1); const qreal *startPts; diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h index b7354db..ae56e87 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h @@ -124,7 +124,16 @@ inline void QTriangulatingStroker::normalVector(float x1, float y1, float x2, fl { float dx = x2 - x1; float dy = y2 - y1; - float pw = m_width / sqrt(dx*dx + dy*dy); + + float pw; + + if (dx == 0) + pw = m_width / dy; + else if (dy == 0) + pw = m_width / dx; + else + pw = m_width / sqrt(dx*dx + dy*dy); + *nx = -dy * pw; *ny = dx * pw; } -- cgit v0.12 From 4e55bb8a761cc3e246c539fc5f7cce103ed4d730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 23 Oct 2009 15:32:21 +0200 Subject: Made sure we invalidate the cache when the effect rect changes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When blurring and the blur radius increases we need a bigger effect rect to do within-pixmap-bounds filtering. Reviewed-by: Bjørn Erik Nilsen --- src/gui/effects/qgraphicseffect.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 96d35b0..383627e 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -353,8 +353,10 @@ void QGraphicsEffect::setEnabled(bool enable) return; d->isEnabled = enable; - if (d->source) + if (d->source) { d->source->d_func()->effectBoundingRectChanged(); + d->source->d_func()->invalidateCache(); + } emit enabledChanged(enable); } @@ -408,8 +410,10 @@ QGraphicsEffectSource *QGraphicsEffect::source() const void QGraphicsEffect::updateBoundingRect() { Q_D(QGraphicsEffect); - if (d->source) + if (d->source) { d->source->d_func()->effectBoundingRectChanged(); + d->source->d_func()->invalidateCache(); + } } /*! -- cgit v0.12 From 319482a6b33ce1bd365457054aca49a51d885e07 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 23 Oct 2009 09:14:39 +0200 Subject: Drag and drop in QListWidget would not preserve the selection Now, when dropping items, these will remain selected, and in the same visual order as when dragged. Auto-test included for the items moving part. For the rest, it's a drag-and-drop thing. Reviewed-by: Olivier --- src/gui/itemviews/qlistwidget.cpp | 31 ++++++++++------ src/gui/itemviews/qlistwidget_p.h | 3 +- tests/auto/qlistwidget/tst_qlistwidget.cpp | 59 ++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 13 deletions(-) diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp index a978d0f..5dd1d76 100644 --- a/src/gui/itemviews/qlistwidget.cpp +++ b/src/gui/itemviews/qlistwidget.cpp @@ -169,6 +169,20 @@ QListWidgetItem *QListModel::take(int row) return item; } +void QListModel::move(int srcRow, int dstRow) +{ + if (srcRow == dstRow + || srcRow < 0 || srcRow >= items.count() + || dstRow < 0 || dstRow >= items.count()) + return; + + beginMoveRows(QModelIndex(), srcRow, srcRow, QModelIndex(), dstRow); + if (srcRow < dstRow) + --dstRow; + items.move(srcRow, dstRow); + endMoveRows(); +} + int QListModel::rowCount(const QModelIndex &parent) const { return parent.isValid() ? 0 : items.count(); @@ -1804,22 +1818,15 @@ void QListWidget::dropEvent(QDropEvent *event) { if (persIndexes.contains(topIndex)) return; + qSort(persIndexes); // The dropped items will remain in the same visual order. QPersistentModelIndex dropRow = model()->index(row, col, topIndex); - QList taken; - for (int i = 0; i < persIndexes.count(); ++i) - taken.append(takeItem(persIndexes.at(i).row())); - - // insert them back in at their new positions + int r = row == -1 ? count() : (dropRow.row() >= 0 ? dropRow.row() : row); for (int i = 0; i < persIndexes.count(); ++i) { - // Either at a specific point or appended - if (row == -1) { - insertItem(count(), taken.takeFirst()); - } else { - int r = dropRow.row() >= 0 ? dropRow.row() : row; - insertItem(qMin(r, count()), taken.takeFirst()); - } + const QPersistentModelIndex &pIndex = persIndexes.at(i); + d->listModel()->move(pIndex.row(), r); + r = pIndex.row() + 1; // Dropped items are inserted contiguously and in the right order. } event->accept(); diff --git a/src/gui/itemviews/qlistwidget_p.h b/src/gui/itemviews/qlistwidget_p.h index 69cfa26..b5f28e3 100644 --- a/src/gui/itemviews/qlistwidget_p.h +++ b/src/gui/itemviews/qlistwidget_p.h @@ -77,7 +77,7 @@ public: { return *i2 < *i1; } }; -class QListModel : public QAbstractListModel +class Q_AUTOTEST_EXPORT QListModel : public QAbstractListModel { Q_OBJECT public: @@ -90,6 +90,7 @@ public: void insert(int row, const QStringList &items); void remove(QListWidgetItem *item); QListWidgetItem *take(int row); + void move(int srcRow, int dstRow); int rowCount(const QModelIndex &parent = QModelIndex()) const; diff --git a/tests/auto/qlistwidget/tst_qlistwidget.cpp b/tests/auto/qlistwidget/tst_qlistwidget.cpp index e825c8f..5c6ed54 100644 --- a/tests/auto/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/qlistwidget/tst_qlistwidget.cpp @@ -46,6 +46,7 @@ #include #include +#include //TESTED_CLASS= //TESTED_FILES= @@ -95,6 +96,8 @@ private slots: void insertItem(); void insertItems_data(); void insertItems(); + void moveItemsPriv_data(); + void moveItemsPriv(); void itemAssignment(); void item_data(); @@ -849,6 +852,62 @@ void tst_QListWidget::removeItems() } +void tst_QListWidget::moveItemsPriv_data() +{ + QTest::addColumn("rowCount"); + QTest::addColumn("srcRow"); + QTest::addColumn("dstRow"); + QTest::addColumn("shouldHaveSignaled"); + + QTest::newRow("Empty") << 0 << 0 << 0 << false; + QTest::newRow("Overflow src") << 5 << 5 << 2 << false; + QTest::newRow("Underflow src") << 5 << -1 << 2 << false; + QTest::newRow("Overflow dst") << 5 << 2 << 5 << false; + QTest::newRow("Underflow dst") << 5 << 2 << -1 << false; + QTest::newRow("Same place") << 5 << 2 << 2 << false; + QTest::newRow("Up") << 5 << 4 << 2 << true; + QTest::newRow("Down") << 5 << 2 << 4 << true; +} + +void tst_QListWidget::moveItemsPriv() +{ + QFETCH(int, rowCount); + QFETCH(int, srcRow); + QFETCH(int, dstRow); + QFETCH(bool, shouldHaveSignaled); + + for (int r = 0; r < rowCount; ++r) + new QListWidgetItem(QString::number(r), testWidget); + + QListModel *model = dynamic_cast(testWidget->model()); + QVERIFY(model); + QSignalSpy beginMoveSpy(model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy movedSpy(model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + model->move(srcRow, dstRow); + + if (shouldHaveSignaled) { + if (srcRow < dstRow) + QCOMPARE(testWidget->item(dstRow - 1)->text(), QString::number(srcRow)); + else + QCOMPARE(testWidget->item(dstRow)->text(), QString::number(srcRow)); + + QCOMPARE(beginMoveSpy.count(), 1); + const QList &beginMoveArgs = beginMoveSpy.takeFirst(); + QCOMPARE(beginMoveArgs.at(1).toInt(), srcRow); + QCOMPARE(beginMoveArgs.at(2).toInt(), srcRow); + QCOMPARE(beginMoveArgs.at(4).toInt(), dstRow); + + QCOMPARE(movedSpy.count(), 1); + const QList &movedArgs = movedSpy.takeFirst(); + QCOMPARE(movedArgs.at(1).toInt(), srcRow); + QCOMPARE(movedArgs.at(2).toInt(), srcRow); + QCOMPARE(movedArgs.at(4).toInt(), dstRow); + } else { + QCOMPARE(beginMoveSpy.count(), 0); + QCOMPARE(movedSpy.count(), 0); + } +} + void tst_QListWidget::itemStreaming_data() { QTest::addColumn("text"); -- cgit v0.12 From bc583eb7bcc11eaa778404bcf73d3f85315fe4ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 26 Oct 2009 11:57:37 +0100 Subject: Fix silly error in bit fiddling That's what I get for not having the brain on when accepting suggestions... Reviewed-by: Thiago Macieira --- src/corelib/io/qfsfileengine_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index d346685..6af5674 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -1264,7 +1264,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla size_t realSize = (size_t)size + extra; QT_OFF_T realOffset = QT_OFF_T(offset); - realOffset &= ~(QT_OFF_T(pageSize)); + realOffset &= ~(QT_OFF_T(pageSize - 1)); #ifdef Q_OS_SYMBIAN void *mapAddress; -- cgit v0.12 From c7e8c1844819bc9b078403f8cdbad9c104452a30 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 26 Oct 2009 12:52:30 +0100 Subject: Fixed typo Would not have introduced any bug as invald QModelIndex are currently initialised with -1 for row and column. Reviewed-by: trust me --- src/gui/itemviews/qitemselectionmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp index dfebe03..f2ccb6e 100644 --- a/src/gui/itemviews/qitemselectionmodel.cpp +++ b/src/gui/itemviews/qitemselectionmodel.cpp @@ -599,7 +599,7 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare while (itParent.isValid() && itParent.parent() != parent) itParent = itParent.parent(); - if (parent.isValid() && start <= itParent.row() && itParent.row() <= end) { + if (itParent.isValid() && start <= itParent.row() && itParent.row() <= end) { deselected.append(*it); it = ranges.erase(it); } else { -- cgit v0.12 From 26713a8b3fa4b82ea18c314c01b4d7ccb54d1125 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Mon, 26 Oct 2009 11:02:52 +0100 Subject: QDom: make tests fail only on Windows Reviewed-by: Carlos Duclos --- tests/auto/qdom/tst_qdom.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp index 0d58554e..f3a7909 100644 --- a/tests/auto/qdom/tst_qdom.cpp +++ b/tests/auto/qdom/tst_qdom.cpp @@ -322,7 +322,9 @@ void tst_QDom::toString_01_data() */ void tst_QDom::toString_01() { +#ifdef Q_OS_WIN QFAIL("make test fail instead of timing out, will be fixed later (QT-2357)"); +#endif QFETCH(QString, fileName); QFile f(fileName); -- cgit v0.12 From 085a994122afc05b0e94c1d035cfcd6d82bdf136 Mon Sep 17 00:00:00 2001 From: Trond Kjernaasen Date: Mon, 26 Oct 2009 13:24:13 +0100 Subject: Fixed PDF generation for Windows. Font names were not retrieved correctly after the QT_WA removal patch. The old code always used the GetTextOutlineA() API, except for WinCE, even when a Unicode compatible Windows platform was used. Reviewed-by: Kim --- src/gui/text/qfontengine_win.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp index fd34d0f..6c367ab 100644 --- a/src/gui/text/qfontengine_win.cpp +++ b/src/gui/text/qfontengine_win.cpp @@ -208,7 +208,7 @@ void QFontEngineWin::getCMap() unitsPerEm = otm->otmEMSquare; x_height = (int)otm->otmsXHeight; loadKerningPairs(designToDevice); - _faceId.filename = (char *)otm + (int)otm->otmpFullName; + _faceId.filename = QString::fromWCharArray((wchar_t *)((char *)otm + (int)otm->otmpFullName)).toLatin1(); lineWidth = otm->otmsUnderscoreSize; fsType = otm->otmfsType; free(otm); @@ -987,8 +987,8 @@ QFontEngine::Properties QFontEngineWin::properties() const Properties p; p.emSquare = unitsPerEm; p.italicAngle = otm->otmItalicAngle; - p.postscriptName = (char *)otm + (int)otm->otmpFamilyName; - p.postscriptName += (char *)otm + (int)otm->otmpStyleName; + p.postscriptName = QString::fromWCharArray((wchar_t *)((char *)otm + (int)otm->otmpFamilyName)).toLatin1(); + p.postscriptName += QString::fromWCharArray((wchar_t *)((char *)otm + (int)otm->otmpStyleName)).toLatin1(); #ifndef QT_NO_PRINTER p.postscriptName = QPdf::stripSpecialCharacters(p.postscriptName); #endif @@ -1110,7 +1110,7 @@ QNativeImage *QFontEngineWin::drawGDIGlyph(HFONT font, glyph_t glyph, int margin ih + 2 * margin + 4, QNativeImage::systemFormat(), !qt_cleartype_enabled); - /*If cleartype is enabled we use the standard system format even on Windows CE + /*If cleartype is enabled we use the standard system format even on Windows CE and not the special textbuffer format we have to use if cleartype is disabled*/ ni->image.fill(0xffffffff); -- cgit v0.12 From 9c78eb972041a066e455bf04d63f3290afacb982 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 26 Oct 2009 15:15:59 +0100 Subject: stabilize test and fix warning --- src/gui/kernel/qguiplatformplugin.cpp | 2 ++ tests/auto/qlistview/tst_qlistview.cpp | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qguiplatformplugin.cpp b/src/gui/kernel/qguiplatformplugin.cpp index 6e074a1..b01d40f 100644 --- a/src/gui/kernel/qguiplatformplugin.cpp +++ b/src/gui/kernel/qguiplatformplugin.cpp @@ -288,6 +288,8 @@ int QGuiPlatformPlugin::platformHint(PlatformHint hint) #endif //by default keep ret = 0 so QCommonStyle will use the style default break; + default: + break; } return ret; } diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 3968529..65ab12d 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -1785,12 +1785,12 @@ void tst_QListView::task262152_setModelColumnNavigate() view.show(); QTest::qWaitForWindowShown(&view); - QTest::qWait(10); + QTest::qWait(100); QTest::keyClick(&view, Qt::Key_Down); - QTest::qWait(10); + QTest::qWait(100); QCOMPARE(view.currentIndex(), model.index(1,1)); QTest::keyClick(&view, Qt::Key_Down); - QTest::qWait(10); + QTest::qWait(100); QCOMPARE(view.currentIndex(), model.index(2,1)); } -- cgit v0.12 From f6480ca465af9617956752e60d9be3a19b710e0f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 26 Oct 2009 16:09:30 +0100 Subject: Cocoa: Synthesize italic text correct way when adding glyphs to path On Mac OS X, Cocoa, we would synthesize italics on the text by slanting it in the incorrect direction (so it leaned to the left) when generating a path from the text, e.g. when printing. The patch makes the text slant the correct way, and the logic now becomes identical with the synthesized italics in the draw() function. Task-number: QTBUG-4969 Reviewed-by: Trond --- src/gui/text/qfontengine_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index 8ce437d..a4e7c04 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -546,7 +546,7 @@ void QCoreTextFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *position cgMatrix = CGAffineTransformScale(cgMatrix, 1, -1); if (synthesisFlags & QFontEngine::SynthesizedItalic) - cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, tanf(14 * acosf(0) / 90), 1, 0, 0)); + cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -tanf(14 * acosf(0) / 90), 1, 0, 0)); for (int i = 0; i < nGlyphs; ++i) { -- cgit v0.12 From 2d750192e73244f5b4ad6b451f264728d42669be Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 26 Oct 2009 15:53:47 +0100 Subject: Fixed crash when setting header data in QSqlQueryModel. The crash (Q_ASSERT_X failure) happened when a proxy model was being attached to the QSqlQueryModel, and no query was set yet. The headerDataChanged() signal was being received by the proxy model who wouldn't check its "proxyfied" data bounds. The patch introduces a behaviour change. However, this change makes the usage of QSqlQueryModel::setHeaderData() to be more in accordance with the current documentation, and to behave in the same way as for QStandardItemModel, QTreeModel, and QTableModel. Task-number: QTBUG-4963 Reviewed-by: Olivier --- src/sql/models/qsqlquerymodel.cpp | 2 +- tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/sql/models/qsqlquerymodel.cpp b/src/sql/models/qsqlquerymodel.cpp index a72ad8c..1719239 100644 --- a/src/sql/models/qsqlquerymodel.cpp +++ b/src/sql/models/qsqlquerymodel.cpp @@ -417,7 +417,7 @@ bool QSqlQueryModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) { Q_D(QSqlQueryModel); - if (orientation != Qt::Horizontal || section < 0) + if (orientation != Qt::Horizontal || section < 0 || columnCount() <= section) return false; if (d->headers.size() <= section) diff --git a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp index 3131f35..02b48fa 100644 --- a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp +++ b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp @@ -96,6 +96,7 @@ private slots: void task_180617(); void task_180617_data() { generic_data(); } + void task_QTBUG_4963_setHeaderDataWithProxyModel(); private: void generic_data(const QString &engine=QString()); @@ -428,6 +429,8 @@ void tst_QSqlQueryModel::setHeaderData() QVERIFY(!model.setHeaderData(5, Qt::Vertical, "foo")); QVERIFY(model.headerData(5, Qt::Vertical).isValid()); + model.setQuery(QSqlQuery("select * from " + qTableName("test"), db)); + qRegisterMetaType("Qt::Orientation"); QSignalSpy spy(&model, SIGNAL(headerDataChanged(Qt::Orientation, int, int))); QVERIFY(model.setHeaderData(2, Qt::Horizontal, "bar")); @@ -437,10 +440,8 @@ void tst_QSqlQueryModel::setHeaderData() QCOMPARE(spy.value(0).value(1).toInt(), 2); QCOMPARE(spy.value(0).value(2).toInt(), 2); - QVERIFY(model.setHeaderData(7, Qt::Horizontal, "foo", Qt::ToolTipRole)); - QVERIFY(model.headerData(7, Qt::Horizontal, Qt::ToolTipRole).isValid()); - - model.setQuery(QSqlQuery("select * from " + qTableName("test"), db)); + QVERIFY(!model.setHeaderData(7, Qt::Horizontal, "foo", Qt::ToolTipRole)); + QVERIFY(!model.headerData(7, Qt::Horizontal, Qt::ToolTipRole).isValid()); bool isToUpper = db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"); QCOMPARE(model.headerData(0, Qt::Horizontal).toString(), isToUpper ? QString("ID") : QString("id")); @@ -603,5 +604,14 @@ void tst_QSqlQueryModel::task_180617() QCOMPARE(view.rowAt(0), -1); } +void tst_QSqlQueryModel::task_QTBUG_4963_setHeaderDataWithProxyModel() +{ + QSqlQueryModel plainModel; + QSortFilterProxyModel proxyModel; + proxyModel.setSourceModel(&plainModel); + QVERIFY(!plainModel.setHeaderData(0, Qt::Horizontal, QObject::tr("ID"))); + // And it should not crash. +} + QTEST_MAIN(tst_QSqlQueryModel) #include "tst_qsqlquerymodel.moc" -- cgit v0.12 From 96f59cb98c248185a3873f06d0e1a2e7652d8cec Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Mon, 19 Oct 2009 07:30:52 -0300 Subject: QGAL: complex anchors can indicate errors when refreshing sizehint Now the refreshSizeHints() returns a boolean, and the parallel anchor will return false in unfeasible cases, e.g. one anchor has maximum size smaller than other minimum size. Signed-off-by: Caio Marcelo de Oliveira Filho Reviewed-by: Eduardo M. Fleury --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 43 ++++++++++++++---------- src/gui/graphicsview/qgraphicsanchorlayout_p.h | 10 +++--- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 8c8c303..a92a63e 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -141,7 +141,7 @@ static void internalSizeHints(QSizePolicy::Policy policy, *expSize = *prefSize; } -void AnchorData::refreshSizeHints(qreal effectiveSpacing) +bool AnchorData::refreshSizeHints(qreal effectiveSpacing) { const bool isInternalAnchor = from->m_item == to->m_item; @@ -164,7 +164,7 @@ void AnchorData::refreshSizeHints(qreal effectiveSpacing) maxSize = QWIDGETSIZE_MAX; if (hasCenter) maxSize /= 2; - return; + return true; } else { QGraphicsLayoutItem *item = from->m_item; @@ -214,6 +214,8 @@ void AnchorData::refreshSizeHints(qreal effectiveSpacing) sizeAtPreferred = prefSize; sizeAtExpanding = prefSize; sizeAtMaximum = prefSize; + + return true; } void ParallelAnchorData::updateChildrenSizes() @@ -227,26 +229,29 @@ void ParallelAnchorData::updateChildrenSizes() secondEdge->updateChildrenSizes(); } -void ParallelAnchorData::refreshSizeHints(qreal effectiveSpacing) +bool ParallelAnchorData::refreshSizeHints(qreal effectiveSpacing) { - refreshSizeHints_helper(effectiveSpacing); + return refreshSizeHints_helper(effectiveSpacing); } -void ParallelAnchorData::refreshSizeHints_helper(qreal effectiveSpacing, +bool ParallelAnchorData::refreshSizeHints_helper(qreal effectiveSpacing, bool refreshChildren) { - if (refreshChildren) { - firstEdge->refreshSizeHints(effectiveSpacing); - secondEdge->refreshSizeHints(effectiveSpacing); + if (refreshChildren && (!firstEdge->refreshSizeHints(effectiveSpacing) + || !secondEdge->refreshSizeHints(effectiveSpacing))) { + return false; } - // ### should we warn if the parallel connection is invalid? - // e.g. 1-2-3 with 10-20-30, the minimum of the latter is - // bigger than the maximum of the former. - minSize = qMax(firstEdge->minSize, secondEdge->minSize); maxSize = qMin(firstEdge->maxSize, secondEdge->maxSize); + // This condition means that the maximum size of one anchor being simplified is smaller than + // the minimum size of the other anchor. The consequence is that there won't be a valid size + // for this parallel setup. + if (minSize > maxSize) { + return false; + } + expSize = qMax(firstEdge->expSize, secondEdge->expSize); expSize = qMin(expSize, maxSize); @@ -258,6 +263,8 @@ void ParallelAnchorData::refreshSizeHints_helper(qreal effectiveSpacing, sizeAtPreferred = prefSize; sizeAtExpanding = prefSize; sizeAtMaximum = prefSize; + + return true; } /*! @@ -362,12 +369,12 @@ void SequentialAnchorData::updateChildrenSizes() } } -void SequentialAnchorData::refreshSizeHints(qreal effectiveSpacing) +bool SequentialAnchorData::refreshSizeHints(qreal effectiveSpacing) { - refreshSizeHints_helper(effectiveSpacing); + return refreshSizeHints_helper(effectiveSpacing); } -void SequentialAnchorData::refreshSizeHints_helper(qreal effectiveSpacing, +bool SequentialAnchorData::refreshSizeHints_helper(qreal effectiveSpacing, bool refreshChildren) { minSize = 0; @@ -379,8 +386,8 @@ void SequentialAnchorData::refreshSizeHints_helper(qreal effectiveSpacing, AnchorData *edge = m_edges.at(i); // If it's the case refresh children information first - if (refreshChildren) - edge->refreshSizeHints(effectiveSpacing); + if (refreshChildren && !edge->refreshSizeHints(effectiveSpacing)) + return false; minSize += edge->minSize; prefSize += edge->prefSize; @@ -393,6 +400,8 @@ void SequentialAnchorData::refreshSizeHints_helper(qreal effectiveSpacing, sizeAtPreferred = prefSize; sizeAtExpanding = prefSize; sizeAtMaximum = prefSize; + + return true; } #ifdef QT_DEBUG diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index d45c004..d4eb2d4 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -159,7 +159,7 @@ struct AnchorData : public QSimplexVariable { type(Normal), hasSize(true), isLayoutAnchor(false) {} virtual void updateChildrenSizes() {} - virtual void refreshSizeHints(qreal effectiveSpacing); + virtual bool refreshSizeHints(qreal effectiveSpacing); virtual ~AnchorData() {} @@ -226,9 +226,9 @@ struct SequentialAnchorData : public AnchorData } virtual void updateChildrenSizes(); - virtual void refreshSizeHints(qreal effectiveSpacing); + virtual bool refreshSizeHints(qreal effectiveSpacing); - void refreshSizeHints_helper(qreal effectiveSpacing, bool refreshChildren = true); + bool refreshSizeHints_helper(qreal effectiveSpacing, bool refreshChildren = true); void setVertices(const QVector &vertices) { @@ -261,9 +261,9 @@ struct ParallelAnchorData : public AnchorData } virtual void updateChildrenSizes(); - virtual void refreshSizeHints(qreal effectiveSpacing); + virtual bool refreshSizeHints(qreal effectiveSpacing); - void refreshSizeHints_helper(qreal effectiveSpacing, bool refreshChildren = true); + bool refreshSizeHints_helper(qreal effectiveSpacing, bool refreshChildren = true); AnchorData* firstEdge; AnchorData* secondEdge; -- cgit v0.12 From 3b025f72636041f7bfe1bf02b34e3b156a78844f Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Fri, 16 Oct 2009 17:40:02 -0300 Subject: QGAL: separate parallel anchor creation from sequence creation Extract the creation of parallel anchors from the creation of sequential anchor. This will be useful to keep track whether a parallel anchor is feasible or not. Signed-off-by: Caio Marcelo de Oliveira Filho Reviewed-by: Eduardo M. Fleury --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 90 ++++++++++++++++-------- 1 file changed, 61 insertions(+), 29 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index a92a63e..8b7ff08 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -519,18 +519,51 @@ inline static qreal checkAdd(qreal a, qreal b) } /*! - * \internal - * - * Takes the sequence of vertices described by (\a before, \a vertices, \a after) and replaces - * all anchors connected to the vertices in \a vertices with one simplified anchor between - * \a before and \a after. The simplified anchor will be a placeholder for all the previous - * anchors between \a before and \a after, and can be restored back to the anchors it is a - * placeholder for. - */ -static bool simplifySequentialChunk(Graph *graph, - AnchorVertex *before, - const QVector &vertices, - AnchorVertex *after) + \internal + + Adds \a newAnchor to the graph \a g. + + Returns the newAnchor itself if it could be added without further changes to the graph. If a + new parallel anchor had to be created, then returns the new parallel anchor. In case the + addition is unfeasible -- because a parallel setup is not possible, returns 0. +*/ +static AnchorData *addAnchorMaybeParallel(Graph *g, + AnchorData *newAnchor) +{ + bool feasible = true; + + // If already exists one anchor where newAnchor is supposed to be, we create a parallel + // anchor. + if (AnchorData *oldAnchor = g->takeEdge(newAnchor->from, newAnchor->to)) { + ParallelAnchorData *parallel = new ParallelAnchorData(oldAnchor, newAnchor); + parallel->isLayoutAnchor = (oldAnchor->isLayoutAnchor + || newAnchor->isLayoutAnchor); + + // At this point we can identify that the parallel anchor is not feasible, e.g. one + // anchor minimum size is bigger than the other anchor maximum size. + feasible = parallel->refreshSizeHints_helper(0, false); + newAnchor = parallel; + } + + g->createEdge(newAnchor->from, newAnchor->to, newAnchor); + return feasible ? newAnchor : 0; +} + + +/*! + \internal + + Takes the sequence of vertices described by (\a before, \a vertices, \a after) and removes + all anchors connected to the vertices in \a vertices, returning one simplified anchor between + \a before and \a after. + + Note that this function doesn't add the created anchor to the graph. This should be done by + the caller. +*/ +static AnchorData *createSequence(Graph *graph, + AnchorVertex *before, + const QVector &vertices, + AnchorVertex *after) { AnchorData *data = graph->edgeData(before, vertices.first()); Q_ASSERT(data); @@ -578,18 +611,7 @@ static bool simplifySequentialChunk(Graph *graph, sequence->isLayoutAnchor = (sequence->m_edges.first()->isLayoutAnchor || sequence->m_edges.last()->isLayoutAnchor); - AnchorData *newAnchor = sequence; - if (AnchorData *oldAnchor = graph->takeEdge(before, after)) { - ParallelAnchorData *parallel = new ParallelAnchorData(oldAnchor, sequence); - parallel->isLayoutAnchor = (oldAnchor->isLayoutAnchor - || sequence->isLayoutAnchor); - parallel->refreshSizeHints_helper(0, false); - newAnchor = parallel; - } - graph->createEdge(before, after, newAnchor); - - // True if we created a parallel anchor - return newAnchor != sequence; + return sequence; } /*! @@ -803,11 +825,21 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP continue; } - // This function will remove the candidates from the graph and create one edge between - // beforeSequence and afterSequence. This function returns true if the sequential - // simplification also caused a parallel simplification to be created. In this case we end - // the iteration and start again (since all the visited state we have may be outdated). - if (simplifySequentialChunk(&g, beforeSequence, candidates, afterSequence)) + // + // Add the sequence to the graph. + // + + AnchorData *sequence = createSequence(&g, beforeSequence, candidates, afterSequence); + + // If 'beforeSequence' and 'afterSequence' already had an anchor between them, we'll + // create a parallel anchor between the new sequence and the old anchor. + AnchorData *newAnchor = addAnchorMaybeParallel(&g, sequence); + + // When a new parallel anchor is create in the graph, we finish the iteration and return + // true to indicate a new iteration is needed. This happens because a parallel anchor + // changes the number of adjacents one vertex has, possibly opening up oportunities for + // building candidate lists (when adjacents == 2). + if (newAnchor != sequence) return true; // If there was no parallel simplification, we'll keep walking the graph. So we clear the -- cgit v0.12 From f9dfd711d104bb438da6ea281012600a897ab30c Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Mon, 19 Oct 2009 11:10:31 -0300 Subject: QGAL: identify unfeasible setups even when graph is simplified The calculate graphs now can return early due to unfeasible anchor setups found out during simplification. This allows finding out problems in parallel anchors, when one anchor has maximum size smaller than the minimum size of the other anchor. The order for simplification and refreshing size hints also has been swaped: - First, refresh size hints for all anchors in the graph. If the graph is simplified, the refreshSizeHints() call will reach the children anchors. - Then, if the simplificated graph is invalid, rebuild it. During this rebuild, refreshSizeHints_helper() will be called for all levels. So in both situations we can identify an unfeasible setup. Note that this test alone is not enough to classify the graph as feasible, depending on the graph, it will still need to go through the Simplex. A test case was added and the function that traverse the graph refreshing now is called refreshAllSizeHints(). The old name was not so clear since the function will not fill only the anchors that have items associated. Last but not least, the lastCalculationUsedSimplex variable is cleared when starting calculateGraphs(), since we now can leave the function earlier, without reaching calculateTrunk(), which is the function that sets it. Signed-off-by: Caio Marcelo de Oliveira Filho Reviewed-by: Eduardo M. Fleury --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 99 +++++++++++++++------- src/gui/graphicsview/qgraphicsanchorlayout_p.h | 6 +- .../tst_qgraphicsanchorlayout.cpp | 51 +++++++++++ 3 files changed, 122 insertions(+), 34 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 8b7ff08..8d13b2b 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -648,15 +648,17 @@ static AnchorData *createSequence(Graph *graph, 2. Go to (1) 3. Done + When creating the parallel anchors, the algorithm might identify unfeasible situations. In this + case the simplification process stops and returns false. Otherwise returns true. */ -void QGraphicsAnchorLayoutPrivate::simplifyGraph(Orientation orientation) +bool QGraphicsAnchorLayoutPrivate::simplifyGraph(Orientation orientation) { static bool noSimplification = !qgetenv("QT_ANCHORLAYOUT_NO_SIMPLIFICATION").isEmpty(); if (noSimplification || items.isEmpty()) - return; + return true; if (graphSimplified[orientation]) - return; + return true; graphSimplified[orientation] = true; #if 0 @@ -665,12 +667,18 @@ void QGraphicsAnchorLayoutPrivate::simplifyGraph(Orientation orientation) #endif if (!graph[orientation].rootVertex()) - return; + return true; bool dirty; + bool feasible = true; do { - dirty = simplifyGraphIteration(orientation); - } while (dirty); + dirty = simplifyGraphIteration(orientation, &feasible); + } while (dirty && feasible); + + if (!feasible) + graphSimplified[orientation] = false; + + return feasible; } /*! @@ -687,7 +695,8 @@ void QGraphicsAnchorLayoutPrivate::simplifyGraph(Orientation orientation) Note that there are some catches to this that are not covered by the above explanation, see the function comments for more details. */ -bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutPrivate::Orientation orientation) +bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutPrivate::Orientation orientation, + bool *feasible) { Q_Q(QGraphicsAnchorLayout); Graph &g = graph[orientation]; @@ -835,6 +844,11 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP // create a parallel anchor between the new sequence and the old anchor. AnchorData *newAnchor = addAnchorMaybeParallel(&g, sequence); + if (!newAnchor) { + *feasible = false; + return false; + } + // When a new parallel anchor is create in the graph, we finish the iteration and return // true to indicate a new iteration is needed. This happens because a parallel anchor // changes the number of adjacents one vertex has, possibly opening up oportunities for @@ -1679,38 +1693,52 @@ QList getVariables(QList constraints) } /*! - \internal + \internal - Calculate graphs is the method that puts together all the helper routines - so that the AnchorLayout can calculate the sizes of each item. + Calculate graphs is the method that puts together all the helper routines + so that the AnchorLayout can calculate the sizes of each item. - In a nutshell it should do: + In a nutshell it should do: - 1) Update anchor nominal sizes, that is, the size that each anchor would - have if no other restrictions applied. This is done by quering the - layout style and the sizeHints of the items belonging to the layout. + 1) Refresh anchor nominal sizes, that is, the size that each anchor would + have if no other restrictions applied. This is done by quering the + layout style and the sizeHints of the items belonging to the layout. - 2) Simplify the graph by grouping together parallel and sequential anchors - into "group anchors". These have equivalent minimum, preferred and maximum - sizeHints as the anchors they replace. + 2) Simplify the graph by grouping together parallel and sequential anchors + into "group anchors". These have equivalent minimum, preferred and maximum + sizeHints as the anchors they replace. - 3) Check if we got to a trivial case. In some cases, the whole graph can be - simplified into a single anchor. If so, use this information. If not, - then call the Simplex solver to calculate the anchors sizes. + 3) Check if we got to a trivial case. In some cases, the whole graph can be + simplified into a single anchor. If so, use this information. If not, + then call the Simplex solver to calculate the anchors sizes. - 4) Once the root anchors had its sizes calculated, propagate that to the - anchors they represent. + 4) Once the root anchors had its sizes calculated, propagate that to the + anchors they represent. */ void QGraphicsAnchorLayoutPrivate::calculateGraphs( QGraphicsAnchorLayoutPrivate::Orientation orientation) { Q_Q(QGraphicsAnchorLayout); - // Simplify the graph - simplifyGraph(orientation); +#if defined(QT_DEBUG) || defined(Q_AUTOTEST_EXPORT) + lastCalculationUsedSimplex[orientation] = false; +#endif + + // Reset the nominal sizes of each anchor based on the current item sizes. This function + // works with both simplified and non-simplified graphs, so it'll work when the + // simplification is going to be reused. + if (!refreshAllSizeHints(orientation)) { + qWarning("QGraphicsAnchorLayout: anchor setup is not feasible."); + graphHasConflicts[orientation] = true; + return; + } - // Reset the nominal sizes of each anchor based on the current item sizes - setAnchorSizeHintsFromItems(orientation); + // Simplify the graph + if (!simplifyGraph(orientation)) { + qWarning("QGraphicsAnchorLayout: anchor setup is not feasible."); + graphHasConflicts[orientation] = true; + return; + } // Traverse all graph edges and store the possible paths to each vertex findPaths(orientation); @@ -1878,12 +1906,16 @@ bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk(const QList &g = graph[orientation]; QList > vertices = g.connections(); @@ -1893,8 +1925,13 @@ void QGraphicsAnchorLayoutPrivate::setAnchorSizeHintsFromItems(Orientation orien for (int i = 0; i < vertices.count(); ++i) { AnchorData *data = g.edgeData(vertices.at(i).first, vertices.at(i).second);; Q_ASSERT(data->from && data->to); - data->refreshSizeHints(spacing); + + // During the traversal we check the feasibility of the complex anchors. + if (!data->refreshSizeHints(spacing)) + return false; } + + return true; } /*! diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index d4eb2d4..a3de6f6 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -428,8 +428,8 @@ public: qreal effectiveSpacing(Orientation orientation) const; // Activation methods - void simplifyGraph(Orientation orientation); - bool simplifyGraphIteration(Orientation orientation); + bool simplifyGraph(Orientation orientation); + bool simplifyGraphIteration(Orientation orientation, bool *feasible); void restoreSimplifiedGraph(Orientation orientation); void calculateGraphs(); @@ -441,7 +441,7 @@ public: bool calculateNonTrunk(const QList &constraints, const QList &variables); - void setAnchorSizeHintsFromItems(Orientation orientation); + bool refreshAllSizeHints(Orientation orientation); void findPaths(Orientation orientation); void constraintsFromPaths(Orientation orientation); void updateAnchorSizes(Orientation orientation); diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 7b87969..facc1ef 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -82,6 +82,7 @@ private slots: void expandingParallel(); void floatConflict(); void infiniteMaxSizes(); + void simplifiableUnfeasible(); }; class RectWidget : public QGraphicsWidget @@ -1755,5 +1756,55 @@ void tst_QGraphicsAnchorLayout::infiniteMaxSizes() QCOMPARE(d->geometry(), QRectF(QWIDGETSIZE_MAX - 50, 0, 50, 10)); } +void tst_QGraphicsAnchorLayout::simplifiableUnfeasible() +{ + QGraphicsWidget *a = createItem(QSizeF(70.0, 100.0), + QSizeF(100.0, 100.0), + QSizeF(100.0, 100.0), "A"); + + QGraphicsWidget *b = createItem(QSizeF(110.0, 100.0), + QSizeF(150.0, 100.0), + QSizeF(190.0, 100.0), "B"); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 0, 0, 0); + l->setSpacing(0); + + l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop); + l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop); + l->addAnchor(b, Qt::AnchorBottom, l, Qt::AnchorBottom); + + l->addAnchors(l, a, Qt::Horizontal); + l->addAnchor(l, Qt::AnchorLeft, b, Qt::AnchorLeft); + l->addAnchor(b, Qt::AnchorRight, a, Qt::AnchorRight); + + QCOMPARE(l->count(), 2); + + QGraphicsWidget p; + p.setLayout(l); + + l->invalidate(); + QVERIFY(layoutHasConflict(l)); + if (hasSimplification) + QVERIFY(!usedSimplex(l, Qt::Horizontal)); + + // Now we make it valid again + b->setMinimumWidth(100); + + l->invalidate(); + QVERIFY(!layoutHasConflict(l)); + if (hasSimplification) + QVERIFY(!usedSimplex(l, Qt::Horizontal)); + + // And make it invalid again + a->setPreferredWidth(70); + a->setMaximumWidth(70); + + l->invalidate(); + QVERIFY(layoutHasConflict(l)); + if (hasSimplification) + QVERIFY(!usedSimplex(l, Qt::Horizontal)); +} + QTEST_MAIN(tst_QGraphicsAnchorLayout) #include "tst_qgraphicsanchorlayout.moc" -- cgit v0.12 From bee00ac4ca0865e621edaea54d079005c68f120e Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Fri, 16 Oct 2009 12:26:21 -0300 Subject: QGAL: store item and center-ness information in the anchor We used to look for this information in the anchor's from and to vertices, but to enable simplification of vertices, we have to store this information in the anchor. Signed-off-by: Caio Marcelo de Oliveira Filho Reviewed-by: Eduardo M. Fleury --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 24 ++++++++++++------------ src/gui/graphicsview/qgraphicsanchorlayout_p.h | 9 +++++++-- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 8d13b2b..aa510f1 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -143,31 +143,25 @@ static void internalSizeHints(QSizePolicy::Policy policy, bool AnchorData::refreshSizeHints(qreal effectiveSpacing) { - const bool isInternalAnchor = from->m_item == to->m_item; - QSizePolicy::Policy policy; qreal minSizeHint; qreal prefSizeHint; qreal maxSizeHint; - if (isInternalAnchor) { + // It is an internal anchor + if (item) { const QGraphicsAnchorLayoutPrivate::Orientation orient = QGraphicsAnchorLayoutPrivate::edgeOrientation(from->m_edge); - const Qt::AnchorPoint centerEdge = - QGraphicsAnchorLayoutPrivate::pickEdge(Qt::AnchorHorizontalCenter, orient); - bool hasCenter = (from->m_edge == centerEdge || to->m_edge == centerEdge); if (isLayoutAnchor) { minSize = 0; prefSize = 0; expSize = 0; maxSize = QWIDGETSIZE_MAX; - if (hasCenter) + if (isCenterAnchor) maxSize /= 2; return true; } else { - - QGraphicsLayoutItem *item = from->m_item; if (orient == QGraphicsAnchorLayoutPrivate::Horizontal) { policy = item->sizePolicy().horizontalPolicy(); minSizeHint = item->effectiveSizeHint(Qt::MinimumSize).width(); @@ -180,7 +174,7 @@ bool AnchorData::refreshSizeHints(qreal effectiveSpacing) maxSizeHint = item->effectiveSizeHint(Qt::MaximumSize).height(); } - if (hasCenter) { + if (isCenterAnchor) { minSizeHint /= 2; prefSizeHint /= 2; maxSizeHint /= 2; @@ -1063,11 +1057,13 @@ void QGraphicsAnchorLayoutPrivate::createCenterAnchors( AnchorData *data = new AnchorData; c->variables.insert(data, 1.0); addAnchor_helper(item, firstEdge, item, centerEdge, data); + data->isCenterAnchor = true; data->refreshSizeHints(0); data = new AnchorData; c->variables.insert(data, -1.0); addAnchor_helper(item, centerEdge, item, lastEdge, data); + data->isCenterAnchor = true; data->refreshSizeHints(0); itemCenterConstraints[orientation].append(c); @@ -1304,6 +1300,10 @@ void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstIt removeAnchor_helper(v1, v2); } + // If its an internal anchor, set the associated item + if (firstItem == secondItem) + data->item = firstItem; + // Create a bi-directional edge in the sense it can be transversed both // from v1 or v2. "data" however is shared between the two references // so we still know that the anchor direction is from 1 to 2. @@ -2188,8 +2188,8 @@ void QGraphicsAnchorLayoutPrivate::identifyNonFloatItems_helper(const AnchorData switch(ad->type) { case AnchorData::Normal: - if (ad->from->m_item == ad->to->m_item && ad->to->m_item != q) - nonFloatingItemsIdentifiedSoFar->insert(ad->to->m_item); + if (ad->item && ad->item != q) + nonFloatingItemsIdentifiedSoFar->insert(ad->item); break; case AnchorData::Sequential: foreach (const AnchorData *d, static_cast(ad)->m_edges) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index a3de6f6..511e1ec 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -151,12 +151,13 @@ struct AnchorData : public QSimplexVariable { }; AnchorData() - : QSimplexVariable(), from(0), to(0), + : QSimplexVariable(), item(0), from(0), to(0), minSize(0), prefSize(0), expSize(0), maxSize(0), sizeAtMinimum(0), sizeAtPreferred(0), sizeAtExpanding(0), sizeAtMaximum(0), graphicsAnchor(0), skipInPreferred(0), - type(Normal), hasSize(true), isLayoutAnchor(false) {} + type(Normal), hasSize(true), isLayoutAnchor(false), + isCenterAnchor(false) {} virtual void updateChildrenSizes() {} virtual bool refreshSizeHints(qreal effectiveSpacing); @@ -180,6 +181,9 @@ struct AnchorData : public QSimplexVariable { hasSize = false; } + // Internal anchors have associated items + QGraphicsLayoutItem *item; + // Anchor is semantically directed AnchorVertex *from; AnchorVertex *to; @@ -206,6 +210,7 @@ struct AnchorData : public QSimplexVariable { uint type : 2; // either Normal, Sequential or Parallel uint hasSize : 1; // if false, get size from style. uint isLayoutAnchor : 1; // if this anchor is connected to a layout 'edge' + uint isCenterAnchor : 1; }; #ifdef QT_DEBUG -- cgit v0.12 From d4c1a4675bdff63912b31243e5292766ff5215a5 Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Fri, 16 Oct 2009 12:43:25 -0300 Subject: QGAL: simplification doesn't depend on vertex anchor point information Look for information inside the anchor instead of on the vertices. This will give us flexibility of simplifying vertices before the anchor simplification phase. Signed-off-by: Caio Marcelo de Oliveira Filho Reviewed-by: Eduardo M. Fleury --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index aa510f1..b0b1408 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -701,8 +701,6 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP QVector candidates; bool candidatesForward; - const Qt::AnchorPoint centerEdge = pickEdge(Qt::AnchorHorizontalCenter, orientation); - // Walk depth-first, in the stack we store start of the candidate sequence (beforeSequence) // and the vertex to be visited. while (!stack.isEmpty()) { @@ -811,7 +809,8 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP // One restriction we have is to not simplify half of an anchor and let the other half // unsimplified. So we remove center edges before and after the sequence. - if (beforeSequence->m_edge == centerEdge && beforeSequence->m_item == candidates.first()->m_item) { + const AnchorData *firstAnchor = g.edgeData(beforeSequence, candidates.first()); + if (firstAnchor->isCenterAnchor) { beforeSequence = candidates.first(); candidates.remove(0); @@ -820,7 +819,8 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP continue; } - if (afterSequence->m_edge == centerEdge && afterSequence->m_item == candidates.last()->m_item) { + const AnchorData *lastAnchor = g.edgeData(candidates.last(), afterSequence); + if (lastAnchor->isCenterAnchor) { afterSequence = candidates.last(); candidates.remove(candidates.count() - 1); -- cgit v0.12 From 73d89d68d5d710e86e6aa74b2924ee4aca11881e Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Fri, 16 Oct 2009 13:10:13 -0300 Subject: QGAL: add orientation bit to the anchor Use a free bit in the anchor struct to save the orientation information. That way we do not depend on looking for this information in the vertices (by looking the orientation of its edge). Signed-off-by: Caio Marcelo de Oliveira Filho Reviewed-by: Eduardo M. Fleury --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 17 +++++++++-------- src/gui/graphicsview/qgraphicsanchorlayout_p.h | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index b0b1408..41e067c 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -150,9 +150,6 @@ bool AnchorData::refreshSizeHints(qreal effectiveSpacing) // It is an internal anchor if (item) { - const QGraphicsAnchorLayoutPrivate::Orientation orient = - QGraphicsAnchorLayoutPrivate::edgeOrientation(from->m_edge); - if (isLayoutAnchor) { minSize = 0; prefSize = 0; @@ -162,7 +159,7 @@ bool AnchorData::refreshSizeHints(qreal effectiveSpacing) maxSize /= 2; return true; } else { - if (orient == QGraphicsAnchorLayoutPrivate::Horizontal) { + if (orientation == QGraphicsAnchorLayoutPrivate::Horizontal) { policy = item->sizePolicy().horizontalPolicy(); minSizeHint = item->effectiveSizeHint(Qt::MinimumSize).width(); prefSizeHint = item->effectiveSizeHint(Qt::PreferredSize).width(); @@ -1285,9 +1282,11 @@ void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstIt { Q_Q(QGraphicsAnchorLayout); + const Orientation orientation = edgeOrientation(firstEdge); + // Guarantee that the graph is no simplified when adding this anchor, // anchor manipulation always happen in the full graph - restoreSimplifiedGraph(edgeOrientation(firstEdge)); + restoreSimplifiedGraph(orientation); // Is the Vertex (firstItem, firstEdge) already represented in our // internal structure? @@ -1296,7 +1295,7 @@ void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstIt // Remove previous anchor // ### Could we update the existing edgeData rather than creating a new one? - if (graph[edgeOrientation(firstEdge)].edgeData(v1, v2)) { + if (graph[orientation].edgeData(v1, v2)) { removeAnchor_helper(v1, v2); } @@ -1304,6 +1303,8 @@ void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstIt if (firstItem == secondItem) data->item = firstItem; + data->orientation = orientation; + // Create a bi-directional edge in the sense it can be transversed both // from v1 or v2. "data" however is shared between the two references // so we still know that the anchor direction is from 1 to 2. @@ -1315,7 +1316,7 @@ void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstIt // Keep track of anchors that are connected to the layout 'edges' data->isLayoutAnchor = (v1->m_item == q || v2->m_item == q); - graph[edgeOrientation(firstEdge)].createEdge(v1, v2, data); + graph[orientation].createEdge(v1, v2, data); } QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::getAnchor(QGraphicsLayoutItem *firstItem, @@ -1480,7 +1481,7 @@ void QGraphicsAnchorLayoutPrivate::anchorSize(const AnchorData *data, Q_ASSERT(minSize || prefSize || maxSize); Q_ASSERT(data); QGraphicsAnchorLayoutPrivate *that = const_cast(this); - that->restoreSimplifiedGraph(edgeOrientation(data->from->m_edge)); + that->restoreSimplifiedGraph(Orientation(data->orientation)); if (minSize) *minSize = data->minSize; diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index 511e1ec..8525eb3 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -157,7 +157,7 @@ struct AnchorData : public QSimplexVariable { sizeAtExpanding(0), sizeAtMaximum(0), graphicsAnchor(0), skipInPreferred(0), type(Normal), hasSize(true), isLayoutAnchor(false), - isCenterAnchor(false) {} + isCenterAnchor(false), orientation(0) {} virtual void updateChildrenSizes() {} virtual bool refreshSizeHints(qreal effectiveSpacing); @@ -211,6 +211,7 @@ struct AnchorData : public QSimplexVariable { uint hasSize : 1; // if false, get size from style. uint isLayoutAnchor : 1; // if this anchor is connected to a layout 'edge' uint isCenterAnchor : 1; + uint orientation : 1; }; #ifdef QT_DEBUG -- cgit v0.12 From a79539b1364fa8c155c5fbd00a977ae40b24acbe Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Mon, 19 Oct 2009 16:17:35 -0300 Subject: QGAL: clarify the usage of isLayoutAnchor bit The 'isLayoutAnchor' is necessary only as a way to flag Layout internal anchors, i.e. anchors with the Layout as 'item' in the AnchorData structure. We don't need to propagate this bit when composing anchors. Signed-off-by: Caio Marcelo de Oliveira Filho Reviewed-by: Eduardo M. Fleury --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 13 +++---------- src/gui/graphicsview/qgraphicsanchorlayout_p.h | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 41e067c..7dbfba9 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -527,8 +527,6 @@ static AnchorData *addAnchorMaybeParallel(Graph *g, // anchor. if (AnchorData *oldAnchor = g->takeEdge(newAnchor->from, newAnchor->to)) { ParallelAnchorData *parallel = new ParallelAnchorData(oldAnchor, newAnchor); - parallel->isLayoutAnchor = (oldAnchor->isLayoutAnchor - || newAnchor->isLayoutAnchor); // At this point we can identify that the parallel anchor is not feasible, e.g. one // anchor minimum size is bigger than the other anchor maximum size. @@ -596,12 +594,6 @@ static AnchorData *createSequence(Graph *graph, sequence->refreshSizeHints_helper(0, false); - // Note that since layout 'edges' can't be simplified away from - // the graph, it's safe to assume that if there's a layout - // 'edge', it'll be in the boundaries of the sequence. - sequence->isLayoutAnchor = (sequence->m_edges.first()->isLayoutAnchor - || sequence->m_edges.last()->isLayoutAnchor); - return sequence; } @@ -1313,8 +1305,9 @@ void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstIt #ifdef QT_DEBUG data->name = QString::fromAscii("%1 --to--> %2").arg(v1->toString()).arg(v2->toString()); #endif - // Keep track of anchors that are connected to the layout 'edges' - data->isLayoutAnchor = (v1->m_item == q || v2->m_item == q); + // ### bit to track internal anchors, since inside AnchorData methods + // we don't have access to the 'q' pointer. + data->isLayoutAnchor = (data->item == q); graph[orientation].createEdge(v1, v2, data); } diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index 8525eb3..8eb65c5 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -209,7 +209,7 @@ struct AnchorData : public QSimplexVariable { uint skipInPreferred : 1; uint type : 2; // either Normal, Sequential or Parallel uint hasSize : 1; // if false, get size from style. - uint isLayoutAnchor : 1; // if this anchor is connected to a layout 'edge' + uint isLayoutAnchor : 1; // if this anchor is an internal layout anchor uint isCenterAnchor : 1; uint orientation : 1; }; -- cgit v0.12 From dc89e929d0f60e996c132e9484357e0b42f99436 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Fri, 16 Oct 2009 16:09:28 -0300 Subject: QGAL: Use constraints of type "equal" for fixed items We usually create two restrictions for each item, one to tell its size should be more than its minimum size and other enforcing it to be at most its maximum size. Now, for items that have fixed size, ie. minSize == maxSize, we create a single constraint telling its size should be equal its min/maxSize. The immediate advantage is to have one less constraint for each of these items. The indirect advantage is that the simplex solver can take advantage of such information. Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 34 +++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 7dbfba9..a83e619 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -2032,17 +2032,27 @@ QList QGraphicsAnchorLayoutPrivate::constraintsFromSizeHin { QList anchorConstraints; for (int i = 0; i < anchors.size(); ++i) { - QSimplexConstraint *c = new QSimplexConstraint; - c->variables.insert(anchors[i], 1.0); - c->constant = anchors[i]->minSize; - c->ratio = QSimplexConstraint::MoreOrEqual; - anchorConstraints += c; - - c = new QSimplexConstraint; - c->variables.insert(anchors[i], 1.0); - c->constant = anchors[i]->maxSize; - c->ratio = QSimplexConstraint::LessOrEqual; - anchorConstraints += c; + AnchorData *ad = anchors[i]; + + if ((ad->minSize == ad->maxSize) || qFuzzyCompare(ad->minSize, ad->maxSize)) { + QSimplexConstraint *c = new QSimplexConstraint; + c->variables.insert(ad, 1.0); + c->constant = ad->minSize; + c->ratio = QSimplexConstraint::Equal; + anchorConstraints += c; + } else { + QSimplexConstraint *c = new QSimplexConstraint; + c->variables.insert(ad, 1.0); + c->constant = ad->minSize; + c->ratio = QSimplexConstraint::MoreOrEqual; + anchorConstraints += c; + + c = new QSimplexConstraint; + c->variables.insert(ad, 1.0); + c->constant = ad->maxSize; + c->ratio = QSimplexConstraint::LessOrEqual; + anchorConstraints += c; + } } return anchorConstraints; @@ -2608,7 +2618,7 @@ void QGraphicsAnchorLayoutPrivate::solveExpanding(const QListsizeAtMaximum) { + if (boundedExpSize == ad->sizeAtMaximum || qFuzzyCompare(boundedExpSize, ad->sizeAtMaximum)) { // The interval has only one possible value, we can use an "Equal" // constraint and don't need to add this variable to the objective. QSimplexConstraint *itemC = new QSimplexConstraint; -- cgit v0.12 From 3f29c77a26d0a898ca3a7c9c6715da90f1ecc50a Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Fri, 16 Oct 2009 16:10:29 -0300 Subject: QGAL: Add QSimplexConstraint::toString() method for debugging Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qsimplex_p.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/gui/graphicsview/qsimplex_p.h b/src/gui/graphicsview/qsimplex_p.h index 51991a9..423f9bc 100644 --- a/src/gui/graphicsview/qsimplex_p.h +++ b/src/gui/graphicsview/qsimplex_p.h @@ -118,6 +118,29 @@ struct QSimplexConstraint return false; } } + + QString toString() { + QString result; + result += QString::fromAscii("-- QSimplexConstraint %1 --").arg(int(this), 0, 16); + + QHash::const_iterator iter; + for (iter = variables.constBegin(); iter != variables.constEnd(); ++iter) { + result += QString::fromAscii(" %1 x %2").arg(iter.value()).arg(int(iter.key()), 0, 16); + } + + switch (ratio) { + case LessOrEqual: + result += QString::fromAscii(" (less) <= %1").arg(constant); + break; + case MoreOrEqual: + result += QString::fromAscii(" (more) >= %1").arg(constant); + break; + default: + result += QString::fromAscii(" (eqal) == %1").arg(constant); + } + + return result; + } #endif }; -- cgit v0.12 From fa767bf7b104a4e44e4e283522f0dfd942094375 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Tue, 20 Oct 2009 18:54:43 -0300 Subject: QGAL (QSimplex): Make deep copy of constraints inside QSimplex The idea is to allow QSimplex solver to modify the constraints without breaking other parts of the code that rely on the original ones. Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 2 +- src/gui/graphicsview/qsimplex_p.cpp | 15 +++++++++++---- src/gui/graphicsview/qsimplex_p.h | 8 +------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index a83e619..b4666c6 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -2459,7 +2459,7 @@ bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList *min = simplex.solveMin(); // Save sizeAtMinimum results - QList variables = simplex.constraintsVariables(); + QList variables = getVariables(constraints); for (int i = 0; i < variables.size(); ++i) { AnchorData *ad = static_cast(variables[i]); Q_ASSERT(ad->result >= ad->minSize || qFuzzyCompare(ad->result, ad->minSize)); diff --git a/src/gui/graphicsview/qsimplex_p.cpp b/src/gui/graphicsview/qsimplex_p.cpp index b8f8fb4..b3997fa 100644 --- a/src/gui/graphicsview/qsimplex_p.cpp +++ b/src/gui/graphicsview/qsimplex_p.cpp @@ -108,10 +108,8 @@ void QSimplex::clearDataStructures() // Constraints for (int i = 0; i < constraints.size(); ++i) { delete constraints[i]->helper.first; - constraints[i]->helper.first = 0; - constraints[i]->helper.second = 0.0; delete constraints[i]->artificial; - constraints[i]->artificial = 0; + delete constraints[i]; } constraints.clear(); @@ -137,7 +135,16 @@ bool QSimplex::setConstraints(const QList newConstraints) if (newConstraints.isEmpty()) return true; // we are ok with no constraints - constraints = newConstraints; + + // Make deep copy of constraints. We need this copy because we may change + // them in the simplification method. + for (int i = 0; i < newConstraints.size(); ++i) { + QSimplexConstraint *c = new QSimplexConstraint; + c->constant = newConstraints[i]->constant; + c->ratio = newConstraints[i]->ratio; + c->variables = newConstraints[i]->variables; + constraints << c; + } /////////////////////////////////////// // Prepare variables and constraints // diff --git a/src/gui/graphicsview/qsimplex_p.h b/src/gui/graphicsview/qsimplex_p.h index 423f9bc..5ec13c3 100644 --- a/src/gui/graphicsview/qsimplex_p.h +++ b/src/gui/graphicsview/qsimplex_p.h @@ -106,7 +106,7 @@ struct QSimplexConstraint Q_ASSERT(constant > 0 || qFuzzyCompare(1, 1 + constant)); - if (qFuzzyCompare(1000 + leftHandSide, 1000 + constant)) + if ((leftHandSide == constant) || qFuzzyCompare(1000 + leftHandSide, 1000 + constant)) return true; switch (ratio) { @@ -152,7 +152,6 @@ public: qreal solveMin(); qreal solveMax(); - QList constraintsVariables(); bool setConstraints(const QList constraints); void setObjective(QSimplexConstraint *objective); @@ -191,11 +190,6 @@ private: qreal *matrix; }; -inline QList QSimplex::constraintsVariables() -{ - return variables; -} - inline qreal QSimplex::valueAt(int rowIndex, int columnIndex) { return matrix[rowIndex * columns + columnIndex]; -- cgit v0.12 From b14a16ce149fe9bc0e4ab66d946eb90416bd4a88 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Fri, 16 Oct 2009 16:10:52 -0300 Subject: QGAL (QSimplex): Add constraints simplification Now the simplex solver is able to remove fixed variables from its constraints as to improve its running time. The simplification consists of two actions that are done iteratively until no possible changes exist: 1st) Look for constraints of type Var == Constant Save constant as the trivial value of Var 2nd) Substitute known results in existing constraints Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qsimplex_p.cpp | 96 ++++++++++++++++++++++++++++++++++++- src/gui/graphicsview/qsimplex_p.h | 7 ++- 2 files changed, 99 insertions(+), 4 deletions(-) diff --git a/src/gui/graphicsview/qsimplex_p.cpp b/src/gui/graphicsview/qsimplex_p.cpp index b3997fa..86b10b4 100644 --- a/src/gui/graphicsview/qsimplex_p.cpp +++ b/src/gui/graphicsview/qsimplex_p.cpp @@ -146,6 +146,13 @@ bool QSimplex::setConstraints(const QList newConstraints) constraints << c; } + // Remove constraints of type Var == K and replace them for their value. + if (!simplifyConstraints(&constraints)) { + qWarning() << "QSimplex: No feasible solution!"; + clearDataStructures(); + return false; + } + /////////////////////////////////////// // Prepare variables and constraints // /////////////////////////////////////// @@ -515,11 +522,21 @@ qreal QSimplex::solver(solverFactor factor) // Remove old objective clearRow(0); - // Set new objective + // Set new objective in the first row of the simplex matrix + qreal resultOffset = 0; QHash::const_iterator iter; for (iter = objective->variables.constBegin(); iter != objective->variables.constEnd(); ++iter) { + + // Check if the variable was removed in the simplification process. + // If so, we save its offset to the objective function and skip adding + // it to the matrix. + if (iter.key()->index == -1) { + resultOffset += iter.value() * iter.key()->result; + continue; + } + setValueAt(0, iter.key()->index, -1 * factor * iter.value()); } @@ -532,7 +549,9 @@ qreal QSimplex::solver(solverFactor factor) } #endif - return factor * valueAt(0, columns - 1); + // Return the value calculated by the simplex plus the value of the + // fixed variables. + return (factor * valueAt(0, columns - 1)) + resultOffset; } /*! @@ -578,4 +597,77 @@ void QSimplex::collectResults() } } +/*! + \internal + + Looks for single-valued variables and remove them from the constraints list. +*/ +bool QSimplex::simplifyConstraints(QList *constraints) +{ + QHash results; // List of single-valued variables + bool modified = true; // Any chance more optimization exists? + + while (modified) { + modified = false; + + // For all constraints + QList::iterator iter = constraints->begin(); + while (iter != constraints->end()) { + QSimplexConstraint *c = *iter; + if ((c->ratio == QSimplexConstraint::Equal) && (c->variables.count() == 1)) { + // Check whether this is a constraint of type Var == K + // If so, save its value to "results". + QSimplexVariable *variable = c->variables.constBegin().key(); + qreal result = c->constant / c->variables.value(variable); + + results.insert(variable, result); + variable->result = result; + variable->index = -1; + modified = true; + + } + + // Replace known values among their variables + QHash::const_iterator r; + for (r = results.constBegin(); r != results.constEnd(); ++r) { + if (c->variables.contains(r.key())) { + c->constant -= r.value() * c->variables.take(r.key()); + modified = true; + } + } + + // Keep it normalized + if (c->constant < 0) + c->invert(); + + if (c->variables.isEmpty()) { + // If constraint became empty due to substitution, delete it. + if (c->isSatisfied() == false) + // We must ensure that the constraint soon to be deleted would not + // make the problem unfeasible if left behind. If that's the case, + // we return false so the simplex solver can properly report that. + return false; + + delete c; + iter = constraints->erase(iter); + } else { + ++iter; + } + } + } + + return true; +} + +void QSimplexConstraint::invert() +{ + constant = -constant; + ratio = Ratio(2 - ratio); + + QHash::iterator iter; + for (iter = variables.begin(); iter != variables.end(); ++iter) { + iter.value() = -iter.value(); + } +} + QT_END_NAMESPACE diff --git a/src/gui/graphicsview/qsimplex_p.h b/src/gui/graphicsview/qsimplex_p.h index 5ec13c3..66ea739 100644 --- a/src/gui/graphicsview/qsimplex_p.h +++ b/src/gui/graphicsview/qsimplex_p.h @@ -63,7 +63,7 @@ struct QSimplexVariable QSimplexVariable() : result(0), index(0) {} qreal result; - uint index; + int index; }; @@ -95,7 +95,8 @@ struct QSimplexConstraint QPair helper; QSimplexVariable * artificial; -#ifdef QT_DEBUG + void invert(); + bool isSatisfied() { qreal leftHandSide(0); @@ -119,6 +120,7 @@ struct QSimplexConstraint } } +#ifdef QT_DEBUG QString toString() { QString result; result += QString::fromAscii("-- QSimplexConstraint %1 --").arg(int(this), 0, 16); @@ -167,6 +169,7 @@ private: void combineRows(int toIndex, int fromIndex, qreal factor); // Simplex + bool simplifyConstraints(QList *constraints); int findPivotColumn(); int pivotRowForColumn(int column); void reducedRowEchelon(); -- cgit v0.12 From 1607216cc6292ef9a4af68ce6d29dc79fffea92c Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Mon, 26 Oct 2009 16:55:20 -0300 Subject: QGAL: Add test for David Boddie bug The current simplification code does not handle sequences with anchors pointed to different directions could not be simplified together into a sequential anchor. A (10 / 20 / 50 ) B (20 / 20 / 20) Ex: o-----------------> <----------------o The reason we don't support it yet is shown in the example above. The resulting anchor would be either: Result_1 (-10 / 0 / 30) o------------------------------------> (or) Result_2 (-30 / 0 / 10) <------------------------------------o But the current implementation assumes no anchors can have negative sizes. Hopefully, the next commits will add support for it and then enable such simplification. :-) Signed-off-by: Eduardo M. Fleury --- .../tst_qgraphicsanchorlayout.cpp | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index facc1ef..5348e59 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -83,6 +83,7 @@ private slots: void floatConflict(); void infiniteMaxSizes(); void simplifiableUnfeasible(); + void simplificationVsOrder(); }; class RectWidget : public QGraphicsWidget @@ -1806,5 +1807,50 @@ void tst_QGraphicsAnchorLayout::simplifiableUnfeasible() QVERIFY(!usedSimplex(l, Qt::Horizontal)); } +/* + Test whether the anchor direction can prevent it from + being simplificated +*/ +void tst_QGraphicsAnchorLayout::simplificationVsOrder() +{ + QSizeF min(10, 10); + QSizeF pref(20, 10); + QSizeF max(50, 10); + + QGraphicsWidget *a = createItem(min, pref, max); + QGraphicsWidget *b = createItem(min, pref, max); + QGraphicsWidget *c = createItem(min, pref, max); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + + // Bulk anchors + l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft); + l->addAnchor(b, Qt::AnchorLeft, c, Qt::AnchorLeft); + l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorRight); + + // Problematic anchor, direction b->c + QGraphicsAnchor *anchor = l->addAnchor(b, Qt::AnchorRight, c, Qt::AnchorRight); + anchor->setSpacing(5); + + l->effectiveSizeHint(Qt::MinimumSize); + if (hasSimplification) { + QCOMPARE(usedSimplex(l, Qt::Horizontal), false); + QCOMPARE(usedSimplex(l, Qt::Vertical), false); + } + + // Problematic anchor, direction c->b + delete anchor; + anchor = l->addAnchor(c, Qt::AnchorRight, b, Qt::AnchorRight); + anchor->setSpacing(5); + + l->effectiveSizeHint(Qt::MinimumSize); + if (hasSimplification) { + QEXPECT_FAIL("", "Sequential anchors cannot handle children of opposite directions", Continue); + QCOMPARE(usedSimplex(l, Qt::Horizontal), false); + QCOMPARE(usedSimplex(l, Qt::Vertical), false); + } +} + QTEST_MAIN(tst_QGraphicsAnchorLayout) #include "tst_qgraphicsanchorlayout.moc" -- cgit v0.12 From 44e9d5264217782762432bb0f4b7c441b4a545cd Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 27 Oct 2009 08:36:23 +0100 Subject: Fixed crash when QPrintDialog parent is a subwidget Reviewed-by: Trond --- src/gui/dialogs/qprintdialog_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/dialogs/qprintdialog_win.cpp b/src/gui/dialogs/qprintdialog_win.cpp index 843c4e2..51e83ac 100644 --- a/src/gui/dialogs/qprintdialog_win.cpp +++ b/src/gui/dialogs/qprintdialog_win.cpp @@ -139,7 +139,7 @@ static void qt_win_setup_PRINTDLGEX(PRINTDLGEX *pd, QWidget *parent, if (d->ep->printToFile) pd->Flags |= PD_PRINTTOFILE; Q_ASSERT(parent != 0 && parent->testAttribute(Qt::WA_WState_Created)); - pd->hwndOwner = parent->winId(); + pd->hwndOwner = parent->window()->winId(); pd->lpPageRanges[0].nFromPage = qMax(pdlg->fromPage(), pdlg->minPage()); pd->lpPageRanges[0].nToPage = (pdlg->toPage() > 0) ? qMin(pdlg->toPage(), pdlg->maxPage()) : 1; pd->nCopies = d->ep->num_copies; -- cgit v0.12 From c39fac87d62ef15867dc5571d03530d7e7240aa7 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 26 Oct 2009 10:39:38 +0100 Subject: Options on how to get a pixmap from an effect source Usable for future optimizations. Reviewed-by: Samuel --- src/gui/effects/qgraphicseffect.cpp | 22 +++-- src/gui/effects/qgraphicseffect.h | 10 ++- src/gui/effects/qgraphicseffect_p.h | 3 +- src/gui/graphicsview/qgraphicsitem.cpp | 31 +++++-- src/gui/graphicsview/qgraphicsitem_p.h | 9 +- src/gui/kernel/qwidget.cpp | 18 +++- src/gui/kernel/qwidget_p.h | 3 +- .../tst_qgraphicseffectsource.cpp | 99 ++++++++++++++++++++++ 8 files changed, 177 insertions(+), 18 deletions(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index f20480b..647fd1b 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -97,6 +97,7 @@ */ #include "qgraphicseffect_p.h" +#include #include #include @@ -248,16 +249,22 @@ bool QGraphicsEffectSource::isPixmap() const \sa QGraphicsEffect::draw(), boundingRect(), deviceRect() */ -QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offset) const +QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offset, PixmapPadMode mode) const { Q_D(const QGraphicsEffectSource); + // Shortcut, no cache for childless pixmap items... + const QGraphicsItem *item = graphicsItem(); + if (system == Qt::LogicalCoordinates && mode == NoExpandPadMode && item && isPixmap()) { + return ((QGraphicsPixmapItem *) item)->pixmap(); + } + QPixmap pm; if (d->m_cachedSystem == system) QPixmapCache::find(d->m_cacheKey, &pm); if (pm.isNull()) { - pm = d->pixmap(system, &d->m_cachedOffset); + pm = d->pixmap(system, &d->m_cachedOffset, mode); d->m_cachedSystem = system; d->invalidateCache(); @@ -565,7 +572,8 @@ void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *sou QPoint offset; if (source->isPixmap()) { // No point in drawing in device coordinates (pixmap will be scaled anyways). - const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset); + const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset, + QGraphicsEffectSource::NoExpandPadMode); d->filter->draw(painter, offset, pixmap); return; } @@ -776,6 +784,8 @@ void QGraphicsDropShadowEffect::setOffset(const QPointF &offset) By default, the horizontal shadow offset is 8 pixels. + + \sa yOffset(), offset() */ @@ -1029,7 +1039,8 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour if (source->isPixmap()) { // No point in drawing in device coordinates (pixmap will be scaled anyways). if (!d->hasOpacityMask) { - const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset); + const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset, + QGraphicsEffectSource::NoExpandPadMode); painter->drawPixmap(offset, pixmap); } else { QRect srcBrect = source->boundingRect().toAlignedRect(); @@ -1050,7 +1061,8 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour } else { // Draw pixmap in device coordinates to avoid pixmap scaling; if (!d->hasOpacityMask) { - const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); + const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset, + QGraphicsEffectSource::NoExpandPadMode); painter->setWorldTransform(QTransform()); painter->drawPixmap(offset, pixmap); } else { diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h index 019e808..abf03b3 100644 --- a/src/gui/effects/qgraphicseffect.h +++ b/src/gui/effects/qgraphicseffect.h @@ -64,6 +64,12 @@ class Q_GUI_EXPORT QGraphicsEffectSource : public QObject { Q_OBJECT public: + enum PixmapPadMode { + NoExpandPadMode, + ExpandToTransparentBorderPadMode, + ExpandToEffectRectPadMode + }; + ~QGraphicsEffectSource(); const QGraphicsItem *graphicsItem() const; const QWidget *widget() const; @@ -75,7 +81,9 @@ public: QRectF boundingRect(Qt::CoordinateSystem coordinateSystem = Qt::LogicalCoordinates) const; QRect deviceRect() const; - QPixmap pixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates, QPoint *offset = 0) const; + QPixmap pixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates, + QPoint *offset = 0, + PixmapPadMode mode = ExpandToEffectRectPadMode) const; protected: QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent = 0); diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h index 24d8696..dff84a1 100644 --- a/src/gui/effects/qgraphicseffect_p.h +++ b/src/gui/effects/qgraphicseffect_p.h @@ -77,7 +77,8 @@ public: virtual void draw(QPainter *p) = 0; virtual void update() = 0; virtual bool isPixmap() const = 0; - virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = 0) const = 0; + virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = 0, + QGraphicsEffectSource::PixmapPadMode mode = QGraphicsEffectSource::ExpandToTransparentBorderPadMode) const = 0; virtual void effectBoundingRectChanged() = 0; void invalidateCache() const { QPixmapCache::remove(m_cacheKey); } diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index f892bb4..97357a7 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1657,7 +1657,7 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, quint32(flags)); // Flags that alter the geometry of the item (or its children). - const quint32 geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations); + const quint32 geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations | ItemIsSelectable); bool fullUpdate = (quint32(flags) & geomChangeFlagsMask) != (d_ptr->flags & geomChangeFlagsMask); if (fullUpdate) d_ptr->paintedViewBoundingRectsNeedRepaint = 1; @@ -9138,10 +9138,14 @@ void QGraphicsPixmapItem::setOffset(const QPointF &offset) QRectF QGraphicsPixmapItem::boundingRect() const { Q_D(const QGraphicsPixmapItem); - qreal pw = 1.0; if (d->pixmap.isNull()) return QRectF(); - return QRectF(d->offset, d->pixmap.size()).adjusted(-pw/2, -pw/2, pw/2, pw/2); + if (d->flags & ItemIsSelectable) { + qreal pw = 1.0; + return QRectF(d->offset, d->pixmap.size()).adjusted(-pw/2, -pw/2, pw/2, pw/2); + } else { + return QRectF(d->offset, d->pixmap.size()); + } } /*! @@ -10660,7 +10664,8 @@ void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter) } } -QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset) const +QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset, + QGraphicsEffectSource::PixmapPadMode mode) const { const bool deviceCoordinates = (system == Qt::DeviceCoordinates); if (!info && deviceCoordinates) { @@ -10674,7 +10679,16 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func(); const QRectF sourceRect = boundingRect(system); - QRect effectRect = item->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); + QRect effectRect; + + if (mode == QGraphicsEffectSource::ExpandToEffectRectPadMode) { + effectRect = item->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); + } else if (mode == QGraphicsEffectSource::ExpandToTransparentBorderPadMode) { + effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect(); + } else { + effectRect = sourceRect.toAlignedRect(); + } + if (offset) *offset = effectRect.topLeft(); @@ -10702,10 +10716,15 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP effectRect.setBottom(deviceHeight -1); } - if (effectRect.isEmpty()) return QPixmap(); + if (system == Qt::LogicalCoordinates + && effectRect.size() == sourceRect.size() + && isPixmap()) { + return static_cast(item)->pixmap(); + } + QPixmap pixmap(effectRect.size()); pixmap.fill(Qt::transparent); QPainter pixmapPainter(&pixmap); diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 7c3c4f0..183e95b 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -61,6 +61,7 @@ #include #include +#include #include @@ -603,7 +604,9 @@ public: inline bool isPixmap() const { - return (item->type() == QGraphicsPixmapItem::Type); + return item->type() == QGraphicsPixmapItem::Type + && !(item->flags() & QGraphicsItem::ItemIsSelectable) + && item->d_ptr->children.size() == 0; //|| (item->d_ptr->isObject && qobject_cast(q_func())); } @@ -621,7 +624,9 @@ public: QRectF boundingRect(Qt::CoordinateSystem system) const; void draw(QPainter *); - QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset) const; + QPixmap pixmap(Qt::CoordinateSystem system, + QPoint *offset, + QGraphicsEffectSource::PixmapPadMode mode) const; QGraphicsItem *item; QGraphicsItemPaintInfo *info; diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 5fa9a92..27e73e0 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -5437,7 +5437,8 @@ void QWidgetEffectSourcePrivate::draw(QPainter *painter) context->sharedPainter, context->backingStore); } -QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset) const +QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset, + QGraphicsEffectSource::PixmapPadMode mode) const { const bool deviceCoordinates = (system == Qt::DeviceCoordinates); if (!context && deviceCoordinates) { @@ -5455,7 +5456,20 @@ QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint * pixmapOffset = painterTransform.map(pixmapOffset); } - QRect effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); + + QRect effectRect; + + if (mode == QGraphicsEffectSource::ExpandToEffectRectPadMode) { + effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); + + } else if (mode == QGraphicsEffectSource::ExpandToTransparentBorderPadMode) { + effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect(); + + } else { + effectRect = sourceRect.toAlignedRect(); + + } + if (offset) *offset = effectRect.topLeft(); diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 159a3f2..616a972 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -819,7 +819,8 @@ public: QRectF boundingRect(Qt::CoordinateSystem system) const; void draw(QPainter *p); - QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset) const; + QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset, + QGraphicsEffectSource::PixmapPadMode mode) const; QWidget *m_widget; QWidgetPaintContext *context; diff --git a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp index 855950b..0635989 100644 --- a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp +++ b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp @@ -166,6 +166,9 @@ private slots: void deviceRect(); void pixmap(); + void pixmapPadding_data(); + void pixmapPadding(); + private: QGraphicsView *view; QGraphicsScene *scene; @@ -318,6 +321,102 @@ void tst_QGraphicsEffectSource::pixmap() QCOMPARE(pixmap1, pixmap2); } +class PaddingEffect : public QGraphicsEffect +{ +public: + PaddingEffect(QObject *parent) : QGraphicsEffect(parent) + { + } + + QRectF boundingRectFor(const QRectF &src) const { + return src.adjusted(-10, -10, 10, 10); + } + + void draw(QPainter *p, QGraphicsEffectSource *source) { + pix = source->pixmap(coordinateMode, &offset, padMode); + } + + QPixmap pix; + QPoint offset; + QGraphicsEffectSource::PixmapPadMode padMode; + Qt::CoordinateSystem coordinateMode; +}; + +void tst_QGraphicsEffectSource::pixmapPadding_data() +{ + QTest::addColumn("coordinateMode"); + QTest::addColumn("padMode"); + QTest::addColumn("size"); + QTest::addColumn("offset"); + QTest::addColumn("ulPixel"); + + QTest::newRow("log,nopad") << int(Qt::LogicalCoordinates) + << int(QGraphicsEffectSource::NoPadMode) + << QSize(10, 10) << QPoint(0, 0) + << 0xffff0000u; + + QTest::newRow("log,transparent") << int(Qt::LogicalCoordinates) + << int(QGraphicsEffectSource::ExpandToTransparentBorderPadMode) + << QSize(12, 12) << QPoint(-1, -1) + << 0x00000000u; + + QTest::newRow("log,effectrect") << int(Qt::LogicalCoordinates) + << int(QGraphicsEffectSource::ExpandToEffectRectPadMode) + << QSize(30, 30) << QPoint(-10, -10) + << 0x00000000u; + + QTest::newRow("dev,nopad") << int(Qt::DeviceCoordinates) + << int(QGraphicsEffectSource::NoPadMode) + << QSize(20, 20) << QPoint(40, 40) + << 0xffff0000u; + + QTest::newRow("dev,transparent") << int(Qt::DeviceCoordinates) + << int(QGraphicsEffectSource::ExpandToTransparentBorderPadMode) + << QSize(22, 22) << QPoint(39, 39) + << 0x00000000u; + + QTest::newRow("dev,effectrect") << int(Qt::DeviceCoordinates) + << int(QGraphicsEffectSource::ExpandToEffectRectPadMode) + << QSize(40, 40) << QPoint(30, 30) + << 0x00000000u; + +} + +void tst_QGraphicsEffectSource::pixmapPadding() +{ + QPixmap dummyTarget(100, 100); + QPainter dummyPainter(&dummyTarget); + dummyPainter.translate(40, 40); + dummyPainter.scale(2, 2); + + QPixmap pm(10, 10); + pm.fill(Qt::red); + + QGraphicsScene *scene = new QGraphicsScene(); + PaddingEffect *effect = new PaddingEffect(scene); + QGraphicsPixmapItem *pmItem = new QGraphicsPixmapItem(pm); + scene->addItem(pmItem); + pmItem->setGraphicsEffect(effect); + + QFETCH(int, coordinateMode); + QFETCH(int, padMode); + QFETCH(QPoint, offset); + QFETCH(QSize, size); + QFETCH(uint, ulPixel); + + effect->padMode = (QGraphicsEffectSource::PixmapPadMode) padMode; + effect->coordinateMode = (Qt::CoordinateSystem) coordinateMode; + + scene->render(&dummyPainter, scene->itemsBoundingRect(), scene->itemsBoundingRect()); + + QCOMPARE(effect->pix.size(), size); + QCOMPARE(effect->offset, offset); + QCOMPARE(effect->pix.toImage().pixel(0, 0), ulPixel); + + // ### Fix corruption in scene destruction, then enable... + // delete scene; +} + QTEST_MAIN(tst_QGraphicsEffectSource) #include "tst_qgraphicseffectsource.moc" -- cgit v0.12 From cdd341bd8ca9834cd631188c5efc440038ad0b20 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 27 Oct 2009 09:08:12 +0100 Subject: Removed a redundant if() check. Its checked in the containing condition Reviewed-by: Samuel --- src/gui/painting/qpaintengine_raster.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index fd0e810..bf2c574 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1739,8 +1739,7 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) const QLineF *lines = reinterpret_cast(path.points()); for (int i = 0; i < lineCount; ++i) { - if (path.shape() == QVectorPath::LinesHint) - dashOffset = s->lastPen.dashOffset(); + dashOffset = s->lastPen.dashOffset(); if (lines[i].p1() == lines[i].p2()) { if (s->lastPen.capStyle() != Qt::FlatCap) { QPointF p = lines[i].p1(); -- cgit v0.12 From a46adcd714ec7c71c926511a7c29a8b29dbc1035 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 27 Oct 2009 09:12:09 +0100 Subject: Reworked QVectorPath API to allow for caching and convex curved shapes --- src/gui/painting/qpaintengine_raster.cpp | 2 +- src/gui/painting/qpaintengineex.cpp | 30 ++++++++++--- src/gui/painting/qpaintengineex_p.h | 6 +-- src/gui/painting/qpainterpath_p.h | 2 +- src/gui/painting/qvectorpath_p.h | 72 +++++++++++++++++++------------- 5 files changed, 72 insertions(+), 40 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index bf2c574..1a8dce1 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1686,7 +1686,7 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) if (!s->penData.blend) return; - if (s->flags.fast_pen && path.shape() <= QVectorPath::NonCurvedShapeHint + if (s->flags.fast_pen && !path.isCurved() && s->lastPen.brush().isOpaque()) { int count = path.elementCount(); QPointF *points = (QPointF *) path.points(); diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 195be0a..9e21182 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -92,6 +92,24 @@ QRectF QVectorPath::controlPointRect() const return QRectF(QPointF(m_cp_rect.x1, m_cp_rect.y1), QPointF(m_cp_rect.x2, m_cp_rect.y2)); } + +QVectorPath::CacheEntry *QVectorPath::addCacheData(QPaintEngineEx *engine, void *data, + qvectorpath_cache_cleanup cleanup) { + Q_ASSERT(!lookupCacheData(engine)); + if ((m_hints & IsCachedHint) == 0) { + m_cache = 0; + m_hints |= IsCachedHint; + } + CacheEntry *e = new CacheEntry; + e->engine = engine; + e->data = data; + e->cleanup = cleanup; + e->next = m_cache; + m_cache = e; + return m_cache; +} + + const QVectorPath &qtVectorPathForPath(const QPainterPath &path) { Q_ASSERT(path.d_func()); @@ -414,7 +432,7 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) // Some engines might decide to optimize for the non-shape hint later on... uint flags = QVectorPath::WindingFill; if (d->stroker.capStyle() == Qt::RoundCap || d->stroker.joinStyle() == Qt::RoundJoin) - flags |= QVectorPath::CurvedShapeHint; + flags |= QVectorPath::CurvedShapeMask; // ### Perspective Xforms are currently not supported... if (!pen.isCosmetic()) { @@ -442,7 +460,7 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) points[4], points[5]); points += 6; types += 3; - flags |= QVectorPath::CurvedShapeHint; + flags |= QVectorPath::CurvedShapeMask; break; default: break; @@ -504,7 +522,7 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) d->activeStroker->cubicTo(c1.x(), c1.y(), c2.x(), c2.y(), e.x(), e.y()); points += 6; types += 3; - flags |= QVectorPath::CurvedShapeHint; + flags |= QVectorPath::CurvedShapeMask; break; } default: @@ -736,7 +754,7 @@ void QPaintEngineEx::drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yR x1 + xRadius, y1 }; - QVectorPath path(pts, 17, qpaintengineex_roundedrect_types); + QVectorPath path(pts, 17, qpaintengineex_roundedrect_types, QVectorPath::RoundedRectHint); draw(path); } @@ -827,7 +845,7 @@ void QPaintEngineEx::drawPoints(const QPointF *points, int pointCount) pts[++oset] = points[i].x() + 0.001; pts[++oset] = points[i].y(); } - QVectorPath path(pts, count * 2, qpaintengineex_line_types_16, QVectorPath::NonCurvedShapeHint); + QVectorPath path(pts, count * 2, qpaintengineex_line_types_16, QVectorPath::LinesHint); stroke(path, pen); pointCount -= 16; points += 16; @@ -858,7 +876,7 @@ void QPaintEngineEx::drawPoints(const QPoint *points, int pointCount) pts[++oset] = points[i].x() + 0.001; pts[++oset] = points[i].y(); } - QVectorPath path(pts, count * 2, qpaintengineex_line_types_16, QVectorPath::NonCurvedShapeHint); + QVectorPath path(pts, count * 2, qpaintengineex_line_types_16, QVectorPath::LinesHint); stroke(path, pen); pointCount -= 16; points += 16; diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h index 3ec9bd6..02d77f4 100644 --- a/src/gui/painting/qpaintengineex_p.h +++ b/src/gui/painting/qpaintengineex_p.h @@ -250,9 +250,9 @@ public: inline uint QVectorPath::polygonFlags(QPaintEngine::PolygonDrawMode mode) { switch (mode) { case QPaintEngine::ConvexMode: return ConvexPolygonHint | ImplicitClose; - case QPaintEngine::OddEvenMode: return NonCurvedShapeHint | OddEvenFill | ImplicitClose; - case QPaintEngine::WindingMode: return NonCurvedShapeHint | WindingFill | ImplicitClose; - case QPaintEngine::PolylineMode: return NonCurvedShapeHint; + case QPaintEngine::OddEvenMode: return PolygonHint | OddEvenFill | ImplicitClose; + case QPaintEngine::WindingMode: return PolygonHint | WindingFill | ImplicitClose; + case QPaintEngine::PolylineMode: return PolygonHint; default: return 0; } } diff --git a/src/gui/painting/qpainterpath_p.h b/src/gui/painting/qpainterpath_p.h index 54c182d..fbdb9a6 100644 --- a/src/gui/painting/qpainterpath_p.h +++ b/src/gui/painting/qpainterpath_p.h @@ -103,7 +103,7 @@ public: points[ptsPos++] = e.x; points[ptsPos++] = e.y; if (e.type == QPainterPath::CurveToElement) - flags |= QVectorPath::CurvedShapeHint; + flags |= QVectorPath::CurvedShapeMask; } if (fillRule == Qt::WindingFill) diff --git a/src/gui/painting/qvectorpath_p.h b/src/gui/painting/qvectorpath_p.h index d023131..ec27970 100644 --- a/src/gui/painting/qvectorpath_p.h +++ b/src/gui/painting/qvectorpath_p.h @@ -66,8 +66,9 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) +class QPaintEngineEx; -#define QVECTORPATH_NO_CACHE +typedef void (*qvectorpath_cache_cleanup)(void *data); struct QRealRect { qreal x1, y1, x2, y2; @@ -77,19 +78,27 @@ class Q_GUI_EXPORT QVectorPath { public: enum Hint { - // Basic shapes... - LinesHint = 0x0001, // Just plain lines... - RectangleHint = 0x0002, - ConvexPolygonHint = 0x0003, // Convex polygon... - NonISectPolygonHint = 0x0004, // concave polygon, but not intersecting.. - NonCurvedShapeHint = 0x0005, // Generic polygon, possibly self-intersecting... - CurvedShapeHint = 0x0006, // Generic vector path.. - EllipseHint = 0x0007, - ShapeHintMask = 0x000f, + // Shape hints, in 0x000000ff, access using shape() + AreaShapeMask = 0x0001, // shape covers an area + NonConvexShapeMask = 0x0002, // shape is not convex + CurvedShapeMask = 0x0004, // shape contains curves... + LinesShapeMask = 0x0008, + RectangleShapeMask = 0x0010, + ShapeMask = 0x001f, + + // Shape hints merged into basic shapes.. + LinesHint = LinesShapeMask, + RectangleHint = AreaShapeMask | RectangleShapeMask, + EllipseHint = AreaShapeMask | CurvedShapeMask, + ConvexPolygonHint = AreaShapeMask, + PolygonHint = AreaShapeMask | NonConvexShapeMask, + RoundedRectHint = AreaShapeMask | CurvedShapeMask, + ArbitraryShapeHint = AreaShapeMask | NonConvexShapeMask | CurvedShapeMask, // Other hints - CacheHint = 0x0100, - ControlPointRect = 0x0200, // Set if the control point rect has been calculated... + IsCachedHint = 0x0100, // Set if the cache hint is set + ShouldUseCacheHint = 0x0200, // Set if the path should be cached when possible.. + ControlPointRect = 0x0400, // Set if the control point rect has been calculated... // Shape rendering specifiers... OddEvenFill = 0x1000, @@ -101,22 +110,21 @@ public: QVectorPath(const qreal *points, int count, const QPainterPath::ElementType *elements = 0, - uint hints = CurvedShapeHint) + uint hints = ArbitraryShapeHint) : m_elements(elements), m_points(points), m_count(count), m_hints(hints) -#ifndef QVECTORPATH_NO_CACHE - , m_cache(0) -#endif { } QRectF controlPointRect() const; - inline Hint shape() const { return (Hint) (m_hints & ShapeHintMask); } + inline Hint shape() const { return (Hint) (m_hints & ShapeMask); } + inline bool isConvex() const { return (m_hints & NonConvexShapeMask) == 0; } + inline bool isCurved() const { return m_hints & CurvedShapeMask; } - inline bool hasCacheHint() const { return m_hints & CacheHint; } + inline bool isCacheable() const { return m_hints & ShouldUseCacheHint; } inline bool hasImplicitClose() const { return m_hints & ImplicitClose; } inline bool hasWindingFill() const { return m_hints & WindingFill; } @@ -131,24 +139,30 @@ public: static inline uint polygonFlags(QPaintEngine::PolygonDrawMode mode); -private: - Q_DISABLE_COPY(QVectorPath) - -#ifndef QVECTORPATH_NO_CACHE struct CacheEntry { - void *engine; - int id; - void *extra; + QPaintEngineEx *engine; + void *data; + qvectorpath_cache_cleanup cleanup; CacheEntry *next; }; - void addCacheData(CacheEntry *d) { - d->next = m_cache; - m_cache = d; + CacheEntry *addCacheData(QPaintEngineEx *engine, void *data, qvectorpath_cache_cleanup cleanup); + inline CacheEntry *lookupCacheData(QPaintEngineEx *engine) const { + Q_ASSERT(m_hints & IsCachedHint); + CacheEntry *e = m_cache; + while (e) { + if (e->engine == engine) + return e; + e = e->next; + } + return 0; } + +private: + Q_DISABLE_COPY(QVectorPath) + CacheEntry *m_cache; -#endif const QPainterPath::ElementType *m_elements; const qreal *m_points; -- cgit v0.12 From 487ebd770e1a406270e24aec97a90adea2062c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 26 Oct 2009 11:12:07 +0100 Subject: Made graphics effects autotest compile. There's no grayscale effect anymore, use colorize effect. Reviewed-by: Gunnar Sletta --- tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index 0201bc4..b40cf43 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -379,7 +379,8 @@ void tst_QGraphicsEffect::grayscale() item->setPen(Qt::NoPen); item->setBrush(QColor(122, 193, 66)); // Qt light green - QGraphicsGrayscaleEffect *effect = new QGraphicsGrayscaleEffect; + QGraphicsColorizeEffect *effect = new QGraphicsColorizeEffect; + effect->setColor(Qt::black); item->setGraphicsEffect(effect); QPainter painter; -- cgit v0.12 From 0ceeded769563914622d26f35397921001c889c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 26 Oct 2009 11:09:05 +0100 Subject: Made blur and drop shadow APIs use qreal instead of int for blur radius. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's no reason to lock ourselves to int in the API when some of the backend could handle floating point blur radii. Reviewed-by: Bjørn Erik Nilsen --- src/gui/effects/qgraphicseffect.cpp | 16 ++++++++-------- src/gui/effects/qgraphicseffect.h | 16 ++++++++-------- src/gui/image/qpixmapfilter.cpp | 20 ++++++++++---------- src/gui/image/qpixmapfilter_p.h | 8 ++++---- src/opengl/qglpixmapfilter.cpp | 4 ++-- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 647fd1b..9ed003c 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -630,16 +630,16 @@ QGraphicsBlurEffect::~QGraphicsBlurEffect() By default, the blur radius is 5 pixels. */ -int QGraphicsBlurEffect::blurRadius() const +qreal QGraphicsBlurEffect::blurRadius() const { Q_D(const QGraphicsBlurEffect); return d->filter->radius(); } -void QGraphicsBlurEffect::setBlurRadius(int radius) +void QGraphicsBlurEffect::setBlurRadius(qreal radius) { Q_D(QGraphicsBlurEffect); - if (d->filter->radius() == radius) + if (qFuzzyCompare(d->filter->radius(), radius)) return; d->filter->setRadius(radius); @@ -648,7 +648,7 @@ void QGraphicsBlurEffect::setBlurRadius(int radius) } /*! - \fn void QGraphicsBlurEffect::blurRadiusChanged(int radius) + \fn void QGraphicsBlurEffect::blurRadiusChanged(qreal radius) This signal is emitted whenever the effect's blur radius changes. The \a radius parameter holds the effect's new blur radius. @@ -816,16 +816,16 @@ void QGraphicsDropShadowEffect::setOffset(const QPointF &offset) \sa color(), offset(). */ -int QGraphicsDropShadowEffect::blurRadius() const +qreal QGraphicsDropShadowEffect::blurRadius() const { Q_D(const QGraphicsDropShadowEffect); return d->filter->blurRadius(); } -void QGraphicsDropShadowEffect::setBlurRadius(int blurRadius) +void QGraphicsDropShadowEffect::setBlurRadius(qreal blurRadius) { Q_D(QGraphicsDropShadowEffect); - if (d->filter->blurRadius() == blurRadius) + if (qFuzzyCompare(d->filter->blurRadius(), blurRadius)) return; d->filter->setBlurRadius(blurRadius); @@ -834,7 +834,7 @@ void QGraphicsDropShadowEffect::setBlurRadius(int blurRadius) } /*! - \fn void QGraphicsDropShadowEffect::blurRadiusChanged(int blurRadius) + \fn void QGraphicsDropShadowEffect::blurRadiusChanged(qreal blurRadius) This signal is emitted whenever the effect's blur radius changes. The \a blurRadius parameter holds the effect's new blur radius. diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h index abf03b3..bf18581 100644 --- a/src/gui/effects/qgraphicseffect.h +++ b/src/gui/effects/qgraphicseffect.h @@ -182,22 +182,22 @@ class QGraphicsBlurEffectPrivate; class Q_GUI_EXPORT QGraphicsBlurEffect: public QGraphicsEffect { Q_OBJECT - Q_PROPERTY(int blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) + Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) Q_PROPERTY(Qt::RenderHint blurHint READ blurHint WRITE setBlurHint NOTIFY blurHintChanged) public: QGraphicsBlurEffect(QObject *parent = 0); ~QGraphicsBlurEffect(); QRectF boundingRectFor(const QRectF &rect) const; - int blurRadius() const; + qreal blurRadius() const; Qt::RenderHint blurHint() const; public Q_SLOTS: - void setBlurRadius(int blurRadius); + void setBlurRadius(qreal blurRadius); void setBlurHint(Qt::RenderHint hint); Q_SIGNALS: - void blurRadiusChanged(int blurRadius); + void blurRadiusChanged(qreal blurRadius); void blurHintChanged(Qt::RenderHint hint); protected: @@ -215,7 +215,7 @@ class Q_GUI_EXPORT QGraphicsDropShadowEffect: public QGraphicsEffect Q_PROPERTY(QPointF offset READ offset WRITE setOffset NOTIFY offsetChanged) Q_PROPERTY(qreal xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged) Q_PROPERTY(qreal yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged) - Q_PROPERTY(int blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) + Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) public: QGraphicsDropShadowEffect(QObject *parent = 0); @@ -230,7 +230,7 @@ public: inline qreal yOffset() const { return offset().y(); } - int blurRadius() const; + qreal blurRadius() const; QColor color() const; public Q_SLOTS: @@ -248,12 +248,12 @@ public Q_SLOTS: inline void setYOffset(qreal dy) { setOffset(QPointF(xOffset(), dy)); } - void setBlurRadius(int blurRadius); + void setBlurRadius(qreal blurRadius); void setColor(const QColor &color); Q_SIGNALS: void offsetChanged(const QPointF &offset); - void blurRadiusChanged(int blurRadius); + void blurRadiusChanged(qreal blurRadius); void colorChanged(const QColor &color); protected: diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp index 9fcf776..f9ac79f 100644 --- a/src/gui/image/qpixmapfilter.cpp +++ b/src/gui/image/qpixmapfilter.cpp @@ -506,7 +506,7 @@ class QPixmapBlurFilterPrivate : public QPixmapFilterPrivate public: QPixmapBlurFilterPrivate() : radius(5), hint(Qt::PerformanceHint) {} - int radius; + qreal radius; Qt::RenderHint hint; }; @@ -535,7 +535,7 @@ QPixmapBlurFilter::~QPixmapBlurFilter() \internal */ -void QPixmapBlurFilter::setRadius(int radius) +void QPixmapBlurFilter::setRadius(qreal radius) { Q_D(QPixmapBlurFilter); d->radius = radius; @@ -546,7 +546,7 @@ void QPixmapBlurFilter::setRadius(int radius) \internal */ -int QPixmapBlurFilter::radius() const +qreal QPixmapBlurFilter::radius() const { Q_D(const QPixmapBlurFilter); return d->radius; @@ -668,7 +668,7 @@ void QPixmapBlurFilter::draw(QPainter *painter, const QPointF &p, const QPixmap if (!painter->isActive()) return; - if (d->radius == 0) { + if (d->radius <= 0) { painter->drawPixmap(srcRect.translated(p), src, srcRect); return; } @@ -688,12 +688,12 @@ void QPixmapBlurFilter::draw(QPainter *painter, const QPointF &p, const QPixmap if (srcRect.isNull()) { srcImage = src.toImage(); - destImage = blurred(srcImage, srcImage.rect(), d->radius); + destImage = blurred(srcImage, srcImage.rect(), qRound(d->radius)); } else { QRect rect = srcRect.toAlignedRect().intersected(src.rect()); srcImage = src.copy(rect).toImage(); - destImage = blurred(srcImage, srcImage.rect(), d->radius); + destImage = blurred(srcImage, srcImage.rect(), qRound(d->radius)); } painter->drawImage(p, destImage); @@ -902,7 +902,7 @@ public: QPointF offset; QColor color; - int radius; + qreal radius; }; /*! @@ -966,7 +966,7 @@ QPixmapDropShadowFilter::~QPixmapDropShadowFilter() \internal */ -int QPixmapDropShadowFilter::blurRadius() const +qreal QPixmapDropShadowFilter::blurRadius() const { Q_D(const QPixmapDropShadowFilter); return d->radius; @@ -981,7 +981,7 @@ int QPixmapDropShadowFilter::blurRadius() const \internal */ -void QPixmapDropShadowFilter::setBlurRadius(int radius) +void QPixmapDropShadowFilter::setBlurRadius(qreal radius) { Q_D(QPixmapDropShadowFilter); d->radius = radius; @@ -1090,7 +1090,7 @@ void QPixmapDropShadowFilter::draw(QPainter *p, QImage tmp = src.isNull() ? px.toImage() : px.copy(src.toAlignedRect()).toImage(); // blur the alpha channel - tmp = blurred(tmp, tmp.rect(), d->radius, true); + tmp = blurred(tmp, tmp.rect(), qRound(d->radius), true); // blacken the image... QPainter tmpPainter(&tmp); diff --git a/src/gui/image/qpixmapfilter_p.h b/src/gui/image/qpixmapfilter_p.h index 8a2207a..fc70795 100644 --- a/src/gui/image/qpixmapfilter_p.h +++ b/src/gui/image/qpixmapfilter_p.h @@ -129,10 +129,10 @@ public: QPixmapBlurFilter(QObject *parent = 0); ~QPixmapBlurFilter(); - void setRadius(int radius); + void setRadius(qreal radius); void setBlurHint(Qt::RenderHint hint); - int radius() const; + qreal radius() const; Qt::RenderHint blurHint() const; QRectF boundingRectFor(const QRectF &rect) const; @@ -175,8 +175,8 @@ public: QRectF boundingRectFor(const QRectF &rect) const; void draw(QPainter *p, const QPointF &pos, const QPixmap &px, const QRectF &src = QRectF()) const; - int blurRadius() const; - void setBlurRadius(int radius); + qreal blurRadius() const; + void setBlurRadius(qreal radius); QColor color() const; void setColor(const QColor &color); diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index 0603369..656957d 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -341,7 +341,7 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const { QGLPixmapBlurFilter *filter = const_cast(this); - int radius = this->radius(); + int radius = qRound(this->radius()); if (!m_haveCached || (m_hint == Qt::QualityHint && radius != m_cachedRadius)) { // Only regenerate the shader from source if parameters have changed. m_haveCached = true; @@ -530,7 +530,7 @@ bool QGLPixmapDropShadowFilter::processGL(QPainter *painter, const QPointF &pos, { QGLPixmapDropShadowFilter *filter = const_cast(this); - int radius = this->blurRadius(); + int radius = qRound(this->blurRadius()); if (!m_haveCached || (m_hint == Qt::QualityHint && radius != m_cachedRadius)) { // Only regenerate the shader from source if parameters have changed. m_haveCached = true; -- cgit v0.12 From f5398e1adc5203b3aa56d50ee3a9bd936531a119 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Tue, 27 Oct 2009 10:51:30 +0200 Subject: Switched setWindowIcon_sys to use QPixmpa::toSymbianCFbsBitmap in S60. There were TODOs in code to remove the temporary solution for creating native CFbsBitmap out of QPixmap. Now when QPixmpa has native backed and it provides toSymbianCFbsBitmap, it it preferred to use toSymbianCFbsBitmap since in best case it can only duplicate the bitmap handle instead of copying the data. Task-number: QTBUG-4948 Reviewed-by: Jani Hautakangas --- src/gui/kernel/qwidget_s60.cpp | 72 +++--------------------------------------- 1 file changed, 4 insertions(+), 68 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index cb615fe..a6d8ed7 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -716,62 +716,6 @@ void QWidgetPrivate::s60UpdateIsOpaque() window->SetTransparentRegion(TRegionFix<1>()); } -CFbsBitmap* qt_pixmapToNativeBitmap(QPixmap pixmap, bool invert) -{ - CFbsBitmap* fbsBitmap = q_check_ptr(new CFbsBitmap); // CBase derived object needs check on new - TSize size(pixmap.size().width(), pixmap.size().height()); - TDisplayMode mode(EColor16MU); - - bool isNull = pixmap.isNull(); - int depth = pixmap.depth(); - - // TODO: dummy assumptions from bit amounts for each color - // Will fix later on when native pixmap is implemented - switch(pixmap.depth()) { - case 1: - mode = EGray2; - break; - case 4: - mode = EColor16; - break; - case 8: - mode = EColor256; - break; - case 12: - mode = EColor4K; - break; - case 16: - mode = EColor64K; - break; - case 24: - mode = EColor16M; - break; - case 32: - case EColor16MU: - break; - default: - qFatal("Unsupported pixmap depth"); - break; - } - - qt_symbian_throwIfError(fbsBitmap->Create(size, mode)); - fbsBitmap->LockHeap(); - QImage image = pixmap.toImage(); - - if (invert) - image.invertPixels(); - - int height = pixmap.size().height(); - for(int i=0;iSetScanLine( scanline, i ); - } - - fbsBitmap->UnlockHeap(); - return fbsBitmap; -} - void QWidgetPrivate::setWindowIcon_sys(bool forceReset) { #ifdef Q_WS_S60 @@ -800,12 +744,8 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset) mask.fill(Qt::color1); } - // Convert to CFbsBitmp - // TODO: When QPixmap is adapted to use native CFbsBitmap, - // it could be set directly to context pane - CFbsBitmap* nBitmap = qt_pixmapToNativeBitmap(pm, false); - CFbsBitmap* nMask = qt_pixmapToNativeBitmap(mask, true); - + CFbsBitmap* nBitmap = pm.toSymbianCFbsBitmap(); + CFbsBitmap* nMask = mask.toSymbianCFbsBitmap(); contextPane->SetPicture(nBitmap,nMask); } else { // Icon set to null -> set context pane picture to default @@ -836,12 +776,8 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset) mask.fill(Qt::color1); } - // Convert to CFbsBitmp - // TODO: When QPixmap is adapted to use native CFbsBitmap, - // it could be set directly to context pane - CFbsBitmap* nBitmap = qt_pixmapToNativeBitmap(pm, false); - CFbsBitmap* nMask = qt_pixmapToNativeBitmap(mask, true); - + CFbsBitmap* nBitmap = pm.toSymbianCFbsBitmap(); + CFbsBitmap* nMask = mask.toSymbianCFbsBitmap(); titlePane->SetSmallPicture( nBitmap, nMask, ETrue ); } else { // Icon set to null -> set context pane picture to default -- cgit v0.12 From a36ee30a9753c766be1017550df581ab941b87e3 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 27 Oct 2009 11:30:25 +0200 Subject: Temporary fix for FEP crash with input masked QLineEdits QLineEdits with input masks report the cursor position relative to displayed text via inputMethodQuery(), but the text returned is the actual text of the control, which can differ from displayed text, causing mismatch between FEP display and control display. To properly fix this we would need to know the displayText of QLineEdits instead of just the text, which on itself should be a trivial change. The difficulties start when we need to commit the changes back to the QLineEdit, which would have to be somehow able to handle displayText, too. Task made to fix this properly: QTBUG-5050 Task-number: QTBUG-4892 Reviewed-by: axis --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index c4d17ff..3f21bc3 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -561,8 +561,28 @@ void QCoeFepInputContext::GetCursorSelectionForFep(TCursorSelection& aCursorSele int cursor = w->inputMethodQuery(Qt::ImCursorPosition).toInt() + m_preeditString.size(); int anchor = w->inputMethodQuery(Qt::ImAnchorPosition).toInt() + m_preeditString.size(); - aCursorSelection.iAnchorPos = anchor; - aCursorSelection.iCursorPos = cursor; + QString text = w->inputMethodQuery(Qt::ImSurroundingText).value(); + int combinedSize = text.size() + m_preeditString.size(); + if (combinedSize < anchor || combinedSize < cursor) { + // ### TODO! FIXME! QTBUG-5050 + // This is a hack to prevent crashing in 4.6 with QLineEdits that use input masks. + // The root problem is that cursor position is relative to displayed text instead of the + // actual text we get. + // + // To properly fix this we would need to know the displayText of QLineEdits instead + // of just the text, which on itself should be a trivial change. The difficulties start + // when we need to commit the changes back to the QLineEdit, which would have to be somehow + // able to handle displayText, too. + // + // Until properly fixed, the cursor and anchor positions will not reflect correct positions + // for masked QLineEdits, unless all the masked positions are filled in order so that + // cursor position relative to the displayed text matches position relative to actual text. + aCursorSelection.iAnchorPos = combinedSize; + aCursorSelection.iCursorPos = combinedSize; + } else { + aCursorSelection.iAnchorPos = anchor; + aCursorSelection.iCursorPos = cursor; + } } void QCoeFepInputContext::GetEditorContentForFep(TDes& aEditorContent, TInt aDocumentPosition, -- cgit v0.12 From 68ab3b34571cfdde4002de9982388f9eec4d9939 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 26 Oct 2009 15:54:18 +0100 Subject: Fixed a bug in QMenuBar in RTL that would display menu at the wrong place This could happen when adding actions in response to the aboutToShow signal. Task-number: QT-2596 Reviewed-by: ogoffart --- src/gui/widgets/qmenu.cpp | 4 ++++ src/gui/widgets/qmenubar.cpp | 29 ++++++++++++----------------- tests/auto/qmenubar/tst_qmenubar.cpp | 29 ++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index ea25901..1b5d1cd 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -1878,6 +1878,10 @@ void QMenu::popup(const QPoint &p, QAction *atAction) if(snapToMouse) //position flowing left from the mouse pos.setX(mouse.x()-size.width()); + //if in a menubar, it should be right-aligned + if (qobject_cast(d->causedPopup.widget)) + pos.rx() -= size.width(); + if (pos.x() < screen.left()+desktopFrame) pos.setX(qMax(p.x(), screen.left()+desktopFrame)); if (pos.x()+size.width()-1 > screen.right()-desktopFrame) diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index f2f0722..689d2e1 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -336,30 +336,25 @@ void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst) const bool fitUp = (q->mapToGlobal(adjustedActionRect.topLeft()).y() >= popup_size.height()); const bool fitDown = (pos.y() + popup_size.height() <= screenRect.bottom()); + const bool rtl = q->isRightToLeft(); const int actionWidth = adjustedActionRect.width(); if (!fitUp && !fitDown) { //we should shift the menu - bool shouldShiftToRight = !q->isRightToLeft(); - if (q->isRightToLeft() && popup_size.width() > pos.x()) + bool shouldShiftToRight = !rtl; + if (rtl && popup_size.width() > pos.x()) shouldShiftToRight = true; else if (actionWidth + popup_size.width() + pos.x() > screenRect.right()) shouldShiftToRight = false; - if (shouldShiftToRight) - pos.rx() += actionWidth; - else - pos.rx() -= popup_size.width(); - } else if (q->isRightToLeft()) { - pos.setX(pos.x()-(popup_size.width() - actionWidth)); - } - - if(pos.x() < screenRect.x()) { - pos.setX(screenRect.x()); - } else { - const int off = pos.x()+popup_size.width() - screenRect.right(); - if(off > 0) - pos.setX(qMax(screenRect.x(), pos.x()-off)); - + if (shouldShiftToRight) { + pos.rx() += actionWidth + (rtl ? popup_size.width() : 0); + } else { + //shift to left + if (!rtl) + pos.rx() -= popup_size.width(); + } + } else if (rtl) { + pos.rx() += actionWidth; } if(!defaultPopDown || (fitUp && !fitDown)) diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp index 07aa9f4..4291c3e 100644 --- a/tests/auto/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/qmenubar/tst_qmenubar.cpp @@ -86,6 +86,18 @@ private: uint sel_count; }; +class Menu : public QMenu +{ + Q_OBJECT + public slots: + void addActions() + { + //this will change the geometry of the menu + addAction("action1"); + addAction("action2"); + } +}; + class tst_QMenuBar : public QObject { Q_OBJECT @@ -1442,7 +1454,7 @@ void tst_QMenuBar::check_menuPosition() #ifdef Q_OS_WINCE_WM QSKIP("Qt/CE uses native menubar", SkipAll); #endif - QMenu menu; + Menu menu; #ifdef QT3_SUPPORT initComplexMenubar(); #else @@ -1496,6 +1508,21 @@ void tst_QMenuBar::check_menuPosition() menu.close(); } + //in RTL, the menu should be stuck at the right of the action geometry + { + Qt::LayoutDirection dir = qApp->layoutDirection(); + qApp->setLayoutDirection(Qt::RightToLeft); + menu.clear(); + QObject::connect(&menu, SIGNAL(aboutToShow()), &menu, SLOT(addActions())); + QRect mbItemRect = mw->menuBar()->actionGeometry(menu_action); + mbItemRect.moveTo(mw->menuBar()->mapToGlobal(mbItemRect.topLeft())); + QTest::keyClick(mw, Qt::Key_M, Qt::AltModifier ); + QVERIFY(menu.isActiveWindow()); + QCOMPARE(menu.geometry().right(), mbItemRect.right()); + menu.close(); + qApp->setLayoutDirection(dir); + } + } void tst_QMenuBar::task223138_triggered() -- cgit v0.12 From 0f6ab9612eba6c5418991443b65a10820d6b5a1f Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Tue, 27 Oct 2009 09:56:28 +0100 Subject: Stabilize sequential animation startDelay autotest on win Reviewed-by: thierry --- .../tst_qsequentialanimationgroup.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index aa6801a..f6afc5b 100644 --- a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -929,16 +929,13 @@ void tst_QSequentialAnimationGroup::startDelay() group.addPause(125); QCOMPARE(group.totalDuration(), 375); - QEventLoop loop; - QObject::connect(&group, SIGNAL(finished()), &loop, SLOT(quit())); - - QTime time; - time.start(); group.start(); - loop.exec(); + QCOMPARE(group.state(), QAnimationGroup::Running); - QVERIFY(time.elapsed() >= 375); - QVERIFY(time.elapsed() < 1000); + QTest::qWait(500); + + QVERIFY(group.currentTime() == 375); + QCOMPARE(group.state(), QAnimationGroup::Stopped); } void tst_QSequentialAnimationGroup::clearGroup() -- cgit v0.12 From fdd29c588801b0c50a8d85c43c7754bc6e988883 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 27 Oct 2009 11:00:24 +0100 Subject: Make use of QVectorPath::isConvex() to speed up rounded rect filling Reviewed-by: Samuel --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index a0810bc..b70810d 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -858,9 +858,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) QGLRect rect(points[0].x(), points[0].y(), points[2].x(), points[2].y()); prepareForDraw(currentBrush->isOpaque()); composite(rect); - } else if (path.shape() == QVectorPath::EllipseHint - || path.shape() == QVectorPath::ConvexPolygonHint) - { + } else if (path.isConvex()) { vertexCoordinateArray.clear(); vertexCoordinateArray.addPath(path, inverseScale, false); prepareForDraw(currentBrush->isOpaque()); -- cgit v0.12 From dd89851abe4b0d0a3c293b5cadace00eb3f75a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 27 Oct 2009 11:01:45 +0100 Subject: If a QGraphicsWidget gets a StyleChange event, invalidate its layout. The layout should be invalidated because all layouts are dependent on some style-specific defaults. (e.g. PM_LayoutHorizontalSpacing can differ.) Reviewed-by: alexis --- src/gui/graphicsview/qgraphicswidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index 35a3c13..d70a281 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -1352,6 +1352,8 @@ void QGraphicsWidget::changeEvent(QEvent *event) case QEvent::StyleChange: // ### Don't unset if the margins are explicitly set. unsetWindowFrameMargins(); + if (d->layout) + d->layout->invalidate(); case QEvent::FontChange: update(); updateGeometry(); -- cgit v0.12 From 890fbc5c6a271d345ec5a47501c4ae716a96fe44 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Tue, 27 Oct 2009 10:58:28 +0100 Subject: Compile on Symbian winscw. Patch by Martin Jones. Malformed in codepaster so was manually applied. Builds with public 5th SDK. The compiler workaround was documented. Reviewed-by: Frans Englich --- src/xmlpatterns/schema/qxsdstatemachine.cpp | 64 -------------------------- src/xmlpatterns/schema/qxsdstatemachine_p.h | 69 +++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 67 deletions(-) diff --git a/src/xmlpatterns/schema/qxsdstatemachine.cpp b/src/xmlpatterns/schema/qxsdstatemachine.cpp index 85bc752..8a43411 100644 --- a/src/xmlpatterns/schema/qxsdstatemachine.cpp +++ b/src/xmlpatterns/schema/qxsdstatemachine.cpp @@ -335,64 +335,6 @@ typename XsdStateMachine::StateId XsdStateMachine -QSet::StateId> XsdStateMachine::epsilonClosure(const QSet &input) const -{ - // every state can reach itself by epsilon transition, so include the input states - // in the result as well - QSet result = input; - - // add the input states to the list of to be processed states - QList workStates = input.toList(); - while (!workStates.isEmpty()) { // while there are states to be processed left... - - // dequeue one state from list - const StateId state = workStates.takeFirst(); - - // get the list of states that can be reached by the epsilon transition - // from the current 'state' - const QVector targetStates = m_epsilonTransitions.value(state); - for (int i = 0; i < targetStates.count(); ++i) { - // if we have this target state not in our result set yet... - if (!result.contains(targetStates.at(i))) { - // ... add it to the result set - result.insert(targetStates.at(i)); - - // add the target state to the list of to be processed states as well, - // as we want to have the epsilon transitions not only for the first - // level of following states - workStates.append(targetStates.at(i)); - } - } - } - - return result; -} - -template -QSet::StateId> XsdStateMachine::move(const QSet &states, TransitionType input) const -{ - QSet result; - - QSetIterator it(states); - while (it.hasNext()) { // iterate over all given states - const StateId state = it.next(); - - // get the transition table for the current state - const QHash > transitions = m_transitions.value(state); - - // get the target states for the given input - const QVector targetStates = transitions.value(input); - - // add all target states to the result - for (int i = 0; i < targetStates.size(); ++i) - result.insert(targetStates.at(i)); - } - - return result; -} - template XsdStateMachine XsdStateMachine::toDFA() const { @@ -469,9 +411,3 @@ QHash::StateId, typename XsdStateMachin { return m_states; } - -template -QHash::StateId, QHash::StateId> > > XsdStateMachine::transitions() const -{ - return m_transitions; -} diff --git a/src/xmlpatterns/schema/qxsdstatemachine_p.h b/src/xmlpatterns/schema/qxsdstatemachine_p.h index e671499..294eb50 100644 --- a/src/xmlpatterns/schema/qxsdstatemachine_p.h +++ b/src/xmlpatterns/schema/qxsdstatemachine_p.h @@ -204,8 +204,14 @@ namespace QPatternist /** * Returns the information of all transitions of the state machine. + * + * The implementation is inlined in order to workaround a compiler + * bug on Symbian/winscw. */ - QHash > > transitions() const; + QHash > > transitions() const + { + return m_transitions; + } private: /** @@ -217,14 +223,71 @@ namespace QPatternist /** * Returns the set of all states that can be reached from the set of @p input states * by the epsilon transition. + * + * The implementation is inlined in order to workaround a compiler + * bug on Symbian/winscw. */ - QSet epsilonClosure(const QSet &input) const; + QSet epsilonClosure(const QSet &input) const + { + // every state can reach itself by epsilon transition, so include the input states + // in the result as well + QSet result = input; + + // add the input states to the list of to be processed states + QList workStates = input.toList(); + while (!workStates.isEmpty()) { // while there are states to be processed left... + + // dequeue one state from list + const StateId state = workStates.takeFirst(); + + // get the list of states that can be reached by the epsilon transition + // from the current 'state' + const QVector targetStates = m_epsilonTransitions.value(state); + for (int i = 0; i < targetStates.count(); ++i) { + // if we have this target state not in our result set yet... + if (!result.contains(targetStates.at(i))) { + // ... add it to the result set + result.insert(targetStates.at(i)); + + // add the target state to the list of to be processed states as well, + // as we want to have the epsilon transitions not only for the first + // level of following states + workStates.append(targetStates.at(i)); + } + } + } + + return result; + } /** * Returns the set of all states that can be reached from the set of given @p states * by the given @p input. + * + * The implementation is inlined in order to workaround a compiler + * bug on Symbian/winscw. */ - QSet move(const QSet &states, TransitionType input) const; + QSet move(const QSet &states, TransitionType input) const + { + QSet result; + + QSetIterator it(states); + while (it.hasNext()) { // iterate over all given states + const StateId state = it.next(); + + // get the transition table for the current state + const QHash > transitions = m_transitions.value(state); + + // get the target states for the given input + const QVector targetStates = transitions.value(input); + + // add all target states to the result + for (int i = 0; i < targetStates.size(); ++i) + result.insert(targetStates.at(i)); + } + + return result; + } NamePool::Ptr m_namePool; QHash m_states; -- cgit v0.12 From 8b2a5214a46fa15b0394ee3c8147343fc79e44d4 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 27 Oct 2009 11:10:00 +0100 Subject: Reset the GL error stack prior to checking for errors in bindTexture() Reviewed-by: Tom --- src/opengl/qgl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 6720ae7..e80521b 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2156,6 +2156,11 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G time.start(); #endif +#ifndef QT_NO_DEBUG + // Reset the gl error stack...git + while (glGetError() != GL_NO_ERROR); +#endif + // Scale the pixmap if needed. GL textures needs to have the // dimensions 2^n+2(border) x 2^m+2(border), unless we're using GL // 2.0 or use the GL_TEXTURE_RECTANGLE texture target -- cgit v0.12 From b9a48dd97e14b36a17590c4008ab5e94c1a734b8 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Tue, 27 Oct 2009 11:32:27 +0100 Subject: Enable webkit and xmlpatterns by default on Symbian. Suggested by Lars, OK'd by Jason, Kristian and Shane. --- configure.exe | Bin 2170880 -> 1169408 bytes tools/configure/configureapp.cpp | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.exe b/configure.exe index dabf10c..f433888 100755 Binary files a/configure.exe and b/configure.exe differ diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index f57f3a8..adf7a1a 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -1448,10 +1448,10 @@ void Configure::applySpecSpecifics() dictionary[ "IWMMXT" ] = "no"; dictionary[ "CE_CRT" ] = "no"; dictionary[ "DIRECT3D" ] = "no"; - dictionary[ "WEBKIT" ] = "no"; + dictionary[ "WEBKIT" ] = "yes"; dictionary[ "ASSISTANT_WEBKIT" ] = "no"; dictionary[ "PHONON" ] = "yes"; - dictionary[ "XMLPATTERNS" ] = "no"; + dictionary[ "XMLPATTERNS" ] = "yes"; dictionary[ "QT_GLIB" ] = "no"; dictionary[ "S60" ] = "yes"; // iconv makes makes apps start and run ridiculously slowly in symbian emulator (HW not tested) -- cgit v0.12 From c17e8c19212d68a6bc2e9492b5ffacdf8c251090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Tue, 27 Oct 2009 12:51:33 +0200 Subject: Use PM_SplitterWidth in QS60Style Updated pixel metrics values from latest S60 layouts. Also, updated pixel metrics harvester to collect pixel metric for QSplitter. Task-number: QT-686 Reviewed-by: Shane Kearns --- src/gui/styles/qs60style.cpp | 39 +++++++++++++++++----------------- util/s60pixelmetrics/pixel_metrics.cpp | 6 +++--- util/s60pixelmetrics/pm_mapper.mmp | 2 +- util/s60pixelmetrics/pm_mapperapp.cpp | 2 +- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 8d59d14..8ef0dd3 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -91,14 +91,14 @@ static const qreal goldenRatio = 1.618; const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { // *** generated layout data *** -{240,320,1,14,true,"QVGA Landscape Mirrored"}, -{240,320,1,14,false,"QVGA Landscape"}, -{320,240,1,14,true,"QVGA Portrait Mirrored"}, -{320,240,1,14,false,"QVGA Portrait"}, -{360,640,1,14,true,"NHD Landscape Mirrored"}, -{360,640,1,14,false,"NHD Landscape"}, -{640,360,1,14,true,"NHD Portrait Mirrored"}, -{640,360,1,14,false,"NHD Portrait"}, +{240,320,1,15,true,"QVGA Landscape Mirrored"}, +{240,320,1,15,false,"QVGA Landscape"}, +{320,240,1,15,true,"QVGA Portrait Mirrored"}, +{320,240,1,15,false,"QVGA Portrait"}, +{360,640,1,15,true,"NHD Landscape Mirrored"}, +{360,640,1,15,false,"NHD Landscape"}, +{640,360,1,15,true,"NHD Portrait Mirrored"}, +{640,360,1,15,false,"NHD Portrait"}, {352,800,1,12,true,"E90 Landscape Mirrored"}, {352,800,1,12,false,"E90 Landscape"} // *** End of generated data *** @@ -108,16 +108,16 @@ const int QS60StylePrivate::m_numberOfLayouts = const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { // *** generated pixel metrics *** -{5,0,-909,0,0,1,0,0,-1,8,15,22,15,15,7,198,-909,-909,-909,19,15,2,0,0,21,-909,21,-909,4,4,1,-909,-909,0,2,0,0,13,23,17,17,21,21,2,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,51,27,51,4,4,5,10,15,-909,5,58,12,5,0,7,4,4,9,4,4,-909,1,-909,-909,-909,-909,4,4,3,1}, -{5,0,-909,0,0,1,0,0,-1,8,15,22,15,15,7,198,-909,-909,-909,19,15,2,0,0,21,-909,21,-909,4,4,1,-909,-909,0,2,0,0,13,23,17,17,21,21,2,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,51,27,51,4,4,5,10,15,-909,5,58,12,5,0,4,4,7,9,4,4,-909,1,-909,-909,-909,-909,4,4,3,1}, -{5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,-909,27,-909,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,4,4,5,10,15,-909,5,58,13,5,0,7,4,4,9,4,4,-909,1,-909,-909,-909,-909,4,4,3,1}, -{5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,-909,27,-909,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,4,4,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,1,-909,-909,-909,-909,4,4,3,1}, -{7,0,-909,0,0,2,0,0,-1,20,53,28,19,19,9,258,-909,-909,-909,29,19,26,0,0,32,-909,72,-909,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,5,5,6,8,19,-909,7,74,19,7,0,8,5,5,12,5,5,-909,2,-909,-909,-909,-909,7,7,3,1}, -{7,0,-909,0,0,2,0,0,-1,20,53,28,19,19,9,258,-909,-909,-909,29,19,26,0,0,32,-909,72,-909,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,5,5,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,2,-909,-909,-909,-909,7,7,3,1}, -{7,0,-909,0,0,2,0,0,-1,20,52,28,19,19,9,258,-909,-909,-909,29,19,6,0,0,32,-909,60,-909,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,98,35,98,5,5,6,8,19,-909,7,74,22,7,0,8,5,5,12,5,5,-909,2,-909,-909,-909,-909,7,7,3,1}, -{7,0,-909,0,0,2,0,0,-1,20,52,28,19,19,9,258,-909,-909,-909,29,19,6,0,0,32,-909,60,-909,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,98,35,98,5,5,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,2,-909,-909,-909,-909,7,7,3,1}, -{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,-909,32,-909,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,5,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,8,6,5,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1}, -{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,-909,32,-909,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1} +{5,0,-909,0,0,2,0,0,-1,7,12,19,13,13,6,200,-909,-909,-909,20,13,2,0,0,21,7,18,-909,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,3,3,4,9,13,-909,5,51,11,5,0,6,3,3,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1}, +{5,0,-909,0,0,2,0,0,-1,7,12,19,13,13,6,200,-909,-909,-909,20,13,2,0,0,21,7,18,-909,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,3,3,4,9,13,-909,5,51,11,5,0,3,3,6,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1}, +{5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,-909,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,4,4,5,10,15,-909,5,58,13,5,0,7,4,4,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1}, +{5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,-909,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,4,4,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1}, +{7,0,-909,0,0,2,0,0,-1,25,69,28,19,19,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,-909,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,5,5,6,8,19,-909,7,74,19,7,0,8,5,5,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1}, +{7,0,-909,0,0,2,0,0,-1,25,69,28,19,19,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,-909,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,5,5,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1}, +{7,0,-909,0,0,2,0,0,-1,25,68,28,19,19,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,-909,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,5,5,6,8,19,-909,7,74,22,7,0,8,5,5,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1}, +{7,0,-909,0,0,2,0,0,-1,25,68,28,19,19,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,-909,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,5,5,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1}, +{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,-909,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,5,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,8,6,5,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1}, +{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,-909,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1} // *** End of generated data *** }; @@ -526,6 +526,7 @@ void QS60StylePrivate::drawPart(QS60StyleEnums::SkinParts skinPart, #else true; #endif + const QPixmap skinPartPixMap((doCache ? cachedPart : part)(skinPart, rect.size(), flags)); if (!skinPartPixMap.isNull()) painter->drawPixmap(rect.topLeft(), skinPartPixMap); @@ -2190,7 +2191,7 @@ int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const if (metricValue == KNotFound) metricValue = QCommonStyle::pixelMetric(metric, option, widget); - if (metric == PM_SubMenuOverlap && widget){ + if (metric == PM_SubMenuOverlap && widget) { const QMenu *menu = qobject_cast(widget); if (menu && menu->activeAction() && menu->activeAction()->menu()) { const int menuWidth = menu->activeAction()->menu()->sizeHint().width(); diff --git a/util/s60pixelmetrics/pixel_metrics.cpp b/util/s60pixelmetrics/pixel_metrics.cpp index 939a718..9507c67 100644 --- a/util/s60pixelmetrics/pixel_metrics.cpp +++ b/util/s60pixelmetrics/pixel_metrics.cpp @@ -50,7 +50,7 @@ // so that we can keep dynamic and static values inline. // Please adjust version data if correcting dynamic PM calculations. const TInt KPMMajorVersion = 1; -const TInt KPMMinorVersion = 14; +const TInt KPMMinorVersion = 15; TPixelMetricsVersion PixelMetrics::Version() { @@ -726,6 +726,7 @@ TInt PixelMetrics::PixelMetricValue(QStyle::PixelMetric metric) value = -1; //disable - not in S60 } break; + case QStyle::PM_SplitterWidth: case QStyle::PM_ScrollBarExtent: { TAknLayoutRect miscGraphicsRect; @@ -1000,7 +1001,7 @@ TInt PixelMetrics::PixelMetricValue(QStyle::PixelMetric metric) case QStyle::PM_ButtonShiftVertical: value = 0; break; - + case QStyle::PM_ToolBarExtensionExtent: value = PixelMetricTabValue(QStyle::PM_TabBarScrollButtonWidth, appWindow.Rect(), landscape); break; @@ -1016,7 +1017,6 @@ TInt PixelMetrics::PixelMetricValue(QStyle::PixelMetric metric) case QStyle::PM_DockWidgetSeparatorExtent: // not in S60 case QStyle::PM_MdiSubWindowMinimizedWidth: //no such thing in S60 case QStyle::PM_HeaderGripMargin: // not in S60 - case QStyle::PM_SplitterWidth: // not in S60 case QStyle::PM_ToolBarSeparatorExtent: // not in S60 case QStyle::PM_ToolBarHandleExtent: // not in s60 case QStyle::PM_MenuButtonIndicator: // none??? diff --git a/util/s60pixelmetrics/pm_mapper.mmp b/util/s60pixelmetrics/pm_mapper.mmp index 7777a3d..a2e2571 100644 --- a/util/s60pixelmetrics/pm_mapper.mmp +++ b/util/s60pixelmetrics/pm_mapper.mmp @@ -40,7 +40,7 @@ ****************************************************************************/ #include -#include +#include TARGET pm_mapper.exe TARGETTYPE exe diff --git a/util/s60pixelmetrics/pm_mapperapp.cpp b/util/s60pixelmetrics/pm_mapperapp.cpp index e24ed29..de6af0d 100644 --- a/util/s60pixelmetrics/pm_mapperapp.cpp +++ b/util/s60pixelmetrics/pm_mapperapp.cpp @@ -138,7 +138,7 @@ void CPixelMetricsMapperAppUi::ConstructL() // TKeyResponse CPixelMetricsMapperAppUi::HandleKeyEventL( const TKeyEvent& /*aKeyEvent*/, - TEventCode aType ) + TEventCode /*aType*/ ) { return EKeyWasNotConsumed; } -- cgit v0.12 From 8a9ab43e572443eefbf19d59740fdc64d25d1005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 27 Oct 2009 11:54:47 +0100 Subject: Respect the per-item layoutSpacing() if the style uses that feature. We move the QLayoutStyleInfo class out of the gridlayout engine to a common header file so that anchor layout also can utilize it. Due to that we now can have a per-item spacing we have to change the 'effectiveSpacing' argument of refreshSizeHints to just take a QLayoutStyleInfo pointer that we will later query for the actual spacing used. --- src/gui/graphicsview/qgraphicsanchorlayout.cpp | 7 +- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 78 +++++----- src/gui/graphicsview/qgraphicsanchorlayout_p.h | 17 ++- src/gui/graphicsview/qgraphicslayout_p.h | 51 +++++++ src/gui/graphicsview/qgridlayoutengine_p.h | 25 +--- .../tst_qgraphicsanchorlayout.cpp | 162 +++++++++++++++++++++ 6 files changed, 271 insertions(+), 69 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp index 081572f..00d3478 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp @@ -400,7 +400,7 @@ void QGraphicsAnchorLayout::setSpacing(qreal spacing) qreal QGraphicsAnchorLayout::horizontalSpacing() const { Q_D(const QGraphicsAnchorLayout); - return d->effectiveSpacing(QGraphicsAnchorLayoutPrivate::Horizontal); + return d->styleInfo().defaultSpacing(Qt::Horizontal); } /*! @@ -411,7 +411,7 @@ qreal QGraphicsAnchorLayout::horizontalSpacing() const qreal QGraphicsAnchorLayout::verticalSpacing() const { Q_D(const QGraphicsAnchorLayout); - return d->effectiveSpacing(QGraphicsAnchorLayoutPrivate::Vertical); + return d->styleInfo().defaultSpacing(Qt::Vertical); } /*! @@ -481,7 +481,8 @@ void QGraphicsAnchorLayout::invalidate() { Q_D(QGraphicsAnchorLayout); QGraphicsLayout::invalidate(); - d->calculateGraphCacheDirty = 1; + d->calculateGraphCacheDirty = true; + d->styleInfoDirty = true; } /*! diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 8c8c303..5bc6708 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -141,7 +141,7 @@ static void internalSizeHints(QSizePolicy::Policy policy, *expSize = *prefSize; } -void AnchorData::refreshSizeHints(qreal effectiveSpacing) +void AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) { const bool isInternalAnchor = from->m_item == to->m_item; @@ -196,7 +196,20 @@ void AnchorData::refreshSizeHints(qreal effectiveSpacing) // their effective size hints might be narrowed down due to their size policies. prefSizeHint = prefSize; } else { - prefSizeHint = effectiveSpacing; + const Qt::Orientation orient = Qt::Orientation(QGraphicsAnchorLayoutPrivate::edgeOrientation(from->m_edge) + 1); + qreal s = styleInfo->defaultSpacing(orient); + if (s < 0) { + QSizePolicy::ControlType controlTypeFrom = from->m_item->sizePolicy().controlType(); + QSizePolicy::ControlType controlTypeTo = to->m_item->sizePolicy().controlType(); + s = styleInfo->perItemSpacing(controlTypeFrom, controlTypeTo, orient); + + // ### Currently we do not support negative anchors inside the graph. + // To avoid those being created by a negative style spacing, we must + // make this test. + if (s < 0) + s = 0; + } + prefSizeHint = s; } maxSizeHint = QWIDGETSIZE_MAX; } @@ -227,17 +240,17 @@ void ParallelAnchorData::updateChildrenSizes() secondEdge->updateChildrenSizes(); } -void ParallelAnchorData::refreshSizeHints(qreal effectiveSpacing) +void ParallelAnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) { - refreshSizeHints_helper(effectiveSpacing); + refreshSizeHints_helper(styleInfo); } -void ParallelAnchorData::refreshSizeHints_helper(qreal effectiveSpacing, +void ParallelAnchorData::refreshSizeHints_helper(const QLayoutStyleInfo *styleInfo, bool refreshChildren) { if (refreshChildren) { - firstEdge->refreshSizeHints(effectiveSpacing); - secondEdge->refreshSizeHints(effectiveSpacing); + firstEdge->refreshSizeHints(styleInfo); + secondEdge->refreshSizeHints(styleInfo); } // ### should we warn if the parallel connection is invalid? @@ -362,12 +375,12 @@ void SequentialAnchorData::updateChildrenSizes() } } -void SequentialAnchorData::refreshSizeHints(qreal effectiveSpacing) +void SequentialAnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) { - refreshSizeHints_helper(effectiveSpacing); + refreshSizeHints_helper(styleInfo); } -void SequentialAnchorData::refreshSizeHints_helper(qreal effectiveSpacing, +void SequentialAnchorData::refreshSizeHints_helper(const QLayoutStyleInfo *styleInfo, bool refreshChildren) { minSize = 0; @@ -380,7 +393,7 @@ void SequentialAnchorData::refreshSizeHints_helper(qreal effectiveSpacing, // If it's the case refresh children information first if (refreshChildren) - edge->refreshSizeHints(effectiveSpacing); + edge->refreshSizeHints(styleInfo); minSize += edge->minSize; prefSize += edge->prefSize; @@ -458,7 +471,7 @@ QString GraphPath::toString() const #endif QGraphicsAnchorLayoutPrivate::QGraphicsAnchorLayoutPrivate() - : calculateGraphCacheDirty(1) + : calculateGraphCacheDirty(true), styleInfoDirty(true) { for (int i = 0; i < NOrientations; ++i) { for (int j = 0; j < 3; ++j) { @@ -1565,34 +1578,32 @@ void QGraphicsAnchorLayoutPrivate::correctEdgeDirection(QGraphicsLayoutItem *&fi } } -qreal QGraphicsAnchorLayoutPrivate::effectiveSpacing(Orientation orientation) const +QLayoutStyleInfo &QGraphicsAnchorLayoutPrivate::styleInfo() const { - Q_Q(const QGraphicsAnchorLayout); - qreal s = spacings[orientation]; - if (s < 0) { - // ### make sure behaviour is the same as in QGraphicsGridLayout + if (styleInfoDirty) { + Q_Q(const QGraphicsAnchorLayout); + //### Fix this if QGV ever gets support for Metal style or different Aqua sizes. + QWidget *wid = 0; + QGraphicsLayoutItem *parent = q->parentLayoutItem(); while (parent && parent->isLayout()) { parent = parent->parentLayoutItem(); } + QGraphicsWidget *w = 0; if (parent) { QGraphicsItem *parentItem = parent->graphicsItem(); - if (parentItem && parentItem->isWidget()) { - QGraphicsWidget *w = static_cast(parentItem); - s = w->style()->pixelMetric(orientation == Horizontal - ? QStyle::PM_LayoutHorizontalSpacing - : QStyle::PM_LayoutVerticalSpacing); - } + if (parentItem && parentItem->isWidget()) + w = static_cast(parentItem); } - } - // ### Currently we do not support negative anchors inside the graph. - // To avoid those being created by a negative style spacing, we must - // make this test. - if (s < 0) - s = 0; + QStyle *style = w ? w->style() : QApplication::style(); + cachedStyleInfo = QLayoutStyleInfo(style, wid); + cachedStyleInfo.setDefaultSpacing(Qt::Horizontal, spacings[0]); + cachedStyleInfo.setDefaultSpacing(Qt::Vertical, spacings[1]); - return s; + styleInfoDirty = false; + } + return cachedStyleInfo; } /*! @@ -1620,7 +1631,7 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs() dumpGraph(QString::fromAscii("%1-after").arg(count)); #endif - calculateGraphCacheDirty = 0; + calculateGraphCacheDirty = false; } // ### Maybe getGraphParts could return the variables when traversing, at least @@ -1847,12 +1858,11 @@ void QGraphicsAnchorLayoutPrivate::setAnchorSizeHintsFromItems(Orientation orien Graph &g = graph[orientation]; QList > vertices = g.connections(); - qreal spacing = effectiveSpacing(orientation); - + QLayoutStyleInfo styleInf = styleInfo(); for (int i = 0; i < vertices.count(); ++i) { AnchorData *data = g.edgeData(vertices.at(i).first, vertices.at(i).second);; Q_ASSERT(data->from && data->to); - data->refreshSizeHints(spacing); + data->refreshSizeHints(&styleInf); } } diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index d45c004..9b7d41e 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -159,7 +159,7 @@ struct AnchorData : public QSimplexVariable { type(Normal), hasSize(true), isLayoutAnchor(false) {} virtual void updateChildrenSizes() {} - virtual void refreshSizeHints(qreal effectiveSpacing); + virtual void refreshSizeHints(const QLayoutStyleInfo *styleInfo); virtual ~AnchorData() {} @@ -226,9 +226,9 @@ struct SequentialAnchorData : public AnchorData } virtual void updateChildrenSizes(); - virtual void refreshSizeHints(qreal effectiveSpacing); + virtual void refreshSizeHints(const QLayoutStyleInfo *styleInfo); - void refreshSizeHints_helper(qreal effectiveSpacing, bool refreshChildren = true); + void refreshSizeHints_helper(const QLayoutStyleInfo *styleInfo, bool refreshChildren = true); void setVertices(const QVector &vertices) { @@ -261,9 +261,9 @@ struct ParallelAnchorData : public AnchorData } virtual void updateChildrenSizes(); - virtual void refreshSizeHints(qreal effectiveSpacing); + virtual void refreshSizeHints(const QLayoutStyleInfo *styleInfo); - void refreshSizeHints_helper(qreal effectiveSpacing, bool refreshChildren = true); + void refreshSizeHints_helper(const QLayoutStyleInfo *styleInfo, bool refreshChildren = true); AnchorData* firstEdge; AnchorData* secondEdge; @@ -423,9 +423,8 @@ public: Qt::AnchorPoint &firstEdge, QGraphicsLayoutItem *&secondItem, Qt::AnchorPoint &secondEdge); - // for getting the actual spacing (will query the style if the - // spacing is not explicitly set). - qreal effectiveSpacing(Orientation orientation) const; + + QLayoutStyleInfo &styleInfo() const; // Activation methods void simplifyGraph(Orientation orientation); @@ -524,6 +523,8 @@ public: #endif uint calculateGraphCacheDirty : 1; + mutable uint styleInfoDirty : 1; + mutable QLayoutStyleInfo cachedStyleInfo; friend class QGraphicsAnchorPrivate; }; diff --git a/src/gui/graphicsview/qgraphicslayout_p.h b/src/gui/graphicsview/qgraphicslayout_p.h index 59c6dba..4aeae39 100644 --- a/src/gui/graphicsview/qgraphicslayout_p.h +++ b/src/gui/graphicsview/qgraphicslayout_p.h @@ -60,6 +60,8 @@ #include "qgraphicslayout.h" #include "qgraphicslayoutitem_p.h" #include +#include +#include QT_BEGIN_NAMESPACE @@ -76,6 +78,55 @@ inline bool qt_graphicsLayoutDebug() } #endif + +class QLayoutStyleInfo +{ +public: + inline QLayoutStyleInfo() { invalidate(); } + inline QLayoutStyleInfo(QStyle *style, QWidget *widget) + : m_valid(true), m_style(style), m_widget(widget) + { + Q_ASSERT(style); + if (widget) //### + m_styleOption.initFrom(widget); + m_defaultSpacing[0] = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing); + m_defaultSpacing[1] = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing); + } + + inline void invalidate() { m_valid = false; m_style = 0; m_widget = 0; } + + inline QStyle *style() const { return m_style; } + inline QWidget *widget() const { return m_widget; } + + inline bool operator==(const QLayoutStyleInfo &other) + { return m_style == other.m_style && m_widget == other.m_widget; } + inline bool operator!=(const QLayoutStyleInfo &other) + { return !(*this == other); } + + inline void setDefaultSpacing(Qt::Orientation o, qreal spacing){ + if (spacing >= 0) + m_defaultSpacing[o - 1] = spacing; + } + + inline qreal defaultSpacing(Qt::Orientation o) const { + return m_defaultSpacing[o - 1]; + } + + inline qreal perItemSpacing(QSizePolicy::ControlType control1, + QSizePolicy::ControlType control2, + Qt::Orientation orientation) const + { + Q_ASSERT(style()); + return style()->layoutSpacing(control1, control2, orientation, &m_styleOption, widget()); + } +private: + bool m_valid; + QStyle *m_style; + QWidget *m_widget; + QStyleOption m_styleOption; + qreal m_defaultSpacing[2]; +}; + class Q_AUTOTEST_EXPORT QGraphicsLayoutPrivate : public QGraphicsLayoutItemPrivate { Q_DECLARE_PUBLIC(QGraphicsLayout) diff --git a/src/gui/graphicsview/qgridlayoutengine_p.h b/src/gui/graphicsview/qgridlayoutengine_p.h index a42a537..ed335a8 100644 --- a/src/gui/graphicsview/qgridlayoutengine_p.h +++ b/src/gui/graphicsview/qgridlayoutengine_p.h @@ -59,7 +59,7 @@ #include "qmap.h" #include "qpair.h" #include "qvector.h" - +#include "qgraphicslayout_p.h" #include QT_BEGIN_NAMESPACE @@ -128,29 +128,6 @@ public: }; -class QLayoutStyleInfo -{ -public: - inline QLayoutStyleInfo() { invalidate(); } - inline QLayoutStyleInfo(QStyle *style, QWidget *widget) - : q_valid(true), q_style(style), q_widget(widget) {} - - inline void invalidate() { q_valid = false; q_style = 0; q_widget = 0; } - - inline QStyle *style() const { return q_style; } - inline QWidget *widget() const { return q_widget; } - - inline bool operator==(const QLayoutStyleInfo &other) - { return q_style == other.q_style && q_widget == other.q_widget; } - inline bool operator!=(const QLayoutStyleInfo &other) - { return !(*this == other); } - -private: - bool q_valid; - QStyle *q_style; - QWidget *q_widget; -}; - class QGridLayoutBox { public: diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 7b87969..f6f1868 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -45,6 +45,7 @@ #include #include #include +#include class tst_QGraphicsAnchorLayout : public QObject { Q_OBJECT; @@ -72,6 +73,7 @@ private slots: void proportionalPreferred(); void example(); void setSpacing(); + void styleDefaults(); void hardComplexS60(); void stability(); void delete_anchor(); @@ -1102,6 +1104,166 @@ void tst_QGraphicsAnchorLayout::setSpacing() delete view; } +class CustomLayoutStyle : public QWindowsStyle +{ + Q_OBJECT +public: + CustomLayoutStyle() : QWindowsStyle() + { + hspacing = 5; + vspacing = 10; + } + + virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, + const QWidget * widget = 0 ) const; + + int hspacing; + int vspacing; + +protected slots: + int layoutSpacingImplementation(QSizePolicy::ControlType control1, + QSizePolicy::ControlType control2, + Qt::Orientation orientation, + const QStyleOption *option = 0, + const QWidget *widget = 0) const; + +}; + +#define CT1(c) CT2(c, c) +#define CT2(c1, c2) ((uint)c1 << 16) | (uint)c2 + +int CustomLayoutStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1, + QSizePolicy::ControlType control2, + Qt::Orientation orientation, + const QStyleOption * /*option = 0*/, + const QWidget * /*widget = 0*/) const +{ + if (orientation == Qt::Horizontal) { + switch (CT2(control1, control2)) { + case CT1(QSizePolicy::PushButton): + return 2; + break; + } + return 5; + } else { + switch (CT2(control1, control2)) { + case CT1(QSizePolicy::RadioButton): + return 2; + break; + + } + return 10; + } +} + +int CustomLayoutStyle::pixelMetric(PixelMetric metric, const QStyleOption * option /*= 0*/, + const QWidget * widget /*= 0*/ ) const +{ + switch (metric) { + case PM_LayoutLeftMargin: + return 0; + break; + case PM_LayoutTopMargin: + return 3; + break; + case PM_LayoutRightMargin: + return 6; + break; + case PM_LayoutBottomMargin: + return 9; + break; + case PM_LayoutHorizontalSpacing: + return hspacing; + case PM_LayoutVerticalSpacing: + return vspacing; + break; + default: + break; + } + return QWindowsStyle::pixelMetric(metric, option, widget); +} + +void tst_QGraphicsAnchorLayout::styleDefaults() +{ + QSizeF min (10, 10); + QSizeF pref(20, 20); + QSizeF max (50, 50); + + /* + create this layout, where a,b have controlType QSizePolicy::RadioButton + c,d have controlType QSizePolicy::PushButton: + +-------+ + |a | + | b | + | c | + | d| + +-------+ + */ + QGraphicsScene scene; + QGraphicsWidget *a = createItem(min, pref, max); + QSizePolicy spRadioButton = a->sizePolicy(); + spRadioButton.setControlType(QSizePolicy::RadioButton); + a->setSizePolicy(spRadioButton); + + QGraphicsWidget *b = createItem(min, pref, max); + b->setSizePolicy(spRadioButton); + + QGraphicsWidget *c = createItem(min, pref, max); + QSizePolicy spPushButton = c->sizePolicy(); + spPushButton.setControlType(QSizePolicy::PushButton); + c->setSizePolicy(spPushButton); + + QGraphicsWidget *d = createItem(min, pref, max); + d->setSizePolicy(spPushButton); + + QGraphicsWidget *window = new QGraphicsWidget(0, Qt::Window); + + // Test layoutSpacingImplementation + CustomLayoutStyle *style = new CustomLayoutStyle; + style->hspacing = -1; + style->vspacing = -1; + window->setStyle(style); + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + + l->addCornerAnchors(l, Qt::TopLeftCorner, a, Qt::TopLeftCorner); + l->addCornerAnchors(a, Qt::BottomRightCorner, b, Qt::TopLeftCorner); + l->addCornerAnchors(b, Qt::BottomRightCorner, c, Qt::TopLeftCorner); + l->addCornerAnchors(c, Qt::BottomRightCorner, d, Qt::TopLeftCorner); + l->addCornerAnchors(d, Qt::BottomRightCorner, l, Qt::BottomRightCorner); + + window->setLayout(l); + + scene.addItem(window); + + window->show(); + QGraphicsView *view = new QGraphicsView(&scene); + view->resize(200, 200); + view->show(); + + window->adjustSize(); + QCOMPARE(a->geometry(), QRectF(0, 3, 20, 20)); //radio + QCOMPARE(b->geometry(), QRectF(25, 25, 20, 20)); //radio + QCOMPARE(c->geometry(), QRectF(50, 55, 20, 20)); //push + QCOMPARE(d->geometry(), QRectF(72, 85, 20, 20)); //push + QCOMPARE(l->geometry(), QRectF(0, 0, 98, 114)); + + + // Test pixelMetric(PM_Layout{Horizontal|Vertical}Spacing + window->setStyle(0); + + style->hspacing = 1; + style->vspacing = 2; + + window->setStyle(style); + window->adjustSize(); + QCOMPARE(a->geometry(), QRectF(0, 3, 20, 20)); + QCOMPARE(b->geometry(), QRectF(21, 25, 20, 20)); + QCOMPARE(c->geometry(), QRectF(42, 47, 20, 20)); + QCOMPARE(d->geometry(), QRectF(63, 69, 20, 20)); + QCOMPARE(l->geometry(), QRectF(0, 0, 89, 98)); +} + + /*! Taken from "hard" complex case, found at https://cwiki.nokia.com/S60QTUI/AnchorLayoutComplexCases -- cgit v0.12 From bc49cbaab3356770eb4b27dcbc2e585bf21e9200 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 27 Oct 2009 12:15:49 +0100 Subject: QTableView would not correctly resize to contents The problem was that we didn't call ensurePolished when getting the size of the sections. Task-number: QTBUG-1002 Reviewed-by: ogoffart --- src/gui/itemviews/qheaderview.cpp | 2 ++ src/gui/itemviews/qtableview.cpp | 4 ++++ tests/auto/qtableview/tst_qtableview.cpp | 11 ++++++----- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index fc9820f..4b5ec71 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -2516,6 +2516,8 @@ QSize QHeaderView::sectionSizeFromContents(int logicalIndex) const Q_D(const QHeaderView); Q_ASSERT(logicalIndex >= 0); + ensurePolished(); + // use SizeHintRole QVariant variant = d->model->headerData(logicalIndex, d->orientation, Qt::SizeHintRole); if (variant.isValid()) diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index 2a937f1..c80faa2 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -2065,6 +2065,8 @@ int QTableView::sizeHintForRow(int row) const if (!model()) return -1; + ensurePolished(); + int left = qMax(0, columnAt(0)); int right = columnAt(d->viewport->width()); if (right == -1) // the table don't have enough columns to fill the viewport @@ -2122,6 +2124,8 @@ int QTableView::sizeHintForColumn(int column) const if (!model()) return -1; + ensurePolished(); + int top = qMax(0, rowAt(0)); int bottom = rowAt(d->viewport->height()); if (!isVisible() || bottom == -1) // the table don't have enough rows to fill the viewport diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index d8110e1..8f8781d 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -2017,8 +2017,9 @@ void tst_QTableView::resizeRowsToContents() view.resizeRowsToContents(); QCOMPARE(resizedSpy.count(), model.rowCount()); - for (int r = 0; r < model.rowCount(); ++r) + for (int r = 0; r < model.rowCount(); ++r) { QCOMPARE(view.rowHeight(r), rowHeight); + } } void tst_QTableView::resizeColumnsToContents_data() @@ -3267,12 +3268,12 @@ void tst_QTableView::resizeToContents() //now let's check the row/col sizes for(int i = 0;i Date: Tue, 27 Oct 2009 12:49:06 +0100 Subject: Designer: Fix potential crash when moving pages of a QTabWidget ... which has movable=true, conflicting with its internal drag and drop. Introduce 'movable' as fake property. Reviewed-by: Jarek Kobus Task-number: QT-1788 --- tools/designer/src/lib/shared/qdesigner_tabwidget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp b/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp index 2789bd3..f4f3d24 100644 --- a/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp +++ b/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp @@ -399,6 +399,7 @@ static const char *currentTabNameKey = "currentTabName"; static const char *currentTabIconKey = "currentTabIcon"; static const char *currentTabToolTipKey = "currentTabToolTip"; static const char *currentTabWhatsThisKey = "currentTabWhatsThis"; +static const char *tabMovableKey = "movable"; QTabWidgetPropertySheet::QTabWidgetPropertySheet(QTabWidget *object, QObject *parent) : QDesignerPropertySheet(object, parent), @@ -411,6 +412,8 @@ QTabWidgetPropertySheet::QTabWidgetPropertySheet(QTabWidget *object, QObject *pa formWindowBase()->addReloadableProperty(this, indexOf(QLatin1String(currentTabIconKey))); createFakeProperty(QLatin1String(currentTabToolTipKey), qVariantFromValue(qdesigner_internal::PropertySheetStringValue())); createFakeProperty(QLatin1String(currentTabWhatsThisKey), qVariantFromValue(qdesigner_internal::PropertySheetStringValue())); + // Prevent the tab widget's drag and drop handling from interfering with Designer's + createFakeProperty(QLatin1String(tabMovableKey), QVariant(false)); } QTabWidgetPropertySheet::TabWidgetProperty QTabWidgetPropertySheet::tabWidgetPropertyFromName(const QString &name) -- cgit v0.12 From 11b1ced7cdc2af028164381d43c146ec79919f19 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 26 Oct 2009 15:55:16 +0100 Subject: Do not hardecode the ToolBar Icon Size So we correctly get the size from the platform plugin Reviewed-by: jbache --- src/gui/styles/qcommonstyle.cpp | 2 +- src/gui/styles/qplastiquestyle.cpp | 3 --- src/gui/styles/qwindowsstyle.cpp | 3 --- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index 5886512..b871842 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -4661,7 +4661,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid case PM_ToolBarIconSize: ret = qt_guiPlatformPlugin()->platformHint(QGuiPlatformPlugin::PH_ToolBarIconSize); if (!ret) - ret = proxy()->pixelMetric(PM_SmallIconSize, opt, widget); + ret = int(QStyleHelper::dpiScaled(24.)); break; case PM_TabBarIconSize: diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp index ce2109a..1f77d90 100644 --- a/src/gui/styles/qplastiquestyle.cpp +++ b/src/gui/styles/qplastiquestyle.cpp @@ -5514,9 +5514,6 @@ int QPlastiqueStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, case PM_MenuHMargin: ret = 0; break; - case PM_ToolBarIconSize: - ret = 24; - break; case PM_ButtonShiftHorizontal: case PM_ButtonShiftVertical: ret = 1; diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp index 0f72440..5cf738e 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -454,9 +454,6 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget); break; - case PM_ToolBarIconSize: - ret = int(QStyleHelper::dpiScaled(24.)); - break; case PM_DockWidgetTitleMargin: ret = int(QStyleHelper::dpiScaled(2.)); break; -- cgit v0.12 From 5ff7b773a0f59e174001da1f0550a7f0c2b6f485 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 27 Oct 2009 11:39:51 +0100 Subject: Fixes QTreeView: stylesheet :has-children pseudo selector doesn't works for the ::item pseudo-class The State_Children was not set on the QStyleOption. Refactorized a little bit the way it was computed. Reviewed-by: Thierry Task-number: 234930 Task-number: QTBUG-3129 --- src/gui/itemviews/qtreeview.cpp | 28 +++++++++++++++------------ src/gui/itemviews/qtreeview_p.h | 3 ++- tests/auto/qtreeview/tst_qtreeview.cpp | 35 +++++++++++++++++++++++++++++++--- 3 files changed, 50 insertions(+), 16 deletions(-) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index f37d8c7..49c8e34 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -1422,8 +1422,8 @@ void QTreeView::drawTree(QPainter *painter, const QRegion ®ion) const for (; i < viewItems.count() && y <= area.bottom(); ++i) { const int itemHeight = d->itemHeight(i); option.rect.setRect(0, y, viewportWidth, itemHeight); - option.state = state | (viewItems.at(i).expanded - ? QStyle::State_Open : QStyle::State_None); + option.state = state | (viewItems.at(i).expanded ? QStyle::State_Open : QStyle::State_None) + | (viewItems.at(i).hasChildren ? QStyle::State_Children : QStyle::State_None ); d->current = i; d->spanning = viewItems.at(i).spanning; if (!multipleRects || !drawn.contains(i)) { @@ -1748,8 +1748,7 @@ void QTreeView::drawBranches(QPainter *painter, const QRect &rect, opt.rect = primitive; const bool expanded = viewItem.expanded; - const bool children = (((expanded && viewItem.total > 0)) // already laid out and has children - || d->hasVisibleChildren(index)); // not laid out yet, so we don't know + const bool children = viewItem.hasChildren; bool moreSiblings = false; if (d->hiddenIndexes.isEmpty()) moreSiblings = (d->model->rowCount(parent) - 1 > index.row()); @@ -3135,17 +3134,22 @@ void QTreeViewPrivate::layout(int i) last = j - hidden + children; } else { last = j - hidden + children; - viewItems[last].index = current; - viewItems[last].level = level; - viewItems[last].height = 0; - viewItems[last].spanning = q->isFirstColumnSpanned(current.row(), parent); - viewItems[last].expanded = false; - viewItems[last].total = 0; + QTreeViewItem *item = &viewItems[last]; + item->index = current; + item->level = level; + item->height = 0; + item->spanning = q->isFirstColumnSpanned(current.row(), parent); + item->expanded = false; + item->total = 0; if (isIndexExpanded(current)) { - viewItems[last].expanded = true; + item->expanded = true; layout(last); - children += viewItems[last].total; + item = &viewItems[last]; + children += item->total; + item->hasChildren = item->total > 0; last = j - hidden + children; + } else { + item->hasChildren = hasVisibleChildren(current); } } } diff --git a/src/gui/itemviews/qtreeview_p.h b/src/gui/itemviews/qtreeview_p.h index def8253..f89c328 100644 --- a/src/gui/itemviews/qtreeview_p.h +++ b/src/gui/itemviews/qtreeview_p.h @@ -66,7 +66,8 @@ struct QTreeViewItem QModelIndex index; // we remove items whenever the indexes are invalidated uint expanded : 1; uint spanning : 1; - uint total : 30; // total number of children visible + uint hasChildren : 1; // if the item has visible children (even if collapsed) + uint total : 29; // total number of children visible uint level : 16; // indentation int height : 16; // row height }; diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index da58725..8d824cb 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -2891,7 +2891,8 @@ void tst_QTreeView::styleOptionViewItem() QVERIFY(!opt.text.isEmpty()); QCOMPARE(opt.index, index); - QCOMPARE(!(opt.features & QStyleOptionViewItemV2::Alternate), !(index.row() % 2)); + if (allCollapsed) + QCOMPARE(!(opt.features & QStyleOptionViewItemV2::Alternate), !(index.row() % 2)); QCOMPARE(!(opt.features & QStyleOptionViewItemV2::HasCheckIndicator), !opt.text.contains("Checkable")); if (opt.text.contains("Beginning")) @@ -2911,12 +2912,15 @@ void tst_QTreeView::styleOptionViewItem() else QCOMPARE(opt.checkState, Qt::Unchecked); + QCOMPARE(!(opt.state & QStyle::State_Children) , !opt.text.contains("HasChildren")); + QVERIFY(!opt.text.contains("Assert")); QStyledItemDelegate::paint(painter, option, index); count++; } mutable int count; + bool allCollapsed; }; QTreeView view; @@ -2926,8 +2930,9 @@ void tst_QTreeView::styleOptionViewItem() view.setItemDelegate(&delegate); model.appendRow(QList() << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") ); + QStandardItem *par1 = new QStandardItem("Beginning HasChildren"); model.appendRow(QList() - << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") ); + << par1 << new QStandardItem("Middle HasChildren") << new QStandardItem("Middle HasChildren") << new QStandardItem("End HasChildren") ); model.appendRow(QList() << new QStandardItem("OnlyOne") << new QStandardItem("Assert") << new QStandardItem("Assert") << new QStandardItem("Assert") ); QStandardItem *checkable = new QStandardItem("Checkable"); @@ -2938,12 +2943,37 @@ void tst_QTreeView::styleOptionViewItem() model.appendRow(QList() << new QStandardItem("Beginning") << checkable << checked << new QStandardItem("End") ); + par1->appendRow(QList() + << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") ); + QStandardItem *par2 = new QStandardItem("Beginning HasChildren"); + par1->appendRow(QList() + << par2 << new QStandardItem("Middle HasChildren") << new QStandardItem("Middle HasChildren") << new QStandardItem("End HasChildren") ); + par2->appendRow(QList() + << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") ); + + QStandardItem *par3 = new QStandardItem("Beginning"); + par1->appendRow(QList() + << par3 << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") ); + par3->appendRow(QList() + << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") ); + view.setRowHidden(0, par3->index(), true); + view.setFirstColumnSpanned(2, QModelIndex(), true); view.setAlternatingRowColors(true); delegate.count = 0; + delegate.allCollapsed = true; view.showMaximized(); + QApplication::processEvents(); QTRY_VERIFY(delegate.count >= 13); + delegate.count = 0; + delegate.allCollapsed = false; + view.expandAll(); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 13); + view.collapse(par2->index()); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 4); } class task174627_TreeView : public QTreeView @@ -3508,6 +3538,5 @@ void tst_QTreeView::task245654_changeModelAndExpandAll() } - QTEST_MAIN(tst_QTreeView) #include "tst_qtreeview.moc" -- cgit v0.12 From 0897713a560700f574386499a872f59e3fc4ce7d Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 27 Oct 2009 12:45:21 +0100 Subject: QTreeView: Make sure the state QStyle::State_Sibling is correctly set That state used not to be set for drawing the content of the items. Also, it could be wrong for branches if there was hidden items. Reviewed-by: Thierry Task-number: related to 234930 --- src/gui/itemviews/qtreeview.cpp | 17 ++++++++--------- src/gui/itemviews/qtreeview_p.h | 3 ++- tests/auto/qtreeview/tst_qtreeview.cpp | 15 +++++++++++---- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 49c8e34..e74ecfc 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -1423,7 +1423,8 @@ void QTreeView::drawTree(QPainter *painter, const QRegion ®ion) const const int itemHeight = d->itemHeight(i); option.rect.setRect(0, y, viewportWidth, itemHeight); option.state = state | (viewItems.at(i).expanded ? QStyle::State_Open : QStyle::State_None) - | (viewItems.at(i).hasChildren ? QStyle::State_Children : QStyle::State_None ); + | (viewItems.at(i).hasChildren ? QStyle::State_Children : QStyle::State_None) + | (viewItems.at(i).hasMoreSiblings ? QStyle::State_Sibling : QStyle::State_None); d->current = i; d->spanning = viewItems.at(i).spanning; if (!multipleRects || !drawn.contains(i)) { @@ -1749,12 +1750,7 @@ void QTreeView::drawBranches(QPainter *painter, const QRect &rect, const bool expanded = viewItem.expanded; const bool children = viewItem.hasChildren; - bool moreSiblings = false; - if (d->hiddenIndexes.isEmpty()) - moreSiblings = (d->model->rowCount(parent) - 1 > index.row()); - else - moreSiblings = ((d->viewItems.size() > item +1) - && (d->viewItems.at(item + 1).index.parent() == parent)); + bool moreSiblings = viewItem.hasMoreSiblings; opt.state = QStyle::State_Item | extraFlags | (moreSiblings ? QStyle::State_Sibling : QStyle::State_None) @@ -3126,7 +3122,7 @@ void QTreeViewPrivate::layout(int i) int hidden = 0; int last = 0; int children = 0; - + QTreeViewItem *item = 0; for (int j = first; j < first + count; ++j) { current = model->index(j - first, 0, parent); if (isRowHidden(current)) { @@ -3134,13 +3130,16 @@ void QTreeViewPrivate::layout(int i) last = j - hidden + children; } else { last = j - hidden + children; - QTreeViewItem *item = &viewItems[last]; + if (item) + item->hasMoreSiblings = true; + item = &viewItems[last]; item->index = current; item->level = level; item->height = 0; item->spanning = q->isFirstColumnSpanned(current.row(), parent); item->expanded = false; item->total = 0; + item->hasMoreSiblings = false; if (isIndexExpanded(current)) { item->expanded = true; layout(last); diff --git a/src/gui/itemviews/qtreeview_p.h b/src/gui/itemviews/qtreeview_p.h index f89c328..62676d8 100644 --- a/src/gui/itemviews/qtreeview_p.h +++ b/src/gui/itemviews/qtreeview_p.h @@ -67,7 +67,8 @@ struct QTreeViewItem uint expanded : 1; uint spanning : 1; uint hasChildren : 1; // if the item has visible children (even if collapsed) - uint total : 29; // total number of children visible + uint hasMoreSiblings : 1; + uint total : 28; // total number of children visible uint level : 16; // indentation int height : 16; // row height }; diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index 8d824cb..cbc999f 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -2913,6 +2913,7 @@ void tst_QTreeView::styleOptionViewItem() QCOMPARE(opt.checkState, Qt::Unchecked); QCOMPARE(!(opt.state & QStyle::State_Children) , !opt.text.contains("HasChildren")); + QCOMPARE(!!(opt.state & QStyle::State_Sibling) , !opt.text.contains("Last")); QVERIFY(!opt.text.contains("Assert")); @@ -2942,6 +2943,8 @@ void tst_QTreeView::styleOptionViewItem() checked->setCheckState(Qt::Checked); model.appendRow(QList() << new QStandardItem("Beginning") << checkable << checked << new QStandardItem("End") ); + model.appendRow(QList() + << new QStandardItem("Beginning Last") << new QStandardItem("Middle Last") << new QStandardItem("Middle Last") << new QStandardItem("End Last") ); par1->appendRow(QList() << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") ); @@ -2949,14 +2952,18 @@ void tst_QTreeView::styleOptionViewItem() par1->appendRow(QList() << par2 << new QStandardItem("Middle HasChildren") << new QStandardItem("Middle HasChildren") << new QStandardItem("End HasChildren") ); par2->appendRow(QList() - << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") ); + << new QStandardItem("Beginning Last") << new QStandardItem("Middle Last") << new QStandardItem("Middle Last") << new QStandardItem("End Last") ); - QStandardItem *par3 = new QStandardItem("Beginning"); + QStandardItem *par3 = new QStandardItem("Beginning Last"); par1->appendRow(QList() - << par3 << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") ); + << par3 << new QStandardItem("Middle Last") << new QStandardItem("Middle Last") << new QStandardItem("End Last") ); par3->appendRow(QList() - << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") ); + << new QStandardItem("Assert") << new QStandardItem("Assert") << new QStandardItem("Assert") << new QStandardItem("Asser") ); view.setRowHidden(0, par3->index(), true); + par1->appendRow(QList() + << new QStandardItem("Assert") << new QStandardItem("Assert") << new QStandardItem("Assert") << new QStandardItem("Asser") ); + view.setRowHidden(3, par1->index(), true); + view.setFirstColumnSpanned(2, QModelIndex(), true); view.setAlternatingRowColors(true); -- cgit v0.12 From 40d7920da5762addbbef36ebc049c32409b575cf Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Tue, 27 Oct 2009 14:21:53 +0200 Subject: Cleanup softkeymanager keyedactions hash when QAction is being deleted. Reviewed-by: TrustMe --- src/gui/kernel/qsoftkeymanager.cpp | 9 ++++++++- src/gui/kernel/qsoftkeymanager_p.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index 75c321e..a5e8eff 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -139,11 +139,18 @@ QAction *QSoftKeyManager::createKeyedAction(StandardSoftKey standardKey, Qt::Key QScopedPointer action(createAction(standardKey, actionWidget)); connect(action.data(), SIGNAL(triggered()), QSoftKeyManager::instance(), SLOT(sendKeyEvent())); - + connect(action.data(), SIGNAL(destroyed(QObject*)), QSoftKeyManager::instance(), SLOT(cleanupHash(QObject*))); QSoftKeyManager::instance()->d_func()->keyedActions.insert(action.data(), key); return action.take(); } +void QSoftKeyManager::cleanupHash(QObject* obj) +{ + Q_D(QSoftKeyManager); + QAction *action = qobject_cast(obj); + d->keyedActions.remove(action); +} + void QSoftKeyManager::sendKeyEvent() { Q_D(QSoftKeyManager); diff --git a/src/gui/kernel/qsoftkeymanager_p.h b/src/gui/kernel/qsoftkeymanager_p.h index b455445..81218cf 100644 --- a/src/gui/kernel/qsoftkeymanager_p.h +++ b/src/gui/kernel/qsoftkeymanager_p.h @@ -96,6 +96,7 @@ protected: Q_DISABLE_COPY(QSoftKeyManager) private Q_SLOTS: + void cleanupHash(QObject* obj); void sendKeyEvent(); }; -- cgit v0.12 From 8dd9e9b5f3e794ecdb70a3b43c4a2e17a8d139a8 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Tue, 27 Oct 2009 14:33:29 +0200 Subject: Fixed 'illegal empty declaration' warning from XmlPatters. The following warning was reported by MWCCSYM2 (Symbian emulator compiler): \src\xmlpatterns\api\qxmlquery.h:77: warning: illegal empty declaration Reviewed-by: TrustMe --- src/xmlpatterns/api/qxmlquery.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xmlpatterns/api/qxmlquery.h b/src/xmlpatterns/api/qxmlquery.h index abfddc0..37e4fe1 100644 --- a/src/xmlpatterns/api/qxmlquery.h +++ b/src/xmlpatterns/api/qxmlquery.h @@ -74,7 +74,7 @@ namespace QPatternist class XsdSchemaParser; class XsdValidatingInstanceReader; class VariableLoader; -}; +} class Q_XMLPATTERNS_EXPORT QXmlQuery { -- cgit v0.12 From d683fd25512dedacdac141222db36209ef65e42d Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 27 Oct 2009 13:43:42 +0100 Subject: Fixed QTreeView not emitting doubleCliked when 1st col is spanned Task-number: QTBUG-976 Reviewed-by: ogoffart --- src/gui/itemviews/qtreeview.cpp | 4 +--- tests/auto/qtreeview/tst_qtreeview.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index e74ecfc..16b454d 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -1840,9 +1840,7 @@ void QTreeView::mouseDoubleClickEvent(QMouseEvent *event) return; // user clicked outside the items const QPersistentModelIndex firstColumnIndex = d->viewItems.at(i).index; - - int column = d->header->logicalIndexAt(event->x()); - QPersistentModelIndex persistent = firstColumnIndex.sibling(firstColumnIndex.row(), column); + const QPersistentModelIndex persistent = indexAt(event->pos()); if (d->pressedIndex != persistent) { mousePressEvent(event); diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index cbc999f..1429771 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -235,6 +235,7 @@ private slots: void task254234_proxySort(); void task248022_changeSelection(); void task245654_changeModelAndExpandAll(); + void doubleClickedWithSpans(); }; class QtTestModel: public QAbstractItemModel @@ -3544,6 +3545,34 @@ void tst_QTreeView::task245654_changeModelAndExpandAll() } +void tst_QTreeView::doubleClickedWithSpans() +{ + QTreeView view; + QStandardItemModel model(1, 2); + view.setModel(&model); + view.setFirstColumnSpanned(0, QModelIndex(), true); + view.show(); + + QPoint p(10, 10); + QCOMPARE(view.indexAt(p), model.index(0, 0)); + QSignalSpy spy(&view, SIGNAL(doubleClicked(QModelIndex))); + QTest::mousePress(view.viewport(), Qt::LeftButton, 0, p); + QTest::mouseDClick(view.viewport(), Qt::LeftButton, 0, p); + QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, p); + QCOMPARE(spy.count(), 1); + + //let's click on the 2nd column + p.setX(p.x() + view.header()->sectionSize(0)); + QCOMPARE(view.indexAt(p), model.index(0, 0)); + + //end the previous edition + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p); + QTest::qWait(100); + QTest::mousePress(view.viewport(), Qt::LeftButton, 0, p); + QTest::mouseDClick(view.viewport(), Qt::LeftButton, 0, p); + QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, p); + QCOMPARE(spy.count(), 2); +} QTEST_MAIN(tst_QTreeView) #include "tst_qtreeview.moc" -- cgit v0.12 From 8f040ea4da93f1b9cae1db560e5e9f9b3140b3ff Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 27 Oct 2009 13:48:39 +0100 Subject: QVariant::isNull does not return the right result with QVariant::setValue Inspired by merge request 1911 Reveiwed-by: Thierry --- src/corelib/kernel/qvariant.h | 1 + tests/auto/qvariant/tst_qvariant.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index eb4fb56..4cce529 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -460,6 +460,7 @@ inline void qVariantSetValue(QVariant &v, const T &t) QVariant::Private &d = v.data_ptr(); if (v.isDetached() && (type <= int(QVariant::Char) || type == d.type)) { d.type = type; + d.is_null = false; T *old = reinterpret_cast(d.is_shared ? d.data.shared->ptr : &d.data.ptr); if (QTypeInfo::isComplex) old->~T(); diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index 9295897..de4d7b4 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -318,6 +318,14 @@ void tst_QVariant::constructor() QVariant var6(qlonglong(0)); QCOMPARE(var6.type(), QVariant::LongLong); QCOMPARE(var6.typeName(), "qlonglong"); + + QVariant var7 = 5; + QVERIFY(var7.isValid()); + QVERIFY(!var7.isNull()); + QVariant var8; + var8.setValue(5); + QVERIFY(var8.isValid()); + QVERIFY(!var8.isNull()); } void tst_QVariant::copy_constructor() -- cgit v0.12 From 3c6c4c6af0d5651097f7eb7c3b7b87eed5e8cc8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 27 Oct 2009 13:51:07 +0100 Subject: Fixed compilation of QGraphicsEffectSource autotest. --- tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp index 0635989..fbeb425 100644 --- a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp +++ b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp @@ -332,7 +332,7 @@ public: return src.adjusted(-10, -10, 10, 10); } - void draw(QPainter *p, QGraphicsEffectSource *source) { + void draw(QPainter *, QGraphicsEffectSource *source) { pix = source->pixmap(coordinateMode, &offset, padMode); } @@ -351,7 +351,7 @@ void tst_QGraphicsEffectSource::pixmapPadding_data() QTest::addColumn("ulPixel"); QTest::newRow("log,nopad") << int(Qt::LogicalCoordinates) - << int(QGraphicsEffectSource::NoPadMode) + << int(QGraphicsEffectSource::NoExpandPadMode) << QSize(10, 10) << QPoint(0, 0) << 0xffff0000u; @@ -366,7 +366,7 @@ void tst_QGraphicsEffectSource::pixmapPadding_data() << 0x00000000u; QTest::newRow("dev,nopad") << int(Qt::DeviceCoordinates) - << int(QGraphicsEffectSource::NoPadMode) + << int(QGraphicsEffectSource::NoExpandPadMode) << QSize(20, 20) << QPoint(40, 40) << 0xffff0000u; -- cgit v0.12 From 5bc69a86b75c1e25e0859ee27714e54878193e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Tue, 27 Oct 2009 15:20:56 +0200 Subject: Draw QSplitter in QS60Style Previously QS60Style did not draw CE_Splitter control at all. With this change, the style draws it when user presses the splitter down to make a drag. Since native side does not have splitter at all, we are drawing splitter rect as partially transparent rounded rect with QPalette::Light (which has been picked from active theme). Task-number: QT-686 Reviewed-by: Shane Kearns --- src/gui/styles/qs60style.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 8ef0dd3..580f949 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1890,6 +1890,17 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, painter->restore(); } break; + case CE_Splitter: + if (option->state & State_Sunken && option->state & State_Enabled) { + painter->save(); + painter->setOpacity(0.5); + painter->setBrush(d->themePalette()->light()); + painter->setRenderHint(QPainter::Antialiasing); + const qreal roundRectRadius = 4 * goldenRatio; + painter->drawRoundedRect(option->rect, roundRectRadius, roundRectRadius); + painter->restore(); + } + break; default: QCommonStyle::drawControl(element, option, painter, widget); } -- cgit v0.12 From a4b77f3887a4eb0f3ce103d2457f57e94938d771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 27 Oct 2009 14:32:05 +0100 Subject: Fix the combobox popup 1-second fadeout regression on Carbon. Regression caused by b946da648af0c5fa1c73fe1e57b0b1e08fb14d13. Prior to that commit, the default duration for macWindowFade was 0, but there was code in the implementation that set it to 0.15 in that case. Set the default duration to 0.15. This matches the old behavior when calling macWindowFade without specifying a duration, and makes it clearer what the default really is. --- src/gui/kernel/qt_cocoa_helpers_mac_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/gui/kernel/qt_cocoa_helpers_mac_p.h index 62db064..5318d31 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac_p.h +++ b/src/gui/kernel/qt_cocoa_helpers_mac_p.h @@ -116,7 +116,7 @@ typedef struct CGPoint NSPoint; QT_BEGIN_NAMESPACE Qt::MouseButtons qt_mac_get_buttons(int buttons); Qt::MouseButton qt_mac_get_button(EventMouseButton button); -void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds = 0); +void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds = 0.15); bool macWindowIsTextured(void * /*OSWindowRef*/ window); void macWindowToolbarShow(const QWidget *widget, bool show ); void macWindowToolbarSet( void * /*OSWindowRef*/ window, void* toolbarRef ); -- cgit v0.12 From d0b0e0ed8ac857d78e497b74bb1c3596273c53ba Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 27 Oct 2009 15:10:46 +0100 Subject: QLibrary on Windows: Do not show error boxes when library load fails When loading a library fails, the error message "The application or DLL ... is not a valid Windows image. Please check this against your installation diskette." is shown, which is not very helpful. Task-number: QT-2357 Reviewed-by: Marius Storm-Olsen --- src/corelib/plugin/qlibrary.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index 2b463a1..6496876 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -659,7 +659,10 @@ bool QLibraryPrivate::isPlugin(QSettings *settings) #endif if (!pHnd) { #ifdef Q_OS_WIN + //avoid 'Bad Image' message box + UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); hTempModule = ::LoadLibraryEx((wchar_t*)QDir::toNativeSeparators(fileName).utf16(), 0, DONT_RESOLVE_DLL_REFERENCES); + SetErrorMode(oldmode); #else # if defined(Q_OS_SYMBIAN) //Guard against accidentally trying to load non-plugin libraries by making sure the stub exists -- cgit v0.12 From dbb127c226f131fabe39d9ce89ace5d3e6f7deb9 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 27 Oct 2009 15:04:48 +0100 Subject: Fixed QPainterPath to properly set the convex hint on QVectorPath's Reviewed-by: Samuel --- src/gui/painting/qpainterpath.cpp | 15 +++++++++++++++ src/gui/painting/qpainterpath_p.h | 37 +++++++++++++++++++++++-------------- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 69e189c..c40bcee 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -688,6 +688,8 @@ void QPainterPath::lineTo(const QPointF &p) return; Element elm = { p.x(), p.y(), LineToElement }; d->elements.append(elm); + + d->convex = d->elements.size() == 3 || (d->elements.size() == 4 && d->isClosed()); } /*! @@ -960,6 +962,8 @@ void QPainterPath::addRect(const QRectF &r) ensureData(); detach(); + bool first = d_func()->elements.size() < 2; + d_func()->elements.reserve(d_func()->elements.size() + 5); moveTo(r.x(), r.y()); @@ -970,6 +974,7 @@ void QPainterPath::addRect(const QRectF &r) d_func()->elements << l1 << l2 << l3 << l4; d_func()->require_moveTo = true; + d_func()->convex = first; } /*! @@ -1039,6 +1044,7 @@ void QPainterPath::addEllipse(const QRectF &boundingRect) detach(); Q_D(QPainterPath); + bool first = d_func()->elements.size() < 2; d->elements.reserve(d->elements.size() + 13); QPointF pts[12]; @@ -1051,6 +1057,8 @@ void QPainterPath::addEllipse(const QRectF &boundingRect) cubicTo(pts[6], pts[7], pts[8]); // 180 -> 90 cubicTo(pts[9], pts[10], pts[11]); // 90 - >0 d_func()->require_moveTo = true; + + d_func()->convex = first; } /*! @@ -3027,6 +3035,8 @@ void QPainterPath::addRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadi ensureData(); detach(); + bool first = d_func()->elements.size() < 2; + arcMoveTo(x, y, rxx2, ryy2, 90); arcTo(x, y, rxx2, ryy2, 90, 90); arcTo(x, y+h-ryy2, rxx2, ryy2, 2*90, 90); @@ -3035,6 +3045,7 @@ void QPainterPath::addRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadi closeSubpath(); d_func()->require_moveTo = true; + d_func()->convex = first; } /*! @@ -3081,6 +3092,8 @@ void QPainterPath::addRoundRect(const QRectF &r, int xRnd, int yRnd) ensureData(); detach(); + bool first = d_func()->elements.size() < 2; + arcMoveTo(x, y, rxx2, ryy2, 90); arcTo(x, y, rxx2, ryy2, 90, 90); arcTo(x, y+h-ryy2, rxx2, ryy2, 2*90, 90); @@ -3089,6 +3102,7 @@ void QPainterPath::addRoundRect(const QRectF &r, int xRnd, int yRnd) closeSubpath(); d_func()->require_moveTo = true; + d_func()->convex = first; } /*! @@ -3269,6 +3283,7 @@ void QPainterPath::setDirty(bool dirty) d_func()->dirtyControlBounds = dirty; delete d_func()->pathConverter; d_func()->pathConverter = 0; + d_func()->convex = false; } void QPainterPath::computeBoundingRect() const diff --git a/src/gui/painting/qpainterpath_p.h b/src/gui/painting/qpainterpath_p.h index fbdb9a6..112c2bd 100644 --- a/src/gui/painting/qpainterpath_p.h +++ b/src/gui/painting/qpainterpath_p.h @@ -81,8 +81,8 @@ class QVectorPathConverter; class QVectorPathConverter { public: - QVectorPathConverter(const QVector &path, uint fillRule) - : pathData(path, fillRule), + QVectorPathConverter(const QVector &path, uint fillRule, bool convex) + : pathData(path, fillRule, convex), path(pathData.points.data(), path.size(), pathData.elements.data(), pathData.flags) {} @@ -91,7 +91,7 @@ public: } struct QVectorPathData { - QVectorPathData(const QVector &path, uint fillRule) + QVectorPathData(const QVector &path, uint fillRule, bool convex) : elements(path.size()), points(path.size() * 2), flags(0) @@ -111,6 +111,8 @@ public: else flags |= QVectorPath::OddEvenFill; + if (!convex) + flags |= QVectorPath::NonConvexShapeMask; } QVarLengthArray elements; QVarLengthArray points; @@ -128,20 +130,26 @@ class QPainterPathData : public QPainterPathPrivate { public: QPainterPathData() : - cStart(0), fillRule(Qt::OddEvenFill), - dirtyBounds(false), dirtyControlBounds(false), - pathConverter(0) + cStart(0), + fillRule(Qt::OddEvenFill), + pathConverter(0), + dirtyBounds(false), + dirtyControlBounds(false) + { ref = 1; require_moveTo = false; + convex = false; } QPainterPathData(const QPainterPathData &other) : QPainterPathPrivate(), cStart(other.cStart), fillRule(other.fillRule), - dirtyBounds(other.dirtyBounds), bounds(other.bounds), - dirtyControlBounds(other.dirtyControlBounds), + bounds(other.bounds), controlBounds(other.controlBounds), - pathConverter(0) + pathConverter(0), + dirtyBounds(other.dirtyBounds), + dirtyControlBounds(other.dirtyControlBounds), + convex(other.convex) { ref = 1; require_moveTo = false; @@ -158,20 +166,21 @@ public: const QVectorPath &vectorPath() { if (!pathConverter) - pathConverter = new QVectorPathConverter(elements, fillRule); + pathConverter = new QVectorPathConverter(elements, fillRule, convex); return pathConverter->path; } int cStart; Qt::FillRule fillRule; - bool require_moveTo; - - bool dirtyBounds; QRectF bounds; - bool dirtyControlBounds; QRectF controlBounds; + uint require_moveTo : 1; + uint dirtyBounds : 1; + uint dirtyControlBounds : 1; + uint convex : 1; + QVectorPathConverter *pathConverter; }; -- cgit v0.12 From c79d83b6d661ea49d893b4590480a434d75b19bd Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 27 Oct 2009 15:18:59 +0100 Subject: QComboBox did not emit currentItemChanged when the model was reset Task-number: QTBUG-569 Reviewed-by: ogoffart --- src/gui/widgets/qcombobox.cpp | 27 +++++++++++---------------- src/gui/widgets/qcombobox.h | 3 +-- src/gui/widgets/qcombobox_p.h | 3 +-- tests/auto/qcombobox/tst_qcombobox.cpp | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 20 deletions(-) diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 0e888d6..7cf35c7 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -192,6 +192,8 @@ void QComboBoxPrivate::_q_modelReset() lineEdit->setText(QString()); updateLineEditGeometry(); } + if (currentIndex.row() != indexBeforeChange) + _q_emitCurrentIndexChanged(currentIndex); q->update(); } @@ -992,14 +994,6 @@ void QComboBoxPrivate::_q_dataChanged(const QModelIndex &topLeft, const QModelIn } } -void QComboBoxPrivate::_q_rowsAboutToBeInserted(const QModelIndex & parent, - int /*start*/, int /*end*/) -{ - if (parent != root) - return; - indexBeforeChange = currentIndex.row(); -} - void QComboBoxPrivate::_q_rowsInserted(const QModelIndex &parent, int start, int end) { Q_Q(QComboBox); @@ -1022,11 +1016,8 @@ void QComboBoxPrivate::_q_rowsInserted(const QModelIndex &parent, int start, int } } -void QComboBoxPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &parent, int /*start*/, int /*end*/) +void QComboBoxPrivate::_q_updateIndexBeforeChange() { - if (parent != root) - return; - indexBeforeChange = currentIndex.row(); } @@ -1868,15 +1859,17 @@ void QComboBox::setModel(QAbstractItemModel *model) disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); disconnect(d->model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT(_q_rowsAboutToBeInserted(QModelIndex,int,int))); + this, SLOT(_q_updateIndexBeforeChange())); disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(_q_rowsInserted(QModelIndex,int,int))); disconnect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int))); + this, SLOT(_q_updateIndexBeforeChange())); disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(_q_rowsRemoved(QModelIndex,int,int))); disconnect(d->model, SIGNAL(destroyed()), this, SLOT(_q_modelDestroyed())); + disconnect(d->model, SIGNAL(modelAboutToBeReset()), + this, SLOT(_q_updateIndexBeforeChange())); disconnect(d->model, SIGNAL(modelReset()), this, SLOT(_q_modelReset())); if (d->model->QObject::parent() == this) @@ -1888,15 +1881,17 @@ void QComboBox::setModel(QAbstractItemModel *model) connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT(_q_rowsAboutToBeInserted(QModelIndex,int,int))); + this, SLOT(_q_updateIndexBeforeChange())); connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(_q_rowsInserted(QModelIndex,int,int))); connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int))); + this, SLOT(_q_updateIndexBeforeChange())); connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(_q_rowsRemoved(QModelIndex,int,int))); connect(model, SIGNAL(destroyed()), this, SLOT(_q_modelDestroyed())); + connect(model, SIGNAL(modelAboutToBeReset()), + this, SLOT(_q_updateIndexBeforeChange())); connect(model, SIGNAL(modelReset()), this, SLOT(_q_modelReset())); diff --git a/src/gui/widgets/qcombobox.h b/src/gui/widgets/qcombobox.h index 6a85096..4089a09 100644 --- a/src/gui/widgets/qcombobox.h +++ b/src/gui/widgets/qcombobox.h @@ -308,9 +308,8 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_returnPressed()) Q_PRIVATE_SLOT(d_func(), void _q_resetButton()) Q_PRIVATE_SLOT(d_func(), void _q_dataChanged(const QModelIndex &, const QModelIndex &)) - Q_PRIVATE_SLOT(d_func(), void _q_rowsAboutToBeInserted(const QModelIndex & parent, int start, int end)) + Q_PRIVATE_SLOT(d_func(), void _q_updateIndexBeforeChange()) Q_PRIVATE_SLOT(d_func(), void _q_rowsInserted(const QModelIndex & parent, int start, int end)) - Q_PRIVATE_SLOT(d_func(), void _q_rowsAboutToBeRemoved(const QModelIndex & parent, int start, int end)) Q_PRIVATE_SLOT(d_func(), void _q_rowsRemoved(const QModelIndex & parent, int start, int end)) Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed()) Q_PRIVATE_SLOT(d_func(), void _q_modelReset()) diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h index f7458c4..06e51e4 100644 --- a/src/gui/widgets/qcombobox_p.h +++ b/src/gui/widgets/qcombobox_p.h @@ -357,9 +357,8 @@ public: #endif void _q_resetButton(); void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); - void _q_rowsAboutToBeInserted(const QModelIndex & parent, int start, int end); + void _q_updateIndexBeforeChange(); void _q_rowsInserted(const QModelIndex & parent, int start, int end); - void _q_rowsAboutToBeRemoved(const QModelIndex & parent, int start, int end); void _q_rowsRemoved(const QModelIndex & parent, int start, int end); void updateArrow(QStyle::StateFlag state); bool updateHoverControl(const QPoint &pos); diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index 0d3469d..8acae7a 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -152,6 +152,7 @@ private slots: void subControlRectsWithOffset(); void task260974_menuItemRectangleForComboBoxPopup(); void removeItem(); + void resetModel(); protected slots: void onEditTextChanged( const QString &newString ); @@ -2416,5 +2417,37 @@ void tst_QComboBox::removeItem() QCOMPARE(cb.count(), 0); } +void tst_QComboBox::resetModel() +{ + class StringListModel : public QStringListModel + { + public: + StringListModel(const QStringList &list) : QStringListModel(list) + { + } + + void reset() + { + QStringListModel::reset(); + } + }; + QComboBox cb; + StringListModel model( QStringList() << "1" << "2"); + QSignalSpy spy(&cb, SIGNAL(currentIndexChanged(int))); + QCOMPARE(spy.count(), 0); + QCOMPARE(cb.currentIndex(), -1); //no selection + + cb.setModel(&model); + + QCOMPARE(spy.count(), 1); + QCOMPARE(cb.currentIndex(), 0); //first item selected + + model.reset(); + QCOMPARE(spy.count(), 2); + QCOMPARE(cb.currentIndex(), -1); //no selection + +} + + QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" -- cgit v0.12 From df26c6e14287f1a02c636c4624c5085fd8271d11 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 27 Oct 2009 15:26:11 +0100 Subject: Fix incomplete documentation for Qt::DecorationRole As noticed by Laurent Montel. Merge-request: 1812 Reviewed-by: Olivier Goffart --- src/corelib/global/qnamespace.qdoc | 2 +- src/gui/itemviews/qitemdelegate.cpp | 2 +- src/gui/itemviews/qstyleditemdelegate.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index e8d6df0..438678a 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2509,7 +2509,7 @@ \value DisplayRole The key data to be rendered in the form of text. (QString) \value DecorationRole The data to be rendered as a decoration in the form - of an icon. (QColor) + of an icon. (QColor, QIcon or QPixmap) \value EditRole The data in a form suitable for editing in an editor. (QString) \value ToolTipRole The data displayed in the item's tooltip. (QString) diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp index 871a4b1..3b3036d 100644 --- a/src/gui/itemviews/qitemdelegate.cpp +++ b/src/gui/itemviews/qitemdelegate.cpp @@ -255,7 +255,7 @@ QSizeF QItemDelegatePrivate::doTextLayout(int lineWidth) const \row \o \l Qt::BackgroundRole \o QBrush \row \o \l Qt::BackgroundColorRole \o QColor (obsolete; use Qt::BackgroundRole instead) \row \o \l Qt::CheckStateRole \o Qt::CheckState - \row \o \l Qt::DecorationRole \o QIcon and QColor + \row \o \l Qt::DecorationRole \o QIcon, QPixmap and QColor \row \o \l Qt::DisplayRole \o QString and types with a string representation \row \o \l Qt::EditRole \o See QItemEditorFactory for details \row \o \l Qt::FontRole \o QFont diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp index 1c36787..1ca0391 100644 --- a/src/gui/itemviews/qstyleditemdelegate.cpp +++ b/src/gui/itemviews/qstyleditemdelegate.cpp @@ -148,7 +148,7 @@ public: \row \o \l Qt::BackgroundRole \o QBrush \row \o \l Qt::BackgroundColorRole \o QColor (obsolete; use Qt::BackgroundRole instead) \row \o \l Qt::CheckStateRole \o Qt::CheckState - \row \o \l Qt::DecorationRole \o QIcon and QColor + \row \o \l Qt::DecorationRole \o QIcon, QPixmap, QImage and QColor \row \o \l Qt::DisplayRole \o QString and types with a string representation \row \o \l Qt::EditRole \o See QItemEditorFactory for details \row \o \l Qt::FontRole \o QFont -- cgit v0.12 From c6218e0e9b64e53391e3e0ddc4988f4f079712eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B6glund?= Date: Tue, 27 Oct 2009 15:25:46 +0100 Subject: Use shared memory images when shared pixmaps are not available. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modern graphics drivers tend to disable shared memory pixmaps, since rendering operations often can't be accelerated by the GPU when the pixmap data is pinned in system RAM. Use XShmPutImage() to flush the window surface when this is case, instead of falling back to the slower XPutImage() method. Merge-request: 1684 Reviewed-by: Samuel Rødal --- src/gui/image/qnativeimage.cpp | 10 ++++++---- src/gui/kernel/qapplication_x11.cpp | 14 ++++++++------ src/gui/kernel/qt_x11_p.h | 1 + src/gui/painting/qwindowsurface_raster.cpp | 6 ++++++ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp index 88faea8..e4ea2e9 100644 --- a/src/gui/image/qnativeimage.cpp +++ b/src/gui/image/qnativeimage.cpp @@ -199,10 +199,12 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /* shmctl(xshminfo.shmid, IPC_RMID, 0); return; } - xshmpm = XShmCreatePixmap(X11->display, DefaultRootWindow(X11->display), xshmimg->data, - &xshminfo, width, height, dd); - if (!xshmpm) { - qWarning() << "QNativeImage: Unable to create shared Pixmap."; + if (X11->use_mitshm_pixmaps) { + xshmpm = XShmCreatePixmap(X11->display, DefaultRootWindow(X11->display), xshmimg->data, + &xshminfo, width, height, dd); + if (!xshmpm) { + qWarning() << "QNativeImage: Unable to create shared Pixmap."; + } } } diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index bf95684..7f11faa 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -1625,6 +1625,7 @@ void qt_init(QApplicationPrivate *priv, int, // MIT-SHM X11->use_mitshm = false; + X11->use_mitshm_pixmaps = false; X11->mitshm_major = 0; X11->sip_serial = 0; @@ -1918,12 +1919,13 @@ void qt_init(QApplicationPrivate *priv, int, bool local = displayName.isEmpty() || displayName.lastIndexOf(QLatin1Char(':')) == 0; if (local && (qgetenv("QT_X11_NO_MITSHM").toInt() == 0)) { Visual *defaultVisual = DefaultVisual(X11->display, DefaultScreen(X11->display)); - X11->use_mitshm = mitshm_pixmaps && ((defaultVisual->red_mask == 0xff0000 - || defaultVisual->red_mask == 0xf800) - && (defaultVisual->green_mask == 0xff00 - || defaultVisual->green_mask == 0x7e0) - && (defaultVisual->blue_mask == 0xff - || defaultVisual->blue_mask == 0x1f)); + X11->use_mitshm = ((defaultVisual->red_mask == 0xff0000 + || defaultVisual->red_mask == 0xf800) + && (defaultVisual->green_mask == 0xff00 + || defaultVisual->green_mask == 0x7e0) + && (defaultVisual->blue_mask == 0xff + || defaultVisual->blue_mask == 0x1f)); + X11->use_mitshm_pixmaps = X11->use_mitshm && mitshm_pixmaps; } } #endif // QT_NO_MITSHM diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h index 61acbac..9f08dc6 100644 --- a/src/gui/kernel/qt_x11_p.h +++ b/src/gui/kernel/qt_x11_p.h @@ -428,6 +428,7 @@ struct QX11Data // true if Qt is compiled w/ MIT-SHM support and MIT-SHM is supported on the connected Display bool use_mitshm; + bool use_mitshm_pixmaps; int mitshm_major; // true if Qt is compiled w/ Tablet support and we have a tablet. diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp index 3a118bd..d412040 100644 --- a/src/gui/painting/qwindowsurface_raster.cpp +++ b/src/gui/painting/qwindowsurface_raster.cpp @@ -215,6 +215,12 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi XCopyArea(X11->display, d_ptr->image->xshmpm, widget->handle(), d_ptr->gc, br.x(), br.y(), br.width(), br.height(), wbr.x(), wbr.y()); XSync(X11->display, False); + } else if (d_ptr->image->xshmimg) { + const QImage &src = d->image->image; + br = br.intersected(src.rect()); + XShmPutImage(X11->display, widget->handle(), d_ptr->gc, d_ptr->image->xshmimg, + br.x(), br.y(), wbr.x(), wbr.y(), br.width(), br.height(), False); + XSync(X11->display, False); } else #endif { -- cgit v0.12 From b65eac5fa966a47b0ffe8e111553052fd4dffb40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 27 Oct 2009 15:26:41 +0100 Subject: Define QT_OPEN_LARGEFILE on Symbian + WinCE Reviewed-by: Thiago Macieira --- mkspecs/common/symbian/qplatformdefs.h | 1 + mkspecs/common/wince/qplatformdefs.h | 1 + 2 files changed, 2 insertions(+) diff --git a/mkspecs/common/symbian/qplatformdefs.h b/mkspecs/common/symbian/qplatformdefs.h index e1d8f6a..c0756b2 100644 --- a/mkspecs/common/symbian/qplatformdefs.h +++ b/mkspecs/common/symbian/qplatformdefs.h @@ -141,6 +141,7 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir +#define QT_OPEN_LARGEFILE 0 #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/common/wince/qplatformdefs.h b/mkspecs/common/wince/qplatformdefs.h index eecbd1e..52a34e9 100644 --- a/mkspecs/common/wince/qplatformdefs.h +++ b/mkspecs/common/wince/qplatformdefs.h @@ -97,6 +97,7 @@ #define QT_CHDIR ::_chdir #define QT_MKDIR ::qt_wince__mkdir #define QT_RMDIR ::qt_wince__rmdir +#define QT_OPEN_LARGEFILE 0 #define QT_OPEN_RDONLY _O_RDONLY #define QT_OPEN_WRONLY _O_WRONLY #define QT_OPEN_RDWR _O_RDWR -- cgit v0.12 From 8caee839df56c005f5e7a289b2cd8b0544210a09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 27 Oct 2009 15:34:29 +0100 Subject: Fix QtOpenGL linker issue by exporting qt_getClipRects It is used in qwindowsurface_x11gl.cpp. The problem only showed when building in release mode due to previous use of Q_AUTOTEST_EXPORT. Reviewed-by: Tom Cooksey --- src/gui/painting/qpaintengine_x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index 59482c6..35b77f7 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -146,7 +146,7 @@ static inline int qpainterOpToXrender(QPainter::CompositionMode mode) // hack, so we don't have to make QRegion::clipRectangles() public or include // X11 headers in qregion.h -Q_AUTOTEST_EXPORT void *qt_getClipRects(const QRegion &r, int &num) +Q_GUI_EXPORT void *qt_getClipRects(const QRegion &r, int &num) { return r.clipRectangles(num); } -- cgit v0.12 From 22b223c31ff961f52f62eaf20aa571b71dfe3bb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 27 Oct 2009 15:57:54 +0100 Subject: (MSVC 2002/2003) Use 64-bit versions of ftell and fseek MSDN documents these as being available since Windows 95. Reviewed-by: Marius Storm-Olsen --- mkspecs/win32-msvc.net/qplatformdefs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/win32-msvc.net/qplatformdefs.h b/mkspecs/win32-msvc.net/qplatformdefs.h index 19f9ba4..e3e287e 100644 --- a/mkspecs/win32-msvc.net/qplatformdefs.h +++ b/mkspecs/win32-msvc.net/qplatformdefs.h @@ -115,8 +115,8 @@ #define QT_FOPEN ::fopen #ifdef QT_LARGEFILE_SUPPORT -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell +#define QT_FSEEK ::_fseeki64 +#define QT_FTELL ::_ftelli64 #else #define QT_FSEEK ::fseek #define QT_FTELL ::ftell -- cgit v0.12 From cc21bffbb23212dfd6b18309aba762ae1538ae42 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Tue, 27 Oct 2009 16:03:05 +0100 Subject: Build fix for QtXmlPatterns' examples on Symbian This is the same workaround as Janne did for QtWebkit. Reviewed-by: Janne Koskinen --- mkspecs/features/qt_functions.prf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index 3f84f42..1be6d9b 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -54,6 +54,10 @@ defineTest(qtAddLibrary) { # Needed for #include because relative inclusion problem in toolchain INCLUDEPATH *= $$QMAKE_INCDIR_QT/QtXmlPatterns } + isEqual(LIB_NAME, QtXmlPatterns) { + # Needed for #include because relative inclusion problem in toolchain + INCLUDEPATH *= $$QMAKE_INCDIR_QT/QtNetwork + } } isEmpty(LINKAGE) { if(!debug_and_release|build_pass):CONFIG(debug, debug|release) { -- cgit v0.12 From 2d0b29c312ddf422595ce9debb3678bb5c4d51b6 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 27 Oct 2009 16:04:29 +0100 Subject: QAbstractSocket: wait with closing until all bytes have been written only disconnect from host when all bytes have been written; i.e. not only check whether the write buffer is empty, but also check whether the socket engine has still bytes to write. This is necessary for HTTP and SOCKS5 socket engine, because they both contain an inner TCP socket which also does buffering. For the native socket engine, there is no difference with this patch. Reviewed-by: Markus Goetz Reviewed-by: Thiago Macieira --- src/network/socket/qabstractsocket.cpp | 22 +++++++++++++++------- src/network/socket/qabstractsocketengine_p.h | 2 ++ src/network/socket/qhttpsocketengine.cpp | 10 ++++++++++ src/network/socket/qhttpsocketengine_p.h | 2 ++ src/network/socket/qnativesocketengine.cpp | 6 ++++++ src/network/socket/qnativesocketengine_p.h | 2 ++ src/network/socket/qsocks5socketengine.cpp | 14 ++++++++++++++ src/network/socket/qsocks5socketengine_p.h | 2 ++ src/network/ssl/qsslsocket.cpp | 2 ++ tests/auto/qsslsocket/tst_qsslsocket.cpp | 4 +--- 10 files changed, 56 insertions(+), 10 deletions(-) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 9fb0b47..955fee0 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -669,11 +669,11 @@ bool QAbstractSocketPrivate::canWriteNotification() if (socketEngine) { #if defined (Q_OS_WIN) - if (!writeBuffer.isEmpty()) - socketEngine->setWriteNotificationEnabled(true); + if (!writeBuffer.isEmpty()) + socketEngine->setWriteNotificationEnabled(true); #else - if (writeBuffer.isEmpty()) - socketEngine->setWriteNotificationEnabled(false); + if (writeBuffer.isEmpty() && socketEngine->bytesToWrite() == 0) + socketEngine->setWriteNotificationEnabled(false); #endif } @@ -710,11 +710,17 @@ void QAbstractSocketPrivate::connectionNotification() bool QAbstractSocketPrivate::flush() { Q_Q(QAbstractSocket); - if (!socketEngine || !socketEngine->isValid() || writeBuffer.isEmpty()) { + if (!socketEngine || !socketEngine->isValid() || (writeBuffer.isEmpty() + && socketEngine->bytesToWrite() == 0)) { #if defined (QABSTRACTSOCKET_DEBUG) qDebug("QAbstractSocketPrivate::flush() nothing to do: valid ? %s, writeBuffer.isEmpty() ? %s", socketEngine->isValid() ? "yes" : "no", writeBuffer.isEmpty() ? "yes" : "no"); #endif + + // this covers the case when the buffer was empty, but we had to wait for the socket engine to finish + if (state == QAbstractSocket::ClosingState) + q->disconnectFromHost(); + return false; } @@ -751,7 +757,8 @@ bool QAbstractSocketPrivate::flush() } } - if (writeBuffer.isEmpty() && socketEngine && socketEngine->isWriteNotificationEnabled()) + if (writeBuffer.isEmpty() && socketEngine && socketEngine->isWriteNotificationEnabled() + && !socketEngine->bytesToWrite()) socketEngine->setWriteNotificationEnabled(false); if (state == QAbstractSocket::ClosingState) q->disconnectFromHost(); @@ -2347,7 +2354,8 @@ void QAbstractSocket::disconnectFromHostImplementation() } // Wait for pending data to be written. - if (d->socketEngine && d->socketEngine->isValid() && d->writeBuffer.size() > 0) { + if (d->socketEngine && d->socketEngine->isValid() && (d->writeBuffer.size() > 0 + || d->socketEngine->bytesToWrite() > 0)) { d->socketEngine->setWriteNotificationEnabled(true); #if defined(QABSTRACTSOCKET_DEBUG) diff --git a/src/network/socket/qabstractsocketengine_p.h b/src/network/socket/qabstractsocketengine_p.h index c639092..14b3c81 100644 --- a/src/network/socket/qabstractsocketengine_p.h +++ b/src/network/socket/qabstractsocketengine_p.h @@ -126,6 +126,8 @@ public: virtual qint64 pendingDatagramSize() const = 0; #endif + virtual qint64 bytesToWrite() const = 0; + virtual int option(SocketOption option) const = 0; virtual bool setOption(SocketOption option, int value) = 0; diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index fb61dbf..5c28318 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -276,6 +276,16 @@ qint64 QHttpSocketEngine::pendingDatagramSize() const } #endif // QT_NO_UDPSOCKET +qint64 QHttpSocketEngine::bytesToWrite() const +{ + Q_D(const QHttpSocketEngine); + if (d->socket) { + return d->socket->bytesToWrite(); + } else { + return 0; + } +} + int QHttpSocketEngine::option(SocketOption option) const { Q_D(const QHttpSocketEngine); diff --git a/src/network/socket/qhttpsocketengine_p.h b/src/network/socket/qhttpsocketengine_p.h index a423116..76430db 100644 --- a/src/network/socket/qhttpsocketengine_p.h +++ b/src/network/socket/qhttpsocketengine_p.h @@ -110,6 +110,8 @@ public: qint64 pendingDatagramSize() const; #endif // QT_NO_UDPSOCKET + qint64 bytesToWrite() const; + int option(SocketOption option) const; bool setOption(SocketOption option, int value); diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index e7f8401..a150b26 100644 --- a/src/network/socket/qnativesocketengine.cpp +++ b/src/network/socket/qnativesocketengine.cpp @@ -754,6 +754,12 @@ qint64 QNativeSocketEngine::write(const char *data, qint64 size) return d->nativeWrite(data, size); } + +qint64 QNativeSocketEngine::bytesToWrite() const +{ + return 0; +} + /*! Reads up to \a maxSize bytes into \a data from the socket. Returns the number of bytes read, or -1 if an error occurred. diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h index 1f6a243..a03d8f1 100644 --- a/src/network/socket/qnativesocketengine_p.h +++ b/src/network/socket/qnativesocketengine_p.h @@ -135,6 +135,8 @@ public: bool hasPendingDatagrams() const; qint64 pendingDatagramSize() const; + qint64 bytesToWrite() const; + qint64 receiveBufferSize() const; void setReceiveBufferSize(qint64 bufferSize); diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 30074cf..bd60ad1 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -1235,6 +1235,9 @@ void QSocks5SocketEnginePrivate::_q_controlSocketError(QAbstractSocket::SocketEr if (!readNotificationPending) connectData->readBuffer.clear(); emitReadNotification(); + data->controlSocket->close(); + // cause a disconnect in the outer socket + emitWriteNotification(); } else if (socks5State == Uninitialized || socks5State == AuthenticationMethodsSent || socks5State == Authenticating @@ -1245,6 +1248,7 @@ void QSocks5SocketEnginePrivate::_q_controlSocketError(QAbstractSocket::SocketEr } else { q_func()->setError(data->controlSocket->error(), data->controlSocket->errorString()); emitReadNotification(); + emitWriteNotification(); } } @@ -1623,6 +1627,16 @@ qint64 QSocks5SocketEngine::pendingDatagramSize() const } #endif // QT_NO_UDPSOCKET +qint64 QSocks5SocketEngine::bytesToWrite() const +{ + Q_D(const QSocks5SocketEngine); + if (d->data && d->data->controlSocket) { + return d->data->controlSocket->bytesToWrite(); + } else { + return 0; + } +} + int QSocks5SocketEngine::option(SocketOption option) const { Q_D(const QSocks5SocketEngine); diff --git a/src/network/socket/qsocks5socketengine_p.h b/src/network/socket/qsocks5socketengine_p.h index 7cb0920..2402517 100644 --- a/src/network/socket/qsocks5socketengine_p.h +++ b/src/network/socket/qsocks5socketengine_p.h @@ -100,6 +100,8 @@ public: qint64 pendingDatagramSize() const; #endif // QT_NO_UDPSOCKET + qint64 bytesToWrite() const; + int option(SocketOption option) const; bool setOption(SocketOption option, int value); diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 2c88130..608d772 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -707,6 +707,8 @@ void QSslSocket::close() qDebug() << "QSslSocket::close()"; #endif Q_D(QSslSocket); + if (d->plainSocket) + d->plainSocket->close(); QTcpSocket::close(); // must be cleared, reading/writing not possible on closed socket: diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index 2bd1684..db46b66 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -1755,9 +1755,7 @@ void tst_QSslSocket::readFromClosedSocket() socket->close(); QVERIFY(!socket->bytesAvailable()); QVERIFY(!socket->bytesToWrite()); - socket->waitForDisconnected(); - QVERIFY(!socket->bytesAvailable()); - QVERIFY(!socket->bytesToWrite()); + QVERIFY(socket->state() == QAbstractSocket::UnconnectedState); } void tst_QSslSocket::writeBigChunk() -- cgit v0.12 From 40ad4bf9bbfef57e63a51a619cf8817a28a3edd2 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 27 Oct 2009 16:41:10 +0100 Subject: Update def files after Gesture API and Text Engine changes Reviewed-by: Trust Me --- src/s60installs/bwins/QtGuiu.def | 8 +++++++- src/s60installs/eabi/QtGuiu.def | 32 ++++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index 4305346..56ba18f 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -5488,7 +5488,7 @@ EXPORTS ?currentIndex@QDataWidgetMapper@@QBEHXZ @ 5487 NONAME ; int QDataWidgetMapper::currentIndex(void) const ?setFont@QApplication@@SAXABVQFont@@PBD@Z @ 5488 NONAME ; void QApplication::setFont(class QFont const &, char const *) ?resized@QDesktopWidget@@IAEXH@Z @ 5489 NONAME ; void QDesktopWidget::resized(int) - ?fontEngine@QTextEngine@@QBEPAVQFontEngine@@ABUQScriptItem@@PAUQFixed@@1@Z @ 5490 NONAME ; class QFontEngine * QTextEngine::fontEngine(struct QScriptItem const &, struct QFixed *, struct QFixed *) const + ?fontEngine@QTextEngine@@QBEPAVQFontEngine@@ABUQScriptItem@@PAUQFixed@@1@Z @ 5490 NONAME ABSENT ; class QFontEngine * QTextEngine::fontEngine(struct QScriptItem const &, struct QFixed *, struct QFixed *) const ??BQVector2D@@QBE?AVQVariant@@XZ @ 5491 NONAME ; QVector2D::operator class QVariant(void) const ?qt_metacall@QTreeWidget@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 5492 NONAME ; int QTreeWidget::qt_metacall(enum QMetaObject::Call, int, void * *) ?setSelectable@QStandardItem@@QAEX_N@Z @ 5493 NONAME ; void QStandardItem::setSelectable(bool) @@ -12542,4 +12542,10 @@ EXPORTS ??0QSplitter@@QAE@PAVQWidget@@@Z @ 12541 NONAME ; QSplitter::QSplitter(class QWidget *) ?DocumentLengthForFep@QCoeFepInputContext@@UBEHXZ @ 12542 NONAME ; int QCoeFepInputContext::DocumentLengthForFep(void) const ??0QShowEvent@@QAE@XZ @ 12543 NONAME ; QShowEvent::QShowEvent(void) + ?fontEngine@QTextEngine@@QBEPAVQFontEngine@@ABUQScriptItem@@PAUQFixed@@11@Z @ 12544 NONAME ; class QFontEngine * QTextEngine::fontEngine(struct QScriptItem const &, struct QFixed *, struct QFixed *, struct QFixed *) const + ?leading@QTextLine@@QBEMXZ @ 12545 NONAME ; float QTextLine::leading(void) const + ?leadingIncluded@QTextLine@@QBE_NXZ @ 12546 NONAME ; bool QTextLine::leadingIncluded(void) const + ?projectedRotate@QMatrix4x4@@AAEAAV1@MMMM@Z @ 12547 NONAME ; class QMatrix4x4 & QMatrix4x4::projectedRotate(float, float, float, float) + ?setLeadingIncluded@QTextLine@@QAEX_N@Z @ 12548 NONAME ; void QTextLine::setLeadingIncluded(bool) + ?toTransform@QMatrix4x4@@QBE?AVQTransform@@XZ @ 12549 NONAME ; class QTransform QMatrix4x4::toTransform(void) const diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index ae69475..2d1c42f 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -1051,12 +1051,12 @@ EXPORTS _ZN11QPaintEventD2Ev @ 1050 NONAME _ZN11QPanGesture11qt_metacallEN11QMetaObject4CallEiPPv @ 1051 NONAME _ZN11QPanGesture11qt_metacastEPKc @ 1052 NONAME - _ZN11QPanGesture13setLastOffsetERK6QSizeF @ 1053 NONAME - _ZN11QPanGesture14setTotalOffsetERK6QSizeF @ 1054 NONAME + _ZN11QPanGesture13setLastOffsetERK6QSizeF @ 1053 NONAME ABSENT + _ZN11QPanGesture14setTotalOffsetERK6QSizeF @ 1054 NONAME ABSENT _ZN11QPanGesture15setAccelerationEf @ 1055 NONAME _ZN11QPanGesture16staticMetaObjectE @ 1056 NONAME DATA 16 _ZN11QPanGesture19getStaticMetaObjectEv @ 1057 NONAME - _ZN11QPanGesture9setOffsetERK6QSizeF @ 1058 NONAME + _ZN11QPanGesture9setOffsetERK6QSizeF @ 1058 NONAME ABSENT _ZN11QPanGestureC1EP7QObject @ 1059 NONAME _ZN11QPanGestureC2EP7QObject @ 1060 NONAME _ZN11QPixmapData12toNativeTypeENS_10NativeTypeE @ 1061 NONAME @@ -6366,7 +6366,7 @@ EXPORTS _ZN8QGesture11qt_metacallEN11QMetaObject4CallEiPPv @ 6365 NONAME _ZN8QGesture11qt_metacastEPKc @ 6366 NONAME _ZN8QGesture12unsetHotSpotEv @ 6367 NONAME - _ZN8QGesture15setTargetObjectEP7QObject @ 6368 NONAME + _ZN8QGesture15setTargetObjectEP7QObject @ 6368 NONAME ABSENT _ZN8QGesture16staticMetaObjectE @ 6369 NONAME DATA 16 _ZN8QGesture19getStaticMetaObjectEv @ 6370 NONAME _ZN8QGestureC1EN2Qt11GestureTypeEP7QObject @ 6371 NONAME ABSENT @@ -7888,7 +7888,7 @@ EXPORTS _ZNK11QTextCursorneERKS_ @ 7887 NONAME _ZNK11QTextEngine10attributesEv @ 7888 NONAME _ZNK11QTextEngine10elidedTextEN2Qt13TextElideModeERK6QFixedi @ 7889 NONAME - _ZNK11QTextEngine10fontEngineERK11QScriptItemP6QFixedS4_ @ 7890 NONAME + _ZNK11QTextEngine10fontEngineERK11QScriptItemP6QFixedS4_ @ 7890 NONAME ABSENT _ZNK11QTextEngine11boundingBoxEii @ 7891 NONAME _ZNK11QTextEngine11formatIndexEPK11QScriptItem @ 7892 NONAME _ZNK11QTextEngine11setBoundaryEi @ 7893 NONAME @@ -10163,7 +10163,7 @@ EXPORTS _ZNK8QGesture10hasHotSpotEv @ 10162 NONAME _ZNK8QGesture10metaObjectEv @ 10163 NONAME _ZNK8QGesture11gestureTypeEv @ 10164 NONAME - _ZNK8QGesture12targetObjectEv @ 10165 NONAME + _ZNK8QGesture12targetObjectEv @ 10165 NONAME ABSENT _ZNK8QGesture5stateEv @ 10166 NONAME _ZNK8QGesture7hotSpotEv @ 10167 NONAME _ZNK8QMdiArea10backgroundEv @ 10168 NONAME @@ -11615,4 +11615,24 @@ EXPORTS _Zls6QDebugRKN12QStyleOption10OptionTypeE @ 11614 NONAME _ZNK14QDesktopWidget14screenGeometryEPK7QWidget @ 11615 NONAME _ZNK14QDesktopWidget17availableGeometryEPK7QWidget @ 11616 NONAME + _ZN11QPanGesture13setLastOffsetERK7QPointF @ 11617 NONAME + _ZN11QPanGesture14setTotalOffsetERK7QPointF @ 11618 NONAME + _ZN11QPanGesture9setOffsetERK7QPointF @ 11619 NONAME + _ZN13QGestureEvent6d_funcEv @ 11620 NONAME + _ZN13QGestureEvent9setWidgetEP7QWidget @ 11621 NONAME + _ZN13QGestureEventD0Ev @ 11622 NONAME + _ZN13QGestureEventD1Ev @ 11623 NONAME + _ZN13QGestureEventD2Ev @ 11624 NONAME + _ZN14QWidgetPrivate36invalidateGraphicsEffectsRecursivelyEv @ 11625 NONAME + _ZN20QGraphicsItemPrivate36invalidateGraphicsEffectsRecursivelyEv @ 11626 NONAME + _ZNK13QGestureEvent10mapToSceneERK7QPointF @ 11627 NONAME + _ZNK13QGestureEvent6d_funcEv @ 11628 NONAME + _ZNK13QGestureEvent6widgetEv @ 11629 NONAME + _Zls6QDebugP15QGraphicsObject @ 11630 NONAME + _ZN10QMatrix4x415projectedRotateEffff @ 11631 NONAME + _ZN9QTextLine18setLeadingIncludedEb @ 11632 NONAME + _ZNK10QMatrix4x411toTransformEv @ 11633 NONAME + _ZNK11QTextEngine10fontEngineERK11QScriptItemP6QFixedS4_S4_ @ 11634 NONAME + _ZNK9QTextLine15leadingIncludedEv @ 11635 NONAME + _ZNK9QTextLine7leadingEv @ 11636 NONAME -- cgit v0.12 From f80dca1e0f035807e5e6a984aec1768519f4d467 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 27 Oct 2009 16:42:31 +0100 Subject: Fix tst_QBoxLayout::setGeometry failure on S60 3.x The S60 style posts a LayoutRequest event when a widget is shown, so that it can draw the focus rectangle around the widget that has keyboard focus. Although lay2->setGeometry was working correctly, processEvents() caused the outer layout to be re-laid out (which expands the inner layout and QDial to fill the available space). The processEvents() call is not necessary for the test case, so it can be removed. Reviewed-by: Jan-Arve --- tests/auto/qboxlayout/tst_qboxlayout.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/qboxlayout/tst_qboxlayout.cpp b/tests/auto/qboxlayout/tst_qboxlayout.cpp index 7ff444b..8887288 100644 --- a/tests/auto/qboxlayout/tst_qboxlayout.cpp +++ b/tests/auto/qboxlayout/tst_qboxlayout.cpp @@ -211,7 +211,6 @@ void tst_QBoxLayout::setGeometry() QRect newGeom(0, 0, 70, 70); lay2->setGeometry(newGeom); - QApplication::processEvents(); QVERIFY2(newGeom.contains(dial->geometry()), "dial->geometry() should be smaller and within newGeom"); } -- cgit v0.12 From 576aced5cb8270b1827a505aa0ae815781b1cfa5 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 27 Oct 2009 16:42:55 +0100 Subject: QToolBar has now a topLevelChanged signal like in QDockWidget Task-number: QTBUG-4169 Reviewed-by: ogoffart --- src/gui/widgets/qtoolbar.cpp | 16 ++++++++++++++++ src/gui/widgets/qtoolbar.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp index 40c0b02..5596ca4 100644 --- a/src/gui/widgets/qtoolbar.cpp +++ b/src/gui/widgets/qtoolbar.cpp @@ -183,6 +183,9 @@ void QToolBarPrivate::setWindowState(bool floating, bool unplug, const QRect &re if (visible) q->show(); + + if (floating != wasFloating) + emit q->topLevelChanged(floating); } void QToolBarPrivate::initDrag(const QPoint &pos) @@ -518,6 +521,19 @@ void QToolBarPrivate::plug(const QRect &r) */ /*! + \since 4.6 + + \fn void QToolBar::topLevelChanged(bool topLevel) + + This signal is emitted when the \l floating property changes. + The \a topLevel parameter is true if the toolbar is now floating; + otherwise it is false. + + \sa isWindow() +*/ + + +/*! Constructs a QToolBar with the given \a parent. */ QToolBar::QToolBar(QWidget *parent) diff --git a/src/gui/widgets/qtoolbar.h b/src/gui/widgets/qtoolbar.h index a084673..a1a24f0 100644 --- a/src/gui/widgets/qtoolbar.h +++ b/src/gui/widgets/qtoolbar.h @@ -142,6 +142,7 @@ Q_SIGNALS: void orientationChanged(Qt::Orientation orientation); void iconSizeChanged(const QSize &iconSize); void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle); + void topLevelChanged(bool topLevel); protected: void actionEvent(QActionEvent *event); -- cgit v0.12 From 2c672ea518265496a0fc7c5de63ca7dda880dd85 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 27 Oct 2009 16:06:36 +0100 Subject: QAbstractSocket: insert timer to prevent timeout This fixes a timeout that occurred on Mac with the gui event dispatcher: we were waiting for a write notification, but timed out when we were in closing state and still waiting for the socket engine to complete writing. Now we close the socket anyway after 2 seconds. Reviewed-by: Thiago Macieira --- src/network/socket/qabstractsocket.cpp | 29 +++++++++++++++++++++++++++-- src/network/socket/qabstractsocket.h | 1 + src/network/socket/qabstractsocket_p.h | 2 ++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 955fee0..89a6e91 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -462,6 +462,7 @@ QAbstractSocketPrivate::QAbstractSocketPrivate() isBuffered(false), blockingTimeout(30000), connectTimer(0), + disconnectTimer(0), connectTimeElapsed(0), hostLookupId(-1), socketType(QAbstractSocket::UnknownSocketType), @@ -497,9 +498,10 @@ void QAbstractSocketPrivate::resetSocketLayer() socketEngine = 0; cachedSocketDescriptor = -1; } - if (connectTimer) { + if (connectTimer) connectTimer->stop(); - } + if (disconnectTimer) + disconnectTimer->stop(); } /*! \internal @@ -1094,6 +1096,15 @@ void QAbstractSocketPrivate::_q_abortConnectionAttempt() } } +void QAbstractSocketPrivate::_q_forceDisconnect() +{ + Q_Q(QAbstractSocket); + if (socketEngine && socketEngine->isValid() && state == QAbstractSocket::ClosingState) { + socketEngine->close(); + q->disconnectFromHost(); + } +} + /*! \internal Reads data from the socket layer into the read buffer. Returns @@ -2356,6 +2367,20 @@ void QAbstractSocket::disconnectFromHostImplementation() // Wait for pending data to be written. if (d->socketEngine && d->socketEngine->isValid() && (d->writeBuffer.size() > 0 || d->socketEngine->bytesToWrite() > 0)) { + // hack: when we are waiting for the socket engine to write bytes (only + // possible when using Socks5 or HTTP socket engine), then close + // anyway after 2 seconds. This is to prevent a timeout on Mac, where we + // sometimes just did not get the write notifier from the underlying + // CFSocket and no progress was made. + if (d->writeBuffer.size() == 0 && d->socketEngine->bytesToWrite() > 0) { + if (!d->disconnectTimer) { + d->disconnectTimer = new QTimer(this); + connect(d->disconnectTimer, SIGNAL(timeout()), this, + SLOT(_q_forceDisconnect()), Qt::DirectConnection); + } + if (!d->disconnectTimer->isActive()) + d->disconnectTimer->start(2000); + } d->socketEngine->setWriteNotificationEnabled(true); #if defined(QABSTRACTSOCKET_DEBUG) diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h index 5d94a01..5cfae17 100644 --- a/src/network/socket/qabstractsocket.h +++ b/src/network/socket/qabstractsocket.h @@ -216,6 +216,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_startConnecting(const QHostInfo &)) Q_PRIVATE_SLOT(d_func(), void _q_abortConnectionAttempt()) Q_PRIVATE_SLOT(d_func(), void _q_testConnection()) + Q_PRIVATE_SLOT(d_func(), void _q_forceDisconnect()) #ifdef QT3_SUPPORT public: diff --git a/src/network/socket/qabstractsocket_p.h b/src/network/socket/qabstractsocket_p.h index 8ccddd3..acf82bf 100644 --- a/src/network/socket/qabstractsocket_p.h +++ b/src/network/socket/qabstractsocket_p.h @@ -93,6 +93,7 @@ public: void _q_startConnecting(const QHostInfo &hostInfo); void _q_testConnection(); void _q_abortConnectionAttempt(); + void _q_forceDisconnect(); bool readSocketNotifierCalled; bool readSocketNotifierState; @@ -148,6 +149,7 @@ public: int blockingTimeout; QTimer *connectTimer; + QTimer *disconnectTimer; int connectTimeElapsed; int hostLookupId; -- cgit v0.12 From f0fa85911b1b5aeedf61a1c41ee81674b1575cc7 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 27 Oct 2009 17:01:32 +0100 Subject: In Qt3Support, the "line up" action for toolbars was not working Task-number: QTBUG-1063 Reviewed-by: ogoffart --- src/qt3support/widgets/q3dockarea.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt3support/widgets/q3dockarea.cpp b/src/qt3support/widgets/q3dockarea.cpp index afeefff..bb34622 100644 --- a/src/qt3support/widgets/q3dockarea.cpp +++ b/src/qt3support/widgets/q3dockarea.cpp @@ -1019,6 +1019,7 @@ void Q3DockArea::lineUp(bool keepNewLines) if (!keepNewLines) dw->setNewLine(false); } + layout->invalidate(); layout->activate(); } -- cgit v0.12 From ad342b62f1b4c6b9ca0997ddb937f3871f6d875b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 27 Oct 2009 18:19:53 +0100 Subject: Make QProcess report errors from a failed subprocess start. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: João Abecasis --- src/corelib/io/qprocess_unix.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 99296c7..f040d16 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -108,6 +108,10 @@ QT_END_NAMESPACE QT_BEGIN_NAMESPACE +// POSIX requires PIPE_BUF to be 512 or larger +// so we will use 512 +static const int errorBufferMax = 512; + #ifdef Q_OS_INTEGRITY static inline char *strdup(const char *data) { @@ -752,18 +756,19 @@ void QProcessPrivate::execChild(const char *workingDir, char **path, char **argv } // notify failure + QString error = qt_error_string(errno); #if defined (QPROCESS_DEBUG) - fprintf(stderr, "QProcessPrivate::execChild() failed, notifying parent process\n"); + fprintf(stderr, "QProcessPrivate::execChild() failed (%s), notifying parent process\n", qPrintable(error)); #endif - qt_safe_write(childStartedPipe[1], "", 1); + qt_safe_write(childStartedPipe[1], error.data(), error.length() * sizeof(QChar)); qt_safe_close(childStartedPipe[1]); childStartedPipe[1] = -1; } bool QProcessPrivate::processStarted() { - char c; - int i = qt_safe_read(childStartedPipe[0], &c, 1); + ushort buf[errorBufferMax]; + int i = qt_safe_read(childStartedPipe[0], &buf, sizeof buf); if (startupSocketNotifier) { startupSocketNotifier->setEnabled(false); startupSocketNotifier->deleteLater(); @@ -775,6 +780,11 @@ bool QProcessPrivate::processStarted() #if defined (QPROCESS_DEBUG) qDebug("QProcessPrivate::processStarted() == %s", i <= 0 ? "true" : "false"); #endif + + // did we read an error message? + if (i > 0) + q_func()->setErrorString(QString::fromUtf16(buf, i / sizeof(QChar))); + return i <= 0; } -- cgit v0.12 From b3435aa7ae1eb4a0766b82560980e49039aea1d8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 27 Oct 2009 17:54:03 +0100 Subject: Autotest: Add some debugging info as to why the subprocess fails to start --- tests/auto/qudpsocket/tst_qudpsocket.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/auto/qudpsocket/tst_qudpsocket.cpp b/tests/auto/qudpsocket/tst_qudpsocket.cpp index 7ea2163..9418be0 100644 --- a/tests/auto/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/qudpsocket/tst_qudpsocket.cpp @@ -719,6 +719,8 @@ void tst_QUdpSocket::outOfProcessConnectedClientServerTest() QProcess serverProcess; serverProcess.start(QLatin1String("clientserver/clientserver server 1 1"), QIODevice::ReadWrite | QIODevice::Text); + QVERIFY2(serverProcess.waitForStarted(3000), + qPrintable("Failed to start subprocess: " + serverProcess.errorString())); // Wait until the server has started and reports success. while (!serverProcess.canReadLine()) @@ -732,6 +734,9 @@ void tst_QUdpSocket::outOfProcessConnectedClientServerTest() clientProcess.start(QString::fromLatin1("clientserver/clientserver connectedclient %1 %2") .arg(QLatin1String("127.0.0.1")).arg(serverPort), QIODevice::ReadWrite | QIODevice::Text); + QVERIFY2(clientProcess.waitForStarted(3000), + qPrintable("Failed to start subprocess: " + clientProcess.errorString())); + // Wait until the server has started and reports success. while (!clientProcess.canReadLine()) QVERIFY(clientProcess.waitForReadyRead(3000)); @@ -779,6 +784,8 @@ void tst_QUdpSocket::outOfProcessUnconnectedClientServerTest() QProcess serverProcess; serverProcess.start(QLatin1String("clientserver/clientserver server 1 1"), QIODevice::ReadWrite | QIODevice::Text); + QVERIFY2(serverProcess.waitForStarted(3000), + qPrintable("Failed to start subprocess: " + serverProcess.errorString())); // Wait until the server has started and reports success. while (!serverProcess.canReadLine()) @@ -792,6 +799,9 @@ void tst_QUdpSocket::outOfProcessUnconnectedClientServerTest() clientProcess.start(QString::fromLatin1("clientserver/clientserver unconnectedclient %1 %2") .arg(QLatin1String("127.0.0.1")).arg(serverPort), QIODevice::ReadWrite | QIODevice::Text); + QVERIFY2(clientProcess.waitForStarted(3000), + qPrintable("Failed to start subprocess: " + clientProcess.errorString())); + // Wait until the server has started and reports success. while (!clientProcess.canReadLine()) QVERIFY(clientProcess.waitForReadyRead(3000)); -- cgit v0.12 From 588b1c40115b975ad4998251646f00db23144cd4 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 27 Oct 2009 20:07:38 +0100 Subject: Compile --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 5bc6708..5f7d5b9 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include +#include #include #include -- cgit v0.12 From b209ab1e2139cb50e26bbeeb094da9a6a4a8a067 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 27 Oct 2009 19:58:10 +0100 Subject: Always use QExplicitlySharedDataPointer Fixes a refcount bug that occurs when QFont is constructed from a QFontPrivate* that was created without an initial ref(). Merge-request: 1831 Reviewed-by: Olivier Goffart --- src/gui/text/qfont.cpp | 12 +++++------ src/gui/text/qfontinfo.h | 3 ++- src/gui/text/qfontmetrics.cpp | 49 +++++++++++++++++++------------------------ src/gui/text/qfontmetrics.h | 5 +++-- 4 files changed, 32 insertions(+), 37 deletions(-) diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 1285935..8722f5b 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2324,22 +2324,22 @@ QDataStream &operator>>(QDataStream &s, QFont &font) */ QFontInfo::QFontInfo(const QFont &font) : d(font.d.data()) -{ d->ref.ref(); } +{ +} /*! Constructs a copy of \a fi. */ QFontInfo::QFontInfo(const QFontInfo &fi) - : d(fi.d) -{ d->ref.ref(); } + : d(fi.d.data()) +{ +} /*! Destroys the font info object. */ QFontInfo::~QFontInfo() { - if (!d->ref.deref()) - delete d; } /*! @@ -2347,7 +2347,7 @@ QFontInfo::~QFontInfo() */ QFontInfo &QFontInfo::operator=(const QFontInfo &fi) { - qAtomicAssign(d, fi.d); + d = fi.d.data(); return *this; } diff --git a/src/gui/text/qfontinfo.h b/src/gui/text/qfontinfo.h index 335d761..0998949 100644 --- a/src/gui/text/qfontinfo.h +++ b/src/gui/text/qfontinfo.h @@ -43,6 +43,7 @@ #define QFONTINFO_H #include +#include QT_BEGIN_HEADER @@ -77,7 +78,7 @@ public: bool exactMatch() const; private: - QFontPrivate *d; + QExplicitlySharedDataPointer d; }; QT_END_NAMESPACE diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index ce122aa..b8c1b33 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -165,7 +165,6 @@ extern int qt_defaultDpi(); QFontMetrics::QFontMetrics(const QFont &font) : d(font.d.data()) { - d->ref.ref(); } /*! @@ -196,7 +195,6 @@ QFontMetrics::QFontMetrics(const QFont &font, QPaintDevice *paintdevice) d->screen = screen; } else { d = font.d.data(); - d->ref.ref(); } } @@ -205,8 +203,9 @@ QFontMetrics::QFontMetrics(const QFont &font, QPaintDevice *paintdevice) Constructs a copy of \a fm. */ QFontMetrics::QFontMetrics(const QFontMetrics &fm) - : d(fm.d) -{ d->ref.ref(); } + : d(fm.d.data()) +{ +} /*! Destroys the font metrics object and frees all allocated @@ -214,8 +213,6 @@ QFontMetrics::QFontMetrics(const QFontMetrics &fm) */ QFontMetrics::~QFontMetrics() { - if (!d->ref.deref()) - delete d; } /*! @@ -223,7 +220,7 @@ QFontMetrics::~QFontMetrics() */ QFontMetrics &QFontMetrics::operator=(const QFontMetrics &fm) { - qAtomicAssign(d, fm.d); + d = fm.d.data(); return *this; } @@ -536,7 +533,7 @@ int QFontMetrics::width(const QString &text, int len) const if (len == 0) return 0; - QTextEngine layout(text, d); + QTextEngine layout(text, d.data()); layout.ignoreBidi = true; return qRound(layout.width(0, len)); } @@ -612,7 +609,7 @@ int QFontMetrics::charWidth(const QString &text, int pos) const int from = qMax(0, pos - 8); int to = qMin(text.length(), pos + 8); QString cstr = QString::fromRawData(text.unicode() + from, to - from); - QTextEngine layout(cstr, d); + QTextEngine layout(cstr, d.data()); layout.ignoreBidi = true; layout.itemize(); width = qRound(layout.width(pos-from, 1)); @@ -661,7 +658,7 @@ QRect QFontMetrics::boundingRect(const QString &text) const if (text.length() == 0) return QRect(); - QTextEngine layout(text, d); + QTextEngine layout(text, d.data()); layout.ignoreBidi = true; layout.itemize(); glyph_metrics_t gm = layout.boundingBox(0, text.length()); @@ -770,7 +767,7 @@ QRect QFontMetrics::boundingRect(const QRect &rect, int flags, const QString &te QRectF rb; QRectF rr(rect); - qt_format_text(QFont(d), rr, flags | Qt::TextDontPrint, text, &rb, tabStops, tabArray, + qt_format_text(QFont(d.data()), rr, flags | Qt::TextDontPrint, text, &rb, tabStops, tabArray, tabArrayLen, 0); return rb.toAlignedRect(); @@ -831,7 +828,7 @@ QRect QFontMetrics::tightBoundingRect(const QString &text) const if (text.length() == 0) return QRect(); - QTextEngine layout(text, d); + QTextEngine layout(text, d.data()); layout.ignoreBidi = true; layout.itemize(); glyph_metrics_t gm = layout.tightBoundingBox(0, text.length()); @@ -876,7 +873,7 @@ QString QFontMetrics::elidedText(const QString &text, Qt::TextElideMode mode, in } _text = _text.mid(posA); } - QStackTextEngine engine(_text, QFont(d)); + QStackTextEngine engine(_text, QFont(d.data())); return engine.elidedText(mode, width, flags); } @@ -989,9 +986,8 @@ int QFontMetrics::lineWidth() const from the given \a fontMetrics object. */ QFontMetricsF::QFontMetricsF(const QFontMetrics &fontMetrics) - : d(fontMetrics.d) + : d(fontMetrics.d.data()) { - d->ref.ref(); } /*! @@ -1001,7 +997,7 @@ QFontMetricsF::QFontMetricsF(const QFontMetrics &fontMetrics) */ QFontMetricsF &QFontMetricsF::operator=(const QFontMetrics &other) { - qAtomicAssign(d, other.d); + d = other.d.data(); return *this; } @@ -1021,7 +1017,6 @@ QFontMetricsF &QFontMetricsF::operator=(const QFontMetrics &other) QFontMetricsF::QFontMetricsF(const QFont &font) : d(font.d.data()) { - d->ref.ref(); } /*! @@ -1052,7 +1047,6 @@ QFontMetricsF::QFontMetricsF(const QFont &font, QPaintDevice *paintdevice) d->screen = screen; } else { d = font.d.data(); - d->ref.ref(); } } @@ -1061,8 +1055,9 @@ QFontMetricsF::QFontMetricsF(const QFont &font, QPaintDevice *paintdevice) Constructs a copy of \a fm. */ QFontMetricsF::QFontMetricsF(const QFontMetricsF &fm) - : d(fm.d) -{ d->ref.ref(); } + : d(fm.d.data()) +{ +} /*! Destroys the font metrics object and frees all allocated @@ -1070,8 +1065,6 @@ QFontMetricsF::QFontMetricsF(const QFontMetricsF &fm) */ QFontMetricsF::~QFontMetricsF() { - if (!d->ref.deref()) - delete d; } /*! @@ -1079,7 +1072,7 @@ QFontMetricsF::~QFontMetricsF() */ QFontMetricsF &QFontMetricsF::operator=(const QFontMetricsF &fm) { - qAtomicAssign(d, fm.d); + d = fm.d.data(); return *this; } @@ -1374,7 +1367,7 @@ qreal QFontMetricsF::rightBearing(QChar ch) const */ qreal QFontMetricsF::width(const QString &text) const { - QTextEngine layout(text, d); + QTextEngine layout(text, d.data()); layout.ignoreBidi = true; layout.itemize(); return layout.width(0, text.length()).toReal(); @@ -1451,7 +1444,7 @@ QRectF QFontMetricsF::boundingRect(const QString &text) const if (len == 0) return QRectF(); - QTextEngine layout(text, d); + QTextEngine layout(text, d.data()); layout.ignoreBidi = true; layout.itemize(); glyph_metrics_t gm = layout.boundingBox(0, len); @@ -1559,7 +1552,7 @@ QRectF QFontMetricsF::boundingRect(const QRectF &rect, int flags, const QString& tabArrayLen++; QRectF rb; - qt_format_text(QFont(d), rect, flags | Qt::TextDontPrint, text, &rb, tabStops, tabArray, + qt_format_text(QFont(d.data()), rect, flags | Qt::TextDontPrint, text, &rb, tabStops, tabArray, tabArrayLen, 0); return rb; } @@ -1624,7 +1617,7 @@ QRectF QFontMetricsF::tightBoundingRect(const QString &text) const if (text.length() == 0) return QRect(); - QTextEngine layout(text, d); + QTextEngine layout(text, d.data()); layout.ignoreBidi = true; layout.itemize(); glyph_metrics_t gm = layout.tightBoundingBox(0, text.length()); @@ -1649,7 +1642,7 @@ QRectF QFontMetricsF::tightBoundingRect(const QString &text) const */ QString QFontMetricsF::elidedText(const QString &text, Qt::TextElideMode mode, qreal width, int flags) const { - QStackTextEngine engine(text, QFont(d)); + QStackTextEngine engine(text, QFont(d.data())); return engine.elidedText(mode, QFixed::fromReal(width), flags); } diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h index 1147e3a..23200c5 100644 --- a/src/gui/text/qfontmetrics.h +++ b/src/gui/text/qfontmetrics.h @@ -43,6 +43,7 @@ #define QFONTMETRICS_H #include +#include #ifndef QT_INCLUDE_COMPAT #include #endif @@ -131,7 +132,7 @@ private: friend class QFontMetricsF; friend class QStackTextEngine; - QFontPrivate *d; + QExplicitlySharedDataPointer d; }; @@ -187,7 +188,7 @@ public: inline bool operator !=(const QFontMetricsF &other) const { return !operator==(other); } private: - QFontPrivate *d; + QExplicitlySharedDataPointer d; }; QT_END_NAMESPACE -- cgit v0.12 From df0001a3d62938c713b351c7e59228b803ec5670 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 27 Oct 2009 19:49:33 +0100 Subject: QFontMetrics test For commit b209ab1e2139cb5 --- tests/auto/qfontmetrics/tst_qfontmetrics.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp index 6b2f0fe..e80f8e0 100644 --- a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp @@ -100,6 +100,20 @@ void tst_QFontMetrics::same() QFontMetrics fm(font); const QString text = QLatin1String("Some stupid STRING"); QCOMPARE(fm.size(0, text), fm.size(0, text)) ; + + { + QImage image; + QFontMetrics fm2(font, &image); + QString text2 = QLatin1String("Foo Foo"); + QCOMPARE(fm2.size(0, text2), fm2.size(0, text2)); //used to crash + } + + { + QImage image; + QFontMetricsF fm3(font, &image); + QString text2 = QLatin1String("Foo Foo"); + QCOMPARE(fm3.size(0, text2), fm3.size(0, text2)); //used to crash + } } -- cgit v0.12 From 75d847ef4f23e16f69ffecff24f44584755f80f5 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 28 Oct 2009 07:58:23 +0100 Subject: Got tst_qpixmapfilter.cpp compiling again Reviewed-by: Trustme --- tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp index 5a9bad7..a80c787 100644 --- a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp +++ b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp @@ -383,7 +383,7 @@ void tst_QPixmapFilter::dropShadowBoundingRectFor() QPixmapDropShadowFilter filter; filter.setBlurRadius(0); - QCOMPARE(filter.blurRadius(), 0); + QCOMPARE(filter.blurRadius(), 0.); const QRectF rect1(0, 0, 50, 50); const QRectF rect2(30, 20, 10, 40); -- cgit v0.12 From 539294ab33467ceedbcd6054137b602865956915 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 28 Oct 2009 07:59:02 +0100 Subject: Adapt testcase to updates in QGraphicsPixmapItem Reviewed-by: TrustMe --- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index dcad8e1..d8cd375 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -3109,7 +3109,7 @@ void tst_QGraphicsItem::boundingRects() void tst_QGraphicsItem::boundingRects2() { QGraphicsPixmapItem pixmap(QPixmap::fromImage(QImage(100, 100, QImage::Format_ARGB32_Premultiplied))); - QCOMPARE(pixmap.boundingRect(), QRectF(-0.5, -0.5, 101, 101)); + QCOMPARE(pixmap.boundingRect(), QRectF(0, 0, 100, 100)); QGraphicsLineItem line(0, 0, 100, 0); line.setPen(QPen(Qt::black, 1)); @@ -4039,7 +4039,7 @@ void tst_QGraphicsItem::defaultItemTest_QGraphicsPixmapItem() item.setOffset(QPointF(-10, -10)); QCOMPARE(item.offset(), QPointF(-10, -10)); - QCOMPARE(item.boundingRect(), QRectF(-10.5, -10.5, 301, 201)); + QCOMPARE(item.boundingRect(), QRectF(-10, -10, 300, 200)); } void tst_QGraphicsItem::defaultItemTest_QGraphicsTextItem() -- cgit v0.12 From 6bc9ef388590b4bfb281d2e1510dc7c3d1837349 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 28 Oct 2009 08:52:30 +0100 Subject: Fix to 8e0fbc2caa3edefb78d6667721235b783bc1a850 This version of the fix will set the def file only if defblock is enabled in qbase.pri. That means that def files don't get turned on for webkit but not for the whole project (avoids build failures in the continuous integration system when other teams change the exported symbols) Reviewed-by: Jason Barron --- src/3rdparty/webkit/WebCore/WebCore.pro | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index a835fc7..d633a7a 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -3376,3 +3376,18 @@ CONFIG(QTDIR_build):isEqual(QT_MAJOR_VERSION, 4):greaterThan(QT_MINOR_VERSION, 4 plugins/win/PaintHooks.asm } } + +# Temporary workaround to pick up the DEF file from the same place as all the others +symbian { + shared { + contains(MMP_RULES, defBlock) { + MMP_RULES -= defBlock + + MMP_RULES += "$${LITERAL_HASH}ifdef WINSCW" \ + "DEFFILE ../../../s60installs/bwins/$${TARGET}.def" \ + "$${LITERAL_HASH}elif defined EABI" \ + "DEFFILE ../../../s60installs/eabi/$${TARGET}.def" \ + "$${LITERAL_HASH}endif" + } + } +} -- cgit v0.12 From 1631a4b79f0f2d2b8b8075cd6ebbebe3bafbdb2b Mon Sep 17 00:00:00 2001 From: Liang QI Date: Wed, 28 Oct 2009 08:52:43 +0100 Subject: Enable QtXmlPatterns module in qt package and assign an UID for it. Enable QtXmlPatterns module in qt package and assign an UID for it. RevBy: Miikka Heikkinen RevBy: Jason Barron --- src/s60installs/s60installs.pro | 4 ++++ src/xmlpatterns/xmlpatterns.pro | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 7233e8a..154d666 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -97,6 +97,10 @@ symbian: { qtlibraries.sources += QtScript.dll } + contains(QT_CONFIG, xmlpatterns): { + qtlibraries.sources += QtXmlPatterns.dll + } + contains(QT_CONFIG, webkit): { qtlibraries.sources += QtWebKit.dll } diff --git a/src/xmlpatterns/xmlpatterns.pro b/src/xmlpatterns/xmlpatterns.pro index bb8e452..1df497d 100644 --- a/src/xmlpatterns/xmlpatterns.pro +++ b/src/xmlpatterns/xmlpatterns.pro @@ -34,3 +34,5 @@ wince*: { QMAKE_CXXFLAGS_RELEASE ~= s/-O1/-Os -Oy -Ob2/ } } + +symbian:TARGET.UID3=0x2001E62B -- cgit v0.12 From cabbff076f40eeeb56beb53220a40f124a2e0215 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 28 Oct 2009 09:15:40 +0100 Subject: Change deployment of SQLite to check for stub SIS file This is less wrong than searching for a file name on specific drives. Correct solution is to use an embedded SIS file dependency, for that we need to get a symbian-signed sis file from the symbian OS team. Reviewed-by: Miikka Heikkinen --- src/s60installs/s60installs.pro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 7233e8a..f553598 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -35,8 +35,8 @@ symbian: { qtlibraries.pkg_postrules += qts60plugindeployment sqlitedeployment = \ - "; EXISTS statement does not resolve !. Lets check the most common drives" \ - "IF NOT EXISTS(\"c:\\sys\\bin\\sqlite3.dll\") AND NOT EXISTS(\"e:\\sys\\bin\\sqlite3.dll\") AND NOT EXISTS(\"z:\\sys\\bin\\sqlite3.dll\")" \ + "; Deploy sqlite onto phone that does not have it (this should be replaced with embedded sis file when available) + "IF NOT package(0x2002533b) " \ "\"$${EPOCROOT}epoc32/release/$(PLATFORM)/$(TARGET)/sqlite3.dll\" - \"!:\\sys\\bin\\sqlite3.dll\"" \ "ENDIF" qtlibraries.pkg_postrules += sqlitedeployment -- cgit v0.12 From c5671bcc033e6e519fe8f88b64c108e8d52371fe Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 28 Oct 2009 09:26:43 +0100 Subject: Bad line ending in cabbff076f40eeeb56beb53220a40f124a2e0215 Reviewed-by: TrustMe --- src/s60installs/s60installs.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index d8f164f..022a072 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -35,7 +35,7 @@ symbian: { qtlibraries.pkg_postrules += qts60plugindeployment sqlitedeployment = \ - "; Deploy sqlite onto phone that does not have it (this should be replaced with embedded sis file when available) + "; Deploy sqlite onto phone that does not have it (this should be replaced with embedded sis file when available)" \ "IF NOT package(0x2002533b) " \ "\"$${EPOCROOT}epoc32/release/$(PLATFORM)/$(TARGET)/sqlite3.dll\" - \"!:\\sys\\bin\\sqlite3.dll\"" \ "ENDIF" -- cgit v0.12 From e6767a4bd15f001df6927d7232598662977bea13 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 28 Oct 2009 09:40:21 +0100 Subject: Updated testcase to match new boundingRect logic --- tests/auto/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp b/tests/auto/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp index e25aef0..5a62dc0 100644 --- a/tests/auto/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp +++ b/tests/auto/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp @@ -165,7 +165,7 @@ void tst_QGraphicsPixmapItem::boundingRect_data() QTest::addColumn("pixmap"); QTest::addColumn("boundingRect"); QTest::newRow("null") << QPixmap() << QRectF(); - QTest::newRow("10x10") << QPixmap(10, 10) << QRectF(-0.5, -0.5, 11, 11); + QTest::newRow("10x10") << QPixmap(10, 10) << QRectF(0, 0, 10, 10); } // public QRectF boundingRect() const -- cgit v0.12 From 08e5bae295204ac0cadc1dda6c7a01599f66a2bb Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Wed, 28 Oct 2009 09:42:14 +0100 Subject: Let QGraphicsItem set QObjectPrivate::wasDeleted when appropriate. This change allows children of QGraphicsObject-derived classes to check if the parent is being deleted by checking the private flag wasDeleted. Reverts 37b16d5cbb4e7bc534f690ebf50434d228b5ecfc, p4 change 9681, to allow QGraphicsItem to set QObjectPrivate's wasDeleted member before entering QObjectPrivate's destructor. The original code was in there to let the user know, via the console output, that QObject was double-deleted (e.g., when placing QObject on the stack, and also giving it a parent, so that if the parent is deleted first, bang). Reviewed-by: Aaron Kennedy Reviewed-by: Bradley T. Hughes --- src/corelib/kernel/qobject.cpp | 7 ---- src/gui/graphicsview/qgraphicsitem.cpp | 2 ++ tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp | 42 ++++++++++++++++++++++ 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 7be19b3..5303975 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -835,14 +835,7 @@ QObject::QObject(QObjectPrivate &dd, QObject *parent) QObject::~QObject() { Q_D(QObject); - if (d->wasDeleted) { -#if defined(QT_DEBUG) - qWarning("QObject: Double deletion detected"); -#endif - return; - } d->wasDeleted = true; - d->blockSig = 0; // unblock signals so we always emit destroyed() if (!d->isWidget) { diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index ad672a3..2e68d3e 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1286,6 +1286,8 @@ QGraphicsItem::QGraphicsItem(QGraphicsItemPrivate &dd, QGraphicsItem *parent, */ QGraphicsItem::~QGraphicsItem() { + if (d_ptr->isObject) + QObjectPrivate::get(static_cast(this))->wasDeleted = true; d_ptr->inDestructor = 1; d_ptr->removeExtraItemCache(); diff --git a/tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp b/tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp index a9fd55a..194665d 100644 --- a/tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp +++ b/tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include "../../shared/util.h" class tst_QGraphicsObject : public QObject { @@ -65,6 +66,7 @@ private slots: void opacity(); void enabled(); void visible(); + void deleted(); }; @@ -249,6 +251,46 @@ void tst_QGraphicsObject::visible() QVERIFY(object.property("visible") == true); } +class DeleteTester : public QGraphicsObject +{ +public: + DeleteTester(bool *w, bool *pw, QGraphicsItem *parent = 0) + : QGraphicsObject(parent), wasDeleted(w), parentWasDeleted(pw) + { } + + ~DeleteTester() + { + *wasDeleted = QObjectPrivate::get(this)->wasDeleted; + if (QGraphicsItem *p = parentItem()) { + if (QGraphicsObject *o = p->toGraphicsObject()) + *parentWasDeleted = QObjectPrivate::get(o)->wasDeleted; + } + } + + void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0) + { } + QRectF boundingRect() const + { return QRectF(); } + + bool *wasDeleted; + bool *parentWasDeleted; +}; + +void tst_QGraphicsObject::deleted() +{ + bool item1_parentWasDeleted = false; + bool item1_wasDeleted = false; + bool item2_parentWasDeleted = false; + bool item2_wasDeleted = false; + DeleteTester *item1 = new DeleteTester(&item1_wasDeleted, &item1_parentWasDeleted); + DeleteTester *item2 = new DeleteTester(&item2_wasDeleted, &item2_parentWasDeleted, item1); + delete item1; + + QVERIFY(!item1_wasDeleted); // destructor not called yet + QVERIFY(!item1_parentWasDeleted); // no parent + QVERIFY(!item2_wasDeleted); // destructor not called yet + QVERIFY(item2_parentWasDeleted); +} QTEST_MAIN(tst_QGraphicsObject) #include "tst_qgraphicsobject.moc" -- cgit v0.12 From 5a5990b8cd3c580e3325a7c3878275196ceb86dd Mon Sep 17 00:00:00 2001 From: Christoph Feck Date: Wed, 28 Oct 2009 09:57:53 +0100 Subject: Fix raster paintengine handling with invalid images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit initTexture() has explicit handling of invalid images, but when calling adjustSpanMethods() the invalid case is not handled for Type == Texture. This caused two types of crashes: * call to 0 address, because sourceFetch[] has 0 pointer for QImage::Format_Invalid (see https://bugs.kde.org/show_bug.cgi?id=176014) * division by zero in tiled blend functions, because of the " % image_size" modulo arithmetic. (see https://bugs.kde.org/show_bug.cgi?id=203231) Merge-request: 1213 Reviewed-by: Samuel Rødal --- src/gui/painting/qpaintengine_raster.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 1a8dce1..8d0b961 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -5119,6 +5119,9 @@ void QSpanData::adjustSpanMethods() #else unclipped_blend = qBlendTexture; #endif + if (!texture.imageData) + unclipped_blend = 0; + break; } // setup clipping -- cgit v0.12 From a8b5aefc48d619c1fc0ff1e97c8e3a42baccb7c0 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 27 Oct 2009 19:07:03 +0100 Subject: QDom autotests: test is not failing anymore removing the temporary QFAIL Reviewed-by: Carlos Duclos --- tests/auto/qdom/tst_qdom.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/auto/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp index f3a7909..6637202 100644 --- a/tests/auto/qdom/tst_qdom.cpp +++ b/tests/auto/qdom/tst_qdom.cpp @@ -322,9 +322,6 @@ void tst_QDom::toString_01_data() */ void tst_QDom::toString_01() { -#ifdef Q_OS_WIN - QFAIL("make test fail instead of timing out, will be fixed later (QT-2357)"); -#endif QFETCH(QString, fileName); QFile f(fileName); -- cgit v0.12 From 5c7345809d7f620981f92cc2e93beb14b10504a9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 23 Oct 2009 10:54:09 +0200 Subject: Add the ability for the match-rule builder to add argument matching. I'll use this feature to match the NameOwnerChanged signal from the bus. --- src/dbus/qdbusconnection.cpp | 4 ++-- src/dbus/qdbusconnection_p.h | 1 + src/dbus/qdbusintegrator.cpp | 17 +++++++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index bb0d06f..bead369 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -609,7 +609,7 @@ bool QDBusConnection::connect(const QString &service, const QString &path, const QString owner = d->getNameOwner(service); // we don't care if the owner is empty hook.signature = signature; // it might get started later - if (!d->prepareHook(hook, key, service, owner, path, interface, name, receiver, slot, 0, false)) + if (!d->prepareHook(hook, key, service, owner, path, interface, name, QStringList(), receiver, slot, 0, false)) return false; // don't connect // avoid duplicating: @@ -663,7 +663,7 @@ bool QDBusConnection::disconnect(const QString &service, const QString &path, co QString owner = d->getNameOwner(service); // we don't care of owner is empty hook.signature = signature; - if (!d->prepareHook(hook, key, service, owner, path, interface, name, receiver, slot, 0, false)) + if (!d->prepareHook(hook, key, service, owner, path, interface, name, QStringList(), receiver, slot, 0, false)) return false; // don't disconnect // avoid duplicating: diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index ab96457..df51c27 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -278,6 +278,7 @@ public: static bool prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key, const QString &service, const QString &owner, const QString &path, const QString &interface, const QString &name, + const QStringList &argMatch, QObject *receiver, const char *signal, int minMIdx, bool buildSignature); static DBusHandlerResult messageFilter(DBusConnection *, DBusMessage *, void *); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index fb2dd77..9e41708 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -392,7 +392,7 @@ static void qDBusNewConnection(DBusServer *server, DBusConnection *connection, v static QByteArray buildMatchRule(const QString &service, const QString & /*owner*/, const QString &objectPath, const QString &interface, - const QString &member, const QString & /*signature*/) + const QString &member, const QStringList &argMatch, const QString & /*signature*/) { QString result = QLatin1String("type='signal',"); QString keyValue = QLatin1String("%1='%2',"); @@ -406,6 +406,14 @@ static QByteArray buildMatchRule(const QString &service, const QString & /*owner if (!member.isEmpty()) result += keyValue.arg(QLatin1String("member"), member); + // add the argument string-matching now + if (!argMatch.isEmpty()) { + keyValue = QLatin1String("arg%1='%2',"); + for (int i = 0; i < argMatch.count(); ++i) + if (!argMatch.at(i).isNull()) + result += keyValue.arg(i).arg(argMatch.at(i)); + } + result.chop(1); // remove ending comma return result.toLatin1(); } @@ -1195,6 +1203,7 @@ int QDBusConnectionPrivate::findSlot(QObject* obj, const QByteArray &normalizedN bool QDBusConnectionPrivate::prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key, const QString &service, const QString &owner, const QString &path, const QString &interface, const QString &name, + const QStringList &argMatch, QObject *receiver, const char *signal, int minMIdx, bool buildSignature) { @@ -1235,7 +1244,7 @@ bool QDBusConnectionPrivate::prepareHook(QDBusConnectionPrivate::SignalHook &hoo hook.signature += QLatin1String( QDBusMetaType::typeToSignature( hook.params.at(i) ) ); } - hook.matchRule = buildMatchRule(service, owner, path, interface, mname, hook.signature); + hook.matchRule = buildMatchRule(service, owner, path, interface, mname, argMatch, hook.signature); return true; // connect to this signal } @@ -2027,7 +2036,7 @@ void QDBusConnectionPrivate::connectRelay(const QString &service, const QString SignalHook hook; QString key; - if (!prepareHook(hook, key, service, owner, path, interface, QString(), receiver, signal, + if (!prepareHook(hook, key, service, owner, path, interface, QString(), QStringList(), receiver, signal, QDBusAbstractInterface::staticMetaObject.methodCount(), true)) return; // don't connect @@ -2059,7 +2068,7 @@ void QDBusConnectionPrivate::disconnectRelay(const QString &service, const QStri SignalHook hook; QString key; - if (!prepareHook(hook, key, service, owner, path, interface, QString(), receiver, signal, + if (!prepareHook(hook, key, service, owner, path, interface, QString(), QStringList(), receiver, signal, QDBusAbstractInterface::staticMetaObject.methodCount(), true)) return; // don't connect -- cgit v0.12 From 735525dc51952c90846c8129b755422b288b204b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 23 Oct 2009 11:13:10 +0200 Subject: Add new public API to QDBusConnection for connecting with string matching. The bus allows us to match string arguments when receiving messages. This is very useful for the NameOwnerChanged signal, whose first argument is usually what we're interested in. By using these new functions, you can restrict receiving of signals to those that you truly want, instead of receiving NameOwnerChanged for all services registered/unregistered on the bus. --- src/dbus/qdbusconnection.cpp | 88 ++++++++++++++++++++++++++++++++++---------- src/dbus/qdbusconnection.h | 12 ++++-- 2 files changed, 78 insertions(+), 22 deletions(-) diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index bead369..3aaba68 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -557,42 +557,61 @@ QDBusPendingCall QDBusConnection::asyncCall(const QDBusMessage &message, int tim bool QDBusConnection::connect(const QString &service, const QString &path, const QString& interface, const QString &name, QObject *receiver, const char *slot) { - return connect(service, path, interface, name, QString(), receiver, slot); + return connect(service, path, interface, name, QStringList(), QString(), receiver, slot); } /*! - Disconnects the signal specified by the \a service, \a path, \a interface and \a name parameters from - the slot \a slot in object \a receiver. The arguments \a service and \a path can be empty, - denoting a disconnection from all signals of the (\a interface, \a name) pair, from all remote - applications. + \overload - Returns true if the disconnection was successful. + Connects the signal to the slot \a slot in object \a + receiver. Unlike the previous connect() overload, this function + allows one to specify the parameter signature to be connected + using the \a signature variable. The function will then verify + that this signature can be delivered to the slot specified by \a + slot and return false otherwise. + + Returns true if the connection was successful. + + \note This function verifies that the signal signature matches the + slot's parameters, but it does not verify that the actual + signal exists with the given signature in the remote + service. */ -bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString &interface, - const QString &name, QObject *receiver, const char *slot) +bool QDBusConnection::connect(const QString &service, const QString &path, const QString& interface, + const QString &name, const QString &signature, + QObject *receiver, const char *slot) { - return disconnect(service, path, interface, name, QString(), receiver, slot); + return connect(service, path, interface, name, QStringList(), signature, receiver, slot); } /*! \overload + \since 4.6 Connects the signal to the slot \a slot in object \a - receiver. Unlike the other connect() overload, this function + receiver. Unlike the previous connect() overload, this function allows one to specify the parameter signature to be connected using the \a signature variable. The function will then verify that this signature can be delivered to the slot specified by \a slot and return false otherwise. + The \a argumentMatch parameter lists the string parameters to be matched, + in sequential order. Note that, to match an empty string, you need to + pass a QString that is empty but not null (i.e., QString("")). A null + QString skips matching at that position. + + Returns true if the connection was successful. + \note This function verifies that the signal signature matches the slot's parameters, but it does not verify that the actual signal exists with the given signature in the remote service. */ bool QDBusConnection::connect(const QString &service, const QString &path, const QString& interface, - const QString &name, const QString &signature, + const QString &name, const QStringList &argumentMatch, const QString &signature, QObject *receiver, const char *slot) { + if (!receiver || !slot || !d || !d->connection) return false; if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface)) @@ -609,7 +628,7 @@ bool QDBusConnection::connect(const QString &service, const QString &path, const QString owner = d->getNameOwner(service); // we don't care if the owner is empty hook.signature = signature; // it might get started later - if (!d->prepareHook(hook, key, service, owner, path, interface, name, QStringList(), receiver, slot, 0, false)) + if (!d->prepareHook(hook, key, service, owner, path, interface, name, argumentMatch, receiver, slot, 0, false)) return false; // don't connect // avoid duplicating: @@ -634,19 +653,50 @@ bool QDBusConnection::connect(const QString &service, const QString &path, const } /*! + Disconnects the signal specified by the \a service, \a path, \a interface + and \a name parameters from the slot \a slot in object \a receiver. The + arguments must be the same as passed to the connect() function. + + Returns true if the disconnection was successful. +*/ +bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString &interface, + const QString &name, QObject *receiver, const char *slot) +{ + return disconnect(service, path, interface, name, QStringList(), QString(), receiver, slot); +} + +/*! \overload - Disconnects the signal from the slot \a slot in object \a - receiver. Unlike the other disconnect() overload, this function - allows one to specify the parameter signature to be disconnected - using the \a signature variable. The function will then verify - that this signature is connected to the slot specified by \a slot - and return false otherwise. + Disconnects the signal specified by the \a service, \a path, \a + interface, \a name, and \a signature parameters from the slot \a slot in + object \a receiver. The arguments must be the same as passed to the + connect() function. + + Returns true if the disconnection was successful. */ bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString& interface, const QString &name, const QString &signature, QObject *receiver, const char *slot) { + return disconnect(service, path, interface, name, QStringList(), signature, receiver, slot); +} + +/*! + \overload + \since 4.6 + + Disconnects the signal specified by the \a service, \a path, \a + interface, \a name, \a argumentMatch, and \a signature parameters from + the slot \a slot in object \a receiver. The arguments must be the same as + passed to the connect() function. + + Returns true if the disconnection was successful. +*/ +bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString& interface, + const QString &name, const QStringList &argumentMatch, const QString &signature, + QObject *receiver, const char *slot) +{ if (!receiver || !slot || !d || !d->connection) return false; if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface)) @@ -663,7 +713,7 @@ bool QDBusConnection::disconnect(const QString &service, const QString &path, co QString owner = d->getNameOwner(service); // we don't care of owner is empty hook.signature = signature; - if (!d->prepareHook(hook, key, service, owner, path, interface, name, QStringList(), receiver, slot, 0, false)) + if (!d->prepareHook(hook, key, service, owner, path, interface, name, argumentMatch, receiver, slot, 0, false)) return false; // don't disconnect // avoid duplicating: diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h index 85fc7c2..82ae726 100644 --- a/src/dbus/qdbusconnection.h +++ b/src/dbus/qdbusconnection.h @@ -132,15 +132,21 @@ public: bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot); - bool disconnect(const QString &service, const QString &path, const QString &interface, - const QString &name, QObject *receiver, const char *slot); - bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, const QString& signature, QObject *receiver, const char *slot); + bool connect(const QString &service, const QString &path, const QString &interface, + const QString &name, const QStringList &argumentMatch, const QString& signature, + QObject *receiver, const char *slot); + + bool disconnect(const QString &service, const QString &path, const QString &interface, + const QString &name, QObject *receiver, const char *slot); bool disconnect(const QString &service, const QString &path, const QString &interface, const QString &name, const QString& signature, QObject *receiver, const char *slot); + bool disconnect(const QString &service, const QString &path, const QString &interface, + const QString &name, const QStringList &argumentMatch, const QString& signature, + QObject *receiver, const char *slot); bool registerObject(const QString &path, QObject *object, RegisterOptions options = ExportAdaptors); -- cgit v0.12 From c180071b66d4e5c22248c488df57c6acd6aa36ed Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 23 Oct 2009 19:23:51 +0200 Subject: Autotest: fix improper use of the serviceOwnerChanged signal This test was doubly wrong: it first registered a service name, then it connected to signal to watch it. You can't receive a signal if you connect to it after it's emitted... Second, it waited for any serviceOwnerChanged() signal to exit the event loop, not necessarily the one we wanted to receive. This used to work because we'd always connect to the D-Bus signal, but now we don't anymore. --- tests/auto/qdbusinterface/tst_qdbusinterface.cpp | 34 ++++++++---------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp index e31a3a0..62d6342 100644 --- a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp @@ -171,6 +171,13 @@ class tst_QDBusInterface: public QObject { Q_OBJECT MyObject obj; +public slots: + void testServiceOwnerChanged(const QString &service) + { + if (service == "com.example.Test") + QTestEventLoop::instance().exitLoop(); + } + private slots: void initTestCase(); @@ -235,32 +242,13 @@ void tst_QDBusInterface::invalidAfterServiceOwnerChanged() QDBusInterface invalidInterface("com.example.Test", "/"); QVERIFY(!invalidInterface.isValid()); + QTestEventLoop::instance().connect(connIface, SIGNAL(serviceOwnerChanged(QString, QString, QString)), + SLOT(exitLoop())); QVERIFY(connIface->registerService("com.example.Test") == QDBusConnectionInterface::ServiceRegistered); - QSignalSpy serviceOwnerChangedSpy(connIface, SIGNAL(serviceOwnerChanged(QString, QString, QString))); - - QEventLoop loop; - QObject::connect(connIface, SIGNAL(serviceOwnerChanged(QString, QString, QString)), - &loop, SLOT(quit())); - loop.exec(); - - // at least once, but other services might have changed while running the test, too. - QVERIFY(serviceOwnerChangedSpy.count() >= 1); - bool foundOurService = false; - for (int i = 0; i < serviceOwnerChangedSpy.count(); ++i) { - QList args = serviceOwnerChangedSpy.at(i); - QString name = args[0].toString(); - QString oldOwner = args[1].toString(); - QString newOwner = args[2].toString(); - if (name == QLatin1String("com.example.Test")) { - if (newOwner == conn.baseService()) { - foundOurService = true; - break; - } - } - } - QVERIFY(foundOurService); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(!invalidInterface.isValid()); } -- cgit v0.12 From feca69fb15a4176689e4f58252361750f3444275 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 23 Oct 2009 19:25:56 +0200 Subject: Autotest: add a test that tries to follow a service changing owners. I'm not sure if this used to work before... --- .../tst_qdbusabstractinterface.cpp | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp index baf769f..d84350b 100644 --- a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp +++ b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp @@ -103,6 +103,8 @@ private slots: void getComplexSignal_data(); void getComplexSignal(); + void followSignal(); + void createErrors_data(); void createErrors(); @@ -432,6 +434,60 @@ void tst_QDBusAbstractInterface::getComplexSignal() QCOMPARE(s[0][0].value(), expectedValue); } +void tst_QDBusAbstractInterface::followSignal() +{ + const QString serviceToFollow = "com.trolltech.tst_qdbusabstractinterface.FollowMe"; + Pinger p = getPinger(serviceToFollow); + QVERIFY2(p, "Not connected to D-Bus"); + + QDBusConnection con = p->connection(); + QVERIFY(!con.interface()->isServiceRegistered(serviceToFollow)); + Pinger control = getPinger(""); + + // we need to connect the signal somewhere in order for D-Bus to enable the rules + QTestEventLoop::instance().connect(p.data(), SIGNAL(voidSignal()), SLOT(exitLoop())); + QTestEventLoop::instance().connect(control.data(), SIGNAL(voidSignal()), SLOT(exitLoop())); + QSignalSpy s(p.data(), SIGNAL(voidSignal())); + + emit targetObj.voidSignal(); + QTestEventLoop::instance().enterLoop(200); + QVERIFY(!QTestEventLoop::instance().timeout()); + + // signal must not have been received because the service isn't registered + QVERIFY(s.isEmpty()); + + // now register the service + QDBusReply r = + con.interface()->registerService(serviceToFollow, QDBusConnectionInterface::DontQueueService, + QDBusConnectionInterface::DontAllowReplacement); + QVERIFY(r.isValid() && r.value() == QDBusConnectionInterface::ServiceRegistered); + QVERIFY(con.interface()->isServiceRegistered(serviceToFollow)); + + // emit the signal again: + emit targetObj.voidSignal(); + QTestEventLoop::instance().enterLoop(2); + QVERIFY(!QTestEventLoop::instance().timeout()); + + // now the signal must have been received: + QVERIFY(s.size() == 1); + QVERIFY(s.at(0).size() == 0); + s.clear(); + + // disconnect the signal + disconnect(p.data(), SIGNAL(voidSignal()), &QTestEventLoop::instance(), 0); + + // emit the signal again: + emit targetObj.voidSignal(); + QTestEventLoop::instance().enterLoop(2); + QVERIFY(!QTestEventLoop::instance().timeout()); + + // and now it mustn't have been received + QVERIFY(s.isEmpty()); + + // cleanup: + con.interface()->unregisterService(serviceToFollow); +} + void tst_QDBusAbstractInterface::createErrors_data() { QTest::addColumn("service"); -- cgit v0.12 From 95d68417bfced3458e72ab3fdbc8f97ab15dd1db Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 23 Oct 2009 12:02:40 +0200 Subject: Use the new argument-based rule-matching in QDBusAbstractInterface. This allows us to listen only to the activations we're really interested in. --- src/dbus/qdbusabstractinterface.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp index 61a9d95..bea365a 100644 --- a/src/dbus/qdbusabstractinterface.cpp +++ b/src/dbus/qdbusabstractinterface.cpp @@ -279,9 +279,17 @@ QDBusAbstractInterface::QDBusAbstractInterface(QDBusAbstractInterfacePrivate &d, : QDBusAbstractInterfaceBase(d, parent) { // keep track of the service owner - if (!d_func()->currentOwner.isEmpty()) - QObject::connect(d_func()->connectionPrivate(), SIGNAL(serviceOwnerChanged(QString,QString,QString)), - this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); + if (d.isValid && + d.connection.isConnected() + && !d.service.isEmpty() + && !d.service.startsWith(QLatin1Char(':'))) + d_func()->connection.connect(QLatin1String(DBUS_SERVICE_DBUS), // service + QString(), // path + QLatin1String(DBUS_INTERFACE_DBUS), // interface + QLatin1String("NameOwnerChanged"), + QStringList() << d.service, + QString(), // signature + this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); } /*! @@ -296,9 +304,17 @@ QDBusAbstractInterface::QDBusAbstractInterface(const QString &service, const QSt con, false), parent) { // keep track of the service owner - if (d_func()->connection.isConnected()) - QObject::connect(d_func()->connectionPrivate(), SIGNAL(serviceOwnerChanged(QString,QString,QString)), - this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); + if (d_func()->isValid && + d_func()->connection.isConnected() + && !service.isEmpty() + && !service.startsWith(QLatin1Char(':'))) + d_func()->connection.connect(QLatin1String(DBUS_SERVICE_DBUS), // service + QString(), // path + QLatin1String(DBUS_INTERFACE_DBUS), // interface + QLatin1String("NameOwnerChanged"), + QStringList() << service, + QString(), //signature + this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); } /*! -- cgit v0.12 From 26c5680cf5adbf0c87357d84f2e2a6256724d4b7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 23 Oct 2009 19:28:35 +0200 Subject: Fix the use of the owner when connecting the service "watcher". Use null services to indicate we're not interested in the owner, but empty-but-not-null to indicate we don't know what the owner is. Since empty service names are not valid, this will mean that this rule won't match. --- src/dbus/qdbusabstractinterface.cpp | 11 +++++++++-- src/dbus/qdbusintegrator.cpp | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp index bea365a..994da10 100644 --- a/src/dbus/qdbusabstractinterface.cpp +++ b/src/dbus/qdbusabstractinterface.cpp @@ -560,9 +560,16 @@ void QDBusAbstractInterface::connectNotify(const char *signal) return; QDBusConnectionPrivate *conn = d->connectionPrivate(); - if (conn) - conn->connectRelay(d->service, d->currentOwner, d->path, d->interface, + if (conn) { + // do we know what our owner is? + QString owner; + if (!d->service.isEmpty() && d->currentOwner.isNull()) + owner = QLatin1String(""); + else + owner = d->currentOwner; + conn->connectRelay(d->service, owner, d->path, d->interface, this, signal); + } } /*! diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 9e41708..8fff8b3 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1487,7 +1487,7 @@ void QDBusConnectionPrivate::handleSignal(const QString &key, const QDBusMessage //qDBusDebug() << signalHooks.keys(); for ( ; it != end && it.key() == key; ++it) { const SignalHook &hook = it.value(); - if (!hook.owner.isEmpty() && hook.owner != msg.service()) + if (!hook.owner.isNull() && hook.owner != msg.service()) continue; if (!hook.path.isEmpty() && hook.path != msg.path()) continue; -- cgit v0.12 From ed75146e45d41ca52b64193acbf433e6d2ceaaf5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 23 Oct 2009 19:33:38 +0200 Subject: Move the bulk of the signal connecting/disconnecting code to QDBusConnectionPrivate I'll need to recurse into the signal connection mechanism in the next commit. --- src/dbus/qdbusconnection.cpp | 63 ++------------------------------------ src/dbus/qdbusconnection_p.h | 6 ++++ src/dbus/qdbusintegrator.cpp | 73 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 60 deletions(-) diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 3aaba68..71e433e 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -619,37 +619,10 @@ bool QDBusConnection::connect(const QString &service, const QString &path, const if (interface.isEmpty() && name.isEmpty()) return false; - // check the slot - QDBusConnectionPrivate::SignalHook hook; - QString key; - QString name2 = name; - if (name2.isNull()) - name2.detach(); - QString owner = d->getNameOwner(service); // we don't care if the owner is empty - hook.signature = signature; // it might get started later - if (!d->prepareHook(hook, key, service, owner, path, interface, name, argumentMatch, receiver, slot, 0, false)) - return false; // don't connect - - // avoid duplicating: + // it might get started later QDBusWriteLocker locker(ConnectAction, d); - QDBusConnectionPrivate::SignalHookHash::ConstIterator it = d->signalHooks.find(key); - QDBusConnectionPrivate::SignalHookHash::ConstIterator end = d->signalHooks.constEnd(); - for ( ; it != end && it.key() == key; ++it) { - const QDBusConnectionPrivate::SignalHook &entry = it.value(); - if (entry.service == hook.service && - entry.owner == hook.owner && - entry.path == hook.path && - entry.signature == hook.signature && - entry.obj == hook.obj && - entry.midx == hook.midx) { - // no need to compare the parameters if it's the same slot - return true; // already there - } - } - - d->connectSignal(key, hook); - return true; + return d->connectSignal(service, owner, path, interface, name, argumentMatch, signature, receiver, slot); } /*! @@ -704,38 +677,8 @@ bool QDBusConnection::disconnect(const QString &service, const QString &path, co if (interface.isEmpty() && name.isEmpty()) return false; - // check the slot - QDBusConnectionPrivate::SignalHook hook; - QString key; - QString name2 = name; - if (name2.isNull()) - name2.detach(); - - QString owner = d->getNameOwner(service); // we don't care of owner is empty - hook.signature = signature; - if (!d->prepareHook(hook, key, service, owner, path, interface, name, argumentMatch, receiver, slot, 0, false)) - return false; // don't disconnect - - // avoid duplicating: QDBusWriteLocker locker(DisconnectAction, d); - QDBusConnectionPrivate::SignalHookHash::Iterator it = d->signalHooks.find(key); - QDBusConnectionPrivate::SignalHookHash::Iterator end = d->signalHooks.end(); - for ( ; it != end && it.key() == key; ++it) { - const QDBusConnectionPrivate::SignalHook &entry = it.value(); - if (entry.service == hook.service && - entry.owner == hook.owner && - entry.path == hook.path && - entry.signature == hook.signature && - entry.obj == hook.obj && - entry.midx == hook.midx) { - // no need to compare the parameters if it's the same slot - d->disconnectSignal(it); - return true; // it was there - } - } - - // the slot was not found - return false; + return d->disconnectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot); } /*! diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index df51c27..2402719 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -175,8 +175,14 @@ public: QDBusPendingCallPrivate *sendWithReplyAsync(const QDBusMessage &message, int timeout = -1); int sendWithReplyAsync(const QDBusMessage &message, QObject *receiver, const char *returnMethod, const char *errorMethod, int timeout = -1); + bool connectSignal(const QString &service, const QString &owner, const QString &path, const QString& interface, + const QString &name, const QStringList &argumentMatch, const QString &signature, + QObject *receiver, const char *slot); void connectSignal(const QString &key, const SignalHook &hook); SignalHookHash::Iterator disconnectSignal(SignalHookHash::Iterator &it); + bool disconnectSignal(const QString &service, const QString &path, const QString& interface, + const QString &name, const QStringList &argumentMatch, const QString &signature, + QObject *receiver, const char *slot); void registerObject(const ObjectTreeNode *node); void connectRelay(const QString &service, const QString ¤tOwner, const QString &path, const QString &interface, diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 8fff8b3..89a7449 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1942,6 +1942,42 @@ int QDBusConnectionPrivate::sendWithReplyAsync(const QDBusMessage &message, QObj return 1; } +bool QDBusConnectionPrivate::connectSignal(const QString &service, const QString &owner, + const QString &path, const QString &interface, const QString &name, + const QStringList &argumentMatch, const QString &signature, + QObject *receiver, const char *slot) +{ + // check the slot + QDBusConnectionPrivate::SignalHook hook; + QString key; + QString name2 = name; + if (name2.isNull()) + name2.detach(); + + hook.signature = signature; + if (!prepareHook(hook, key, service, owner, path, interface, name, argumentMatch, receiver, slot, 0, false)) + return false; // don't connect + + // avoid duplicating: + QDBusConnectionPrivate::SignalHookHash::ConstIterator it = signalHooks.find(key); + QDBusConnectionPrivate::SignalHookHash::ConstIterator end = signalHooks.constEnd(); + for ( ; it != end && it.key() == key; ++it) { + const QDBusConnectionPrivate::SignalHook &entry = it.value(); + if (entry.service == hook.service && + entry.owner == hook.owner && + entry.path == hook.path && + entry.signature == hook.signature && + entry.obj == hook.obj && + entry.midx == hook.midx) { + // no need to compare the parameters if it's the same slot + return true; // already there + } + } + + connectSignal(key, hook); + return true; +} + void QDBusConnectionPrivate::connectSignal(const QString &key, const SignalHook &hook) { signalHooks.insertMulti(key, hook); @@ -1973,6 +2009,43 @@ void QDBusConnectionPrivate::connectSignal(const QString &key, const SignalHook } } +bool QDBusConnectionPrivate::disconnectSignal(const QString &service, + const QString &path, const QString &interface, const QString &name, + const QStringList &argumentMatch, const QString &signature, + QObject *receiver, const char *slot) +{ + // check the slot + QDBusConnectionPrivate::SignalHook hook; + QString key; + QString name2 = name; + if (name2.isNull()) + name2.detach(); + + hook.signature = signature; + if (!prepareHook(hook, key, service, QString(), path, interface, name, argumentMatch, receiver, slot, 0, false)) + return false; // don't disconnect + + // avoid duplicating: + QDBusConnectionPrivate::SignalHookHash::Iterator it = signalHooks.find(key); + QDBusConnectionPrivate::SignalHookHash::Iterator end = signalHooks.end(); + for ( ; it != end && it.key() == key; ++it) { + const QDBusConnectionPrivate::SignalHook &entry = it.value(); + if (entry.service == hook.service && + //entry.owner == hook.owner && + entry.path == hook.path && + entry.signature == hook.signature && + entry.obj == hook.obj && + entry.midx == hook.midx) { + // no need to compare the parameters if it's the same slot + disconnectSignal(it); + return true; // it was there + } + } + + // the slot was not found + return false; +} + QDBusConnectionPrivate::SignalHookHash::Iterator QDBusConnectionPrivate::disconnectSignal(SignalHookHash::Iterator &it) { -- cgit v0.12 From 1176ecf0b533279e5a1c97f183e5c5f1c57fb188 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 23 Oct 2009 19:35:19 +0200 Subject: Stop using the NameOwnerChanged signal without arg0 in QtDBus itself We were using this signal to update the signal hooks when the remote service changed. That meant each Qt app received every single service creation, change or destruction. Now we only watch the services we're really interested in. --- src/dbus/qdbusconnection.cpp | 4 ---- src/dbus/qdbusconnection_p.h | 2 ++ src/dbus/qdbusintegrator.cpp | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 71e433e..d7088ff 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -1005,14 +1005,10 @@ void QDBusConnectionPrivate::setBusService(const QDBusConnection &connection) busService = new QDBusConnectionInterface(connection, this); ref.deref(); // busService has increased the refcounting to us // avoid cyclic refcounting -// if (mode != PeerMode) - QObject::connect(busService, SIGNAL(serviceOwnerChanged(QString,QString,QString)), - this, SIGNAL(serviceOwnerChanged(QString,QString,QString))); QObject::connect(this, SIGNAL(callWithCallbackFailed(QDBusError,QDBusMessage)), busService, SIGNAL(callWithCallbackFailed(QDBusError,QDBusMessage)), Qt::QueuedConnection); - } /*! diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index 2402719..ed29e4e 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -154,6 +154,7 @@ public: typedef QMultiHash SignalHookHash; typedef QHash MetaObjectHash; typedef QHash MatchRefCountHash; + typedef QHash WatchedServicesHash; public: // public methods are entry points from other objects @@ -270,6 +271,7 @@ public: QDBusError lastError; QStringList serviceNames; + WatchedServicesHash watchedServiceNames; SignalHookHash signalHooks; MatchRefCountHash matchRefCounts; ObjectTreeNode rootNode; diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 89a7449..c7538c3 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -501,6 +501,11 @@ static QObject *findChildObject(const QDBusConnectionPrivate::ObjectTreeNode *ro return 0; } +static bool shouldWatchService(const QString &service) +{ + return !service.isEmpty() && !service.startsWith(QLatin1Char(':')); +} + extern QDBUS_EXPORT void qDBusAddSpyHook(QDBusSpyHook); void qDBusAddSpyHook(QDBusSpyHook hook) { @@ -941,6 +946,7 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p) QDBusMetaTypeId::init(); rootNode.flags = 0; + watchedServiceNames[QLatin1String(DBUS_SERVICE_DBUS)] = 1; connect(this, SIGNAL(serviceOwnerChanged(QString,QString,QString)), this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); @@ -2005,6 +2011,22 @@ void QDBusConnectionPrivate::connectSignal(const QString &key, const SignalHook hook.obj->metaObject()->method(hook.midx).signature(), qPrintable(qerror.name()), qPrintable(qerror.message())); Q_ASSERT(false); + } else { + // Successfully connected the signal + // Do we need to watch for this name? + if (shouldWatchService(hook.service)) { + WatchedServicesHash::Iterator it = watchedServiceNames.find(hook.service); + if (it != watchedServiceNames.end()) { + // already watching + ++it.value(); + } else { + // we need to watch for this service changing + QString dbusServerService = QLatin1String(DBUS_SERVICE_DBUS); + connectSignal(dbusServerService, dbusServerService, QString(), QLatin1String(DBUS_INTERFACE_DBUS), + QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(), + this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); + } + } } } } @@ -2051,6 +2073,19 @@ QDBusConnectionPrivate::disconnectSignal(SignalHookHash::Iterator &it) { const SignalHook &hook = it.value(); + WatchedServicesHash::Iterator sit = watchedServiceNames.find(hook.service); + if (sit != watchedServiceNames.end()) { + if (sit.value() == 1) { + watchedServiceNames.erase(sit); + QString dbusServerService = QLatin1String(DBUS_SERVICE_DBUS); + disconnectSignal(dbusServerService, QString(), QLatin1String(DBUS_INTERFACE_DBUS), + QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(), + this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); + } else { + --sit.value(); + } + } + bool erase = false; MatchRefCountHash::iterator i = matchRefCounts.find(hook.matchRule); if (i == matchRefCounts.end()) { -- cgit v0.12 From da9a3a919326e35730b13d0660bb4a7b64e2c81c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 23 Oct 2009 19:37:16 +0200 Subject: Add a warning to user's connecting to serviceOwnerChanged directly We want people to not use this signal directly. --- src/dbus/qdbusconnectioninterface.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/dbus/qdbusconnectioninterface.cpp b/src/dbus/qdbusconnectioninterface.cpp index 8670ed5..414d318 100644 --- a/src/dbus/qdbusconnectioninterface.cpp +++ b/src/dbus/qdbusconnectioninterface.cpp @@ -336,8 +336,14 @@ void QDBusConnectionInterface::connectNotify(const char *signalName) else if (qstrcmp(signalName, SIGNAL(serviceUnregistered(QString))) == 0) QDBusAbstractInterface::connectNotify(SIGNAL(NameLost(QString))); - else if (qstrcmp(signalName, SIGNAL(serviceOwnerChanged(QString,QString,QString))) == 0) + else if (qstrcmp(signalName, SIGNAL(serviceOwnerChanged(QString,QString,QString))) == 0) { + static bool warningPrinted = false; + if (!warningPrinted) { + qWarning("Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)"); + warningPrinted = true; + } QDBusAbstractInterface::connectNotify(SIGNAL(NameOwnerChanged(QString,QString,QString))); + } } /*! -- cgit v0.12 From fb941d5c297e3205d421126c38a9f3a262584b88 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 26 Oct 2009 12:21:29 +0100 Subject: Add QDBusServiceWatcher class. --- src/dbus/dbus.pro | 148 ++++++++++++++------------- src/dbus/qdbusservicewatcher.cpp | 211 +++++++++++++++++++++++++++++++++++++++ src/dbus/qdbusservicewatcher.h | 103 +++++++++++++++++++ 3 files changed, 393 insertions(+), 69 deletions(-) create mode 100644 src/dbus/qdbusservicewatcher.cpp create mode 100644 src/dbus/qdbusservicewatcher.h diff --git a/src/dbus/dbus.pro b/src/dbus/dbus.pro index 57c6a58..9ab3920 100644 --- a/src/dbus/dbus.pro +++ b/src/dbus/dbus.pro @@ -1,77 +1,87 @@ -TARGET = QtDBus -QPRO_PWD = $$PWD -QT = core xml -CONFIG += link_pkgconfig -DEFINES += QDBUS_MAKEDLL DBUS_API_SUBJECT_TO_CHANGE +TARGET = QtDBus +QPRO_PWD = $$PWD +QT = core \ + xml +CONFIG += link_pkgconfig +DEFINES += QDBUS_MAKEDLL \ + DBUS_API_SUBJECT_TO_CHANGE QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS - -contains(QT_CONFIG, dbus-linked) { +contains(QT_CONFIG, dbus-linked) { LIBS_PRIVATE += $$QT_LIBS_DBUS - DEFINES += QT_LINKED_LIBDBUS + DEFINES += QT_LINKED_LIBDBUS } -#INCLUDEPATH += . - -unix { - QMAKE_PKGCONFIG_DESCRIPTION = Qt DBus module - QMAKE_PKGCONFIG_REQUIRES = QtCore QtXml +# INCLUDEPATH += . +unix { + QMAKE_PKGCONFIG_DESCRIPTION = Qt \ + DBus \ + module + QMAKE_PKGCONFIG_REQUIRES = QtCore \ + QtXml } - -win32 { - LIBS_PRIVATE += -lws2_32 -ladvapi32 -lnetapi32 -luser32 - CONFIG(debug, debug|release):LIBS_PRIVATE += -ldbus-1d - else:LIBS_PRIVATE += -ldbus-1 +win32 { + LIBS_PRIVATE += -lws2_32 \ + -ladvapi32 \ + -lnetapi32 \ + -luser32 + CONFIG(debug, debug|release):LIBS_PRIVATE += -ldbus-1d + else:LIBS_PRIVATE += -ldbus-1 } - include(../qbase.pri) - -PUB_HEADERS = qdbusargument.h \ - qdbusconnectioninterface.h \ - qdbusmacros.h \ - qdbuserror.h \ - qdbusextratypes.h \ - qdbusmessage.h \ - qdbusserver.h \ - qdbusconnection.h \ - qdbusabstractinterface.h \ - qdbusinterface.h \ - qdbusabstractadaptor.h \ - qdbusreply.h \ - qdbusmetatype.h \ - qdbuspendingcall.h \ - qdbuspendingreply.h \ - qdbuscontext.h - +PUB_HEADERS = qdbusargument.h \ + qdbusconnectioninterface.h \ + qdbusmacros.h \ + qdbuserror.h \ + qdbusextratypes.h \ + qdbusmessage.h \ + qdbusserver.h \ + qdbusconnection.h \ + qdbusabstractinterface.h \ + qdbusinterface.h \ + qdbusabstractadaptor.h \ + qdbusreply.h \ + qdbusmetatype.h \ + qdbuspendingcall.h \ + qdbuspendingreply.h \ + qdbuscontext.h HEADERS += $$PUB_HEADERS \ - qdbusconnection_p.h qdbusmessage_p.h \ - qdbusinterface_p.h qdbusxmlparser_p.h qdbusabstractadaptor_p.h \ - qdbusargument_p.h qdbusutil_p.h qdbusabstractinterface_p.h \ - qdbuscontext_p.h qdbusthreaddebug_p.h qdbusintegrator_p.h \ - qdbuspendingcall_p.h qdbus_symbols_p.h - -SOURCES += qdbusconnection.cpp \ - qdbusconnectioninterface.cpp \ - qdbuserror.cpp \ - qdbusintegrator.cpp \ - qdbusmessage.cpp \ - qdbusserver.cpp \ - qdbusabstractinterface.cpp \ - qdbusinterface.cpp \ - qdbusxmlparser.cpp \ - qdbusutil.cpp \ - qdbusintrospection.cpp \ - qdbusabstractadaptor.cpp \ - qdbusinternalfilters.cpp \ - qdbusmetaobject.cpp \ - qdbusxmlgenerator.cpp \ - qdbusmisc.cpp \ - qdbusargument.cpp \ - qdbusreply.cpp \ - qdbusmetatype.cpp \ - qdbusextratypes.cpp \ - qdbusmarshaller.cpp \ - qdbuscontext.cpp \ - qdbuspendingcall.cpp \ - qdbuspendingreply.cpp \ - qdbus_symbols.cpp - + qdbusconnection_p.h \ + qdbusmessage_p.h \ + qdbusinterface_p.h \ + qdbusxmlparser_p.h \ + qdbusabstractadaptor_p.h \ + qdbusargument_p.h \ + qdbusutil_p.h \ + qdbusabstractinterface_p.h \ + qdbuscontext_p.h \ + qdbusthreaddebug_p.h \ + qdbusintegrator_p.h \ + qdbuspendingcall_p.h \ + qdbus_symbols_p.h \ + qdbusservicewatcher.h +SOURCES += qdbusconnection.cpp \ + qdbusconnectioninterface.cpp \ + qdbuserror.cpp \ + qdbusintegrator.cpp \ + qdbusmessage.cpp \ + qdbusserver.cpp \ + qdbusabstractinterface.cpp \ + qdbusinterface.cpp \ + qdbusxmlparser.cpp \ + qdbusutil.cpp \ + qdbusintrospection.cpp \ + qdbusabstractadaptor.cpp \ + qdbusinternalfilters.cpp \ + qdbusmetaobject.cpp \ + qdbusxmlgenerator.cpp \ + qdbusmisc.cpp \ + qdbusargument.cpp \ + qdbusreply.cpp \ + qdbusmetatype.cpp \ + qdbusextratypes.cpp \ + qdbusmarshaller.cpp \ + qdbuscontext.cpp \ + qdbuspendingcall.cpp \ + qdbuspendingreply.cpp \ + qdbus_symbols.cpp \ + qdbusservicewatcher.cpp diff --git a/src/dbus/qdbusservicewatcher.cpp b/src/dbus/qdbusservicewatcher.cpp new file mode 100644 index 0000000..d8a33c3 --- /dev/null +++ b/src/dbus/qdbusservicewatcher.cpp @@ -0,0 +1,211 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDBus 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qdbusservicewatcher.h" +#include "qdbusconnection.h" +#include "qdbus_symbols_p.h" + +#include + +#include + +Q_GLOBAL_STATIC_WITH_ARGS(QString, busService, (QLatin1String(DBUS_SERVICE_DBUS))) +Q_GLOBAL_STATIC_WITH_ARGS(QString, busPath, (QLatin1String(DBUS_PATH_DBUS))) +Q_GLOBAL_STATIC_WITH_ARGS(QString, busInterface, (QLatin1String(DBUS_INTERFACE_DBUS))) +Q_GLOBAL_STATIC_WITH_ARGS(QString, signalName, (QLatin1String("NameOwnerChanged"))) + +class QDBusServiceWatcherPrivate: public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QDBusServiceWatcher) +public: + QDBusServiceWatcherPrivate(const QDBusConnection &c, QDBusServiceWatcher::WatchMode wm) + : connection(c), watchMode(wm) + { + } + + QStringList servicesWatched; + QDBusConnection connection; + QDBusServiceWatcher::WatchMode watchMode; + + void _q_serviceOwnerChanged(const QString &, const QString &, const QString &); + void setConnection(const QStringList &services, const QDBusConnection &c, QDBusServiceWatcher::WatchMode watchMode); + + QStringList matchArgsForService(const QString &service); + void addService(const QString &service); + void removeService(const QString &service); +}; + +void QDBusServiceWatcherPrivate::_q_serviceOwnerChanged(const QString &service, const QString &oldOwner, const QString &newOwner) +{ + Q_Q(QDBusServiceWatcher); + emit q->serviceOwnerChanged(service, oldOwner, newOwner); + if (oldOwner.isEmpty()) + emit q->serviceRegistered(service); + else if (newOwner.isEmpty()) + emit q->serviceUnregistered(service); +} + +void QDBusServiceWatcherPrivate::setConnection(const QStringList &s, const QDBusConnection &c, QDBusServiceWatcher::WatchMode wm) +{ + if (connection.isConnected()) { + // remove older rules + foreach (const QString &s, servicesWatched) + removeService(s); + } + + connection = c; + watchMode = wm; + servicesWatched = s; + + if (connection.isConnected()) { + // add new rules + foreach (const QString &s, servicesWatched) + addService(s); + } +} + +QStringList QDBusServiceWatcherPrivate::matchArgsForService(const QString &service) +{ + QStringList matchArgs; + matchArgs << service; + + switch (watchMode) { + case QDBusServiceWatcher::WatchForOwnerChange: + break; + + case QDBusServiceWatcher::WatchForRegistration: + matchArgs << QString::fromLatin1("", 0); + break; + + case QDBusServiceWatcher::WatchForUnregistration: + matchArgs << QString() << QString::fromLatin1("", 0); + break; + } + return matchArgs; +} + +void QDBusServiceWatcherPrivate::addService(const QString &service) +{ + QStringList matchArgs = matchArgsForService(service); + connection.connect(*busService(), *busPath(), *busInterface(), *signalName(), + matchArgs, QString(), q_func(), + SLOT(_q_serviceOwnerChanged(QString,QString,QString))); +} + +void QDBusServiceWatcherPrivate::removeService(const QString &service) +{ + QStringList matchArgs = matchArgsForService(service); + connection.disconnect(*busService(), *busPath(), *busInterface(), *signalName(), + matchArgs, QString(), q_func(), + SLOT(_q_serviceOwnerChanged(QString,QString,QString))); +} + +QDBusServiceWatcher::QDBusServiceWatcher(QObject *parent) + : QObject(*new QDBusServiceWatcherPrivate(QDBusConnection(QString()), WatchForOwnerChange), parent) +{ +} + +QDBusServiceWatcher::QDBusServiceWatcher(const QString &service, const QDBusConnection &connection, WatchMode watchMode, QObject *parent) + : QObject(*new QDBusServiceWatcherPrivate(connection, watchMode), parent) +{ + d_func()->setConnection(QStringList() << service, connection, watchMode); +} + +QDBusServiceWatcher::~QDBusServiceWatcher() +{ +} + +QStringList QDBusServiceWatcher::watchedServices() const +{ + return d_func()->servicesWatched; +} + +void QDBusServiceWatcher::setWatchedServices(const QStringList &services) +{ + Q_D(QDBusServiceWatcher); + if (services == d->servicesWatched) + return; + d->setConnection(services, d->connection, d->watchMode); +} + +void QDBusServiceWatcher::addWatchedService(const QString &newService) +{ + Q_D(QDBusServiceWatcher); + if (d->servicesWatched.contains(newService)) + return; + d->addService(newService); + d->servicesWatched << newService; +} + +bool QDBusServiceWatcher::removeWatchedService(const QString &service) +{ + Q_D(QDBusServiceWatcher); + d->removeService(service); + return d->servicesWatched.removeOne(service); +} + +QDBusServiceWatcher::WatchMode QDBusServiceWatcher::watchMode() const +{ + return d_func()->watchMode; +} + +void QDBusServiceWatcher::setWatchMode(WatchMode mode) +{ + Q_D(QDBusServiceWatcher); + if (mode == d->watchMode) + return; + d->setConnection(d->servicesWatched, d->connection, mode); +} + +QDBusConnection QDBusServiceWatcher::connection() const +{ + return d_func()->connection; +} + +void QDBusServiceWatcher::setConnection(const QDBusConnection &connection) +{ + Q_D(QDBusServiceWatcher); + if (connection.name() == d->connection.name()) + return; + d->setConnection(d->servicesWatched, connection, d->watchMode); +} + +#include "moc_qdbusservicewatcher.cpp" diff --git a/src/dbus/qdbusservicewatcher.h b/src/dbus/qdbusservicewatcher.h new file mode 100644 index 0000000..a968a9c --- /dev/null +++ b/src/dbus/qdbusservicewatcher.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDBus 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDBUSSERVICEWATCHER_H +#define QDBUSSERVICEWATCHER_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(DBus) + +class QDBusConnection; + +class QDBusServiceWatcherPrivate; +class QDBUS_EXPORT QDBusServiceWatcher: public QObject +{ + Q_OBJECT + Q_PROPERTY(QStringList watchedServices READ watchedServices WRITE setWatchedServices) + Q_PROPERTY(WatchMode watchMode READ watchMode WRITE setWatchMode) +public: + enum WatchModeFlag { + WatchForRegistration = 0x01, + WatchForUnregistration = 0x02, + WatchForOwnerChange = 0x03 + }; + Q_DECLARE_FLAGS(WatchMode, WatchModeFlag) + + explicit QDBusServiceWatcher(QObject *parent = 0); + QDBusServiceWatcher(const QString &service, const QDBusConnection &connection, + WatchMode watchMode = WatchForOwnerChange, QObject *parent = 0); + ~QDBusServiceWatcher(); + + QStringList watchedServices() const; + void setWatchedServices(const QStringList &services); + void addWatchedService(const QString &newService); + bool removeWatchedService(const QString &service); + + WatchMode watchMode() const; + void setWatchMode(WatchMode mode); + + QDBusConnection connection() const; + void setConnection(const QDBusConnection &connection); + +Q_SIGNALS: + void serviceRegistered(const QString &service); + void serviceUnregistered(const QString &service); + void serviceOwnerChanged(const QString &service, const QString &oldOwner, const QString &newOwner); + +private: + Q_PRIVATE_SLOT(d_func(), void _q_serviceOwnerChanged(QString,QString,QString)) + Q_DISABLE_COPY(QDBusServiceWatcher) + Q_DECLARE_PRIVATE(QDBusServiceWatcher) +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QDBusServiceWatcher::WatchMode) + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QDBUSSERVICEWATCHER_H -- cgit v0.12 From f9b55c5263ba25e707c8cc35988935a804af2f50 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 26 Oct 2009 14:08:01 +0100 Subject: Autotest: add unit test for QDBusServiceWatcher --- .../qdbusservicewatcher/qdbusservicewatcher.pro | 8 + .../tst_qdbusservicewatcher.cpp | 273 +++++++++++++++++++++ 2 files changed, 281 insertions(+) create mode 100644 tests/auto/qdbusservicewatcher/qdbusservicewatcher.pro create mode 100644 tests/auto/qdbusservicewatcher/tst_qdbusservicewatcher.cpp diff --git a/tests/auto/qdbusservicewatcher/qdbusservicewatcher.pro b/tests/auto/qdbusservicewatcher/qdbusservicewatcher.pro new file mode 100644 index 0000000..4970f16 --- /dev/null +++ b/tests/auto/qdbusservicewatcher/qdbusservicewatcher.pro @@ -0,0 +1,8 @@ +load(qttest_p4) +QT = core +contains(QT_CONFIG,dbus): { + SOURCES += tst_qdbusservicewatcher.cpp + QT += dbus +} else { + SOURCES += ../qdbusmarshall/dummy.cpp +} diff --git a/tests/auto/qdbusservicewatcher/tst_qdbusservicewatcher.cpp b/tests/auto/qdbusservicewatcher/tst_qdbusservicewatcher.cpp new file mode 100644 index 0000000..10b43b1 --- /dev/null +++ b/tests/auto/qdbusservicewatcher/tst_qdbusservicewatcher.cpp @@ -0,0 +1,273 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +class tst_QDBusServiceWatcher: public QObject +{ + Q_OBJECT + QString serviceName; +public: + tst_QDBusServiceWatcher(); + +private slots: + void initTestCase(); + void cleanup(); + + void watchForCreation(); + void watchForDisappearance(); + void watchForOwnerChange(); + void modeChange(); +}; + +tst_QDBusServiceWatcher::tst_QDBusServiceWatcher() + : serviceName("com.example.TestName") +{ +} + +void tst_QDBusServiceWatcher::initTestCase() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QVERIFY(con.isConnected()); +} + +void tst_QDBusServiceWatcher::cleanup() +{ + // ensure that the name isn't registered + QDBusConnection::sessionBus().unregisterService(serviceName); +} + +void tst_QDBusServiceWatcher::watchForCreation() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QVERIFY(con.isConnected()); + + QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForRegistration); + + QSignalSpy spyR(&watcher, SIGNAL(serviceRegistered(QString))); + QSignalSpy spyU(&watcher, SIGNAL(serviceUnregistered(QString))); + QSignalSpy spyO(&watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString))); + QTestEventLoop::instance().connect(&watcher, SIGNAL(serviceRegistered(QString)), SLOT(exitLoop())); + + // register a name + QVERIFY(con.registerService(serviceName)); + + QTestEventLoop::instance().enterLoop(1); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QCOMPARE(spyR.count(), 1); + QCOMPARE(spyR.at(0).at(0).toString(), serviceName); + + QCOMPARE(spyU.count(), 0); + + QCOMPARE(spyO.count(), 1); + QCOMPARE(spyO.at(0).at(0).toString(), serviceName); + QVERIFY(spyO.at(0).at(1).toString().isEmpty()); + QCOMPARE(spyO.at(0).at(2).toString(), con.baseService()); + + spyR.clear(); + spyU.clear(); + spyO.clear(); + + // unregister it: + con.unregisterService(serviceName); + + // and register again + QVERIFY(con.registerService(serviceName)); + + QTestEventLoop::instance().enterLoop(1); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QCOMPARE(spyR.count(), 1); + QCOMPARE(spyR.at(0).at(0).toString(), serviceName); + + QCOMPARE(spyU.count(), 0); + + QCOMPARE(spyO.count(), 1); + QCOMPARE(spyO.at(0).at(0).toString(), serviceName); + QVERIFY(spyO.at(0).at(1).toString().isEmpty()); + QCOMPARE(spyO.at(0).at(2).toString(), con.baseService()); +} + +void tst_QDBusServiceWatcher::watchForDisappearance() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QVERIFY(con.isConnected()); + + QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForUnregistration); + + QSignalSpy spyR(&watcher, SIGNAL(serviceRegistered(QString))); + QSignalSpy spyU(&watcher, SIGNAL(serviceUnregistered(QString))); + QSignalSpy spyO(&watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString))); + QTestEventLoop::instance().connect(&watcher, SIGNAL(serviceUnregistered(QString)), SLOT(exitLoop())); + + // register a name + QVERIFY(con.registerService(serviceName)); + + // unregister it: + con.unregisterService(serviceName); + + QTestEventLoop::instance().enterLoop(1); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QCOMPARE(spyR.count(), 0); + + QCOMPARE(spyU.count(), 1); + QCOMPARE(spyU.at(0).at(0).toString(), serviceName); + + QCOMPARE(spyO.count(), 1); + QCOMPARE(spyO.at(0).at(0).toString(), serviceName); + QCOMPARE(spyO.at(0).at(1).toString(), con.baseService()); + QVERIFY(spyO.at(0).at(2).toString().isEmpty()); +} + +void tst_QDBusServiceWatcher::watchForOwnerChange() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QVERIFY(con.isConnected()); + + QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForOwnerChange); + + QSignalSpy spyR(&watcher, SIGNAL(serviceRegistered(QString))); + QSignalSpy spyU(&watcher, SIGNAL(serviceUnregistered(QString))); + QSignalSpy spyO(&watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString))); + QTestEventLoop::instance().connect(&watcher, SIGNAL(serviceRegistered(QString)), SLOT(exitLoop())); + + // register a name + QVERIFY(con.registerService(serviceName)); + + QTestEventLoop::instance().enterLoop(1); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QCOMPARE(spyR.count(), 1); + QCOMPARE(spyR.at(0).at(0).toString(), serviceName); + + QCOMPARE(spyU.count(), 0); + + QCOMPARE(spyO.count(), 1); + QCOMPARE(spyO.at(0).at(0).toString(), serviceName); + QVERIFY(spyO.at(0).at(1).toString().isEmpty()); + QCOMPARE(spyO.at(0).at(2).toString(), con.baseService()); + + spyR.clear(); + spyU.clear(); + spyO.clear(); + + // unregister it: + con.unregisterService(serviceName); + + // and register again + QVERIFY(con.registerService(serviceName)); + + QTestEventLoop::instance().enterLoop(1); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QCOMPARE(spyR.count(), 1); + QCOMPARE(spyR.at(0).at(0).toString(), serviceName); + + QCOMPARE(spyU.count(), 1); + QCOMPARE(spyU.at(0).at(0).toString(), serviceName); + + QCOMPARE(spyO.count(), 2); + QCOMPARE(spyO.at(0).at(0).toString(), serviceName); + QCOMPARE(spyO.at(0).at(1).toString(), con.baseService()); + QVERIFY(spyO.at(0).at(2).toString().isEmpty()); + QCOMPARE(spyO.at(1).at(0).toString(), serviceName); + QVERIFY(spyO.at(1).at(1).toString().isEmpty()); + QCOMPARE(spyO.at(1).at(2).toString(), con.baseService()); +} + +void tst_QDBusServiceWatcher::modeChange() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QVERIFY(con.isConnected()); + + QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForRegistration); + + QSignalSpy spyR(&watcher, SIGNAL(serviceRegistered(QString))); + QSignalSpy spyU(&watcher, SIGNAL(serviceUnregistered(QString))); + QSignalSpy spyO(&watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString))); + QTestEventLoop::instance().connect(&watcher, SIGNAL(serviceRegistered(QString)), SLOT(exitLoop())); + + // register a name + QVERIFY(con.registerService(serviceName)); + + QTestEventLoop::instance().enterLoop(1); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QCOMPARE(spyR.count(), 1); + QCOMPARE(spyR.at(0).at(0).toString(), serviceName); + + QCOMPARE(spyU.count(), 0); + + QCOMPARE(spyO.count(), 1); + QCOMPARE(spyO.at(0).at(0).toString(), serviceName); + QVERIFY(spyO.at(0).at(1).toString().isEmpty()); + QCOMPARE(spyO.at(0).at(2).toString(), con.baseService()); + + spyR.clear(); + spyU.clear(); + spyO.clear(); + + watcher.setWatchMode(QDBusServiceWatcher::WatchForUnregistration); + + // unregister it: + con.unregisterService(serviceName); + + QTestEventLoop::instance().connect(&watcher, SIGNAL(serviceUnregistered(QString)), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(1); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QCOMPARE(spyR.count(), 0); + + QCOMPARE(spyU.count(), 1); + QCOMPARE(spyU.at(0).at(0).toString(), serviceName); + + QCOMPARE(spyO.count(), 1); + QCOMPARE(spyO.at(0).at(0).toString(), serviceName); + QCOMPARE(spyO.at(0).at(1).toString(), con.baseService()); + QVERIFY(spyO.at(0).at(2).toString().isEmpty()); +} + +QTEST_MAIN(tst_QDBusServiceWatcher) +#include "tst_qdbusservicewatcher.moc" -- cgit v0.12 From bd9a8091eb8c731569e4972a04f23c9a2f48391c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 26 Oct 2009 15:16:47 +0100 Subject: Doc: add documentation for QDBusServiceWatcher class. --- src/dbus/qdbusservicewatcher.cpp | 163 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) diff --git a/src/dbus/qdbusservicewatcher.cpp b/src/dbus/qdbusservicewatcher.cpp index d8a33c3..4872732 100644 --- a/src/dbus/qdbusservicewatcher.cpp +++ b/src/dbus/qdbusservicewatcher.cpp @@ -138,26 +138,159 @@ void QDBusServiceWatcherPrivate::removeService(const QString &service) SLOT(_q_serviceOwnerChanged(QString,QString,QString))); } +/*! + \class QDBusServiceWatcher + \since 4.6 + \inmodule QtDBus + + \brief The QDBusServiceWatcher class allows the user to watch for a bus service change. + + A QDBusServiceWatcher object can be used to notify the application about + an ownership change of a service name on the bus. It has three watch + modes: + + \list + \o watching for service registration only + \o watching for service unregistration only + \o watching for any kind of service ownership change (the default mode) + \endlist + + Besides being created or deleted, services may change owners without a + unregister/register operation happening. So the \ref serviceRegistered() + and \ref serviceUnregistered() signals may not be emitted if that + happens. + + This class is more efficient than using the + QDBusConnectionInterface::serviceOwnerChanged() signal because it allows + one to receive only the signals for which the class is interested in. + + \sa QDBusConnection +*/ + +/*! + \enum QDBusServiceWatcher::WatchModeFlag + + QDBusServiceWatcher supports three different watch modes, which are configured by this flag: + + \value WatchForRegistration watch for service registration only, ignoring + any signals related to other service ownership change. + + \value WatchForUnregistration watch for service unregistration only, + ignoring any signals related to other service ownership change. + + \value WatchForOwnerChange watch for any kind of service ownership + change. +*/ + +/*! + \property QDBusServiceWatcher::watchMode + + The \c watchMode property holds the current watch mode for this + QDBusServiceWatcher object. The default value for this property is + QDBusServiceWatcher::WatchForOwnershipChange. +*/ + +/*! + \property QDBusServiceWatcher::watchedServices + + The \c servicesWatched property holds the list of services watched. + + Note that modifying this list with setServicesWatched() is an expensive + operation. If you can, prefer to change it by way of addWatchedService() + and removeWatchedService(). +*/ + +/*! + \fn void QDBusServiceWatcher::serviceRegistered(const QString &serviceName) + + This signal is emitted whenever this object detects that the service \a + serviceName became available on the bus. + + \sa serviceUnregistered(), serviceOwnerChanged() +*/ + +/*! + \fn void QDBusServiceWatcher::serviceUnregistered(const QString &serviceName) + + This signal is emitted whenever this object detects that the service \a + serviceName was unregistered from the bus and is no longer available. + + \sa serviceRegistered(), serviceOwnerChanged() +*/ + +/*! + \fn void QDBusServiceWatcher::serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner) + + This signal is emitted whenever this object detects that there was a + service ownership change relating to the \a serviceName service. The \a + oldOwner parameter contains the old owner name and \a newOwner is the new + owner. Both \a oldOwner and \a newOwner are unique connection names. + + Note that this signal is also emitted whenever the \a serviceName service + was registered or unregistered. If it was registered, \a oldOwner will + contain an empty string, whereas if it was unregistered, \a newOwner will + contain an empty string. + + If you need only to find out if the service is registered or unregistered + only, without being notified that the ownership changed, consider using + the specific modes for those operations. This class is more efficient if + you use the more specific modes. + + \sa serviceRegistered(), serviceUnregistered() +*/ + +/*! + Creates a QDBusServiceWatcher object. Note that until you set a + connection with setConnection(), this object will not emit any signals. + + The \a parent parameter is passed to QObject to set the parent of this + object. +*/ QDBusServiceWatcher::QDBusServiceWatcher(QObject *parent) : QObject(*new QDBusServiceWatcherPrivate(QDBusConnection(QString()), WatchForOwnerChange), parent) { } +/*! + Creates a QDBusServiceWatcher object and attaches it to the \a connection + connection. Also, this function immediately starts watching for \a + watchMode changes to service \a service. + + The \a parent parameter is passed to QObject to set the parent of this + object. +*/ QDBusServiceWatcher::QDBusServiceWatcher(const QString &service, const QDBusConnection &connection, WatchMode watchMode, QObject *parent) : QObject(*new QDBusServiceWatcherPrivate(connection, watchMode), parent) { d_func()->setConnection(QStringList() << service, connection, watchMode); } +/*! + Destroys the QDBusServiceWatcher object and releases any resources + associated with it. +*/ QDBusServiceWatcher::~QDBusServiceWatcher() { } +/*! + Returns the list of D-Bus services that are being watched. + + \sa setWatchedServices() +*/ QStringList QDBusServiceWatcher::watchedServices() const { return d_func()->servicesWatched; } +/*! + Sets the list of D-Bus services being watched to be \a services. + + Note that setting the entire list means removing all previous rules for + watching services and adding new ones. This is an expensive operation and + should be avoided, if possible. Instead, use addWatchedService() and + removeWatchedService() if you can to manipulate entries in the list. +*/ void QDBusServiceWatcher::setWatchedServices(const QStringList &services) { Q_D(QDBusServiceWatcher); @@ -166,6 +299,11 @@ void QDBusServiceWatcher::setWatchedServices(const QStringList &services) d->setConnection(services, d->connection, d->watchMode); } +/*! + Adds \a newService to the list of services to be watched by this object. + This function is more efficient than setWatchedServices() and should be + used whenever possible to add services. +*/ void QDBusServiceWatcher::addWatchedService(const QString &newService) { Q_D(QDBusServiceWatcher); @@ -175,6 +313,14 @@ void QDBusServiceWatcher::addWatchedService(const QString &newService) d->servicesWatched << newService; } +/*! + Removes the \a service from the list of services being watched by this + object. Note that D-Bus notifications are asynchronous, so there may + still be signals pending delivery about \a service. Those signals will + still be emitted whenever the D-Bus messages are processed. + + This function returns true if any services were removed. +*/ bool QDBusServiceWatcher::removeWatchedService(const QString &service) { Q_D(QDBusServiceWatcher); @@ -195,11 +341,28 @@ void QDBusServiceWatcher::setWatchMode(WatchMode mode) d->setConnection(d->servicesWatched, d->connection, mode); } +/*! + Returns the QDBusConnection that this object is attached to. + + \sa setConnection() +*/ QDBusConnection QDBusServiceWatcher::connection() const { return d_func()->connection; } +/*! + Sets the D-Bus connection that this object is attached to be \a + connection. All services watched will be transferred to this connection. + + Note that QDBusConnection objects are reference counted: + QDBusServiceWatcher will keep a reference for this connection while it + exists. The connection is not closed until the reference count drops to + zero, so this will ensure that any notifications are received while this + QDBusServiceWatcher object exists. + + \sa connection() +*/ void QDBusServiceWatcher::setConnection(const QDBusConnection &connection) { Q_D(QDBusServiceWatcher); -- cgit v0.12 From 680de3b4bf3c62b2df83797f8cee5789c121bf00 Mon Sep 17 00:00:00 2001 From: Jani Hautakangas Date: Wed, 28 Oct 2009 11:13:08 +0200 Subject: Fix EColor16M conversion in QPixmap::fromSymbianCFbsBitmap() EColor16M is in BGR format so after conversion to QImage RGB values needs to be swapped. Reviewed-by: jbarron --- src/gui/image/qpixmap_s60.cpp | 15 +++++++++------ tests/auto/qpixmap/tst_qpixmap.cpp | 2 ++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index 666d608..c56e9b7 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -935,18 +935,21 @@ void QS60PixmapData::fromNativeType(void* pixmap, NativeType nativeType) da.beginDataAccess(sourceBitmap); uchar *bytes = (uchar*)sourceBitmap->DataAddress(); QImage img = QImage(bytes, size.iWidth, size.iHeight, format); + img = img.copy(); da.endDataAccess(sourceBitmap); - fromImage(img, Qt::AutoColor); - - if(deleteSourceBitmap) - delete sourceBitmap; - if(displayMode == EGray2) { //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid //So invert mono bitmaps so that masks work correctly. - image.invertPixels(); + img.invertPixels(); + } else if(displayMode == EColor16M) { + img = img.rgbSwapped(); // EColor16M is BGR } + + fromImage(img, Qt::AutoColor); + + if(deleteSourceBitmap) + delete sourceBitmap; } else { CFbsBitmap* duplicate = 0; QT_TRAP_THROWING(duplicate = new (ELeave) CFbsBitmap); diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 53b6230..8e02c74 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -1134,6 +1134,8 @@ void tst_QPixmap::fromSymbianCFbsBitmap_data() QTest::newRow("EColor4K big") << EColor4K << largeWidth << largeHeight << QColor(Qt::red); QTest::newRow("EColor64K small") << EColor64K << smallWidth << smallHeight << QColor(Qt::green); QTest::newRow("EColor64K big") << EColor64K << largeWidth << largeHeight << QColor(Qt::green); + QTest::newRow("EColor16M small") << EColor16M << smallWidth << smallHeight << QColor(Qt::yellow); + QTest::newRow("EColor16M big") << EColor16M << largeWidth << largeHeight << QColor(Qt::yellow); QTest::newRow("EColor16MU small") << EColor16MU << smallWidth << smallHeight << QColor(Qt::red); QTest::newRow("EColor16MU big") << EColor16MU << largeWidth << largeHeight << QColor(Qt::red); QTest::newRow("EColor16MA small opaque") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0); -- cgit v0.12 From de7de35082ec21d506a90e68cb30888540ec64cc Mon Sep 17 00:00:00 2001 From: Thorvald Natvig Date: Tue, 20 Oct 2009 13:31:02 +0200 Subject: Fix XML entities in QTextDocument::toHtml() If a QTextDocument contains an anchor with a & in it, this & is not escaped in the toHtml() function, meaning the resulting document can't be parsed as XML as it will contain invalid entities. Reviewed-by: Olivier Goffart Merge-request: 1753 --- src/gui/text/qtextdocument.cpp | 33 ++++++++++++++++++++------ tests/auto/qtextdocument/qtextdocument.pro | 1 + tests/auto/qtextdocument/tst_qtextdocument.cpp | 32 +++++++++++++++++++++++-- 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index a8956b8..17981e3 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -168,6 +168,25 @@ QString Qt::escape(const QString& plain) return rich; } +static QString escapeXml(const QString &plain) +{ + QString rich; + rich.reserve(int(plain.length() * 1.1)); + for (int i = 0; i < plain.length(); ++i) { + if (plain.at(i) == QLatin1Char('<')) + rich += QLatin1String("<"); + else if (plain.at(i) == QLatin1Char('>')) + rich += QLatin1String(">"); + else if (plain.at(i) == QLatin1Char('&')) + rich += QLatin1String("&"); + else if (plain.at(i) == QLatin1Char('"')) + rich += QLatin1String("""); + else + rich += plain.at(i); + } + return rich; +} + /*! \fn QString Qt::convertFromPlainText(const QString &plain, WhiteSpaceMode mode) @@ -2038,7 +2057,7 @@ void QTextHtmlExporter::emitAttribute(const char *attribute, const QString &valu html += QLatin1Char(' '); html += QLatin1String(attribute); html += QLatin1String("=\""); - html += value; + html += escapeXml(value); html += QLatin1Char('"'); } @@ -2302,12 +2321,12 @@ void QTextHtmlExporter::emitFontFamily(const QString &family) { html += QLatin1String(" font-family:"); - QLatin1Char quote('\''); - if (family.contains(quote)) - quote = QLatin1Char('\"'); + QLatin1String quote("\'"); + if (family.contains(QLatin1Char('\''))) + quote = QLatin1String("""); html += quote; - html += family; + html += escapeXml(family); html += quote; html += QLatin1Char(';'); } @@ -2341,13 +2360,13 @@ void QTextHtmlExporter::emitFragment(const QTextFragment &fragment) const QString name = format.anchorName(); if (!name.isEmpty()) { html += QLatin1String(""); } const QString href = format.anchorHref(); if (!href.isEmpty()) { html += QLatin1String(""); closeAnchor = true; } diff --git a/tests/auto/qtextdocument/qtextdocument.pro b/tests/auto/qtextdocument/qtextdocument.pro index d3ec45d..1e44a9c 100644 --- a/tests/auto/qtextdocument/qtextdocument.pro +++ b/tests/auto/qtextdocument/qtextdocument.pro @@ -1,4 +1,5 @@ load(qttest_p4) +QT += xml HEADERS += common.h SOURCES += tst_qtextdocument.cpp diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp index f393393..452b683 100644 --- a/tests/auto/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp @@ -59,6 +59,7 @@ #include #include #include +#include #include "common.h" @@ -732,7 +733,7 @@ void tst_QTextDocument::toHtml_data() cursor.insertText("Blah", fmt); QTest::newRow("font-family-with-quotes1") << QTextDocumentFragment(&doc) - << QString("

Blah

"); + << QString("

Blah

"); } { @@ -743,7 +744,7 @@ void tst_QTextDocument::toHtml_data() cursor.insertText("Blah", fmt); QTest::newRow("font-family-with-quotes2") << QTextDocumentFragment(&doc) - << QString("

Blah

"); + << QString("

Blah

"); } { @@ -974,6 +975,30 @@ void tst_QTextDocument::toHtml_data() { CREATE_DOC_AND_CURSOR(); + QTextCharFormat fmt; + fmt.setAnchor(true); + fmt.setAnchorHref("http://www.kde.org/?a=1&b=2"); + cursor.insertText("Blah", fmt); + + QTest::newRow("href anchor with &") << QTextDocumentFragment(&doc) + << QString("

Blah

"); + } + + { + CREATE_DOC_AND_CURSOR(); + + QTextCharFormat fmt; + fmt.setAnchor(true); + fmt.setAnchorHref("http://www.kde.org/?a='&b=\""); + cursor.insertText("Blah", fmt); + + QTest::newRow("href anchor with ' and \"") << QTextDocumentFragment(&doc) + << QString("

Blah

"); + } + + { + CREATE_DOC_AND_CURSOR(); + cursor.insertTable(2, 2); QTest::newRow("simpletable") << QTextDocumentFragment(&doc) @@ -1541,6 +1566,9 @@ void tst_QTextDocument::toHtml() QString output = doc->toHtml(); QCOMPARE(output, expectedOutput); + + QDomDocument document; + QVERIFY2(document.setContent(output), "Output was not valid XML"); } void tst_QTextDocument::toHtml2() -- cgit v0.12 From 1f3218e086778a0e324542a00937cd44e8e10c79 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 27 Oct 2009 20:37:27 +0100 Subject: Qt::escape(): also escape the quote (") This amend previous commit by removing the duplicate function. The quote need to be escaped in attributes. Reviewed-by: Thomas Zander --- dist/changes-4.6.0 | 3 +++ src/gui/text/qtextdocument.cpp | 27 +++++--------------------- tests/auto/qtextdocument/tst_qtextdocument.cpp | 26 +++++++++++++++++++++++-- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 7f723da..ba2b051 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -35,6 +35,9 @@ information about a particular change. * Added QVariant::toFloat() and QVariant::toReal() * Added QVariant(float) constructor + - Qt::escape + * now escape the double quote (") + **************************************************************************** * Platform Specific Changes * **************************************************************************** diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 17981e3..6978b6c 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -140,7 +140,7 @@ bool Qt::mightBeRichText(const QString& text) /*! Converts the plain text string \a plain to a HTML string with - HTML metacharacters \c{<}, \c{>}, and \c{&} replaced by HTML + HTML metacharacters \c{<}, \c{>}, \c{&}, and \c{"} replaced by HTML entities. Example: @@ -162,23 +162,6 @@ QString Qt::escape(const QString& plain) rich += QLatin1String(">"); else if (plain.at(i) == QLatin1Char('&')) rich += QLatin1String("&"); - else - rich += plain.at(i); - } - return rich; -} - -static QString escapeXml(const QString &plain) -{ - QString rich; - rich.reserve(int(plain.length() * 1.1)); - for (int i = 0; i < plain.length(); ++i) { - if (plain.at(i) == QLatin1Char('<')) - rich += QLatin1String("<"); - else if (plain.at(i) == QLatin1Char('>')) - rich += QLatin1String(">"); - else if (plain.at(i) == QLatin1Char('&')) - rich += QLatin1String("&"); else if (plain.at(i) == QLatin1Char('"')) rich += QLatin1String("""); else @@ -2057,7 +2040,7 @@ void QTextHtmlExporter::emitAttribute(const char *attribute, const QString &valu html += QLatin1Char(' '); html += QLatin1String(attribute); html += QLatin1String("=\""); - html += escapeXml(value); + html += Qt::escape(value); html += QLatin1Char('"'); } @@ -2326,7 +2309,7 @@ void QTextHtmlExporter::emitFontFamily(const QString &family) quote = QLatin1String("""); html += quote; - html += escapeXml(family); + html += Qt::escape(family); html += quote; html += QLatin1Char(';'); } @@ -2360,13 +2343,13 @@ void QTextHtmlExporter::emitFragment(const QTextFragment &fragment) const QString name = format.anchorName(); if (!name.isEmpty()) { html += QLatin1String(""); } const QString href = format.anchorHref(); if (!href.isEmpty()) { html += QLatin1String(""); closeAnchor = true; } diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp index 452b683..5237438 100644 --- a/tests/auto/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp @@ -176,6 +176,8 @@ private slots: void testUndoBlocks(); void receiveCursorPositionChangedAfterContentsChange(); + void escape_data(); + void escape(); private: void backgroundImage_checkExpectedHtml(const QTextDocument &doc); @@ -577,7 +579,7 @@ void tst_QTextDocument::task240325() } void tst_QTextDocument::stylesheetFont_data() -{ +{ QTest::addColumn("stylesheet"); QTest::addColumn("font"); @@ -1566,7 +1568,7 @@ void tst_QTextDocument::toHtml() QString output = doc->toHtml(); QCOMPARE(output, expectedOutput); - + QDomDocument document; QVERIFY2(document.setContent(output), "Output was not valid XML"); } @@ -2680,5 +2682,25 @@ void tst_QTextDocument::receiveCursorPositionChangedAfterContentsChange() QCOMPARE(rec.first, QString("contentsChanged")); } +void tst_QTextDocument::escape_data() +{ + QTest::addColumn("original"); + QTest::addColumn("expected"); + + QTest::newRow("1") << "Hello World\n" << "Hello World\n"; + QTest::newRow("2") << "#include " << "#include <QtCore>"; + QTest::newRow("3") << "

plop -->

" + << "<p class="cool"><a href="http://example.com/?foo=bar&amp;bar=foo">plop --&gt; </a></p>"; + QTest::newRow("4") << QString::fromUtf8("<\320\222\321\201>") << QString::fromUtf8("<\320\222\321\201>"); +} + +void tst_QTextDocument::escape() +{ + QFETCH(QString, original); + QFETCH(QString, expected); + + QCOMPARE(Qt::escape(original), expected); +} + QTEST_MAIN(tst_QTextDocument) #include "tst_qtextdocument.moc" -- cgit v0.12 From a925ba1ab6316a155f2ac61f898c52f07a1340b4 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 28 Oct 2009 09:58:18 +0100 Subject: QSplitter would not show previously collapsed widgets. After deleting or hiding the last non collapsed item in a QSplitter, none would be visible. We now check wether there is any non-hidden, collapsed widget, and set it to non-collapsed. Auto-test included. Task-number: QTBUG-4101 Reviewed-by: Olivier --- src/gui/widgets/qsplitter.cpp | 17 +++++++++++++++-- tests/auto/qsplitter/tst_qsplitter.cpp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qsplitter.cpp b/src/gui/widgets/qsplitter.cpp index e3121ae..520a802 100644 --- a/src/gui/widgets/qsplitter.cpp +++ b/src/gui/widgets/qsplitter.cpp @@ -360,13 +360,26 @@ void QSplitterPrivate::recalc(bool update) before a hidden widget must be hidden. */ bool first = true; + bool allInvisible = n != 0; for (int i = 0; i < n ; ++i) { QSplitterLayoutStruct *s = list.at(i); - s->handle->setHidden(first || s->widget->isHidden()); - if (!s->widget->isHidden()) + bool widgetHidden = s->widget->isHidden(); + if (allInvisible && !widgetHidden && !s->collapsed) + allInvisible = false; + s->handle->setHidden(first || widgetHidden); + if (!widgetHidden) first = false; } + if (allInvisible) + for (int i = 0; i < n ; ++i) { + QSplitterLayoutStruct *s = list.at(i); + if (!s->widget->isHidden()) { + s->collapsed = false; + break; + } + } + int fi = 2 * q->frameWidth(); int maxl = fi; int minl = fi; diff --git a/tests/auto/qsplitter/tst_qsplitter.cpp b/tests/auto/qsplitter/tst_qsplitter.cpp index cf16421..b832f3a 100644 --- a/tests/auto/qsplitter/tst_qsplitter.cpp +++ b/tests/auto/qsplitter/tst_qsplitter.cpp @@ -102,6 +102,8 @@ private slots: void task187373_addAbstractScrollAreas(); void task187373_addAbstractScrollAreas_data(); void task169702_sizes(); + void taskQTBUG_4101_ensureOneNonCollapsedWidget_data(); + void taskQTBUG_4101_ensureOneNonCollapsedWidget(); private: void removeThirdWidget(); @@ -1281,6 +1283,8 @@ class MyFriendlySplitter : public QSplitter public: MyFriendlySplitter(QWidget *parent = 0) : QSplitter(parent) {} void setRubberBand(int pos) { QSplitter::setRubberBand(pos); } + + friend class tst_QSplitter; }; void tst_QSplitter::rubberBandNotInSplitter() @@ -1403,5 +1407,35 @@ void tst_QSplitter::task169702_sizes() QCOMPARE(testW->size().height(), testW->minimumSizeHint().height()); } +void tst_QSplitter::taskQTBUG_4101_ensureOneNonCollapsedWidget_data() +{ + QTest::addColumn("testingHide"); + + QTest::newRow("last non collapsed hidden") << true; + QTest::newRow("last non collapsed deleted") << false; +} + +void tst_QSplitter::taskQTBUG_4101_ensureOneNonCollapsedWidget() +{ + QFETCH(bool, testingHide); + + MyFriendlySplitter s; + QLabel *l; + for (int i = 0; i < 5; ++i) { + l = new QLabel(QString("Label ") + QChar('A' + i)); + l->setAlignment(Qt::AlignCenter); + s.addWidget(l); + s.moveSplitter(0, i); // Collapse all the labels except the last one. + } + + s.show(); + if (testingHide) + l->hide(); + else + delete l; + QTest::qWait(100); + QVERIFY(s.sizes().at(0) > 0); +} + QTEST_MAIN(tst_QSplitter) #include "tst_qsplitter.moc" -- cgit v0.12 From 44f8fac4e2fc4a4258b921ac595c2826ca96e99c Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 28 Oct 2009 11:31:33 +0100 Subject: Double-clicking a dock widget titlebar could make it disappear If it wasn't already docked on a mainwindow, its state would become unexpected. Task-number: QTBUG-945 Reviewed-by: gabi --- src/gui/widgets/qdockwidget.cpp | 10 ++++++---- tests/auto/qdockwidget/tst_qdockwidget.cpp | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp index 6710275..a8e2a37 100644 --- a/src/gui/widgets/qdockwidget.cpp +++ b/src/gui/widgets/qdockwidget.cpp @@ -685,8 +685,6 @@ void QDockWidgetPrivate::_q_toggleTopLevel() void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca) { - Q_Q(QDockWidget); - if (state != 0) return; @@ -694,8 +692,6 @@ void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca) Q_ASSERT(win != 0); QMainWindowLayout *layout = qobject_cast(win->layout()); Q_ASSERT(layout != 0); - if (layout->layoutState.indexOf(q).isEmpty()) //The dock widget has not been added into the main window - return; if (layout->pluggingWidget != 0) // the main window is animating a docking operation return; @@ -1012,6 +1008,12 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect { Q_Q(QDockWidget); + if (!floating && parent) { + QMainWindowLayout *mwlayout = qobject_cast(q->parentWidget()->layout()); + if (!mwlayout || mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea) + return; // this dockwidget can't be redocked + } + bool wasFloating = q->isFloating(); bool hidden = q->isHidden(); diff --git a/tests/auto/qdockwidget/tst_qdockwidget.cpp b/tests/auto/qdockwidget/tst_qdockwidget.cpp index dc67f36..e62ba8c 100644 --- a/tests/auto/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/qdockwidget/tst_qdockwidget.cpp @@ -86,6 +86,7 @@ private slots: void visibilityChanged(); void dockLocationChanged(); void setTitleBarWidget(); + void titleBarDoubleClick(); // task specific tests: void task165177_deleteFocusWidget(); void task169808_setFloating(); @@ -694,6 +695,24 @@ void tst_QDockWidget::setTitleBarWidget() QCOMPARE(w2.isVisible(), false); } +void tst_QDockWidget::titleBarDoubleClick() +{ + QMainWindow win; + QDockWidget dock(&win); + win.show(); + dock.setFloating(true); + + QEvent e(QEvent::NonClientAreaMouseButtonDblClick); + QApplication::sendEvent(&dock, &e); + QVERIFY(dock.isFloating()); + QCOMPARE(win.dockWidgetArea(&dock), Qt::NoDockWidgetArea); + + win.addDockWidget(Qt::TopDockWidgetArea, &dock); + dock.setFloating(true); + QApplication::sendEvent(&dock, &e); + QVERIFY(!dock.isFloating()); + QCOMPARE(win.dockWidgetArea(&dock), Qt::TopDockWidgetArea); +} void tst_QDockWidget::task165177_deleteFocusWidget() { -- cgit v0.12 From cc34b794439b59e3e226e2a8dc896fec5e27689d Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Wed, 28 Oct 2009 11:25:31 +0100 Subject: Fix initial focus bug in ItemIsFocusScope. The task provides an example that doesn't gain input focus when started. The fix contains two parts: one is to allow items with focus scope ancestors to become focus items even if the scope is inactive. The other is to fix up the focusItem pointers on reparent. Before, the focus scopes' focusItem pointers always pointed to itself, or the next scope. Now these items are treated no differently than other items in that respect. The change has a performance impact when reparenting a large subtree that has a sub focus item onto another item (one more dig). Task-number: QT-2331 Reviewed-by: Alexis Menard --- src/gui/graphicsview/qgraphicsitem.cpp | 39 +++++++++--- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 87 +++++++++++++++++++++++--- 2 files changed, 112 insertions(+), 14 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 0107fba..ef43d5c 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1039,13 +1039,31 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) } // Update focus scope item ptr in new scope. - if (newParent) { + QGraphicsItem *newFocusScopeItem = subFocusItem ? subFocusItem : parentFocusScopeItem; + if (newFocusScopeItem && newParent) { + if (subFocusItem) { + // Find the subFocusItem's topmost focus scope. + QGraphicsItem *ancestorScope = 0; + QGraphicsItem *p = subFocusItem->d_ptr->parent; + while (p) { + if (p->flags() & QGraphicsItem::ItemIsFocusScope) + ancestorScope = p; + if (p->isPanel()) + break; + p = p->parentItem(); + } + if (ancestorScope) + newFocusScopeItem = ancestorScope; + } + QGraphicsItem *p = newParent; while (p) { if (p->flags() & QGraphicsItem::ItemIsFocusScope) { - p->d_ptr->focusScopeItem = subFocusItem ? subFocusItem : parentFocusScopeItem; - // ### The below line might not make sense... - if (subFocusItem) + p->d_ptr->focusScopeItem = newFocusScopeItem; + // Ensure the new item is no longer the subFocusItem. The + // only way to set focus on a child of a focus scope is + // by setting focus on the scope itself. + if (subFocusItem && !p->focusItem()) subFocusItem->d_ptr->clearSubFocus(); break; } @@ -2983,8 +3001,11 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim while (p) { if (p->flags() & QGraphicsItem::ItemIsFocusScope) { p->d_ptr->focusScopeItem = q_ptr; - if (!q_ptr->isActive() || !p->focusItem()) + if (!p->focusItem()) { + // If you call setFocus on a child of a focus scope that + // doesn't currently have a focus item, then stop. return; + } break; } p = p->d_ptr->parent; @@ -10751,8 +10772,12 @@ QDebug operator<<(QDebug debug, QGraphicsItem *item) return debug; } - debug << "QGraphicsItem(this =" << ((void*)item) - << ", parent =" << ((void*)item->parentItem()) + if (QGraphicsObject *o = item->toGraphicsObject()) + debug << o->metaObject()->className(); + else + debug << "QGraphicsItem"; + debug << "(this =" << (void*)item + << ", parent =" << (void*)item->parentItem() << ", pos =" << item->pos() << ", z =" << item->zValue() << ", flags = " << item->flags() << ")"; diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index dabf64c..2c948cc 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -391,6 +391,7 @@ private slots: void moveWhileDeleting(); void ensureDirtySceneTransform(); void focusScope(); + void focusScope2(); void stackBefore(); void sceneModality(); void panelModality(); @@ -8465,7 +8466,7 @@ void tst_QGraphicsItem::focusScope() QVERIFY(!scope2->focusScopeItem()); scope3->setParentItem(scope2); QCOMPARE(scope2->focusScopeItem(), (QGraphicsItem *)scope3); - QCOMPARE(scope2->focusItem(), (QGraphicsItem *)scope2); + QCOMPARE(scope2->focusItem(), (QGraphicsItem *)scope3); QGraphicsRectItem *scope1 = new QGraphicsRectItem; scope1->setData(0, "scope1"); @@ -8474,9 +8475,9 @@ void tst_QGraphicsItem::focusScope() QVERIFY(!scope1->focusScopeItem()); scope2->setParentItem(scope1); - QCOMPARE(scope1->focusItem(), (QGraphicsItem *)scope1); - QCOMPARE(scope2->focusItem(), (QGraphicsItem *)0); - QCOMPARE(scope3->focusItem(), (QGraphicsItem *)0); + QCOMPARE(scope1->focusItem(), (QGraphicsItem *)scope3); + QCOMPARE(scope2->focusItem(), (QGraphicsItem *)scope3); + QCOMPARE(scope3->focusItem(), (QGraphicsItem *)scope3); QCOMPARE(scope1->focusScopeItem(), (QGraphicsItem *)scope2); QCOMPARE(scope2->focusScopeItem(), (QGraphicsItem *)scope3); QCOMPARE(scope3->focusScopeItem(), (QGraphicsItem *)0); @@ -8527,11 +8528,13 @@ void tst_QGraphicsItem::focusScope() rect5->setFocus(); rect5->setParentItem(rect4); QCOMPARE(scope3->focusScopeItem(), (QGraphicsItem *)rect5); - QVERIFY(!rect5->hasFocus()); + QVERIFY(rect5->hasFocus()); rect4->setParentItem(0); + QVERIFY(rect5->hasFocus()); QCOMPARE(scope3->focusScopeItem(), (QGraphicsItem *)0); - QVERIFY(scope3->hasFocus()); + QCOMPARE(scope3->focusItem(), (QGraphicsItem *)0); + QVERIFY(!scope3->hasFocus()); QGraphicsRectItem *rectA = new QGraphicsRectItem; QGraphicsRectItem *scopeA = new QGraphicsRectItem(rectA); @@ -8542,7 +8545,7 @@ void tst_QGraphicsItem::focusScope() scopeB->setFocus(); scene.addItem(rectA); - QVERIFY(!rect5->hasFocus()); + QVERIFY(rect5->hasFocus()); QVERIFY(!scopeB->hasFocus()); scopeA->setFocus(); @@ -8550,6 +8553,76 @@ void tst_QGraphicsItem::focusScope() QCOMPARE(scopeB->focusItem(), (QGraphicsItem *)scopeB); } +void tst_QGraphicsItem::focusScope2() +{ + QGraphicsRectItem *child1 = new QGraphicsRectItem; + child1->setFlags(QGraphicsItem::ItemIsFocusable); + child1->setFocus(); + QCOMPARE(child1->focusItem(), (QGraphicsItem *)child1); + + QGraphicsRectItem *child2 = new QGraphicsRectItem; + child2->setFlags(QGraphicsItem::ItemIsFocusable); + + QGraphicsRectItem *rootFocusScope = new QGraphicsRectItem; + rootFocusScope->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsFocusScope); + rootFocusScope->setFocus(); + QCOMPARE(rootFocusScope->focusItem(), (QGraphicsItem *)rootFocusScope); + + child1->setParentItem(rootFocusScope); + child2->setParentItem(rootFocusScope); + + QCOMPARE(rootFocusScope->focusScopeItem(), (QGraphicsItem *)child1); + QCOMPARE(rootFocusScope->focusItem(), (QGraphicsItem *)child1); + + QGraphicsRectItem *siblingChild1 = new QGraphicsRectItem; + siblingChild1->setFlags(QGraphicsItem::ItemIsFocusable); + siblingChild1->setFocus(); + + QGraphicsRectItem *siblingChild2 = new QGraphicsRectItem; + siblingChild2->setFlags(QGraphicsItem::ItemIsFocusable); + + QGraphicsRectItem *siblingFocusScope = new QGraphicsRectItem; + siblingFocusScope->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsFocusScope); + + siblingChild1->setParentItem(siblingFocusScope); + siblingChild2->setParentItem(siblingFocusScope); + + QCOMPARE(siblingFocusScope->focusScopeItem(), (QGraphicsItem *)siblingChild1); + QCOMPARE(siblingFocusScope->focusItem(), (QGraphicsItem *)0); + + QGraphicsItem *root = new QGraphicsRectItem; + rootFocusScope->setParentItem(root); + siblingFocusScope->setParentItem(root); + + QCOMPARE(root->focusItem(), (QGraphicsItem *)child1); + + QGraphicsScene scene; + scene.addItem(root); + + QEvent activate(QEvent::WindowActivate); + qApp->sendEvent(&scene, &activate); + scene.setFocus(); + + QCOMPARE(scene.focusItem(), (QGraphicsItem *)child1); + + // You cannot set focus on a descendant of a focus scope directly; + // this will only change the scope's focus scope item pointer. If + // you want to give true input focus, you must set it directly on + // the scope itself + siblingChild2->setFocus(); + QVERIFY(!siblingChild2->hasFocus()); + QVERIFY(!siblingChild2->focusItem()); + QCOMPARE(siblingFocusScope->focusScopeItem(), (QGraphicsItem *)siblingChild2); + QCOMPARE(siblingFocusScope->focusItem(), (QGraphicsItem *)0); + + // Set focus on the scope; focus is forwarded to the focus scope item. + siblingFocusScope->setFocus(); + QVERIFY(siblingChild2->hasFocus()); + QVERIFY(siblingChild2->focusItem()); + QCOMPARE(siblingFocusScope->focusScopeItem(), (QGraphicsItem *)siblingChild2); + QCOMPARE(siblingFocusScope->focusItem(), (QGraphicsItem *)siblingChild2); +} + void tst_QGraphicsItem::stackBefore() { QGraphicsRectItem parent; -- cgit v0.12 From 51a644360cdf9ef4d936700f02da6cc380ae1f9d Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 28 Oct 2009 11:43:40 +0100 Subject: Make the QPropertyAnimation pass on windows by waiting slightly longer Timers on windows are not accurate enough to "only" wait for the animation duration + 50. --- tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index 7dd17e5..92bed7d 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -495,7 +495,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() anim->setEndValue(100); QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); anim->start(QVariantAnimation::DeleteWhenStopped); - QTest::qWait(anim->duration() + 50); + QTest::qWait(anim->duration() + 100); QCOMPARE(runningSpy.count(), 2); //started and then stopped QVERIFY(!anim); } @@ -659,7 +659,7 @@ void tst_QPropertyAnimation::playForwardBackward() anim.setStartValue(0); anim.setEndValue(100); anim.start(); - QTest::qWait(anim.duration() + 50); + QTest::qWait(anim.duration() + 100); QCOMPARE(anim.state(), QAbstractAnimation::Stopped); QCOMPARE(anim.currentTime(), anim.duration()); @@ -667,7 +667,7 @@ void tst_QPropertyAnimation::playForwardBackward() anim.setDirection(QVariantAnimation::Backward); anim.start(); QCOMPARE(anim.state(), QAbstractAnimation::Running); - QTest::qWait(anim.duration() + 50); + QTest::qWait(anim.duration() + 100); QCOMPARE(anim.state(), QAbstractAnimation::Stopped); QCOMPARE(anim.currentTime(), 0); @@ -676,7 +676,7 @@ void tst_QPropertyAnimation::playForwardBackward() anim.start(); QCOMPARE(anim.state(), QAbstractAnimation::Running); QCOMPARE(anim.currentTime(), anim.duration()); - QTest::qWait(anim.duration() + 50); + QTest::qWait(anim.duration() + 100); QCOMPARE(anim.state(), QAbstractAnimation::Stopped); QCOMPARE(anim.currentTime(), 0); } -- cgit v0.12 From 8cf53009aa8012c1d911eb3ccac5c5345da712e7 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 28 Oct 2009 11:46:35 +0100 Subject: Changing the time we wait for the end of the animation We now wait for the animation duration + 100 (instead of 50). It makes tests more reliable on windows (and probably embedded) --- tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index 92bed7d..56c1ced 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -1093,7 +1093,7 @@ void tst_QPropertyAnimation::valueChanged() QSignalSpy spy(&anim, SIGNAL(valueChanged(QVariant))); anim.start(); - QTest::qWait(anim.duration() + 50); + QTest::qWait(anim.duration() + 100); QCOMPARE(anim.state(), QAbstractAnimation::Stopped); QCOMPARE(anim.currentTime(), anim.duration()); @@ -1144,7 +1144,7 @@ void tst_QPropertyAnimation::twoAnimations() o1.anim.start(); o2.anim.start(); - QTest::qWait(o1.anim.duration() + 50); + QTest::qWait(o1.anim.duration() + 100); QCOMPARE(o1.anim.state(), QAbstractAnimation::Stopped); QCOMPARE(o2.anim.state(), QAbstractAnimation::Stopped); @@ -1194,7 +1194,7 @@ void tst_QPropertyAnimation::deletedInUpdateCurrentTime() MyComposedAnimation composedAnimation(&o, "value", "realValue"); composedAnimation.start(); QCOMPARE(composedAnimation.state(), QAbstractAnimation::Running); - QTest::qWait(composedAnimation.duration() + 50); + QTest::qWait(composedAnimation.duration() + 100); QCOMPARE(composedAnimation.state(), QAbstractAnimation::Stopped); QCOMPARE(o.value(), 1000); -- cgit v0.12 From 0b637c89e785cf4151fbda91eda905032d4baf1e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 28 Oct 2009 13:17:17 +0100 Subject: Allow to put the central widget in a QMainWindow after it was shown Task-number: QTBUG-1171 --- src/gui/widgets/qdockarealayout.cpp | 14 ++++++++------ src/gui/widgets/qdockarealayout_p.h | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index 5a0a9d4..df131ee 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -2259,7 +2259,7 @@ QRect QDockAreaLayoutInfo::tabContentRect() const ** QDockAreaLayout */ -QDockAreaLayout::QDockAreaLayout(QMainWindow *win) +QDockAreaLayout::QDockAreaLayout(QMainWindow *win) : have_central(false) { mainWindow = win; sep = win->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, win); @@ -2582,7 +2582,9 @@ void QDockAreaLayout::getGrid(QVector *_ver_struct_list, { QSize center_hint(0, 0); QSize center_min(0, 0); - bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty(); + const bool old_have_central = have_central; + have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty(); + const bool fallbackToSizeHints = !old_have_central && have_central; if (have_central) { center_hint = centralWidgetRect.size(); if (!center_hint.isValid()) @@ -2601,28 +2603,28 @@ void QDockAreaLayout::getGrid(QVector *_ver_struct_list, center_rect.setBottom(rect.bottom() - docks[QInternal::BottomDock].rect.height() - sep); QSize left_hint = docks[QInternal::LeftDock].size(); - if (left_hint.isNull()) + if (left_hint.isNull() || fallbackToSizeHints) left_hint = docks[QInternal::LeftDock].sizeHint(); QSize left_min = docks[QInternal::LeftDock].minimumSize(); QSize left_max = docks[QInternal::LeftDock].maximumSize(); left_hint = left_hint.boundedTo(left_max).expandedTo(left_min); QSize right_hint = docks[QInternal::RightDock].size(); - if (right_hint.isNull()) + if (right_hint.isNull() || fallbackToSizeHints) right_hint = docks[QInternal::RightDock].sizeHint(); QSize right_min = docks[QInternal::RightDock].minimumSize(); QSize right_max = docks[QInternal::RightDock].maximumSize(); right_hint = right_hint.boundedTo(right_max).expandedTo(right_min); QSize top_hint = docks[QInternal::TopDock].size(); - if (top_hint.isNull()) + if (top_hint.isNull() || fallbackToSizeHints) top_hint = docks[QInternal::TopDock].sizeHint(); QSize top_min = docks[QInternal::TopDock].minimumSize(); QSize top_max = docks[QInternal::TopDock].maximumSize(); top_hint = top_hint.boundedTo(top_max).expandedTo(top_min); QSize bottom_hint = docks[QInternal::BottomDock].size(); - if (bottom_hint.isNull()) + if (bottom_hint.isNull() || fallbackToSizeHints) bottom_hint = docks[QInternal::BottomDock].sizeHint(); QSize bottom_min = docks[QInternal::BottomDock].minimumSize(); QSize bottom_max = docks[QInternal::BottomDock].maximumSize(); diff --git a/src/gui/widgets/qdockarealayout_p.h b/src/gui/widgets/qdockarealayout_p.h index 99a9dbb..1ed14ce 100644 --- a/src/gui/widgets/qdockarealayout_p.h +++ b/src/gui/widgets/qdockarealayout_p.h @@ -233,6 +233,7 @@ public: QDockAreaLayout(QMainWindow *win); QDockAreaLayoutInfo docks[4]; int sep; // separator extent + bool have_central; mutable QVector separatorWidgets; bool isValid() const; -- cgit v0.12 From 9862d354c0e2135df848dd02417f958b1d7e16f5 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 28 Oct 2009 13:33:16 +0100 Subject: Compile on 64bit Reviewed-by: Jan-Arve --- src/gui/graphicsview/qsimplex_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/graphicsview/qsimplex_p.h b/src/gui/graphicsview/qsimplex_p.h index 66ea739..084ad7f 100644 --- a/src/gui/graphicsview/qsimplex_p.h +++ b/src/gui/graphicsview/qsimplex_p.h @@ -123,11 +123,11 @@ struct QSimplexConstraint #ifdef QT_DEBUG QString toString() { QString result; - result += QString::fromAscii("-- QSimplexConstraint %1 --").arg(int(this), 0, 16); + result += QString::fromAscii("-- QSimplexConstraint %1 --").arg(quintptr(this), 0, 16); QHash::const_iterator iter; for (iter = variables.constBegin(); iter != variables.constEnd(); ++iter) { - result += QString::fromAscii(" %1 x %2").arg(iter.value()).arg(int(iter.key()), 0, 16); + result += QString::fromAscii(" %1 x %2").arg(iter.value()).arg(quintptr(iter.key()), 0, 16); } switch (ratio) { -- cgit v0.12 From f62e0f8323304b2afbf2e3b918d611ea1d0f6856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 28 Oct 2009 13:30:28 +0100 Subject: Stabilize tst_QGraphicsView::optimizationFlags_dontSavePainterState2 Make sure the view is painted, otherwise the transforms are identity and comparisons don't make sense. --- tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 092f81d..89628d8 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -2486,7 +2486,7 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState2() scene.addRect(0, 0, 20, 20)->setTransform(QTransform::fromScale(2, 2)); scene.addRect(50, 50, 20, 20)->setTransform(QTransform::fromTranslate(200, 200)); - QGraphicsView view(&scene); + CustomView view(&scene); if (!savePainter) view.setOptimizationFlag(QGraphicsView::DontSavePainterState); view.rotate(45); @@ -2495,7 +2495,11 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState2() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(150); + + // Make sure the view is repainted; otherwise the tests below will fail. + view.viewport()->repaint(); + QTest::qWait(200); + QVERIFY(view.painted); // Make sure the painter's world transform is preserved after drawItems. const QTransform expectedTransform = view.viewportTransform(); -- cgit v0.12 From 992f5cef19ce9e313dd06279c47d7535c6dbc857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 28 Oct 2009 12:39:33 +0100 Subject: Wrong caching of opaque children in QWidget. The opaque children cache was clipped to all the ancestors up to the top-level, which means whenever a widget changes geometry all the children must be invalidated. However, the bug was that we didn't invalidate the children, and that is of course slow so we don't want to do it either. A better solution is to only clip the children cache to the widget itself (widget->rect() instead of widget->clipRect()), and we can perfectly do this because the region we subtract the opaque children from is already inside the clipRect(). Auto-test included. Task-number: QTBUG-4245 (related to) --- src/gui/kernel/qwidget.cpp | 22 ++++++++------------ src/gui/kernel/qwidget_p.h | 1 - tests/auto/qwidget/tst_qwidget.cpp | 42 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 14 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 5fa9a92..1951ab2 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1825,18 +1825,6 @@ void QWidgetPrivate::setDirtyOpaqueRegion() pd->setDirtyOpaqueRegion(); } -QRegion QWidgetPrivate::getOpaqueRegion() const -{ - Q_Q(const QWidget); - - QRegion r = isOpaque ? q->rect() : getOpaqueChildren(); - if (extra && extra->hasMask) - r &= extra->mask; - if (r.isEmpty()) - return r; - return r & clipRect(); -} - const QRegion &QWidgetPrivate::getOpaqueChildren() const { if (!dirtyOpaqueChildren) @@ -1851,9 +1839,17 @@ const QRegion &QWidgetPrivate::getOpaqueChildren() const continue; const QPoint offset = child->geometry().topLeft(); - that->opaqueChildren += child->d_func()->getOpaqueRegion().translated(offset); + QWidgetPrivate *childd = child->d_func(); + QRegion r = childd->isOpaque ? child->rect() : childd->getOpaqueChildren(); + if (childd->extra && childd->extra->hasMask) + r &= childd->extra->mask; + if (r.isEmpty()) + continue; + r.translate(offset); + that->opaqueChildren += r; } + that->opaqueChildren &= q_func()->rect(); that->dirtyOpaqueChildren = false; return that->opaqueChildren; diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 159a3f2..5cea641 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -386,7 +386,6 @@ public: bool paintOnScreen() const; void invalidateGraphicsEffectsRecursively(); - QRegion getOpaqueRegion() const; const QRegion &getOpaqueChildren() const; void setDirtyOpaqueRegion(); diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 050d1c5..9c421d1 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -332,6 +332,7 @@ private slots: void doubleRepaint(); #ifndef Q_WS_MAC void resizeInPaintEvent(); + void opaqueChildren(); #endif void setMaskInResizeEvent(); @@ -8272,6 +8273,47 @@ void tst_QWidget::resizeInPaintEvent() // Make sure the resize triggers another update. QTRY_COMPARE(widget.numPaintEvents, 1); } + +void tst_QWidget::opaqueChildren() +{ + QWidget widget; + widget.resize(200, 200); + + QWidget child(&widget); + child.setGeometry(-700, -700, 200, 200); + + QWidget grandChild(&child); + grandChild.resize(200, 200); + + QWidget greatGrandChild(&grandChild); + greatGrandChild.setGeometry(50, 50, 200, 200); + greatGrandChild.setPalette(Qt::red); + greatGrandChild.setAutoFillBackground(true); // Opaque child widget. + + widget.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&widget); +#endif + QTest::qWait(100); + + // Child, grandChild and greatGrandChild are outside the ancestor clip. + QRegion expectedOpaqueRegion(50, 50, 150, 150); + QCOMPARE(qt_widget_private(&grandChild)->getOpaqueChildren(), expectedOpaqueRegion); + + // Now they are all inside the ancestor clip. + child.setGeometry(50, 50, 150, 150); + QCOMPARE(qt_widget_private(&grandChild)->getOpaqueChildren(), expectedOpaqueRegion); + + // Set mask on greatGrandChild. + const QRegion mask(10, 10, 50, 50); + greatGrandChild.setMask(mask); + expectedOpaqueRegion &= mask.translated(50, 50); + QCOMPARE(qt_widget_private(&grandChild)->getOpaqueChildren(), expectedOpaqueRegion); + + // Make greatGrandChild "transparent". + greatGrandChild.setAutoFillBackground(false); + QCOMPARE(qt_widget_private(&grandChild)->getOpaqueChildren(), QRegion()); +} #endif -- cgit v0.12 From 69216ca888373e8ca82dfe75fd940fc2ab824c2c Mon Sep 17 00:00:00 2001 From: Stefano Pironato Date: Wed, 28 Oct 2009 14:48:44 +0200 Subject: Fix bug for message error "Texture updload failed, error code 0x500" The error message come from the QGLContextPrivate::bindTexture. But since OpenGl errors are retains until glGetError is called the actual error was happening somewhere else. After adding in all the gl* call a check for a gl error, I was able to get the place where opengl fail with a GL_INVALID_ENUM. This happen in the call of glEnable(GL_TEXTURE_2D) in the file qgl_x11egl.cpp. This glEnable call does not need: removed. Reviewed-by: Tom Cooksey --- src/opengl/qgl_x11egl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 3894ed1..7180682 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -589,7 +589,6 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData* pd, cons GLuint textureId; glGenTextures(1, &textureId); - glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, textureId); // bind the egl pixmap surface to a texture -- cgit v0.12 From e2584b9e910da18e7e472b5681eb7d0d1630647a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20L=C3=A9tourneau?= Date: Mon, 14 Sep 2009 16:54:13 -0400 Subject: Use qLowerBound in qBinaryFind The current implementation of qBinaryFind use 64bit arithmetics even on a 32bit system, which make it slow The docs mention qBinaryFind will find any occurence of the search value not necessarily the first one, but this is not case with current implementation So nothing prevents the use of qLowerBound Reviewed-by: Olivier Goffart Merge-request: 1513 --- src/corelib/tools/qalgorithms.h | 42 ++++++++++------------------------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h index a68ce27..f70821a 100644 --- a/src/corelib/tools/qalgorithms.h +++ b/src/corelib/tools/qalgorithms.h @@ -295,23 +295,12 @@ template Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value) { // Implementation is duplicated from QAlgorithmsPrivate. - qint64 l = 0; - qint64 r = end - begin - 1; - if (r < 0) - return end; - qint64 i = (l + r + 1) / 2; - - while (r != l) { - if (value < begin[i]) - r = i - 1; - else - l = i; - i = (l + r + 1) / 2; - } - if (begin[i] < value || value < begin[i]) + RandomAccessIterator it = qLowerBound(begin, end, value); + + if (it == end || value < *it) return end; - else - return begin + i; + + return it; } template @@ -520,23 +509,12 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator template Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) { - qint64 l = 0; - qint64 r = end - begin - 1; - if (r < 0) - return end; - qint64 i = (l + r + 1) / 2; - - while (r != l) { - if (lessThan(value, begin[i])) - r = i - 1; - else - l = i; - i = (l + r + 1) / 2; - } - if (lessThan(begin[i], value) || lessThan(value, begin[i])) + RandomAccessIterator it = qLowerBoundHelper(begin, end, value, lessThan); + + if (it == end || lessThan(value, *it)) return end; - else - return begin + i; + + return it; } } //namespace QAlgorithmsPrivate -- cgit v0.12 From b41086b8f68f280f1f683d0f107b26d1c6221883 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 28 Oct 2009 14:20:29 +0100 Subject: Extand test of qBinaryFind --- tests/auto/qalgorithms/tst_qalgorithms.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/auto/qalgorithms/tst_qalgorithms.cpp b/tests/auto/qalgorithms/tst_qalgorithms.cpp index 1f1de82..176a451 100644 --- a/tests/auto/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/qalgorithms/tst_qalgorithms.cpp @@ -602,9 +602,15 @@ void tst_QAlgorithms::test_qUpperBound() void tst_QAlgorithms::test_qBinaryFind_data() { QTest::addColumn >("data"); - QTest::addColumn("resultValue"); + QTest::addColumn("resultValue"); // -42 means not found QTest::newRow("sorted-duplicate") << (QList() << 1 << 2 << 2 << 3) << 2; + QTest::newRow("sorted-end") << (QList() << -5 << -2 << 0 << 8) << 8; + QTest::newRow("sorted-beginning") << (QList() << -5 << -2 << 0 << 8) << -5; + QTest::newRow("sorted-duplicate-beginning") << (QList() << -5 << -5 << -2 << 0 << 8) << -5; + QTest::newRow("empty") << (QList()) << -42; + QTest::newRow("not found 1 ") << (QList() << 1 << 5 << 8 << 65) << -42; + QTest::newRow("not found 2 ") << (QList() << -456 << -5 << 8 << 65) << -42; } void tst_QAlgorithms::test_qBinaryFind() @@ -612,6 +618,15 @@ void tst_QAlgorithms::test_qBinaryFind() QFETCH(QList, data); QFETCH(int, resultValue); + //-42 means not found + if (resultValue == -42) { + QVERIFY(qBinaryFind(data.constBegin(), data.constEnd(), resultValue) == data.end()); + QVERIFY(qBinaryFind(data, resultValue) == data.end()); + QVERIFY(qBinaryFind(data.begin(), data.end(), resultValue) == data.end()); + QVERIFY(qBinaryFind(data.begin(), data.end(), resultValue, qLess()) == data.end()); + return; + } + QCOMPARE(*qBinaryFind(data.constBegin(), data.constEnd(), resultValue), resultValue); QCOMPARE(*qBinaryFind(data.begin(), data.end(), resultValue), resultValue); QCOMPARE(*qBinaryFind(data, resultValue), resultValue); -- cgit v0.12 From 8007617f784fcad76661efbb2ce9ee7393946e02 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 28 Oct 2009 15:32:33 +0200 Subject: Increased block size for file IO in Symbian. Each read requires costly IPC call to Symbian file server, so reading and writing large files has lot of unnecessary overhead when using 4k block size. Increased the block size to 16k, which is what QIODevice will request at maximum. This speeds up reading large files up to 10%. Also included are some unnecessary whitespace removals. Task-number: QT-2347 Reviewed-by: axis --- src/corelib/io/qfsfileengine.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index fb096a7..b69a5e5 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -76,6 +76,16 @@ QT_BEGIN_NAMESPACE # endif #endif +#ifdef Q_OS_SYMBIAN + // Using default 4k block in symbian is highly inefficient due to + // the fact that each file operation requires slow IPC calls, so + // use somewhat larger block size. +# define FDFH_BLOCK_SIZE 16384 +#else + // Read/write in blocks of 4k to avoid platform limitations (Windows + // commonly bails out if you read or write too large blocks at once). +# define FDFH_BLOCK_SIZE 4096 +#endif /*! \class QFSFileEngine \brief The QFSFileEngine class implements Qt's default file engine. @@ -160,11 +170,11 @@ QString QFSFileEnginePrivate::canonicalized(const QString &path) if ( #ifdef Q_OS_SYMBIAN // Symbian doesn't support directory symlinks, so do not check for link unless we - // are handling the last path element. This not only slightly improves performance, + // are handling the last path element. This not only slightly improves performance, // but also saves us from lot of unnecessary platform security check failures // when dealing with files under *:/private directories. separatorPos == -1 && -#endif +#endif !nonSymlinks.contains(prefix)) { fi.setFile(prefix); if (fi.isSymLink()) { @@ -628,14 +638,12 @@ qint64 QFSFileEnginePrivate::readFdFh(char *data, qint64 len) qint64 read = 0; int retry = 0; - // Read in blocks of 4k to avoid platform limitations (Windows - // commonly bails out if you read or write too large blocks at once). qint64 bytesToRead; do { if (retry == 1) retry = 2; - bytesToRead = qMin(4096, len - read); + bytesToRead = qMin(FDFH_BLOCK_SIZE, len - read); do { readBytes = fread(data + read, 1, size_t(bytesToRead), fh); } while (readBytes == 0 && !feof(fh) && errno == EINTR); @@ -666,10 +674,8 @@ qint64 QFSFileEnginePrivate::readFdFh(char *data, qint64 len) qint64 read = 0; errno = 0; - // Read in blocks of 4k to avoid platform limitations (Windows - // commonly bails out if you read or write too large blocks at once). do { - qint64 bytesToRead = qMin(4096, len - read); + qint64 bytesToRead = qMin(FDFH_BLOCK_SIZE, len - read); do { result = QT_READ(fd, data + read, int(bytesToRead)); } while (result == -1 && errno == EINTR); @@ -770,9 +776,7 @@ qint64 QFSFileEnginePrivate::writeFdFh(const char *data, qint64 len) qint64 written = 0; do { - // Write blocks of 4k to avoid platform limitations (Windows commonly - // bails out if you read or write too large blocks at once). - qint64 bytesToWrite = qMin(4096, len - written); + qint64 bytesToWrite = qMin(FDFH_BLOCK_SIZE, len - written); if (fh) { do { // Buffered stdlib mode. @@ -903,7 +907,7 @@ bool QFSFileEngine::supportsExtension(Extension extension) const /*! \fn QString QFSFileEngine::currentPath(const QString &fileName) For Unix, returns the current working directory for the file engine. - + For Windows, returns the canonicalized form of the current path used by the file engine for the drive specified by \a fileName. On Windows, each drive has its own current directory, so a different -- cgit v0.12 From 79da7bb4739f9f63178ce5146702dce6b8feafb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 28 Oct 2009 14:09:04 +0100 Subject: Don't try to mmap past EOF On Mac OS, mmap would succeed, returning a valid pointer, but trying to read from it would result in a SIGBUS. By adding this check we commit to a safe cross-platform behavior users can depend on. Reviewed-by: Thiago Macieira --- src/corelib/io/qfsfileengine_unix.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 6af5674..7824520 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -1250,6 +1250,12 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla return 0; } + // If we know the mapping will extend beyond EOF, fail early to avoid + // undefined behavior. Otherwise, let mmap have its say. + if (doStat() + && (QT_OFF_T(size) > st.st_size - QT_OFF_T(offset))) + return 0; + int access = 0; if (openMode & QIODevice::ReadOnly) access |= PROT_READ; if (openMode & QIODevice::WriteOnly) access |= PROT_WRITE; -- cgit v0.12 From e77732c9b0c8b8313138306d723f5227cfbc124d Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Wed, 28 Oct 2009 11:17:18 -0300 Subject: QGAL: set the orientation bit for complex anchors Sets the orientation bit for complex anchors. This is being done in the constructor, and I did a minor refactor to make the constructor of SequentialAnchor take the list of vertices and anchors that it is simplifying. Before that we set one of those directly in the structure and the other via a setter function. The tests were passing because right now, complex anchors do not use the orientation bit, while some Normal anchors use in the refreshSizeHints() function (to get either the width() or height() of an item). Signed-off-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 6 +++--- src/gui/graphicsview/qgraphicsanchorlayout_p.h | 15 +++++---------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index b4666c6..ac81ddc 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -577,18 +577,18 @@ static AnchorData *createSequence(Graph *graph, qDebug("simplifying [%s] to [%s - %s]", qPrintable(strPath), qPrintable(before->toString()), qPrintable(after->toString())); #endif - SequentialAnchorData *sequence = new SequentialAnchorData; AnchorVertex *prev = before; + QVector edges; for (int i = 0; i <= orderedVertices.count(); ++i) { AnchorVertex *next = (i < orderedVertices.count()) ? orderedVertices.at(i) : after; AnchorData *ad = graph->takeEdge(prev, next); Q_ASSERT(ad); - sequence->m_edges.append(ad); + edges.append(ad); prev = next; } - sequence->setVertices(orderedVertices); + SequentialAnchorData *sequence = new SequentialAnchorData(orderedVertices, edges); sequence->from = before; sequence->to = after; diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index 8eb65c5..600b06c 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -223,11 +223,13 @@ inline QString AnchorData::toString() const struct SequentialAnchorData : public AnchorData { - SequentialAnchorData() : AnchorData() + SequentialAnchorData(const QVector &vertices, const QVector &edges) + : AnchorData(), m_children(vertices), m_edges(edges) { type = AnchorData::Sequential; + orientation = m_edges.at(0)->orientation; #ifdef QT_DEBUG - name = QLatin1String("SequentialAnchorData"); + name = QString::fromAscii("%1 -- %2").arg(vertices.first()->toString(), vertices.last()->toString()); #endif } @@ -236,14 +238,6 @@ struct SequentialAnchorData : public AnchorData bool refreshSizeHints_helper(qreal effectiveSpacing, bool refreshChildren = true); - void setVertices(const QVector &vertices) - { - m_children = vertices; -#ifdef QT_DEBUG - name = QString::fromAscii("%1 -- %2").arg(vertices.first()->toString(), vertices.last()->toString()); -#endif - } - QVector m_children; // list of vertices in the sequence QVector m_edges; // keep the list of edges too. }; @@ -254,6 +248,7 @@ struct ParallelAnchorData : public AnchorData : AnchorData(), firstEdge(first), secondEdge(second) { type = AnchorData::Parallel; + orientation = first->orientation; // ### Those asserts force that both child anchors have the same direction, // but can't we simplify a pair of anchors in opposite directions? -- cgit v0.12 From 0283ca4cf2ad1c9e642b24f8376aa7179fa54599 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 22 Oct 2009 20:59:07 +0200 Subject: Add some STL compatibility for QContiguousCache and private inheritance The private inheritance ensures that we don't try to access the types under the wrong pointer. If we did that, we'd cause strict aliasing violations. Reviewed-by: Olivier Goffart --- src/corelib/tools/qcontiguouscache.h | 125 ++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 60 deletions(-) diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index ad78d1f..862df61 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -62,6 +62,12 @@ struct Q_CORE_EXPORT QContiguousCacheData int start; int offset; uint sharable : 1; + // uint unused : 31; + + // total is 24 bytes (HP-UX aCC: 40 bytes) + // the next entry is already aligned to 8 bytes + // there will be an 8 byte gap here if T requires 16-byte alignment + // (such as long double on 64-bit platforms, __int128, __float128) #ifdef QT_QCONTIGUOUSCACHE_DEBUG void dump() const; @@ -69,33 +75,32 @@ struct Q_CORE_EXPORT QContiguousCacheData }; template -struct QContiguousCacheTypedData +struct QContiguousCacheTypedData: private QContiguousCacheData { - QBasicAtomicInt ref; - int alloc; - int count; - int start; - int offset; - uint sharable : 1; - // uint unused : 31; - - // total is 24 bytes (HP-UX aCC: 40 bytes) - // the next entry is already aligned to 8 bytes - // there will be an 8 byte gap here if T requires 16-byte alignment - // (such as long double on 64-bit platforms, __int128, __float128) - + // private inheritance to avoid aliasing warningss T array[1]; + + static inline void free(QContiguousCacheTypedData *data) { QContiguousCacheData::free(data); } }; template class QContiguousCache { typedef QContiguousCacheTypedData Data; - union { QContiguousCacheData *p; QContiguousCacheTypedData *d; }; + union { QContiguousCacheData *d; QContiguousCacheTypedData *p; }; public: + // STL compatibility + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef ptrdiff_t difference_type; + typedef int size_type; + explicit QContiguousCache(int capacity = 0); QContiguousCache(const QContiguousCache &v) : d(v.d) { d->ref.ref(); if (!d->sharable) detach_helper(); } - inline ~QContiguousCache() { if (!d) return; if (!d->ref.deref()) free(d); } + inline ~QContiguousCache() { if (!d) return; if (!d->ref.deref()) free(p); } inline void detach() { if (d->ref != 1) detach_helper(); } inline bool isDetached() const { return d->ref == 1; } @@ -128,10 +133,10 @@ public: inline int firstIndex() const { return d->offset; } inline int lastIndex() const { return d->offset + d->count - 1; } - inline const T &first() const { Q_ASSERT(!isEmpty()); return d->array[d->start]; } - inline const T &last() const { Q_ASSERT(!isEmpty()); return d->array[(d->start + d->count -1) % d->alloc]; } - inline T &first() { Q_ASSERT(!isEmpty()); detach(); return d->array[d->start]; } - inline T &last() { Q_ASSERT(!isEmpty()); detach(); return d->array[(d->start + d->count -1) % d->alloc]; } + inline const T &first() const { Q_ASSERT(!isEmpty()); return p->array[d->start]; } + inline const T &last() const { Q_ASSERT(!isEmpty()); return p->array[(d->start + d->count -1) % d->alloc]; } + inline T &first() { Q_ASSERT(!isEmpty()); detach(); return p->array[d->start]; } + inline T &last() { Q_ASSERT(!isEmpty()); detach(); return p->array[(d->start + d->count -1) % d->alloc]; } void removeFirst(); T takeFirst(); @@ -161,9 +166,9 @@ private: template void QContiguousCache::detach_helper() { - union { QContiguousCacheData *p; QContiguousCacheTypedData *d; } x; + union { QContiguousCacheData *d; QContiguousCacheTypedData *p; } x; - x.p = malloc(d->alloc); + x.d = malloc(d->alloc); x.d->ref = 1; x.d->count = d->count; x.d->start = d->start; @@ -171,8 +176,8 @@ void QContiguousCache::detach_helper() x.d->alloc = d->alloc; x.d->sharable = true; - T *dest = x.d->array + x.d->start; - T *src = d->array + d->start; + T *dest = x.p->array + x.d->start; + T *src = p->array + d->start; int oldcount = x.d->count; while (oldcount--) { if (QTypeInfo::isComplex) { @@ -181,15 +186,15 @@ void QContiguousCache::detach_helper() *dest = *src; } dest++; - if (dest == x.d->array + x.d->alloc) - dest = x.d->array; + if (dest == x.p->array + x.d->alloc) + dest = x.p->array; src++; - if (src == d->array + d->alloc) - src = d->array; + if (src == p->array + d->alloc) + src = p->array; } if (!d->ref.deref()) - free(d); + free(p); d = x.d; } @@ -205,8 +210,8 @@ void QContiguousCache::setCapacity(int asize) x.d->count = qMin(d->count, asize); x.d->offset = d->offset + d->count - x.d->count; x.d->start = x.d->offset % x.d->alloc; - T *dest = x.d->array + (x.d->start + x.d->count-1) % x.d->alloc; - T *src = d->array + (d->start + d->count-1) % d->alloc; + T *dest = x.p->array + (x.d->start + x.d->count-1) % x.d->alloc; + T *src = p->array + (d->start + d->count-1) % d->alloc; int oldcount = x.d->count; while (oldcount--) { if (QTypeInfo::isComplex) { @@ -214,11 +219,11 @@ void QContiguousCache::setCapacity(int asize) } else { *dest = *src; } - if (dest == x.d->array) - dest = x.d->array + x.d->alloc; + if (dest == x.p->array) + dest = x.p->array + x.d->alloc; dest--; - if (src == d->array) - src = d->array + d->alloc; + if (src == p->array) + src = p->array + d->alloc; src--; } /* free old */ @@ -232,24 +237,24 @@ void QContiguousCache::clear() if (d->ref == 1) { if (QTypeInfo::isComplex) { int oldcount = d->count; - T * i = d->array + d->start; - T * e = d->array + d->alloc; + T * i = p->array + d->start; + T * e = p->array + d->alloc; while (oldcount--) { i->~T(); i++; if (i == e) - i = d->array; + i = p->array; } } d->count = d->start = d->offset = 0; } else { - union { QContiguousCacheData *p; QContiguousCacheTypedData *d; } x; - x.p = malloc(d->alloc); + union { QContiguousCacheData *d; QContiguousCacheTypedData *p; } x; + x.d = malloc(d->alloc); x.d->ref = 1; x.d->alloc = d->alloc; x.d->count = x.d->start = x.d->offset = 0; x.d->sharable = true; - if (!d->ref.deref()) free(d); + if (!d->ref.deref()) free(p); d = x.d; } } @@ -263,7 +268,7 @@ inline QContiguousCacheData *QContiguousCache::malloc(int aalloc) template QContiguousCache::QContiguousCache(int cap) { - p = malloc(cap); + d = malloc(cap); d->ref = 1; d->alloc = cap; d->count = d->start = d->offset = 0; @@ -303,13 +308,13 @@ void QContiguousCache::free(Data *x) { if (QTypeInfo::isComplex) { int oldcount = d->count; - T * i = d->array + d->start; - T * e = d->array + d->alloc; + T * i = p->array + d->start; + T * e = p->array + d->alloc; while (oldcount--) { i->~T(); i++; if (i == e) - i = d->array; + i = p->array; } } qFree(x); @@ -320,10 +325,10 @@ void QContiguousCache::append(const T &value) detach(); if (QTypeInfo::isComplex) { if (d->count == d->alloc) - (d->array + (d->start+d->count) % d->alloc)->~T(); - new (d->array + (d->start+d->count) % d->alloc) T(value); + (p->array + (d->start+d->count) % d->alloc)->~T(); + new (p->array + (d->start+d->count) % d->alloc) T(value); } else { - d->array[(d->start+d->count) % d->alloc] = value; + p->array[(d->start+d->count) % d->alloc] = value; } if (d->count == d->alloc) { @@ -349,12 +354,12 @@ void QContiguousCache::prepend(const T &value) d->count++; else if (d->count == d->alloc) - (d->array + d->start)->~T(); + (p->array + d->start)->~T(); if (QTypeInfo::isComplex) - new (d->array + d->start) T(value); + new (p->array + d->start) T(value); else - d->array[d->start] = value; + p->array[d->start] = value; } template @@ -364,9 +369,9 @@ void QContiguousCache::insert(int pos, const T &value) detach(); if (containsIndex(pos)) { if(QTypeInfo::isComplex) - new (d->array + pos % d->alloc) T(value); + new (p->array + pos % d->alloc) T(value); else - d->array[pos % d->alloc] = value; + p->array[pos % d->alloc] = value; } else if (pos == d->offset-1) prepend(value); else if (pos == d->offset+d->count) @@ -378,18 +383,18 @@ void QContiguousCache::insert(int pos, const T &value) d->start = pos % d->alloc; d->count = 1; if (QTypeInfo::isComplex) - new (d->array + d->start) T(value); + new (p->array + d->start) T(value); else - d->array[d->start] = value; + p->array[d->start] = value; } } template inline const T &QContiguousCache::at(int pos) const -{ Q_ASSERT_X(pos >= d->offset && pos - d->offset < d->count, "QContiguousCache::at", "index out of range"); return d->array[pos % d->alloc]; } +{ Q_ASSERT_X(pos >= d->offset && pos - d->offset < d->count, "QContiguousCache::at", "index out of range"); return p->array[pos % d->alloc]; } template inline const T &QContiguousCache::operator[](int pos) const -{ Q_ASSERT_X(pos >= d->offset && pos - d->offset < d->count, "QContiguousCache::at", "index out of range"); return d->array[pos % d->alloc]; } +{ Q_ASSERT_X(pos >= d->offset && pos - d->offset < d->count, "QContiguousCache::at", "index out of range"); return p->array[pos % d->alloc]; } template inline T &QContiguousCache::operator[](int pos) @@ -397,7 +402,7 @@ inline T &QContiguousCache::operator[](int pos) detach(); if (!containsIndex(pos)) insert(pos, T()); - return d->array[pos % d->alloc]; + return p->array[pos % d->alloc]; } template @@ -407,7 +412,7 @@ inline void QContiguousCache::removeFirst() detach(); d->count--; if (QTypeInfo::isComplex) - (d->array + d->start)->~T(); + (p->array + d->start)->~T(); d->start = (d->start + 1) % d->alloc; d->offset++; } @@ -419,7 +424,7 @@ inline void QContiguousCache::removeLast() detach(); d->count--; if (QTypeInfo::isComplex) - (d->array + (d->start + d->count) % d->alloc)->~T(); + (p->array + (d->start + d->count) % d->alloc)->~T(); } template -- cgit v0.12 From 3f0b969772cf3056ed54349bfe6837d9de2995ea Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 22 Oct 2009 18:57:53 +0200 Subject: Add the aligned versions of qMalloc/qRealloc/qFree --- src/corelib/global/qglobal.h | 3 ++ src/corelib/global/qmalloc.cpp | 100 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 5ee1815..cbb8fda 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -2065,6 +2065,9 @@ Q_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE); Q_CORE_EXPORT void *qMalloc(size_t size); Q_CORE_EXPORT void qFree(void *ptr); Q_CORE_EXPORT void *qRealloc(void *ptr, size_t size); +Q_CORE_EXPORT void *qMallocAligned(size_t size, size_t alignment); +Q_CORE_EXPORT void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment); +Q_CORE_EXPORT void qFreeAligned(void *ptr); Q_CORE_EXPORT void *qMemCopy(void *dest, const void *src, size_t n); Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n); diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp index a9f103c..db5e519 100644 --- a/src/corelib/global/qmalloc.cpp +++ b/src/corelib/global/qmalloc.cpp @@ -42,6 +42,7 @@ #include "qplatformdefs.h" #include +#include /* Define the container allocation functions in a separate file, so that our @@ -65,4 +66,103 @@ void *qRealloc(void *ptr, size_t size) return ::realloc(ptr, size); } +#if ((defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600)) +# define HAVE_POSIX_MEMALIGN +#endif + +void *qMallocAligned(size_t size, size_t alignment) +{ +#if defined(Q_OS_WIN) + return _aligned_malloc(size, alignment); +#elif defined(HAVE_POSIX_MEMALIGN) + if (alignment <= sizeof(void*)) + return qMalloc(size); + + // we have posix_memalign + void *ptr = 0; + if (posix_memalign(&ptr, alignment, size) == 0) + return ptr; + return 0; +#else + return qReallocAligned(0, size, 0, alignment); +#endif +} + +void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t alignment) +{ +#if defined(Q_OS_WIN) + Q_UNUSED(oldsize); + return _aligned_realloc(oldptr, newsize, alignment); +#elif defined(HAVE_POSIX_MEMALIGN) + if (alignment <= sizeof(void*)) + return qRealloc(oldptr, newsize); + + void *newptr = qMallocAligned(newsize, alignment); + if (!newptr) + return 0; + qMemCopy(newptr, oldptr, qMin(oldsize, newsize)); + qFree(oldptr); + return newptr; +#else + // fake an aligned allocation + Q_UNUSED(oldsize); + + void *actualptr = oldptr ? static_cast(oldptr)[-1] : 0; + if (alignment <= sizeof(void*)) { + // special, fast case + void **newptr = static_cast(qRealloc(actualptr, newsize + sizeof(void*))); + if (!newptr) + return 0; + if (newptr == actualptr) { + // realloc succeeded without reallocating + return oldptr; + } + + *newptr = newptr; + return newptr + 1; + } + + union { void *ptr; void **pptr; quintptr n; } real, faked; + + // qMalloc returns pointers aligned at least at sizeof(size_t) boundaries + // but usually more (8- or 16-byte boundaries). + // So we overallocate by alignment-sizeof(size_t) bytes, so we're guaranteed to find a + // somewhere within the first alignment-sizeof(size_t) that is properly aligned. + + // However, we need to store the actual pointer, so we need to allocate actually size + + // alignment anyway. + + real.ptr = qRealloc(actualptr, newsize + alignment); + if (!real.ptr) + return 0; + + faked.n = real.n + alignment; + faked.n &= ~(alignment - 1); + + // now save the value of the real pointer at faked-sizeof(void*) + // by construction, alignment > sizeof(void*) and is a power of 2, so + // faked-sizeof(void*) is properly aligned for a pointer + faked.pptr[-1] = real.ptr; + + // and save the actual size just before the pointer + //reinterpret_cast(faked.pptr - 1)[-1] = size; + + return faked.ptr; +#endif +} + +void qFreeAligned(void *ptr) +{ +#if defined(Q_OS_WIN) + _aligned_free(ptr); +#elif defined(HAVE_POSIX_MEMALIGN) + ::free(ptr); +#else + if (!ptr) + return; + void **ptr2 = static_cast(ptr); + free(ptr2[-1]); +#endif +} + QT_END_NAMESPACE -- cgit v0.12 From e83bb2fdfc2dc899526c8157fd8b77a68cdde9da Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 22 Oct 2009 21:09:24 +0200 Subject: Fix Qt containers to properly support types with strict alignments. QContiguousCache is a new type, so there are no binary compatibility issues. QHash and QMap didn't have any public qMalloc / qFree, so the entire logic is contained in .cpp code. However, since old code will not inform us of the alignment requirements, we need to add a bit to the structure to indicate whether strict alignment is in use or not. QList doesn't require any changes. For small, movable types, they're all stored in the pointer array itself, so they're aligned. For larger types, we use new(), so types with stricter requirements should define their own operator new(). QLinkedList cannot be fixed. It uses new() on the QLinkedListNode, which contains a T type. Sorry. QVector did have public qMalloc / qFree. I've moved the calls to the inner function and made it keep the old calls if the alignment requirement is below a certain threshold. The idea is that, if it's above, no one was using QVector anyway. Reviewed-by: Bradley T. Hughes --- src/corelib/global/qmalloc.cpp | 3 - src/corelib/tools/qcontiguouscache.cpp | 10 +++ src/corelib/tools/qcontiguouscache.h | 15 +++- src/corelib/tools/qhash.cpp | 27 ++++--- src/corelib/tools/qhash.h | 36 ++++++---- src/corelib/tools/qmap.cpp | 31 ++++++-- src/corelib/tools/qmap.h | 20 ++++-- src/corelib/tools/qvector.cpp | 27 +++++++ src/corelib/tools/qvector.h | 20 +++++- tests/auto/collections/tst_collections.cpp | 109 +++++++++++++++++++++++++++++ 10 files changed, 259 insertions(+), 39 deletions(-) diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp index db5e519..e33f77c 100644 --- a/src/corelib/global/qmalloc.cpp +++ b/src/corelib/global/qmalloc.cpp @@ -144,9 +144,6 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align // faked-sizeof(void*) is properly aligned for a pointer faked.pptr[-1] = real.ptr; - // and save the actual size just before the pointer - //reinterpret_cast(faked.pptr - 1)[-1] = size; - return faked.ptr; #endif } diff --git a/src/corelib/tools/qcontiguouscache.cpp b/src/corelib/tools/qcontiguouscache.cpp index b0ed701..dd7cab6 100644 --- a/src/corelib/tools/qcontiguouscache.cpp +++ b/src/corelib/tools/qcontiguouscache.cpp @@ -56,6 +56,16 @@ void QContiguousCacheData::dump() const } #endif +QContiguousCacheData *QContiguousCacheData::allocate(int size, int alignment) +{ + return static_cast(qMallocAligned(size, alignment)); +} + +void QContiguousCacheData::free(QContiguousCacheData *data) +{ + qFreeAligned(data); +} + /*! \class QContiguousCache \brief The QContiguousCache class is a template class that provides a contiguous cache. \ingroup tools diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index 862df61..b9d04b8 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -69,6 +69,9 @@ struct Q_CORE_EXPORT QContiguousCacheData // there will be an 8 byte gap here if T requires 16-byte alignment // (such as long double on 64-bit platforms, __int128, __float128) + static QContiguousCacheData *allocate(int size, int alignment); + static void free(QContiguousCacheData *data); + #ifdef QT_QCONTIGUOUSCACHE_DEBUG void dump() const; #endif @@ -161,6 +164,14 @@ private: // count the padding at the end return reinterpret_cast(&(reinterpret_cast(this))->array[1]) - reinterpret_cast(this); } + int alignOfTypedData() const + { +#ifdef Q_ALIGNOF + return qMax(sizeof(void*), Q_ALIGNOF(Data)); +#else + return 0; +#endif + } }; template @@ -262,7 +273,7 @@ void QContiguousCache::clear() template inline QContiguousCacheData *QContiguousCache::malloc(int aalloc) { - return static_cast(qMalloc(sizeOfTypedData() + (aalloc - 1) * sizeof(T))); + return QContiguousCacheData::allocate(sizeOfTypedData() + (aalloc - 1) * sizeof(T), alignOfTypedData()); } template @@ -317,7 +328,7 @@ void QContiguousCache::free(Data *x) i = p->array; } } - qFree(x); + x->free(x); } template void QContiguousCache::append(const T &value) diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index f33aba9..23fff1c 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -166,29 +166,38 @@ static int countBits(int hint) const int MinNumBits = 4; QHashData QHashData::shared_null = { - 0, 0, Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, MinNumBits, 0, 0, true + 0, 0, Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, MinNumBits, 0, 0, true, false }; void *QHashData::allocateNode() { - void *ptr = qMalloc(nodeSize); + return allocateNode(0); +} + +void *QHashData::allocateNode(int nodeAlign) +{ + void *ptr = strictAlignment ? qMallocAligned(nodeSize, nodeAlign) : qMalloc(nodeSize); Q_CHECK_PTR(ptr); return ptr; } void QHashData::freeNode(void *node) { - qFree(node); + if (strictAlignment) + qFreeAligned(node); + else + qFree(node); } QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *), int nodeSize) { - return detach_helper( node_duplicate, 0, nodeSize ); + return detach_helper2( node_duplicate, 0, nodeSize, 0 ); } -QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *), - void (*node_delete)(Node *), - int nodeSize) +QHashData *QHashData::detach_helper2(void (*node_duplicate)(Node *, void *), + void (*node_delete)(Node *), + int nodeSize, + int nodeAlign) { union { QHashData *d; @@ -204,6 +213,7 @@ QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *), d->numBits = numBits; d->numBuckets = numBuckets; d->sharable = true; + d->strictAlignment = nodeAlign > 8; if (numBuckets) { QT_TRY { @@ -222,7 +232,7 @@ QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *), Node *oldNode = buckets[i]; while (oldNode != this_e) { QT_TRY { - Node *dup = static_cast(allocateNode()); + Node *dup = static_cast(allocateNode(nodeAlign)); QT_TRY { node_duplicate(oldNode, dup); @@ -262,6 +272,7 @@ void QHashData::free_helper(void (*node_delete)(Node *)) while (cur != this_e) { Node *next = cur->next; node_delete(cur); + freeNode(cur); cur = next; } } diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index b65f1d3..67b394b 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -125,12 +125,14 @@ struct Q_CORE_EXPORT QHashData short numBits; int numBuckets; uint sharable : 1; + uint strictAlignment : 1; - void *allocateNode(); + void *allocateNode(); // ### Qt5 remove me + void *allocateNode(int nodeAlign); void freeNode(void *node); QHashData *detach_helper(void (*node_duplicate)(Node *, void *), int nodeSize); // ### Qt5 remove me - QHashData *detach_helper(void (*node_duplicate)(Node *, void *), void (*node_delete)(Node *), - int nodeSize); + QHashData *detach_helper2(void (*node_duplicate)(Node *, void *), void (*node_delete)(Node *), + int nodeSize, int nodeAlign); void mightGrow(); bool willGrow(); void hasShrunk(); @@ -267,6 +269,14 @@ class QHash return reinterpret_cast(node); } +#ifdef Q_ALIGNOF + static inline int alignOfNode() { return qMax(sizeof(void*), Q_ALIGNOF(Node)); } + static inline int alignOfDummyNode() { return qMax(sizeof(void*), Q_ALIGNOF(DummyNode)); } +#else + static inline int alignOfNode() { return 0; } + static inline int alignOfDummyNode() { return 0; } +#endif + public: inline QHash() : d(&QHashData::shared_null) { d->ref.ref(); } inline QHash(const QHash &other) : d(other.d) { d->ref.ref(); if (!d->sharable) detach(); } @@ -483,7 +493,7 @@ private: Node **findNode(const Key &key, uint *hp = 0) const; Node *createNode(uint h, const Key &key, const T &value, Node **nextNode); void deleteNode(Node *node); - static void deleteNode(QHashData::Node *node); + static void deleteNode2(QHashData::Node *node); static void duplicateNode(QHashData::Node *originalNode, void *newNode); }; @@ -492,12 +502,12 @@ private: template Q_INLINE_TEMPLATE void QHash::deleteNode(Node *node) { - deleteNode(reinterpret_cast(node)); + deleteNode2(reinterpret_cast(node)); + d->freeNode(node); } - template -Q_INLINE_TEMPLATE void QHash::deleteNode(QHashData::Node *node) +Q_INLINE_TEMPLATE void QHash::deleteNode2(QHashData::Node *node) { #ifdef Q_CC_BOR concrete(node)->~QHashNode(); @@ -506,7 +516,6 @@ Q_INLINE_TEMPLATE void QHash::deleteNode(QHashData::Node *node) #else concrete(node)->~Node(); #endif - qFree(node); } template @@ -527,9 +536,9 @@ QHash::createNode(uint ah, const Key &akey, const T &avalue, Node **anex Node *node; if (QTypeInfo::isDummy) { - node = reinterpret_cast(new (d->allocateNode()) DummyNode(akey)); + node = reinterpret_cast(new (d->allocateNode(alignOfDummyNode())) DummyNode(akey)); } else { - node = new (d->allocateNode()) Node(akey, avalue); + node = new (d->allocateNode(alignOfNode())) Node(akey, avalue); } node->h = ah; @@ -554,7 +563,7 @@ Q_INLINE_TEMPLATE QHash &QHash::unite(const QHash &other template Q_OUTOFLINE_TEMPLATE void QHash::freeData(QHashData *x) { - x->free_helper(deleteNode); + x->free_helper(deleteNode2); } template @@ -566,8 +575,9 @@ Q_INLINE_TEMPLATE void QHash::clear() template Q_OUTOFLINE_TEMPLATE void QHash::detach_helper() { - QHashData *x = d->detach_helper(duplicateNode, deleteNode, - QTypeInfo::isDummy ? sizeof(DummyNode) : sizeof(Node)); + QHashData *x = d->detach_helper2(duplicateNode, deleteNode2, + QTypeInfo::isDummy ? sizeof(DummyNode) : sizeof(Node), + QTypeInfo::isDummy ? alignOfDummyNode() : alignOfNode()); if (!d->ref.deref()) freeData(d); d = x; diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp index 1385810..cfb18b4 100644 --- a/src/corelib/tools/qmap.cpp +++ b/src/corelib/tools/qmap.cpp @@ -53,11 +53,16 @@ QT_BEGIN_NAMESPACE QMapData QMapData::shared_null = { &shared_null, { &shared_null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, 0, false, true + Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, 0, false, true, false }; QMapData *QMapData::createData() { + return createData(0); +} + +QMapData *QMapData::createData(int alignment) +{ QMapData *d = new QMapData; Q_CHECK_PTR(d); Node *e = reinterpret_cast(d); @@ -69,6 +74,7 @@ QMapData *QMapData::createData() d->randomBits = 0; d->insertInOrder = false; d->sharable = true; + d->strictAlignment = alignment > 8; return d; } @@ -80,11 +86,19 @@ void QMapData::continueFreeData(int offset) while (cur != e) { prev = cur; cur = cur->forward[0]; - qFree(reinterpret_cast(prev) - offset); + if (strictAlignment) + qFreeAligned(reinterpret_cast(prev) - offset); + else + qFree(reinterpret_cast(prev) - offset); } delete this; } +QMapData::Node *QMapData::node_create(Node *update[], int offset) +{ + return node_create(update, offset, 0); +} + /*! Creates a new node inside the data structure. @@ -94,10 +108,12 @@ void QMapData::continueFreeData(int offset) \a offset is an amount of bytes that needs to reserved just before the QMapData::Node structure. + \a alignment dictates the alignment for the data. + \internal \since 4.6 */ -QMapData::Node *QMapData::node_create(Node *update[], int offset) +QMapData::Node *QMapData::node_create(Node *update[], int offset, int alignment) { int level = 0; uint mask = (1 << Sparseness) - 1; @@ -118,7 +134,9 @@ QMapData::Node *QMapData::node_create(Node *update[], int offset) if (level == 3 && !insertInOrder) randomBits = qrand(); - void *concreteNode = qMalloc(offset + sizeof(Node) + level * sizeof(Node *)); + void *concreteNode = strictAlignment ? + qMallocAligned(offset + sizeof(Node) + level * sizeof(Node *), alignment) : + qMalloc(offset + sizeof(Node) + level * sizeof(Node *)); Q_CHECK_PTR(concreteNode); Node *abstractNode = reinterpret_cast(reinterpret_cast(concreteNode) + offset); @@ -145,7 +163,10 @@ void QMapData::node_delete(Node *update[], int offset, Node *node) update[i]->forward[i] = node->forward[i]; } --size; - qFree(reinterpret_cast(node) - offset); + if (strictAlignment) + qFreeAligned(reinterpret_cast(node) - offset); + else + qFree(reinterpret_cast(node) - offset); } #ifdef QT_QMAP_DEBUG diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 688aca6..20980e7 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -74,10 +74,13 @@ struct Q_CORE_EXPORT QMapData uint randomBits; uint insertInOrder : 1; uint sharable : 1; + uint strictAlignment : 1; - static QMapData *createData(); + static QMapData *createData(); // ### Qt5 remove me + static QMapData *createData(int alignment); void continueFreeData(int offset); - Node *node_create(Node *update[], int offset); + Node *node_create(Node *update[], int offset); // ### Qt5 remove me + Node *node_create(Node *update[], int offset, int alignment); void node_delete(Node *update[], int offset, Node *node); #ifdef QT_QMAP_DEBUG uint adjust_ptr(Node *node); @@ -145,6 +148,13 @@ class QMap }; static inline int payload() { return sizeof(PayloadNode) - sizeof(QMapData::Node *); } + static inline int alignment() { +#ifdef Q_ALIGNOF + return qMax(sizeof(void*), Q_ALIGNOF(Node)); +#else + return 0; +#endif + } static inline Node *concrete(QMapData::Node *node) { return reinterpret_cast(reinterpret_cast(node) - payload()); } @@ -414,7 +424,7 @@ template Q_INLINE_TEMPLATE typename QMapData::Node * QMap::node_create(QMapData *adt, QMapData::Node *aupdate[], const Key &akey, const T &avalue) { - QMapData::Node *abstractNode = adt->node_create(aupdate, payload()); + QMapData::Node *abstractNode = adt->node_create(aupdate, payload(), alignment()); QT_TRY { Node *concreteNode = concrete(abstractNode); new (&concreteNode->key) Key(akey); @@ -715,7 +725,7 @@ template Q_OUTOFLINE_TEMPLATE void QMap::detach_helper() { union { QMapData *d; QMapData::Node *e; } x; - x.d = QMapData::createData(); + x.d = QMapData::createData(alignment()); if (d->size) { x.d->insertInOrder = true; QMapData::Node *update[QMapData::LastLevel + 1]; @@ -905,7 +915,7 @@ Q_OUTOFLINE_TEMPLATE bool QMap::operator==(const QMap &other) co template Q_OUTOFLINE_TEMPLATE QMap::QMap(const std::map &other) { - d = QMapData::createData(); + d = QMapData::createData(alignment()); d->insertInOrder = true; typename std::map::const_iterator it = other.end(); while (it != other.begin()) { diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp index 20f3a80..6522791 100644 --- a/src/corelib/tools/qvector.cpp +++ b/src/corelib/tools/qvector.cpp @@ -45,6 +45,13 @@ QT_BEGIN_NAMESPACE +static inline int alignmentThreshold() +{ + // malloc on 32-bit platforms should return pointers that are 8-byte aligned or more + // while on 64-bit platforms they should be 16-byte aligned or more + return 2 * sizeof(void*); +} + QVectorData QVectorData::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, true, false }; QVectorData *QVectorData::malloc(int sizeofTypedData, int size, int sizeofT, QVectorData *init) @@ -55,6 +62,26 @@ QVectorData *QVectorData::malloc(int sizeofTypedData, int size, int sizeofT, QVe return p; } +QVectorData *QVectorData::allocate(int size, int alignment) +{ + return static_cast(alignment > alignmentThreshold() ? qMallocAligned(size, alignment) : qMalloc(size)); +} + +QVectorData *QVectorData::reallocate(QVectorData *x, int newsize, int oldsize, int alignment) +{ + if (alignment > alignmentThreshold()) + return static_cast(qReallocAligned(x, newsize, oldsize, alignment)); + return static_cast(qRealloc(x, newsize)); +} + +void QVectorData::free(QVectorData *x, int alignment) +{ + if (alignment > alignmentThreshold()) + qFreeAligned(x); + else + qFree(x); +} + int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive) { if (excessive) diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index b77b53a..cf7df12 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -79,6 +79,9 @@ struct Q_CORE_EXPORT QVectorData // some debugges when the QVector is member of a class within an unnamed namespace. // ### Qt 5: can be removed completely. (Ralf) static QVectorData *malloc(int sizeofTypedData, int size, int sizeofT, QVectorData *init); + static QVectorData *allocate(int size, int alignment); + static QVectorData *reallocate(QVectorData *old, int newsize, int oldsize, int alignment); + static void free(QVectorData *data, int alignment); static int grow(int sizeofTypedData, int size, int sizeofT, bool excessive); }; @@ -87,6 +90,8 @@ struct QVectorTypedData : private QVectorData { // private inheritance as we must not access QVectorData member thought QVectorTypedData // as this would break strict aliasing rules. (in the case of shared_null) T array[1]; + + static inline void free(QVectorTypedData *x, int alignment) { QVectorData::free(x, alignment); } }; class QRegion; @@ -302,6 +307,14 @@ private: // count the padding at the end return reinterpret_cast(&(reinterpret_cast(this))->array[1]) - reinterpret_cast(this); } + inline int alignOfTypedData() const + { +#ifdef Q_ALIGNOF + return qMax(sizeof(void*), Q_ALIGNOF(Data)); +#else + return 0; +#endif + } }; template @@ -373,7 +386,7 @@ QVector &QVector::operator=(const QVector &v) template inline QVectorData *QVector::malloc(int aalloc) { - QVectorData *vectordata = static_cast(qMalloc(sizeOfTypedData() + (aalloc - 1) * sizeof(T))); + QVectorData *vectordata = QVectorData::allocate(sizeOfTypedData() + (aalloc - 1) * sizeof(T), alignOfTypedData()); Q_CHECK_PTR(vectordata); return vectordata; } @@ -420,7 +433,7 @@ void QVector::free(Data *x) while (i-- != b) i->~T(); } - qFree(x); + x->free(x, alignOfTypedData()); } template @@ -459,7 +472,8 @@ void QVector::realloc(int asize, int aalloc) } } else { QT_TRY { - QVectorData *mem = static_cast(qRealloc(p, sizeOfTypedData() + (aalloc - 1) * sizeof(T))); + QVectorData *mem = QVectorData::reallocate(d, sizeOfTypedData() + (aalloc - 1) * sizeof(T), + sizeOfTypedData() + (d->alloc - 1) * sizeof(T), alignOfTypedData()); Q_CHECK_PTR(mem); x.d = d = mem; x.d->size = d->size; diff --git a/tests/auto/collections/tst_collections.cpp b/tests/auto/collections/tst_collections.cpp index 670cff0..f97805e 100644 --- a/tests/auto/collections/tst_collections.cpp +++ b/tests/auto/collections/tst_collections.cpp @@ -164,6 +164,7 @@ private slots: void qtimerList(); void containerTypedefs(); void forwardDeclared(); + void alignment(); }; struct LargeStatic { @@ -3481,5 +3482,113 @@ void tst_Collections::forwardDeclared() { typedef QSet C; C *x = 0; /* C::iterator i; */ C::const_iterator j; Q_UNUSED(x) } } +#if defined(Q_ALIGNOF) && defined(Q_DECL_ALIGN) + +class Q_DECL_ALIGN(4) Aligned4 +{ + char i; +public: + Aligned4(int i = 0) : i(i) {} + bool checkAligned() const + { + return (quintptr(this) & 3) == 0; + } + + inline bool operator==(const Aligned4 &other) const { return i == other.i; } + inline bool operator<(const Aligned4 &other) const { return i < other.i; } + friend inline int qHash(const Aligned4 &a) { return qHash(a.i); } +}; + +class Q_DECL_ALIGN(128) Aligned128 +{ + char i; +public: + Aligned128(int i = 0) : i(i) {} + bool checkAligned() const + { + return (quintptr(this) & 127) == 0; + } + + inline bool operator==(const Aligned128 &other) const { return i == other.i; } + inline bool operator<(const Aligned128 &other) const { return i < other.i; } + friend inline int qHash(const Aligned128 &a) { return qHash(a.i); } +}; + +template +void testVectorAlignment() +{ + typedef typename C::value_type Aligned; + C container; + container.append(Aligned()); + QVERIFY(container[0].checkAligned()); + + for (int i = 0; i < 200; ++i) + container.append(Aligned()); + + for (int i = 0; i < container.size(); ++i) + QVERIFY(container.at(i).checkAligned()); +} + +template +void testContiguousCacheAlignment() +{ + typedef typename C::value_type Aligned; + C container(150); + container.append(Aligned()); + QVERIFY(container[container.firstIndex()].checkAligned()); + + for (int i = 0; i < 200; ++i) + container.append(Aligned()); + + for (int i = container.firstIndex(); i < container.lastIndex(); ++i) + QVERIFY(container.at(i).checkAligned()); +} + +template +void testAssociativeContainerAlignment() +{ + typedef typename C::key_type Key; + typedef typename C::mapped_type Value; + C container; + container.insert(Key(), Value()); + + typename C::const_iterator it = container.constBegin(); + QVERIFY(it.key().checkAligned()); + QVERIFY(it.value().checkAligned()); + + // add some more elements + for (int i = 0; i < 200; ++i) + container.insert(Key(i), Value(i)); + + it = container.constBegin(); + for ( ; it != container.constEnd(); ++it) { + QVERIFY(it.key().checkAligned()); + QVERIFY(it.value().checkAligned()); + } +} + +void tst_Collections::alignment() +{ + testVectorAlignment >(); + testVectorAlignment >(); + testContiguousCacheAlignment >(); + testContiguousCacheAlignment >(); + testAssociativeContainerAlignment >(); + testAssociativeContainerAlignment >(); + testAssociativeContainerAlignment >(); + testAssociativeContainerAlignment >(); + testAssociativeContainerAlignment >(); + testAssociativeContainerAlignment >(); + testAssociativeContainerAlignment >(); + testAssociativeContainerAlignment >(); +} + +#else +void tst_Collections::alignment() +{ + QSKIP("Compiler doesn't support necessary extension keywords", SkipAll) +} +#endif + QTEST_APPLESS_MAIN(tst_Collections) #include "tst_collections.moc" -- cgit v0.12 From 5b4b6b2be7b901ef9a29c37431998034730fa3d3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 28 Oct 2009 12:47:35 +0100 Subject: Initialise the reserved bits to 0. This is future compatibility: we must rely on them being 0 in older versions of Qt. Reviewed-by: Bradley T. Hughes --- src/corelib/tools/qcontiguouscache.h | 3 ++- src/corelib/tools/qhash.cpp | 3 ++- src/corelib/tools/qhash.h | 1 + src/corelib/tools/qmap.cpp | 3 ++- src/corelib/tools/qmap.h | 1 + src/corelib/tools/qvector.cpp | 2 +- src/corelib/tools/qvector.h | 2 ++ 7 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index b9d04b8..ef5b238 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -62,7 +62,7 @@ struct Q_CORE_EXPORT QContiguousCacheData int start; int offset; uint sharable : 1; - // uint unused : 31; + uint reserved : 31; // total is 24 bytes (HP-UX aCC: 40 bytes) // the next entry is already aligned to 8 bytes @@ -186,6 +186,7 @@ void QContiguousCache::detach_helper() x.d->offset = d->offset; x.d->alloc = d->alloc; x.d->sharable = true; + x.d->reserved = 0; T *dest = x.p->array + x.d->start; T *src = p->array + d->start; diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 23fff1c..c82c389 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -166,7 +166,7 @@ static int countBits(int hint) const int MinNumBits = 4; QHashData QHashData::shared_null = { - 0, 0, Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, MinNumBits, 0, 0, true, false + 0, 0, Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, MinNumBits, 0, 0, true, false, 0 }; void *QHashData::allocateNode() @@ -214,6 +214,7 @@ QHashData *QHashData::detach_helper2(void (*node_duplicate)(Node *, void *), d->numBuckets = numBuckets; d->sharable = true; d->strictAlignment = nodeAlign > 8; + d->reserved = 0; if (numBuckets) { QT_TRY { diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 67b394b..1918229 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -126,6 +126,7 @@ struct Q_CORE_EXPORT QHashData int numBuckets; uint sharable : 1; uint strictAlignment : 1; + uint reserved : 30; void *allocateNode(); // ### Qt5 remove me void *allocateNode(int nodeAlign); diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp index cfb18b4..3b48c3f 100644 --- a/src/corelib/tools/qmap.cpp +++ b/src/corelib/tools/qmap.cpp @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE QMapData QMapData::shared_null = { &shared_null, { &shared_null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, 0, false, true, false + Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, 0, false, true, false, 0 }; QMapData *QMapData::createData() @@ -75,6 +75,7 @@ QMapData *QMapData::createData(int alignment) d->insertInOrder = false; d->sharable = true; d->strictAlignment = alignment > 8; + d->reserved = 0; return d; } diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 20980e7..65c3d2a 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -75,6 +75,7 @@ struct Q_CORE_EXPORT QMapData uint insertInOrder : 1; uint sharable : 1; uint strictAlignment : 1; + uint reserved : 29; static QMapData *createData(); // ### Qt5 remove me static QMapData *createData(int alignment); diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp index 6522791..8bb1074 100644 --- a/src/corelib/tools/qvector.cpp +++ b/src/corelib/tools/qvector.cpp @@ -52,7 +52,7 @@ static inline int alignmentThreshold() return 2 * sizeof(void*); } -QVectorData QVectorData::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, true, false }; +QVectorData QVectorData::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, true, false, 0 }; QVectorData *QVectorData::malloc(int sizeofTypedData, int size, int sizeofT, QVectorData *init) { diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index cf7df12..7402d77 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -72,6 +72,7 @@ struct Q_CORE_EXPORT QVectorData #else uint sharable : 1; uint capacity : 1; + uint reserved : 30; #endif static QVectorData shared_null; @@ -486,6 +487,7 @@ void QVector::realloc(int asize, int aalloc) x.d->alloc = aalloc; x.d->sharable = true; x.d->capacity = d->capacity; + x.d->reserved = 0; } if (QTypeInfo::isComplex) { -- cgit v0.12 From 138e8c17767959c183b3e00e3fb364ab5b6fbdfd Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 28 Oct 2009 14:14:25 +0100 Subject: QLocalServer: block indefinitely when timeout value is -1 ... as described in the documentation. Furthermore: * use qt_safe_select to timeout correctly * return immediately when timeout value is 0 Reviewed-by: Oswald Buddenhagen --- src/network/socket/qlocalserver_unix.cpp | 22 ++++++---------------- tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 2 +- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/network/socket/qlocalserver_unix.cpp b/src/network/socket/qlocalserver_unix.cpp index 5ffe0c0..e09e547 100644 --- a/src/network/socket/qlocalserver_unix.cpp +++ b/src/network/socket/qlocalserver_unix.cpp @@ -216,24 +216,14 @@ void QLocalServerPrivate::waitForNewConnection(int msec, bool *timedOut) timeout.tv_sec = msec / 1000; timeout.tv_usec = (msec % 1000) * 1000; - // timeout can not be 0 or else select will return an error. - if (0 == msec) - timeout.tv_usec = 1000; - int result = -1; - // on Linux timeout will be updated by select, but _not_ on other systems. - QTime timer; - timer.start(); - while (pendingConnections.isEmpty() && (-1 == msec || timer.elapsed() < msec)) { - result = ::select(listenSocket + 1, &readfds, 0, 0, &timeout); - if (-1 == result && errno != EINTR) { - setError(QLatin1String("QLocalServer::waitForNewConnection")); - closeServer(); - break; - } - if (result > 0) - _q_onNewConnection(); + result = qt_safe_select(listenSocket + 1, &readfds, 0, 0, (msec == -1) ? 0 : &timeout); + if (-1 == result) { + setError(QLatin1String("QLocalServer::waitForNewConnection")); + closeServer(); } + if (result > 0) + _q_onNewConnection(); if (timedOut) *timedOut = (result == 0); } diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index be39d00..ab7b0ac 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -976,7 +976,7 @@ void tst_QLocalSocket::writeOnlySocket() #if defined(Q_OS_SYMBIAN) QTest::qWait(250); #endif - QVERIFY(server.waitForNewConnection()); + QVERIFY(server.waitForNewConnection(200)); QLocalSocket* serverSocket = server.nextPendingConnection(); QVERIFY(serverSocket); -- cgit v0.12 From 6e228d57da9d5dd9b7365d5539f6ed88cafb5d97 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 28 Oct 2009 16:00:49 +0100 Subject: Fixed missing repaints on QTreeView when moving the mouse ..from the decoration to the item itself. QAbstractItemView can't handle that because it doesn't know anything about decoration. Reviewed-by: gabi --- src/gui/itemviews/qtreeview.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 16b454d..bad9dfe 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -1226,8 +1226,12 @@ bool QTreeView::viewportEvent(QEvent *event) if (oldIndex != newIndex) { QRect oldRect = visualRect(oldIndex); QRect newRect = visualRect(newIndex); - viewport()->update(oldRect.left() - d->indent, oldRect.top(), d->indent, oldRect.height()); - viewport()->update(newRect.left() - d->indent, newRect.top(), d->indent, newRect.height()); + oldRect.rLeft() -= d->indent; + newRect.rLeft() -= d->indent; + //we need to paint the whole items (including the decoration) so that when the user + //moves the mouse over those elements they are updated + viewport()->update(oldRect); + viewport()->update(newRect); } } if (selectionBehavior() == QAbstractItemView::SelectRows) { -- cgit v0.12 From d560894ad085ac8c6266fd1af66139db950f473f Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 28 Oct 2009 15:10:36 +0100 Subject: Fixed bug in QTableView spans. In some cases, the spans internal structure was left in an inconsistent state. Auto-test included. Bonus: spans consistency checking method. Task-number: QTBUG-5062 Reviewed-by: Olivier --- src/gui/itemviews/qtableview.cpp | 43 +++++++++++++++++++++++++++++++- src/gui/itemviews/qtableview_p.h | 6 ++++- tests/auto/qtableview/tst_qtableview.cpp | 38 ++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 2 deletions(-) diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index c80faa2..02e5fff 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -117,7 +117,7 @@ void QSpanCollection::updateSpan(QSpanCollection::Span *span, int old_height) Index::iterator it_y = index.lowerBound(-span->bottom()); Q_ASSERT(it_y != index.end()); //it_y must exist since the span is in the list while (-it_y.key() <= span->top() + old_height -1) { - if(-it_y.key() != span->bottom()) { + if (-it_y.key() > span->bottom()) { (*it_y).remove(-span->left()); if (it_y->isEmpty()) { it_y = index.erase(it_y) - 1; @@ -544,6 +544,47 @@ void QSpanCollection::updateRemovedColumns(int start, int end) qDeleteAll(toBeDeleted); } +#ifdef QT_BUILD_INTERNAL +/*! + \internal + Checks whether the span index structure is self-consistent, and consistent with the spans list. +*/ +bool QSpanCollection::checkConsistency() const +{ + for (Index::const_iterator it_y = index.begin(); it_y != index.end(); ++it_y) { + int y = -it_y.key(); + const SubIndex &subIndex = it_y.value(); + for (SubIndex::const_iterator it = subIndex.begin(); it != subIndex.end(); ++it) { + int x = -it.key(); + Span *span = it.value(); + if (!spans.contains(span) || span->left() != x + || y < span->top() || y > span->bottom()) + return false; + } + } + + foreach (const Span *span, spans) { + if (span->width() < 1 || span->height() < 1 + || (span->width() == 1 && span->height() == 1)) + return false; + for (int y = span->top(); y <= span->bottom(); ++y) { + Index::const_iterator it_y = index.find(-y); + if (it_y == index.end()) { + if (y == span->top()) + return false; + else + continue; + } + const SubIndex &subIndex = it_y.value(); + SubIndex::const_iterator it = subIndex.find(-span->left()); + if (it == subIndex.end() || it.value() != span) + return false; + } + } + return true; +} +#endif + class QTableCornerButton : public QAbstractButton { Q_OBJECT diff --git a/src/gui/itemviews/qtableview_p.h b/src/gui/itemviews/qtableview_p.h index 9fa14c2..6b19ded 100644 --- a/src/gui/itemviews/qtableview_p.h +++ b/src/gui/itemviews/qtableview_p.h @@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE * The key of the first map is the row where the subspan starts, the value of the first map is * a list (map) of all subspans that starts at the same row. It is indexed with its row */ -class QSpanCollection +class Q_AUTOTEST_EXPORT QSpanCollection { public: struct Span @@ -112,6 +112,10 @@ public: void updateRemovedRows(int start, int end); void updateRemovedColumns(int start, int end); +#ifdef QT_BUILD_INTERNAL + bool checkConsistency() const; +#endif + typedef QLinkedList SpanList; SpanList spans; //lists of all spans private: diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 8f8781d..fe2794f 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -41,6 +41,7 @@ #include +#include #include #include "../../shared/util.h" #include "private/qapplication_p.h" @@ -58,6 +59,13 @@ } \ } while(0) +#ifdef QT_BUILD_INTERNAL +#define VERIFY_SPANS_CONSISTENCY(TEST_VIEW_) \ + QVERIFY(static_cast(QObjectPrivate::get(TEST_VIEW_))->spans.checkConsistency()) +#else +#define VERIFY_SPANS_CONSISTENCY(TEST_VIEW_) (void)false +#endif + typedef QList IntList; Q_DECLARE_METATYPE(IntList) @@ -188,6 +196,7 @@ private slots: void task248688_autoScrollNavigation(); void task259308_scrollVerticalHeaderSwappedSections(); void task191545_dragSelectRows(); + void taskQTBUG_5062_spansInconsistency(); void mouseWheel_data(); void mouseWheel(); @@ -2899,6 +2908,8 @@ void tst_QTableView::span() view.clearSpans(); QCOMPARE(view.rowSpan(row, column), 1); QCOMPARE(view.columnSpan(row, column), 1); + + VERIFY_SPANS_CONSISTENCY(&view); } typedef QVector SpanList; @@ -3034,6 +3045,8 @@ void tst_QTableView::spans() QCOMPARE(view.columnSpan(pos.x(), pos.y()), expectedColumnSpan); QCOMPARE(view.rowSpan(pos.x(), pos.y()), expectedRowSpan); + + VERIFY_SPANS_CONSISTENCY(&view); } void tst_QTableView::spansAfterRowInsertion() @@ -3068,6 +3081,8 @@ void tst_QTableView::spansAfterRowInsertion() view.model()->insertRows(12, 2); QCOMPARE(view.rowSpan(7, 3), 5); QCOMPARE(view.columnSpan(7, 3), 3); + + VERIFY_SPANS_CONSISTENCY(&view); } void tst_QTableView::spansAfterColumnInsertion() @@ -3102,6 +3117,8 @@ void tst_QTableView::spansAfterColumnInsertion() view.model()->insertColumns(12, 2); QCOMPARE(view.rowSpan(3, 7), 3); QCOMPARE(view.columnSpan(3, 7), 5); + + VERIFY_SPANS_CONSISTENCY(&view); } void tst_QTableView::spansAfterRowRemoval() @@ -3139,6 +3156,8 @@ void tst_QTableView::spansAfterRowRemoval() QCOMPARE(view.columnSpan(span.top(), span.left()), span.width()); QCOMPARE(view.rowSpan(span.top(), span.left()), span.height()); } + + VERIFY_SPANS_CONSISTENCY(&view); } void tst_QTableView::spansAfterColumnRemoval() @@ -3177,6 +3196,8 @@ void tst_QTableView::spansAfterColumnRemoval() QCOMPARE(view.columnSpan(span.left(), span.top()), span.height()); QCOMPARE(view.rowSpan(span.left(), span.top()), span.width()); } + + VERIFY_SPANS_CONSISTENCY(&view); } class Model : public QAbstractTableModel { @@ -3845,5 +3866,22 @@ void tst_QTableView::task234926_setHeaderSorting() QCOMPARE(model.stringList() , sortedDataD); } +void tst_QTableView::taskQTBUG_5062_spansInconsistency() +{ + const int nRows = 5; + const int nColumns = 5; + + QtTestTableModel model(nRows, nColumns); + QtTestTableView view; + view.setModel(&model); + + for (int i = 0; i < nRows; ++i) + view.setSpan(i, 0, 1, nColumns); + view.setSpan(2, 0, 1, 1); + view.setSpan(3, 0, 1, 1); + + VERIFY_SPANS_CONSISTENCY(&view); +} + QTEST_MAIN(tst_QTableView) #include "tst_qtableview.moc" -- cgit v0.12 From 51f1d68addd23516d7e6e252e476feac0a95d0c0 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 28 Oct 2009 15:55:47 +0100 Subject: Fix warning in qvariant.h header + make sure QVariant in QVariant works as expected Also add more test Reviewed-by: Thierry --- src/corelib/kernel/qvariant.h | 39 ++---- tests/auto/qvariant/tst_qvariant.cpp | 245 +++++++++++++++++++++++++++++++++++ 2 files changed, 257 insertions(+), 27 deletions(-) diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 4cce529..a1ab4e9 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -456,9 +456,9 @@ template inline void qVariantSetValue(QVariant &v, const T &t) { //if possible we reuse the current QVariant private - const int type = qMetaTypeId(reinterpret_cast(0)); + const uint type = qMetaTypeId(reinterpret_cast(0)); QVariant::Private &d = v.data_ptr(); - if (v.isDetached() && (type <= int(QVariant::Char) || type == d.type)) { + if (v.isDetached() && (type <= uint(QVariant::Char) || type == d.type)) { d.type = type; d.is_null = false; T *old = reinterpret_cast(d.is_shared ? d.data.shared->ptr : &d.data.ptr); @@ -470,6 +470,13 @@ inline void qVariantSetValue(QVariant &v, const T &t) } } +template <> +inline void qVariantSetValue(QVariant &v, const QVariant &t) +{ + v = t; +} + + inline QVariant::QVariant() {} inline bool QVariant::isValid() const { return d.type != Invalid; } @@ -559,9 +566,7 @@ inline bool operator!=(const QVariant &v1, const QVariantComparisonHelper &v2) #endif #ifndef QT_MOC -#if !defined qdoc && defined Q_CC_MSVC && _MSC_VER < 1300 - -template T qvariant_cast(const QVariant &v, T * = 0) +template inline T qvariant_cast(const QVariant &v) { const int vid = qMetaTypeId(static_cast(0)); if (vid == v.userType()) @@ -574,28 +579,9 @@ template T qvariant_cast(const QVariant &v, T * = 0) return T(); } -template -inline T qVariantValue(const QVariant &variant, T *t = 0) -{ return qvariant_cast(variant, t); } - -template -inline bool qVariantCanConvert(const QVariant &variant, T *t = 0) +template<> inline QVariant qvariant_cast(const QVariant &v) { - return variant.canConvert(static_cast(qMetaTypeId(t))); -} -#else - -template T qvariant_cast(const QVariant &v) -{ - const int vid = qMetaTypeId(static_cast(0)); - if (vid == v.userType()) - return *reinterpret_cast(v.constData()); - if (vid < int(QMetaType::User)) { - T t; - if (qvariant_cast_helper(v, QVariant::Type(vid), &t)) - return t; - } - return T(); + return v; } template @@ -609,7 +595,6 @@ inline bool qVariantCanConvert(const QVariant &variant) qMetaTypeId(static_cast(0)))); } #endif -#endif Q_DECLARE_SHARED(QVariant) Q_DECLARE_TYPEINFO(QVariant, Q_MOVABLE_TYPE); diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index de4d7b4..61e9a4f 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -270,6 +270,8 @@ private slots: void task256984_setValue(); void numericalConvert(); + void moreCustomTypes(); + void variantInVariant(); }; Q_DECLARE_METATYPE(QDate) @@ -3135,7 +3137,250 @@ void tst_QVariant::numericalConvert() } +template void playWithVariant(const T &orig, bool isNull, const QString &toString, double toDouble, bool toBool) +{ + QVariant v = QVariant::fromValue(orig); + QVERIFY(v.isValid()); + QCOMPARE(v.isNull(), isNull); + QCOMPARE(v.toString(), toString); + QCOMPARE(v.toDouble(), toDouble); + QCOMPARE(v.toBool(), toBool); + QCOMPARE(qvariant_cast(v), orig); + + { + QVariant v2 = v; + QCOMPARE(v2, v); + QVERIFY(v2.isValid()); + QCOMPARE(v2.isNull(), isNull); + QCOMPARE(v2.toString(), toString); + QCOMPARE(v2.toDouble(), toDouble); + QCOMPARE(v2.toBool(), toBool); + QCOMPARE(qvariant_cast(v2), orig); + + QVariant v3; + v = QVariant(); + QCOMPARE(v3, v); + v = v2; + QCOMPARE(v, v2); + QCOMPARE(qvariant_cast(v2), qvariant_cast(v)); + QCOMPARE(v2.toString(), toString); + v3 = qVariantFromValue(orig); + + QVERIFY(v3.isValid()); + QCOMPARE(v3.isNull(), isNull); + QCOMPARE(v3.toString(), toString); + QCOMPARE(v3.toDouble(), toDouble); + QCOMPARE(v3.toBool(), toBool); + QCOMPARE(qvariant_cast(v3), qvariant_cast(v)); + } + + QVERIFY(v.isValid()); + QCOMPARE(v.isNull(), isNull); + QCOMPARE(v.toString(), toString); + QCOMPARE(v.toDouble(), toDouble); + QCOMPARE(v.toBool(), toBool); + QCOMPARE(qvariant_cast(v), orig); + + if (qMetaTypeId() != qMetaTypeId()) { + QCOMPARE(v.userType(), qMetaTypeId()); + QCOMPARE(QVariant::typeToName(QVariant::Type(v.userType())), QMetaType::typeName(qMetaTypeId())); + } +} + + +struct MyPrimitive +{ + char x, y; + bool operator==(const MyPrimitive &o) const + { + return x == o.x && y == o.y; + } +}; +Q_DECLARE_TYPEINFO(MyPrimitive, Q_PRIMITIVE_TYPE); + +struct MyData +{ + void *ptr; + MyData() : ptr(this) {} + ~MyData() { Q_ASSERT(ptr == this); } + MyData(const MyData& o) : ptr(this) { Q_ASSERT(o.ptr == &o); } + MyData &operator=(const MyData &o) + { + Q_ASSERT(ptr == this); + Q_ASSERT(o.ptr == &o); + return *this; + } + bool operator==(const MyData &o) const + { + Q_ASSERT(ptr == this); + Q_ASSERT(o.ptr == &o); + return true; + } +}; + +struct MyMovable +{ + static int count; + int v; + MyMovable() { v = count++; } + ~MyMovable() { count--; } + MyMovable(const MyMovable &o) : v(o.v) { count++; } + + bool operator==(const MyMovable &o) const + { + return v == o.v; + } +}; + +int MyMovable::count = 0; + + +Q_DECLARE_TYPEINFO(MyMovable, Q_MOVABLE_TYPE); + +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(MyPrimitive) +Q_DECLARE_METATYPE(MyData) +Q_DECLARE_METATYPE(MyMovable) +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(MyPrimitive *) +Q_DECLARE_METATYPE(MyData *) +Q_DECLARE_METATYPE(MyMovable *) + +void tst_QVariant::moreCustomTypes() +{ + { + QList listSize; + playWithVariant(listSize, false, QString(), 0, false); + listSize << QSize(4,5) << QSize(89,23) << QSize(5,6); + playWithVariant(listSize, false, QString(), 0, false); + } + + { + QString str; + playWithVariant(str, true, QString(), 0, false); + str = QString::fromLatin1("123456789.123"); + playWithVariant(str, false, str, 123456789.123, true); + } + + { + QSize size; + playWithVariant(size, false, QString(), 0, false); + playWithVariant(QSize(45,78), false, QString(), 0, false); + } + + { + MyData d; + playWithVariant(d, false, QString(), 0, false); + playWithVariant(&d, false, QString(), 0, false); + QList l; + playWithVariant(l, false, QString(), 0, false); + l << MyData() << MyData(); + playWithVariant(l, false, QString(), 0, false); + } + + { + MyPrimitive d = { 4, 5 }; + playWithVariant(d, false, QString(), 0, false); + playWithVariant(&d, false, QString(), 0, false); + QList l; + playWithVariant(l, false, QString(), 0, false); + l << d; + playWithVariant(l, false, QString(), 0, false); + } + + { + MyMovable d; + playWithVariant(d, false, QString(), 0, false); + playWithVariant(&d, false, QString(), 0, false); + QList l; + playWithVariant(l, false, QString(), 0, false); + l << MyMovable() << d; + playWithVariant(l, false, QString(), 0, false); + } + QCOMPARE(MyMovable::count, 0); + + { + playWithVariant(12.12, false, "12.12", 12.12, true); + playWithVariant(12.12f, false, "12.12", 12.12f, true); + playWithVariant('a', false, "a", 'a', true); + playWithVariant((unsigned char)('a'), false, "a", 'a', true); + playWithVariant( quint8(12), false, "\xc", 12, true); + playWithVariant( qint8(13), false, "\xd", 13, true); + playWithVariant(quint16(14), false, "14", 14, true); + playWithVariant( qint16(15), false, "15", 15, true); + playWithVariant(quint32(16), false, "16", 16, true); + playWithVariant( qint32(17), false, "17", 17, true); + playWithVariant(quint64(18), false, "18", 18, true); + playWithVariant( qint64(19), false, "19", 19, true); + playWithVariant( qint8(-12), false, "\xf4", -12, true); + playWithVariant( qint16(-13), false, "-13", -13, true); + playWithVariant( qint32(-14), false, "-14", -14, true); + playWithVariant( qint64(-15), false, "-15", -15, true); + playWithVariant(quint64(0), false, "0", 0, false); + playWithVariant( true, false, "true", 1, true); + playWithVariant( false, false, "false", 0, false); + + playWithVariant(QString("hello\n"), false, "hello\n", 0, true); + } + + { + int i = 5; + playWithVariant((void *)(&i), false, QString(), 0, false); + playWithVariant((void *)(0), false, QString(), 0, false); + } + + { + QVariant v1 = QVariant::fromValue(5); + QVariant v2 = QVariant::fromValue(5.0); + QVariant v3 = QVariant::fromValue(quint16(5)); + QVariant v4 = 5; + QVariant v5 = QVariant::fromValue(MyPrimitive()); + QVariant v6 = QVariant::fromValue(MyMovable()); + QVariant v7 = QVariant::fromValue(MyData()); + playWithVariant(v1, false, "5", 5, true); + playWithVariant(v2, false, "5", 5, true); + playWithVariant(v3, false, "5", 5, true); + playWithVariant(v4, false, "5", 5, true); + + playWithVariant(v5, false, QString(), 0, false); + } +} + + +void tst_QVariant::variantInVariant() +{ + QVariant var1 = 5; + QCOMPARE(var1.type(), QVariant::Int); + QVariant var2 = var1; + QCOMPARE(var2, var1); + QCOMPARE(var2.type(), QVariant::Int); + QVariant var3 = QVariant::fromValue(var1); + QCOMPARE(var3, var1); + QCOMPARE(var3.type(), QVariant::Int); + QVariant var4 = qvariant_cast(var1); + QCOMPARE(var4, var1); + QCOMPARE(var4.type(), QVariant::Int); + QVariant var5; + var5 = var1; + QCOMPARE(var5, var1); + QCOMPARE(var5.type(), QVariant::Int); + QVariant var6; + var6.setValue(var1); + QCOMPARE(var6, var1); + QCOMPARE(var6.type(), QVariant::Int); + + QCOMPARE(QVariant::fromValue(var1), QVariant::fromValue(var2)); + QCOMPARE(qvariant_cast(var3), QVariant::fromValue(var4)); + QCOMPARE(qvariant_cast(var5), qvariant_cast(var6)); + + QString str("hello"); + QVariant var8 = qvariant_cast(QVariant::fromValue(QVariant::fromValue(str))); + QCOMPARE((int)var8.type(), (int)QVariant::String); + QCOMPARE(qvariant_cast(QVariant(qvariant_cast(var8))), str); +} QTEST_MAIN(tst_QVariant) #include "tst_qvariant.moc" -- cgit v0.12 From f360555f3c7ded3c729ce972fbd65f035876b1b4 Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 28 Oct 2009 16:09:45 +0100 Subject: Fixed crash/drawing artifacts on rotation change on Symbian. On every beginDataAccess on the pixmap data, we checked the value of the pointer to the bits and only updated the image if the pointer had changed. However, we didn't take into account that the pointer could be the same, even though the dimensions were different, since malloc() could return the same memory area. This would lead to painting into an image that had the wrong dimensions, which again led to either crashes or image shearing. Fixed by checking the dimensions before deciding to update the image. Task: QTBUG-4815 RevBy: Jason Barron --- src/gui/image/qpixmap_s60.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index c56e9b7..7086341 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -684,9 +684,10 @@ void QS60PixmapData::beginDataAccess() uchar* newBytes = (uchar*)cfbsBitmap->DataAddress(); - if (newBytes == bytes) - return; + TSize size = cfbsBitmap->SizeInPixels(); + if (newBytes == bytes && image.width() == size.iWidth && image.height() == size.iHeight) + return; bytes = newBytes; TDisplayMode mode = cfbsBitmap->DisplayMode(); @@ -695,8 +696,6 @@ void QS60PixmapData::beginDataAccess() if (format == QImage::Format_ARGB32) format = QImage::Format_ARGB32_Premultiplied; // pixel data is actually in premultiplied format - TSize size = cfbsBitmap->SizeInPixels(); - QVector savedColorTable; if (!image.isNull()) savedColorTable = image.colorTable(); -- cgit v0.12 From f32abd2b9febdeadeb5536d0318f77be4180f142 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 29 Oct 2009 17:01:36 +1000 Subject: Compile with -no-qt3support Reviewed-by: andreas --- src/gui/itemviews/qtreeview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index bad9dfe..be64c46 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -1226,8 +1226,8 @@ bool QTreeView::viewportEvent(QEvent *event) if (oldIndex != newIndex) { QRect oldRect = visualRect(oldIndex); QRect newRect = visualRect(newIndex); - oldRect.rLeft() -= d->indent; - newRect.rLeft() -= d->indent; + oldRect.setLeft(oldRect.left() - d->indent); + newRect.setLeft(newRect.left() - d->indent); //we need to paint the whole items (including the decoration) so that when the user //moves the mouse over those elements they are updated viewport()->update(oldRect); -- cgit v0.12 From 25502811723a026a38c0a861a6a304d24b8e6a95 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 29 Oct 2009 09:37:26 +0100 Subject: Stabilize tests --- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 2 +- tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp | 4 +++- tests/auto/qtreeview/tst_qtreeview.cpp | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 2c948cc..28f249f 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -7463,7 +7463,7 @@ void tst_QGraphicsItem::moveLineItem() // Make sure the calculated region is correct. item->update(); QTest::qWait(10); - QCOMPARE(view.paintedRegion, expectedRegion); + QTRY_COMPARE(view.paintedRegion, expectedRegion); view.reset(); // Old position: (50, 50) diff --git a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp index 9dfd486..7d98748 100644 --- a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp +++ b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp @@ -45,6 +45,8 @@ #include #include #include +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= @@ -356,7 +358,7 @@ void tst_QGraphicsSceneIndex::clear() MyItem *item = new MyItem; scene.addItem(item); qApp->processEvents(); - QCOMPARE(item->numPaints, 1); + QTRY_COMPARE(item->numPaints, 1); } QTEST_MAIN(tst_QGraphicsSceneIndex) diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index 1429771..75c02e9 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -3552,6 +3552,7 @@ void tst_QTreeView::doubleClickedWithSpans() view.setModel(&model); view.setFirstColumnSpanned(0, QModelIndex(), true); view.show(); + QTest::qWaitForWindowShown(&view); QPoint p(10, 10); QCOMPARE(view.indexAt(p), model.index(0, 0)); -- cgit v0.12 From f5c553078b7381c3dff7d0bd6b9990a7acf86abb Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Thu, 29 Oct 2009 10:13:18 +0100 Subject: Fixed highlighting of string components when inputting Japanese text. After typing a sentence in Japanese, and before committing the sentence, you can select each component and choose a different character representation for it. This commit fixes highlighting of the currently selected sentence component which was broken by commit 55137901. Reviewed-by: Marius Storm-Olsen --- src/gui/inputmethod/qwininputcontext_win.cpp | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/src/gui/inputmethod/qwininputcontext_win.cpp b/src/gui/inputmethod/qwininputcontext_win.cpp index e9ab870..ef2f5c0 100644 --- a/src/gui/inputmethod/qwininputcontext_win.cpp +++ b/src/gui/inputmethod/qwininputcontext_win.cpp @@ -327,28 +327,13 @@ static int getCursorPosition(HIMC himc) static QString getString(HIMC himc, DWORD dwindex, int *selStart = 0, int *selLength = 0) { - static wchar_t *buffer = 0; - static int buflen = 0; - - int len = getCompositionString(himc, dwindex, 0, 0) + 1; - if (!buffer || len > buflen) { - delete [] buffer; - buflen = qMin(len, 256); - buffer = new wchar_t[buflen]; - } - - len = getCompositionString(himc, dwindex, buffer, buflen * sizeof(wchar_t)); + const int bufferSize = 256; + wchar_t buffer[bufferSize]; + int len = getCompositionString(himc, dwindex, buffer, bufferSize * sizeof(wchar_t)); if (selStart) { - static wchar_t *attrbuffer = 0; - static int attrbuflen = 0; - int attrlen = getCompositionString(himc, dwindex, 0, 0) + 1; - if (!attrbuffer || attrlen> attrbuflen) { - delete [] attrbuffer; - attrbuflen = qMin(attrlen, 256); - attrbuffer = new wchar_t[attrbuflen]; - } - attrlen = getCompositionString(himc, GCS_COMPATTR, attrbuffer, attrbuflen * sizeof(wchar_t)); + char attrbuffer[bufferSize]; + int attrlen = getCompositionString(himc, GCS_COMPATTR, attrbuffer, bufferSize); *selStart = attrlen+1; *selLength = -1; for (int i = 0; i < attrlen; i++) { -- cgit v0.12 From d5a228fbd44f7dd92a10981a5c835db66e3ea6f8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 29 Oct 2009 09:59:40 +0100 Subject: Fix compilation in QContiguousCache. Reviewed-by: TrustMe --- src/corelib/tools/qcontiguouscache.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index ef5b238..3785938 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -216,8 +216,8 @@ void QContiguousCache::setCapacity(int asize) if (asize == d->alloc) return; detach(); - union { QContiguousCacheData *p; QContiguousCacheTypedData *d; } x; - x.p = malloc(asize); + union { QContiguousCacheData *d; QContiguousCacheTypedData *p; } x; + x.d = malloc(asize); x.d->alloc = asize; x.d->count = qMin(d->count, asize); x.d->offset = d->offset + d->count - x.d->count; @@ -239,7 +239,7 @@ void QContiguousCache::setCapacity(int asize) src--; } /* free old */ - free(d); + free(p); d = x.d; } -- cgit v0.12 From 8307d3511b35adbb945948eda2cf54bbd3c0a20e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 29 Oct 2009 10:28:28 +0100 Subject: Update confusing qWarning message. Reviewed-by: Olivier Goffart --- src/corelib/kernel/qmetaobject.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index f98c449..71afc5b 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -574,8 +574,8 @@ int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject, co if (i >= 0 && m && m->d.superdata) { int conflict = m->d.superdata->indexOfMethod(signal); if (conflict >= 0) - qWarning("QMetaObject::indexOfSignal:%s: Conflict with %s::%s", - m->d.stringdata, m->d.superdata->d.stringdata, signal); + qWarning("QMetaObject::indexOfSignal: signal %s from %s redefined in %s", + signal, m->d.superdata->d.stringdata, m->d.stringdata); } #endif return i; -- cgit v0.12 From ffe49ed60c9ee778b9999ee4145b44851b053f9f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 29 Oct 2009 10:31:48 +0100 Subject: Fix compilation on Mac: there's no malloc.h there Reviewed-by: Trust Me --- src/corelib/global/qmalloc.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp index e33f77c..3584c50 100644 --- a/src/corelib/global/qmalloc.cpp +++ b/src/corelib/global/qmalloc.cpp @@ -42,7 +42,10 @@ #include "qplatformdefs.h" #include -#include + +#ifdef Q_OS_WIN +# include +#endif /* Define the container allocation functions in a separate file, so that our @@ -66,10 +69,6 @@ void *qRealloc(void *ptr, size_t size) return ::realloc(ptr, size); } -#if ((defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600)) -# define HAVE_POSIX_MEMALIGN -#endif - void *qMallocAligned(size_t size, size_t alignment) { #if defined(Q_OS_WIN) -- cgit v0.12 From 00908877d47c72e178cb0cee643229e3f3e1c64e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 29 Oct 2009 10:39:16 +0100 Subject: Fix autotest for QMainWindow --- src/gui/widgets/qdockarealayout.cpp | 11 +++++++---- src/gui/widgets/qdockarealayout_p.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index df131ee..6895e09 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -2259,7 +2259,7 @@ QRect QDockAreaLayoutInfo::tabContentRect() const ** QDockAreaLayout */ -QDockAreaLayout::QDockAreaLayout(QMainWindow *win) : have_central(false) +QDockAreaLayout::QDockAreaLayout(QMainWindow *win) : fallbackToSizeHints(true) { mainWindow = win; sep = win->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, win); @@ -2346,6 +2346,9 @@ bool QDockAreaLayout::restoreState(QDataStream &stream, const QList(cornerData[i]); } + + if (!testing) + fallbackToSizeHints = false; } return ok; @@ -2582,9 +2585,7 @@ void QDockAreaLayout::getGrid(QVector *_ver_struct_list, { QSize center_hint(0, 0); QSize center_min(0, 0); - const bool old_have_central = have_central; - have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty(); - const bool fallbackToSizeHints = !old_have_central && have_central; + const bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty(); if (have_central) { center_hint = centralWidgetRect.size(); if (!center_hint.isValid()) @@ -2630,6 +2631,8 @@ void QDockAreaLayout::getGrid(QVector *_ver_struct_list, QSize bottom_max = docks[QInternal::BottomDock].maximumSize(); bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min); + fallbackToSizeHints = !have_central; + if (_ver_struct_list != 0) { QVector &ver_struct_list = *_ver_struct_list; ver_struct_list.resize(3); diff --git a/src/gui/widgets/qdockarealayout_p.h b/src/gui/widgets/qdockarealayout_p.h index 1ed14ce..065890d 100644 --- a/src/gui/widgets/qdockarealayout_p.h +++ b/src/gui/widgets/qdockarealayout_p.h @@ -233,7 +233,7 @@ public: QDockAreaLayout(QMainWindow *win); QDockAreaLayoutInfo docks[4]; int sep; // separator extent - bool have_central; + bool fallbackToSizeHints; //determines if we should use the sizehint for the dock areas (true until the layout is restored or the central widget is set) mutable QVector separatorWidgets; bool isValid() const; -- cgit v0.12 From 7d5b560f71e0f11c20b7ebef11f3095e760ca32c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 28 Oct 2009 14:44:10 +0100 Subject: Added some optimizations to the blur and drop shadow GL filters. * Use ExpandToTransparentBorderPadMode since we can use GL_CLAMP_TO_EDGE to clamp to the texture. * Shrink the bounding rects reported by the blur and drop shadow filters (expanding by 2 * radius isn't needed). * Use a single-pass blur for radii <= 3 to avoid the overhead of rendering to an FBO. * Made the fast blur setting generate filters for only a predefined set of radii, and then use the actual blur radius to spread the sample points outwards. * Optimized the generated program to rely less on temporary variables, as those seemed to not be handled very well by certain GLSL compilers. Reviewed-by: Gunnar Sletta --- src/gui/effects/qgraphicseffect.cpp | 16 +- src/gui/effects/qgraphicseffect_p.h | 8 +- src/gui/graphicsview/qgraphicsitem.cpp | 3 +- src/gui/image/qpixmapfilter.cpp | 13 +- .../gl2paintengineex/qglengineshadermanager.cpp | 2 +- .../gl2paintengineex/qglengineshadersource_p.h | 16 +- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 8 +- src/opengl/qglpixmapfilter.cpp | 436 +++++++++++++-------- 8 files changed, 307 insertions(+), 195 deletions(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 9ed003c..3a6bab5 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -101,6 +101,7 @@ #include #include +#include #include #include #include @@ -260,12 +261,13 @@ QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offse } QPixmap pm; - if (d->m_cachedSystem == system) + if (d->m_cachedSystem == system && d->m_cachedMode == mode) QPixmapCache::find(d->m_cacheKey, &pm); if (pm.isNull()) { pm = d->pixmap(system, &d->m_cachedOffset, mode); d->m_cachedSystem = system; + d->m_cachedMode = mode; d->invalidateCache(); d->m_cacheKey = QPixmapCache::insert(pm); @@ -708,9 +710,13 @@ void QGraphicsBlurEffect::draw(QPainter *painter, QGraphicsEffectSource *source) return; } + QGraphicsEffectSource::PixmapPadMode mode = QGraphicsEffectSource::ExpandToEffectRectPadMode; + if (painter->paintEngine()->type() == QPaintEngine::OpenGL2) + mode = QGraphicsEffectSource::ExpandToTransparentBorderPadMode; + // Draw pixmap in device coordinates to avoid pixmap scaling. QPoint offset; - const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); + const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset, mode); QTransform restoreTransform = painter->worldTransform(); painter->setWorldTransform(QTransform()); d->filter->draw(painter, offset, pixmap); @@ -893,9 +899,13 @@ void QGraphicsDropShadowEffect::draw(QPainter *painter, QGraphicsEffectSource *s return; } + QGraphicsEffectSource::PixmapPadMode mode = QGraphicsEffectSource::ExpandToEffectRectPadMode; + if (painter->paintEngine()->type() == QPaintEngine::OpenGL2) + mode = QGraphicsEffectSource::ExpandToTransparentBorderPadMode; + // Draw pixmap in device coordinates to avoid pixmap scaling. QPoint offset; - const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); + const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset, mode); QTransform restoreTransform = painter->worldTransform(); painter->setWorldTransform(QTransform()); d->filter->draw(painter, offset, pixmap); diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h index dff84a1..1ed7103 100644 --- a/src/gui/effects/qgraphicseffect_p.h +++ b/src/gui/effects/qgraphicseffect_p.h @@ -66,7 +66,12 @@ class QGraphicsEffectSourcePrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QGraphicsEffectSource) public: - QGraphicsEffectSourcePrivate() : QObjectPrivate() {} + QGraphicsEffectSourcePrivate() + : QObjectPrivate() + , m_cachedSystem(Qt::DeviceCoordinates) + , m_cachedMode(QGraphicsEffectSource::ExpandToTransparentBorderPadMode) + {} + virtual ~QGraphicsEffectSourcePrivate() { invalidateCache(); } virtual void detach() = 0; virtual QRectF boundingRect(Qt::CoordinateSystem system) const = 0; @@ -88,6 +93,7 @@ public: private: mutable Qt::CoordinateSystem m_cachedSystem; + mutable QGraphicsEffectSource::PixmapPadMode m_cachedMode; mutable QPoint m_cachedOffset; mutable QPixmapCache::Key m_cacheKey; }; diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 7d9390c..738c6e3 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -10703,7 +10703,8 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP if (mode == QGraphicsEffectSource::ExpandToEffectRectPadMode) { effectRect = item->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); } else if (mode == QGraphicsEffectSource::ExpandToTransparentBorderPadMode) { - effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect(); + // adjust by 1.5 to account for cosmetic pens + effectRect = sourceRect.adjusted(-1.5, -1.5, 1.5, 1.5).toAlignedRect(); } else { effectRect = sourceRect.toAlignedRect(); } diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp index f9ac79f..d0de03e 100644 --- a/src/gui/image/qpixmapfilter.cpp +++ b/src/gui/image/qpixmapfilter.cpp @@ -584,7 +584,7 @@ Qt::RenderHint QPixmapBlurFilter::blurHint() const QRectF QPixmapBlurFilter::boundingRectFor(const QRectF &rect) const { Q_D(const QPixmapBlurFilter); - const qreal delta = d->radius * 2; + const qreal delta = d->radius + 1; return rect.adjusted(-delta, -delta, delta, delta); } @@ -1057,14 +1057,9 @@ void QPixmapDropShadowFilter::setOffset(const QPointF &offset) QRectF QPixmapDropShadowFilter::boundingRectFor(const QRectF &rect) const { Q_D(const QPixmapDropShadowFilter); - - const qreal delta = qreal(d->radius * 2); - qreal x1 = qMin(rect.left(), rect.left() + d->offset.x() - delta); - qreal y1 = qMin(rect.top(), rect.top() + d->offset.y() - delta); - qreal x2 = qMax(rect.right(), rect.right() + d->offset.x() + delta); - qreal y2 = qMax(rect.bottom(), rect.bottom() + d->offset.y() + delta); - - return QRectF(x1, y1, x2 - x1, y2 - y1); + qreal delta = d->radius + 1; + return rect.adjusted(-2, -2, 2, 2).united( + rect.translated(d->offset).adjusted(-delta, -delta, delta, delta)); } /*! diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index e22303d..af9306f 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -476,7 +476,7 @@ bool QGLEngineShaderManager::useCorrectShaderProg() return false; bool useCustomSrc = customSrcStage != 0; - if (useCustomSrc && srcPixelType != QGLEngineShaderManager::ImageSrc) { + if (useCustomSrc && srcPixelType != QGLEngineShaderManager::ImageSrc && srcPixelType != Qt::TexturePattern) { useCustomSrc = false; qWarning("QGLEngineShaderManager - Ignoring custom shader stage for non image src"); } diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index 3eef808..2407979 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -258,7 +258,7 @@ static const char* const qglslPositionWithTextureBrushVertexShader = "\ uniform mediump vec2 halfViewportSize; \ uniform highp vec2 invertedTextureSize; \ uniform highp mat3 brushTransform; \ - varying highp vec2 brushTextureCoords; \ + varying highp vec2 textureCoords; \ void setPosition(void) { \ gl_Position = pmvMatrix * vertexCoordsArray;\ gl_Position.xy = gl_Position.xy / gl_Position.w; \ @@ -267,7 +267,7 @@ static const char* const qglslPositionWithTextureBrushVertexShader = "\ mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ gl_Position.xy = gl_Position.xy * invertedHTexCoordsZ; \ gl_Position.w = invertedHTexCoordsZ; \ - brushTextureCoords.xy = (hTexCoords.xy * invertedTextureSize) * gl_Position.w; \ + textureCoords.xy = (hTexCoords.xy * invertedTextureSize) * gl_Position.w; \ }"; static const char* const qglslAffinePositionWithTextureBrushVertexShader @@ -278,26 +278,26 @@ static const char* const qglslAffinePositionWithTextureBrushVertexShader // we emulate GL_REPEAT by only taking the fractional part of the texture coords. // TODO: Special case POT textures which don't need this emulation static const char* const qglslTextureBrushSrcFragmentShader = "\ - varying highp vec2 brushTextureCoords; \ + varying highp vec2 textureCoords; \ uniform lowp sampler2D brushTexture; \ lowp vec4 srcPixel() { \ - return texture2D(brushTexture, fract(brushTextureCoords)); \ + return texture2D(brushTexture, fract(textureCoords)); \ }"; #else static const char* const qglslTextureBrushSrcFragmentShader = "\ - varying highp vec2 brushTextureCoords; \ + varying highp vec2 textureCoords; \ uniform lowp sampler2D brushTexture; \ lowp vec4 srcPixel() { \ - return texture2D(brushTexture, brushTextureCoords); \ + return texture2D(brushTexture, textureCoords); \ }"; #endif static const char* const qglslTextureBrushSrcWithPatternFragmentShader = "\ - varying highp vec2 brushTextureCoords; \ + varying highp vec2 textureCoords; \ uniform lowp vec4 patternColor; \ uniform lowp sampler2D brushTexture; \ lowp vec4 srcPixel() { \ - return patternColor * (1.0 - texture2D(brushTexture, brushTextureCoords).r); \ + return patternColor * (1.0 - texture2D(brushTexture, textureCoords).r); \ }"; // Solid Fill Brush diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index b70810d..a9744b3 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -535,7 +535,7 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms() shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col); } - QSizeF invertedTextureSize(1.0 / texPixmap.width(), 1.0 * textureInvertedY / texPixmap.height()); + QSizeF invertedTextureSize(1.0 / texPixmap.width(), 1.0 / texPixmap.height()); shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::InvertedTextureSize), invertedTextureSize); QVector2D halfViewportSize(width*0.5, height*0.5); @@ -550,7 +550,11 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms() QTransform translate(1, 0, 0, 1, -translationPoint.x(), -translationPoint.y()); QTransform gl_to_qt(1, 0, 0, -1, 0, height); - QTransform inv_matrix = gl_to_qt * (brushQTransform * matrix).inverted() * translate; + QTransform inv_matrix; + if (style == Qt::TexturePattern && textureInvertedY == -1) + inv_matrix = gl_to_qt * (QTransform(1, 0, 0, -1, 0, currentBrush->texture().height()) * brushQTransform * matrix).inverted() * translate; + else + inv_matrix = gl_to_qt * (brushQTransform * matrix).inverted() * translate; shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::BrushTransform), inv_matrix); shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::BrushTexture), QT_BRUSH_TEXTURE_UNIT); diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index 656957d..e381a5d 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -104,7 +104,7 @@ public: void setUniforms(QGLShaderProgram *program); - static QByteArray generateGaussianShader(int radius, bool dropShadow = false); + static QByteArray generateGaussianShader(int radius, bool singlePass = false, bool dropShadow = false); protected: bool processGL(QPainter *painter, const QPointF &pos, const QPixmap &src, const QRectF &srcRect) const; @@ -113,6 +113,7 @@ private: mutable QSize m_textureSize; mutable bool m_horizontalBlur; + mutable bool m_singlePass; mutable bool m_haveCached; mutable int m_cachedRadius; @@ -132,6 +133,7 @@ protected: private: mutable QSize m_textureSize; mutable bool m_horizontalBlur; + mutable bool m_singlePass; mutable bool m_haveCached; mutable int m_cachedRadius; @@ -298,123 +300,155 @@ bool QGLPixmapConvolutionFilter::processGL(QPainter *painter, const QPointF &pos return true; } -static const char *qt_gl_blur_filter_fast = - "const int samples = 9;" - "uniform mediump vec2 delta;" - "lowp vec4 customShader(lowp sampler2D src, highp vec2 srcCoords) {" - " mediump vec4 color = vec4(0.0, 0.0, 0.0, 0.0);" - " mediump float offset = (float(samples) - 1.0) / 2.0;" - " for (int i = 0; i < samples; i++) {" - " mediump vec2 coord = srcCoords + delta * (offset - float(i)) / offset;" - " color += texture2D(src, coord);" - " }" - " return color * (1.0 / float(samples));" - "}"; - -static const char *qt_gl_drop_shadow_filter_fast = - "const int samples = 9;" - "uniform mediump vec2 delta;" - "uniform mediump vec4 shadowColor;" - "lowp vec4 customShader(lowp sampler2D src, highp vec2 srcCoords) {" - " mediump vec4 color = vec4(0.0, 0.0, 0.0, 0.0);" - " mediump float offset = (float(samples) - 1.0) / 2.0;" - " for (int i = 0; i < samples; i++) {" - " mediump vec2 coord = srcCoords + delta * (offset - float(i)) / offset;" - " color += texture2D(src, coord).a * shadowColor;" - " }" - " return color * (1.0 / float(samples));" - "}"; +static const char *qt_gl_texture_sampling_helper = + "lowp float texture2DAlpha(lowp sampler2D src, highp vec2 srcCoords) {\n" + " return texture2D(src, srcCoords).a;\n" + "}\n"; + +static const char *qt_gl_clamped_texture_sampling_helper = + "highp vec4 texture_dimensions;\n" // x = width, y = height, z = 0.5/width, w = 0.5/height + "lowp float clampedTexture2DAlpha(lowp sampler2D src, highp vec2 srcCoords) {\n" + " highp vec2 clampedCoords = clamp(srcCoords, texture_dimensions.zw, vec2(1.0) - texture_dimensions.zw);\n" + " highp vec2 t = clamp(min(srcCoords, vec2(1.0) - srcCoords) * srcDim + 0.5, 0.0, 1.0);\n" + " return texture2D(src, clampedCoords).a * t.x * t.y;\n" + "}\n" + "lowp vec4 clampedTexture2D(lowp sampler2D src, highp vec2 srcCoords) {\n" + " highp vec2 clampedCoords = clamp(srcCoords, texture_dimensions.zw, vec2(1.0) - texture_dimensions.zw);\n" + " highp vec2 t = clamp(min(srcCoords, vec2(1.0) - srcCoords) * srcDim + 0.5, 0.0, 1.0);\n" + " return texture2D(src, clampedCoords) * t.x * t.y;\n" + "}\n"; + +static QByteArray qt_gl_convertToClamped(const QByteArray &source) +{ + QByteArray result; + result.append(qt_gl_clamped_texture_sampling_helper); + result.append(QByteArray(source).replace("texture2DAlpha", "clampedTexture2DAlpha") + .replace("texture2D", "clampedTexture2D")); + return result; +} QGLPixmapBlurFilter::QGLPixmapBlurFilter(Qt::RenderHint hint) : m_haveCached(false) - , m_cachedRadius(5) + , m_cachedRadius(0) , m_hint(hint) { - if (hint == Qt::PerformanceHint) { - QGLPixmapBlurFilter *filter = const_cast(this); - filter->setSource(qt_gl_blur_filter_fast); - m_haveCached = true; - } } bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const QPixmap &src, const QRectF &) const { QGLPixmapBlurFilter *filter = const_cast(this); - int radius = qRound(this->radius()); - if (!m_haveCached || (m_hint == Qt::QualityHint && radius != m_cachedRadius)) { - // Only regenerate the shader from source if parameters have changed. - m_haveCached = true; - m_cachedRadius = radius; - filter->setSource(generateGaussianShader(radius)); + int actualRadius = qRound(radius()); + int filterRadius = actualRadius; + int fastRadii[] = { 1, 2, 3, 5, 8, 15, 25 }; + if (m_hint == Qt::PerformanceHint) { + uint i = 0; + for (; i < (sizeof(fastRadii)/sizeof(*fastRadii))-1; ++i) { + if (fastRadii[i+1] > filterRadius) + break; + } + filterRadius = fastRadii[i]; } - QGLFramebufferObjectFormat format; - format.setInternalTextureFormat(GLenum(src.hasAlphaChannel() ? GL_RGBA : GL_RGB)); - QGLFramebufferObject *fbo = qgl_fbo_pool()->acquire(src.size(), format); + m_singlePass = filterRadius <= 3; - if (!fbo) - return false; + if (!m_haveCached || filterRadius != m_cachedRadius) { + // Only regenerate the shader from source if parameters have changed. + m_haveCached = true; + m_cachedRadius = filterRadius; + QByteArray source = generateGaussianShader(filterRadius, m_singlePass); + filter->setSource(source); + } - glBindTexture(GL_TEXTURE_2D, fbo->texture()); + QRect targetRect = QRectF(src.rect()).translated(pos).adjusted(-actualRadius, -actualRadius, actualRadius, actualRadius).toAlignedRect(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glBindTexture(GL_TEXTURE_2D, 0); + if (m_singlePass) { + // prepare for updateUniforms + m_textureSize = src.size(); - // prepare for updateUniforms - m_textureSize = src.size(); + // ensure GL_LINEAR filtering is used + painter->setRenderHint(QPainter::SmoothPixmapTransform); + filter->setOnPainter(painter); + QBrush pixmapBrush = src; + pixmapBrush.setTransform(QTransform::fromTranslate(pos.x(), pos.y())); + painter->fillRect(targetRect, pixmapBrush); + filter->removeFromPainter(painter); + } else { + QGLFramebufferObjectFormat format; + format.setInternalTextureFormat(GLenum(src.hasAlphaChannel() ? GL_RGBA : GL_RGB)); + QGLFramebufferObject *fbo = qgl_fbo_pool()->acquire(targetRect.size(), format); - // horizontal pass, to pixmap - m_horizontalBlur = true; + if (!fbo) + return false; - QPainter fboPainter(fbo); + glBindTexture(GL_TEXTURE_2D, fbo->texture()); - if (src.hasAlphaChannel()) { - glClearColor(0, 0, 0, 0); - glClear(GL_COLOR_BUFFER_BIT); - } + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glBindTexture(GL_TEXTURE_2D, 0); - // ensure GL_LINEAR filtering is used - fboPainter.setRenderHint(QPainter::SmoothPixmapTransform); - filter->setOnPainter(&fboPainter); - fboPainter.drawPixmap(0, 0, src); - filter->removeFromPainter(&fboPainter); - fboPainter.end(); + // prepare for updateUniforms + m_textureSize = src.size(); - QGL2PaintEngineEx *engine = static_cast(painter->paintEngine()); + // horizontal pass, to pixmap + m_horizontalBlur = true; - // vertical pass, to painter - m_horizontalBlur = false; + QPainter fboPainter(fbo); - painter->save(); - // ensure GL_LINEAR filtering is used - painter->setRenderHint(QPainter::SmoothPixmapTransform); - filter->setOnPainter(painter); - engine->drawTexture(src.rect().translated(pos.x(), pos.y()), fbo->texture(), fbo->size(), src.rect().translated(0, fbo->height() - src.height())); - filter->removeFromPainter(painter); - painter->restore(); + if (src.hasAlphaChannel()) { + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); + } - qgl_fbo_pool()->release(fbo); + // ensure GL_LINEAR filtering is used + fboPainter.setRenderHint(QPainter::SmoothPixmapTransform); + filter->setOnPainter(&fboPainter); + QBrush pixmapBrush = src; + pixmapBrush.setTransform(QTransform::fromTranslate(actualRadius, actualRadius)); + fboPainter.fillRect(QRect(0, 0, targetRect.width(), targetRect.height()), pixmapBrush); + filter->removeFromPainter(&fboPainter); + fboPainter.end(); + + QGL2PaintEngineEx *engine = static_cast(painter->paintEngine()); + + // vertical pass, to painter + m_horizontalBlur = false; + m_textureSize = fbo->size(); + + painter->save(); + // ensure GL_LINEAR filtering is used + painter->setRenderHint(QPainter::SmoothPixmapTransform); + filter->setOnPainter(painter); + engine->drawTexture(targetRect, fbo->texture(), fbo->size(), QRect(QPoint(), targetRect.size()).translated(0, fbo->height() - targetRect.height())); + filter->removeFromPainter(painter); + painter->restore(); + + qgl_fbo_pool()->release(fbo); + } return true; } void QGLPixmapBlurFilter::setUniforms(QGLShaderProgram *program) { + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + if (m_hint == Qt::QualityHint) { - if (m_horizontalBlur) + if (m_singlePass) + program->setUniformValue("delta", 1.0 / m_textureSize.width(), 1.0 / m_textureSize.height()); + else if (m_horizontalBlur) program->setUniformValue("delta", 1.0 / m_textureSize.width(), 0.0); else program->setUniformValue("delta", 0.0, 1.0 / m_textureSize.height()); } else { - // 1.4 is chosen to most closely match the blurriness of the gaussian blur - // at low radii - qreal blur = radius() / 1.4f; + qreal blur = radius() / qreal(m_cachedRadius); - if (m_horizontalBlur) + if (m_singlePass) + program->setUniformValue("delta", blur / m_textureSize.width(), blur / m_textureSize.height()); + else if (m_horizontalBlur) program->setUniformValue("delta", blur / m_textureSize.width(), 0.0); else program->setUniformValue("delta", 0.0, blur / m_textureSize.height()); @@ -426,12 +460,21 @@ static inline qreal gaussian(qreal dx, qreal sigma) return exp(-dx * dx / (2 * sigma * sigma)) / (Q_2PI * sigma * sigma); } -QByteArray QGLPixmapBlurFilter::generateGaussianShader(int radius, bool dropShadow) +QByteArray QGLPixmapBlurFilter::generateGaussianShader(int radius, bool singlePass, bool dropShadow) { Q_ASSERT(radius >= 1); + radius = qMin(127, radius); + + static QCache shaderSourceCache; + uint key = radius | (int(singlePass) << 7) | (int(dropShadow) << 8); + QByteArray *cached = shaderSourceCache.object(key); + if (cached) + return *cached; + QByteArray source; source.reserve(1000); + source.append(qt_gl_texture_sampling_helper); source.append("uniform highp vec2 delta;\n"); if (dropShadow) @@ -446,7 +489,7 @@ QByteArray QGLPixmapBlurFilter::generateGaussianShader(int radius, bool dropShad qreal sigma = radius / 1.65; qreal sum = 0; - for (int i = -radius; i <= radius; ++i) { + for (int i = -radius; i < radius; ++i) { float value = gaussian(i, sigma); gaussianComponents << value; sum += value; @@ -464,43 +507,67 @@ QByteArray QGLPixmapBlurFilter::generateGaussianShader(int radius, bool dropShad weights << weight; } - // odd size ? - if (gaussianComponents.size() & 1) { - sampleOffsets << radius; - weights << gaussianComponents.last(); - } - - int currentVariable = 1; - source.append(" mediump vec4 sample = vec4(0.0);\n"); - source.append(" mediump vec2 coord;\n"); - - qreal weightSum = 0; - source.append(" mediump float c;\n"); - for (int i = 0; i < sampleOffsets.size(); ++i) { - qreal delta = sampleOffsets.at(i); - - ++currentVariable; + int limit = sampleOffsets.size(); + if (singlePass) + limit *= limit; + + QByteArray baseCoordinate = "srcCoords"; + + for (int i = 0; i < limit; ++i) { + QByteArray coordinate = baseCoordinate; + + qreal weight; + if (singlePass) { + const int xIndex = i % sampleOffsets.size(); + const int yIndex = i / sampleOffsets.size(); + + const qreal deltaX = sampleOffsets.at(xIndex); + const qreal deltaY = sampleOffsets.at(yIndex); + weight = weights.at(xIndex) * weights.at(yIndex); + + if (!qFuzzyCompare(deltaX, deltaY)) { + coordinate.append(" + vec2(delta.x * float("); + coordinate.append(QByteArray::number(deltaX)); + coordinate.append("), delta.y * float("); + coordinate.append(QByteArray::number(deltaY)); + coordinate.append("))"); + } else if (!qFuzzyIsNull(deltaX)) { + coordinate.append(" + delta * float("); + coordinate.append(QByteArray::number(deltaX)); + coordinate.append(")"); + } + } else { + const qreal delta = sampleOffsets.at(i); + weight = weights.at(i); + if (!qFuzzyIsNull(delta)) { + coordinate.append(" + delta * float("); + coordinate.append(QByteArray::number(delta)); + coordinate.append(")"); + } + } - QByteArray coordinate = "srcCoords"; - if (delta != qreal(0)) { - coordinate.append(" + delta * float("); - coordinate.append(QByteArray::number(delta)); - coordinate.append(")"); + if (i == 0) { + if (dropShadow) + source.append(" mediump float sample = "); + else + source.append(" mediump vec4 sample = "); + } else { + if (dropShadow) + source.append(" sample += "); + else + source.append(" sample += "); } - source.append(" coord = "); + source.append("texture2D(src, "); source.append(coordinate); - source.append(";\n"); + source.append(")"); if (dropShadow) - source.append(" sample += texture2D(src, coord).a * shadowColor"); - else - source.append(" sample += texture2D(src, coord)"); + source.append(".a"); - weightSum += weights.at(i); - if (weights.at(i) != qreal(1)) { + if (!qFuzzyCompare(weight, qreal(1))) { source.append(" * float("); - source.append(QByteArray::number(weights.at(i))); + source.append(QByteArray::number(weight)); source.append(");\n"); } else { source.append(";\n"); @@ -508,86 +575,109 @@ QByteArray QGLPixmapBlurFilter::generateGaussianShader(int radius, bool dropShad } source.append(" return "); + if (dropShadow) + source.append("shadowColor * "); source.append("sample;\n"); source.append("}\n"); + cached = new QByteArray(source); + shaderSourceCache.insert(key, cached); + return source; } QGLPixmapDropShadowFilter::QGLPixmapDropShadowFilter(Qt::RenderHint hint) : m_haveCached(false) - , m_cachedRadius(5) + , m_cachedRadius(0) , m_hint(hint) { - if (hint == Qt::PerformanceHint) { - QGLPixmapDropShadowFilter *filter = const_cast(this); - filter->setSource(qt_gl_drop_shadow_filter_fast); - m_haveCached = true; - } } bool QGLPixmapDropShadowFilter::processGL(QPainter *painter, const QPointF &pos, const QPixmap &src, const QRectF &srcRect) const { QGLPixmapDropShadowFilter *filter = const_cast(this); - int radius = qRound(this->blurRadius()); - if (!m_haveCached || (m_hint == Qt::QualityHint && radius != m_cachedRadius)) { + int actualRadius = qRound(blurRadius()); + int filterRadius = actualRadius; + m_singlePass = filterRadius <= 3; + + if (!m_haveCached || filterRadius != m_cachedRadius) { // Only regenerate the shader from source if parameters have changed. m_haveCached = true; - m_cachedRadius = radius; - filter->setSource(QGLPixmapBlurFilter::generateGaussianShader(radius, true)); + m_cachedRadius = filterRadius; + QByteArray source = QGLPixmapBlurFilter::generateGaussianShader(filterRadius, m_singlePass, true); + filter->setSource(source); } - QGLFramebufferObjectFormat format; - format.setInternalTextureFormat(GLenum(src.hasAlphaChannel() ? GL_RGBA : GL_RGB)); - QGLFramebufferObject *fbo = qgl_fbo_pool()->acquire(src.size(), format); - - if (!fbo) - return false; - - glBindTexture(GL_TEXTURE_2D, fbo->texture()); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glBindTexture(GL_TEXTURE_2D, 0); + QRect targetRect = QRectF(src.rect()).translated(pos + offset()).adjusted(-actualRadius, -actualRadius, actualRadius, actualRadius).toAlignedRect(); + + if (m_singlePass) { + // prepare for updateUniforms + m_textureSize = src.size(); + + painter->save(); + // ensure GL_LINEAR filtering is used + painter->setRenderHint(QPainter::SmoothPixmapTransform); + filter->setOnPainter(painter); + QBrush pixmapBrush = src; + pixmapBrush.setTransform(QTransform::fromTranslate(pos.x() + offset().x(), pos.y() + offset().y())); + painter->fillRect(targetRect, pixmapBrush); + filter->removeFromPainter(painter); + painter->restore(); + } else { + QGLFramebufferObjectFormat format; + format.setInternalTextureFormat(GLenum(src.hasAlphaChannel() ? GL_RGBA : GL_RGB)); + QGLFramebufferObject *fbo = qgl_fbo_pool()->acquire(targetRect.size(), format); - // prepare for updateUniforms - m_textureSize = src.size(); + if (!fbo) + return false; - // horizontal pass, to pixmap - m_horizontalBlur = true; + glBindTexture(GL_TEXTURE_2D, fbo->texture()); - QPainter fboPainter(fbo); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glBindTexture(GL_TEXTURE_2D, 0); - if (src.hasAlphaChannel()) { - glClearColor(0, 0, 0, 0); - glClear(GL_COLOR_BUFFER_BIT); - } + // prepare for updateUniforms + m_textureSize = src.size(); - // ensure GL_LINEAR filtering is used - fboPainter.setRenderHint(QPainter::SmoothPixmapTransform); - filter->setOnPainter(&fboPainter); - fboPainter.drawPixmap(0, 0, src); - filter->removeFromPainter(&fboPainter); - fboPainter.end(); + // horizontal pass, to pixmap + m_horizontalBlur = true; - QGL2PaintEngineEx *engine = static_cast(painter->paintEngine()); + QPainter fboPainter(fbo); - // vertical pass, to painter - m_horizontalBlur = false; - - painter->save(); - // ensure GL_LINEAR filtering is used - painter->setRenderHint(QPainter::SmoothPixmapTransform); - filter->setOnPainter(painter); - QPointF ofs = offset(); - engine->drawTexture(src.rect().translated(pos.x() + ofs.x(), pos.y() + ofs.y()), fbo->texture(), fbo->size(), src.rect().translated(0, fbo->height() - src.height())); - filter->removeFromPainter(painter); - painter->restore(); + if (src.hasAlphaChannel()) { + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); + } - qgl_fbo_pool()->release(fbo); + // ensure GL_LINEAR filtering is used + fboPainter.setRenderHint(QPainter::SmoothPixmapTransform); + filter->setOnPainter(&fboPainter); + QBrush pixmapBrush = src; + pixmapBrush.setTransform(QTransform::fromTranslate(actualRadius, actualRadius)); + fboPainter.fillRect(QRect(0, 0, targetRect.width(), targetRect.height()), pixmapBrush); + filter->removeFromPainter(&fboPainter); + fboPainter.end(); + + QGL2PaintEngineEx *engine = static_cast(painter->paintEngine()); + + // vertical pass, to painter + m_horizontalBlur = false; + m_textureSize = fbo->size(); + + painter->save(); + // ensure GL_LINEAR filtering is used + painter->setRenderHint(QPainter::SmoothPixmapTransform); + filter->setOnPainter(painter); + engine->drawTexture(targetRect, fbo->texture(), fbo->size(), src.rect().translated(0, fbo->height() - src.height())); + filter->removeFromPainter(painter); + painter->restore(); + + qgl_fbo_pool()->release(fbo); + } // Now draw the actual pixmap over the top. painter->drawPixmap(pos, src, srcRect); @@ -597,8 +687,11 @@ bool QGLPixmapDropShadowFilter::processGL(QPainter *painter, const QPointF &pos, void QGLPixmapDropShadowFilter::setUniforms(QGLShaderProgram *program) { + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + QColor col = color(); - if (m_horizontalBlur) { + if (m_horizontalBlur && !m_singlePass) { program->setUniformValue("shadowColor", 1.0f, 1.0f, 1.0f, 1.0f); } else { qreal alpha = col.alphaF(); @@ -607,17 +700,20 @@ void QGLPixmapDropShadowFilter::setUniforms(QGLShaderProgram *program) col.blueF() * alpha, alpha); } + if (m_hint == Qt::QualityHint) { - if (m_horizontalBlur) + if (m_singlePass) + program->setUniformValue("delta", 1.0 / m_textureSize.width(), 1.0 / m_textureSize.height()); + else if (m_horizontalBlur) program->setUniformValue("delta", 1.0 / m_textureSize.width(), 0.0); else program->setUniformValue("delta", 0.0, 1.0 / m_textureSize.height()); } else { - // 1.4 is chosen to most closely match the blurriness of the gaussian blur - // at low radii - qreal blur = blurRadius() / 1.4f; + qreal blur = blurRadius() / qreal(m_cachedRadius); - if (m_horizontalBlur) + if (m_singlePass) + program->setUniformValue("delta", blur / m_textureSize.width(), blur / m_textureSize.height()); + else if (m_horizontalBlur) program->setUniformValue("delta", blur / m_textureSize.width(), 0.0); else program->setUniformValue("delta", 0.0, blur / m_textureSize.height()); -- cgit v0.12 From 8f527513fd2bc280d3613759d411e8e4e96a522e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 28 Oct 2009 18:02:40 +0100 Subject: Got rid of redundant texture parameter settings in GL pixmap filters. The texture parameters are set in drawTexture anyways. Reviewed-by: Gunnar Sletta --- src/opengl/qglpixmapfilter.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index e381a5d..2af69e0 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -381,14 +381,6 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const if (!fbo) return false; - glBindTexture(GL_TEXTURE_2D, fbo->texture()); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glBindTexture(GL_TEXTURE_2D, 0); - // prepare for updateUniforms m_textureSize = src.size(); @@ -632,14 +624,6 @@ bool QGLPixmapDropShadowFilter::processGL(QPainter *painter, const QPointF &pos, if (!fbo) return false; - glBindTexture(GL_TEXTURE_2D, fbo->texture()); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glBindTexture(GL_TEXTURE_2D, 0); - // prepare for updateUniforms m_textureSize = src.size(); -- cgit v0.12 From 7881773800c05c09f0e85a80c1cbb678981bd6c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 28 Oct 2009 17:57:12 +0100 Subject: Made internal FBOs snap to power-of-two when not wasting too much space. This improves performance on certain OpenGL ES 2.0 platforms. Reviewed-by: Gunnar Sletta --- src/opengl/qpixmapdata_gl.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index 83ebece..c965947 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -76,6 +76,19 @@ static inline int areaDiff(const QSize &size, const QGLFramebufferObject *fbo) return qAbs(size.width() * size.height() - fbo->width() * fbo->height()); } +extern int qt_next_power_of_two(int v); + +static inline QSize maybeRoundToNextPowerOfTwo(const QSize &sz) +{ +#ifdef QT_OPENGL_ES_2 + QSize rounded(qt_next_power_of_two(sz.width()), qt_next_power_of_two(sz.height())); + if (rounded.width() * rounded.height() < 1.20 * sz.width() * sz.height()) + return rounded; +#endif + return sz; +} + + QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize, const QGLFramebufferObjectFormat &requestFormat) { QGLFramebufferObject *chosen = 0; @@ -106,7 +119,7 @@ QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize if (sz != fboSize) { delete candidate; - candidate = new QGLFramebufferObject(sz, requestFormat); + candidate = new QGLFramebufferObject(maybeRoundToNextPowerOfTwo(sz), requestFormat); } chosen = candidate; @@ -114,7 +127,7 @@ QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize } if (!chosen) { - chosen = new QGLFramebufferObject(requestSize, requestFormat); + chosen = new QGLFramebufferObject(maybeRoundToNextPowerOfTwo(requestSize), requestFormat); } if (!chosen->isValid()) { -- cgit v0.12 From ce0c22d4da46664636e651285f6e3ba38e77aea7 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 29 Oct 2009 10:40:14 +0100 Subject: Fix qvariant_cast when a QVariant is really inside a QVariant This fix the QPropertyAnimation test. Reviewed-by: Gabriel Reviewed-by: Thierry --- src/corelib/kernel/qvariant.h | 3 +++ tests/auto/qvariant/tst_qvariant.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index a1ab4e9..3c10788 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -581,6 +581,9 @@ template inline T qvariant_cast(const QVariant &v) template<> inline QVariant qvariant_cast(const QVariant &v) { + static const int vid = qRegisterMetaType("QVariant"); + if (vid == v.userType()) + return *reinterpret_cast(v.constData()); return v; } diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index 61e9a4f..e2a606f 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -3380,6 +3380,10 @@ void tst_QVariant::variantInVariant() QVariant var8 = qvariant_cast(QVariant::fromValue(QVariant::fromValue(str))); QCOMPARE((int)var8.type(), (int)QVariant::String); QCOMPARE(qvariant_cast(QVariant(qvariant_cast(var8))), str); + + QVariant var9(qMetaTypeId(), &var1); + QCOMPARE(var9.userType(), qMetaTypeId()); + QCOMPARE(qvariant_cast(var9), var1); } QTEST_MAIN(tst_QVariant) -- cgit v0.12 From f736d889bca3ce5d33b1e5499ad8714952c67906 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 29 Oct 2009 11:20:31 +0100 Subject: Fix QDateTime on S60 3.1 S60 3.1 plugin returned empty strings for the unsupported APIs Since these APIs are needed for the most common use case of converting a QDateTime to a QString using the local format, I have implemented an emulation of the missing APIs using older APIs that are supported. Updated the autotest so it does some sanity checking on the result of local date/time conversion - it would pass instead of fail if the string was garbage before. Reviewed-by: Aleksandar Sasha Babic --- src/plugins/s60/src/qlocale_3_1.cpp | 96 ++++++++++++++++++++++++++++++++-- tests/auto/qdatetime/tst_qdatetime.cpp | 7 +++ 2 files changed, 98 insertions(+), 5 deletions(-) diff --git a/src/plugins/s60/src/qlocale_3_1.cpp b/src/plugins/s60/src/qlocale_3_1.cpp index 0afd10a..beeee7f 100644 --- a/src/plugins/s60/src/qlocale_3_1.cpp +++ b/src/plugins/s60/src/qlocale_3_1.cpp @@ -40,23 +40,109 @@ ****************************************************************************/ #include +#include +#include -EXPORT_C void defaultFormatL(TTime&, TDes& des, const TDesC&, const TLocale&) +_LIT(KYear, "%Y"); +_LIT(KMonth, "%M"); +_LIT(KDay, "%D"); +_LIT(KLocaleIndependent, "%F"); +static TBuf<10> dateFormat; +static TBuf<10> timeFormat; + +static void initialiseDateFormat() +{ + if(dateFormat.Length()) + return; + + TLocale locale; + + //Separator 1 is used between 1st and 2nd components of the date + //Separator 2 is used between 2nd and 3rd components of the date + //Usually they are the same, but they are allowed to be different + TChar s1 = locale.DateSeparator(1); + TChar s2 = locale.DateSeparator(2); + dateFormat=KLocaleIndependent; + switch(locale.DateFormat()) { + case EDateAmerican: + dateFormat.Append(KMonth); + dateFormat.Append(s1); + dateFormat.Append(KDay); + dateFormat.Append(s2); + dateFormat.Append(KYear); + break; + case EDateEuropean: + dateFormat.Append(KDay); + dateFormat.Append(s1); + dateFormat.Append(KMonth); + dateFormat.Append(s2); + dateFormat.Append(KYear); + break; + case EDateJapanese: + default: //it's closest to ISO format + dateFormat.Append(KYear); + dateFormat.Append(s1); + dateFormat.Append(KMonth); + dateFormat.Append(s2); + dateFormat.Append(KDay); + break; + } +#ifdef _DEBUG + RDebug::Print(_L("Date Format \"%S\""), &dateFormat); +#endif +} + +static void initialiseTimeFormat() +{ + if(timeFormat.Length()) + return; + + TLocale locale; + //Separator 1 is used between 1st and 2nd components of the time + //Separator 2 is used between 2nd and 3rd components of the time + //Usually they are the same, but they are allowed to be different + TChar s1 = locale.TimeSeparator(1); + TChar s2 = locale.TimeSeparator(2); + switch(locale.TimeFormat()) { + case ETime12: + timeFormat.Append(_L("%I")); + break; + case ETime24: + default: + timeFormat.Append(_L("%H")); + break; + } + timeFormat.Append(s1); + timeFormat.Append(_L("%T")); + timeFormat.Append(s2); + timeFormat.Append(_L("%S")); + +#ifdef _DEBUG + RDebug::Print(_L("Time Format \"%S\""), &timeFormat); +#endif +} + +EXPORT_C void defaultFormatL(TTime& time, TDes& des, const TDesC& fmt, const TLocale&) { - des.Zero(); + //S60 3.1 does not support format for a specific locale, so use default locale + time.FormatL(des, fmt); } +//S60 3.1 doesn't support extended locale date&time formats, so use default locale EXPORT_C TPtrC defaultGetTimeFormatSpec(TExtendedLocale&) { - return TPtrC(KNullDesC); + initialiseTimeFormat(); + return TPtrC(timeFormat); } EXPORT_C TPtrC defaultGetLongDateFormatSpec(TExtendedLocale&) { - return TPtrC(KNullDesC); + initialiseDateFormat(); + return TPtrC(dateFormat); } EXPORT_C TPtrC defaultGetShortDateFormatSpec(TExtendedLocale&) { - return TPtrC(KNullDesC); + initialiseDateFormat(); + return TPtrC(dateFormat); } diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp index 8fb0c91..c53780e 100644 --- a/tests/auto/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/qdatetime/tst_qdatetime.cpp @@ -447,7 +447,14 @@ void tst_QDateTime::toString_enumformat() QCOMPARE(str2, QString("1995-05-20T12:34:56")); QString str3 = dt1.toString(Qt::LocalDate); + qDebug() << str3; QVERIFY(!str3.isEmpty()); + //check for date/time components in any order + QVERIFY(str3.contains("1995")); + //day and month may be in numeric or word form + QVERIFY(str3.contains("12")); + QVERIFY(str3.contains("34")); + QVERIFY(str3.contains("56")); } void tst_QDateTime::addDays() -- cgit v0.12 From 0f1aeb863474d2894a896fb28ea8eae8d736a363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 29 Oct 2009 11:47:44 +0100 Subject: Fix tst_QWidget::compatibilityChildInsertedEvents test This broke after commit: a8e2a457bb7d2fc377c1c65b6a4172974919e055 (Add a new event type, WinIdChange). The first thing that happens in show() is that the top-level is created, and hence we send WinIdChange. We therefore have to add this event to list of expected events. Reviewed-by: TrustMe --- tests/auto/qwidget/tst_qwidget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 9c421d1..c27de1d 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -6320,6 +6320,7 @@ void tst_QWidget::compatibilityChildInsertedEvents() widget.show(); expected = EventRecorder::EventList() + << qMakePair(&widget, QEvent::WinIdChange) << qMakePair(&widget, QEvent::Polish) << qMakePair(&widget, QEvent::Move) << qMakePair(&widget, QEvent::Resize) @@ -6405,6 +6406,7 @@ void tst_QWidget::compatibilityChildInsertedEvents() widget.show(); expected = EventRecorder::EventList() + << qMakePair(&widget, QEvent::WinIdChange) << qMakePair(&widget, QEvent::Polish) #ifdef QT_HAS_QT3SUPPORT << qMakePair(&widget, QEvent::ChildInserted) @@ -6502,6 +6504,7 @@ void tst_QWidget::compatibilityChildInsertedEvents() widget.show(); expected = EventRecorder::EventList() + << qMakePair(&widget, QEvent::WinIdChange) << qMakePair(&widget, QEvent::Polish) #ifdef QT_HAS_QT3SUPPORT << qMakePair(&widget, QEvent::ChildInserted) -- cgit v0.12 From d38ebd566f3a73f280903929d4ac49d255be3aed Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 29 Oct 2009 13:22:49 +0200 Subject: Removed mentions about certain flags being temporary for Symbian In configure app, some QT_NO_* flags were indicated to be temporary and should be removed once Qt for Symbian is out, but it looks like at least some of them will be there for longer haul, so removed mentions of temporary nature of these flags. Task-number: QTBUG-4744 Reviewed-by: Janne Anttila --- tools/configure/configureapp.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index adf7a1a..25a02f3 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -2780,17 +2780,6 @@ QString Configure::addDefine(QString def) } #if !defined(EVAL) -// ### This should be removed once Qt for S60 is out. -static void applyTemporarySymbianFlags(QStringList &qconfigList) -{ - qconfigList += "QT_NO_CONCURRENT"; - qconfigList += "QT_NO_QFUTURE"; - // This is removed because it uses UNIX signals which are not implemented yet - qconfigList += "QT_NO_CRASHHANDLER"; - qconfigList += "QT_NO_PRINTER"; - qconfigList += "QT_NO_SYSTEMTRAYICON"; -} - void Configure::generateConfigfiles() { QDir(buildPath).mkpath("src/corelib/global"); @@ -2913,9 +2902,14 @@ void Configure::generateConfigfiles() if (dictionary["GRAPHICS_SYSTEM"] == "openvg") qconfigList += "QT_GRAPHICSSYSTEM_OPENVG"; if (dictionary["GRAPHICS_SYSTEM"] == "opengl") qconfigList += "QT_GRAPHICSSYSTEM_OPENGL"; if (dictionary["GRAPHICS_SYSTEM"] == "raster") qconfigList += "QT_GRAPHICSSYSTEM_RASTER"; - // ### This block should be removed once Qt for S60 is out. + if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) { - applyTemporarySymbianFlags(qconfigList); + // These features are not ported to Symbian (yet) + qconfigList += "QT_NO_CONCURRENT"; + qconfigList += "QT_NO_QFUTURE"; + qconfigList += "QT_NO_CRASHHANDLER"; + qconfigList += "QT_NO_PRINTER"; + qconfigList += "QT_NO_SYSTEMTRAYICON"; } qconfigList.sort(); -- cgit v0.12 From 316bf04887aed61804e16d64857754b78cf2f713 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 29 Oct 2009 12:03:34 +0100 Subject: ItemViews: make the geometries update when header data changes autotest included Task-number: QT-711 Reviewed-by: ogoffart --- src/gui/itemviews/qabstractitemview.cpp | 4 ++++ src/gui/itemviews/qabstractitemview.h | 1 + src/gui/itemviews/qabstractitemview_p.h | 1 + tests/auto/qtableview/tst_qtableview.cpp | 21 +++++++++++++++++++++ 4 files changed, 27 insertions(+) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index d91cedd..9247411 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -605,6 +605,8 @@ void QAbstractItemView::setModel(QAbstractItemModel *model) this, SLOT(_q_modelDestroyed())); disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(dataChanged(QModelIndex,QModelIndex))); + disconnect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), + this, SLOT(_q_headerDataChanged())); disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted(QModelIndex,int,int))); disconnect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), @@ -637,6 +639,8 @@ void QAbstractItemView::setModel(QAbstractItemModel *model) this, SLOT(_q_modelDestroyed())); connect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(dataChanged(QModelIndex,QModelIndex))); + connect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), + this, SLOT(_q_headerDataChanged())); connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted(QModelIndex,int,int))); connect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), diff --git a/src/gui/itemviews/qabstractitemview.h b/src/gui/itemviews/qabstractitemview.h index f438148..7a0509b 100644 --- a/src/gui/itemviews/qabstractitemview.h +++ b/src/gui/itemviews/qabstractitemview.h @@ -358,6 +358,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_rowsRemoved(const QModelIndex&, int, int)) Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed()) Q_PRIVATE_SLOT(d_func(), void _q_layoutChanged()) + Q_PRIVATE_SLOT(d_func(), void _q_headerDataChanged()) friend class QTreeViewPrivate; // needed to compile with MSVC friend class QAccessibleItemRow; diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index 66b7662..c691f61 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -117,6 +117,7 @@ public: virtual void _q_columnsInserted(const QModelIndex &parent, int start, int end); virtual void _q_modelDestroyed(); virtual void _q_layoutChanged(); + void _q_headerDataChanged() { doDelayedItemsLayout(); } void fetchMore(); diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index fe2794f..227ca6f 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -203,6 +203,8 @@ private slots: void addColumnWhileEditing(); void task234926_setHeaderSorting(); + + void changeHeaderData(); }; // Testing get/set functions @@ -3883,5 +3885,24 @@ void tst_QTableView::taskQTBUG_5062_spansInconsistency() VERIFY_SPANS_CONSISTENCY(&view); } +void tst_QTableView::changeHeaderData() +{ + QTableView view; + QStandardItemModel model(5,5); + view.setModel(&model); + view.show(); + QTest::qWaitForWindowShown(&view); + + QString text = "long long long text"; + const int textWidth = view.fontMetrics().width(text); + QVERIFY(view.verticalHeader()->width() < textWidth); + + model.setHeaderData(2, Qt::Vertical, text); + QTest::qWait(100); //leave time for layout + + QVERIFY(view.verticalHeader()->width() > textWidth); +} + + QTEST_MAIN(tst_QTableView) #include "tst_qtableview.moc" -- cgit v0.12 From 76095a14bc84305c69b3eaf8f3953dc683ebe370 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Thu, 29 Oct 2009 15:45:17 +0200 Subject: Fix for softkey visibility when dialog launched from fullscreen widget. Softkeys should be always the topmost window in order to be visible. For example when QMessageBox is launched from fullscreen window, we need to make sure that softkey is located on top of window tree. Task-number: QTBUG-4953 Reviewed-by: Jason Barron --- src/gui/kernel/qsoftkeymanager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index a5e8eff..a5a2201 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -207,6 +207,7 @@ bool QSoftKeyManager::event(QEvent *e) void QSoftKeyManagerPrivate::updateSoftKeys_sys(const QList &softkeys) { CEikButtonGroupContainer* nativeContainer = S60->buttonGroupContainer(); + nativeContainer->DrawableWindow()->SetOrdinalPosition(0); nativeContainer->DrawableWindow()->SetPointerCapturePriority(1); //keep softkeys available in modal dialog QT_TRAP_THROWING(nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS)); -- cgit v0.12 From 5e4035ede6505f638f4741dcebbf19e485a1b993 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 29 Oct 2009 14:50:51 +0100 Subject: qdoc3: Fixed a linking error for qml properties. This: https://qtmetrics.europe.nokia.com/kinetic-declarativeui/qml-item.html#rotation-prop should now be this: https://qtmetrics.europe.nokia.com/kinetic-declarativeui/qml-item.html#transformOrigin-prop) --- tools/qdoc3/htmlgenerator.cpp | 11 +++++++---- tools/qdoc3/pagegenerator.cpp | 19 +++++++------------ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 18c7916..eaf4b2e 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -3467,10 +3467,13 @@ QString HtmlGenerator::refForNode(const Node *node) ref += "-" + QString::number(func->overloadNumber()); } break; - case Node::Property: -#ifdef QDOC_QML +#ifdef QDOC_QML + case Node::Fake: + if (node->subType() != Node::QmlPropertyGroup) + break; case Node::QmlProperty: #endif + case Node::Property: ref = node->name() + "-prop"; break; #ifdef QDOC_QML @@ -3512,9 +3515,9 @@ QString HtmlGenerator::linkForNode(const Node *node, const Node *relative) // ### reintroduce this test, without breaking .dcf files if (fn != outFileName()) #endif - link += fn; + link += fn; - if (!node->isInnerNode()) { + if (!node->isInnerNode() || node->subType() == Node::QmlPropertyGroup) { ref = refForNode(node); if (relative && fn == fileName(relative) && ref == refForNode(relative)) return QString(); diff --git a/tools/qdoc3/pagegenerator.cpp b/tools/qdoc3/pagegenerator.cpp index 83ea561..7d9fbee 100644 --- a/tools/qdoc3/pagegenerator.cpp +++ b/tools/qdoc3/pagegenerator.cpp @@ -81,14 +81,13 @@ QString PageGenerator::fileBase(const Node *node) { if (node->relates()) node = node->relates(); - else if (!node->isInnerNode()) { + else if (!node->isInnerNode()) node = node->parent(); #ifdef QDOC_QML - if (node->subType() == Node::QmlPropertyGroup) { - node = node->parent(); - } -#endif + if (node->subType() == Node::QmlPropertyGroup) { + node = node->parent(); } +#endif QString base = node->doc().baseName(); if (!base.isEmpty()) @@ -97,6 +96,7 @@ QString PageGenerator::fileBase(const Node *node) const Node *p = node; forever { + const Node *pp = p->parent(); base.prepend(p->name()); #ifdef QDOC_QML /* @@ -104,15 +104,10 @@ QString PageGenerator::fileBase(const Node *node) we prepend "qml-" to the file name of QML element doc files. */ - if ((p->subType() == Node::QmlClass) || - (p->subType() == Node::QmlPropertyGroup)) - base.prepend("qml-"); - else if ((p->type() == Node::QmlProperty) || - (p->type() == Node::QmlSignal) || - (p->type() == Node::QmlMethod)) + if (p->subType() == Node::QmlClass) { base.prepend("qml-"); + } #endif - const Node *pp = p->parent(); if (!pp || pp->name().isEmpty() || pp->type() == Node::Fake) break; base.prepend(QLatin1Char('-')); -- cgit v0.12 From 4531ffbd8aa2cc0ae656715e449caca1649c18b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 29 Oct 2009 14:28:36 +0100 Subject: Added QImagePixmapCleanupHooks functions for enabling hooks. Better than having to befriend QPixmapData and setting is_cached manually. Reviewed-by: Tom Cooksey --- src/gui/image/qimagepixmapcleanuphooks.cpp | 18 +++++++++++++++++- src/gui/image/qimagepixmapcleanuphooks_p.h | 4 ++++ src/gui/image/qpixmapdata_p.h | 3 +-- src/opengl/qgl.cpp | 4 ++-- src/opengl/qgl_x11.cpp | 3 ++- src/opengl/qgl_x11egl.cpp | 3 ++- 6 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp index ac30646..35322e9 100644 --- a/src/gui/image/qimagepixmapcleanuphooks.cpp +++ b/src/gui/image/qimagepixmapcleanuphooks.cpp @@ -40,7 +40,8 @@ ****************************************************************************/ #include "qimagepixmapcleanuphooks_p.h" -#include "qpixmapdata_p.h" +#include "private/qpixmapdata_p.h" +#include "private/qimage_p.h" QT_BEGIN_NAMESPACE @@ -132,4 +133,19 @@ void QImagePixmapCleanupHooks::executeImageHooks(qint64 key) qt_image_cleanup_hook_64(key); } +void QImagePixmapCleanupHooks::enableCleanupHooks(const QPixmap &pixmap) +{ + enableCleanupHooks(const_cast(pixmap).data_ptr().data()); +} + +void QImagePixmapCleanupHooks::enableCleanupHooks(QPixmapData *pixmapData) +{ + pixmapData->is_cached = true; +} + +void QImagePixmapCleanupHooks::enableCleanupHooks(const QImage &image) +{ + const_cast(image).data_ptr()->is_cached = true; +} + QT_END_NAMESPACE diff --git a/src/gui/image/qimagepixmapcleanuphooks_p.h b/src/gui/image/qimagepixmapcleanuphooks_p.h index 16c8974..9e490d7 100644 --- a/src/gui/image/qimagepixmapcleanuphooks_p.h +++ b/src/gui/image/qimagepixmapcleanuphooks_p.h @@ -70,6 +70,10 @@ public: static QImagePixmapCleanupHooks *instance(); + static void enableCleanupHooks(const QImage &image); + static void enableCleanupHooks(const QPixmap &pixmap); + static void enableCleanupHooks(QPixmapData *pixmapData); + // Gets called when a pixmap is about to be modified: void addPixmapModificationHook(_qt_pixmap_cleanup_hook_pm); diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h index 2f4f201..e99409c 100644 --- a/src/gui/image/qpixmapdata_p.h +++ b/src/gui/image/qpixmapdata_p.h @@ -131,12 +131,11 @@ protected: private: friend class QPixmap; - friend class QGLContextPrivate; friend class QX11PixmapData; friend class QS60PixmapData; + friend class QImagePixmapCleanupHooks; // Needs to set is_cached friend class QGLTextureCache; //Needs to check the reference count friend class QExplicitlySharedDataPointer; - friend bool qt_createEGLSurfaceForPixmap(QPixmapData*, bool); // Needs to set is_cached QAtomicInt ref; int detach_no; diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index e80521b..3fec1f0 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2137,7 +2137,7 @@ QGLTexture *QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G Q_ASSERT(texture); if (texture->id > 0) - const_cast(image).data_ptr()->is_cached = true; + QImagePixmapCleanupHooks::enableCleanupHooks(image); return texture; } @@ -2396,7 +2396,7 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, Q_ASSERT(texture); if (texture->id > 0) - const_cast(pixmap).data_ptr()->is_cached = true; + QImagePixmapCleanupHooks::enableCleanupHooks(pixmap); return texture; } diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index 86e593d..899047a 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #ifdef Q_OS_HPUX // for GLXPBuffer #include @@ -1704,7 +1705,7 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData *pmd, con pixmapData->gl_surface = (Qt::HANDLE)glxPixmap; // Make sure the cleanup hook gets called so we can delete the glx pixmap - pixmapData->is_cached = true; + QImagePixmapCleanupHooks::enableCleanupHooks(pixmapData); } GLuint textureId; diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 7180682..9b20297 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -42,6 +42,7 @@ #include "qgl.h" #include #include +#include #include #include #include "qgl_egl_p.h" @@ -531,7 +532,7 @@ bool Q_OPENGL_EXPORT qt_createEGLSurfaceForPixmap(QPixmapData* pmd, bool readOnl Q_ASSERT(sizeof(Qt::HANDLE) >= sizeof(EGLSurface)); // Just to make totally sure! pixmapData->gl_surface = (Qt::HANDLE)pixmapSurface; - pixmapData->is_cached = true; // Make sure the cleanup hook gets called + QImagePixmapCleanupHooks::enableCleanupHooks(pixmapData); // Make sure the cleanup hook gets called return true; } -- cgit v0.12 From 94be7bf47fe93ca4fa6ae90f5906f6ef711f558e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 29 Oct 2009 15:23:03 +0100 Subject: Compile fix until configure.exe is rebuilt for Windows --- src/corelib/global/qlibraryinfo.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 15a06d7..32693e0 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -215,7 +215,8 @@ QLibraryInfo::buildKey() QDate QLibraryInfo::buildDate() { - return QDate::fromString(QString::fromLatin1(qt_configure_installation + 12), Qt::ISODate); + return QDate(); + //return QDate::fromString(QString::fromLatin1(qt_configure_installation + 12), Qt::ISODate); } /*! -- cgit v0.12 From 198b974587ba9751a2bdc73464c05c164d49f10c Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 29 Oct 2009 16:28:45 +0200 Subject: Fixed: Variable res goes out of scope but is accessed later via pointer In qdatetime UTC conversion functions, variable res was declared in incorrect scope and went out of scope too soon in Symbian. Reviewed-by: Janne Koskinen --- src/corelib/tools/qdatetime.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 54465bb..db6435e 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -1855,7 +1855,7 @@ QTime QTime::currentTime() t = localtime(<ime); #endif Q_CHECK_PTR(t); - + ct.mds = MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min + 1000 * t->tm_sec + tv.tv_usec / 1000; #else @@ -3725,11 +3725,11 @@ static QDateTimePrivate::Spec utcToLocal(QDate &date, QTime &time) TTimeIntervalSeconds tTimeIntervalSecsSince1Jan1970UTC(secsSince1Jan1970UTC); TTime epochTTime; TInt err = epochTTime.Set(KUnixEpoch); + tm res; if(err == KErrNone) { TTime utcTTime = epochTTime + tTimeIntervalSecsSince1Jan1970UTC; utcTTime = utcTTime + utcOffset; TDateTime utcDateTime = utcTTime.DateTime(); - tm res; res.tm_sec = utcDateTime.Second(); res.tm_min = utcDateTime.Minute(); res.tm_hour = utcDateTime.Hour(); @@ -3816,11 +3816,11 @@ static void localToUtc(QDate &date, QTime &time, int isdst) TTimeIntervalSeconds tTimeIntervalSecsSince1Jan1970UTC(secsSince1Jan1970UTC); TTime epochTTime; TInt err = epochTTime.Set(KUnixEpoch); + tm res; if(err == KErrNone) { TTime utcTTime = epochTTime + tTimeIntervalSecsSince1Jan1970UTC; utcTTime = utcTTime + utcOffset; TDateTime utcDateTime = utcTTime.DateTime(); - tm res; res.tm_sec = utcDateTime.Second(); res.tm_min = utcDateTime.Minute(); res.tm_hour = utcDateTime.Hour(); -- cgit v0.12 From 02d815b4bd497a5c7f07330576a5e3c3da3f46ab Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 29 Oct 2009 15:44:08 +0100 Subject: QListView: make sure we relayout items when data changes in the model Task-number: QTBUG-633 Reviewed-by: ogoffart --- src/gui/itemviews/qlistview.cpp | 6 ++++++ src/gui/itemviews/qlistview_p.h | 3 ++- tests/auto/qlistview/tst_qlistview.cpp | 21 +++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 109d760..d680af8 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -2403,6 +2403,12 @@ QVector QListModeViewBase::intersectingSet(const QRect &area) const return ret; } +void QListModeViewBase::dataChanged(const QModelIndex &, const QModelIndex &) +{ + dd->doDelayedItemsLayout(); +} + + QRect QListModeViewBase::mapToViewport(const QRect &rect) const { if (isWrapping()) diff --git a/src/gui/itemviews/qlistview_p.h b/src/gui/itemviews/qlistview_p.h index 3f8f9db..31459b0 100644 --- a/src/gui/itemviews/qlistview_p.h +++ b/src/gui/itemviews/qlistview_p.h @@ -130,6 +130,7 @@ public: virtual void clear() = 0; virtual void setRowCount(int) = 0; virtual QVector intersectingSet(const QRect &area) const = 0; + virtual void dataChanged(const QModelIndex &, const QModelIndex &) = 0; virtual int horizontalScrollToValue(int index, QListView::ScrollHint hint, bool leftOf, bool rightOf, const QRect &area, const QRect &rect) const; @@ -141,7 +142,6 @@ public: virtual int verticalOffset() const { return verticalScrollBar()->value(); } virtual void updateHorizontalScrollBar(const QSize &step); virtual void updateVerticalScrollBar(const QSize &step); - virtual void dataChanged(const QModelIndex &, const QModelIndex &) { } virtual void appendHiddenRow(int row); virtual void removeHiddenRow(int row); virtual void setPositionForIndex(const QPoint &, const QModelIndex &) { } @@ -217,6 +217,7 @@ public: void clear(); void setRowCount(int rowCount) { flowPositions.resize(rowCount); } QVector intersectingSet(const QRect &area) const; + void dataChanged(const QModelIndex &, const QModelIndex &); int horizontalScrollToValue(int index, QListView::ScrollHint hint, bool leftOf, bool rightOf,const QRect &area, const QRect &rect) const; diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 65ab12d..727e6d3 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -119,6 +119,7 @@ private slots: void task262152_setModelColumnNavigate(); void taskQTBUG_2233_scrollHiddenItems_data(); void taskQTBUG_2233_scrollHiddenItems(); + void taskQTBUG_633_changeModelData(); }; // Testing get/set functions @@ -1832,5 +1833,25 @@ void tst_QListView::taskQTBUG_2233_scrollHiddenItems() } } +void tst_QListView::taskQTBUG_633_changeModelData() +{ + QListView view; + view.setFlow(QListView::LeftToRight); + QStandardItemModel model(5,1); + for (int i = 0; i < model.rowCount(); ++i) { + model.setData( model.index(i, 0), QString::number(i)); + } + + view.setModel(&model); + view.show(); + QTest::qWaitForWindowShown(&view); + model.setData( model.index(1, 0), QLatin1String("long long text")); + QTest::qWait(100); //leave time for relayouting the items + QRect rectLongText = view.visualRect(model.index(1,0)); + QRect rect2 = view.visualRect(model.index(2,0)); + QVERIFY( ! rectLongText.intersects(rect2) ); +} + + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" -- cgit v0.12 From da9880eaed0d09338717db1a73db01e6b0ab080d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Thu, 29 Oct 2009 17:41:52 +0200 Subject: QS60Style does not mix well with the stylesheets QS60Style basically ignores user set / stylesheet set palettes. Now, tested with: * QLineEdit * QPushButton * QSpinBox * QComboBox * QAbstractScrollArea * QCheckBox * QRadioButton * QGroupBox * QFrame * QTreeView * QTableView * QHeaderView * QProgressBar * QScrollBar * QSplitter * QSlider * QTabWidget * QToolButton * QToolBar and fixed QS60Style so that it obeys externally set palettes. Task-number: QTBUG-4820 Reviewed-by: Janne Koskinen --- src/gui/styles/qs60style.cpp | 199 +++++++++++++++++++-------------- src/gui/styles/qs60style_p.h | 6 +- src/gui/styles/qs60style_s60.cpp | 61 ++++------ src/gui/styles/qs60style_simulated.cpp | 4 +- 4 files changed, 146 insertions(+), 124 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 580f949..b87f3a8 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -66,7 +66,6 @@ #include "qtextedit.h" #include "qtoolbar.h" #include "qtoolbutton.h" -#include "qtreeview.h" #include "qfocusframe.h" #include "private/qtoolbarextension_p.h" @@ -527,7 +526,7 @@ void QS60StylePrivate::drawPart(QS60StyleEnums::SkinParts skinPart, true; #endif - const QPixmap skinPartPixMap((doCache ? cachedPart : part)(skinPart, rect.size(), flags)); + const QPixmap skinPartPixMap((doCache ? cachedPart : part)(skinPart, rect.size(), painter, flags)); if (!skinPartPixMap.isNull()) painter->drawPixmap(rect.topLeft(), skinPartPixMap); } @@ -594,14 +593,14 @@ void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start, } QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part, - const QSize &size, SkinElementFlags flags) + const QSize &size, QPainter *painter, SkinElementFlags flags) { QPixmap result; const QString cacheKey = QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4") .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags); if (!QPixmapCache::find(cacheKey, result)) { - result = QS60StylePrivate::part(part, size, flags); + result = QS60StylePrivate::part(part, size, painter, flags); QPixmapCache::insert(cacheKey, result); } return result; @@ -1316,13 +1315,13 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, painter->setClipRect(voptAdj.rect); const bool isSelected = (vopt->state & QStyle::State_Selected); - bool isVisible = false; + bool isScrollBarVisible = false; int scrollBarWidth = 0; QList scrollBars = qFindChildren(widget); for (int i = 0; i < scrollBars.size(); ++i) { QScrollBar *scrollBar = scrollBars.at(i); if (scrollBar && scrollBar->orientation() == Qt::Vertical) { - isVisible = scrollBar->isVisible(); + isScrollBarVisible = scrollBar->isVisible(); scrollBarWidth = scrollBar->size().width(); break; } @@ -1330,7 +1329,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, int rightValue = widget ? widget->contentsRect().right() : 0; - if (isVisible) + if (isScrollBarVisible) rightValue -= scrollBarWidth; if (voptAdj.rect.right() > rightValue) @@ -1338,40 +1337,40 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, const QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &voptAdj, widget); QRect textRect = subElementRect(SE_ItemViewItemText, &voptAdj, widget); + const QAbstractItemView *itemView = qobject_cast(widget); // draw themed background for table unless background brush has been defined. if (vopt->backgroundBrush == Qt::NoBrush) { - const QStyleOptionViewItemV4 *tableOption = qstyleoption_cast(option); - const QTableView *table = qobject_cast(widget); - if (table && tableOption) { - const QModelIndex index = tableOption->index; + if (itemView) { + const QModelIndex index = vopt->index; //todo: Draw cell background only once - for the first cell. QStyleOptionViewItemV4 voptAdj2 = voptAdj; - const QModelIndex indexFirst = table->model()->index(0,0); - const QModelIndex indexLast = table->model()->index( - table->model()->rowCount()-1,table->model()->columnCount()-1); - if (table->viewport()) - voptAdj2.rect = QRect( table->visualRect(indexFirst).topLeft(), - table->visualRect(indexLast).bottomRight()).intersect(table->viewport()->rect()); - drawPrimitive(PE_PanelItemViewItem, &voptAdj2, painter, widget); + const QModelIndex indexFirst = itemView->model()->index(0,0); + const QModelIndex indexLast = itemView->model()->index( + itemView->model()->rowCount()-1,itemView->model()->columnCount()-1); + if (itemView->viewport()) + voptAdj2.rect = QRect( itemView->visualRect(indexFirst).topLeft(), + itemView->visualRect(indexLast).bottomRight()).intersect(itemView->viewport()->rect()); + drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget); } - } else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, option, painter, widget);} + } else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget);} // draw the focus rect if (isSelected) { QRect highlightRect = option->rect.adjusted(1,1,-1,-1); - const QAbstractItemView *view = qobject_cast(widget); - if (view && view->selectionBehavior() != QAbstractItemView::SelectItems) { + QAbstractItemView::SelectionBehavior selectionBehavior = + itemView ? itemView->selectionBehavior() : QAbstractItemView::SelectItems; + if (selectionBehavior != QAbstractItemView::SelectItems) { // set highlight rect so that it is continuous from cell to cell, yet sligthly // smaller than cell rect int xBeginning = 0, yBeginning = 0, xEnd = 0, yEnd = 0; - if (view->selectionBehavior() == QAbstractItemView::SelectRows) { + if (selectionBehavior == QAbstractItemView::SelectRows) { yBeginning = 1; yEnd = -1; if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) xBeginning = 1; else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) xEnd = -1; - } else if (view->selectionBehavior() == QAbstractItemView::SelectColumns) { + } else if (selectionBehavior == QAbstractItemView::SelectColumns) { xBeginning = 1; xEnd = -1; if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) yBeginning = 1; @@ -1380,7 +1379,9 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, } highlightRect = option->rect.adjusted(xBeginning, yBeginning, xEnd, yEnd); } - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, highlightRect, flags); + if (vopt->showDecorationSelected && + (vopt->palette.highlight().color() == d->themePalette()->highlight().color())) + QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, highlightRect, flags); } // draw the icon @@ -1389,48 +1390,44 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, voptAdj.icon.paint(painter, iconRect, voptAdj.decorationAlignment, mode, state); // Draw selection check mark. Show check mark only in multi selection modes. - if (const QListView *listView = (qobject_cast(widget))) { + if (itemView) { const bool singleSelection = - listView && - (listView->selectionMode() == QAbstractItemView::SingleSelection || - listView->selectionMode() == QAbstractItemView::NoSelection); + (itemView->selectionMode() == QAbstractItemView::SingleSelection || + itemView->selectionMode() == QAbstractItemView::NoSelection); const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget); + + QStyleOptionViewItemV4 checkMarkOption(voptAdj); + // Draw selection mark. if (voptAdj.state & QStyle::State_Selected && !singleSelection) { - QStyleOptionViewItemV4 option(voptAdj); - option.rect = selectionRect; - // Draw selection mark. - drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &option, painter, widget); + checkMarkOption.rect = selectionRect; + drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); if ( textRect.right() > selectionRect.left() ) textRect.setRight(selectionRect.left()); } else if (singleSelection && - voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator) { - // draw the check mark - if (selectionRect.isValid()) { - QStyleOptionViewItemV4 option(*vopt); - option.rect = selectionRect; - option.state = option.state & ~QStyle::State_HasFocus; - - switch (vopt->checkState) { - case Qt::Unchecked: - option.state |= QStyle::State_Off; - break; - case Qt::PartiallyChecked: - option.state |= QStyle::State_NoChange; - break; - case Qt::Checked: - option.state |= QStyle::State_On; - break; - } - drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &option, painter, widget); + voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator && + selectionRect.isValid()) { + checkMarkOption.rect = selectionRect; + checkMarkOption.state = checkMarkOption.state & ~QStyle::State_HasFocus; + + switch (vopt->checkState) { + case Qt::Unchecked: + checkMarkOption.state |= QStyle::State_Off; + break; + case Qt::PartiallyChecked: + checkMarkOption.state |= QStyle::State_NoChange; + break; + case Qt::Checked: + checkMarkOption.state |= QStyle::State_On; + break; } + drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); } } // draw the text if (!voptAdj.text.isEmpty()) { - const QStyleOptionViewItemV4 *tableOption = qstyleoption_cast(option); if (isSelected) { - if (qobject_cast(widget) && tableOption) + if (qobject_cast(widget)) voptAdj.palette.setColor( QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); else @@ -1723,8 +1720,11 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, // direction is set to north (and south when in RightToLeft) const QS60StylePrivate::SkinElementFlag arrowDirection = (arrowOptions.direction == Qt::LeftToRight) ? QS60StylePrivate::SF_PointNorth : QS60StylePrivate::SF_PointSouth; + painter->save(); + painter->setPen(option->palette.windowText().color()); QS60StylePrivate::drawSkinPart(QS60StyleEnums::SP_QgnIndiSubMenu, painter, arrowOptions.rect, (flags | QS60StylePrivate::SF_ColorSkinned | arrowDirection)); + painter->restore(); } //draw text @@ -1831,8 +1831,12 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, break; #endif //QT_NO_TOOLBAR case CE_ShapedFrame: - if (qobject_cast(widget)) { - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags); + if (const QTextEdit *textEdit = qobject_cast(widget)) { + const QStyleOptionFrame *frame = qstyleoption_cast(option); + if (frame->palette.base().color()==Qt::transparent) + QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags); + else + QCommonStyle::drawControl(element, option, painter, widget); } else if (qobject_cast(widget)) { QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableItem, painter, option->rect, flags); } else if (const QHeaderView *header = qobject_cast(widget)) { @@ -1897,7 +1901,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, painter->setBrush(d->themePalette()->light()); painter->setRenderHint(QPainter::Antialiasing); const qreal roundRectRadius = 4 * goldenRatio; - painter->drawRoundedRect(option->rect, roundRectRadius, roundRectRadius); + painter->drawRoundedRect(option->rect, roundRectRadius, roundRectRadius); painter->restore(); } break; @@ -1911,6 +1915,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, */ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { + Q_D(const QS60Style); const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; switch (element) { #ifndef QT_NO_LINEEDIT @@ -1920,19 +1925,27 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti if (widget && qobject_cast(widget->parentWidget())) break; #endif - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_FrameLineEdit, - painter, option->rect, flags); + QBrush editBrush = option->palette.brush(QPalette::Base); + if (editBrush.color() == Qt::transparent) + QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_FrameLineEdit, + painter, option->rect, flags); + else + QCommonStyle::drawPrimitive(element, option, painter, widget); } break; #endif // QT_NO_LINEEDIT case PE_IndicatorCheckBox: { - const QRect indicatorRect = option->rect; // Draw checkbox indicator as color skinned graphics. const QS60StyleEnums::SkinParts skinPart = (option->state & QStyle::State_On) ? QS60StyleEnums::SP_QgnIndiCheckboxOn : QS60StyleEnums::SP_QgnIndiCheckboxOff; - QS60StylePrivate::drawSkinPart(skinPart, painter, indicatorRect, - (flags | QS60StylePrivate::SF_ColorSkinned)); + painter->save(); + QColor themeColor = d->s60Color(QS60StyleEnums::CL_QsnIconColors, 13, option); + QColor buttonTextColor = option->palette.buttonText().color(); + if (themeColor != buttonTextColor) + painter->setPen(buttonTextColor); + QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags | QS60StylePrivate::SF_ColorSkinned ); + painter->restore(); } break; case PE_IndicatorViewItemCheck: @@ -1972,21 +1985,33 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti const int newY = (buttonRect.bottomRight().y() - option->rect.bottomRight().y()) >> 1 ; buttonRect.adjust(0,-newY,0,-newY); + painter->save(); + QColor themeColor = d->s60Color(QS60StyleEnums::CL_QsnIconColors, 13, option); + QColor buttonTextColor = option->palette.buttonText().color(); + if (themeColor != buttonTextColor) + painter->setPen(buttonTextColor); + // Draw radiobutton indicator as color skinned graphics. QS60StyleEnums::SkinParts skinPart = (option->state & QStyle::State_On) ? QS60StyleEnums::SP_QgnIndiRadiobuttOn : QS60StyleEnums::SP_QgnIndiRadiobuttOff; QS60StylePrivate::drawSkinPart(skinPart, painter, buttonRect, (flags | QS60StylePrivate::SF_ColorSkinned)); + painter->restore(); } break; case PE_PanelButtonCommand: case PE_PanelButtonTool: case PE_PanelButtonBevel: case PE_FrameButtonBevel: { - const bool isPressed = option->state & QStyle::State_Sunken; - const QS60StylePrivate::SkinElements skinElement = - isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal; - QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); + QBrush editBrush = option->palette.brush(QPalette::Base); + if (editBrush.color() == Qt::transparent) { + const bool isPressed = option->state & QStyle::State_Sunken; + const QS60StylePrivate::SkinElements skinElement = + isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal; + QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); + } else { + QCommonStyle::drawPrimitive(element, option, painter, widget); + } } break; #ifndef QT_NO_TOOLBUTTON @@ -2013,21 +2038,29 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti case PE_IndicatorSpinUp: if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { QStyleOptionSpinBox optionSpinBox = *spinBox; - const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ? - QS60StyleEnums::SP_QgnGrafScrollArrowUp : - QS60StyleEnums::SP_QgnGrafScrollArrowDown; - const int adjustment = qMin(optionSpinBox.rect.width(), optionSpinBox.rect.height())/6; - optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment ); - QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect,flags); + if (optionSpinBox.palette.base().color()==Qt::transparent) { + const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ? + QS60StyleEnums::SP_QgnGrafScrollArrowUp : + QS60StyleEnums::SP_QgnGrafScrollArrowDown; + const int adjustment = qMin(optionSpinBox.rect.width(), optionSpinBox.rect.height())/6; + optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment ); + QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect,flags); + } else { + QCommonStyle::drawPrimitive(element, &optionSpinBox, painter, widget); + } } #ifndef QT_NO_COMBOBOX else if (const QStyleOptionFrame *cmb = qstyleoption_cast(option)) { - // We want to draw down arrow here for comboboxes as well. - const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown; - QStyleOptionFrame comboBox = *cmb; - const int adjustment = qMin(comboBox.rect.width(), comboBox.rect.height())/6; - comboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment ); - QS60StylePrivate::drawSkinPart(part, painter, comboBox.rect,flags); + if (cmb->palette.base().color()==Qt::transparent) { + // We want to draw down arrow here for comboboxes as well. + const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown; + QStyleOptionFrame comboBox = *cmb; + const int adjustment = qMin(comboBox.rect.width(), comboBox.rect.height())/6; + comboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment ); + QS60StylePrivate::drawSkinPart(part, painter, comboBox.rect,flags); + } else { + QCommonStyle::drawPrimitive(element, cmb, painter, widget); + } } #endif //QT_NO_COMBOBOX break; @@ -2057,8 +2090,12 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti || qobject_cast (widget) #endif //QT_NO_MENU ) { - QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_OptionsMenu; - QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); + if (option->palette.base().color()==Qt::transparent) { + QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_OptionsMenu; + QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); + } else { + QCommonStyle::drawPrimitive(element, option, painter, widget); + } } break; case PE_FrameWindow: @@ -2145,7 +2182,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti drawSkinPart = true; } - if ( drawSkinPart ) + if (drawSkinPart) QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags); if (option->state & State_Children) { @@ -2890,7 +2927,7 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, return QCommonStyle::standardIconImplementation(standardIcon, option, widget); } const QS60StylePrivate::SkinElementFlags flags = adjustedFlags; - const QPixmap cachedPixMap(QS60StylePrivate::cachedPart(part, iconSize.size(), flags)); + const QPixmap cachedPixMap(QS60StylePrivate::cachedPart(part, iconSize.size(), 0, flags)); return cachedPixMap.isNull() ? QCommonStyle::standardIconImplementation(standardIcon, option, widget) : QIcon(cachedPixMap); } diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 8e53eee..54af757 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -372,7 +372,7 @@ public: SF_StateEnabled = 0x0010, // Enabled = the default SF_StateDisabled = 0x0020, - SF_ColorSkinned = 0x0040, + SF_ColorSkinned = 0x0040, // pixmap is colored with foreground pen color }; enum CacheClearReason { @@ -472,7 +472,7 @@ private: const QRect &rect, SkinElementFlags flags = KDefaultSkinElementFlags); static QPixmap cachedPart(QS60StyleEnums::SkinParts part, const QSize &size, - SkinElementFlags flags = KDefaultSkinElementFlags); + QPainter *painter, SkinElementFlags flags = KDefaultSkinElementFlags); static QPixmap cachedFrame(SkinFrameElements frame, const QSize &size, SkinElementFlags flags = KDefaultSkinElementFlags); @@ -489,7 +489,7 @@ private: static QSize partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags = KDefaultSkinElementFlags); static QPixmap part(QS60StyleEnums::SkinParts part, const QSize &size, - SkinElementFlags flags = KDefaultSkinElementFlags); + QPainter *painter, SkinElementFlags flags = KDefaultSkinElementFlags); static QFont s60Font_specific(QS60StyleEnums::FontCategories fontCategory, int pointSize); diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 9765066..678844c 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -99,7 +99,7 @@ public: const QSize &size, QS60StylePrivate::SkinElementFlags flags); static QPixmap skinnedGraphics(QS60StylePrivate::SkinFrameElements frameElement, const QSize &size, QS60StylePrivate::SkinElementFlags flags); static QPixmap colorSkinnedGraphics(const QS60StyleEnums::SkinParts &stylepart, - const QSize &size, QS60StylePrivate::SkinElementFlags flags); + const QSize &size, QPainter *painter, QS60StylePrivate::SkinElementFlags flags); static QColor colorValue(const TAknsItemID &colorGroup, int colorIndex); static QPixmap fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask, QS60StylePrivate::SkinElementFlags flags, QImage::Format format); static bool disabledPartGraphic(QS60StyleEnums::SkinParts &part); @@ -112,14 +112,12 @@ private: const QSize &size, QS60StylePrivate::SkinElementFlags flags); static QPixmap createSkinnedGraphicsLX(QS60StylePrivate::SkinFrameElements frameElement, const QSize &size, QS60StylePrivate::SkinElementFlags flags); static QPixmap colorSkinnedGraphicsLX(const QS60StyleEnums::SkinParts &stylepart, - const QSize &size, QS60StylePrivate::SkinElementFlags flags); + const QSize &size, QPainter *painter, QS60StylePrivate::SkinElementFlags flags); static void frameIdAndCenterId(QS60StylePrivate::SkinFrameElements frameElement, TAknsItemID &frameId, TAknsItemID ¢erId); static TRect innerRectFromElement(QS60StylePrivate::SkinFrameElements frameElement, const TRect &outerRect); static void checkAndUnCompressBitmapL(CFbsBitmap*& aOriginalBitmap); static void checkAndUnCompressBitmap(CFbsBitmap*& aOriginalBitmap); static void unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap* aTrgBitmap, CFbsBitmap* aSrcBitmap); - static void colorGroupAndIndex(QS60StyleEnums::SkinParts skinID, - TAknsItemID &colorGroup, int &colorIndex); static void fallbackInfo(const QS60StyleEnums::SkinParts &stylepart, TDes& fallbackFileName, TInt& fallbackIndex); static bool checkSupport(const int supportedRelease); static TAknsItemID checkAndUpdateReleaseSpecificGraphics(int part); @@ -361,11 +359,11 @@ QPixmap QS60StyleModeSpecifics::skinnedGraphics( } QPixmap QS60StyleModeSpecifics::colorSkinnedGraphics( - const QS60StyleEnums::SkinParts &stylepart, - const QSize &size, QS60StylePrivate::SkinElementFlags flags) + const QS60StyleEnums::SkinParts &stylepart, const QSize &size, QPainter *painter, + QS60StylePrivate::SkinElementFlags flags) { QPixmap colorGraphics; - TRAPD(error, QT_TRYCATCH_LEAVING(colorGraphics = colorSkinnedGraphicsLX(stylepart, size, flags))); + TRAPD(error, QT_TRYCATCH_LEAVING(colorGraphics = colorSkinnedGraphicsLX(stylepart, size, painter, flags))); return error ? QPixmap() : colorGraphics; } @@ -525,7 +523,7 @@ void QS60StyleModeSpecifics::fallbackInfo(const QS60StyleEnums::SkinParts &style QPixmap QS60StyleModeSpecifics::colorSkinnedGraphicsLX( const QS60StyleEnums::SkinParts &stylepart, - const QSize &size, QS60StylePrivate::SkinElementFlags flags) + const QSize &size, QPainter *painter, QS60StylePrivate::SkinElementFlags flags) { // this function can throw both exceptions and leaves. There are no cleanup dependencies between Qt and Symbian parts. const int stylepartIndex = (int)stylepart; @@ -537,8 +535,13 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphicsLX( fallbackInfo(stylepart, fileNamePtr, fallbackGraphicID); TAknsItemID colorGroup = KAknsIIDQsnIconColors; - int colorIndex = 0; - colorGroupAndIndex(stylepart, colorGroup, colorIndex); + TRgb defaultColor = KRgbBlack; + int colorIndex = -1; //set a bogus value to color index to ensure that painter color is used + //to color the icon + if (painter) { + QRgb widgetColor = painter->pen().color().rgb(); + defaultColor = TRgb(qRed(widgetColor), qGreen(widgetColor), qBlue(widgetColor)); + } const bool rotatedBy90or270 = (flags & (QS60StylePrivate::SF_PointEast | QS60StylePrivate::SF_PointWest)); @@ -550,7 +553,7 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphicsLX( fallbackGraphicID == KErrNotFound?KErrNotFound:fallbackGraphicID+1; //masks are auto-generated as next in mif files MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); AknsUtils::CreateColorIconLC( - skinInstance, skinId, colorGroup, colorIndex, icon, iconMask, fileNamePtr, fallbackGraphicID , fallbackGraphicsMaskID, KRgbBlack); + skinInstance, skinId, colorGroup, colorIndex, icon, iconMask, fileNamePtr, fallbackGraphicID , fallbackGraphicsMaskID, defaultColor); User::LeaveIfError(AknIconUtils::SetSize(icon, targetSize, EAspectRatioNotPreserved)); User::LeaveIfError(AknIconUtils::SetSize(iconMask, targetSize, EAspectRatioNotPreserved)); QPixmap result = fromFbsBitmap(icon, iconMask, flags, qt_TDisplayMode2Format(icon->DisplayMode())); @@ -652,8 +655,8 @@ QPoint qt_s60_fill_background_offset(const QWidget *targetWidget) } QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX( - QS60StyleEnums::SkinParts part, - const QSize &size, QS60StylePrivate::SkinElementFlags flags) + QS60StyleEnums::SkinParts part, const QSize &size, + QS60StylePrivate::SkinElementFlags flags) { // this function can throw both exceptions and leaves. There are no cleanup dependencies between Qt and Symbian parts. if (!size.isValid()) @@ -700,13 +703,13 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX( CleanupStack::PushL(background); User::LeaveIfError(background->Create(targetSize, EColor16MA)); - CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(background); + CFbsBitmapDevice *dev = CFbsBitmapDevice::NewL(background); CleanupStack::PushL(dev); - CFbsBitGc* gc = NULL; + CFbsBitGc *gc = NULL; User::LeaveIfError(dev->CreateContext(gc)); CleanupStack::PushL(gc); - CAknsBasicBackgroundControlContext* bgContext = CAknsBasicBackgroundControlContext::NewL( + CAknsBasicBackgroundControlContext *bgContext = CAknsBasicBackgroundControlContext::NewL( skinId, targetSize, EFalse); @@ -1145,12 +1148,12 @@ QPixmap QS60StyleModeSpecifics::generateMissingThemeGraphic(QS60StyleEnums::Skin } QPixmap QS60StylePrivate::part(QS60StyleEnums::SkinParts part, - const QSize &size, SkinElementFlags flags) + const QSize &size, QPainter *painter, SkinElementFlags flags) { QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); QPixmap result = (flags & SF_ColorSkinned)? - QS60StyleModeSpecifics::colorSkinnedGraphics(part, size, flags) + QS60StyleModeSpecifics::colorSkinnedGraphics(part, size, painter, flags) : QS60StyleModeSpecifics::skinnedGraphics(part, size, flags); lock.relock(); @@ -1189,7 +1192,7 @@ QPixmap QS60StylePrivate::backgroundTexture() { if (!m_background) { QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen, - QSize(S60->screenWidthInPixels, S60->screenHeightInPixels), SkinElementFlags()); + QSize(S60->screenWidthInPixels, S60->screenHeightInPixels), 0, SkinElementFlags()); m_background = new QPixmap(background); } return *m_background; @@ -1343,26 +1346,6 @@ QSize QS60StylePrivate::screenSize() return QSize(screenSize.iWidth, screenSize.iHeight); } -void QS60StyleModeSpecifics::colorGroupAndIndex( - QS60StyleEnums::SkinParts skinID, TAknsItemID &colorGroup, int &colorIndex) -{ - switch(skinID) { - case QS60StyleEnums::SP_QgnIndiSubMenu: - colorGroup = KAknsIIDQsnIconColors; - colorIndex = EAknsCIQsnIconColorsCG1; - break; - case QS60StyleEnums::SP_QgnIndiRadiobuttOff: - case QS60StyleEnums::SP_QgnIndiRadiobuttOn: - case QS60StyleEnums::SP_QgnIndiCheckboxOff: - case QS60StyleEnums::SP_QgnIndiCheckboxOn: - colorGroup = KAknsIIDQsnIconColors; - colorIndex = EAknsCIQsnIconColorsCG14; - break; - default: - break; - } -} - QS60Style::QS60Style() : QCommonStyle(*new QS60StylePrivate) { diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp index 8a2616d..14f0424 100644 --- a/src/gui/styles/qs60style_simulated.cpp +++ b/src/gui/styles/qs60style_simulated.cpp @@ -189,8 +189,10 @@ QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list, } QPixmap QS60StylePrivate::part(QS60StyleEnums::SkinParts part, const QSize &size, - QS60StylePrivate::SkinElementFlags flags) + QPainter *painter, QS60StylePrivate::SkinElementFlags flags) { + Q_UNUSED(painter); + const QString partKey = QS60Style::partKeys().at(part); const QPicture partPicture = QS60StyleModeSpecifics::m_partPictures.value(partKey); QSize partSize(partPicture.boundingRect().size()); -- cgit v0.12 From 89ccbd14fe8c0e6b0fefcca2151da28d98088bf5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 29 Oct 2009 16:48:38 +0100 Subject: do not crash --- .../linguist/lupdate/testdata/good/parsecpp/main.cpp | 19 +++++++++++++++++++ .../lupdate/testdata/good/parsecpp/project.ts.result | 8 ++++++++ tools/linguist/lupdate/cpp.cpp | 12 +++++++----- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp index 8201add..e243e66 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp @@ -228,3 +228,22 @@ QT_TRID_NOOP("this_a_id") //~ some thing //% "This needs to be here. Really." QString test = qtTrId("this_another_id", n); + + + +class YetAnotherTest : QObject { + Q_OBJECT + + int function(void) + { + // + //: + //= + //~ + //# + //============= + //~~~~~~~~~~~~~ + //::::::::::::: + tr("nothing"); + } +}; diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result index d63c7c3..26e5a65 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result @@ -278,6 +278,14 @@ backslashed \ stuff. + YetAnotherTest + + + nothing + + + + scope diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index 6374912..4d89156 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -1896,25 +1896,26 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) prospectiveContext.clear(); } break; - case Tok_Comment: + case Tok_Comment: { if (!tor) goto case_default; - if (yyWord.at(0) == QLatin1Char(':') && yyWord.at(1).isSpace()) { + const QChar *ptr = yyWord.unicode(); + if (*ptr == QLatin1Char(':') && ptr[1].isSpace()) { yyWord.remove(0, 2); extracomment += yyWord; extracomment.detach(); - } else if (yyWord.at(0) == QLatin1Char('=') && yyWord.at(1).isSpace()) { + } else if (*ptr == QLatin1Char('=') && ptr[1].isSpace()) { yyWord.remove(0, 2); msgid = yyWord.simplified(); msgid.detach(); - } else if (yyWord.at(0) == QLatin1Char('~') && yyWord.at(1).isSpace()) { + } else if (*ptr == QLatin1Char('~') && ptr[1].isSpace()) { yyWord.remove(0, 2); text = yyWord.trimmed(); int k = text.indexOf(QLatin1Char(' ')); if (k > -1) extra.insert(text.left(k), text.mid(k + 1).trimmed()); text.clear(); - } else if (yyWord.at(0) == QLatin1Char('%') && yyWord.at(1).isSpace()) { + } else if (*ptr == QLatin1Char('%') && ptr[1].isSpace()) { sourcetext.reserve(sourcetext.length() + yyWord.length() - 2); ushort *ptr = (ushort *)sourcetext.data() + sourcetext.length(); int p = 2, c; @@ -1977,6 +1978,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) } yyTok = getToken(); break; + } case Tok_Arrow: yyTok = getToken(); if (yyTok == Tok_tr || yyTok == Tok_trUtf8) -- cgit v0.12 From 7a6296197cdab656053fbf1fc2584707e78cbe54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 8 Oct 2009 12:57:20 +0200 Subject: Make QT_NO_PHONON_PLATFORMPLUGIN work Reviewed-by:tom --- src/3rdparty/phonon/phonon/factory.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/phonon/phonon/factory.cpp b/src/3rdparty/phonon/phonon/factory.cpp index 5c3752a..e5adb490 100644 --- a/src/3rdparty/phonon/phonon/factory.cpp +++ b/src/3rdparty/phonon/phonon/factory.cpp @@ -189,11 +189,12 @@ bool FactoryPrivate::createBackend() } FactoryPrivate::FactoryPrivate() + : #ifndef QT_NO_PHONON_PLATFORMPLUGIN - : m_platformPlugin(0), - m_noPlatformPlugin(false) + m_platformPlugin(0), + m_noPlatformPlugin(false), #endif //QT_NO_PHONON_PLATFORMPLUGIN - , m_backendObject(0) + m_backendObject(0) { // Add the post routine to make sure that all other global statics (especially the ones from Qt) // are still available. If the FactoryPrivate dtor is called too late many bad things can happen -- cgit v0.12 From 5c4ed2858f31d6b3adcf5200c3a64fbf188a3f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 9 Oct 2009 11:20:32 +0200 Subject: Fix QFeature QT_NO_PHONON_VOLUMEFADEREFFECT Reviewed-by: Jens Bache-Wiig --- src/3rdparty/phonon/gstreamer/backend.cpp | 4 ++++ src/3rdparty/phonon/gstreamer/volumefadereffect.cpp | 4 ++-- src/3rdparty/phonon/gstreamer/volumefadereffect.h | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/phonon/gstreamer/backend.cpp b/src/3rdparty/phonon/gstreamer/backend.cpp index cd49454..ceaf94a 100644 --- a/src/3rdparty/phonon/gstreamer/backend.cpp +++ b/src/3rdparty/phonon/gstreamer/backend.cpp @@ -134,7 +134,11 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const } case VolumeFaderEffectClass: +#ifndef QT_NO_PHONON_VOLUMEFADEREFFECT return new VolumeFaderEffect(this, parent); +#else + return 0; +#endif //QT_NO_PHONON_VOLUMEFADEREFFECT case VisualizationClass: //Fall through default: diff --git a/src/3rdparty/phonon/gstreamer/volumefadereffect.cpp b/src/3rdparty/phonon/gstreamer/volumefadereffect.cpp index d7ee11b..bf0d646 100644 --- a/src/3rdparty/phonon/gstreamer/volumefadereffect.cpp +++ b/src/3rdparty/phonon/gstreamer/volumefadereffect.cpp @@ -21,11 +21,11 @@ QT_BEGIN_NAMESPACE +#ifndef QT_NO_PHONON_VOLUMEFADEREFFECT namespace Phonon { namespace Gstreamer { - VolumeFaderEffect::VolumeFaderEffect(Backend *backend, QObject *parent) : Effect(backend, parent, AudioSource | AudioSink) , m_fadeCurve(Phonon::VolumeFaderEffect::Fade3Decibel) @@ -156,7 +156,7 @@ bool VolumeFaderEffect::event(QEvent *event) } }} //namespace Phonon::Gstreamer - +#endif //QT_NO_PHONON_VOLUMEFADEREFFECT QT_END_NAMESPACE #include "moc_volumefadereffect.cpp" diff --git a/src/3rdparty/phonon/gstreamer/volumefadereffect.h b/src/3rdparty/phonon/gstreamer/volumefadereffect.h index d74014c..748d2d6 100644 --- a/src/3rdparty/phonon/gstreamer/volumefadereffect.h +++ b/src/3rdparty/phonon/gstreamer/volumefadereffect.h @@ -30,7 +30,7 @@ #include QT_BEGIN_NAMESPACE - +#ifndef QT_NO_PHONON_VOLUMEFADEREFFECT namespace Phonon { namespace Gstreamer @@ -64,7 +64,7 @@ namespace Gstreamer QTime m_fadeStartTime; }; }} //namespace Phonon::Gstreamer - +#endif //QT_NO_PHONON_VOLUMEFADEREFFECT QT_END_NAMESPACE #endif // Phonon_GSTREAMER_VOLUMEFADEREFFECT_H -- cgit v0.12 From a7a70ad81a9a1f3cba5fca66c232e7d8560a2850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 9 Oct 2009 11:21:51 +0200 Subject: Fix QT_NO_IMAGEFORMAT_PNG Reviewed-by: tom --- src/gui/styles/qcommonstyle.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index 70d130a..b08dc4b 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -5169,13 +5169,12 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option, const QWidget *widget) const { + const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QApplication::isRightToLeft()); #ifdef QT_NO_IMAGEFORMAT_PNG - Q_UNUSED(option); Q_UNUSED(widget); Q_UNUSED(sp); #else QPixmap pixmap; - const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QApplication::isRightToLeft()); if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) { switch (sp) { -- cgit v0.12 From 86e3be13d870e8dce1e06f7cd0adeb8996fade7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 9 Oct 2009 11:22:24 +0200 Subject: Fix dependencies to QT_NO_PRINTPREVIEWWIDGET Reviewed-by: Trust Me --- src/corelib/global/qfeatures.h | 2 +- src/corelib/global/qfeatures.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index 36c2cf9..ab81290 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -767,7 +767,7 @@ #endif // QPrintPreviewWidget -#if !defined(QT_NO_PRINTPREVIEWWIDGET) && (defined(QT_NO_GRAPHICSVIEW) || defined(QT_NO_PRINTER)) +#if !defined(QT_NO_PRINTPREVIEWWIDGET) && (defined(QT_NO_GRAPHICSVIEW) || defined(QT_NO_PRINTER) || defined(QT_NO_TOOLBAR) || defined(QT_NO_MAINWINDOW)) #define QT_NO_PRINTPREVIEWWIDGET #endif diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index ec47883..a0928fc 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -567,7 +567,7 @@ Feature: PRINTPREVIEWWIDGET Description: Provides a widget for previewing page layouts for printer output. a date. Section: Widgets -Requires: GRAPHICSVIEW PRINTER +Requires: GRAPHICSVIEW PRINTER TOOLBAR MAINWINDOW Name: QPrintPreviewWidget SeeAlso: ??? -- cgit v0.12 From 854df9c08635fd175f6658e66320d8fa2360389a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 9 Oct 2009 15:51:57 +0200 Subject: The PRINTER feature now depends on TEMPORARYFILE Reviewed-by: Trust Me --- src/corelib/global/qfeatures.h | 2 +- src/corelib/global/qfeatures.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index ab81290..b18196e 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -522,7 +522,7 @@ #endif // QPrinter -#if !defined(QT_NO_PRINTER) && (defined(QT_NO_TEXTSTREAM) || defined(QT_NO_PICTURE)) +#if !defined(QT_NO_PRINTER) && (defined(QT_NO_TEXTSTREAM) || defined(QT_NO_PICTURE) || defined(QT_NO_TEMPORARYFILE)) #define QT_NO_PRINTER #endif diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index a0928fc..c18df62 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -910,7 +910,7 @@ SeeAlso: ??? Feature: PRINTER Description: Supports printing Section: Painting -Requires: TEXTSTREAM PICTURE +Requires: TEXTSTREAM PICTURE TEMPORARYFILE Name: QPrinter SeeAlso: ??? -- cgit v0.12 From 8c29407a7bf5af9dbcaff1ea7f24951297aa9e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 16 Oct 2009 10:42:56 +0200 Subject: Fix QT_NO_PHONON_ABSTRACTMEDIASTREAM in phonon Seemed to be missing from gstreamer backend Reviewed-by: Jens Bache-Wiig --- src/3rdparty/phonon/gstreamer/mediaobject.cpp | 5 +++++ src/3rdparty/phonon/gstreamer/phononsrc.cpp | 28 ++++++++++++++++++++++++++ src/3rdparty/phonon/gstreamer/phononsrc.h | 2 ++ src/3rdparty/phonon/gstreamer/streamreader.cpp | 3 ++- src/3rdparty/phonon/gstreamer/streamreader.h | 4 ++++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/gstreamer/mediaobject.cpp b/src/3rdparty/phonon/gstreamer/mediaobject.cpp index 5dcbd42..0b800af 100644 --- a/src/3rdparty/phonon/gstreamer/mediaobject.cpp +++ b/src/3rdparty/phonon/gstreamer/mediaobject.cpp @@ -392,6 +392,7 @@ bool MediaObject::createPipefromURL(const QUrl &url) */ bool MediaObject::createPipefromStream(const MediaSource &source) { +#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM // Remove any existing data source if (m_datasource) { gst_bin_remove(GST_BIN(m_pipeline), m_datasource); @@ -413,6 +414,10 @@ bool MediaObject::createPipefromStream(const MediaSource &source) return false; } return true; +#else //QT_NO_PHONON_ABSTRACTMEDIASTREAM + Q_UNUSED(source); + return false; +#endif } void MediaObject::createPipeline() diff --git a/src/3rdparty/phonon/gstreamer/phononsrc.cpp b/src/3rdparty/phonon/gstreamer/phononsrc.cpp index f893fb5..97d7220 100644 --- a/src/3rdparty/phonon/gstreamer/phononsrc.cpp +++ b/src/3rdparty/phonon/gstreamer/phononsrc.cpp @@ -109,18 +109,25 @@ static void phonon_src_class_init (PhononSrcClass * klass) static void phonon_src_init (PhononSrc * src, PhononSrcClass * g_class) { Q_UNUSED(g_class); +#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM src->device = 0; +#else + Q_UNUSED(src); +#endif } static void phonon_src_finalize (GObject * object) { +#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM PhononSrc *src; src = GST_PHONON_SRC (object); delete src->device; src->device = 0; +#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM G_OBJECT_CLASS (parent_class)->finalize (object); } +#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM static gboolean phonon_src_set_device(PhononSrc * src, StreamReader* device) { GstState state; @@ -145,6 +152,7 @@ wrong_state: return FALSE; } } +#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM static void phonon_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { @@ -153,6 +161,7 @@ static void phonon_src_set_property (GObject * object, guint prop_id, const GVal src = GST_PHONON_SRC (object); switch (prop_id) { +#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM case ARG_PHONONSRC: { StreamReader *dev = (StreamReader*)(g_value_get_pointer(value)); @@ -160,6 +169,9 @@ static void phonon_src_set_property (GObject * object, guint prop_id, const GVal phonon_src_set_device(src, dev); break; } +#else + Q_UNUSED(value); +#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -174,9 +186,13 @@ static void phonon_src_get_property (GObject * object, guint prop_id, GValue * v src = GST_PHONON_SRC (object); switch (prop_id) { +#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM case ARG_PHONONSRC: g_value_set_pointer(value, src->device); break; +#else //QT_NO_PHONON_ABSTRACTMEDIASTREAM + Q_UNUSED(value); +#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -185,6 +201,7 @@ static void phonon_src_get_property (GObject * object, guint prop_id, GValue * v static GstFlowReturn phonon_src_create_read (PhononSrc * src, guint64 offset, guint length, GstBuffer ** buffer) { +#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM Q_ASSERT(src->device); if (!src->device) return GST_FLOW_ERROR; @@ -204,6 +221,13 @@ static GstFlowReturn phonon_src_create_read (PhononSrc * src, guint64 offset, gu gst_mini_object_unref(GST_MINI_OBJECT(buf)); return GST_FLOW_ERROR; +#else //QT_NO_PHONON_ABSTRACTMEDIASTREAM + Q_UNUSED(src); + Q_UNUSED(offset); + Q_UNUSED(length); + Q_UNUSED(buffer); + return GST_FLOW_ERROR; +#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM } static GstFlowReturn phonon_src_create (GstBaseSrc * basesrc, guint64 offset, guint length, GstBuffer ** buffer) @@ -218,19 +242,23 @@ static GstFlowReturn phonon_src_create (GstBaseSrc * basesrc, guint64 offset, gu static gboolean phonon_src_is_seekable (GstBaseSrc * basesrc) { PhononSrc *src = GST_PHONON_SRC (basesrc); +#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM if (src->device) return src->device->streamSeekable(); +#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM return false; } static gboolean phonon_src_get_size (GstBaseSrc * basesrc, guint64 * size) { +#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM PhononSrc *src; src = GST_PHONON_SRC (basesrc); if (src->device && src->device->streamSeekable()) { *size = src->device->streamSize(); return TRUE; } +#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM *size = 0; return FALSE; } diff --git a/src/3rdparty/phonon/gstreamer/phononsrc.h b/src/3rdparty/phonon/gstreamer/phononsrc.h index a2cd8b3..a50f8a2 100644 --- a/src/3rdparty/phonon/gstreamer/phononsrc.h +++ b/src/3rdparty/phonon/gstreamer/phononsrc.h @@ -49,7 +49,9 @@ typedef struct _PhononSrcClass PhononSrcClass; // PhononSrc: struct _PhononSrc { GstBaseSrc element; +#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM StreamReader *device; +#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM }; struct _PhononSrcClass { diff --git a/src/3rdparty/phonon/gstreamer/streamreader.cpp b/src/3rdparty/phonon/gstreamer/streamreader.cpp index 04fa6cc..f8219e6 100644 --- a/src/3rdparty/phonon/gstreamer/streamreader.cpp +++ b/src/3rdparty/phonon/gstreamer/streamreader.cpp @@ -20,7 +20,7 @@ along with this library. If not, see . #include QT_BEGIN_NAMESPACE - +#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM namespace Phonon { namespace Gstreamer @@ -49,5 +49,6 @@ bool StreamReader::read(quint64 pos, int length, char * buffer) } } +#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/gstreamer/streamreader.h b/src/3rdparty/phonon/gstreamer/streamreader.h index c2e61c8..387370c 100644 --- a/src/3rdparty/phonon/gstreamer/streamreader.h +++ b/src/3rdparty/phonon/gstreamer/streamreader.h @@ -23,6 +23,8 @@ along with this library. If not, see . QT_BEGIN_NAMESPACE +#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM + namespace Phonon { class MediaSource; @@ -91,6 +93,8 @@ private: } } +#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM + QT_END_NAMESPACE #endif -- cgit v0.12 From 1a8a4b2ce746f357a58b04a02321824f8040b3e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 16 Oct 2009 10:44:52 +0200 Subject: Updated qfeatures.h Reviewed-by: Trust Me --- src/corelib/global/qfeatures.h | 27 ++++++++++++++------------- util/scripts/make_qfeatures_dot_h | 1 + 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index b18196e..d87cf64 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -43,6 +43,7 @@ * All features and their dependencies. * * This list is generated from $QTDIR/src/corelib/global/qfeatures.txt + * by $QTSRCDIR/util/scripts/make_qfeatures_dot_h */ // QAction @@ -521,11 +522,6 @@ #define QT_NO_LIBRARY #endif -// QPrinter -#if !defined(QT_NO_PRINTER) && (defined(QT_NO_TEXTSTREAM) || defined(QT_NO_PICTURE) || defined(QT_NO_TEMPORARYFILE)) -#define QT_NO_PRINTER -#endif - // QScrollArea #if !defined(QT_NO_SCROLLAREA) && (defined(QT_NO_SCROLLBAR)) #define QT_NO_SCROLLAREA @@ -561,6 +557,11 @@ #define QT_NO_MDIAREA #endif +// QPrinter +#if !defined(QT_NO_PRINTER) && (defined(QT_NO_TEXTSTREAM) || defined(QT_NO_PICTURE) || defined(QT_NO_TEMPORARYFILE)) +#define QT_NO_PRINTER +#endif + // QSpinBox #if !defined(QT_NO_SPINBOX) && (defined(QT_NO_SPINWIDGET) || defined(QT_NO_LINEEDIT) || defined(QT_NO_VALIDATOR)) #define QT_NO_SPINBOX @@ -731,11 +732,6 @@ #define QT_NO_COMPLETER #endif -// Common UNIX Printing System -#if !defined(QT_NO_CUPS) && (defined(QT_NO_PRINTER) || defined(QT_NO_LIBRARY)) -#define QT_NO_CUPS -#endif - // QDataWidgetMapper #if !defined(QT_NO_DATAWIDGETMAPPER) && (defined(QT_NO_ITEMVIEWS) || defined(QT_NO_PROPERTIES)) #define QT_NO_DATAWIDGETMAPPER @@ -766,9 +762,9 @@ #define QT_NO_TREEWIDGET #endif -// QPrintPreviewWidget -#if !defined(QT_NO_PRINTPREVIEWWIDGET) && (defined(QT_NO_GRAPHICSVIEW) || defined(QT_NO_PRINTER) || defined(QT_NO_TOOLBAR) || defined(QT_NO_MAINWINDOW)) -#define QT_NO_PRINTPREVIEWWIDGET +// Common UNIX Printing System +#if !defined(QT_NO_CUPS) && (defined(QT_NO_PRINTER) || defined(QT_NO_LIBRARY)) +#define QT_NO_CUPS #endif // QToolBar @@ -831,6 +827,11 @@ #define QT_NO_FONTDIALOG #endif +// QPrintPreviewWidget +#if !defined(QT_NO_PRINTPREVIEWWIDGET) && (defined(QT_NO_GRAPHICSVIEW) || defined(QT_NO_PRINTER) || defined(QT_NO_TOOLBAR) || defined(QT_NO_MAINWINDOW)) +#define QT_NO_PRINTPREVIEWWIDGET +#endif + // QWorkSpace #if !defined(QT_NO_WORKSPACE) && (defined(QT_NO_SCROLLBAR) || defined(QT_NO_RESIZEHANDLER) || defined(QT_NO_MENU) || defined(QT_NO_TOOLBUTTON) || defined(QT_NO_MAINWINDOW) || defined(QT_NO_TOOLBAR) || defined(QT_NO_MENUBAR)) #define QT_NO_WORKSPACE diff --git a/util/scripts/make_qfeatures_dot_h b/util/scripts/make_qfeatures_dot_h index bdd68a3..23d88a3 100755 --- a/util/scripts/make_qfeatures_dot_h +++ b/util/scripts/make_qfeatures_dot_h @@ -175,6 +175,7 @@ print OUT * All features and their dependencies. * * This list is generated from $QTDIR/src/corelib/global/qfeatures.txt + * by $QTSRCDIR/util/scripts/make_qfeatures_dot_h */ '; -- cgit v0.12 From 5c4130a509248e897d52e4980cc8d58f0940d76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 16 Oct 2009 11:42:00 +0200 Subject: Added QT_NO_PHONON_EFFECT to gstreamer backend Reviewed-by: Jens Bache-Wiig --- src/3rdparty/phonon/gstreamer/audioeffect.cpp | 3 ++- src/3rdparty/phonon/gstreamer/audioeffect.h | 4 ++-- src/3rdparty/phonon/gstreamer/backend.cpp | 3 ++- src/3rdparty/phonon/gstreamer/effect.cpp | 4 ++-- src/3rdparty/phonon/gstreamer/effect.h | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/3rdparty/phonon/gstreamer/audioeffect.cpp b/src/3rdparty/phonon/gstreamer/audioeffect.cpp index db72c8b..d3d7a35 100644 --- a/src/3rdparty/phonon/gstreamer/audioeffect.cpp +++ b/src/3rdparty/phonon/gstreamer/audioeffect.cpp @@ -23,7 +23,7 @@ #include "gsthelper.h" #include - +#ifndef QT_NO_PHONON_EFFECT QT_BEGIN_NAMESPACE namespace Phonon @@ -75,4 +75,5 @@ GstElement* AudioEffect::createEffectBin() } //namespace Phonon::Gstreamer QT_END_NAMESPACE +#endif //QT_NO_PHONON_EFFECT #include "moc_audioeffect.cpp" diff --git a/src/3rdparty/phonon/gstreamer/audioeffect.h b/src/3rdparty/phonon/gstreamer/audioeffect.h index 3a985e5..f49f8d2 100644 --- a/src/3rdparty/phonon/gstreamer/audioeffect.h +++ b/src/3rdparty/phonon/gstreamer/audioeffect.h @@ -29,8 +29,8 @@ #include +#ifndef QT_NO_PHONON_EFFECT QT_BEGIN_NAMESPACE - namespace Phonon { namespace Gstreamer @@ -49,7 +49,7 @@ namespace Gstreamer QString m_effectName; }; }} //namespace Phonon::Gstreamer - QT_END_NAMESPACE +#endif //QT_NO_PHONON_EFFECT #endif // Phonon_GSTREAMER_AUDIOEFFECT_H diff --git a/src/3rdparty/phonon/gstreamer/backend.cpp b/src/3rdparty/phonon/gstreamer/backend.cpp index ceaf94a..b285fd9 100644 --- a/src/3rdparty/phonon/gstreamer/backend.cpp +++ b/src/3rdparty/phonon/gstreamer/backend.cpp @@ -117,9 +117,10 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const m_audioOutputs.append(ao); return ao; } +#ifndef QT_NO_PHONON_EFFECT case EffectClass: return new AudioEffect(this, args[0].toInt(), parent); - +#endif //QT_NO_PHONON_EFFECT case AudioDataOutputClass: logMessage("createObject() : AudioDataOutput not implemented"); break; diff --git a/src/3rdparty/phonon/gstreamer/effect.cpp b/src/3rdparty/phonon/gstreamer/effect.cpp index f653535..4937246 100644 --- a/src/3rdparty/phonon/gstreamer/effect.cpp +++ b/src/3rdparty/phonon/gstreamer/effect.cpp @@ -25,8 +25,8 @@ #include +#ifndef QT_NO_PHONON_EFFECT QT_BEGIN_NAMESPACE - namespace Phonon { namespace Gstreamer @@ -241,6 +241,6 @@ void Effect::setParameterValue(const EffectParameter &p, const QVariant &v) } } //namespace Phonon::Gstreamer - QT_END_NAMESPACE +#endif //QT_NO_PHONON_EFFECT #include "moc_effect.cpp" diff --git a/src/3rdparty/phonon/gstreamer/effect.h b/src/3rdparty/phonon/gstreamer/effect.h index dbbb457..51cbe9c 100644 --- a/src/3rdparty/phonon/gstreamer/effect.h +++ b/src/3rdparty/phonon/gstreamer/effect.h @@ -28,8 +28,8 @@ #include +#ifndef QT_NO_PHONON_EFFECT QT_BEGIN_NAMESPACE - namespace Phonon { namespace Gstreamer @@ -58,7 +58,7 @@ namespace Gstreamer QList m_parameterList; }; }} //namespace Phonon::Gstreamer - QT_END_NAMESPACE +#endif //QT_NO_PHONON_EFFECT #endif // Phonon_GSTREAMER_EFFECT_H -- cgit v0.12 From 7c1122b79df61668525b63670c03c5da7e44ac9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 19 Oct 2009 09:41:57 +0200 Subject: Fix QT_NO_XMLSTREAMREADER Reviewed-by: tom --- src/corelib/xml/qxmlstream.g | 4 +++- src/corelib/xml/qxmlstream_p.h | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/corelib/xml/qxmlstream.g b/src/corelib/xml/qxmlstream.g index 3bf0e7d..6c0c0cf 100644 --- a/src/corelib/xml/qxmlstream.g +++ b/src/corelib/xml/qxmlstream.g @@ -243,7 +243,7 @@ public: class QXmlStreamEntityResolver; - +#ifndef QT_NO_XMLSTREAMREADER class QXmlStreamReaderPrivate : public QXmlStreamReader_Table, public QXmlStreamPrivateTagStack{ QXmlStreamReader *q_ptr; Q_DECLARE_PUBLIC(QXmlStreamReader) @@ -1840,4 +1840,6 @@ nmtoken ::= COLON; } return false; } +#endif //QT_NO_XMLSTREAMREADER.xml + ./ diff --git a/src/corelib/xml/qxmlstream_p.h b/src/corelib/xml/qxmlstream_p.h index ed65409..eee3a13 100644 --- a/src/corelib/xml/qxmlstream_p.h +++ b/src/corelib/xml/qxmlstream_p.h @@ -736,9 +736,9 @@ public: } }; - class QXmlStreamEntityResolver; +#ifndef QT_NO_XMLSTREAMREADER class QXmlStreamReaderPrivate : public QXmlStreamReader_Table, public QXmlStreamPrivateTagStack{ QXmlStreamReader *q_ptr; Q_DECLARE_PUBLIC(QXmlStreamReader) @@ -1959,5 +1959,6 @@ bool QXmlStreamReaderPrivate::parse() return false; } +#endif //QT_NO_XMLSTREAMREADER #endif // QXMLSTREAM_P_H -- cgit v0.12 From 7246b5a5942049b485bfdefbe133d7bb12165301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 19 Oct 2009 09:43:36 +0200 Subject: Fix QT_NO_ACTION dependencies Reviewed-by: tom --- src/corelib/global/qfeatures.h | 25 +++++++++++++++---------- src/corelib/global/qfeatures.txt | 11 +++++++++-- src/gui/kernel/qsoftkeymanager.cpp | 3 ++- src/gui/kernel/qsoftkeymanager_p.h | 2 ++ 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index d87cf64..1266be1 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -307,11 +307,6 @@ // //#define QT_NO_XMLSTREAM -// Accessibility -#if !defined(QT_NO_ACCESSIBILITY) && (defined(QT_NO_PROPERTIES)) -#define QT_NO_ACCESSIBILITY -#endif - // Animation #if !defined(QT_NO_ANIMATION) && (defined(QT_NO_PROPERTIES)) #define QT_NO_ANIMATION @@ -387,11 +382,6 @@ #define QT_NO_PHONON_VOLUMEFADEREFFECT #endif -// Phonon::VolumeSlider -#if !defined(QT_NO_PHONON_VOLUMESLIDER) && (defined(QT_NO_SLIDER)) -#define QT_NO_PHONON_VOLUMESLIDER -#endif - // QProcess #if !defined(QT_NO_PROCESS) && (defined(QT_NO_THREAD)) #define QT_NO_PROCESS @@ -442,6 +432,11 @@ #define QT_NO_SOCKS5 #endif +// QSoftKeyManager +#if !defined(QT_NO_SOFTKEYMANAGER) && (defined(QT_NO_ACTION)) +#define QT_NO_SOFTKEYMANAGER +#endif + // QSplitter #if !defined(QT_NO_SPLITTER) && (defined(QT_NO_RUBBERBAND)) #define QT_NO_SPLITTER @@ -497,6 +492,11 @@ #define QT_NO_XMLSTREAMWRITER #endif +// Accessibility +#if !defined(QT_NO_ACCESSIBILITY) && (defined(QT_NO_PROPERTIES) || defined(QT_NO_ACTION)) +#define QT_NO_ACCESSIBILITY +#endif + // Context menu #if !defined(QT_NO_CONTEXTMENU) && (defined(QT_NO_MENU)) #define QT_NO_CONTEXTMENU @@ -522,6 +522,11 @@ #define QT_NO_LIBRARY #endif +// Phonon::VolumeSlider +#if !defined(QT_NO_PHONON_VOLUMESLIDER) && (defined(QT_NO_SLIDER) || defined(QT_NO_ACTION)) +#define QT_NO_PHONON_VOLUMESLIDER +#endif + // QScrollArea #if !defined(QT_NO_SCROLLAREA) && (defined(QT_NO_SCROLLBAR)) #define QT_NO_SCROLLAREA diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index c18df62..9d4eb5e 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -70,6 +70,13 @@ Requires: Name: QAction SeeAlso: ??? +Feature: SOFTKEYMANAGER +Description: Supports softkeys. +Section: Gui +Requires: ACTION +Name: QSoftKeyManager +SeeAlso: ??? + Feature: CURSOR Description: Supports mouse cursors. Section: Kernel @@ -1146,7 +1153,7 @@ SeeAlso: ??? Feature: ACCESSIBILITY Description: Provides accessibility support. Section: Utilities -Requires: PROPERTIES +Requires: PROPERTIES ACTION Name: Accessibility SeeAlso: ??? @@ -1403,7 +1410,7 @@ SeeAlso: ??? Feature: PHONON_VOLUMESLIDER Description: Support for the Volume Slider class Section: Phonon -Requires: SLIDER +Requires: SLIDER ACTION Name: Phonon::VolumeSlider SeeAlso: ??? diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index 75c321e..5249dab 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -48,6 +48,7 @@ #include "private/qsoftkeymanager_p.h" #include "private/qobject_p.h" +#ifndef QT_NO_SOFTKEYMANAGER QT_BEGIN_NAMESPACE #ifdef Q_WS_S60 @@ -277,4 +278,4 @@ void QSoftKeyManagerPrivate::updateSoftKeys_sys(const QList &) #endif QT_END_NAMESPACE - +#endif //QT_NO_SOFTKEYMANAGER diff --git a/src/gui/kernel/qsoftkeymanager_p.h b/src/gui/kernel/qsoftkeymanager_p.h index b455445..62d872f 100644 --- a/src/gui/kernel/qsoftkeymanager_p.h +++ b/src/gui/kernel/qsoftkeymanager_p.h @@ -58,6 +58,7 @@ QT_BEGIN_HEADER +#ifndef QT_NO_SOFTKEYMANAGER QT_BEGIN_NAMESPACE class QSoftKeyManagerPrivate; @@ -100,6 +101,7 @@ private Q_SLOTS: }; QT_END_NAMESPACE +#endif //QT_NO_SOFTKEYMANAGER QT_END_HEADER -- cgit v0.12 From e55810dc838e95c60a275f1ea3be3bb6bb93fb83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 19 Oct 2009 10:59:39 +0200 Subject: Fix QT_NO_PROPERTIES However, there are some stuff added to qscript that I'm really not sure about. Reviewed-by: tom --- src/3rdparty/phonon/gstreamer/backend.cpp | 3 ++- src/3rdparty/phonon/phonon/factory.cpp | 3 ++- src/script/bridge/qscriptqobject.cpp | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/phonon/gstreamer/backend.cpp b/src/3rdparty/phonon/gstreamer/backend.cpp index b285fd9..647bb6f 100644 --- a/src/3rdparty/phonon/gstreamer/backend.cpp +++ b/src/3rdparty/phonon/gstreamer/backend.cpp @@ -55,12 +55,13 @@ Backend::Backend(QObject *parent, const QVariantList &) g_error_free(err); qRegisterMetaType("Message"); - +#ifndef QT_NO_PROPERTIES setProperty("identifier", QLatin1String("phonon_gstreamer")); setProperty("backendName", QLatin1String("Gstreamer")); setProperty("backendComment", QLatin1String("Gstreamer plugin for Phonon")); setProperty("backendVersion", QLatin1String("0.2")); setProperty("backendWebsite", QLatin1String("http://qt.nokia.com/")); +#endif //QT_NO_PROPERTIES //check if we should enable debug output QString debugLevelString = qgetenv("PHONON_GST_DEBUG"); diff --git a/src/3rdparty/phonon/phonon/factory.cpp b/src/3rdparty/phonon/phonon/factory.cpp index e5adb490..881aca3 100644 --- a/src/3rdparty/phonon/phonon/factory.cpp +++ b/src/3rdparty/phonon/phonon/factory.cpp @@ -443,6 +443,7 @@ QObject *Factory::backend(bool createWhenNull) return globalFactory->m_backendObject; } +#ifndef QT_NO_PROPERTIES #define GET_STRING_PROPERTY(name) \ QString Factory::name() \ { \ @@ -458,7 +459,7 @@ GET_STRING_PROPERTY(backendComment) GET_STRING_PROPERTY(backendVersion) GET_STRING_PROPERTY(backendIcon) GET_STRING_PROPERTY(backendWebsite) - +#endif //QT_NO_PROPERTIES QObject *Factory::registerQObject(QObject *o) { if (o) { diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp index 345489f..caf1018 100644 --- a/src/script/bridge/qscriptqobject.cpp +++ b/src/script/bridge/qscriptqobject.cpp @@ -1190,6 +1190,7 @@ bool QObjectDelegate::getOwnPropertySlot(QScriptObject *object, JSC::ExecState * const JSC::Identifier &propertyName, JSC::PropertySlot &slot) { +#ifndef QT_NO_PROPERTIES QByteArray name = QString(propertyName.ustring()).toLatin1(); QObject *qobject = data->value; if (!qobject) { @@ -1296,12 +1297,16 @@ bool QObjectDelegate::getOwnPropertySlot(QScriptObject *object, JSC::ExecState * } return QScriptObjectDelegate::getOwnPropertySlot(object, exec, propertyName, slot); +#else //QT_NO_PROPERTIES + return false; +#endif //QT_NO_PROPERTIES } void QObjectDelegate::put(QScriptObject *object, JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue value, JSC::PutPropertySlot &slot) { +#ifndef QT_NO_PROPERTIES QByteArray name = ((QString)propertyName.ustring()).toLatin1(); QObject *qobject = data->value; if (!qobject) { @@ -1392,12 +1397,14 @@ void QObjectDelegate::put(QScriptObject *object, JSC::ExecState* exec, } QScriptObjectDelegate::put(object, exec, propertyName, value, slot); +#endif //QT_NO_PROPERTIES } bool QObjectDelegate::deleteProperty(QScriptObject *object, JSC::ExecState *exec, const JSC::Identifier& propertyName, bool checkDontDelete) { +#ifndef QT_NO_PROPERTIES QByteArray name = ((QString)propertyName.ustring()).toLatin1(); QObject *qobject = data->value; if (!qobject) { @@ -1436,6 +1443,9 @@ bool QObjectDelegate::deleteProperty(QScriptObject *object, JSC::ExecState *exec } return QScriptObjectDelegate::deleteProperty(object, exec, propertyName, checkDontDelete); +#else //QT_NO_PROPERTIES + return false; +#endif //QT_NO_PROPERTIES } bool QObjectDelegate::getPropertyAttributes(const QScriptObject *object, @@ -1443,6 +1453,7 @@ bool QObjectDelegate::getPropertyAttributes(const QScriptObject *object, const JSC::Identifier &propertyName, unsigned &attributes) const { +#ifndef QT_NO_PROPERTIES // ### try to avoid duplicating logic from getOwnPropertySlot() QByteArray name = ((QString)propertyName.ustring()).toLatin1(); QObject *qobject = data->value; @@ -1511,12 +1522,16 @@ bool QObjectDelegate::getPropertyAttributes(const QScriptObject *object, } return QScriptObjectDelegate::getPropertyAttributes(object, exec, propertyName, attributes); +#else //QT_NO_PROPERTIES + return false; +#endif //QT_NO_PROPERTIES } void QObjectDelegate::getOwnPropertyNames(QScriptObject *object, JSC::ExecState *exec, JSC::PropertyNameArray &propertyNames, bool includeNonEnumerable) { +#ifndef QT_NO_PROPERTIES QObject *qobject = data->value; if (!qobject) { QString message = QString::fromLatin1("cannot get property names of deleted QObject"); @@ -1560,6 +1575,7 @@ void QObjectDelegate::getOwnPropertyNames(QScriptObject *object, JSC::ExecState } QScriptObjectDelegate::getOwnPropertyNames(object, exec, propertyNames, includeNonEnumerable); +#endif //QT_NO_PROPERTIES } void QObjectDelegate::markChildren(QScriptObject *object, JSC::MarkStack& markStack) -- cgit v0.12 From 6eb1faad9511dde6ab31b9a4f75fce0bdfbdc12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 19 Oct 2009 13:55:38 +0200 Subject: Fixed MENU and QWS_PROXYSCREEN Reviewed-by: tom --- src/corelib/global/qfeatures.h | 20 +++++++++++++++----- src/corelib/global/qfeatures.txt | 16 +++++++++++++++- src/plugins/gfxdrivers/transformed/main.cpp | 5 ++++- src/plugins/gfxdrivers/vnc/main.cpp | 5 ++++- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index 1266be1..c9dfabb 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -417,6 +417,16 @@ #define QT_NO_QWS_MANAGER #endif +// QVncTransformed +#if !defined(QT_NO_QWS_TRANSFORMED) && (defined(QT_NO_QWS_PROXYSCREEN)) +#define QT_NO_QWS_TRANSFORMED +#endif + +// QVncScreen +#if !defined(QT_NO_QWS_VNC) && (defined(QT_NO_QWS_PROXYSCREEN)) +#define QT_NO_QWS_VNC +#endif + // QScrollBar #if !defined(QT_NO_SCROLLBAR) && (defined(QT_NO_SLIDER)) #define QT_NO_SCROLLBAR @@ -492,11 +502,6 @@ #define QT_NO_XMLSTREAMWRITER #endif -// Accessibility -#if !defined(QT_NO_ACCESSIBILITY) && (defined(QT_NO_PROPERTIES) || defined(QT_NO_ACTION)) -#define QT_NO_ACCESSIBILITY -#endif - // Context menu #if !defined(QT_NO_CONTEXTMENU) && (defined(QT_NO_MENU)) #define QT_NO_CONTEXTMENU @@ -617,6 +622,11 @@ #define QT_NO_UNDOGROUP #endif +// Accessibility +#if !defined(QT_NO_ACCESSIBILITY) && (defined(QT_NO_PROPERTIES) || defined(QT_NO_ACTION) || defined(QT_NO_MENU)) +#define QT_NO_ACCESSIBILITY +#endif + // The Model/View Framework #if !defined(QT_NO_ITEMVIEWS) && (defined(QT_NO_RUBBERBAND) || defined(QT_NO_SCROLLAREA)) #define QT_NO_ITEMVIEWS diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index 9d4eb5e..fb9181b 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -1153,7 +1153,7 @@ SeeAlso: ??? Feature: ACCESSIBILITY Description: Provides accessibility support. Section: Utilities -Requires: PROPERTIES ACTION +Requires: PROPERTIES ACTION MENU Name: Accessibility SeeAlso: ??? @@ -1324,6 +1324,20 @@ Requires: Name: QProxyScreen SeeAlso: ??? +Feature: QWS_VNC +Description: Provides VNC screen driver +Section: Qt for Embedded Linux +Requires: QWS_PROXYSCREEN +Name: QVncScreen +SeeAlso: ??? + +Feature: QWS_TRANSFORMED +Description: Provides Transformed screen driver +Section: Qt for Embedded Linux +Requires: QWS_PROXYSCREEN +Name: QVncTransformed +SeeAlso: ??? + Feature: QWS_DYNAMICSCREENTRANSFORMATION Description: Enables dynamic setting of screen transformation/rotation. Section: Qt for Embedded Linux diff --git a/src/plugins/gfxdrivers/transformed/main.cpp b/src/plugins/gfxdrivers/transformed/main.cpp index 982882e..859fd49 100644 --- a/src/plugins/gfxdrivers/transformed/main.cpp +++ b/src/plugins/gfxdrivers/transformed/main.cpp @@ -68,9 +68,12 @@ QStringList GfxTransformedDriver::keys() const QScreen* GfxTransformedDriver::create(const QString& driver, int displayId) { +#ifndef QT_NO_QWS_TRANSFORMED if (driver.toLower() == "transformed") return new QTransformedScreen(displayId); - +#else //QT_NO_QWS_TRANSFORMED + printf("QT buildt with QT_NO_QWS_TRANSFORMED. No screen driver returned\n"); +#endif //QT_NO_QWS_TRANSFORMED return 0; } diff --git a/src/plugins/gfxdrivers/vnc/main.cpp b/src/plugins/gfxdrivers/vnc/main.cpp index aa20d11..7d91ff5 100644 --- a/src/plugins/gfxdrivers/vnc/main.cpp +++ b/src/plugins/gfxdrivers/vnc/main.cpp @@ -68,9 +68,12 @@ QStringList GfxVncDriver::keys() const QScreen* GfxVncDriver::create(const QString& driver, int displayId) { +#ifndef QT_NO_QWS_VNC if (driver.toLower() == "vnc") return new QVNCScreen(displayId); - +#else //QT_NO_QWS_VNC + printf("QT buildt with QT_NO_QWS_VNC. No screen driver returned\n"); +#endif //QT_NO_QWS_VNC return 0; } -- cgit v0.12 From cbef10e1781cdef5ec6dcf0bdeea6506258ee431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 19 Oct 2009 16:25:44 +0200 Subject: Fix Validator Reviewed-by: tom --- src/gui/widgets/qlinecontrol_p.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index 68898b6..f8e1a5d 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -174,8 +174,10 @@ public: void setMaxLength(int maxLength); int maxLength() const; +#ifndef QT_NO_VALIDATOR const QValidator *validator() const; void setValidator(const QValidator *); +#endif #ifndef QT_NO_COMPLETER QCompleter *completer() const; @@ -282,7 +284,9 @@ private: bool finishChange(int validateFromState = -1, bool update = false, bool edited = true); +#ifndef QT_NO_VALIDATOR QPointer m_validator; +#endif QPointer m_completer; #ifndef QT_NO_COMPLETER bool advanceToEnabledItem(int dir); @@ -623,6 +627,7 @@ inline int QLineControl::maxLength() const return m_maxLength; } +#ifndef QT_NO_VALIDATOR inline const QValidator *QLineControl::validator() const { return m_validator; @@ -632,6 +637,7 @@ inline void QLineControl::setValidator(const QValidator *v) { m_validator = const_cast(v); } +#endif #ifndef QT_NO_COMPLETER inline QCompleter *QLineControl::completer() const -- cgit v0.12 From f56f27e2cfd5880dfa8435f7648b080e02c8ee99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 20 Oct 2009 09:18:44 +0200 Subject: Fix QT_NO_GROUPBOX Reviewed-by: tom --- src/gui/widgets/qplaintextedit.cpp | 2 +- src/gui/widgets/qtextedit.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index fc61889..bb93546 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -1599,7 +1599,6 @@ void QPlainTextEdit::keyPressEvent(QKeyEvent *e) return; } } -#endif // QT_NO_SHORTCUT if (!(tif & Qt::TextEditable)) { switch (e->key()) { @@ -1627,6 +1626,7 @@ void QPlainTextEdit::keyPressEvent(QKeyEvent *e) } return; } +#endif // QT_NO_SHORTCUT d->sendControlEvent(e); #ifdef QT_KEYPAD_NAVIGATION diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp index f477fee..d995e0f 100644 --- a/src/gui/widgets/qtextedit.cpp +++ b/src/gui/widgets/qtextedit.cpp @@ -1246,7 +1246,6 @@ void QTextEdit::keyPressEvent(QKeyEvent *e) return; } } -#endif // QT_NO_SHORTCUT if (!(tif & Qt::TextEditable)) { switch (e->key()) { @@ -1274,6 +1273,7 @@ void QTextEdit::keyPressEvent(QKeyEvent *e) } return; } +#endif // QT_NO_SHORTCUT { QTextCursor cursor = d->control->textCursor(); -- cgit v0.12 From 488a89e2671fb93981db6c71f3557500b9f52588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 20 Oct 2009 09:19:40 +0200 Subject: Fix QT_NO_GROUPBOX Reviewed-by: tom --- src/gui/styles/qcleanlooksstyle.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index fc12cfe..973e682 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -3825,6 +3825,7 @@ QSize QCleanlooksStyle::sizeFromContents(ContentsType type, const QStyleOption * } } break; +#ifndef QT_NO_GROUPBOX case CT_GroupBox: // Since we use a bold font we have to recalculate base width if (const QGroupBox *gb = qobject_cast(widget)) { @@ -3840,6 +3841,7 @@ QSize QCleanlooksStyle::sizeFromContents(ContentsType type, const QStyleOption * } newSize += QSize(0, 1); break; +#endif //QT_NO_GROUPBOX case CT_RadioButton: case CT_CheckBox: newSize += QSize(0, 1); -- cgit v0.12 From d24fd9b951352fe184ff9bccb0f53e18368e8735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 21 Oct 2009 15:23:30 +0200 Subject: Fix LIBRARY and SETTINGS in phonon Reviewed-by: Jens Bache-Wiig Squash me with Fix LIBRARY and SETTINGS in phonon 7d2282 --- src/3rdparty/phonon/gstreamer/artssink.cpp | 3 ++- src/3rdparty/phonon/gstreamer/devicemanager.cpp | 7 +++++-- src/3rdparty/phonon/gstreamer/mediaobject.cpp | 6 +++++- src/3rdparty/phonon/phonon/factory.cpp | 6 ++++++ src/3rdparty/phonon/phonon/globalconfig.cpp | 14 ++++++++++++-- src/3rdparty/phonon/phonon/globalconfig_p.h | 4 ++++ src/3rdparty/phonon/phonon/qsettingsgroup_p.h | 3 +++ 7 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/3rdparty/phonon/gstreamer/artssink.cpp b/src/3rdparty/phonon/gstreamer/artssink.cpp index ff56da9..441607d 100644 --- a/src/3rdparty/phonon/gstreamer/artssink.cpp +++ b/src/3rdparty/phonon/gstreamer/artssink.cpp @@ -233,7 +233,7 @@ static void arts_sink_init (ArtsSink * src, ArtsSinkClass * g_class) Q_UNUSED(g_class); GST_DEBUG_OBJECT (src, "initializing artssink"); src->stream = 0; - +#ifndef QT_NO_LIBRARY p_arts_init = (Ptr_arts_init)QLibrary::resolve(QLatin1String("artsc"), 0, "arts_init"); p_arts_play_stream = (Ptr_arts_play_stream)QLibrary::resolve(QLatin1String("artsc"), 0, "arts_play_stream"); p_arts_close_stream = (Ptr_arts_close_stream)QLibrary::resolve(QLatin1String("artsc"), 0, "arts_close_stream"); @@ -250,6 +250,7 @@ static void arts_sink_init (ArtsSink * src, ArtsSinkClass * g_class) } } sinkCount ++; +#endif //QT_NO_LIBRARY } static void arts_sink_dispose (GObject * object) diff --git a/src/3rdparty/phonon/gstreamer/devicemanager.cpp b/src/3rdparty/phonon/gstreamer/devicemanager.cpp index 2240396..86463c1 100644 --- a/src/3rdparty/phonon/gstreamer/devicemanager.cpp +++ b/src/3rdparty/phonon/gstreamer/devicemanager.cpp @@ -72,18 +72,21 @@ DeviceManager::DeviceManager(Backend *backend) : QObject(backend) , m_backend(backend) { + m_audioSink = qgetenv("PHONON_GST_AUDIOSINK"); + m_videoSinkWidget = qgetenv("PHONON_GST_VIDEOMODE"); + +#ifndef QT_NO_SETTINGS QSettings settings(QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("Qt")); - m_audioSink = qgetenv("PHONON_GST_AUDIOSINK"); if (m_audioSink.isEmpty()) { m_audioSink = settings.value(QLatin1String("audiosink"), "Auto").toByteArray().toLower(); } - m_videoSinkWidget = qgetenv("PHONON_GST_VIDEOMODE"); if (m_videoSinkWidget.isEmpty()) { m_videoSinkWidget = settings.value(QLatin1String("videomode"), "Auto").toByteArray().toLower(); } +#endif //QT_NO_SETTINGS if (m_backend->isValid()) updateDeviceList(); diff --git a/src/3rdparty/phonon/gstreamer/mediaobject.cpp b/src/3rdparty/phonon/gstreamer/mediaobject.cpp index 0b800af..1c32c3c 100644 --- a/src/3rdparty/phonon/gstreamer/mediaobject.cpp +++ b/src/3rdparty/phonon/gstreamer/mediaobject.cpp @@ -226,6 +226,7 @@ void MediaObject::cb_unknown_type (GstElement *decodebin, GstPad *pad, GstCaps * QString value = "unknown codec"; // These functions require GStreamer > 0.10.12 +#ifndef QT_NO_LIBRARY static Ptr_gst_pb_utils_init p_gst_pb_utils_init = 0; static Ptr_gst_pb_utils_get_codec_description p_gst_pb_utils_get_codec_description = 0; if (!p_gst_pb_utils_init) { @@ -239,10 +240,13 @@ void MediaObject::cb_unknown_type (GstElement *decodebin, GstPad *pad, GstCaps * codecName = p_gst_pb_utils_get_codec_description (caps); value = QString::fromUtf8(codecName); g_free (codecName); - } else { + } else +#endif //QT_NO_LIBRARY + { // For GStreamer versions < 0.10.12 GstStructure *str = gst_caps_get_structure (caps, 0); value = QString::fromUtf8(gst_structure_get_name (str)); + } media->addMissingCodecName(value); } diff --git a/src/3rdparty/phonon/phonon/factory.cpp b/src/3rdparty/phonon/phonon/factory.cpp index 881aca3..d5010e7 100644 --- a/src/3rdparty/phonon/phonon/factory.cpp +++ b/src/3rdparty/phonon/phonon/factory.cpp @@ -111,6 +111,7 @@ void Factory::setBackend(QObject *b) bool FactoryPrivate::createBackend() { +#ifndef QT_NO_LIBRARY Q_ASSERT(m_backendObject == 0); #ifndef QT_NO_PHONON_PLATFORMPLUGIN PlatformPlugin *f = globalFactory->platformPlugin(); @@ -186,6 +187,11 @@ bool FactoryPrivate::createBackend() SLOT(objectDescriptionChanged(ObjectDescriptionType))); return true; +#else //QT_NO_LIBRARY + pWarning() << Q_FUNC_INFO << "Trying to use Phonon with QT_NO_LIBRARY defined. " + "That is currently not supported"; + return false; +#endif } FactoryPrivate::FactoryPrivate() diff --git a/src/3rdparty/phonon/phonon/globalconfig.cpp b/src/3rdparty/phonon/phonon/globalconfig.cpp index d13e491..3718c6a 100644 --- a/src/3rdparty/phonon/phonon/globalconfig.cpp +++ b/src/3rdparty/phonon/phonon/globalconfig.cpp @@ -38,7 +38,10 @@ QT_BEGIN_NAMESPACE namespace Phonon { -GlobalConfig::GlobalConfig() : m_config(QLatin1String("kde.org"), QLatin1String("libphonon")) +GlobalConfig::GlobalConfig() +#ifndef QT_NO_SETTINGS + : m_config(QLatin1String("kde.org"), QLatin1String("libphonon")) +#endif //QT_NO_SETTINGS { } @@ -82,6 +85,7 @@ static void filter(ObjectDescriptionType type, BackendInterface *backendIface, Q } } +#ifndef QT_NO_PHONON_SETTINGSGROUP static QList listSortedByConfig(const QSettingsGroup &backendConfig, Phonon::Category category, QList &defaultList) { if (defaultList.size() <= 1) { @@ -126,7 +130,9 @@ static QList listSortedByConfig(const QSettingsGroup &backendConfig, Phonon return deviceList; } +#endif //QT_NO_PHONON_SETTINGSGROUP +#ifndef QT_NO_PHONON_SETTINGSGROUP QList GlobalConfig::audioOutputDeviceListFor(Phonon::Category category, int override) const { //The devices need to be stored independently for every backend @@ -172,7 +178,7 @@ QList GlobalConfig::audioOutputDeviceListFor(Phonon::Category category, int return listSortedByConfig(backendConfig, category, defaultList); } - +#endif //QT_NO_SETTINGSGROUPS int GlobalConfig::audioOutputDeviceFor(Phonon::Category category, int override) const { QList ret = audioOutputDeviceListFor(category, override); @@ -184,6 +190,7 @@ int GlobalConfig::audioOutputDeviceFor(Phonon::Category category, int override) #ifndef QT_NO_PHONON_AUDIOCAPTURE QList GlobalConfig::audioCaptureDeviceListFor(Phonon::Category category, int override) const { +#ifndef QT_NO_PHONON_SETTINGSGROUP //The devices need to be stored independently for every backend const QSettingsGroup backendConfig(&m_config, QLatin1String("AudioCaptureDevice")); // + Factory::identifier()); const QSettingsGroup generalGroup(&m_config, QLatin1String("General")); @@ -226,6 +233,9 @@ QList GlobalConfig::audioCaptureDeviceListFor(Phonon::Category category, in } return listSortedByConfig(backendConfig, category, defaultList); +#else //QT_NO_SETTINGSGROUP + return QList(); +#endif //QT_NO_SETTINGSGROUP } int GlobalConfig::audioCaptureDeviceFor(Phonon::Category category, int override) const diff --git a/src/3rdparty/phonon/phonon/globalconfig_p.h b/src/3rdparty/phonon/phonon/globalconfig_p.h index 023858f..034bce3 100644 --- a/src/3rdparty/phonon/phonon/globalconfig_p.h +++ b/src/3rdparty/phonon/phonon/globalconfig_p.h @@ -46,7 +46,9 @@ namespace Phonon AdvancedDevicesFromSettings = 2, HideUnavailableDevices = 4 }; +#ifndef QT_NO_PHONON_SETTINGSGROUP QList audioOutputDeviceListFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const; +#endif //QT_NO_PHONON_SETTINGSGROUP int audioOutputDeviceFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const; #ifndef QT_NO_PHONON_AUDIOCAPTURE @@ -55,7 +57,9 @@ namespace Phonon #endif //QT_NO_PHONON_AUDIOCAPTURE protected: +#ifndef QT_NO_SETTINGS QSettings m_config; +#endif //QT_NO_SETTINGS }; } // namespace Phonon diff --git a/src/3rdparty/phonon/phonon/qsettingsgroup_p.h b/src/3rdparty/phonon/phonon/qsettingsgroup_p.h index 95f6c9b..501fe37 100644 --- a/src/3rdparty/phonon/phonon/qsettingsgroup_p.h +++ b/src/3rdparty/phonon/phonon/qsettingsgroup_p.h @@ -27,6 +27,8 @@ #include #include +#ifndef QT_NO_PHONON_SETTINGSGROUP + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -87,5 +89,6 @@ class QSettingsGroup QT_END_NAMESPACE QT_END_HEADER +#endif //QT_NO_PHONON_SETTINGSGROUP #endif // PHONON_QSETTINGSGROUP_P_H -- cgit v0.12 From f73e3063649220f80b2d0ada3a7f087c32c0bfc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 21 Oct 2009 15:25:28 +0200 Subject: Fix dependencies in qfeatures Reviewed-by: Trust Me --- src/corelib/global/qfeatures.h | 110 ++++++++++++++++++++++----------------- src/corelib/global/qfeatures.txt | 41 ++++++++++----- 2 files changed, 89 insertions(+), 62 deletions(-) diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index c9dfabb..adc2743 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -148,9 +148,6 @@ // Phonon::ObjectDescriptionModel //#define QT_NO_PHONON_OBJECTDESCRIPTIONMODEL -// Phonon::PlatformPlugin -//#define QT_NO_PHONON_PLATFORMPLUGIN - // Phonon::VideoWidget //#define QT_NO_PHONON_VIDEO @@ -175,9 +172,6 @@ // Decoration //#define QT_NO_QWS_DECORATION_DEFAULT -// QWSInputMethod -//#define QT_NO_QWS_INPUTMETHODS - // Keyboard //#define QT_NO_QWS_KEYBOARD @@ -527,9 +521,9 @@ #define QT_NO_LIBRARY #endif -// Phonon::VolumeSlider -#if !defined(QT_NO_PHONON_VOLUMESLIDER) && (defined(QT_NO_SLIDER) || defined(QT_NO_ACTION)) -#define QT_NO_PHONON_VOLUMESLIDER +// Phonon::AbstractMediaStream +#if !defined(QT_NO_PHONON_SETTINGSGROUP) && (defined(QT_NO_SETTINGS)) +#define QT_NO_PHONON_SETTINGSGROUP #endif // QScrollArea @@ -537,6 +531,11 @@ #define QT_NO_SCROLLAREA #endif +// QWindowsVistaStyle +#if !defined(QT_NO_STYLE_WINDOWSVISTA) && (defined(QT_NO_STYLE_WINDOWSXP)) +#define QT_NO_STYLE_WINDOWSVISTA +#endif + // OdfWriter #if !defined(QT_NO_TEXTODFWRITER) && (defined(QT_NO_XMLSTREAMWRITER)) #define QT_NO_TEXTODFWRITER @@ -552,6 +551,11 @@ #define QT_NO_TRANSLATION_UTF8 #endif +// QUndoGroup +#if !defined(QT_NO_UNDOGROUP) && (defined(QT_NO_UNDOSTACK)) +#define QT_NO_UNDOGROUP +#endif + // Drag and drop #if !defined(QT_NO_DRAGANDDROP) && (defined(QT_NO_QWS_PROPERTIES) || defined(QT_NO_IMAGEFORMAT_XPM)) #define QT_NO_DRAGANDDROP @@ -562,11 +566,21 @@ #define QT_NO_GRAPHICSVIEW #endif +// QInputContext +#if !defined(QT_NO_IM) && (defined(QT_NO_LIBRARY)) +#define QT_NO_IM +#endif + // QMdiArea #if !defined(QT_NO_MDIAREA) && (defined(QT_NO_SCROLLAREA)) #define QT_NO_MDIAREA #endif +// Phonon::PlatformPlugin +#if !defined(QT_NO_PHONON_PLATFORMPLUGIN) && (defined(QT_NO_LIBRARY)) +#define QT_NO_PHONON_PLATFORMPLUGIN +#endif + // QPrinter #if !defined(QT_NO_PRINTER) && (defined(QT_NO_TEXTSTREAM) || defined(QT_NO_PICTURE) || defined(QT_NO_TEMPORARYFILE)) #define QT_NO_PRINTER @@ -602,11 +616,6 @@ #define QT_NO_STYLE_WINDOWSMOBILE #endif -// QWindowsVistaStyle -#if !defined(QT_NO_STYLE_WINDOWSVISTA) && (defined(QT_NO_STYLE_WINDOWS) || defined(QT_NO_STYLE_WINDOWSXP)) -#define QT_NO_STYLE_WINDOWSVISTA -#endif - // QtSvg module #if !defined(QT_NO_SVG) && (defined(QT_NO_XMLSTREAMREADER) || defined(QT_NO_CSSPARSER)) #define QT_NO_SVG @@ -617,14 +626,14 @@ #define QT_NO_TABBAR #endif -// QUndoGroup -#if !defined(QT_NO_UNDOGROUP) && (defined(QT_NO_UNDOCOMMAND) || defined(QT_NO_UNDOSTACK)) -#define QT_NO_UNDOGROUP +// QWhatsThis +#if !defined(QT_NO_WHATSTHIS) && (defined(QT_NO_TOOLBUTTON)) +#define QT_NO_WHATSTHIS #endif -// Accessibility -#if !defined(QT_NO_ACCESSIBILITY) && (defined(QT_NO_PROPERTIES) || defined(QT_NO_ACTION) || defined(QT_NO_MENU)) -#define QT_NO_ACCESSIBILITY +// QColorDialog +#if !defined(QT_NO_COLORDIALOG) && (defined(QT_NO_SPINBOX)) +#define QT_NO_COLORDIALOG #endif // The Model/View Framework @@ -632,6 +641,16 @@ #define QT_NO_ITEMVIEWS #endif +// Phonon::VolumeSlider +#if !defined(QT_NO_PHONON_VOLUMESLIDER) && (defined(QT_NO_SLIDER) || defined(QT_NO_TOOLBUTTON)) +#define QT_NO_PHONON_VOLUMESLIDER +#endif + +// QWSInputMethod +#if !defined(QT_NO_QWS_INPUTMETHODS) && (defined(QT_NO_IM)) +#define QT_NO_QWS_INPUTMETHODS +#endif + // Sound Server #if !defined(QT_NO_QWS_SOUNDSERVER) && (defined(QT_NO_SOUND) || defined(QT_NO_HOSTINFO) || defined(QT_NO_QWS_MULTIPROCESS)) #define QT_NO_QWS_SOUNDSERVER @@ -662,11 +681,6 @@ #define QT_NO_TEXTEDIT #endif -// QWhatsThis -#if !defined(QT_NO_WHATSTHIS) && (defined(QT_NO_TOOLBUTTON) || defined(QT_NO_ACTION)) -#define QT_NO_WHATSTHIS -#endif - // QDirModel #if !defined(QT_NO_DIRMODEL) && (defined(QT_NO_ITEMVIEWS)) #define QT_NO_DIRMODEL @@ -732,11 +746,6 @@ #define QT_NO_TREEVIEW #endif -// QColorDialog -#if !defined(QT_NO_COLORDIALOG) && (defined(QT_NO_LINEEDIT) || defined(QT_NO_VALIDATOR) || defined(QT_NO_SPINBOX)) -#define QT_NO_COLORDIALOG -#endif - // QColumnView #if !defined(QT_NO_COLUMNVIEW) && (defined(QT_NO_LISTVIEW)) #define QT_NO_COLUMNVIEW @@ -772,11 +781,21 @@ #define QT_NO_TABLEWIDGET #endif +// QToolBox +#if !defined(QT_NO_TOOLBOX) && (defined(QT_NO_TOOLBUTTON) || defined(QT_NO_SCROLLAREA)) +#define QT_NO_TOOLBOX +#endif + // QTreeWidget #if !defined(QT_NO_TREEWIDGET) && (defined(QT_NO_TREEVIEW)) #define QT_NO_TREEWIDGET #endif +// Accessibility +#if !defined(QT_NO_ACCESSIBILITY) && (defined(QT_NO_PROPERTIES) || defined(QT_NO_MENUBAR)) +#define QT_NO_ACCESSIBILITY +#endif + // Common UNIX Printing System #if !defined(QT_NO_CUPS) && (defined(QT_NO_PRINTER) || defined(QT_NO_LIBRARY)) #define QT_NO_CUPS @@ -787,11 +806,6 @@ #define QT_NO_TOOLBAR #endif -// QToolBox -#if !defined(QT_NO_TOOLBOX) && (defined(QT_NO_ICON) || defined(QT_NO_TOOLBUTTON) || defined(QT_NO_SCROLLAREA)) -#define QT_NO_TOOLBOX -#endif - // QDockwidget #if !defined(QT_NO_DOCKWIDGET) && (defined(QT_NO_RUBBERBAND) || defined(QT_NO_MAINWINDOW)) #define QT_NO_DOCKWIDGET @@ -808,10 +822,20 @@ #endif // QComboBox -#if !defined(QT_NO_COMBOBOX) && (defined(QT_NO_LINEEDIT) || defined(QT_NO_STANDARDITEMMODEL) || defined(QT_NO_LISTVIEW)) +#if !defined(QT_NO_COMBOBOX) && (defined(QT_NO_LINEEDIT) || defined(QT_NO_STANDARDITEMMODEL) || defined(QT_NO_LISTVIEW) || defined(QT_NO_ICON)) #define QT_NO_COMBOBOX #endif +// QPrintPreviewWidget +#if !defined(QT_NO_PRINTPREVIEWWIDGET) && (defined(QT_NO_GRAPHICSVIEW) || defined(QT_NO_PRINTER) || defined(QT_NO_MAINWINDOW)) +#define QT_NO_PRINTPREVIEWWIDGET +#endif + +// QWorkSpace +#if !defined(QT_NO_WORKSPACE) && (defined(QT_NO_SCROLLBAR) || defined(QT_NO_MAINWINDOW) || defined(QT_NO_MENUBAR)) +#define QT_NO_WORKSPACE +#endif + // QCalendarWidget #if !defined(QT_NO_CALENDARWIDGET) && (defined(QT_NO_TABLEVIEW) || defined(QT_NO_MENU) || defined(QT_NO_TEXTDATE) || defined(QT_NO_SPINBOX) || defined(QT_NO_TOOLBUTTON)) #define QT_NO_CALENDARWIDGET @@ -842,18 +866,8 @@ #define QT_NO_FONTDIALOG #endif -// QPrintPreviewWidget -#if !defined(QT_NO_PRINTPREVIEWWIDGET) && (defined(QT_NO_GRAPHICSVIEW) || defined(QT_NO_PRINTER) || defined(QT_NO_TOOLBAR) || defined(QT_NO_MAINWINDOW)) -#define QT_NO_PRINTPREVIEWWIDGET -#endif - -// QWorkSpace -#if !defined(QT_NO_WORKSPACE) && (defined(QT_NO_SCROLLBAR) || defined(QT_NO_RESIZEHANDLER) || defined(QT_NO_MENU) || defined(QT_NO_TOOLBUTTON) || defined(QT_NO_MAINWINDOW) || defined(QT_NO_TOOLBAR) || defined(QT_NO_MENUBAR)) -#define QT_NO_WORKSPACE -#endif - // QPrintDialog -#if !defined(QT_NO_PRINTDIALOG) && (defined(QT_NO_PRINTER) || defined(QT_NO_COMBOBOX) || defined(QT_NO_BUTTONGROUP) || defined(QT_NO_SPINBOX) || defined(QT_NO_TREEVIEW) || defined(QT_NO_STACKEDWIDGET) || defined(QT_NO_TABWIDGET)) +#if !defined(QT_NO_PRINTDIALOG) && (defined(QT_NO_PRINTER) || defined(QT_NO_COMBOBOX) || defined(QT_NO_BUTTONGROUP) || defined(QT_NO_SPINBOX) || defined(QT_NO_TREEVIEW) || defined(QT_NO_TABWIDGET)) #define QT_NO_PRINTDIALOG #endif @@ -863,7 +877,7 @@ #endif // QPrintPreviewDialog -#if !defined(QT_NO_PRINTPREVIEWDIALOG) && (defined(QT_NO_PRINTPREVIEWWIDGET) || defined(QT_NO_PRINTDIALOG) || defined(QT_NO_MAINWINDOW)) +#if !defined(QT_NO_PRINTPREVIEWDIALOG) && (defined(QT_NO_PRINTPREVIEWWIDGET) || defined(QT_NO_PRINTDIALOG)) #define QT_NO_PRINTPREVIEWDIALOG #endif diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index fb9181b..4b012d9 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -154,6 +154,12 @@ Requires: XMLSTREAM Name: QXmlStreamWriter SeeAlso: ??? +Feature: IM +Description: Inputmethods with QInputContext +Section: Kernel +Requires: LIBRARY +Name: QInputContext +SeeAlso: ??? # Data structures Feature: STL @@ -346,7 +352,7 @@ SeeAlso: ??? Feature: COMBOBOX Description: Supports comboboxes presenting a list of options to the user. Section: Widgets -Requires: LINEEDIT STANDARDITEMMODEL LISTVIEW +Requires: LINEEDIT STANDARDITEMMODEL LISTVIEW ICON Name: QComboBox SeeAlso: ??? @@ -374,7 +380,7 @@ SeeAlso: ??? Feature: TOOLBOX Description: Supports columns of tabbed widget items. Section: Widgets -Requires: ICON TOOLBUTTON SCROLLAREA +Requires: TOOLBUTTON SCROLLAREA Name: QToolBox SeeAlso: ??? @@ -410,7 +416,7 @@ SeeAlso: ??? Feature: WORKSPACE Description: Supports workspace windows, e.g. used in an MDI application. Section: Widgets -Requires: SCROLLBAR RESIZEHANDLER MENU TOOLBUTTON MAINWINDOW TOOLBAR MENUBAR +Requires: SCROLLBAR MAINWINDOW MENUBAR Name: QWorkSpace SeeAlso: ??? @@ -544,7 +550,7 @@ SeeAlso: ??? Feature: WHATSTHIS Description: Supports displaying "What's this" help. Section: Widgets -Requires: TOOLBUTTON ACTION +Requires: TOOLBUTTON Name: QWhatsThis SeeAlso: ??? @@ -574,7 +580,7 @@ Feature: PRINTPREVIEWWIDGET Description: Provides a widget for previewing page layouts for printer output. a date. Section: Widgets -Requires: GRAPHICSVIEW PRINTER TOOLBAR MAINWINDOW +Requires: GRAPHICSVIEW PRINTER MAINWINDOW Name: QPrintPreviewWidget SeeAlso: ??? @@ -591,7 +597,7 @@ SeeAlso: ??? Feature: COLORDIALOG Description: Supports a dialog widget for specifying colors. Section: Dialogs -Requires: LINEEDIT VALIDATOR SPINBOX +Requires: SPINBOX Name: QColorDialog SeeAlso: ??? @@ -612,14 +618,14 @@ SeeAlso: ??? Feature: PRINTDIALOG Description: Supports a dialog widget for specifying printer configuration. Section: Dialogs -Requires: PRINTER COMBOBOX BUTTONGROUP SPINBOX TREEVIEW STACKEDWIDGET TABWIDGET +Requires: PRINTER COMBOBOX BUTTONGROUP SPINBOX TREEVIEW TABWIDGET Name: QPrintDialog SeeAlso: ??? Feature: PRINTPREVIEWDIALOG Description: Provides a dialog for previewing and configuring page layouts for printer output. Section: Dialogs -Requires: PRINTPREVIEWWIDGET PRINTDIALOG MAINWINDOW +Requires: PRINTPREVIEWWIDGET PRINTDIALOG Name: QPrintPreviewDialog SeeAlso: ??? @@ -779,7 +785,7 @@ SeeAlso: ??? Feature: STYLE_WINDOWSVISTA Description: Supports a Microsoft WindowsVista-like look and feel. Section: Styles -Requires: STYLE_WINDOWS STYLE_WINDOWSXP +Requires: STYLE_WINDOWSXP Name: QWindowsVistaStyle SeeAlso: ??? @@ -1021,7 +1027,7 @@ SeeAlso: ??? Feature: QWS_INPUTMETHODS Description: Supports international input methods. Section: Internationalization -Requires: +Requires: IM Name: QWSInputMethod SeeAlso: ??? @@ -1139,7 +1145,7 @@ SeeAlso: ??? Feature: UNDOGROUP Description: Section: Utilities -Requires: UNDOCOMMAND UNDOSTACK +Requires: UNDOSTACK Name: QUndoGroup SeeAlso: ??? @@ -1153,7 +1159,7 @@ SeeAlso: ??? Feature: ACCESSIBILITY Description: Provides accessibility support. Section: Utilities -Requires: PROPERTIES ACTION MENU +Requires: PROPERTIES MENUBAR Name: Accessibility SeeAlso: ??? @@ -1359,7 +1365,7 @@ SeeAlso: ??? Feature: PHONON_PLATFORMPLUGIN Description: Support for platform plugin Section: Phonon -Requires: +Requires: LIBRARY Name: Phonon::PlatformPlugin SeeAlso: ??? @@ -1424,7 +1430,7 @@ SeeAlso: ??? Feature: PHONON_VOLUMESLIDER Description: Support for the Volume Slider class Section: Phonon -Requires: SLIDER ACTION +Requires: SLIDER TOOLBUTTON Name: Phonon::VolumeSlider SeeAlso: ??? @@ -1441,3 +1447,10 @@ Section: Phonon Requires: Name: Phonon::AbstractMediaStream SeeAlso: ??? + +Feature: PHONON_SETTINGSGROUP +Description: Phonon settingsgroup +Section: Phonon +Requires: SETTINGS +Name: Phonon::AbstractMediaStream +SeeAlso: ??? -- cgit v0.12 From fccbc9b94d843f4c55834ee75127cd6219b4839a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 21 Oct 2009 15:26:06 +0200 Subject: Fix LIBRARY and ICON However, compiling with QT_NO_ICON will still not work :( Reviewed-by: tom --- src/gui/graphicsview/qgraphicsitem.cpp | 2 ++ src/gui/graphicsview/qgraphicsscene.cpp | 2 ++ src/gui/image/qicon.cpp | 2 ++ src/gui/image/qicon_p.h | 3 ++- src/gui/image/qiconloader.cpp | 9 +++++++-- src/gui/image/qiconloader_p.h | 3 +++ src/gui/kernel/qapplication.cpp | 5 ++++- src/gui/kernel/qwidget.cpp | 12 ++++++++++++ src/gui/kernel/qwidget_qws.cpp | 3 ++- src/gui/painting/qprinterinfo_unix.cpp | 2 ++ src/gui/text/qtextcontrol.cpp | 2 ++ src/gui/widgets/qcombobox.h | 1 - src/gui/widgets/qlinecontrol.cpp | 3 ++- src/network/access/qnetworkaccessdebugpipebackend.cpp | 4 ++-- src/plugins/gfxdrivers/qvfb/main.cpp | 2 ++ src/plugins/gfxdrivers/transformed/main.cpp | 3 ++- src/plugins/gfxdrivers/vnc/main.cpp | 3 +++ 17 files changed, 51 insertions(+), 10 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 2685b86..f7cea17 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -9670,12 +9670,14 @@ bool QGraphicsTextItem::sceneEvent(QEvent *event) // Reset the focus widget's input context, regardless // of how this item gained or lost focus. if (QWidget *fw = qApp->focusWidget()) { +#ifndef QT_NO_IM if (QInputContext *qic = fw->inputContext()) { if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut) qic->reset(); else qic->update(); } +#endif //QT_NO_IM } break; default: diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index c459d21..1e4fe6f 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -691,6 +691,7 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item, focusItem = 0; sendEvent(lastFocusItem, &event); +#ifndef QT_NO_IM if (lastFocusItem && (lastFocusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod)) { // Reset any visible preedit text @@ -706,6 +707,7 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item, views.at(i)->inputContext()->reset(); } } +#endif //QT_NO_IM } if (item) { diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index e0779a0..cff9cd2 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -66,6 +66,7 @@ #include "private/qkde_p.h" #endif +#ifndef QT_NO_ICON QT_BEGIN_NAMESPACE /*! @@ -1217,3 +1218,4 @@ QSize QIcon::pixmapSize(Size which) */ QT_END_NAMESPACE +#endif //QT_NO_ICON diff --git a/src/gui/image/qicon_p.h b/src/gui/image/qicon_p.h index fc96a65..43a59a6 100644 --- a/src/gui/image/qicon_p.h +++ b/src/gui/image/qicon_p.h @@ -60,6 +60,7 @@ #include #include +#ifndef QT_NO_ICON QT_BEGIN_NAMESPACE class QIconPrivate @@ -134,5 +135,5 @@ private: }; QT_END_NAMESPACE - +#endif //QT_NO_ICON #endif // QICON_P_H diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 46c5431..234f271 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -38,7 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - +#ifndef QT_NO_ICON #include #include @@ -92,11 +92,13 @@ QIconLoader::QIconLoader() : if (m_systemTheme.isEmpty()) m_systemTheme = fallbackTheme(); +#ifndef QT_NO_LIBRARY QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterfaceV2_iid, QLatin1String("/iconengines"), Qt::CaseInsensitive); if (iconFactoryLoader.keys().contains(QLatin1String("svg"))) m_supportsSvg = true; +#endif //QT_NO_LIBRARY } QIconLoader *QIconLoader::instance() @@ -160,7 +162,7 @@ QIconTheme::QIconTheme(const QString &themeName) break; } } - +#ifndef QT_NO_SETTINGS if (themeIndex.exists()) { const QSettings indexReader(themeIndex.fileName(), QSettings::IniFormat); QStringListIterator keyIterator(indexReader.allKeys()); @@ -213,6 +215,7 @@ QIconTheme::QIconTheme(const QString &themeName) if (!m_parents.contains(QLatin1String("hicolor"))) m_parents.append(QLatin1String("hicolor")); } +#endif //QT_NO_SETTINGS } QThemeIconEntries QIconLoader::findIconHelper(const QString &themeName, @@ -546,3 +549,5 @@ void QIconLoaderEngine::virtual_hook(int id, void *data) } QT_END_NAMESPACE + +#endif //QT_NO_ICON diff --git a/src/gui/image/qiconloader_p.h b/src/gui/image/qiconloader_p.h index b152d46..2a330d3 100644 --- a/src/gui/image/qiconloader_p.h +++ b/src/gui/image/qiconloader_p.h @@ -42,6 +42,7 @@ #ifndef QDESKTOPICON_P_H #define QDESKTOPICON_P_H +#ifndef QT_NO_ICON // // W A R N I N G // ------------- @@ -185,3 +186,5 @@ private: QT_END_NAMESPACE #endif // QDESKTOPICON_P_H + +#endif //QT_NO_ICON diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 85b055e..30d3c7f 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -2081,7 +2081,7 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) } QWidget *prev = focus_widget; focus_widget = focus; - +#ifndef QT_NO_IM if (prev && ((reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason && prev->testAttribute(Qt::WA_InputMethodEnabled)) // Do reset the input context, in case the new focus widget won't accept keyboard input @@ -2094,6 +2094,7 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) qic->setFocusWidget(0); } } +#endif //QT_NO_IM if(focus_widget) focus_widget->d_func()->setFocus_sys(); @@ -2125,12 +2126,14 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) QApplication::sendEvent(that->style(), &out); } if(focus && QApplicationPrivate::focus_widget == focus) { +#ifndef QT_NO_IM if (focus->testAttribute(Qt::WA_InputMethodEnabled)) { QInputContext *qic = focus->inputContext(); if (qic && focus->testAttribute(Qt::WA_WState_Created) && focus->isEnabled()) qic->setFocusWidget(focus); } +#endif //QT_NO_IM QFocusEvent in(QEvent::FocusIn, reason); QPointer that = focus; QApplication::sendEvent(focus, &in); diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 5fa9a92..916ae8b 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -3072,6 +3072,7 @@ void QWidgetPrivate::setEnabled_helper(bool enable) #if defined(Q_WS_MAC) setEnabled_helper_sys(enable); #endif +#ifndef QT_NO_IM if (q->testAttribute(Qt::WA_InputMethodEnabled) && q->hasFocus()) { QInputContext *qic = inputContext(); if (enable) { @@ -3081,6 +3082,7 @@ void QWidgetPrivate::setEnabled_helper(bool enable) qic->setFocusWidget(0); } } +#endif //QT_NO_IM QEvent e(QEvent::EnabledChange); QApplication::sendEvent(q, &e); #ifdef QT3_SUPPORT @@ -8950,11 +8952,16 @@ QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const Qt::InputMethodHints QWidget::inputMethodHints() const { Q_D(const QWidget); +#ifndef QT_NO_IM return d->imHints; +#else //QT_NO_IM + return 0; +#endif //QT_NO_IM } void QWidget::setInputMethodHints(Qt::InputMethodHints hints) { +#ifndef QT_NO_IM Q_D(QWidget); d->imHints = hints; // Optimisation to update input context only it has already been created. @@ -8963,6 +8970,7 @@ void QWidget::setInputMethodHints(Qt::InputMethodHints hints) if (ic) ic->update(); } +#endif //QT_NO_IM } @@ -10294,6 +10302,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) QApplication::sendEvent(this, &e); break; } case Qt::WA_NativeWindow: { +#ifndef QT_NO_IM QInputContext *ic = 0; if (on && !internalWinId() && testAttribute(Qt::WA_InputMethodEnabled) && hasFocus()) { ic = d->inputContext(); @@ -10306,6 +10315,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) d->createWinId(); if (ic && isEnabled()) ic->setFocusWidget(this); +#endif //QT_NO_IM break; } case Qt::WA_PaintOnScreen: @@ -10335,6 +10345,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) #endif break; case Qt::WA_InputMethodEnabled: { +#ifndef QT_NO_IM QInputContext *ic = d->ic; if (!ic && (!on || hasFocus())) ic = d->inputContext(); @@ -10346,6 +10357,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) ic->setFocusWidget(0); } } +#endif //QT_NO_IM break; } case Qt::WA_WindowPropagation: diff --git a/src/gui/kernel/qwidget_qws.cpp b/src/gui/kernel/qwidget_qws.cpp index 0f46016..e299c6e 100644 --- a/src/gui/kernel/qwidget_qws.cpp +++ b/src/gui/kernel/qwidget_qws.cpp @@ -280,7 +280,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) QApplicationPrivate::leaveModal(this); else if ((windowType() == Qt::Popup)) qApp->d_func()->closePopup(this); - +#ifndef QT_NO_IM if (d->ic) { delete d->ic; d->ic =0; @@ -291,6 +291,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) if (qic) qic->widgetDestroyed(this); } +#endif //QT_NO_IM if ((windowType() == Qt::Desktop)) { } else { diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp index 7e2946a..6684ff7 100644 --- a/src/gui/painting/qprinterinfo_unix.cpp +++ b/src/gui/painting/qprinterinfo_unix.cpp @@ -421,6 +421,7 @@ int qt_pd_foreach(int /*status */, char * /*key */, int /*keyLen */, int qt_retrieveNisPrinters(QList *printers) { +#ifndef QT_NO_LIBRARY typedef int (*WildCast)(int, char *, int, char *, int, char *); char printersConfByname[] = "printers.conf.byname"; char *domain; @@ -444,6 +445,7 @@ int qt_retrieveNisPrinters(QList *printers) if (!err) return Success; } +#endif //QT_NO_LIBRARY return Unavail; } diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index ee8b751..3f6545c 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -1619,9 +1619,11 @@ void QTextControlPrivate::mouseMoveEvent(Qt::MouseButtons buttons, const QPointF if (cursor.position() != oldCursorPos) emit q->cursorPositionChanged(); _q_updateCurrentCharFormatAndSelection(); +#ifndef QT_NO_IM if (QInputContext *ic = inputContext()) { ic->update(); } +#endif //QT_NO_IM } else { //emit q->visibilityRequest(QRectF(mousePos, QSizeF(1, 1))); if (cursor.position() != oldCursorPos) diff --git a/src/gui/widgets/qcombobox.h b/src/gui/widgets/qcombobox.h index 6a85096..462636c 100644 --- a/src/gui/widgets/qcombobox.h +++ b/src/gui/widgets/qcombobox.h @@ -52,7 +52,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Gui) - #ifndef QT_NO_COMBOBOX class QAbstractItemView; diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 7f9ff82..8f17e98 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -447,8 +447,9 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) cursorPositionChanged = true; } } - +#ifndef QT_NO_IM setPreeditArea(m_cursor, event->preeditString()); +#endif //QT_NO_IM m_preeditCursor = event->preeditString().length(); m_hideCursor = false; QList formats; diff --git a/src/network/access/qnetworkaccessdebugpipebackend.cpp b/src/network/access/qnetworkaccessdebugpipebackend.cpp index b4af5b6..4f7f15c 100644 --- a/src/network/access/qnetworkaccessdebugpipebackend.cpp +++ b/src/network/access/qnetworkaccessdebugpipebackend.cpp @@ -229,7 +229,7 @@ void QNetworkAccessDebugPipeBackend::possiblyFinish() void QNetworkAccessDebugPipeBackend::closeDownstreamChannel() { - qWarning() << "QNetworkAccessDebugPipeBackend::closeDownstreamChannel()" << operation(); + qWarning("QNetworkAccessDebugPipeBackend::closeDownstreamChannel()",operation());; //if (operation() == QNetworkAccessManager::GetOperation) // socket.disconnectFromHost(); } @@ -237,7 +237,7 @@ void QNetworkAccessDebugPipeBackend::closeDownstreamChannel() void QNetworkAccessDebugPipeBackend::socketError() { - qWarning() << "QNetworkAccessDebugPipeBackend::socketError()" << socket.error(); + qWarning("QNetworkAccessDebugPipeBackend::socketError()", socket.error()); QNetworkReply::NetworkError code; switch (socket.error()) { case QAbstractSocket::RemoteHostClosedError: diff --git a/src/plugins/gfxdrivers/qvfb/main.cpp b/src/plugins/gfxdrivers/qvfb/main.cpp index bcaecab..beca37e 100644 --- a/src/plugins/gfxdrivers/qvfb/main.cpp +++ b/src/plugins/gfxdrivers/qvfb/main.cpp @@ -43,6 +43,7 @@ #include #include +#ifndef QT_NO_LIBRARY QT_BEGIN_NAMESPACE class ScreenVfbDriver : public QScreenDriverPlugin @@ -78,3 +79,4 @@ Q_EXPORT_STATIC_PLUGIN(ScreenVfbDriver) Q_EXPORT_PLUGIN2(qscreenvfb, ScreenVfbDriver) QT_END_NAMESPACE +#endif //QT_NO_LIBRARY diff --git a/src/plugins/gfxdrivers/transformed/main.cpp b/src/plugins/gfxdrivers/transformed/main.cpp index 859fd49..a9ff97d 100644 --- a/src/plugins/gfxdrivers/transformed/main.cpp +++ b/src/plugins/gfxdrivers/transformed/main.cpp @@ -42,7 +42,7 @@ #include #include #include - +#ifndef QT_NO_LIBRARY QT_BEGIN_NAMESPACE class GfxTransformedDriver : public QScreenDriverPlugin @@ -81,3 +81,4 @@ Q_EXPORT_STATIC_PLUGIN(GfxTransformedDriver) Q_EXPORT_PLUGIN2(qgfxtransformed, GfxTransformedDriver) QT_END_NAMESPACE +#endif //QT_NO_LIBRARY diff --git a/src/plugins/gfxdrivers/vnc/main.cpp b/src/plugins/gfxdrivers/vnc/main.cpp index 7d91ff5..58c8c25 100644 --- a/src/plugins/gfxdrivers/vnc/main.cpp +++ b/src/plugins/gfxdrivers/vnc/main.cpp @@ -43,6 +43,7 @@ #include #include +#ifndef QT_NO_LIBRARY QT_BEGIN_NAMESPACE class GfxVncDriver : public QScreenDriverPlugin @@ -81,3 +82,5 @@ Q_EXPORT_STATIC_PLUGIN(GfxVncDriver) Q_EXPORT_PLUGIN2(qgfxvnc, GfxVncDriver) QT_END_NAMESPACE + +#endif //QT_NO_LIBRARY -- cgit v0.12 From a45a8e33b72a4a86ae269acabc5e95ed8452cda9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 22 Oct 2009 11:32:20 +0200 Subject: Fix QT_NO_PHONON_VIDEO Reviewed-by: Jens Bache-Wiig --- src/3rdparty/phonon/gstreamer/abstractrenderer.cpp | 3 ++- src/3rdparty/phonon/gstreamer/abstractrenderer.h | 3 ++- src/3rdparty/phonon/gstreamer/backend.cpp | 7 +++---- src/3rdparty/phonon/gstreamer/devicemanager.cpp | 2 ++ src/3rdparty/phonon/gstreamer/videowidget.cpp | 2 ++ src/3rdparty/phonon/gstreamer/videowidget.h | 3 ++- src/3rdparty/phonon/gstreamer/widgetrenderer.cpp | 2 ++ src/3rdparty/phonon/gstreamer/widgetrenderer.h | 3 ++- 8 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/3rdparty/phonon/gstreamer/abstractrenderer.cpp b/src/3rdparty/phonon/gstreamer/abstractrenderer.cpp index 924b611..5d88d10 100644 --- a/src/3rdparty/phonon/gstreamer/abstractrenderer.cpp +++ b/src/3rdparty/phonon/gstreamer/abstractrenderer.cpp @@ -17,6 +17,7 @@ #include "abstractrenderer.h" +#ifndef QT_NO_PHONON_VIDEO QT_BEGIN_NAMESPACE namespace Phonon @@ -52,5 +53,5 @@ void AbstractRenderer::movieSizeChanged(const QSize &size) } //namespace Phonon::Gstreamer QT_END_NAMESPACE - +#endif //QT_NO_PHONON_VIDEO diff --git a/src/3rdparty/phonon/gstreamer/abstractrenderer.h b/src/3rdparty/phonon/gstreamer/abstractrenderer.h index 140413d..10a2822 100644 --- a/src/3rdparty/phonon/gstreamer/abstractrenderer.h +++ b/src/3rdparty/phonon/gstreamer/abstractrenderer.h @@ -23,6 +23,7 @@ #include "medianode.h" #include +#ifndef QT_NO_PHONON_VIDEO QT_BEGIN_NAMESPACE class QString; @@ -58,5 +59,5 @@ protected: } //namespace Phonon::Gstreamer QT_END_NAMESPACE - +#endif //QT_NO_PHONON_VIDEO #endif // Phonon_GSTREAMER_ABSTRACTRENDERER_H diff --git a/src/3rdparty/phonon/gstreamer/backend.cpp b/src/3rdparty/phonon/gstreamer/backend.cpp index 647bb6f..e1ffd1f 100644 --- a/src/3rdparty/phonon/gstreamer/backend.cpp +++ b/src/3rdparty/phonon/gstreamer/backend.cpp @@ -126,6 +126,7 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const logMessage("createObject() : AudioDataOutput not implemented"); break; +#ifndef QT_NO_PHONON_VIDEO case VideoDataOutputClass: logMessage("createObject() : VideoDataOutput not implemented"); break; @@ -134,12 +135,10 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QWidget *widget = qobject_cast(parent); return new VideoWidget(this, widget); } - - case VolumeFaderEffectClass: +#endif //QT_NO_PHONON_VIDEO #ifndef QT_NO_PHONON_VOLUMEFADEREFFECT + case VolumeFaderEffectClass: return new VolumeFaderEffect(this, parent); -#else - return 0; #endif //QT_NO_PHONON_VOLUMEFADEREFFECT case VisualizationClass: //Fall through diff --git a/src/3rdparty/phonon/gstreamer/devicemanager.cpp b/src/3rdparty/phonon/gstreamer/devicemanager.cpp index 86463c1..60e860f 100644 --- a/src/3rdparty/phonon/gstreamer/devicemanager.cpp +++ b/src/3rdparty/phonon/gstreamer/devicemanager.cpp @@ -246,6 +246,7 @@ GstElement *DeviceManager::createAudioSink(Category category) return sink; } +#ifndef QT_NO_PHONON_VIDEO AbstractRenderer *DeviceManager::createVideoRenderer(VideoWidget *parent) { #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES) @@ -268,6 +269,7 @@ AbstractRenderer *DeviceManager::createVideoRenderer(VideoWidget *parent) #endif return new WidgetRenderer(parent); } +#endif //QT_NO_PHONON_VIDEO /* * Returns a positive device id or -1 if device diff --git a/src/3rdparty/phonon/gstreamer/videowidget.cpp b/src/3rdparty/phonon/gstreamer/videowidget.cpp index efc750a..e1f0ec9 100644 --- a/src/3rdparty/phonon/gstreamer/videowidget.cpp +++ b/src/3rdparty/phonon/gstreamer/videowidget.cpp @@ -33,6 +33,7 @@ #include "widgetrenderer.h" #include "x11renderer.h" +#ifndef QT_NO_PHONON_VIDEO QT_BEGIN_NAMESPACE namespace Phonon @@ -383,5 +384,6 @@ void VideoWidget::mediaNodeEvent(const MediaNodeEvent *event) } //namespace Phonon::Gstreamer QT_END_NAMESPACE +#endif //QT_NO_PHONON_VIDEO #include "moc_videowidget.cpp" diff --git a/src/3rdparty/phonon/gstreamer/videowidget.h b/src/3rdparty/phonon/gstreamer/videowidget.h index a0ebe5f..dc0754d 100644 --- a/src/3rdparty/phonon/gstreamer/videowidget.h +++ b/src/3rdparty/phonon/gstreamer/videowidget.h @@ -28,6 +28,7 @@ #include +#ifndef QT_NO_PHONON_VIDEO QT_BEGIN_NAMESPACE class QString; @@ -102,5 +103,5 @@ private: } //namespace Phonon::Gstreamer QT_END_NAMESPACE - +#endif //QT_NO_PHONON_VIDEO #endif // Phonon_GSTREAMER_VIDEOWIDGET_H diff --git a/src/3rdparty/phonon/gstreamer/widgetrenderer.cpp b/src/3rdparty/phonon/gstreamer/widgetrenderer.cpp index d4a411f..423af9d 100644 --- a/src/3rdparty/phonon/gstreamer/widgetrenderer.cpp +++ b/src/3rdparty/phonon/gstreamer/widgetrenderer.cpp @@ -32,6 +32,7 @@ # define GL_TEXTURE2 0x84C2 #endif +#ifndef QT_NO_PHONON_VIDEO QT_BEGIN_NAMESPACE static void frameRendered() @@ -148,3 +149,4 @@ bool WidgetRenderer::eventFilter(QEvent * event) } //namespace Phonon::Gstreamer QT_END_NAMESPACE +#endif //QT_NO_PHONON_VIDEO diff --git a/src/3rdparty/phonon/gstreamer/widgetrenderer.h b/src/3rdparty/phonon/gstreamer/widgetrenderer.h index ff64fa7..03ee9c0 100644 --- a/src/3rdparty/phonon/gstreamer/widgetrenderer.h +++ b/src/3rdparty/phonon/gstreamer/widgetrenderer.h @@ -26,6 +26,7 @@ #include #endif +#ifndef QT_NO_PHONON_VIDEO QT_BEGIN_NAMESPACE class QString; @@ -59,5 +60,5 @@ private: } //namespace Phonon::Gstreamer QT_END_NAMESPACE - +#endif //QT_NO_PHONON_VIDEO #endif // Phonon_GSTREAMER_WIDGETRENDERER_H -- cgit v0.12 From 433d3d130ac1b542f12574566c176f065bab29d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 22 Oct 2009 13:46:32 +0200 Subject: Remove ICON from QFeature Reviewed-by: Trust Me --- src/corelib/global/qconfig-local.h | 3 + src/corelib/global/qfeatures.h | 109 ++++++++++++++++++------------------- src/corelib/global/qfeatures.txt | 13 +---- 3 files changed, 58 insertions(+), 67 deletions(-) create mode 100644 src/corelib/global/qconfig-local.h diff --git a/src/corelib/global/qconfig-local.h b/src/corelib/global/qconfig-local.h new file mode 100644 index 0000000..90db873 --- /dev/null +++ b/src/corelib/global/qconfig-local.h @@ -0,0 +1,3 @@ +#ifndef QT_NO_SCROLLAREA +# define QT_NO_SCROLLAREA +#endif diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index adc2743..e4fd67a 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -82,9 +82,6 @@ // QGroupBox //#define QT_NO_GROUPBOX -// QIcon -//#define QT_NO_ICON - // QImageIOPlugin //#define QT_NO_IMAGEFORMATPLUGIN @@ -256,6 +253,9 @@ // QSystemSemaphore //#define QT_NO_SYSTEMSEMAPHORE +// QSystemTrayIcon +//#define QT_NO_SYSTEMTRAYICON + // QTabletEvent //#define QT_NO_TABLETEVENT @@ -466,9 +466,9 @@ #define QT_NO_SXE #endif -// QSystemTrayIcon -#if !defined(QT_NO_SYSTEMTRAYICON) && (defined(QT_NO_ICON)) -#define QT_NO_SYSTEMTRAYICON +// QToolButton +#if !defined(QT_NO_TOOLBUTTON) && (defined(QT_NO_ACTION)) +#define QT_NO_TOOLBUTTON #endif // QUndoStack @@ -536,16 +536,16 @@ #define QT_NO_STYLE_WINDOWSVISTA #endif +// QTabBar +#if !defined(QT_NO_TABBAR) && (defined(QT_NO_TOOLBUTTON)) +#define QT_NO_TABBAR +#endif + // OdfWriter #if !defined(QT_NO_TEXTODFWRITER) && (defined(QT_NO_XMLSTREAMWRITER)) #define QT_NO_TEXTODFWRITER #endif -// QToolButton -#if !defined(QT_NO_TOOLBUTTON) && (defined(QT_NO_ICON) || defined(QT_NO_ACTION)) -#define QT_NO_TOOLBUTTON -#endif - // Translation (UTF-8 representation) #if !defined(QT_NO_TRANSLATION_UTF8) && (defined(QT_NO_TRANSLATION) || defined(QT_NO_TEXTCODEC)) #define QT_NO_TRANSLATION_UTF8 @@ -556,6 +556,11 @@ #define QT_NO_UNDOGROUP #endif +// QWhatsThis +#if !defined(QT_NO_WHATSTHIS) && (defined(QT_NO_TOOLBUTTON)) +#define QT_NO_WHATSTHIS +#endif + // Drag and drop #if !defined(QT_NO_DRAGANDDROP) && (defined(QT_NO_QWS_PROPERTIES) || defined(QT_NO_IMAGEFORMAT_XPM)) #define QT_NO_DRAGANDDROP @@ -581,6 +586,11 @@ #define QT_NO_PHONON_PLATFORMPLUGIN #endif +// Phonon::VolumeSlider +#if !defined(QT_NO_PHONON_VOLUMESLIDER) && (defined(QT_NO_SLIDER) || defined(QT_NO_TOOLBUTTON)) +#define QT_NO_PHONON_VOLUMESLIDER +#endif + // QPrinter #if !defined(QT_NO_PRINTER) && (defined(QT_NO_TEXTSTREAM) || defined(QT_NO_PICTURE) || defined(QT_NO_TEMPORARYFILE)) #define QT_NO_PRINTER @@ -621,14 +631,9 @@ #define QT_NO_SVG #endif -// QTabBar -#if !defined(QT_NO_TABBAR) && (defined(QT_NO_TOOLBUTTON)) -#define QT_NO_TABBAR -#endif - -// QWhatsThis -#if !defined(QT_NO_WHATSTHIS) && (defined(QT_NO_TOOLBUTTON)) -#define QT_NO_WHATSTHIS +// Q3TabDialog +#if !defined(QT_NO_TABDIALOG) && (defined(QT_NO_TABBAR)) +#define QT_NO_TABDIALOG #endif // QColorDialog @@ -641,9 +646,9 @@ #define QT_NO_ITEMVIEWS #endif -// Phonon::VolumeSlider -#if !defined(QT_NO_PHONON_VOLUMESLIDER) && (defined(QT_NO_SLIDER) || defined(QT_NO_TOOLBUTTON)) -#define QT_NO_PHONON_VOLUMESLIDER +// QMenuBar +#if !defined(QT_NO_MENUBAR) && (defined(QT_NO_MENU) || defined(QT_NO_TOOLBUTTON)) +#define QT_NO_MENUBAR #endif // QWSInputMethod @@ -666,9 +671,9 @@ #define QT_NO_SVGRENDERER #endif -// Q3TabDialog -#if !defined(QT_NO_TABDIALOG) && (defined(QT_NO_TABBAR)) -#define QT_NO_TABDIALOG +// QTabWidget +#if !defined(QT_NO_TABWIDGET) && (defined(QT_NO_TABBAR) || defined(QT_NO_STACKEDWIDGET)) +#define QT_NO_TABWIDGET #endif // QTextCodecPlugin @@ -696,9 +701,9 @@ #define QT_NO_LISTVIEW #endif -// QMenuBar -#if !defined(QT_NO_MENUBAR) && (defined(QT_NO_MENU) || defined(QT_NO_TOOLBUTTON)) -#define QT_NO_MENUBAR +// QMainWindow +#if !defined(QT_NO_MAINWINDOW) && (defined(QT_NO_MENU) || defined(QT_NO_RESIZEHANDLER) || defined(QT_NO_TOOLBUTTON)) +#define QT_NO_MAINWINDOW #endif // QAbstractProxyModel @@ -731,21 +736,26 @@ #define QT_NO_TABLEVIEW #endif -// QTabWidget -#if !defined(QT_NO_TABWIDGET) && (defined(QT_NO_TABBAR) || defined(QT_NO_STACKEDWIDGET)) -#define QT_NO_TABWIDGET -#endif - // QTextBrowser #if !defined(QT_NO_TEXTBROWSER) && (defined(QT_NO_TEXTEDIT)) #define QT_NO_TEXTBROWSER #endif +// QToolBox +#if !defined(QT_NO_TOOLBOX) && (defined(QT_NO_TOOLBUTTON) || defined(QT_NO_SCROLLAREA)) +#define QT_NO_TOOLBOX +#endif + // QTreeView #if !defined(QT_NO_TREEVIEW) && (defined(QT_NO_ITEMVIEWS)) #define QT_NO_TREEVIEW #endif +// Accessibility +#if !defined(QT_NO_ACCESSIBILITY) && (defined(QT_NO_PROPERTIES) || defined(QT_NO_MENUBAR)) +#define QT_NO_ACCESSIBILITY +#endif + // QColumnView #if !defined(QT_NO_COLUMNVIEW) && (defined(QT_NO_LISTVIEW)) #define QT_NO_COLUMNVIEW @@ -766,11 +776,6 @@ #define QT_NO_LISTWIDGET #endif -// QMainWindow -#if !defined(QT_NO_MAINWINDOW) && (defined(QT_NO_MENU) || defined(QT_NO_RESIZEHANDLER) || defined(QT_NO_TOOLBUTTON)) -#define QT_NO_MAINWINDOW -#endif - // QSortFilterProxyModel #if !defined(QT_NO_SORTFILTERPROXYMODEL) && (defined(QT_NO_PROXYMODEL)) #define QT_NO_SORTFILTERPROXYMODEL @@ -781,9 +786,9 @@ #define QT_NO_TABLEWIDGET #endif -// QToolBox -#if !defined(QT_NO_TOOLBOX) && (defined(QT_NO_TOOLBUTTON) || defined(QT_NO_SCROLLAREA)) -#define QT_NO_TOOLBOX +// QToolBar +#if !defined(QT_NO_TOOLBAR) && (defined(QT_NO_MAINWINDOW)) +#define QT_NO_TOOLBAR #endif // QTreeWidget @@ -791,21 +796,11 @@ #define QT_NO_TREEWIDGET #endif -// Accessibility -#if !defined(QT_NO_ACCESSIBILITY) && (defined(QT_NO_PROPERTIES) || defined(QT_NO_MENUBAR)) -#define QT_NO_ACCESSIBILITY -#endif - // Common UNIX Printing System #if !defined(QT_NO_CUPS) && (defined(QT_NO_PRINTER) || defined(QT_NO_LIBRARY)) #define QT_NO_CUPS #endif -// QToolBar -#if !defined(QT_NO_TOOLBAR) && (defined(QT_NO_MAINWINDOW)) -#define QT_NO_TOOLBAR -#endif - // QDockwidget #if !defined(QT_NO_DOCKWIDGET) && (defined(QT_NO_RUBBERBAND) || defined(QT_NO_MAINWINDOW)) #define QT_NO_DOCKWIDGET @@ -822,20 +817,20 @@ #endif // QComboBox -#if !defined(QT_NO_COMBOBOX) && (defined(QT_NO_LINEEDIT) || defined(QT_NO_STANDARDITEMMODEL) || defined(QT_NO_LISTVIEW) || defined(QT_NO_ICON)) +#if !defined(QT_NO_COMBOBOX) && (defined(QT_NO_LINEEDIT) || defined(QT_NO_STANDARDITEMMODEL) || defined(QT_NO_LISTVIEW)) #define QT_NO_COMBOBOX #endif -// QPrintPreviewWidget -#if !defined(QT_NO_PRINTPREVIEWWIDGET) && (defined(QT_NO_GRAPHICSVIEW) || defined(QT_NO_PRINTER) || defined(QT_NO_MAINWINDOW)) -#define QT_NO_PRINTPREVIEWWIDGET -#endif - // QWorkSpace #if !defined(QT_NO_WORKSPACE) && (defined(QT_NO_SCROLLBAR) || defined(QT_NO_MAINWINDOW) || defined(QT_NO_MENUBAR)) #define QT_NO_WORKSPACE #endif +// QPrintPreviewWidget +#if !defined(QT_NO_PRINTPREVIEWWIDGET) && (defined(QT_NO_GRAPHICSVIEW) || defined(QT_NO_PRINTER) || defined(QT_NO_MAINWINDOW)) +#define QT_NO_PRINTPREVIEWWIDGET +#endif + // QCalendarWidget #if !defined(QT_NO_CALENDARWIDGET) && (defined(QT_NO_TABLEVIEW) || defined(QT_NO_MENU) || defined(QT_NO_TEXTDATE) || defined(QT_NO_SPINBOX) || defined(QT_NO_TOOLBUTTON)) #define QT_NO_CALENDARWIDGET diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index 4b012d9..0bee94a 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -352,7 +352,7 @@ SeeAlso: ??? Feature: COMBOBOX Description: Supports comboboxes presenting a list of options to the user. Section: Widgets -Requires: LINEEDIT STANDARDITEMMODEL LISTVIEW ICON +Requires: LINEEDIT STANDARDITEMMODEL LISTVIEW Name: QComboBox SeeAlso: ??? @@ -366,7 +366,7 @@ SeeAlso: ??? Feature: TOOLBUTTON Description: Supports quick-access buttons to commands and options. Section: Widgets -Requires: ICON ACTION +Requires: ACTION Name: QToolButton SeeAlso: ??? @@ -826,13 +826,6 @@ Requires: Name: QImageIOPlugin SeeAlso: ??? -Feature: ICON -Description: Supports scalable icons in different modes and states. -Section: Images -Requires: -Name: QIcon -SeeAlso: ??? - Feature: MOVIE Description: Supports animated images. Section: Images @@ -1124,7 +1117,7 @@ SeeAlso: ??? Feature: SYSTEMTRAYICON Description: Provides an icon for an application in the system tray. Section: Utilities -Requires: ICON +Requires: Name: QSystemTrayIcon SeeAlso: ??? -- cgit v0.12 From 38908792600e7cd471fece1de71e2ad13cbb0866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 22 Oct 2009 13:48:23 +0200 Subject: Fix SCROLLAREA by fixing missing QT_NO_GRAPHICSVIEW dependencies Reviewed-by: tom --- src/gui/graphicsview/qgraphicsanchorlayout.cpp | 3 ++- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 3 ++- src/gui/graphicsview/qgraphicsanchorlayout_p.h | 3 ++- src/gui/graphicsview/qgraphicstransform.cpp | 3 ++- src/gui/graphicsview/qgraphicstransform.h | 2 ++ src/gui/graphicsview/qgraphicstransform_p.h | 3 ++- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp index e21cd99..2bed776 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp @@ -123,7 +123,7 @@ */ #include "qgraphicsanchorlayout_p.h" - +#ifndef QT_NO_GRAPHICSVIEW QT_BEGIN_NAMESPACE QGraphicsAnchor::QGraphicsAnchor(QGraphicsAnchorLayout *parentLayout) @@ -535,3 +535,4 @@ QSizeF QGraphicsAnchorLayout::sizeHint(Qt::SizeHint which, const QSizeF &constra } QT_END_NAMESPACE +#endif //QT_NO_GRAPHICSVIEW diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 8c8c303..c424be5 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -48,7 +48,7 @@ #endif #include "qgraphicsanchorlayout_p.h" - +#ifndef QT_NO_GRAPHICSVIEW QT_BEGIN_NAMESPACE @@ -2635,3 +2635,4 @@ void QGraphicsAnchorLayoutPrivate::dumpGraph(const QString &name) #endif QT_END_NAMESPACE +#endif //QT_NO_GRAPHICSVIEW diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index d45c004..9513ddf 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -60,7 +60,7 @@ #include "qgraphicsanchorlayout.h" #include "qgraph_p.h" #include "qsimplex_p.h" - +#ifndef QT_NO_GRAPHICSVIEW QT_BEGIN_NAMESPACE /* @@ -529,5 +529,6 @@ public: }; QT_END_NAMESPACE +#endif //QT_NO_GRAPHICSVIEW #endif diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp index e2a3f08..83bc9e1 100644 --- a/src/gui/graphicsview/qgraphicstransform.cpp +++ b/src/gui/graphicsview/qgraphicstransform.cpp @@ -93,8 +93,8 @@ #include #include +#ifndef QT_NO_GRAPHICSVIEW QT_BEGIN_NAMESPACE - void QGraphicsTransformPrivate::setItem(QGraphicsItem *i) { if (item == i) @@ -565,3 +565,4 @@ void QGraphicsRotation::applyTo(QMatrix4x4 *matrix) const #include "moc_qgraphicstransform.cpp" QT_END_NAMESPACE +#endif //QT_NO_GRAPHICSVIEW diff --git a/src/gui/graphicsview/qgraphicstransform.h b/src/gui/graphicsview/qgraphicstransform.h index 58075aa..58e3077 100644 --- a/src/gui/graphicsview/qgraphicstransform.h +++ b/src/gui/graphicsview/qgraphicstransform.h @@ -47,6 +47,7 @@ #include #include +#ifndef QT_NO_GRAPHICSVIEW QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -150,5 +151,6 @@ private: QT_END_NAMESPACE QT_END_HEADER +#endif //QT_NO_GRAPHICSVIEW #endif // QFXTRANSFORM_H diff --git a/src/gui/graphicsview/qgraphicstransform_p.h b/src/gui/graphicsview/qgraphicstransform_p.h index 9e708b2..ddf99bb 100644 --- a/src/gui/graphicsview/qgraphicstransform_p.h +++ b/src/gui/graphicsview/qgraphicstransform_p.h @@ -54,7 +54,7 @@ // #include "private/qobject_p.h" - +#ifndef QT_NO_GRAPHICSVIEW QT_BEGIN_NAMESPACE class QGraphicsItem; @@ -73,5 +73,6 @@ public: }; QT_END_NAMESPACE +#endif //QT_NO_GRAPHCISVIEW #endif // QGRAPHICSTRANSFORM_P_H -- cgit v0.12 From 9d4d1814eb7e130cd3ef75393a7957216dc14d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 26 Oct 2009 12:27:20 +0100 Subject: Fix THREAD and TOOLBAR Reviewed-by: tom Squash me with Fix THREAD and TOOLBAR a6e785b4ff9ec9cd48 --- src/corelib/global/qconfig-local.h | 4 +-- src/corelib/global/qfeatures.h | 29 ++++++++++-------- src/corelib/global/qfeatures.txt | 15 ++++++--- src/corelib/thread/qmutexpool.cpp | 20 ++++++------ src/corelib/thread/qmutexpool_p.h | 17 +++++++++-- src/corelib/thread/qthread.cpp | 24 +++++++++------ src/corelib/thread/qthread_p.h | 62 ++++++++++++++++++-------------------- src/gui/dialogs/qfscompleter_p.h | 4 +-- 8 files changed, 101 insertions(+), 74 deletions(-) diff --git a/src/corelib/global/qconfig-local.h b/src/corelib/global/qconfig-local.h index 90db873..b9a5090 100644 --- a/src/corelib/global/qconfig-local.h +++ b/src/corelib/global/qconfig-local.h @@ -1,3 +1,3 @@ -#ifndef QT_NO_SCROLLAREA -# define QT_NO_SCROLLAREA +#ifndef QT_NO_TOOLBAR +# define QT_NO_TOOLBAR #endif diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index e4fd67a..455fead 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -301,11 +301,6 @@ // //#define QT_NO_XMLSTREAM -// Animation -#if !defined(QT_NO_ANIMATION) && (defined(QT_NO_PROPERTIES)) -#define QT_NO_ANIMATION -#endif - // QButtonGroup #if !defined(QT_NO_BUTTONGROUP) && (defined(QT_NO_GROUPBOX)) #define QT_NO_BUTTONGROUP @@ -496,6 +491,11 @@ #define QT_NO_XMLSTREAMWRITER #endif +// Animation +#if !defined(QT_NO_ANIMATION) && (defined(QT_NO_PROPERTIES) || defined(QT_NO_THREAD)) +#define QT_NO_ANIMATION +#endif + // Context menu #if !defined(QT_NO_CONTEXTMENU) && (defined(QT_NO_MENU)) #define QT_NO_CONTEXTMENU @@ -686,11 +686,6 @@ #define QT_NO_TEXTEDIT #endif -// QDirModel -#if !defined(QT_NO_DIRMODEL) && (defined(QT_NO_ITEMVIEWS)) -#define QT_NO_DIRMODEL -#endif - // QErrorMessage #if !defined(QT_NO_ERRORMESSAGE) && (defined(QT_NO_TEXTEDIT)) #define QT_NO_ERRORMESSAGE @@ -806,6 +801,11 @@ #define QT_NO_DOCKWIDGET #endif +// QDirModel +#if !defined(QT_NO_DIRMODEL) && (defined(QT_NO_ITEMVIEWS) || defined(QT_NO_FILESYSTEMMODEL)) +#define QT_NO_DIRMODEL +#endif + // QUndoView #if !defined(QT_NO_UNDOVIEW) && (defined(QT_NO_UNDOSTACK) || defined(QT_NO_LISTVIEW)) #define QT_NO_UNDOVIEW @@ -816,6 +816,11 @@ #define QT_NO_GRAPHICSSVGITEM #endif +// QCompleter +#if !defined(QT_NO_FSCOMPLETER) && (defined(QT_NO_FILESYSTEMMODEL) || defined(QT_NO_COMPLETER)) +#define QT_NO_FSCOMPLETER +#endif + // QComboBox #if !defined(QT_NO_COMBOBOX) && (defined(QT_NO_LINEEDIT) || defined(QT_NO_STANDARDITEMMODEL) || defined(QT_NO_LISTVIEW)) #define QT_NO_COMBOBOX @@ -867,12 +872,12 @@ #endif // QFileDialog -#if !defined(QT_NO_FILEDIALOG) && (defined(QT_NO_DIRMODEL) || defined(QT_NO_TREEVIEW) || defined(QT_NO_COMBOBOX) || defined(QT_NO_TOOLBUTTON) || defined(QT_NO_BUTTONGROUP) || defined(QT_NO_TOOLTIP) || defined(QT_NO_SPLITTER) || defined(QT_NO_STACKEDWIDGET) || defined(QT_NO_FILESYSTEMMODEL)) +#if !defined(QT_NO_FILEDIALOG) && (defined(QT_NO_DIRMODEL) || defined(QT_NO_TREEVIEW) || defined(QT_NO_COMBOBOX) || defined(QT_NO_TOOLBUTTON) || defined(QT_NO_BUTTONGROUP) || defined(QT_NO_TOOLTIP) || defined(QT_NO_SPLITTER) || defined(QT_NO_STACKEDWIDGET)) #define QT_NO_FILEDIALOG #endif // QPrintPreviewDialog -#if !defined(QT_NO_PRINTPREVIEWDIALOG) && (defined(QT_NO_PRINTPREVIEWWIDGET) || defined(QT_NO_PRINTDIALOG)) +#if !defined(QT_NO_PRINTPREVIEWDIALOG) && (defined(QT_NO_PRINTPREVIEWWIDGET) || defined(QT_NO_PRINTDIALOG) || defined(QT_NO_TOOLBAR)) #define QT_NO_PRINTPREVIEWDIALOG #endif diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index 0bee94a..f2b5c20 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -604,7 +604,7 @@ SeeAlso: ??? Feature: FILEDIALOG Description: Supports a dialog widget for selecting files or directories. Section: Dialogs -Requires: DIRMODEL TREEVIEW COMBOBOX TOOLBUTTON BUTTONGROUP TOOLTIP SPLITTER STACKEDWIDGET FILESYSTEMMODEL +Requires: DIRMODEL TREEVIEW COMBOBOX TOOLBUTTON BUTTONGROUP TOOLTIP SPLITTER STACKEDWIDGET Name: QFileDialog SeeAlso: ??? @@ -625,7 +625,7 @@ SeeAlso: ??? Feature: PRINTPREVIEWDIALOG Description: Provides a dialog for previewing and configuring page layouts for printer output. Section: Dialogs -Requires: PRINTPREVIEWWIDGET PRINTDIALOG +Requires: PRINTPREVIEWWIDGET PRINTDIALOG TOOLBAR Name: QPrintPreviewDialog SeeAlso: ??? @@ -677,7 +677,7 @@ SeeAlso: ??? Feature: DIRMODEL Description: Supports a data model for the local filesystem. Section: ItemViews -Requires: ITEMVIEWS +Requires: ITEMVIEWS FILESYSTEMMODEL Name: QDirModel SeeAlso: ??? @@ -1107,6 +1107,13 @@ Requires: PROXYMODEL Name: QCompleter SeeAlso: ??? +Feature: FSCOMPLETER +Description: Provides completions based on an item model. +Section: Utilities +Requires: FILESYSTEMMODEL COMPLETER +Name: QCompleter +SeeAlso: ??? + Feature: DESKTOPSERVICES Description: Provides methods for accessing common desktop services. Section: Utilities @@ -1159,7 +1166,7 @@ SeeAlso: ??? Feature: ANIMATION Description: Provides a framework for animations. Section: Utilities -Requires: PROPERTIES +Requires: PROPERTIES THREAD Name: Animation SeeAlso: ??? diff --git a/src/corelib/thread/qmutexpool.cpp b/src/corelib/thread/qmutexpool.cpp index c5c1882..9f37239 100644 --- a/src/corelib/thread/qmutexpool.cpp +++ b/src/corelib/thread/qmutexpool.cpp @@ -42,7 +42,6 @@ #include "qatomic.h" #include "qmutexpool_p.h" -#ifndef QT_NO_THREAD QT_BEGIN_NAMESPACE @@ -50,6 +49,7 @@ QT_BEGIN_NAMESPACE // use QMutexpool::instance() in new clode. Q_CORE_EXPORT QMutexPool *qt_global_mutexpool = 0; Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (QMutex::Recursive)) +#ifndef QT_NO_THREAD /*! \class QMutexPool @@ -114,15 +114,6 @@ QMutexPool::~QMutexPool() mutexes[index] = 0; } } - -/*! - Returns the global QMutexPool instance. -*/ -QMutexPool *QMutexPool::instance() -{ - return globalMutexPool(); -} - /*! Returns a QMutex from the pool. QMutexPool uses the value \a address to determine which mutex is returned from the pool. @@ -152,7 +143,14 @@ QMutex *QMutexPool::globalInstanceGet(const void *address) return 0; return globalInstance->get(address); } +#endif // QT_NO_THREAD +/*! + Returns the global QMutexPool instance. +*/ +QMutexPool *QMutexPool::instance() +{ + return globalMutexPool(); +} QT_END_NAMESPACE -#endif // QT_NO_THREAD diff --git a/src/corelib/thread/qmutexpool_p.h b/src/corelib/thread/qmutexpool_p.h index 3e1bad0..c26711b 100644 --- a/src/corelib/thread/qmutexpool_p.h +++ b/src/corelib/thread/qmutexpool_p.h @@ -57,9 +57,9 @@ #include "QtCore/qmutex.h" #include "QtCore/qvarlengtharray.h" -#ifndef QT_NO_THREAD QT_BEGIN_NAMESPACE +#ifndef QT_NO_THREAD class Q_CORE_EXPORT QMutexPool { @@ -75,11 +75,24 @@ private: QVarLengthArray, 131> mutexes; QMutex::RecursionMode recursionMode; }; +#else //QT_NO_THREAD +Q_GLOBAL_STATIC(QMutex, globalMutex) +class Q_CORE_EXPORT QMutexPool +{ +public: + explicit QMutexPool(QMutex::RecursionMode recursionMode = QMutex::NonRecursive, int size = 131){} + ~QMutexPool(){} + + QMutex *get(const void *address){return globalMutex();} + static QMutexPool *instance(); + static QMutex *globalInstanceGet(const void *address){return globalMutex();} +}; + +#endif // QT_NO_THREAD extern Q_CORE_EXPORT QMutexPool *qt_global_mutexpool; QT_END_NAMESPACE -#endif // QT_NO_THREAD #endif // QMUTEXPOOL_P_H diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index ac191fe..cf57d33 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -727,6 +727,16 @@ QThread *QThread::currentThread() return QThreadData::current()->thread; } +/*! \internal + */ +QThread::QThread(QThreadPrivate &dd, QObject *parent) + : QObject(dd, parent) +{ + Q_D(QThread); + // fprintf(stderr, "QThreadData %p taken from private data for thread %p\n", d->data, this); + d->data->thread = this; +} + QThreadData* QThreadData::current() { static QThreadData *data = 0; // reinterpret_cast(pthread_getspecific(current_thread_data_key)); @@ -738,17 +748,13 @@ QThreadData* QThreadData::current() } return data; } - -/*! \internal - */ -QThread::QThread(QThreadPrivate &dd, QObject *parent) - : QObject(dd, parent) +#endif // QT_NO_THREAD +QThreadData* QThreadData::get2(QThread *thread) { - Q_D(QThread); - // fprintf(stderr, "QThreadData %p taken from private data for thread %p\n", d->data, this); - d->data->thread = this; + Q_ASSERT_X(thread != 0, "QThread", "internal error"); + return thread->d_func()->data; } -#endif // QT_NO_THREAD + QT_END_NAMESPACE diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index af68434..8c3acdb 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -111,6 +111,36 @@ public: { } }; +class QThreadData +{ + QAtomicInt _ref; + +public: + QThreadData(int initialRefCount = 1); + ~QThreadData(); + + static QThreadData *current(); + static QThreadData *get2(QThread *thread); + + void ref(); + void deref(); + + QThread *thread; + bool quitNow; + int loopLevel; + QAbstractEventDispatcher *eventDispatcher; + QStack eventLoops; + QPostEventList postEventList; + bool canWait; + QMap tls; + + QMutex mutex; + +# ifdef Q_OS_SYMBIAN + RThread symbian_thread_handle; +# endif +}; + #ifndef QT_NO_THREAD class QThreadPrivate : public QObjectPrivate { @@ -179,38 +209,6 @@ public: #endif // QT_NO_THREAD -class QThreadData -{ - QAtomicInt _ref; - -public: - QThreadData(int initialRefCount = 1); - ~QThreadData(); - - static QThreadData *current(); - static QThreadData *get2(QThread *thread) - { Q_ASSERT_X(thread != 0, "QThread", "internal error"); return thread->d_func()->data; } - - - void ref(); - void deref(); - - QThread *thread; - bool quitNow; - int loopLevel; - QAbstractEventDispatcher *eventDispatcher; - QStack eventLoops; - QPostEventList postEventList; - bool canWait; - QMap tls; - - QMutex mutex; - -# ifdef Q_OS_SYMBIAN - RThread symbian_thread_handle; -# endif -}; - // thread wrapper for the main() thread class QAdoptedThread : public QThread { diff --git a/src/gui/dialogs/qfscompleter_p.h b/src/gui/dialogs/qfscompleter_p.h index cb1b427..1edab2d 100644 --- a/src/gui/dialogs/qfscompleter_p.h +++ b/src/gui/dialogs/qfscompleter_p.h @@ -56,7 +56,7 @@ #include "qcompleter.h" #include QT_BEGIN_NAMESPACE -#ifndef QT_NO_COMPLETER +#ifndef QT_NO_FSCOMPLETER /*! QCompleter that can deal with QFileSystemModel @@ -76,7 +76,7 @@ public: QAbstractProxyModel *proxyModel; QFileSystemModel *sourceModel; }; -#endif // QT_NO_COMPLETER +#endif // QT_NO_FSCOMPLETER QT_END_NAMESPACE #endif // QFSCOMPLETOR_P_H -- cgit v0.12 From a733f087467c5f8361a7765a38e45037549c019f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 27 Oct 2009 08:34:39 +0100 Subject: Fix FSCOMPLETER Reviewed-by: tom --- src/gui/dialogs/qfiledialog.cpp | 12 ++++++------ src/gui/dialogs/qfiledialog_p.h | 4 ++-- src/gui/dialogs/qprintdialog_unix.cpp | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index eab842f..c6b4a77 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -777,7 +777,7 @@ void QFileDialog::setDirectory(const QString &directory) QModelIndex root = d->model->setRootPath(newDirectory); d->qFileDialogUi->newFolderButton->setEnabled(d->model->flags(root) & Qt::ItemIsDropEnabled); if (root != d->rootIndex()) { -#ifndef QT_NO_COMPLETER +#ifndef QT_NO_FSCOMPLETER if (directory.endsWith(QLatin1Char('/'))) d->completer->setCompletionPrefix(newDirectory); else @@ -2177,12 +2177,12 @@ void QFileDialogPrivate::createWidgets() #ifndef QT_NO_SHORTCUT qFileDialogUi->fileNameLabel->setBuddy(qFileDialogUi->fileNameEdit); #endif -#ifndef QT_NO_COMPLETER +#ifndef QT_NO_FSCOMPLETER completer = new QFSCompleter(model, q); qFileDialogUi->fileNameEdit->setCompleter(completer); QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(textChanged(QString)), q, SLOT(_q_autoCompleteFileName(QString))); -#endif // QT_NO_COMPLETER +#endif // QT_NO_FSCOMPLETER QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(textChanged(QString)), q, SLOT(_q_updateOkButton())); @@ -2302,7 +2302,7 @@ void QFileDialog::setProxyModel(QAbstractProxyModel *proxyModel) proxyModel->setSourceModel(d->model); d->qFileDialogUi->listView->setModel(d->proxyModel); d->qFileDialogUi->treeView->setModel(d->proxyModel); -#ifndef QT_NO_COMPLETER +#ifndef QT_NO_FSCOMPLETER d->completer->setModel(d->proxyModel); d->completer->proxyModel = d->proxyModel; #endif @@ -2312,7 +2312,7 @@ void QFileDialog::setProxyModel(QAbstractProxyModel *proxyModel) d->proxyModel = 0; d->qFileDialogUi->listView->setModel(d->model); d->qFileDialogUi->treeView->setModel(d->model); -#ifndef QT_NO_COMPLETER +#ifndef QT_NO_FSCOMPLETER d->completer->setModel(d->model); d->completer->sourceModel = d->model; d->completer->proxyModel = 0; @@ -3218,7 +3218,7 @@ void QFileDialogLineEdit::keyPressEvent(QKeyEvent *e) } } -#ifndef QT_NO_COMPLETER +#ifndef QT_NO_FSCOMPLETER QString QFSCompleter::pathFromIndex(const QModelIndex &index) const { diff --git a/src/gui/dialogs/qfiledialog_p.h b/src/gui/dialogs/qfiledialog_p.h index 32cd397..0e447a3 100644 --- a/src/gui/dialogs/qfiledialog_p.h +++ b/src/gui/dialogs/qfiledialog_p.h @@ -234,9 +234,9 @@ public: QStringList watching; QFileSystemModel *model; -#ifndef QT_NO_COMPLETER +#ifndef QT_NO_FSCOMPLETER QFSCompleter *completer; -#endif //QT_NO_COMPLETER +#endif //QT_NO_FSCOMPLETER QFileDialog::FileMode fileMode; QFileDialog::AcceptMode acceptMode; diff --git a/src/gui/dialogs/qprintdialog_unix.cpp b/src/gui/dialogs/qprintdialog_unix.cpp index 7daa273..6fc270d 100644 --- a/src/gui/dialogs/qprintdialog_unix.cpp +++ b/src/gui/dialogs/qprintdialog_unix.cpp @@ -696,7 +696,7 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p) #ifndef QT_NO_FILESYSTEMMODEL QFileSystemModel *fsm = new QFileSystemModel(widget.filename); fsm->setRootPath(QDir::homePath()); -#if !defined(QT_NO_COMPLETER) && !defined(QT_NO_FILEDIALOG) +#if !defined(QT_NO_FSCOMPLETER) && !defined(QT_NO_FILEDIALOG) widget.filename->setCompleter(new QFSCompleter(fsm, widget.filename)); #endif #endif -- cgit v0.12 From c0c9940b371215eea294ae83ed6586a6414957ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 27 Oct 2009 10:53:17 +0100 Subject: Fix TEXTCODEC Reviewed-by: tom --- src/gui/kernel/qclipboard.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp index 5ed4dc9..e43f8b5 100644 --- a/src/gui/kernel/qclipboard.cpp +++ b/src/gui/kernel/qclipboard.cpp @@ -296,12 +296,16 @@ QString QClipboard::text(QString &subtype, Mode mode) const const QByteArray rawData = data->data(QLatin1String("text/") + subtype); +#ifndef QT_NO_TEXTCODEC QTextCodec* codec = QTextCodec::codecForMib(106); // utf-8 is default if (subtype == QLatin1String("html")) codec = QTextCodec::codecForHtml(rawData, codec); else codec = QTextCodec::codecForUtfText(rawData, codec); return codec->toUnicode(rawData); +#else //QT_NO_TEXTCODEC + return rawData; +#endif //QT_NO_TEXTCODEC } /*! -- cgit v0.12 From d0aa2b8422eea07823caef639a0970b8f2a1fde0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 27 Oct 2009 10:55:28 +0100 Subject: Fix PROXYMODEL Reviewed-by: Trust Me --- src/corelib/global/qconfig-local.h | 3 --- src/corelib/global/qfeatures.h | 2 +- src/corelib/global/qfeatures.txt | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) delete mode 100644 src/corelib/global/qconfig-local.h diff --git a/src/corelib/global/qconfig-local.h b/src/corelib/global/qconfig-local.h deleted file mode 100644 index b9a5090..0000000 --- a/src/corelib/global/qconfig-local.h +++ /dev/null @@ -1,3 +0,0 @@ -#ifndef QT_NO_TOOLBAR -# define QT_NO_TOOLBAR -#endif diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index 455fead..3996180 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -872,7 +872,7 @@ #endif // QFileDialog -#if !defined(QT_NO_FILEDIALOG) && (defined(QT_NO_DIRMODEL) || defined(QT_NO_TREEVIEW) || defined(QT_NO_COMBOBOX) || defined(QT_NO_TOOLBUTTON) || defined(QT_NO_BUTTONGROUP) || defined(QT_NO_TOOLTIP) || defined(QT_NO_SPLITTER) || defined(QT_NO_STACKEDWIDGET)) +#if !defined(QT_NO_FILEDIALOG) && (defined(QT_NO_DIRMODEL) || defined(QT_NO_TREEVIEW) || defined(QT_NO_COMBOBOX) || defined(QT_NO_TOOLBUTTON) || defined(QT_NO_BUTTONGROUP) || defined(QT_NO_TOOLTIP) || defined(QT_NO_SPLITTER) || defined(QT_NO_STACKEDWIDGET) || defined(QT_NO_PROXYMODEL)) #define QT_NO_FILEDIALOG #endif diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index f2b5c20..543056f 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -604,7 +604,7 @@ SeeAlso: ??? Feature: FILEDIALOG Description: Supports a dialog widget for selecting files or directories. Section: Dialogs -Requires: DIRMODEL TREEVIEW COMBOBOX TOOLBUTTON BUTTONGROUP TOOLTIP SPLITTER STACKEDWIDGET +Requires: DIRMODEL TREEVIEW COMBOBOX TOOLBUTTON BUTTONGROUP TOOLTIP SPLITTER STACKEDWIDGET PROXYMODEL Name: QFileDialog SeeAlso: ??? -- cgit v0.12 From 3117574558b2aeb6e3e3e90ff8e44f4a2e74cf6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 27 Oct 2009 14:30:25 +0100 Subject: Fix SHAREDMEMORY Reviewed-by: tom --- src/corelib/kernel/qsharedmemory_unix.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp index 1165fb1..40b9f04 100644 --- a/src/corelib/kernel/qsharedmemory_unix.cpp +++ b/src/corelib/kernel/qsharedmemory_unix.cpp @@ -49,8 +49,6 @@ #include -#ifndef QT_NO_SHAREDMEMORY - #include #include #include @@ -61,6 +59,7 @@ #include "private/qcore_unix_p.h" +#ifndef QT_NO_SHAREDMEMORY QT_BEGIN_NAMESPACE QSharedMemoryPrivate::QSharedMemoryPrivate() -- cgit v0.12 From eec8980202f05737b0ef0b8db410675e0df5bafe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 27 Oct 2009 14:30:56 +0100 Subject: FIX TABBAR Reviewed-by: tom --- src/gui/widgets/qdockarealayout.cpp | 14 ++++++++++---- src/gui/widgets/qdockarealayout_p.h | 8 ++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index 5a0a9d4..ec35c4f 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -1556,9 +1556,10 @@ void QDockAreaLayoutInfo::apply(bool animate) } } } - +#ifndef QT_NO_TABBAR if (sep == 1) updateSeparatorWidgets(); +#endif //QT_NO_TABBAR } static void paintSep(QPainter *p, QWidget *w, const QRect &r, Qt::Orientation o, bool mouse_over) @@ -2008,13 +2009,14 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList updateTabBar(); setCurrentTabId(tabId(item_list.at(index))); } -#endif if (!testing && sep == 1) updateSeparatorWidgets(); +#endif return true; } +#ifndef QT_NO_TABBAR void QDockAreaLayoutInfo::updateSeparatorWidgets() const { if (tabbed) { @@ -2065,6 +2067,7 @@ void QDockAreaLayoutInfo::updateSeparatorWidgets() const separatorWidgets.resize(j); Q_ASSERT(separatorWidgets.size() == j); } +#endif //QT_NO_TABBAR #ifndef QT_NO_TABBAR void QDockAreaLayoutInfo::updateTabBar() const @@ -3073,9 +3076,10 @@ void QDockAreaLayout::apply(bool animate) widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect, animate); } - +#ifndef QT_NO_TABBAR if (sep == 1) updateSeparatorWidgets(); +#endif //QT_NO_TABBAR } void QDockAreaLayout::paintSeparators(QPainter *p, QWidget *widget, @@ -3153,6 +3157,7 @@ int QDockAreaLayout::separatorMove(const QList &separator, const QPoint &or return delta; } +#ifndef QT_NO_TABBAR // Sets the correct positions for the seperator widgets // Allocates new sepearator widgets with getSeparatorWidget void QDockAreaLayout::updateSeparatorWidgets() const @@ -3186,6 +3191,7 @@ void QDockAreaLayout::updateSeparatorWidgets() const separatorWidgets.resize(j); } +#endif //QT_NO_TABBAR QLayoutItem *QDockAreaLayout::itemAt(int *x, int index) const { @@ -3238,7 +3244,6 @@ QSet QDockAreaLayout::usedTabBars() const } return result; } -#endif // Returns the set of all used separator widgets QSet QDockAreaLayout::usedSeparatorWidgets() const @@ -3253,6 +3258,7 @@ QSet QDockAreaLayout::usedSeparatorWidgets() const } return result; } +#endif QRect QDockAreaLayout::gapRect(const QList &path) const { diff --git a/src/gui/widgets/qdockarealayout_p.h b/src/gui/widgets/qdockarealayout_p.h index 99a9dbb..5692850 100644 --- a/src/gui/widgets/qdockarealayout_p.h +++ b/src/gui/widgets/qdockarealayout_p.h @@ -196,9 +196,10 @@ public: QRect rect; QMainWindow *mainWindow; QList item_list; - +#ifndef QT_NO_TABBAR void updateSeparatorWidgets() const; QSet usedSeparatorWidgets() const; +#endif //QT_NO_TABBAR #ifndef QT_NO_TABBAR quintptr currentTabId() const; @@ -278,7 +279,9 @@ public: const QPoint &mouse) const; QRegion separatorRegion() const; int separatorMove(const QList &separator, const QPoint &origin, const QPoint &dest); +#ifndef QT_NO_TABBAR void updateSeparatorWidgets() const; +#endif //QT_NO_TABBAR QLayoutItem *itemAt(int *x, int index) const; QLayoutItem *takeAt(int *x, int index); @@ -292,9 +295,10 @@ public: QRect gapRect(const QList &path) const; void keepSize(QDockWidget *w); - +#ifndef QT_NO_TABBAR QSet usedTabBars() const; QSet usedSeparatorWidgets() const; +#endif //QT_NO_TABBAR }; QT_END_NAMESPACE -- cgit v0.12 From 578b113f3dcceec0a88599494ad686fbc8cbfbb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 28 Oct 2009 08:42:10 +0100 Subject: Fix QT_NO_MAINWINDOW Reviewed-by: tom --- src/gui/widgets/qwidgetanimator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/widgets/qwidgetanimator.cpp b/src/gui/widgets/qwidgetanimator.cpp index f440961..bdd3c75 100644 --- a/src/gui/widgets/qwidgetanimator.cpp +++ b/src/gui/widgets/qwidgetanimator.cpp @@ -105,7 +105,9 @@ void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, boo #else //we do it in one shot widget->setGeometry(final_geometry); +#ifndef QT_NO_MAINWINDOW m_mainWindowLayout->animationFinished(widget); +#endif //QT_NO_MAINWINDOW #endif //QT_NO_ANIMATION } -- cgit v0.12 From 23b6599324bc62666d4303ca108ed372e8d7c490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 28 Oct 2009 09:23:45 +0100 Subject: Remove QT_NO_ICON from mimimal Reviewed-by: Trust Me --- src/corelib/global/qconfig-minimal.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/corelib/global/qconfig-minimal.h b/src/corelib/global/qconfig-minimal.h index 3d9539e..9cc3057 100644 --- a/src/corelib/global/qconfig-minimal.h +++ b/src/corelib/global/qconfig-minimal.h @@ -123,9 +123,6 @@ #endif /* Images */ -#ifndef QT_NO_ICON -# define QT_NO_ICON -#endif #ifndef QT_NO_IMAGEFORMATPLUGIN # define QT_NO_IMAGEFORMATPLUGIN #endif -- cgit v0.12 From 9c681ddc3a70b220de5d38de498ab1804ec12d4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 28 Oct 2009 15:50:04 +0100 Subject: Fix GRAPHICSVIEW Reviewed-by: tom --- src/gui/kernel/qevent.cpp | 2 ++ src/gui/kernel/qevent.h | 2 ++ src/gui/kernel/qgesturemanager.cpp | 2 ++ src/gui/kernel/qgesturemanager_p.h | 2 ++ src/gui/kernel/qwidget.cpp | 40 ++++++++++++++++++++++++--------- src/gui/painting/qbackingstore.cpp | 4 ++-- src/gui/painting/qwindowsurface_qws.cpp | 2 ++ 7 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 065bd09..bf9479f 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4345,6 +4345,7 @@ QWidget *QGestureEvent::widget() const return d_func()->widget; } +#ifndef QT_NO_GRAPHICSVIEW /*! Returns the scene-local coordinates if the \a gesturePoint is inside a graphics view. @@ -4361,6 +4362,7 @@ QPointF QGestureEvent::mapToScene(const QPointF &gesturePoint) const } return QPointF(); } +#endif //QT_NO_GRAPHICSVIEW /*! \internal diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index b7370fd..d6b1dc1 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -854,7 +854,9 @@ public: void setWidget(QWidget *widget); QWidget *widget() const; +#ifndef QT_NO_GRAPHICSVIEW QPointF mapToScene(const QPointF &gesturePoint) const; +#endif private: QGestureEventPrivate *d_func(); diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index ed8e744..5ad607b 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -331,6 +331,7 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) return filterEventThroughContexts(contexts, event); } +#ifndef QT_NO_GRAPHICSVIEW bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) { QSet types; @@ -360,6 +361,7 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) } return filterEventThroughContexts(contexts, event); } +#endif bool QGestureManager::filterEvent(QGesture *state, QEvent *event) { diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index f0e7225..8199e02 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -74,7 +74,9 @@ public: bool filterEvent(QWidget *receiver, QEvent *event); bool filterEvent(QGesture *receiver, QEvent *event); +#ifndef QT_NO_GRAPHICSVIEW bool filterEvent(QGraphicsObject *receiver, QEvent *event); +#endif //QT_NO_GRAPHICSVIEW // declared in qapplication.cpp static QGestureManager* instance(); diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 916ae8b..62cfd12 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1549,7 +1549,9 @@ void QWidgetPrivate::createExtra() extra = new QWExtra; extra->glContext = 0; extra->topextra = 0; +#ifndef QT_NO_GRAPHICSVIEW extra->proxyWidget = 0; +#endif #ifndef QT_NO_CURSOR extra->curs = 0; #endif @@ -1699,12 +1701,13 @@ void QWidgetPrivate::propagatePaletteChange() { Q_Q(QWidget); // Propagate a new inherited mask to all children. - if (!q->parentWidget() && extra && extra->proxyWidget) { #ifndef QT_NO_GRAPHICSVIEW + if (!q->parentWidget() && extra && extra->proxyWidget) { QGraphicsProxyWidget *p = extra->proxyWidget; inheritedPaletteResolveMask = p->d_func()->inheritedPaletteResolveMask | p->palette().resolve(); + } else #endif //QT_NO_GRAPHICSVIEW - } else if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) { + if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) { inheritedPaletteResolveMask = 0; } int mask = data.pal.resolve() | inheritedPaletteResolveMask; @@ -4381,7 +4384,11 @@ QPalette QWidgetPrivate::naturalWidgetPalette(uint inheritedMask) const Q_Q(const QWidget); QPalette naturalPalette = QApplication::palette(q); if (!q->testAttribute(Qt::WA_StyleSheet) - && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation) || (extra && extra->proxyWidget))) { + && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation) +#ifndef QT_NO_GRAPHICSVIEW + || (extra && extra->proxyWidget) +#endif //QT_NO_GRAPHICSVIEW + )) { if (QWidget *p = q->parentWidget()) { if (!p->testAttribute(Qt::WA_StyleSheet)) { if (!naturalPalette.isCopyOf(QApplication::palette())) { @@ -4392,13 +4399,14 @@ QPalette QWidgetPrivate::naturalWidgetPalette(uint inheritedMask) const naturalPalette = p->palette(); } } - } else if (extra && extra->proxyWidget) { + } #ifndef QT_NO_GRAPHICSVIEW + else if (extra && extra->proxyWidget) { QPalette inheritedPalette = extra->proxyWidget->palette(); inheritedPalette.resolve(inheritedMask); naturalPalette = inheritedPalette.resolve(naturalPalette); -#endif //QT_NO_GRAPHICSVIEW } +#endif //QT_NO_GRAPHICSVIEW } naturalPalette.resolve(0); return naturalPalette; @@ -4516,7 +4524,11 @@ QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const Q_Q(const QWidget); QFont naturalFont = QApplication::font(q); if (!q->testAttribute(Qt::WA_StyleSheet) - && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation) || (extra && extra->proxyWidget))) { + && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation) +#ifndef QT_NO_GRAPHICSVIEW + || (extra && extra->proxyWidget) +#endif //QT_NO_GRAPHICSVIEW + )) { if (QWidget *p = q->parentWidget()) { if (!p->testAttribute(Qt::WA_StyleSheet)) { if (!naturalFont.isCopyOf(QApplication::font())) { @@ -4527,13 +4539,14 @@ QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const naturalFont = p->font(); } } - } else if (extra && extra->proxyWidget) { + } #ifndef QT_NO_GRAPHICSVIEW + else if (extra && extra->proxyWidget) { QFont inheritedFont = extra->proxyWidget->font(); inheritedFont.resolve(inheritedMask); naturalFont = inheritedFont.resolve(naturalFont); -#endif //QT_NO_GRAPHICSVIEW } +#endif //QT_NO_GRAPHICSVIEW } naturalFont.resolve(0); return naturalFont; @@ -4580,12 +4593,13 @@ void QWidgetPrivate::updateFont(const QFont &font) data.fnt.x11SetScreen(xinfo.screen()); #endif // Combine new mask with natural mask and propagate to children. - if (!q->parentWidget() && extra && extra->proxyWidget) { #ifndef QT_NO_GRAPHICSVIEW + if (!q->parentWidget() && extra && extra->proxyWidget) { QGraphicsProxyWidget *p = extra->proxyWidget; inheritedFontResolveMask = p->d_func()->inheritedFontResolveMask | p->font().resolve(); + } else #endif //QT_NO_GRAPHICSVIEW - } else if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) { + if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) { inheritedFontResolveMask = 0; } uint newMask = data.fnt.resolve() | inheritedFontResolveMask; @@ -5396,7 +5410,11 @@ void QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *pdev, const QObjectLis , sharedPainter, backingStore); } - if (w->updatesEnabled() && (!w->d_func()->extra || !w->d_func()->extra->proxyWidget)) { + if (w->updatesEnabled() +#ifndef QT_NO_GRAPHICSVIEW + && (!w->d_func()->extra || !w->d_func()->extra->proxyWidget) +#endif //QT_NO_GRAPHICSVIEW + ) { QRegion wRegion(rgn); wRegion &= wd->effectiveRectFor(w->data->crect); wRegion.translate(-widgetPos); diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index 3cd1402..de97302 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -891,7 +891,7 @@ void QWidgetPrivate::moveRect(const QRect &rect, int dx, int dy) const QRect parentRect(rect & clipR); bool accelerateMove = accelEnv && isOpaque -#ifndef QT_NO_GRAPHICSCVIEW +#ifndef QT_NO_GRAPHICSVIEW // No accelerate move for proxy widgets. && !tlw->d_func()->extra->proxyWidget #endif @@ -1189,7 +1189,7 @@ void QWidgetBackingStore::sync() : wd->dirty); toClean += widgetDirty; -#ifndef QT_NO_GRAPHICSCVIEW +#ifndef QT_NO_GRAPHICSVIEW if (tlw->d_func()->extra->proxyWidget) { resetWidget(w); continue; diff --git a/src/gui/painting/qwindowsurface_qws.cpp b/src/gui/painting/qwindowsurface_qws.cpp index 4f489c4..fa0c80e 100644 --- a/src/gui/painting/qwindowsurface_qws.cpp +++ b/src/gui/painting/qwindowsurface_qws.cpp @@ -668,9 +668,11 @@ void QWSWindowSurface::flush(QWidget *widget, const QRegion ®ion, if (!win) return; +#ifndef QT_NO_GRAPHICSVIEW QWExtra *extra = win->d_func()->extra; if (extra && extra->proxyWidget) return; +#endif //QT_NO_GRAPHICSVIEW Q_UNUSED(offset); -- cgit v0.12 From 2f9c37c4b48c4b5005c89f1c5a5fa036e1e22811 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 29 Oct 2009 17:14:47 +0100 Subject: Avoid infinite loop when laying out text with unconvertible chars When the stringToCMap() fails, it can be because it did not have enough space in the layout, or it can because of other errors. In order to implement "try-again" processing in a simple way, we had an infinite loop which assumed that stringToCMap() would always succeed in the second run (which would be the case if the only possible error was "not enough space".) Since there are other possible failures not related to the number of glyphs, you could easily get into an infinite loop here, e.g. when laying out text that contains the Byte Order Mark. The fix changes the implementation to explictly try stringToCMap() twice at max, and is also how it's implemented in the default qtextengine.cpp. Task-number: QTBUG-4680 Reviewed-by: Trond --- src/gui/text/qtextengine_mac.cpp | 73 ++++++++++++++---------------- tests/auto/qtextlayout/tst_qtextlayout.cpp | 13 ++++++ 2 files changed, 48 insertions(+), 38 deletions(-) diff --git a/src/gui/text/qtextengine_mac.cpp b/src/gui/text/qtextengine_mac.cpp index eeccc72..54be53b 100644 --- a/src/gui/text/qtextengine_mac.cpp +++ b/src/gui/text/qtextengine_mac.cpp @@ -594,53 +594,50 @@ void QTextEngine::shapeTextMac(int item) const str = reinterpret_cast(uc); } - while (true) { - ensureSpace(num_glyphs); - num_glyphs = layoutData->glyphLayout.numGlyphs - layoutData->used; - - QGlyphLayout g = availableGlyphs(&si); - g.numGlyphs = num_glyphs; - unsigned short *log_clusters = logClusters(&si); + ensureSpace(num_glyphs); + num_glyphs = layoutData->glyphLayout.numGlyphs - layoutData->used; - if (fe->stringToCMap(str, - len, - &g, - &num_glyphs, - flags, - log_clusters, - attributes())) { + QGlyphLayout g = availableGlyphs(&si); + g.numGlyphs = num_glyphs; + unsigned short *log_clusters = logClusters(&si); - heuristicSetGlyphAttributes(str, len, &g, log_clusters, num_glyphs); - break; - } + bool stringToCMapFailed = false; + if (!fe->stringToCMap(str, len, &g, &num_glyphs, flags, log_clusters, attributes())) { + ensureSpace(num_glyphs); + stringToCMapFailed = fe->stringToCMap(str, len, &g, &num_glyphs, flags, log_clusters, + attributes()); } - si.num_glyphs = num_glyphs; + if (!stringToCMapFailed) { + heuristicSetGlyphAttributes(str, len, &g, log_clusters, num_glyphs); - layoutData->used += si.num_glyphs; + si.num_glyphs = num_glyphs; - QGlyphLayout g = shapedGlyphs(&si); + layoutData->used += si.num_glyphs; - if (si.analysis.script == QUnicodeTables::Arabic) { - QVarLengthArray props(len + 2); - QArabicProperties *properties = props.data(); - int f = si.position; - int l = len; - if (f > 0) { - --f; - ++l; - ++properties; - } - if (f + l < layoutData->string.length()) { - ++l; - } - qt_getArabicProperties((const unsigned short *)(layoutData->string.unicode()+f), l, props.data()); + QGlyphLayout g = shapedGlyphs(&si); - unsigned short *log_clusters = logClusters(&si); + if (si.analysis.script == QUnicodeTables::Arabic) { + QVarLengthArray props(len + 2); + QArabicProperties *properties = props.data(); + int f = si.position; + int l = len; + if (f > 0) { + --f; + ++l; + ++properties; + } + if (f + l < layoutData->string.length()) { + ++l; + } + qt_getArabicProperties((const unsigned short *)(layoutData->string.unicode()+f), l, props.data()); - for (int i = 0; i < len; ++i) { - int gpos = log_clusters[i]; - g.attributes[gpos].justification = properties[i].justification; + unsigned short *log_clusters = logClusters(&si); + + for (int i = 0; i < len; ++i) { + int gpos = log_clusters[i]; + g.attributes[gpos].justification = properties[i].justification; + } } } diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index fe87dfb..7c3f4f2 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -118,6 +118,7 @@ private slots: void smallTextLengthWordWrap(); void smallTextLengthWrapAtWordBoundaryOrAnywhere(); void testLineBreakingAllSpaces(); + void lineWidthFromBOM(); private: @@ -1306,6 +1307,18 @@ void tst_QTextLayout::columnWrapWithTabs() } +void tst_QTextLayout::lineWidthFromBOM() +{ + const QString string(QChar(0xfeff)); // BYTE ORDER MARK + QTextLayout layout(string); + layout.beginLayout(); + QTextLine line = layout.createLine(); + line.setLineWidth(INT_MAX / 256); + layout.endLayout(); + + // Don't spin into an infinite loop + } + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" -- cgit v0.12 From 4204fdcc04e20eabd19704f2235ba06afa84605e Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 29 Oct 2009 17:32:57 +0100 Subject: Avoid infinite loop when laying out text with unconvertible chars When the stringToCMap() fails, it can be because it did not have enough space in the layout, or it can because of other errors. In order to implement "try-again" processing in a simple way, we had an infinite loop which assumed that stringToCMap() would always succeed in the second run (which would be the case if the only possible error was "not enough space".) Since there are other possible failures not related to the number of glyphs, you could easily get into an infinite loop here, e.g. when laying out text that contains the Byte Order Mark. The fix changes the implementation to explictly try stringToCMap() twice at max, and is also how it's implemented in the default qtextengine.cpp. Task-number: QTBUG-4680 Reviewed-by: Trond Conflicts: src/gui/text/qtextengine_mac.cpp tests/auto/qtextlayout/tst_qtextlayout.cpp --- src/gui/text/qtextengine_mac.cpp | 77 ++++++++++++++---------------- tests/auto/qtextlayout/tst_qtextlayout.cpp | 14 ++++++ 2 files changed, 51 insertions(+), 40 deletions(-) diff --git a/src/gui/text/qtextengine_mac.cpp b/src/gui/text/qtextengine_mac.cpp index 4f20094..e35f9e0 100644 --- a/src/gui/text/qtextengine_mac.cpp +++ b/src/gui/text/qtextengine_mac.cpp @@ -595,53 +595,50 @@ void QTextEngine::shapeTextMac(int item) const str = reinterpret_cast(uc); } - while (true) { - ensureSpace(num_glyphs); - num_glyphs = layoutData->glyphLayout.numGlyphs - layoutData->used; - - QGlyphLayout g = availableGlyphs(&si); - g.numGlyphs = num_glyphs; - unsigned short *log_clusters = logClusters(&si); - - if (fe->stringToCMap(str, - len, - &g, - &num_glyphs, - flags, - log_clusters, - attributes())) { - - heuristicSetGlyphAttributes(str, len, &g, log_clusters, num_glyphs); - break; - } + ensureSpace(num_glyphs); + num_glyphs = layoutData->glyphLayout.numGlyphs - layoutData->used; + + QGlyphLayout g = availableGlyphs(&si); + g.numGlyphs = num_glyphs; + unsigned short *log_clusters = logClusters(&si); + + bool stringToCMapFailed = false; + if (!fe->stringToCMap(str, len, &g, &num_glyphs, flags, log_clusters, attributes())) { + ensureSpace(num_glyphs); + stringToCMapFailed = fe->stringToCMap(str, len, &g, &num_glyphs, flags, log_clusters, + attributes()); } - si.num_glyphs = num_glyphs; + if (!stringToCMapFailed) { + heuristicSetGlyphAttributes(str, len, &g, log_clusters, num_glyphs); - layoutData->used += si.num_glyphs; + si.num_glyphs = num_glyphs; - QGlyphLayout g = shapedGlyphs(&si); + layoutData->used += si.num_glyphs; - if (si.analysis.script == QUnicodeTables::Arabic) { - QVarLengthArray props(len + 2); - QArabicProperties *properties = props.data(); - int f = si.position; - int l = len; - if (f > 0) { - --f; - ++l; - ++properties; - } - if (f + l < layoutData->string.length()) { - ++l; - } - qt_getArabicProperties((const unsigned short *)(layoutData->string.unicode()+f), l, props.data()); + QGlyphLayout g = shapedGlyphs(&si); - unsigned short *log_clusters = logClusters(&si); + if (si.analysis.script == QUnicodeTables::Arabic) { + QVarLengthArray props(len + 2); + QArabicProperties *properties = props.data(); + int f = si.position; + int l = len; + if (f > 0) { + --f; + ++l; + ++properties; + } + if (f + l < layoutData->string.length()) { + ++l; + } + qt_getArabicProperties((const unsigned short *)(layoutData->string.unicode()+f), l, props.data()); - for (int i = 0; i < len; ++i) { - int gpos = log_clusters[i]; - g.attributes[gpos].justification = properties[i].justification; + unsigned short *log_clusters = logClusters(&si); + + for (int i = 0; i < len; ++i) { + int gpos = log_clusters[i]; + g.attributes[gpos].justification = properties[i].justification; + } } } diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index a5fed4e..b02a704 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -119,6 +119,7 @@ private slots: void smallTextLengthWordWrap(); void smallTextLengthWrapAtWordBoundaryOrAnywhere(); void testLineBreakingAllSpaces(); + void lineWidthFromBOM(); private: @@ -1277,5 +1278,18 @@ void tst_QTextLayout::widthOfTabs() QCOMPARE(qRound(engine.width(0, 5)), qRound(engine.boundingBox(0, 5).width)); } +void tst_QTextLayout::lineWidthFromBOM() +{ + const QString string(QChar(0xfeff)); // BYTE ORDER MARK + QTextLayout layout(string); + layout.beginLayout(); + QTextLine line = layout.createLine(); + line.setLineWidth(INT_MAX / 256); + layout.endLayout(); + + // Don't spin into an infinite loop + } + + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" -- cgit v0.12 From 5641bd0cdd9c90427d7d976473b894c530cdb715 Mon Sep 17 00:00:00 2001 From: kh1 Date: Thu, 29 Oct 2009 17:51:24 +0100 Subject: Fix wrong version number in Assistant internal help. Task-number: QT-1522 Reviewed-by: kh --- tools/assistant/tools/assistant/assistant.qch | Bin 368640 -> 364544 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/tools/assistant/tools/assistant/assistant.qch b/tools/assistant/tools/assistant/assistant.qch index 3e66bd9..78fe9f3 100644 Binary files a/tools/assistant/tools/assistant/assistant.qch and b/tools/assistant/tools/assistant/assistant.qch differ -- cgit v0.12 From 9e01ced1d14467c06d7e1db57982556c9e861372 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 29 Oct 2009 18:07:06 +0100 Subject: Remove the posix_memalign and Win32 _aligned_malloc MinGW doesn't have _aligned_malloc and posix_memalign doesn't have a realloc function. So use our own implementation in all platforms. Removing posix_memalign was reviewed by Brad, but I apparently lost the commit. Reviewed-by: Trust Me --- src/corelib/global/qmalloc.cpp | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp index 3584c50..4aab1bd 100644 --- a/src/corelib/global/qmalloc.cpp +++ b/src/corelib/global/qmalloc.cpp @@ -43,10 +43,6 @@ #include -#ifdef Q_OS_WIN -# include -#endif - /* Define the container allocation functions in a separate file, so that our users can easily override them. @@ -71,38 +67,11 @@ void *qRealloc(void *ptr, size_t size) void *qMallocAligned(size_t size, size_t alignment) { -#if defined(Q_OS_WIN) - return _aligned_malloc(size, alignment); -#elif defined(HAVE_POSIX_MEMALIGN) - if (alignment <= sizeof(void*)) - return qMalloc(size); - - // we have posix_memalign - void *ptr = 0; - if (posix_memalign(&ptr, alignment, size) == 0) - return ptr; - return 0; -#else return qReallocAligned(0, size, 0, alignment); -#endif } void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t alignment) { -#if defined(Q_OS_WIN) - Q_UNUSED(oldsize); - return _aligned_realloc(oldptr, newsize, alignment); -#elif defined(HAVE_POSIX_MEMALIGN) - if (alignment <= sizeof(void*)) - return qRealloc(oldptr, newsize); - - void *newptr = qMallocAligned(newsize, alignment); - if (!newptr) - return 0; - qMemCopy(newptr, oldptr, qMin(oldsize, newsize)); - qFree(oldptr); - return newptr; -#else // fake an aligned allocation Q_UNUSED(oldsize); @@ -144,21 +113,14 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align faked.pptr[-1] = real.ptr; return faked.ptr; -#endif } void qFreeAligned(void *ptr) { -#if defined(Q_OS_WIN) - _aligned_free(ptr); -#elif defined(HAVE_POSIX_MEMALIGN) - ::free(ptr); -#else if (!ptr) return; void **ptr2 = static_cast(ptr); free(ptr2[-1]); -#endif } QT_END_NAMESPACE -- cgit v0.12 From 6f602c01b9dc2b037cb42cacfe1c2df6e092a6b4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 29 Oct 2009 18:13:21 +0100 Subject: Autotest: this test is failing, enable debugging to find out why. It doesn't happen on my machine, so I need to figure out what's different. Reviewed-by: Trust Me --- tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp index d84350b..91050f5 100644 --- a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp +++ b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp @@ -132,6 +132,9 @@ tst_QDBusAbstractInterface::tst_QDBusAbstractInterface() void tst_QDBusAbstractInterface::initTestCase() { + // enable debugging temporarily: + putenv("QDBUS_DEBUG=1"); + // register the object QDBusConnection con = QDBusConnection::sessionBus(); QVERIFY(con.isConnected()); @@ -469,7 +472,7 @@ void tst_QDBusAbstractInterface::followSignal() QVERIFY(!QTestEventLoop::instance().timeout()); // now the signal must have been received: - QVERIFY(s.size() == 1); + QCOMPARE(s.size(), 1); QVERIFY(s.at(0).size() == 0); s.clear(); -- cgit v0.12 From 764d195bfa252775702bffc93989a35d0c19f035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 29 Oct 2009 15:32:03 +0100 Subject: Turns out 64-bit fseek/ftell are not available on VS 2003/2002... Not when linking dynamically to the CRT (/MT). So we can't rely on them. The declarations for those are also not on the standard headers. Reverts "(MSVC 2002/2003) Use 64-bit versions of ftell and fseek", fixes return type of QT_FTELL and skips known failures on large-file test case. --- mkspecs/win32-msvc.net/qplatformdefs.h | 6 ++++-- tests/auto/qfile/largefile/tst_largefile.cpp | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mkspecs/win32-msvc.net/qplatformdefs.h b/mkspecs/win32-msvc.net/qplatformdefs.h index e3e287e..da092fa 100644 --- a/mkspecs/win32-msvc.net/qplatformdefs.h +++ b/mkspecs/win32-msvc.net/qplatformdefs.h @@ -115,8 +115,10 @@ #define QT_FOPEN ::fopen #ifdef QT_LARGEFILE_SUPPORT -#define QT_FSEEK ::_fseeki64 -#define QT_FTELL ::_ftelli64 +// 64-bit versions of fseek/ftell not always available. E.g., when linking +// dynamically to CRT (/MT) +#define QT_FSEEK ::fseek +#define QT_FTELL (QT_OFF_T)::ftell #else #define QT_FSEEK ::fseek #define QT_FTELL ::ftell diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp index d2bbffe..53dbc12 100644 --- a/tests/auto/qfile/largefile/tst_largefile.cpp +++ b/tests/auto/qfile/largefile/tst_largefile.cpp @@ -402,6 +402,11 @@ void tst_LargeFile::streamPositioning() { QFETCH( qint64, position ); +#if defined(QT_LARGEFILE_SUPPORT) && defined(Q_CC_MSVC) && _MSC_VER < 1400 + if (position >= (qint64)1 << 31) + QSKIP("MSVC 2003 doesn't have 64 bit versions of fseek/ftell.", SkipSingle); +#endif + stream_ = QT_FOPEN("qt_largefile.tmp", "rb"); QVERIFY( 0 != stream_ ); -- cgit v0.12 From 27c99302d0b44c6e9cd0eda6ba888b6a6f5bea38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 29 Oct 2009 18:50:55 +0100 Subject: Get rid of QPainter warnings generated from QGraphicsOpacityEffect. Problem was that we painted on null pixmap. We also want to use the pixmap cache (QGraphicsEffectSource::pixmap()) to improve performance. Reported by Andrew Baldwin's performance team. --- src/gui/effects/qgraphicseffect.cpp | 69 +++++++++++-------------------------- 1 file changed, 20 insertions(+), 49 deletions(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 96d35b0..969b6b5 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -1235,64 +1235,35 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour return; } - painter->save(); - painter->setOpacity(d->opacity); QPoint offset; - if (source->isPixmap()) { - // No point in drawing in device coordinates (pixmap will be scaled anyways). - if (!d->hasOpacityMask) { - const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset); - painter->drawPixmap(offset, pixmap); - } else { - QRect srcBrect = source->boundingRect().toAlignedRect(); - offset = srcBrect.topLeft(); - QPixmap pixmap(srcBrect.size()); - pixmap.fill(Qt::transparent); + Qt::CoordinateSystem system = source->isPixmap() ? Qt::LogicalCoordinates : Qt::DeviceCoordinates; + QPixmap pixmap = source->pixmap(system, &offset); + if (pixmap.isNull()) + return; - QPainter pixmapPainter(&pixmap); - pixmapPainter.setRenderHints(painter->renderHints()); - pixmapPainter.translate(-offset); - source->draw(&pixmapPainter); - pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn); - pixmapPainter.fillRect(srcBrect, d->opacityMask); - pixmapPainter.end(); + painter->save(); + painter->setOpacity(d->opacity); - painter->drawPixmap(offset, pixmap); - } - } else { - // Draw pixmap in device coordinates to avoid pixmap scaling; - if (!d->hasOpacityMask) { - const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); - painter->setWorldTransform(QTransform()); - painter->drawPixmap(offset, pixmap); - } else { + if (d->hasOpacityMask) { + QPainter pixmapPainter(&pixmap); + pixmapPainter.setRenderHints(painter->renderHints()); + pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn); + if (system == Qt::DeviceCoordinates) { QTransform worldTransform = painter->worldTransform(); - - // Calculate source bounding rect in logical and device coordinates. - QRectF srcBrect = source->boundingRect(); - QRect srcDeviceBrect = worldTransform.mapRect(srcBrect).toAlignedRect(); - srcDeviceBrect &= source->deviceRect(); - - offset = srcDeviceBrect.topLeft(); - worldTransform *= QTransform::fromTranslate(-srcDeviceBrect.x(), -srcDeviceBrect.y()); - - QPixmap pixmap(srcDeviceBrect.size()); - pixmap.fill(Qt::transparent); - - QPainter pixmapPainter(&pixmap); - pixmapPainter.setRenderHints(painter->renderHints()); + worldTransform *= QTransform::fromTranslate(-offset.x(), -offset.y()); pixmapPainter.setWorldTransform(worldTransform); - source->draw(&pixmapPainter); - pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn); - pixmapPainter.fillRect(srcBrect, d->opacityMask); - pixmapPainter.end(); - - painter->setWorldTransform(QTransform()); - painter->drawPixmap(offset, pixmap); + pixmapPainter.fillRect(source->boundingRect(), d->opacityMask); + } else { + pixmapPainter.translate(-offset); + pixmapPainter.fillRect(pixmap.rect(), d->opacityMask); } } + if (system == Qt::DeviceCoordinates) + painter->setWorldTransform(QTransform()); + + painter->drawPixmap(offset, pixmap); painter->restore(); } -- cgit v0.12 From f5589e3b4d352b9b8d9fd54e974d548713e7b640 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 30 Oct 2009 13:37:18 +1000 Subject: Make it possible to set the OpenVG swap interval The QT_VG_SWAP_INTERVAL environment variable can be used to specify a value for eglSwapInterval(). Task-number: QT-2409 Reviewed-by: trustme --- src/openvg/qwindowsurface_vgegl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp index 103f84d..29d82c8 100644 --- a/src/openvg/qwindowsurface_vgegl.cpp +++ b/src/openvg/qwindowsurface_vgegl.cpp @@ -193,6 +193,13 @@ static QEglContext *createContext(QPaintDevice *device) return 0; } + // Set the swap interval for the display. + QByteArray interval = qgetenv("QT_VG_SWAP_INTERVAL"); + if (!interval.isEmpty()) + eglSwapInterval(context->display(), interval.toInt()); + else + eglSwapInterval(context->display(), 1); + // Choose an appropriate configuration for rendering into the device. QEglProperties configProps; configProps.setPaintDeviceFormat(device); -- cgit v0.12 From 2833d72c3d0e67317b9aba3de59f0e90317ecb12 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 30 Oct 2009 15:08:36 +1000 Subject: Remove drawCursorImage() from the OpenVG composition helper The drawCursorPixmap() function is more efficient and can render the QImage form of the QPixmap directly if necessary. Reviewed-by: trustme --- src/openvg/qpaintengine_vg.cpp | 69 ++++++++++++++++++------------------- src/openvg/qvgcompositionhelper_p.h | 1 - 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 94e0793..8a485a0 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -3574,51 +3574,48 @@ void QVGCompositionHelper::fillBackground } } -void QVGCompositionHelper::drawCursorImage - (const QImage& image, const QPoint& offset) +void QVGCompositionHelper::drawCursorPixmap + (const QPixmap& pixmap, const QPoint& offset) { - QImage img = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); + VGImage vgImage = VG_INVALID_HANDLE; - VGImage vgImg = vgCreateImage - (VG_sARGB_8888_PRE, img.width(), img.height(), - VG_IMAGE_QUALITY_FASTER); - vgImageSubData - (vgImg, img.bits() + img.bytesPerLine() * (img.height() - 1), - -(img.bytesPerLine()), VG_sARGB_8888_PRE, 0, 0, - img.width(), img.height()); + // Fetch the VGImage from the pixmap if possible. + QPixmapData *pd = pixmap.pixmapData(); + if (pd->classId() == QPixmapData::OpenVGClass) { + QVGPixmapData *vgpd = static_cast(pd); + if (vgpd->isValid()) + vgImage = vgpd->toVGImage(); + } - QTransform transform; - int y = screenSize.height() - (offset.y() + img.height()); - transform.translate(offset.x() + 0.5f, y + 0.5f); + // Set the image transformation and modes. + VGfloat devh = screenSize.height() - 1; + QTransform transform(1.0f, 0.0f, 0.0f, + 0.0f, -1.0f, 0.0f, + -0.5f, devh + 0.5f, 1.0f); + transform.translate(offset.x(), offset.y()); d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform); - d->setImageMode(VG_DRAW_IMAGE_NORMAL); - vgDrawImage(vgImg); - vgDestroyImage(vgImg); -} + // Draw the VGImage. + if (vgImage != VG_INVALID_HANDLE) { + vgDrawImage(vgImage); + } else { + QImage img = pixmap.toImage().convertToFormat + (QImage::Format_ARGB32_Premultiplied); -void QVGCompositionHelper::drawCursorPixmap - (const QPixmap& pixmap, const QPoint& offset) -{ - QPixmapData *pd = pixmap.pixmapData(); - if (pd->classId() == QPixmapData::OpenVGClass) { - QVGPixmapData *vgpd = static_cast(pd); - if (vgpd->isValid()) { - VGfloat devh = screenSize.height() - 1; - QTransform transform(1.0f, 0.0f, 0.0f, - 0.0f, -1.0f, 0.0f, - -0.5f, devh + 0.5f, 1.0f); - transform.translate(offset.x(), offset.y()); - d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform); - - d->setImageMode(VG_DRAW_IMAGE_NORMAL); - vgDrawImage(vgpd->toVGImage()); + vgImage = vgCreateImage + (VG_sARGB_8888_PRE, img.width(), img.height(), + VG_IMAGE_QUALITY_FASTER); + if (vgImage == VG_INVALID_HANDLE) return; - } - } + vgImageSubData + (vgImage, img.bits() + img.bytesPerLine() * (img.height() - 1), + -(img.bytesPerLine()), VG_sARGB_8888_PRE, 0, 0, + img.width(), img.height()); - drawCursorImage(pixmap.toImage(), offset); + vgDrawImage(vgImage); + vgDestroyImage(vgImage); + } } void QVGCompositionHelper::setScissor(const QRegion& region) diff --git a/src/openvg/qvgcompositionhelper_p.h b/src/openvg/qvgcompositionhelper_p.h index 6317c3f..3afe31e 100644 --- a/src/openvg/qvgcompositionhelper_p.h +++ b/src/openvg/qvgcompositionhelper_p.h @@ -74,7 +74,6 @@ public: void blitWindow(QVGEGLWindowSurfacePrivate *surface, const QRect& rect, const QPoint& topLeft, int opacity); void fillBackground(const QRegion& region, const QBrush& brush); - void drawCursorImage(const QImage& image, const QPoint& offset); void drawCursorPixmap(const QPixmap& pixmap, const QPoint& offset); void setScissor(const QRegion& region); void clearScissor(); -- cgit v0.12 From a9f7e08ab08ce25413b85272526907f7347e6fe3 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 30 Oct 2009 15:13:18 +1000 Subject: OpenVG pixmap filter classes don't need to be exported. Reviewed-by: trustme --- src/openvg/qpixmapfilter_vg_p.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/openvg/qpixmapfilter_vg_p.h b/src/openvg/qpixmapfilter_vg_p.h index efbbc7b..29dd37e 100644 --- a/src/openvg/qpixmapfilter_vg_p.h +++ b/src/openvg/qpixmapfilter_vg_p.h @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE #if !defined(QT_SHIVAVG) -class Q_OPENVG_EXPORT QVGPixmapConvolutionFilter : public QPixmapConvolutionFilter +class QVGPixmapConvolutionFilter : public QPixmapConvolutionFilter { Q_OBJECT public: @@ -71,7 +71,7 @@ public: void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const; }; -class Q_OPENVG_EXPORT QVGPixmapColorizeFilter : public QPixmapColorizeFilter +class QVGPixmapColorizeFilter : public QPixmapColorizeFilter { Q_OBJECT public: @@ -81,7 +81,7 @@ public: void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const; }; -class Q_OPENVG_EXPORT QVGPixmapDropShadowFilter : public QPixmapDropShadowFilter +class QVGPixmapDropShadowFilter : public QPixmapDropShadowFilter { Q_OBJECT public: @@ -91,7 +91,7 @@ public: void draw(QPainter *p, const QPointF &pos, const QPixmap &px, const QRectF &src) const; }; -class Q_OPENVG_EXPORT QVGPixmapBlurFilter : public QPixmapBlurFilter +class QVGPixmapBlurFilter : public QPixmapBlurFilter { Q_OBJECT public: -- cgit v0.12 From 83fff2f970b9a7b41861336c7dca0eadbda28099 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 29 Oct 2009 15:28:02 +0100 Subject: Introduce internal StateType to avoid excessive qobject_casts The state machine algorithm frequently needs to know what type a state is, e.g. if it is atomic, final or a history state. We were using qobject_cast() to determine this, but that function is expensive. This commit introduces an internal StateType to be able to differentiate between the different types of state. This vastly improves performance. Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/corelib/statemachine/qabstractstate.cpp | 11 +++-- src/corelib/statemachine/qabstractstate_p.h | 12 ++++- src/corelib/statemachine/qfinalstate.cpp | 1 + src/corelib/statemachine/qhistorystate.cpp | 3 +- src/corelib/statemachine/qstate.cpp | 3 +- src/corelib/statemachine/qstatemachine.cpp | 68 +++++++++++++++++++++-------- src/corelib/statemachine/qstatemachine_p.h | 7 +++ 7 files changed, 80 insertions(+), 25 deletions(-) diff --git a/src/corelib/statemachine/qabstractstate.cpp b/src/corelib/statemachine/qabstractstate.cpp index cf67cdd..ec5332f 100644 --- a/src/corelib/statemachine/qabstractstate.cpp +++ b/src/corelib/statemachine/qabstractstate.cpp @@ -78,8 +78,8 @@ QT_BEGIN_NAMESPACE function to perform custom processing when the state is exited. */ -QAbstractStatePrivate::QAbstractStatePrivate() - : parentState(0) +QAbstractStatePrivate::QAbstractStatePrivate(StateType type) + : stateType(type), isMachine(false), parentState(0) { } @@ -88,6 +88,11 @@ QAbstractStatePrivate *QAbstractStatePrivate::get(QAbstractState *q) return q->d_func(); } +const QAbstractStatePrivate *QAbstractStatePrivate::get(const QAbstractState *q) +{ + return q->d_func(); +} + QStateMachine *QAbstractStatePrivate::machine() const { QObject *par = parent; @@ -127,7 +132,7 @@ void QAbstractStatePrivate::emitExited() Constructs a new state with the given \a parent state. */ QAbstractState::QAbstractState(QState *parent) - : QObject(*new QAbstractStatePrivate, parent) + : QObject(*new QAbstractStatePrivate(QAbstractStatePrivate::AbstractState), parent) { } diff --git a/src/corelib/statemachine/qabstractstate_p.h b/src/corelib/statemachine/qabstractstate_p.h index cd57815..faea6b6 100644 --- a/src/corelib/statemachine/qabstractstate_p.h +++ b/src/corelib/statemachine/qabstractstate_p.h @@ -65,9 +65,17 @@ class QAbstractStatePrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QAbstractState) public: - QAbstractStatePrivate(); + enum StateType { + AbstractState, + StandardState, + FinalState, + HistoryState + }; + + QAbstractStatePrivate(StateType type); static QAbstractStatePrivate *get(QAbstractState *q); + static const QAbstractStatePrivate *get(const QAbstractState *q); QStateMachine *machine() const; @@ -77,6 +85,8 @@ public: void emitEntered(); void emitExited(); + uint stateType:31; + uint isMachine:1; mutable QState *parentState; }; diff --git a/src/corelib/statemachine/qfinalstate.cpp b/src/corelib/statemachine/qfinalstate.cpp index 761eee4..d900ddd 100644 --- a/src/corelib/statemachine/qfinalstate.cpp +++ b/src/corelib/statemachine/qfinalstate.cpp @@ -92,6 +92,7 @@ public: }; QFinalStatePrivate::QFinalStatePrivate() + : QAbstractStatePrivate(FinalState) { } diff --git a/src/corelib/statemachine/qhistorystate.cpp b/src/corelib/statemachine/qhistorystate.cpp index 0c2b858..18436d3 100644 --- a/src/corelib/statemachine/qhistorystate.cpp +++ b/src/corelib/statemachine/qhistorystate.cpp @@ -120,7 +120,8 @@ QT_BEGIN_NAMESPACE */ QHistoryStatePrivate::QHistoryStatePrivate() - : defaultState(0), historyType(QHistoryState::ShallowHistory) + : QAbstractStatePrivate(HistoryState), + defaultState(0), historyType(QHistoryState::ShallowHistory) { } diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp index bcd8364..5dc310b 100644 --- a/src/corelib/statemachine/qstate.cpp +++ b/src/corelib/statemachine/qstate.cpp @@ -124,7 +124,8 @@ QT_BEGIN_NAMESPACE */ QStatePrivate::QStatePrivate() - : errorState(0), initialState(0), childMode(QState::ExclusiveStates), + : QAbstractStatePrivate(StandardState), + errorState(0), initialState(0), childMode(QState::ExclusiveStates), childStatesListNeedsRefresh(true), transitionsListNeedsRefresh(true) { } diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 689967a..ea5587e 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -178,6 +178,8 @@ QT_BEGIN_NAMESPACE QStateMachinePrivate::QStateMachinePrivate() { + QAbstractStatePrivate::isMachine = true; + state = NotRunning; _startState = 0; processing = false; @@ -336,7 +338,7 @@ QSet QStateMachinePrivate::selectTransitions(QEvent *event if (isPreempted(state, enabledTransitions)) continue; QList lst = properAncestors(state, rootState()->parentState()); - if (QState *grp = qobject_cast(state)) + if (QState *grp = toStandardState(state)) lst.prepend(grp); bool found = false; for (int j = 0; (j < lst.size()) && !found; ++j) { @@ -414,7 +416,7 @@ QList QStateMachinePrivate::exitStates(QEvent *event, const QLi qSort(statesToExit_sorted.begin(), statesToExit_sorted.end(), stateExitLessThan); for (int i = 0; i < statesToExit_sorted.size(); ++i) { QAbstractState *s = statesToExit_sorted.at(i); - if (QState *grp = qobject_cast(s)) { + if (QState *grp = toStandardState(s)) { QList hlst = QStatePrivate::get(grp)->historyStates(); for (int j = 0; j < hlst.size(); ++j) { QHistoryState *h = hlst.at(j); @@ -563,7 +565,7 @@ void QStateMachinePrivate::addStatesToEnter(QAbstractState *s, QState *root, QSet &statesToEnter, QSet &statesForDefaultEntry) { - if (QHistoryState *h = qobject_cast(s)) { + if (QHistoryState *h = toHistoryState(s)) { QList hconf = QHistoryStatePrivate::get(h)->configuration; if (!hconf.isEmpty()) { for (int k = 0; k < hconf.size(); ++k) { @@ -600,7 +602,7 @@ void QStateMachinePrivate::addStatesToEnter(QAbstractState *s, QState *root, } statesToEnter.insert(s); if (isParallel(s)) { - QState *grp = qobject_cast(s); + QState *grp = toStandardState(s); QList lst = QStatePrivate::get(grp)->childStates(); for (int i = 0; i < lst.size(); ++i) { QAbstractState *child = lst.at(i); @@ -608,7 +610,7 @@ void QStateMachinePrivate::addStatesToEnter(QAbstractState *s, QState *root, } } else if (isCompound(s)) { statesForDefaultEntry.insert(s); - QState *grp = qobject_cast(s); + QState *grp = toStandardState(s); QAbstractState *initial = grp->initialState(); if (initial != 0) { Q_ASSERT(initial->machine() == q_func()); @@ -660,7 +662,7 @@ void QStateMachinePrivate::applyProperties(const QList &tr QHash > propertyAssignmentsForState; QHash pendingRestorables = registeredRestorables; for (int i = 0; i < enteredStates.size(); ++i) { - QState *s = qobject_cast(enteredStates.at(i)); + QState *s = toStandardState(enteredStates.at(i)); if (!s) continue; @@ -831,7 +833,7 @@ void QStateMachinePrivate::applyProperties(const QList &tr // Emit polished signal for entered states that have no animated properties. for (int i = 0; i < enteredStates.size(); ++i) { - QState *s = qobject_cast(enteredStates.at(i)); + QState *s = toStandardState(enteredStates.at(i)); if (s #ifndef QT_NO_ANIMATION && !animationsForState.contains(s) @@ -845,21 +847,21 @@ void QStateMachinePrivate::applyProperties(const QList &tr bool QStateMachinePrivate::isFinal(const QAbstractState *s) { - return qobject_cast(s) != 0; + return s && (QAbstractStatePrivate::get(s)->stateType == QAbstractStatePrivate::FinalState); } bool QStateMachinePrivate::isParallel(const QAbstractState *s) { - const QState *ss = qobject_cast(s); + const QState *ss = toStandardState(s); return ss && (QStatePrivate::get(ss)->childMode == QState::ParallelStates); } bool QStateMachinePrivate::isCompound(const QAbstractState *s) const { - const QState *group = qobject_cast(s); + const QState *group = toStandardState(s); if (!group) return false; - bool isMachine = (qobject_cast(group) != 0); + bool isMachine = QStatePrivate::get(group)->isMachine; // Don't treat the machine as compound if it's a sub-state of this machine if (isMachine && (group != rootState())) return false; @@ -869,11 +871,11 @@ bool QStateMachinePrivate::isCompound(const QAbstractState *s) const bool QStateMachinePrivate::isAtomic(const QAbstractState *s) const { - const QState *ss = qobject_cast(s); + const QState *ss = toStandardState(s); return (ss && QStatePrivate::get(ss)->childStates().isEmpty()) || isFinal(s) // Treat the machine as atomic if it's a sub-state of this machine - || (ss && (qobject_cast(ss) != 0) && (ss != rootState())); + || (ss && QStatePrivate::get(ss)->isMachine && (ss != rootState())); } @@ -897,10 +899,38 @@ QList QStateMachinePrivate::properAncestors(const QAbstractState *state return result; } +QState *QStateMachinePrivate::toStandardState(QAbstractState *state) +{ + if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::StandardState)) + return static_cast(state); + return 0; +} + +const QState *QStateMachinePrivate::toStandardState(const QAbstractState *state) +{ + if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::StandardState)) + return static_cast(state); + return 0; +} + +QFinalState *QStateMachinePrivate::toFinalState(QAbstractState *state) +{ + if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::FinalState)) + return static_cast(state); + return 0; +} + +QHistoryState *QStateMachinePrivate::toHistoryState(QAbstractState *state) +{ + if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::HistoryState)) + return static_cast(state); + return 0; +} + bool QStateMachinePrivate::isInFinalState(QAbstractState* s) const { if (isCompound(s)) { - QState *grp = qobject_cast(s); + QState *grp = toStandardState(s); QList lst = QStatePrivate::get(grp)->childStates(); for (int i = 0; i < lst.size(); ++i) { QAbstractState *cs = lst.at(i); @@ -909,7 +939,7 @@ bool QStateMachinePrivate::isInFinalState(QAbstractState* s) const } return false; } else if (isParallel(s)) { - QState *grp = qobject_cast(s); + QState *grp = toStandardState(s); QList lst = QStatePrivate::get(grp)->childStates(); for (int i = 0; i < lst.size(); ++i) { QAbstractState *cs = lst.at(i); @@ -975,7 +1005,7 @@ QAbstractState *QStateMachinePrivate::findErrorState(QAbstractState *context) // Find error state recursively in parent hierarchy if not set explicitly for context state QAbstractState *errorState = 0; if (context != 0) { - QState *s = qobject_cast(context); + QState *s = toStandardState(context); if (s != 0) errorState = s->errorState(); @@ -1100,7 +1130,7 @@ void QStateMachinePrivate::_q_animationFinished() animations.removeOne(anim); if (animations.isEmpty()) { animationsForState.erase(it); - QStatePrivate::get(qobject_cast(state))->emitPolished(); + QStatePrivate::get(toStandardState(state))->emitPolished(); } } @@ -1388,7 +1418,7 @@ void QStateMachinePrivate::goToState(QAbstractState *targetState) if (state == Running) { QSet::const_iterator it; for (it = configuration.constBegin(); it != configuration.constEnd(); ++it) { - sourceState = qobject_cast(*it); + sourceState = toStandardState(*it); if (sourceState != 0) break; } @@ -1412,7 +1442,7 @@ void QStateMachinePrivate::goToState(QAbstractState *targetState) void QStateMachinePrivate::registerTransitions(QAbstractState *state) { - QState *group = qobject_cast(state); + QState *group = toStandardState(state); if (!group) return; QList transitions = QStatePrivate::get(group)->transitions(); diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index 69b727d..01c9361 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -73,6 +73,8 @@ class QSignalEventGenerator; class QSignalTransition; class QAbstractState; class QAbstractTransition; +class QFinalState; +class QHistoryState; class QState; #ifndef QT_NO_ANIMATION @@ -138,6 +140,11 @@ public: const QList &exitedStates, const QList &enteredStates); + static QState *toStandardState(QAbstractState *state); + static const QState *toStandardState(const QAbstractState *state); + static QFinalState *toFinalState(QAbstractState *state); + static QHistoryState *toHistoryState(QAbstractState *state); + bool isInFinalState(QAbstractState *s) const; static bool isFinal(const QAbstractState *s); static bool isParallel(const QAbstractState *s); -- cgit v0.12 From 79eef278228aac21fbf8b21eaa337f2922bc68c1 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 28 Oct 2009 13:49:19 +0100 Subject: Lazily construct QPixmapData's for null pixmaps Reviewed-by: Trond --- src/gui/image/qpixmap.cpp | 64 +++++++++++++++++++++++++------------------ src/gui/image/qpixmap_mac.cpp | 3 ++ src/gui/image/qpixmap_qws.cpp | 8 +++--- src/gui/image/qpixmap_s60.cpp | 13 +++++---- src/gui/image/qpixmap_win.cpp | 3 ++ src/gui/image/qpixmap_x11.cpp | 7 +++-- src/gui/image/qpixmapdata.cpp | 13 +++++++++ src/gui/image/qpixmapdata_p.h | 2 ++ 8 files changed, 75 insertions(+), 38 deletions(-) diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 45ff5f4..c452b9a 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -113,13 +113,10 @@ void QPixmap::init(int w, int h, Type type) void QPixmap::init(int w, int h, int type) { - QGraphicsSystem* gs = QApplicationPrivate::graphicsSystem(); - if (gs) - data = gs->createPixmapData(static_cast(type)); + if ((w > 0 && h > 0) || type == QPixmapData::BitmapType) + data = QPixmapData::create(w, h, (QPixmapData::PixelType) type); else - data = QGraphicsSystem::createDefaultPixmapData(static_cast(type)); - - data->resize(w, h); + data = 0; } /*! @@ -307,7 +304,7 @@ QPixmap::QPixmap(const char * const xpm[]) QImage image(xpm); if (!image.isNull()) { - if (data->pixelType() == QPixmapData::BitmapType) + if (data && data->pixelType() == QPixmapData::BitmapType) *this = QBitmap::fromImage(image); else *this = fromImage(image); @@ -322,8 +319,8 @@ QPixmap::QPixmap(const char * const xpm[]) QPixmap::~QPixmap() { - Q_ASSERT(data->ref >= 1); // Catch if ref-counting changes again - if (data->is_cached && data->ref == 1) // ref will be decrememnted after destructor returns + Q_ASSERT(!data || data->ref >= 1); // Catch if ref-counting changes again + if (data && data->is_cached && data->ref == 1) // ref will be decrememnted after destructor returns QImagePixmapCleanupHooks::executePixmapDestructionHooks(this); } @@ -544,7 +541,7 @@ bool QPixmap::isQBitmap() const */ bool QPixmap::isNull() const { - return data->isNull(); + return !data || data->isNull(); } /*! @@ -556,7 +553,7 @@ bool QPixmap::isNull() const */ int QPixmap::width() const { - return data->width(); + return data ? data->width() : 0; } /*! @@ -568,7 +565,7 @@ int QPixmap::width() const */ int QPixmap::height() const { - return data->height(); + return data ? data->height() : 0; } /*! @@ -581,7 +578,7 @@ int QPixmap::height() const */ QSize QPixmap::size() const { - return QSize(data->width(), data->height()); + return data ? QSize(data->width(), data->height()) : QSize(); } /*! @@ -593,7 +590,7 @@ QSize QPixmap::size() const */ QRect QPixmap::rect() const { - return QRect(0, 0, data->width(), data->height()); + return data ? QRect(0, 0, data->width(), data->height()) : QRect(); } /*! @@ -609,7 +606,7 @@ QRect QPixmap::rect() const */ int QPixmap::depth() const { - return data->depth(); + return data ? data->depth() : 0; } /*! @@ -639,7 +636,7 @@ void QPixmap::resize_helper(const QSize &s) return; // Create new pixmap - QPixmap pm(QSize(w, h), data->type); + QPixmap pm(QSize(w, h), data ? data->type : QPixmapData::PixmapType); bool uninit = false; #if defined(Q_WS_X11) QX11PixmapData *x11Data = data->classId() == QPixmapData::X11Class ? static_cast(data.data()) : 0; @@ -728,6 +725,9 @@ void QPixmap::setMask(const QBitmap &mask) return; } + if (isNull()) + return; + if (static_cast(mask).data == data) // trying to selfmask return; @@ -826,11 +826,14 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers QFileInfo info(fileName); QString key = QLatin1String("qt_pixmap_") + info.absoluteFilePath() + QLatin1Char('_') + QString::number(info.lastModified().toTime_t()) + QLatin1Char('_') + - QString::number(info.size()) + QLatin1Char('_') + QString::number(data->pixelType()); + QString::number(info.size()) + QLatin1Char('_') + QString::number(data ? data->pixelType() : QPixmapData::PixmapType); if (QPixmapCache::find(key, *this)) return true; + if (!data) + data = QPixmapData::create(0, 0, QPixmapData::PixmapType); + if (data->fromFile(fileName, format, flags)) { QPixmapCache::insert(key, *this); return true; @@ -863,6 +866,9 @@ bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Qt::I if (len == 0 || buf == 0) return false; + if (!data) + data = QPixmapData::create(0, 0, QPixmapData::PixmapType); + return data->fromData(buf, len, format, flags); } @@ -1008,6 +1014,9 @@ int QPixmap::serialNumber() const */ qint64 QPixmap::cacheKey() const { + if (isNull()) + return 0; + int classKey = data->classId(); if (classKey >= 1024) classKey = -(classKey >> 10); @@ -1224,7 +1233,7 @@ QPixmap::QPixmap(const QImage& image) QPixmap &QPixmap::operator=(const QImage &image) { - if (data->pixelType() == QPixmapData::BitmapType) + if (data && data->pixelType() == QPixmapData::BitmapType) *this = QBitmap::fromImage(image); else *this = fromImage(image); @@ -1254,7 +1263,7 @@ bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Color */ bool QPixmap::convertFromImage(const QImage &image, ColorMode mode) { - if (data->pixelType() == QPixmapData::BitmapType) + if (data && data->pixelType() == QPixmapData::BitmapType) *this = QBitmap::fromImage(image, colorModeToFlags(mode)); else *this = fromImage(image, colorModeToFlags(mode)); @@ -1341,7 +1350,7 @@ Q_GUI_EXPORT void copyBlt(QPixmap *dst, int dx, int dy, bool QPixmap::isDetached() const { - return data->ref == 1; + return data && data->ref == 1; } /*! \internal @@ -1753,7 +1762,7 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) */ bool QPixmap::hasAlpha() const { - return (data->hasAlphaChannel() || !data->mask().isNull()); + return data && (data->hasAlphaChannel() || !data->mask().isNull()); } /*! @@ -1764,7 +1773,7 @@ bool QPixmap::hasAlpha() const */ bool QPixmap::hasAlphaChannel() const { - return data->hasAlphaChannel(); + return data && data->hasAlphaChannel(); } /*! @@ -1772,7 +1781,7 @@ bool QPixmap::hasAlphaChannel() const */ int QPixmap::metric(PaintDeviceMetric metric) const { - return data->metric(metric); + return data ? data->metric(metric) : 0; } /*! @@ -1844,7 +1853,7 @@ void QPixmap::setAlphaChannel(const QPixmap &alphaChannel) */ QPixmap QPixmap::alphaChannel() const { - return data->alphaChannel(); + return data ? data->alphaChannel() : QPixmap(); } /*! @@ -1852,7 +1861,7 @@ QPixmap QPixmap::alphaChannel() const */ QPaintEngine *QPixmap::paintEngine() const { - return data->paintEngine(); + return data ? data->paintEngine() : 0; } /*! @@ -1867,7 +1876,7 @@ QPaintEngine *QPixmap::paintEngine() const */ QBitmap QPixmap::mask() const { - return data->mask(); + return data ? data->mask() : QBitmap(); } /*! @@ -1916,6 +1925,9 @@ int QPixmap::defaultDepth() */ void QPixmap::detach() { + if (!data) + return; + QPixmapData::ClassId id = data->classId(); if (id == QPixmapData::RasterClass) { QRasterPixmapData *rasterData = static_cast(data.data()); diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp index afa6f83..15350e8 100644 --- a/src/gui/image/qpixmap_mac.cpp +++ b/src/gui/image/qpixmap_mac.cpp @@ -965,6 +965,9 @@ Qt::HANDLE QPixmap::macQDAlphaHandle() const Qt::HANDLE QPixmap::macCGHandle() const { + if (isNull()) + return 0; + if (data->classId() == QPixmapData::MacClass) { QMacPixmapData *d = static_cast(data.data()); if (!d->cg_data) diff --git a/src/gui/image/qpixmap_qws.cpp b/src/gui/image/qpixmap_qws.cpp index 6b4283e..a8516a5 100644 --- a/src/gui/image/qpixmap_qws.cpp +++ b/src/gui/image/qpixmap_qws.cpp @@ -114,7 +114,7 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h) QRgb* QPixmap::clut() const { - if (data->classId() == QPixmapData::RasterClass) { + if (data && data->classId() == QPixmapData::RasterClass) { const QRasterPixmapData *d = static_cast(data.data()); return d->image.colorTable().data(); } @@ -124,7 +124,7 @@ QRgb* QPixmap::clut() const int QPixmap::numCols() const { - if (data->classId() == QPixmapData::RasterClass) { + if (data && data->classId() == QPixmapData::RasterClass) { const QRasterPixmapData *d = static_cast(data.data()); return d->image.numColors(); } @@ -134,7 +134,7 @@ int QPixmap::numCols() const const uchar* QPixmap::qwsBits() const { - if (data->classId() == QPixmapData::RasterClass) { + if (data && data->classId() == QPixmapData::RasterClass) { const QRasterPixmapData *d = static_cast(data.data()); return d->image.bits(); } @@ -144,7 +144,7 @@ const uchar* QPixmap::qwsBits() const int QPixmap::qwsBytesPerLine() const { - if (data->classId() == QPixmapData::RasterClass) { + if (data && data->classId() == QPixmapData::RasterClass) { const QRasterPixmapData *d = static_cast(data.data()); return d->image.bytesPerLine(); } diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index 666d608..d4c97e1 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -311,7 +311,7 @@ QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h) CFbsBitmap *QPixmap::toSymbianCFbsBitmap() const { QPixmapData *data = pixmapData(); - if (data->isNull()) + if (!data || data->isNull()) return 0; return reinterpret_cast(data->toNativeType(QPixmapData::FbsBitmap)); @@ -337,8 +337,9 @@ QPixmap QPixmap::fromSymbianCFbsBitmap(CFbsBitmap *bitmap) if (!bitmap) return QPixmap(); - QPixmap pixmap; - pixmap.pixmapData()->fromNativeType(reinterpret_cast(bitmap), QPixmapData::FbsBitmap); + QScopedPointer data(new QS60PixmapData(QPixmapData::PixmapType)); + data->fromNativeType(reinterpret_cast(bitmap), QPixmapData::FbsBitmap); + QPixmap pixmap(data.take()); return pixmap; } @@ -752,9 +753,9 @@ QPixmap QPixmap::fromSymbianRSgImage(RSgImage *sgImage) if (!sgImage) return QPixmap(); - QPixmap pixmap; - pixmap.pixmapData()->fromNativeType(reinterpret_cast(sgImage), QPixmapData::SgImage); - + QScopedPointer data(new QS60PixmapData(QPixmapData::PixmapType)); + data->fromNativeType(reinterpret_cast(bitmap), QPixmapData::SgImage); + QPixmap pixmap(data.take()); return pixmap; } diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp index 1b61484..04027c1 100644 --- a/src/gui/image/qpixmap_win.cpp +++ b/src/gui/image/qpixmap_win.cpp @@ -121,6 +121,9 @@ QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h ) HBITMAP QPixmap::toWinHBITMAP(HBitmapFormat format) const { + if (isNull()) + return 0; + HBITMAP bitmap = 0; if (data->classId() == QPixmapData::RasterClass) { QRasterPixmapData* d = static_cast(data.data()); diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp index ea9eff9..8a0120a 100644 --- a/src/gui/image/qpixmap_x11.cpp +++ b/src/gui/image/qpixmap_x11.cpp @@ -1976,6 +1976,9 @@ void QPixmap::x11SetScreen(int screen) return; } + if (isNull()) + return; + if (data->classId() != QPixmapData::X11Class) return; @@ -2078,7 +2081,7 @@ bool QX11PixmapData::hasAlphaChannel() const const QX11Info &QPixmap::x11Info() const { - if (data->classId() == QPixmapData::X11Class) + if (data && data->classId() == QPixmapData::X11Class) return static_cast(data.data())->xinfo; else { static QX11Info nullX11Info; @@ -2135,7 +2138,7 @@ QPaintEngine* QX11PixmapData::paintEngine() const Qt::HANDLE QPixmap::x11PictureHandle() const { #ifndef QT_NO_XRENDER - if (data->classId() == QPixmapData::X11Class) + if (data && data->classId() == QPixmapData::X11Class) return static_cast(data.data())->picture; else return 0; diff --git a/src/gui/image/qpixmapdata.cpp b/src/gui/image/qpixmapdata.cpp index 1ad1f02..10194e4 100644 --- a/src/gui/image/qpixmapdata.cpp +++ b/src/gui/image/qpixmapdata.cpp @@ -51,6 +51,19 @@ QT_BEGIN_NAMESPACE const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; +QPixmapData *QPixmapData::create(int w, int h, PixelType type) +{ + QPixmapData *data; + QGraphicsSystem* gs = QApplicationPrivate::graphicsSystem(); + if (gs) + data = gs->createPixmapData(static_cast(type)); + else + data = QGraphicsSystem::createDefaultPixmapData(static_cast(type)); + data->resize(w, h); + return data; +} + + QPixmapData::QPixmapData(PixelType pixelType, int objectId) : w(0), h(0), diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h index e99409c..d1bb92a 100644 --- a/src/gui/image/qpixmapdata_p.h +++ b/src/gui/image/qpixmapdata_p.h @@ -122,6 +122,8 @@ public: virtual void fromNativeType(void* pixmap, NativeType type); #endif + static QPixmapData *create(int w, int h, PixelType type); + protected: void setSerialNumber(int serNo); int w; -- cgit v0.12 From a5c3cd6d540f282f59c7c5891598ed8f2c6e033f Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 30 Oct 2009 10:44:37 +0100 Subject: Updated QTextEdit auto-test after changes in commit 04d18b38c. --- .../fullWidthSelection/centered-fully-selected.png | Bin 1232 -> 1232 bytes .../fullWidthSelection/centered-partly-selected.png | Bin 1231 -> 1231 bytes .../fullWidthSelection/last-char-on-line.png | Bin 1220 -> 1226 bytes .../fullWidthSelection/last-char-on-parag.png | Bin 1222 -> 1223 bytes .../fullWidthSelection/multiple-full-width-lines.png | Bin 1236 -> 1236 bytes .../auto/qtextedit/fullWidthSelection/nowrap_long.png | Bin 1199 -> 1199 bytes .../fullWidthSelection/single-full-width-line.png | Bin 1235 -> 1225 bytes tests/auto/qtextedit/tst_qtextedit.cpp | 4 ++-- 8 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qtextedit/fullWidthSelection/centered-fully-selected.png b/tests/auto/qtextedit/fullWidthSelection/centered-fully-selected.png index 7467478..ced6eb6 100644 Binary files a/tests/auto/qtextedit/fullWidthSelection/centered-fully-selected.png and b/tests/auto/qtextedit/fullWidthSelection/centered-fully-selected.png differ diff --git a/tests/auto/qtextedit/fullWidthSelection/centered-partly-selected.png b/tests/auto/qtextedit/fullWidthSelection/centered-partly-selected.png index 7a10e63..481b99c 100644 Binary files a/tests/auto/qtextedit/fullWidthSelection/centered-partly-selected.png and b/tests/auto/qtextedit/fullWidthSelection/centered-partly-selected.png differ diff --git a/tests/auto/qtextedit/fullWidthSelection/last-char-on-line.png b/tests/auto/qtextedit/fullWidthSelection/last-char-on-line.png index df5b92e..292d3f9 100644 Binary files a/tests/auto/qtextedit/fullWidthSelection/last-char-on-line.png and b/tests/auto/qtextedit/fullWidthSelection/last-char-on-line.png differ diff --git a/tests/auto/qtextedit/fullWidthSelection/last-char-on-parag.png b/tests/auto/qtextedit/fullWidthSelection/last-char-on-parag.png index d58d4cc..69b72ed 100644 Binary files a/tests/auto/qtextedit/fullWidthSelection/last-char-on-parag.png and b/tests/auto/qtextedit/fullWidthSelection/last-char-on-parag.png differ diff --git a/tests/auto/qtextedit/fullWidthSelection/multiple-full-width-lines.png b/tests/auto/qtextedit/fullWidthSelection/multiple-full-width-lines.png index c5c3c22..467b91e 100644 Binary files a/tests/auto/qtextedit/fullWidthSelection/multiple-full-width-lines.png and b/tests/auto/qtextedit/fullWidthSelection/multiple-full-width-lines.png differ diff --git a/tests/auto/qtextedit/fullWidthSelection/nowrap_long.png b/tests/auto/qtextedit/fullWidthSelection/nowrap_long.png index 7ded254..cce921b 100644 Binary files a/tests/auto/qtextedit/fullWidthSelection/nowrap_long.png and b/tests/auto/qtextedit/fullWidthSelection/nowrap_long.png differ diff --git a/tests/auto/qtextedit/fullWidthSelection/single-full-width-line.png b/tests/auto/qtextedit/fullWidthSelection/single-full-width-line.png index d2fd629..937494a 100644 Binary files a/tests/auto/qtextedit/fullWidthSelection/single-full-width-line.png and b/tests/auto/qtextedit/fullWidthSelection/single-full-width-line.png differ diff --git a/tests/auto/qtextedit/tst_qtextedit.cpp b/tests/auto/qtextedit/tst_qtextedit.cpp index 59abbd5..fee030c 100644 --- a/tests/auto/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/qtextedit/tst_qtextedit.cpp @@ -1967,7 +1967,7 @@ void tst_QTextEdit::fullWidthSelection() qt_setQtEnableTestFont(true); QFont testFont; testFont.setFamily("__Qt__Box__Engine__"); - testFont.setPixelSize(12); + testFont.setPixelSize(11); testFont.setWeight(QFont::Normal); QTextCharFormat cf; cf.setFont(testFont); @@ -2015,7 +2015,7 @@ void tst_QTextEdit::fullWidthSelection2() qt_setQtEnableTestFont(true); QFont testFont; testFont.setFamily("__Qt__Box__Engine__"); - testFont.setPixelSize(12); + testFont.setPixelSize(11); testFont.setWeight(QFont::Normal); QTextCharFormat cf; cf.setFont(testFont); -- cgit v0.12 From d670ef51fe76adccd6f4d017f6a23940ab5284ee Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 30 Oct 2009 10:55:29 +0100 Subject: rename qstringbuilder test classes --- tests/auto/qstringbuilder1/qstringbuilder1.pro | 3 -- tests/auto/qstringbuilder1/stringbuilder.cpp | 56 +--------------------- tests/auto/qstringbuilder1/stringbuilder.h | 55 --------------------- tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp | 33 ++++++++++++- tests/auto/qstringbuilder2/qstringbuilder2.pro | 3 -- tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp | 32 +++++++++++++ tests/auto/qstringbuilder3/qstringbuilder3.pro | 3 -- tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp | 31 ++++++++++++ tests/auto/qstringbuilder4/qstringbuilder4.pro | 3 -- tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp | 34 ++++++++++++- 10 files changed, 129 insertions(+), 124 deletions(-) delete mode 100644 tests/auto/qstringbuilder1/stringbuilder.h diff --git a/tests/auto/qstringbuilder1/qstringbuilder1.pro b/tests/auto/qstringbuilder1/qstringbuilder1.pro index 1ca9d45..5bb14d4 100644 --- a/tests/auto/qstringbuilder1/qstringbuilder1.pro +++ b/tests/auto/qstringbuilder1/qstringbuilder1.pro @@ -3,7 +3,4 @@ load(qttest_p4) QT = core SOURCES += tst_qstringbuilder1.cpp -HEADERS += ../qstringbuilder1/stringbuilder.h - -DEFINES += SCENARIO=1 diff --git a/tests/auto/qstringbuilder1/stringbuilder.cpp b/tests/auto/qstringbuilder1/stringbuilder.cpp index 9fea137..f35d4d2 100644 --- a/tests/auto/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/qstringbuilder1/stringbuilder.cpp @@ -39,61 +39,9 @@ ** ****************************************************************************/ -// This is included in various .cpp files as a compile test for various scenarios -// depending on NO_CAST_* and QT_USE_FAST_OPERATOR_PLUS and QT_USE_FAST_CONCATENATION - -#if SCENARIO == 1 -// this is the "no harm done" version. Only operator% is active, -// with NO_CAST * defined -#define P % -#undef QT_USE_FAST_OPERATOR_PLUS -#undef QT_USE_FAST_CONCATENATION -#define QT_NO_CAST_FROM_ASCII -#define QT_NO_CAST_TO_ASCII -#endif - - -#if SCENARIO == 2 -// this is the "full" version. Operator+ is replaced by a QStringBuilder -// based version -// with NO_CAST * defined -#define P + -#define QT_USE_FAST_OPERATOR_PLUS -#define QT_USE_FAST_CONCATENATION -#define QT_NO_CAST_FROM_ASCII -#define QT_NO_CAST_TO_ASCII -#endif - -#if SCENARIO == 3 -// this is the "no harm done" version. Only operator% is active, -// with NO_CAST * _not_ defined -#define P % -#undef QT_USE_FAST_OPERATOR_PLUS -#undef QT_USE_FAST_CONCATENATION -#undef QT_NO_CAST_FROM_ASCII -#undef QT_NO_CAST_TO_ASCII -#endif - -#if SCENARIO == 4 -// this is the "full" version. Operator+ is replaced by a QStringBuilder -// based version -// with NO_CAST * _not_ defined -#define P + -#define QT_USE_FAST_OPERATOR_PLUS -#define QT_USE_FAST_CONCATENATION -#undef QT_NO_CAST_FROM_ASCII -#undef QT_NO_CAST_TO_ASCII -#endif - -#include -#include "stringbuilder.h" - -//TESTED_CLASS=QStringBuilder -//TESTED_FILES=qstringbuilder.cpp - #define LITERAL "some literal" -void tst_QStringBuilder::scenario() +void runScenario() { QLatin1Literal l1literal(LITERAL); QLatin1String l1string(LITERAL); @@ -129,5 +77,3 @@ void tst_QStringBuilder::scenario() QCOMPARE(r, r2); #endif } - -QTEST_APPLESS_MAIN(tst_QStringBuilder) diff --git a/tests/auto/qstringbuilder1/stringbuilder.h b/tests/auto/qstringbuilder1/stringbuilder.h deleted file mode 100644 index 5ac9dbe..0000000 --- a/tests/auto/qstringbuilder1/stringbuilder.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying -** this package. -** -** 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TST_QSTRINGBUILDER_H -#define TST_QSTRINGBUILDER_H - -#include - -class tst_QStringBuilder : public QObject -{ - Q_OBJECT - -private slots: - void scenario(); -}; - -#endif diff --git a/tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp b/tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp index bd2e4b0..d0a613c 100644 --- a/tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp +++ b/tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp @@ -39,4 +39,35 @@ ** ****************************************************************************/ -#include "../qstringbuilder1/stringbuilder.cpp" + +// SCENARIO 1 +// this is the "no harm done" version. Only operator% is active, +// with NO_CAST * defined +#define P % +#undef QT_USE_FAST_OPERATOR_PLUS +#undef QT_USE_FAST_CONCATENATION +#define QT_NO_CAST_FROM_ASCII +#define QT_NO_CAST_TO_ASCII + + +#include + +//TESTED_CLASS=QStringBuilder +//TESTED_FILES=qstringbuilder.cpp + +#define LITERAL "some literal" + +void runScenario(); // Defined in stringbuilder.cpp #included below. + +class tst_QStringBuilder1 : public QObject +{ + Q_OBJECT + +private slots: + void scenario() { runScenario(); } +}; + +#include "stringbuilder.cpp" +#include "tst_qstringbuilder1.moc" + +QTEST_APPLESS_MAIN(tst_QStringBuilder1) diff --git a/tests/auto/qstringbuilder2/qstringbuilder2.pro b/tests/auto/qstringbuilder2/qstringbuilder2.pro index c0b3ebc..4152dc3 100644 --- a/tests/auto/qstringbuilder2/qstringbuilder2.pro +++ b/tests/auto/qstringbuilder2/qstringbuilder2.pro @@ -3,6 +3,3 @@ load(qttest_p4) QT = core SOURCES += tst_qstringbuilder2.cpp -HEADERS += ../qstringbuilder1/stringbuilder.h - -DEFINES += SCENARIO=2 diff --git a/tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp b/tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp index bd2e4b0..4470928 100644 --- a/tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp +++ b/tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp @@ -39,4 +39,36 @@ ** ****************************************************************************/ + +// SCENARIO 2 +// this is the "full" version. Operator+ is replaced by a QStringBuilder +// based version +// with NO_CAST * defined +#define P + +#define QT_USE_FAST_OPERATOR_PLUS +#define QT_USE_FAST_CONCATENATION +#define QT_NO_CAST_FROM_ASCII +#define QT_NO_CAST_TO_ASCII + + +#include + +//TESTED_CLASS=QStringBuilder +//TESTED_FILES=qstringbuilder.cpp + +#define LITERAL "some literal" + +void runScenario(); // Defined in stringbuilder.cpp #included below. + +class tst_QStringBuilder2 : public QObject +{ + Q_OBJECT + +private slots: + void scenario() { runScenario(); } +}; + #include "../qstringbuilder1/stringbuilder.cpp" +#include "tst_qstringbuilder2.moc" + +QTEST_APPLESS_MAIN(tst_QStringBuilder2) diff --git a/tests/auto/qstringbuilder3/qstringbuilder3.pro b/tests/auto/qstringbuilder3/qstringbuilder3.pro index 93d1a39..b4d2225 100644 --- a/tests/auto/qstringbuilder3/qstringbuilder3.pro +++ b/tests/auto/qstringbuilder3/qstringbuilder3.pro @@ -3,6 +3,3 @@ load(qttest_p4) QT = core SOURCES += tst_qstringbuilder3.cpp -HEADERS += ../qstringbuilder1/stringbuilder.h - -DEFINES += SCENARIO=3 diff --git a/tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp b/tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp index bd2e4b0..30f0181 100644 --- a/tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp +++ b/tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp @@ -39,4 +39,35 @@ ** ****************************************************************************/ + +// SCENARIO 3 +// this is the "no harm done" version. Only operator% is active, +// with NO_CAST * _not_ defined +#define P % +#undef QT_USE_FAST_OPERATOR_PLUS +#undef QT_USE_FAST_CONCATENATION +#undef QT_NO_CAST_FROM_ASCII +#undef QT_NO_CAST_TO_ASCII + + +#include + +//TESTED_CLASS=QStringBuilder +//TESTED_FILES=qstringbuilder.cpp + +#define LITERAL "some literal" + +void runScenario(); // Defined in stringbuilder.cpp #included below. + +class tst_QStringBuilder3 : public QObject +{ + Q_OBJECT + +private slots: + void scenario() { runScenario(); } +}; + #include "../qstringbuilder1/stringbuilder.cpp" +#include "tst_qstringbuilder3.moc" + +QTEST_APPLESS_MAIN(tst_QStringBuilder3) diff --git a/tests/auto/qstringbuilder4/qstringbuilder4.pro b/tests/auto/qstringbuilder4/qstringbuilder4.pro index eeec447..6ec5228 100644 --- a/tests/auto/qstringbuilder4/qstringbuilder4.pro +++ b/tests/auto/qstringbuilder4/qstringbuilder4.pro @@ -3,6 +3,3 @@ load(qttest_p4) QT = core SOURCES += tst_qstringbuilder4.cpp -HEADERS += ../qstringbuilder1/stringbuilder.h - -DEFINES += SCENARIO=4 diff --git a/tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp b/tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp index 2159283..95b4ec3 100644 --- a/tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp +++ b/tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtXmlPatterns module of the Qt Toolkit. +** This file is part of the test suite module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -39,4 +39,36 @@ ** ****************************************************************************/ + +// SCENARIO 4 +// this is the "full" version. Operator+ is replaced by a QStringBuilder +// based version +// with NO_CAST * _not_ defined +#define P + +#define QT_USE_FAST_OPERATOR_PLUS +#define QT_USE_FAST_CONCATENATION +#undef QT_NO_CAST_FROM_ASCII +#undef QT_NO_CAST_TO_ASCII + + +#include + +//TESTED_CLASS=QStringBuilder +//TESTED_FILES=qstringbuilder.cpp + +#define LITERAL "some literal" + +void runScenario(); // Defined in stringbuilder.cpp #included below. + +class tst_QStringBuilder4 : public QObject +{ + Q_OBJECT + +private slots: + void scenario() { runScenario(); } +}; + #include "../qstringbuilder1/stringbuilder.cpp" +#include "tst_qstringbuilder4.moc" + +QTEST_APPLESS_MAIN(tst_QStringBuilder4) -- cgit v0.12 From 2cdea6a10da75b7b8870f27c432a5e02f7500340 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 30 Oct 2009 11:11:26 +0100 Subject: QActionGroup: reset the checkedAction when it is unchecked Task-number: QTBUG-1019 Reviewed-by: Gabriel --- src/gui/kernel/qactiongroup.cpp | 14 ++++++++++---- tests/auto/qactiongroup/tst_qactiongroup.cpp | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qactiongroup.cpp b/src/gui/kernel/qactiongroup.cpp index 40d18a2..8db76e4 100644 --- a/src/gui/kernel/qactiongroup.cpp +++ b/src/gui/kernel/qactiongroup.cpp @@ -72,10 +72,16 @@ void QActionGroupPrivate::_q_actionChanged() Q_Q(QActionGroup); QAction *action = qobject_cast(q->sender()); Q_ASSERT_X(action != 0, "QWidgetGroup::_q_actionChanged", "internal error"); - if(exclusive && action->isChecked() && action != current) { - if(current) - current->setChecked(false); - current = action; + if(exclusive) { + if (action->isChecked()) { + if (action != current) { + if(current) + current->setChecked(false); + current = action; + } + } else if (action == current) { + current = 0; + } } } diff --git a/tests/auto/qactiongroup/tst_qactiongroup.cpp b/tests/auto/qactiongroup/tst_qactiongroup.cpp index 2d215a0..7259479 100644 --- a/tests/auto/qactiongroup/tst_qactiongroup.cpp +++ b/tests/auto/qactiongroup/tst_qactiongroup.cpp @@ -70,6 +70,7 @@ private slots: void separators(); void testActionInTwoQActionGroup(); + void unCheckCurrentAction(); }; tst_QActionGroup::tst_QActionGroup() @@ -278,5 +279,25 @@ void tst_QActionGroup::testActionInTwoQActionGroup() QCOMPARE(group1.actions().isEmpty(), true); } +void tst_QActionGroup::unCheckCurrentAction() +{ + QActionGroup group(0); + QAction action1(&group) ,action2(&group); + action1.setCheckable(true); + action2.setCheckable(true); + QVERIFY(!action1.isChecked()); + QVERIFY(!action2.isChecked()); + action1.setChecked(true); + QVERIFY(action1.isChecked()); + QVERIFY(!action2.isChecked()); + QAction *current = group.checkedAction(); + QCOMPARE(current, &action1); + current->setChecked(false); + QVERIFY(!action1.isChecked()); + QVERIFY(!action2.isChecked()); + QVERIFY(group.checkedAction() == 0); +} + + QTEST_MAIN(tst_QActionGroup) #include "tst_qactiongroup.moc" -- cgit v0.12 From 1bed105d048531e3e260eff0ef2533d7cc8ba7fb Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 26 Oct 2009 12:40:33 +0100 Subject: introduce int QTextDocument::available{Undo,Redo}Steps() const; Formerly, QTextDocument::revision() could be used to guesstimate the number of available undo steps that was used in Qt Creator to store cursor positions in parallel to the actual text contents. Now that revision() is strictly increasing, another means is needed, therefore the new functions providing the needed data. Reviewed-by: mae --- src/gui/text/qtextdocument.cpp | 27 +++++++++++++++++++++++++++ src/gui/text/qtextdocument.h | 3 +++ src/gui/text/qtextdocument_p.h | 3 +++ 3 files changed, 33 insertions(+) diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index a8956b8..5398111 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -956,6 +956,8 @@ QString QTextDocument::defaultStyleSheet() const /*! Returns true if undo is available; otherwise returns false. + + \sa isRedoAvailable(), availableUndoSteps() */ bool QTextDocument::isUndoAvailable() const { @@ -965,6 +967,8 @@ bool QTextDocument::isUndoAvailable() const /*! Returns true if redo is available; otherwise returns false. + + \sa isUndoAvailable(), availableRedoSteps() */ bool QTextDocument::isRedoAvailable() const { @@ -972,6 +976,29 @@ bool QTextDocument::isRedoAvailable() const return d->isRedoAvailable(); } +/*! \since 4.6 + + Returns the number of available undo steps. + + \sa isUndoAvailable() +*/ +int QTextDocument::availableUndoSteps() const +{ + Q_D(const QTextDocument); + return d->availableUndoSteps(); +} + +/*! \since 4.6 + + Returns the number of available redo steps. + + \sa isRedoAvailable() +*/ +int QTextDocument::availableRedoSteps() const +{ + Q_D(const QTextDocument); + return d->availableRedoSteps(); +} /*! \since 4.4 diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h index e52716a..d217a4d 100644 --- a/src/gui/text/qtextdocument.h +++ b/src/gui/text/qtextdocument.h @@ -142,6 +142,9 @@ public: bool isUndoAvailable() const; bool isRedoAvailable() const; + int availableUndoSteps() const; + int availableRedoSteps() const; + int revision() const; void setDocumentLayout(QAbstractTextDocumentLayout *layout); diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index ce25c57..c10855b 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -212,6 +212,9 @@ public: inline bool isUndoAvailable() const { return undoEnabled && undoState > 0; } inline bool isRedoAvailable() const { return undoEnabled && undoState < undoStack.size(); } + inline int availableUndoSteps() const { return undoEnabled ? undoState : 0; } + inline int availableRedoSteps() const { return undoEnabled ? qMax(undoStack.size() - undoState - 1, 0) : 0; } + inline QString buffer() const { return text; } QString plainText() const; inline int length() const { return fragments.length(); } -- cgit v0.12 From c726e83aebf2252b5a94444d5d61e03ef2033437 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 30 Oct 2009 11:36:30 +0100 Subject: In ItemViews, right click on the viewport clear the ext selection Task-number: QTBUG-435 Reviewed-by: Gabriel --- src/gui/itemviews/qabstractitemview.cpp | 2 +- tests/auto/qlistview/tst_qlistview.cpp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 9247411..23bef12 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -3641,7 +3641,7 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionC const bool controlKeyPressed = modifiers & Qt::ControlModifier; if (((index == pressedIndex && selectionModel->isSelected(index)) || !index.isValid()) && state != QAbstractItemView::DragSelectingState - && !shiftKeyPressed && !controlKeyPressed && !rightButtonPressed) + && !shiftKeyPressed && !controlKeyPressed && (!rightButtonPressed || !index.isValid())) return QItemSelectionModel::ClearAndSelect|selectionBehaviorFlags(); return QItemSelectionModel::NoUpdate; } diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 727e6d3..a5ff153 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -120,6 +120,7 @@ private slots: void taskQTBUG_2233_scrollHiddenItems_data(); void taskQTBUG_2233_scrollHiddenItems(); void taskQTBUG_633_changeModelData(); + void taskQTBUG_435_deselectOnViewportClick(); }; // Testing get/set functions @@ -1852,6 +1853,28 @@ void tst_QListView::taskQTBUG_633_changeModelData() QVERIFY( ! rectLongText.intersects(rect2) ); } +void tst_QListView::taskQTBUG_435_deselectOnViewportClick() +{ + QListView view; + QStringListModel model( QStringList() << "1" << "2" << "3" << "4"); + view.setModel(&model); + view.setSelectionMode(QAbstractItemView::ExtendedSelection); + view.selectAll(); + QCOMPARE(view.selectionModel()->selectedIndexes().count(), model.rowCount()); + + + QPoint p = view.visualRect(model.index(model.rowCount() - 1)).center() + QPoint(0, 20); + //first the left button + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p); + QVERIFY(!view.selectionModel()->hasSelection()); + + view.selectAll(); + QCOMPARE(view.selectionModel()->selectedIndexes().count(), model.rowCount()); + + //and now the right button + QTest::mouseClick(view.viewport(), Qt::RightButton, 0, p); + QVERIFY(!view.selectionModel()->hasSelection()); +} QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" -- cgit v0.12 From 5e95f9c3c224b87840e750d4280806a40ed40c92 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Fri, 30 Oct 2009 12:21:25 +0100 Subject: Remove a paintBox call that should have been moved a few lines down, but was instead copied in commit ea13922 Reviewed-by: TrustMe --- src/gui/styles/qgtkstyle.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index d315c98..b8d3674 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -1933,9 +1933,6 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom QRect grooveRect = option->rect.adjusted(focusFrameMargin, outerSize + focusFrameMargin, -focusFrameMargin, -outerSize - focusFrameMargin); - gtkPainter.paintBox( scaleWidget, "trough", grooveRect, state, - GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition)); - gboolean trough_side_details = false; // Indicates if the upper or lower scale background differs if (!QGtk::gtk_check_version(2, 10, 0)) QGtk::gtk_widget_style_get((GtkWidget*)(scaleWidget), "trough-side-details", &trough_side_details, NULL); -- cgit v0.12 From b68cd1df21935fc032a93c7d7bc33fcb77c7b8cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 30 Oct 2009 12:20:09 +0100 Subject: Reverts bf1a6bb6b3b8c98f6ab402512eb2f1996c2435c7 and removes THREAD from qfeature Reviewed-by: Trust Me --- src/corelib/global/qconfig-minimal.h | 3 -- src/corelib/global/qfeatures.h | 63 ++++++++++++++++-------------------- src/corelib/global/qfeatures.txt | 15 +++------ src/corelib/thread/qmutexpool.cpp | 20 ++++++------ src/corelib/thread/qmutexpool_p.h | 17 ++-------- src/corelib/thread/qthread.cpp | 24 ++++++-------- src/corelib/thread/qthread_p.h | 62 ++++++++++++++++++----------------- 7 files changed, 85 insertions(+), 119 deletions(-) diff --git a/src/corelib/global/qconfig-minimal.h b/src/corelib/global/qconfig-minimal.h index 9cc3057..58565d6 100644 --- a/src/corelib/global/qconfig-minimal.h +++ b/src/corelib/global/qconfig-minimal.h @@ -255,9 +255,6 @@ #ifndef QT_NO_TEXTHTMLPARSER # define QT_NO_TEXTHTMLPARSER #endif -#ifndef QT_NO_THREAD -# define QT_NO_THREAD -#endif #ifndef QT_NO_CONCURRENT # define QT_NO_CONCURRENT #endif diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index 3996180..9b3e817 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -55,6 +55,9 @@ // Color Names //#define QT_NO_COLORNAMES +// QtConcurrent +//#define QT_NO_CONCURRENT + // QCopChannel //#define QT_NO_COP @@ -76,6 +79,9 @@ // Effects //#define QT_NO_EFFECTS +// QFileSystemWatcher +//#define QT_NO_FILESYSTEMWATCHER + // Freetype Font Engine //#define QT_NO_FREETYPE @@ -151,6 +157,9 @@ // QPicture //#define QT_NO_PICTURE +// QProcess +//#define QT_NO_PROCESS + // QProgressBar //#define QT_NO_PROGRESSBAR @@ -274,9 +283,6 @@ // QTextStream //#define QT_NO_TEXTSTREAM -// QThread -//#define QT_NO_THREAD - // QToolTip //#define QT_NO_TOOLTIP @@ -301,6 +307,11 @@ // //#define QT_NO_XMLSTREAM +// Animation +#if !defined(QT_NO_ANIMATION) && (defined(QT_NO_PROPERTIES)) +#define QT_NO_ANIMATION +#endif + // QButtonGroup #if !defined(QT_NO_BUTTONGROUP) && (defined(QT_NO_GROUPBOX)) #define QT_NO_BUTTONGROUP @@ -316,11 +327,6 @@ #define QT_NO_CODECS #endif -// QtConcurrent -#if !defined(QT_NO_CONCURRENT) && (defined(QT_NO_THREAD)) -#define QT_NO_CONCURRENT -#endif - // QDate/QTime/QDateTime #if !defined(QT_NO_DATESTRING) && (defined(QT_NO_TEXTDATE)) #define QT_NO_DATESTRING @@ -331,9 +337,9 @@ #define QT_NO_DIAL #endif -// QFileSystemWatcher -#if !defined(QT_NO_FILESYSTEMWATCHER) && (defined(QT_NO_THREAD)) -#define QT_NO_FILESYSTEMWATCHER +// QFileSystemModel +#if !defined(QT_NO_FILESYSTEMMODEL) && (defined(QT_NO_FILESYSTEMWATCHER)) +#define QT_NO_FILESYSTEMMODEL #endif // QHostInfo @@ -371,11 +377,6 @@ #define QT_NO_PHONON_VOLUMEFADEREFFECT #endif -// QProcess -#if !defined(QT_NO_PROCESS) && (defined(QT_NO_THREAD)) -#define QT_NO_PROCESS -#endif - // QProgressDialog #if !defined(QT_NO_PROGRESSDIALOG) && (defined(QT_NO_PROGRESSBAR)) #define QT_NO_PROGRESSDIALOG @@ -491,21 +492,11 @@ #define QT_NO_XMLSTREAMWRITER #endif -// Animation -#if !defined(QT_NO_ANIMATION) && (defined(QT_NO_PROPERTIES) || defined(QT_NO_THREAD)) -#define QT_NO_ANIMATION -#endif - // Context menu #if !defined(QT_NO_CONTEXTMENU) && (defined(QT_NO_MENU)) #define QT_NO_CONTEXTMENU #endif -// QFileSystemModel -#if !defined(QT_NO_FILESYSTEMMODEL) && (defined(QT_NO_FILESYSTEMWATCHER)) -#define QT_NO_FILESYSTEMMODEL -#endif - // File Transfer Protocol #if !defined(QT_NO_FTP) && (defined(QT_NO_URLINFO) || defined(QT_NO_TEXTDATE)) #define QT_NO_FTP @@ -796,31 +787,31 @@ #define QT_NO_CUPS #endif -// QDockwidget -#if !defined(QT_NO_DOCKWIDGET) && (defined(QT_NO_RUBBERBAND) || defined(QT_NO_MAINWINDOW)) -#define QT_NO_DOCKWIDGET -#endif - // QDirModel #if !defined(QT_NO_DIRMODEL) && (defined(QT_NO_ITEMVIEWS) || defined(QT_NO_FILESYSTEMMODEL)) #define QT_NO_DIRMODEL #endif +// QDockwidget +#if !defined(QT_NO_DOCKWIDGET) && (defined(QT_NO_RUBBERBAND) || defined(QT_NO_MAINWINDOW)) +#define QT_NO_DOCKWIDGET +#endif + // QUndoView #if !defined(QT_NO_UNDOVIEW) && (defined(QT_NO_UNDOSTACK) || defined(QT_NO_LISTVIEW)) #define QT_NO_UNDOVIEW #endif -// QGraphicsSvgItem -#if !defined(QT_NO_GRAPHICSSVGITEM) && (defined(QT_NO_SVGRENDERER) || defined(QT_NO_GRAPHICSVIEW)) -#define QT_NO_GRAPHICSSVGITEM -#endif - // QCompleter #if !defined(QT_NO_FSCOMPLETER) && (defined(QT_NO_FILESYSTEMMODEL) || defined(QT_NO_COMPLETER)) #define QT_NO_FSCOMPLETER #endif +// QGraphicsSvgItem +#if !defined(QT_NO_GRAPHICSSVGITEM) && (defined(QT_NO_SVGRENDERER) || defined(QT_NO_GRAPHICSVIEW)) +#define QT_NO_GRAPHICSSVGITEM +#endif + // QComboBox #if !defined(QT_NO_COMBOBOX) && (defined(QT_NO_LINEEDIT) || defined(QT_NO_STANDARDITEMMODEL) || defined(QT_NO_LISTVIEW)) #define QT_NO_COMBOBOX diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index 543056f..ff34006 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -28,17 +28,10 @@ Requires: Name: CssParser SeeAlso: ??? -Feature: THREAD -Description: Supports multithreaded programming. -Section: Kernel -Requires: -Name: QThread -SeeAlso: ??? - Feature: CONCURRENT Description: Provides a high-level multi-threaded APIs Section: Kernel -Requires: THREAD +Requires: Name: QtConcurrent SeeAlso: ??? @@ -195,7 +188,7 @@ SeeAlso: ??? Feature: PROCESS Description: Supports external process invocation. Section: File I/O -Requires: THREAD +Requires: Name: QProcess SeeAlso: ??? @@ -245,7 +238,7 @@ Feature: FILESYSTEMWATCHER Description: Provides an interface for monitoring files and directories for modications. Section: File I/O -Requires: THREAD +Requires: Name: QFileSystemWatcher SeeAlso: ??? @@ -1166,7 +1159,7 @@ SeeAlso: ??? Feature: ANIMATION Description: Provides a framework for animations. Section: Utilities -Requires: PROPERTIES THREAD +Requires: PROPERTIES Name: Animation SeeAlso: ??? diff --git a/src/corelib/thread/qmutexpool.cpp b/src/corelib/thread/qmutexpool.cpp index 9f37239..c5c1882 100644 --- a/src/corelib/thread/qmutexpool.cpp +++ b/src/corelib/thread/qmutexpool.cpp @@ -42,6 +42,7 @@ #include "qatomic.h" #include "qmutexpool_p.h" +#ifndef QT_NO_THREAD QT_BEGIN_NAMESPACE @@ -49,7 +50,6 @@ QT_BEGIN_NAMESPACE // use QMutexpool::instance() in new clode. Q_CORE_EXPORT QMutexPool *qt_global_mutexpool = 0; Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (QMutex::Recursive)) -#ifndef QT_NO_THREAD /*! \class QMutexPool @@ -114,6 +114,15 @@ QMutexPool::~QMutexPool() mutexes[index] = 0; } } + +/*! + Returns the global QMutexPool instance. +*/ +QMutexPool *QMutexPool::instance() +{ + return globalMutexPool(); +} + /*! Returns a QMutex from the pool. QMutexPool uses the value \a address to determine which mutex is returned from the pool. @@ -143,14 +152,7 @@ QMutex *QMutexPool::globalInstanceGet(const void *address) return 0; return globalInstance->get(address); } -#endif // QT_NO_THREAD -/*! - Returns the global QMutexPool instance. -*/ -QMutexPool *QMutexPool::instance() -{ - return globalMutexPool(); -} QT_END_NAMESPACE +#endif // QT_NO_THREAD diff --git a/src/corelib/thread/qmutexpool_p.h b/src/corelib/thread/qmutexpool_p.h index c26711b..3e1bad0 100644 --- a/src/corelib/thread/qmutexpool_p.h +++ b/src/corelib/thread/qmutexpool_p.h @@ -57,9 +57,9 @@ #include "QtCore/qmutex.h" #include "QtCore/qvarlengtharray.h" +#ifndef QT_NO_THREAD QT_BEGIN_NAMESPACE -#ifndef QT_NO_THREAD class Q_CORE_EXPORT QMutexPool { @@ -75,24 +75,11 @@ private: QVarLengthArray, 131> mutexes; QMutex::RecursionMode recursionMode; }; -#else //QT_NO_THREAD -Q_GLOBAL_STATIC(QMutex, globalMutex) -class Q_CORE_EXPORT QMutexPool -{ -public: - explicit QMutexPool(QMutex::RecursionMode recursionMode = QMutex::NonRecursive, int size = 131){} - ~QMutexPool(){} - - QMutex *get(const void *address){return globalMutex();} - static QMutexPool *instance(); - static QMutex *globalInstanceGet(const void *address){return globalMutex();} -}; - -#endif // QT_NO_THREAD extern Q_CORE_EXPORT QMutexPool *qt_global_mutexpool; QT_END_NAMESPACE +#endif // QT_NO_THREAD #endif // QMUTEXPOOL_P_H diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index cf57d33..ac191fe 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -727,16 +727,6 @@ QThread *QThread::currentThread() return QThreadData::current()->thread; } -/*! \internal - */ -QThread::QThread(QThreadPrivate &dd, QObject *parent) - : QObject(dd, parent) -{ - Q_D(QThread); - // fprintf(stderr, "QThreadData %p taken from private data for thread %p\n", d->data, this); - d->data->thread = this; -} - QThreadData* QThreadData::current() { static QThreadData *data = 0; // reinterpret_cast(pthread_getspecific(current_thread_data_key)); @@ -748,13 +738,17 @@ QThreadData* QThreadData::current() } return data; } -#endif // QT_NO_THREAD -QThreadData* QThreadData::get2(QThread *thread) + +/*! \internal + */ +QThread::QThread(QThreadPrivate &dd, QObject *parent) + : QObject(dd, parent) { - Q_ASSERT_X(thread != 0, "QThread", "internal error"); - return thread->d_func()->data; + Q_D(QThread); + // fprintf(stderr, "QThreadData %p taken from private data for thread %p\n", d->data, this); + d->data->thread = this; } - +#endif // QT_NO_THREAD QT_END_NAMESPACE diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 8c3acdb..af68434 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -111,36 +111,6 @@ public: { } }; -class QThreadData -{ - QAtomicInt _ref; - -public: - QThreadData(int initialRefCount = 1); - ~QThreadData(); - - static QThreadData *current(); - static QThreadData *get2(QThread *thread); - - void ref(); - void deref(); - - QThread *thread; - bool quitNow; - int loopLevel; - QAbstractEventDispatcher *eventDispatcher; - QStack eventLoops; - QPostEventList postEventList; - bool canWait; - QMap tls; - - QMutex mutex; - -# ifdef Q_OS_SYMBIAN - RThread symbian_thread_handle; -# endif -}; - #ifndef QT_NO_THREAD class QThreadPrivate : public QObjectPrivate { @@ -209,6 +179,38 @@ public: #endif // QT_NO_THREAD +class QThreadData +{ + QAtomicInt _ref; + +public: + QThreadData(int initialRefCount = 1); + ~QThreadData(); + + static QThreadData *current(); + static QThreadData *get2(QThread *thread) + { Q_ASSERT_X(thread != 0, "QThread", "internal error"); return thread->d_func()->data; } + + + void ref(); + void deref(); + + QThread *thread; + bool quitNow; + int loopLevel; + QAbstractEventDispatcher *eventDispatcher; + QStack eventLoops; + QPostEventList postEventList; + bool canWait; + QMap tls; + + QMutex mutex; + +# ifdef Q_OS_SYMBIAN + RThread symbian_thread_handle; +# endif +}; + // thread wrapper for the main() thread class QAdoptedThread : public QThread { -- cgit v0.12 From 30b0902cf05b0c1dc649e9c2e7ae0415e0c1d042 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 30 Oct 2009 12:35:49 +0100 Subject: Remove the unnecessary (and broken) tst_QMouseEvent::checkMouseMoveEvent() test According to people responsible for the test, it is not necessary. This partially reverts commit b1f9882fa52745c922eb0109daa011908214dcf7. --- tests/auto/qmouseevent/tst_qmouseevent.cpp | 75 ------------------------------ 1 file changed, 75 deletions(-) diff --git a/tests/auto/qmouseevent/tst_qmouseevent.cpp b/tests/auto/qmouseevent/tst_qmouseevent.cpp index d700181..b961851 100644 --- a/tests/auto/qmouseevent/tst_qmouseevent.cpp +++ b/tests/auto/qmouseevent/tst_qmouseevent.cpp @@ -62,7 +62,6 @@ public: } bool mousePressEventRecieved; bool mouseReleaseEventRecieved; - bool mouseMoveEventRecieved; #ifdef QT3_SUPPORT int mousePressStateBefore; int mousePressStateAfter; @@ -77,13 +76,6 @@ public: int mouseReleaseButton; int mouseReleaseButtons; int mouseReleaseModifiers; -#ifdef QT3_SUPPORT - int mouseMoveStateBefore; - int mouseMoveStateAfter; -#endif - int mouseMoveButton; - int mouseMoveButtons; - int mouseMoveModifiers; protected: void mousePressEvent(QMouseEvent *e) { @@ -111,19 +103,6 @@ protected: mouseReleaseEventRecieved = TRUE; e->accept(); } - void mouseMoveEvent(QMouseEvent *e) - { - QWidget::mouseMoveEvent(e); -#ifdef QT3_SUPPORT - mouseMoveStateBefore = e->state(); - mouseMoveStateAfter = e->stateAfter(); -#endif - mouseMoveButton = e->button(); - mouseMoveButtons = e->buttons(); - mouseMoveModifiers = e->modifiers(); - mouseMoveEventRecieved = TRUE; - e->accept(); - } }; class tst_QMouseEvent : public QObject @@ -145,8 +124,6 @@ private slots: void checkMousePressEvent(); void checkMouseReleaseEvent_data(); void checkMouseReleaseEvent(); - void checkMouseMoveEvent_data(); - void checkMouseMoveEvent(); void qt3supportConstructors(); @@ -180,14 +157,11 @@ void tst_QMouseEvent::init() { testMouseWidget->mousePressEventRecieved = FALSE; testMouseWidget->mouseReleaseEventRecieved = FALSE; - testMouseWidget->mouseMoveEventRecieved = FALSE; #ifdef QT3_SUPPORT testMouseWidget->mousePressStateBefore = 0; testMouseWidget->mousePressStateAfter = 0; testMouseWidget->mouseReleaseStateBefore = 0; testMouseWidget->mouseReleaseStateAfter = 0; - testMouseWidget->mouseMoveStateBefore = 0; - testMouseWidget->mouseMoveStateAfter = 0; #endif testMouseWidget->mousePressButton = 0; testMouseWidget->mousePressButtons = 0; @@ -195,9 +169,6 @@ void tst_QMouseEvent::init() testMouseWidget->mouseReleaseButton = 0; testMouseWidget->mouseReleaseButtons = 0; testMouseWidget->mouseReleaseModifiers = 0; - testMouseWidget->mouseMoveButton = 0; - testMouseWidget->mouseMoveButtons = 0; - testMouseWidget->mouseMoveModifiers = 0; } void tst_QMouseEvent::cleanup() @@ -294,52 +265,6 @@ void tst_QMouseEvent::checkMouseReleaseEvent() #endif } -void tst_QMouseEvent::checkMouseMoveEvent_data() -{ - QTest::addColumn("buttonMoved"); - QTest::addColumn("keyPressed"); - - QTest::newRow("leftButton-nokey") << int(Qt::LeftButton) << int(Qt::NoButton); - QTest::newRow("leftButton-shiftkey") << int(Qt::LeftButton) << int(Qt::ShiftModifier); - QTest::newRow("leftButton-controlkey") << int(Qt::LeftButton) << int(Qt::ControlModifier); - QTest::newRow("leftButton-altkey") << int(Qt::LeftButton) << int(Qt::AltModifier); - QTest::newRow("leftButton-metakey") << int(Qt::LeftButton) << int(Qt::MetaModifier); - QTest::newRow("rightButton-nokey") << int(Qt::RightButton) << int(Qt::NoButton); - QTest::newRow("rightButton-shiftkey") << int(Qt::RightButton) << int(Qt::ShiftModifier); - QTest::newRow("rightButton-controlkey") << int(Qt::RightButton) << int(Qt::ControlModifier); - QTest::newRow("rightButton-altkey") << int(Qt::RightButton) << int(Qt::AltModifier); - QTest::newRow("rightButton-metakey") << int(Qt::RightButton) << int(Qt::MetaModifier); - QTest::newRow("midButton-nokey") << int(Qt::MidButton) << int(Qt::NoButton); - QTest::newRow("midButton-shiftkey") << int(Qt::MidButton) << int(Qt::ShiftModifier); - QTest::newRow("midButton-controlkey") << int(Qt::MidButton) << int(Qt::ControlModifier); - QTest::newRow("midButton-altkey") << int(Qt::MidButton) << int(Qt::AltModifier); - QTest::newRow("midButton-metakey") << int(Qt::MidButton) << int(Qt::MetaModifier); -} - -void tst_QMouseEvent::checkMouseMoveEvent() -{ - QFETCH(int,buttonMoved); - QFETCH(int,keyPressed); - int button = (int)Qt::NoButton; - int buttons = buttonMoved; - int modifiers = keyPressed; - - QTest::mousePress(testMouseWidget, Qt::MouseButton(buttonMoved), Qt::KeyboardModifiers(keyPressed)); - QTest::mouseMove(testMouseWidget, QPoint(10,10)); - QVERIFY(testMouseWidget->mouseMoveEventRecieved); - QCOMPARE(testMouseWidget->mouseMoveButton, button); - QCOMPARE(testMouseWidget->mouseMoveButtons, buttons); - QCOMPARE(testMouseWidget->mouseMoveModifiers, modifiers); -#ifdef QT3_SUPPORT - int stateAfter = buttons|modifiers; - int stateBefore = stateAfter|button; - - QCOMPARE(testMouseWidget->mouseMoveStateBefore, stateBefore); - QCOMPARE(testMouseWidget->mouseMoveStateAfter, stateAfter); -#endif - QTest::mouseRelease(testMouseWidget, Qt::MouseButton(buttonMoved), Qt::KeyboardModifiers(keyPressed)); -} - void tst_QMouseEvent::qt3supportConstructors() { #if !defined(QT3_SUPPORT) -- cgit v0.12 From 85b7896a47f9bb622b394107769cb7c1121a6995 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 30 Oct 2009 12:40:13 +0100 Subject: QItemSelectionModel could emit selectionChanged with no change Task-number: QTBUG-560 Reviewed-by: ogoffart --- src/gui/itemviews/qitemselectionmodel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp index f2ccb6e..c6e02a6 100644 --- a/src/gui/itemviews/qitemselectionmodel.cpp +++ b/src/gui/itemviews/qitemselectionmodel.cpp @@ -1587,7 +1587,8 @@ void QItemSelectionModel::emitSelectionChanged(const QItemSelection &newSelectio } } - emit selectionChanged(selected, deselected); + if (!selected.isEmpty() || !deselected.isEmpty()) + emit selectionChanged(selected, deselected); } #ifndef QT_NO_DEBUG_STREAM -- cgit v0.12 From 180e36e586437ffb751166f0088329ecbec3001e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Fri, 30 Oct 2009 13:43:40 +0200 Subject: S60Style: List items should be taller for touch use (5th Edition) This fixes private JIRA issue: QT-1479. The change makes itemview items taller by twice the QStyle::PM_FocusFrameVMargin amount (both margins) when touch is in use. It is rather curious that the QCommonStyle modifies QRect for itemviews in horizontal direction by twice the QStyle::PM_FocusFrameHMargin amount, but does not do it in vertical direction. Task-number: QT-1479 (private) Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index b87f3a8..dc38397 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2266,10 +2266,19 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz += QSize(2*f->lineWidth, 4*f->lineWidth); break; case CT_TabBarTab: - QSize naviPaneSize = QS60StylePrivate::naviPaneSize(); + { + const QSize naviPaneSize = QS60StylePrivate::naviPaneSize(); + sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget); + if (naviPaneSize.height() > sz.height()) + sz.setHeight(naviPaneSize.height()); + } + break; + case CT_ItemViewItem: sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); - if (naviPaneSize.height() > sz.height()) - sz.setHeight(naviPaneSize.height()); + if (QS60StylePrivate::isTouchSupported()) + //Make itemview easier to use in touch devices + //QCommonStyle does not adjust height with horizontal margin, it only adjusts width + sz.setHeight(sz.height() + 2*pixelMetric(QStyle::PM_FocusFrameVMargin)); break; default: sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); -- cgit v0.12 From e662c6a07a01506bd14b57790a887d5c68b79420 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 20 Oct 2009 16:42:06 +0200 Subject: Refactor of shader manager to not use partial shaders This is a first step towards supporting binary shaders. Note: This change will introduce a (rare) leak of shader objects, as the shaders will never be kicked out from the cache (because the cache is still a QList) :-) This will be corrected by the next patch. Reviewed-By: Samuel --- .../gl2paintengineex/qglcustomshaderstage.cpp | 21 +- .../gl2paintengineex/qglcustomshaderstage_p.h | 3 +- .../gl2paintengineex/qglengineshadermanager.cpp | 340 ++++++++++----------- .../gl2paintengineex/qglengineshadermanager_p.h | 64 ++-- 4 files changed, 211 insertions(+), 217 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglcustomshaderstage.cpp b/src/opengl/gl2paintengineex/qglcustomshaderstage.cpp index ab2026c..b71a7b7 100644 --- a/src/opengl/gl2paintengineex/qglcustomshaderstage.cpp +++ b/src/opengl/gl2paintengineex/qglcustomshaderstage.cpp @@ -67,8 +67,10 @@ QGLCustomShaderStage::QGLCustomShaderStage() QGLCustomShaderStage::~QGLCustomShaderStage() { Q_D(QGLCustomShaderStage); - if (d->m_manager) - d->m_manager->removeCustomStage(this); + if (d->m_manager) { + d->m_manager->removeCustomStage(); + d->m_manager->sharedShaders->cleanupCustomStage(this); + } } void QGLCustomShaderStage::setUniformsDirty() @@ -85,6 +87,8 @@ bool QGLCustomShaderStage::setOnPainter(QPainter* p) qWarning("QGLCustomShaderStage::setOnPainter() - paint engine not OpenGL2"); return false; } + if (d->m_manager) + qWarning("Custom shader is already set on a painter"); QGL2PaintEngineEx *engine = static_cast(p->paintEngine()); d->m_manager = QGL2PaintEngineExPrivate::shaderManagerForEngine(engine); @@ -108,12 +112,21 @@ void QGLCustomShaderStage::removeFromPainter(QPainter* p) // This should leave the program in a compiled/linked state // if the next custom shader stage is this one again. d->m_manager->setCustomStage(0); + d->m_manager = 0; } -const char* QGLCustomShaderStage::source() const +QByteArray QGLCustomShaderStage::source() const { Q_D(const QGLCustomShaderStage); - return d->m_source.constData(); + return d->m_source; +} + +// Called by the shader manager if another custom shader is attached or +// the manager is deleted +void QGLCustomShaderStage::setInactive() +{ + Q_D(QGLCustomShaderStage); + d->m_manager = 0; } void QGLCustomShaderStage::setSource(const QByteArray& s) diff --git a/src/opengl/gl2paintengineex/qglcustomshaderstage_p.h b/src/opengl/gl2paintengineex/qglcustomshaderstage_p.h index f8c13c5..e319389 100644 --- a/src/opengl/gl2paintengineex/qglcustomshaderstage_p.h +++ b/src/opengl/gl2paintengineex/qglcustomshaderstage_p.h @@ -74,8 +74,9 @@ public: bool setOnPainter(QPainter*); void removeFromPainter(QPainter*); - const char* source() const; + QByteArray source() const; + void setInactive(); protected: void setSource(const QByteArray&); diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index af9306f..9dc2b53 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -78,7 +78,6 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) , blitShaderProg(0) , simpleShaderProg(0) { - memset(compiledShaders, 0, sizeof(compiledShaders)); /* Rather than having the shader source array statically initialised, it is initialised @@ -121,7 +120,7 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) code[ImageSrcFragmentShader] = qglslImageSrcFragmentShader; code[ImageSrcWithPatternFragmentShader] = qglslImageSrcWithPatternFragmentShader; code[NonPremultipliedImageSrcFragmentShader] = qglslNonPremultipliedImageSrcFragmentShader; - code[CustomImageSrcFragmentShader] = ""; // Supplied by app. + code[CustomImageSrcFragmentShader] = qglslCustomSrcFragmentShader; // Calls "customShader", which must be appended code[SolidBrushSrcFragmentShader] = qglslSolidBrushSrcFragmentShader; code[TextureBrushSrcFragmentShader] = qglslTextureBrushSrcFragmentShader; code[TextureBrushSrcWithPatternFragmentShader] = qglslTextureBrushSrcWithPatternFragmentShader; @@ -163,16 +162,26 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) qglEngineShaderSourceCodePopulated = true; } + QGLShader* fragShader; + QGLShader* vertexShader; + QByteArray source; + // Compile up the simple shader: + source.clear(); + source.append(qglEngineShaderSourceCode[MainVertexShader]); + source.append(qglEngineShaderSourceCode[PositionOnlyVertexShader]); + vertexShader = new QGLShader(QGLShader::VertexShader, context, this); + vertexShader->compile(source); + + source.clear(); + source.append(qglEngineShaderSourceCode[MainFragmentShader]); + source.append(qglEngineShaderSourceCode[ShockingPinkSrcFragmentShader]); + fragShader = new QGLShader(QGLShader::FragmentShader, context, this); + fragShader->compile(source); + simpleShaderProg = new QGLShaderProgram(context, this); - compileNamedShader(MainVertexShader, QGLShader::PartialVertexShader); - compileNamedShader(PositionOnlyVertexShader, QGLShader::PartialVertexShader); - compileNamedShader(MainFragmentShader, QGLShader::PartialFragmentShader); - compileNamedShader(ShockingPinkSrcFragmentShader, QGLShader::PartialFragmentShader); - simpleShaderProg->addShader(compiledShaders[MainVertexShader]); - simpleShaderProg->addShader(compiledShaders[PositionOnlyVertexShader]); - simpleShaderProg->addShader(compiledShaders[MainFragmentShader]); - simpleShaderProg->addShader(compiledShaders[ShockingPinkSrcFragmentShader]); + simpleShaderProg->addShader(vertexShader); + simpleShaderProg->addShader(fragShader); simpleShaderProg->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); simpleShaderProg->link(); if (!simpleShaderProg->isLinked()) { @@ -181,82 +190,29 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) } // Compile the blit shader: + source.clear(); + source.append(qglEngineShaderSourceCode[MainWithTexCoordsVertexShader]); + source.append(qglEngineShaderSourceCode[UntransformedPositionVertexShader]); + vertexShader = new QGLShader(QGLShader::VertexShader, context, this); + vertexShader->compile(source); + + source.clear(); + source.append(qglEngineShaderSourceCode[MainFragmentShader]); + source.append(qglEngineShaderSourceCode[ImageSrcFragmentShader]); + fragShader = new QGLShader(QGLShader::FragmentShader, context, this); + fragShader->compile(source); + blitShaderProg = new QGLShaderProgram(context, this); - compileNamedShader(MainWithTexCoordsVertexShader, QGLShader::PartialVertexShader); - compileNamedShader(UntransformedPositionVertexShader, QGLShader::PartialVertexShader); - compileNamedShader(MainFragmentShader, QGLShader::PartialFragmentShader); - compileNamedShader(ImageSrcFragmentShader, QGLShader::PartialFragmentShader); - blitShaderProg->addShader(compiledShaders[MainWithTexCoordsVertexShader]); - blitShaderProg->addShader(compiledShaders[UntransformedPositionVertexShader]); - blitShaderProg->addShader(compiledShaders[MainFragmentShader]); - blitShaderProg->addShader(compiledShaders[ImageSrcFragmentShader]); + blitShaderProg->addShader(vertexShader); + blitShaderProg->addShader(fragShader); blitShaderProg->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR); blitShaderProg->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); blitShaderProg->link(); if (!blitShaderProg->isLinked()) { qCritical() << "Errors linking blit shader:" - << blitShaderProg->log(); - } -} - -void QGLEngineSharedShaders::shaderDestroyed(QObject *shader) -{ - // Remove any shader programs which has this as the srcPixel shader: - for (int i = 0; i < cachedPrograms.size(); ++i) { - if (cachedPrograms.at(i).srcPixelFragShader == shader) { - delete cachedPrograms.at(i).program; - cachedPrograms.removeAt(i--); - } + << simpleShaderProg->log(); } - emit shaderProgNeedsChanging(); -} - -QGLShader *QGLEngineSharedShaders::compileNamedShader(ShaderName name, QGLShader::ShaderType type) -{ - Q_ASSERT(name != CustomImageSrcFragmentShader); - Q_ASSERT(name < InvalidShaderName); - - if (compiledShaders[name]) - return compiledShaders[name]; - - QByteArray source = qglEngineShaderSourceCode[name]; - QGLShader *newShader = new QGLShader(type, ctxGuard.context(), this); - newShader->compile(source); - -#if defined(QT_DEBUG) - // Name the shader for easier debugging - QMetaEnum m = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("ShaderName")); - newShader->setObjectName(QLatin1String(m.valueToKey(name))); -#endif - - compiledShaders[name] = newShader; - return newShader; -} - -QGLShader *QGLEngineSharedShaders::compileCustomShader(QGLCustomShaderStage *stage, QGLShader::ShaderType type) -{ - QByteArray source = stage->source(); - source += qglslCustomSrcFragmentShader; - - QGLShader *newShader = customShaderCache.object(source); - if (newShader) - return newShader; - - newShader = new QGLShader(type, ctxGuard.context(), this); - newShader->compile(source); - customShaderCache.insert(source, newShader); - - connect(newShader, SIGNAL(destroyed(QObject *)), - this, SLOT(shaderDestroyed(QObject *))); - -#if defined(QT_DEBUG) - // Name the shader for easier debugging - QMetaEnum m = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("ShaderName")); - newShader->setObjectName(QLatin1String(m.valueToKey(CustomImageSrcFragmentShader))); -#endif - - return newShader; } // The address returned here will only be valid until next time this function is called. @@ -270,14 +226,54 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS cachedPrograms.append(prog); QGLEngineShaderProg &cached = cachedPrograms.last(); + QByteArray source; + source.append(qglEngineShaderSourceCode[prog.mainFragShader]); + source.append(qglEngineShaderSourceCode[prog.srcPixelFragShader]); + if (prog.srcPixelFragShader == CustomImageSrcFragmentShader) + source.append(prog.customStageSource); + if (prog.compositionFragShader) + source.append(qglEngineShaderSourceCode[prog.compositionFragShader]); + if (prog.maskFragShader) + source.append(qglEngineShaderSourceCode[prog.maskFragShader]); + QGLShader* fragShader = new QGLShader(QGLShader::FragmentShader, ctxGuard.context(), this); + fragShader->compile(source); + + source.clear(); + source.append(qglEngineShaderSourceCode[prog.mainVertexShader]); + source.append(qglEngineShaderSourceCode[prog.positionVertexShader]); + QGLShader* vertexShader = new QGLShader(QGLShader::VertexShader, ctxGuard.context(), this); + vertexShader->compile(source); + +#if defined(QT_DEBUG) + // Name the shaders for easier debugging + QMetaEnum m = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("ShaderName")); + QByteArray description; + description.append("Fragment shader: main="); + description.append(m.valueToKey(prog.mainFragShader)); + description.append(", srcPixel="); + description.append(m.valueToKey(prog.srcPixelFragShader)); + if (prog.compositionFragShader) { + description.append(", composition="); + description.append(m.valueToKey(prog.compositionFragShader)); + } + if (prog.maskFragShader) { + description.append(", mask="); + description.append(m.valueToKey(prog.maskFragShader)); + } + fragShader->setObjectName(QString::fromLatin1(description)); + + description.clear(); + description.append("Vertex shader: main="); + description.append(m.valueToKey(prog.mainVertexShader)); + description.append(", position="); + description.append(m.valueToKey(prog.positionVertexShader)); + vertexShader->setObjectName(QString::fromLatin1(description)); +#endif + // If the shader program's not found in the cache, create it now. cached.program = new QGLShaderProgram(ctxGuard.context(), this); - cached.program->addShader(cached.mainVertexShader); - cached.program->addShader(cached.positionVertexShader); - cached.program->addShader(cached.mainFragShader); - cached.program->addShader(cached.srcPixelFragShader); - cached.program->addShader(cached.maskFragShader); - cached.program->addShader(cached.compositionFragShader); + cached.program->addShader(vertexShader); + cached.program->addShader(fragShader); // We have to bind the vertex attribute names before the program is linked: cached.program->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); @@ -294,25 +290,11 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS error = QLatin1String("Shader program failed to link,") #if defined(QT_DEBUG) + br - + QLatin1String(" Shaders Used:\n") - + QLatin1String(" mainVertexShader = ") - + (cached.mainVertexShader ? - cached.mainVertexShader->objectName() : none) + br - + QLatin1String(" positionVertexShader = ") - + (cached.positionVertexShader ? - cached.positionVertexShader->objectName() : none) + br - + QLatin1String(" mainFragShader = ") - + (cached.mainFragShader ? - cached.mainFragShader->objectName() : none) + br - + QLatin1String(" srcPixelFragShader = ") - + (cached.srcPixelFragShader ? - cached.srcPixelFragShader->objectName() : none) + br - + QLatin1String(" maskFragShader = ") - + (cached.maskFragShader ? - cached.maskFragShader->objectName() : none) + br - + QLatin1String(" compositionFragShader = ") - + (cached.compositionFragShader ? - cached.compositionFragShader->objectName() : none) + br + + QLatin1String(" Shaders Used:") + br + + QLatin1String(" ") + vertexShader->objectName() + QLatin1String(": ") + br + + QLatin1String(vertexShader->sourceCode()) + br + + QLatin1String(" ") + fragShader->objectName() + QLatin1String(": ") + br + + QLatin1String(fragShader->sourceCode()) + br #endif + QLatin1String(" Error Log:\n") + QLatin1String(" ") + cached.program->log(); @@ -327,6 +309,20 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS } } + +void QGLEngineSharedShaders::cleanupCustomStage(QGLCustomShaderStage* stage) +{ + // Remove any shader programs which has this as the custom shader src: + for (int i = 0; i < cachedPrograms.size(); ++i) { + if (cachedPrograms.at(i).customStageSource == stage->source()) { + delete cachedPrograms.at(i).program; + cachedPrograms.removeAt(i--); + } + } +} + + + QGLEngineShaderManager::QGLEngineShaderManager(QGLContext* context) : ctx(context), shaderProgNeedsChanging(true), @@ -335,8 +331,7 @@ QGLEngineShaderManager::QGLEngineShaderManager(QGLContext* context) maskType(NoMask), compositionMode(QPainter::CompositionMode_SourceOver), customSrcStage(0), - currentShaderProg(0), - customShader(0) + currentShaderProg(0) { sharedShaders = QGLEngineSharedShaders::shadersForContext(context); connect(sharedShaders, SIGNAL(shaderProgNeedsChanging()), this, SLOT(shaderProgNeedsChangingSlot())); @@ -345,6 +340,7 @@ QGLEngineShaderManager::QGLEngineShaderManager(QGLContext* context) QGLEngineShaderManager::~QGLEngineShaderManager() { //### + removeCustomStage(); } uint QGLEngineShaderManager::getUniformLocation(Uniform id) @@ -436,21 +432,20 @@ void QGLEngineShaderManager::setCompositionMode(QPainter::CompositionMode mode) void QGLEngineShaderManager::setCustomStage(QGLCustomShaderStage* stage) { + if (customSrcStage) + removeCustomStage(); customSrcStage = stage; - customShader = 0; // Will be compiled from 'customSrcStage' later. shaderProgNeedsChanging = true; } -void QGLEngineShaderManager::removeCustomStage(QGLCustomShaderStage* stage) +void QGLEngineShaderManager::removeCustomStage() { - Q_UNUSED(stage); // Currently we only support one at a time... - + if (customSrcStage) + customSrcStage->setInactive(); customSrcStage = 0; - customShader = 0; shaderProgNeedsChanging = true; } - QGLShaderProgram* QGLEngineShaderManager::currentProgram() { return currentShaderProg->program; @@ -488,16 +483,16 @@ bool QGLEngineShaderManager::useCorrectShaderProg() // Choose vertex shader shader position function (which typically also sets // varyings) and the source pixel (srcPixel) fragment shader function: - QGLEngineSharedShaders::ShaderName positionVertexShaderName = QGLEngineSharedShaders::InvalidShaderName; - QGLEngineSharedShaders::ShaderName srcPixelFragShaderName = QGLEngineSharedShaders::InvalidShaderName; + requiredProgram.positionVertexShader = QGLEngineSharedShaders::InvalidShaderName; + requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::InvalidShaderName; bool isAffine = brushTransform.isAffine(); if ( (srcPixelType >= Qt::Dense1Pattern) && (srcPixelType <= Qt::DiagCrossPattern) ) { if (isAffine) - positionVertexShaderName = QGLEngineSharedShaders::AffinePositionWithPatternBrushVertexShader; + requiredProgram.positionVertexShader = QGLEngineSharedShaders::AffinePositionWithPatternBrushVertexShader; else - positionVertexShaderName = QGLEngineSharedShaders::PositionWithPatternBrushVertexShader; + requiredProgram.positionVertexShader = QGLEngineSharedShaders::PositionWithPatternBrushVertexShader; - srcPixelFragShaderName = QGLEngineSharedShaders::PatternBrushSrcFragmentShader; + requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::PatternBrushSrcFragmentShader; } else switch (srcPixelType) { default: @@ -505,172 +500,157 @@ bool QGLEngineShaderManager::useCorrectShaderProg() qFatal("QGLEngineShaderManager::useCorrectShaderProg() - Qt::NoBrush style is set"); break; case QGLEngineShaderManager::ImageSrc: - srcPixelFragShaderName = QGLEngineSharedShaders::ImageSrcFragmentShader; - positionVertexShaderName = QGLEngineSharedShaders::PositionOnlyVertexShader; + requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::ImageSrcFragmentShader; + requiredProgram.positionVertexShader = QGLEngineSharedShaders::PositionOnlyVertexShader; texCoords = true; break; case QGLEngineShaderManager::NonPremultipliedImageSrc: - srcPixelFragShaderName = QGLEngineSharedShaders::NonPremultipliedImageSrcFragmentShader; - positionVertexShaderName = QGLEngineSharedShaders::PositionOnlyVertexShader; + requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::NonPremultipliedImageSrcFragmentShader; + requiredProgram.positionVertexShader = QGLEngineSharedShaders::PositionOnlyVertexShader; texCoords = true; break; case QGLEngineShaderManager::PatternSrc: - srcPixelFragShaderName = QGLEngineSharedShaders::ImageSrcWithPatternFragmentShader; - positionVertexShaderName = QGLEngineSharedShaders::PositionOnlyVertexShader; + requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::ImageSrcWithPatternFragmentShader; + requiredProgram.positionVertexShader = QGLEngineSharedShaders::PositionOnlyVertexShader; texCoords = true; break; case QGLEngineShaderManager::TextureSrcWithPattern: - srcPixelFragShaderName = QGLEngineSharedShaders::TextureBrushSrcWithPatternFragmentShader; - positionVertexShaderName = isAffine ? QGLEngineSharedShaders::AffinePositionWithTextureBrushVertexShader + requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::TextureBrushSrcWithPatternFragmentShader; + requiredProgram.positionVertexShader = isAffine ? QGLEngineSharedShaders::AffinePositionWithTextureBrushVertexShader : QGLEngineSharedShaders::PositionWithTextureBrushVertexShader; break; case Qt::SolidPattern: - srcPixelFragShaderName = QGLEngineSharedShaders::SolidBrushSrcFragmentShader; - positionVertexShaderName = QGLEngineSharedShaders::PositionOnlyVertexShader; + requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::SolidBrushSrcFragmentShader; + requiredProgram.positionVertexShader = QGLEngineSharedShaders::PositionOnlyVertexShader; break; case Qt::LinearGradientPattern: - srcPixelFragShaderName = QGLEngineSharedShaders::LinearGradientBrushSrcFragmentShader; - positionVertexShaderName = isAffine ? QGLEngineSharedShaders::AffinePositionWithLinearGradientBrushVertexShader + requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::LinearGradientBrushSrcFragmentShader; + requiredProgram.positionVertexShader = isAffine ? QGLEngineSharedShaders::AffinePositionWithLinearGradientBrushVertexShader : QGLEngineSharedShaders::PositionWithLinearGradientBrushVertexShader; break; case Qt::ConicalGradientPattern: - srcPixelFragShaderName = QGLEngineSharedShaders::ConicalGradientBrushSrcFragmentShader; - positionVertexShaderName = isAffine ? QGLEngineSharedShaders::AffinePositionWithConicalGradientBrushVertexShader + requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::ConicalGradientBrushSrcFragmentShader; + requiredProgram.positionVertexShader = isAffine ? QGLEngineSharedShaders::AffinePositionWithConicalGradientBrushVertexShader : QGLEngineSharedShaders::PositionWithConicalGradientBrushVertexShader; break; case Qt::RadialGradientPattern: - srcPixelFragShaderName = QGLEngineSharedShaders::RadialGradientBrushSrcFragmentShader; - positionVertexShaderName = isAffine ? QGLEngineSharedShaders::AffinePositionWithRadialGradientBrushVertexShader + requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::RadialGradientBrushSrcFragmentShader; + requiredProgram.positionVertexShader = isAffine ? QGLEngineSharedShaders::AffinePositionWithRadialGradientBrushVertexShader : QGLEngineSharedShaders::PositionWithRadialGradientBrushVertexShader; break; case Qt::TexturePattern: - srcPixelFragShaderName = QGLEngineSharedShaders::TextureBrushSrcFragmentShader; - positionVertexShaderName = isAffine ? QGLEngineSharedShaders::AffinePositionWithTextureBrushVertexShader + requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::TextureBrushSrcFragmentShader; + requiredProgram.positionVertexShader = isAffine ? QGLEngineSharedShaders::AffinePositionWithTextureBrushVertexShader : QGLEngineSharedShaders::PositionWithTextureBrushVertexShader; break; }; - requiredProgram.positionVertexShader = sharedShaders->compileNamedShader(positionVertexShaderName, QGLShader::PartialVertexShader); + if (useCustomSrc) { - if (!customShader) - customShader = sharedShaders->compileCustomShader(customSrcStage, QGLShader::PartialFragmentShader); - requiredProgram.srcPixelFragShader = customShader; - } else { - requiredProgram.srcPixelFragShader = sharedShaders->compileNamedShader(srcPixelFragShaderName, QGLShader::PartialFragmentShader); + requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::CustomImageSrcFragmentShader; + requiredProgram.customStageSource = customSrcStage->source(); } const bool hasCompose = compositionMode > QPainter::CompositionMode_Plus; const bool hasMask = maskType != QGLEngineShaderManager::NoMask; // Choose fragment shader main function: - QGLEngineSharedShaders::ShaderName mainFragShaderName; - if (opacityMode == AttributeOpacity) { Q_ASSERT(!hasCompose && !hasMask); - mainFragShaderName = QGLEngineSharedShaders::MainFragmentShader_ImageArrays; + requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader_ImageArrays; } else { bool useGlobalOpacity = (opacityMode == UniformOpacity); if (hasCompose && hasMask && useGlobalOpacity) - mainFragShaderName = QGLEngineSharedShaders::MainFragmentShader_CMO; + requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader_CMO; if (hasCompose && hasMask && !useGlobalOpacity) - mainFragShaderName = QGLEngineSharedShaders::MainFragmentShader_CM; + requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader_CM; if (!hasCompose && hasMask && useGlobalOpacity) - mainFragShaderName = QGLEngineSharedShaders::MainFragmentShader_MO; + requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader_MO; if (!hasCompose && hasMask && !useGlobalOpacity) - mainFragShaderName = QGLEngineSharedShaders::MainFragmentShader_M; + requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader_M; if (hasCompose && !hasMask && useGlobalOpacity) - mainFragShaderName = QGLEngineSharedShaders::MainFragmentShader_CO; + requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader_CO; if (hasCompose && !hasMask && !useGlobalOpacity) - mainFragShaderName = QGLEngineSharedShaders::MainFragmentShader_C; + requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader_C; if (!hasCompose && !hasMask && useGlobalOpacity) - mainFragShaderName = QGLEngineSharedShaders::MainFragmentShader_O; + requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader_O; if (!hasCompose && !hasMask && !useGlobalOpacity) - mainFragShaderName = QGLEngineSharedShaders::MainFragmentShader; + requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader; } - requiredProgram.mainFragShader = sharedShaders->compileNamedShader(mainFragShaderName, QGLShader::PartialFragmentShader); - if (hasMask) { - QGLEngineSharedShaders::ShaderName maskShaderName = QGLEngineSharedShaders::InvalidShaderName; if (maskType == PixelMask) { - maskShaderName = QGLEngineSharedShaders::MaskFragmentShader; + requiredProgram.maskFragShader = QGLEngineSharedShaders::MaskFragmentShader; texCoords = true; } else if (maskType == SubPixelMaskPass1) { - maskShaderName = QGLEngineSharedShaders::RgbMaskFragmentShaderPass1; + requiredProgram.maskFragShader = QGLEngineSharedShaders::RgbMaskFragmentShaderPass1; texCoords = true; } else if (maskType == SubPixelMaskPass2) { - maskShaderName = QGLEngineSharedShaders::RgbMaskFragmentShaderPass2; + requiredProgram.maskFragShader = QGLEngineSharedShaders::RgbMaskFragmentShaderPass2; texCoords = true; } else if (maskType == SubPixelWithGammaMask) { - maskShaderName = QGLEngineSharedShaders::RgbMaskWithGammaFragmentShader; + requiredProgram.maskFragShader = QGLEngineSharedShaders::RgbMaskWithGammaFragmentShader; texCoords = true; } else { qCritical("QGLEngineShaderManager::useCorrectShaderProg() - Unknown mask type"); } - - requiredProgram.maskFragShader = sharedShaders->compileNamedShader(maskShaderName, QGLShader::PartialFragmentShader); } else { requiredProgram.maskFragShader = 0; } if (hasCompose) { - QGLEngineSharedShaders::ShaderName compositionShaderName = QGLEngineSharedShaders::InvalidShaderName; switch (compositionMode) { case QPainter::CompositionMode_Multiply: - compositionShaderName = QGLEngineSharedShaders::MultiplyCompositionModeFragmentShader; + requiredProgram.compositionFragShader = QGLEngineSharedShaders::MultiplyCompositionModeFragmentShader; break; case QPainter::CompositionMode_Screen: - compositionShaderName = QGLEngineSharedShaders::ScreenCompositionModeFragmentShader; + requiredProgram.compositionFragShader = QGLEngineSharedShaders::ScreenCompositionModeFragmentShader; break; case QPainter::CompositionMode_Overlay: - compositionShaderName = QGLEngineSharedShaders::OverlayCompositionModeFragmentShader; + requiredProgram.compositionFragShader = QGLEngineSharedShaders::OverlayCompositionModeFragmentShader; break; case QPainter::CompositionMode_Darken: - compositionShaderName = QGLEngineSharedShaders::DarkenCompositionModeFragmentShader; + requiredProgram.compositionFragShader = QGLEngineSharedShaders::DarkenCompositionModeFragmentShader; break; case QPainter::CompositionMode_Lighten: - compositionShaderName = QGLEngineSharedShaders::LightenCompositionModeFragmentShader; + requiredProgram.compositionFragShader = QGLEngineSharedShaders::LightenCompositionModeFragmentShader; break; case QPainter::CompositionMode_ColorDodge: - compositionShaderName = QGLEngineSharedShaders::ColorDodgeCompositionModeFragmentShader; + requiredProgram.compositionFragShader = QGLEngineSharedShaders::ColorDodgeCompositionModeFragmentShader; break; case QPainter::CompositionMode_ColorBurn: - compositionShaderName = QGLEngineSharedShaders::ColorBurnCompositionModeFragmentShader; + requiredProgram.compositionFragShader = QGLEngineSharedShaders::ColorBurnCompositionModeFragmentShader; break; case QPainter::CompositionMode_HardLight: - compositionShaderName = QGLEngineSharedShaders::HardLightCompositionModeFragmentShader; + requiredProgram.compositionFragShader = QGLEngineSharedShaders::HardLightCompositionModeFragmentShader; break; case QPainter::CompositionMode_SoftLight: - compositionShaderName = QGLEngineSharedShaders::SoftLightCompositionModeFragmentShader; + requiredProgram.compositionFragShader = QGLEngineSharedShaders::SoftLightCompositionModeFragmentShader; break; case QPainter::CompositionMode_Difference: - compositionShaderName = QGLEngineSharedShaders::DifferenceCompositionModeFragmentShader; + requiredProgram.compositionFragShader = QGLEngineSharedShaders::DifferenceCompositionModeFragmentShader; break; case QPainter::CompositionMode_Exclusion: - compositionShaderName = QGLEngineSharedShaders::ExclusionCompositionModeFragmentShader; + requiredProgram.compositionFragShader = QGLEngineSharedShaders::ExclusionCompositionModeFragmentShader; break; default: qWarning("QGLEngineShaderManager::useCorrectShaderProg() - Unsupported composition mode"); } - requiredProgram.compositionFragShader = sharedShaders->compileNamedShader(compositionShaderName, QGLShader::PartialFragmentShader); } else { requiredProgram.compositionFragShader = 0; } - // Choose vertex shader main function - QGLEngineSharedShaders::ShaderName mainVertexShaderName = QGLEngineSharedShaders::InvalidShaderName; + // Choose vertex shader main function if (opacityMode == AttributeOpacity) { Q_ASSERT(texCoords); - mainVertexShaderName = QGLEngineSharedShaders::MainWithTexCoordsAndOpacityVertexShader; + requiredProgram.mainVertexShader = QGLEngineSharedShaders::MainWithTexCoordsAndOpacityVertexShader; } else if (texCoords) { - mainVertexShaderName = QGLEngineSharedShaders::MainWithTexCoordsVertexShader; + requiredProgram.mainVertexShader = QGLEngineSharedShaders::MainWithTexCoordsVertexShader; } else { - mainVertexShaderName = QGLEngineSharedShaders::MainVertexShader; + requiredProgram.mainVertexShader = QGLEngineSharedShaders::MainVertexShader; } - requiredProgram.mainVertexShader = sharedShaders->compileNamedShader(mainVertexShaderName, QGLShader::PartialVertexShader); requiredProgram.useTextureCoords = texCoords; requiredProgram.useOpacityAttribute = (opacityMode == AttributeOpacity); - // At this point, requiredProgram is fully populated so try to find the program in the cache currentShaderProg = sharedShaders->findProgramInCache(requiredProgram); diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index 291d24c..e4f7aa6 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -234,14 +234,16 @@ QT_BEGIN_NAMESPACE QT_MODULE(OpenGL) + struct QGLEngineShaderProg { - QGLShader* mainVertexShader; - QGLShader* positionVertexShader; - QGLShader* mainFragShader; - QGLShader* srcPixelFragShader; - QGLShader* maskFragShader; // Can be null for no mask - QGLShader* compositionFragShader; // Can be null for GL-handled mode + int mainVertexShader; + int positionVertexShader; + int mainFragShader; + int srcPixelFragShader; + int maskFragShader; + int compositionFragShader; + QByteArray customStageSource; //TODO: Decent cache key for custom stages QGLShaderProgram* program; QVector uniformLocations; @@ -256,7 +258,8 @@ struct QGLEngineShaderProg mainFragShader == other.mainFragShader && srcPixelFragShader == other.srcPixelFragShader && maskFragShader == other.maskFragShader && - compositionFragShader == other.compositionFragShader + compositionFragShader == other.compositionFragShader && + customStageSource == other.customStageSource ); } }; @@ -344,33 +347,44 @@ public: TotalShaderCount, InvalidShaderName }; +#if defined (QT_DEBUG) + Q_ENUMS(ShaderName) +#endif - QGLEngineSharedShaders(const QGLContext *context); +/* + // These allow the ShaderName enum to be used as a cache key + const int mainVertexOffset = 0; + const int positionVertexOffset = (1<<2) - PositionOnlyVertexShader; + const int mainFragOffset = (1<<6) - MainFragmentShader_CMO; + const int srcPixelOffset = (1<<10) - ImageSrcFragmentShader; + const int maskOffset = (1<<14) - NoMaskShader; + const int compositionOffset = (1 << 16) - MultiplyCompositionModeFragmentShader; +*/ - QGLShader *compileNamedShader(ShaderName name, QGLShader::ShaderType type); + QGLEngineSharedShaders(const QGLContext *context); QGLShaderProgram *simpleProgram() { return simpleShaderProg; } QGLShaderProgram *blitProgram() { return blitShaderProg; } // Compile the program if it's not already in the cache, return the item in the cache. QGLEngineShaderProg *findProgramInCache(const QGLEngineShaderProg &prog); // Compile the custom shader if it's not already in the cache, return the item in the cache. - QGLShader *compileCustomShader(QGLCustomShaderStage *stage, QGLShader::ShaderType type); static QGLEngineSharedShaders *shadersForContext(const QGLContext *context); + // Ideally, this would be static and cleanup all programs in all contexts which + // contain the custom code. Currently it is just a hint and we rely on deleted + // custom shaders being cleaned up by being kicked out of the cache when it's + // full. + void cleanupCustomStage(QGLCustomShaderStage* stage); + signals: void shaderProgNeedsChanging(); -private slots: - void shaderDestroyed(QObject *shader); - private: QGLSharedResourceGuard ctxGuard; QGLShaderProgram *blitShaderProg; QGLShaderProgram *simpleShaderProg; QList cachedPrograms; - QCache customShaderCache; - QGLShader* compiledShaders[TotalShaderCount]; static const char* qglEngineShaderSourceCode[TotalShaderCount]; }; @@ -426,7 +440,7 @@ public: void setMaskType(MaskType); void setCompositionMode(QPainter::CompositionMode); void setCustomStage(QGLCustomShaderStage* stage); - void removeCustomStage(QGLCustomShaderStage* stage); + void removeCustomStage(); uint getUniformLocation(Uniform id); @@ -437,19 +451,7 @@ public: QGLShaderProgram* simpleProgram(); // Used to draw into e.g. stencil buffers QGLShaderProgram* blitProgram(); // Used to blit a texture into the framebuffer -/* - // These allow the ShaderName enum to be used as a cache key - const int mainVertexOffset = 0; - const int positionVertexOffset = (1<<2) - PositionOnlyVertexShader; - const int mainFragOffset = (1<<6) - MainFragmentShader_CMO; - const int srcPixelOffset = (1<<10) - ImageSrcFragmentShader; - const int maskOffset = (1<<14) - NoMaskShader; - const int compositionOffset = (1 << 16) - MultiplyCompositionModeFragmentShader; -*/ - -#if defined (QT_DEBUG) - Q_ENUMS(ShaderName) -#endif + QGLEngineSharedShaders* sharedShaders; private slots: void shaderProgNeedsChangingSlot() { shaderProgNeedsChanging = true; } @@ -466,9 +468,7 @@ private: QPainter::CompositionMode compositionMode; QGLCustomShaderStage* customSrcStage; - QGLEngineShaderProg* currentShaderProg; - QGLEngineSharedShaders *sharedShaders; - QGLShader *customShader; + QGLEngineShaderProg* currentShaderProg; }; QT_END_NAMESPACE -- cgit v0.12 From 4e60cdcf222f607ccc49138035fb3d17140fee51 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 30 Oct 2009 13:54:24 +0200 Subject: Fixed keypad navigation in QFileDialog details view Made it possible to navigate out of QFileDialog details view using keypad navigation. Task-number: QTBUG-4793 Reviewed-by: Alessandro Portale --- src/gui/dialogs/qfiledialog.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index eab842f..50823cd 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -3187,7 +3187,17 @@ void QFileDialogTreeView::keyPressEvent(QKeyEvent *e) if (!d_ptr->itemViewKeyboardEvent(e)) { QTreeView::keyPressEvent(e); } +#ifdef QT_KEYPAD_NAVIGATION + else if ((QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder + || QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) + && !hasEditFocus()) { + e->ignore(); + } else { + e->accept(); + } +#else e->accept(); +#endif } QSize QFileDialogTreeView::sizeHint() const -- cgit v0.12 From 3a7804813d9dd4162e088bc19746abd20aaa7827 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 30 Oct 2009 13:23:27 +0100 Subject: Removed the margin in assistant on Mac. Change 9551b8c349ce4e15a57c24a2408ee1b73c2b7510 enabled documentMode on the tabbar in Assistant. To make it look more native we also remove the margin around the tabwidget. Reviewed-by: Prasanth --- tools/assistant/tools/assistant/centralwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 2722b2f..62b4736 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -222,8 +222,8 @@ CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent) QVBoxLayout *vboxLayout = new QVBoxLayout(this); QString resourcePath = QLatin1String(":/trolltech/assistant/images/"); -#ifndef Q_OS_MAC vboxLayout->setMargin(0); +#ifndef Q_OS_MAC resourcePath.append(QLatin1String("win")); #else resourcePath.append(QLatin1String("mac")); -- cgit v0.12 From d025ebb1a8163cd1f03151927486cf62c5e77957 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 30 Oct 2009 09:55:20 +0100 Subject: Fixes regression in QComboBox with keypad navigation while mouse is over the popup The problem is that is we move the selection with the keyboard in a way that causes the view to scroll, the current selection would jump. This happends since commit 9cb231d773db6deb that fixed the emission of the enter signal when the view is scrolled. We Therefor cannot use the enter signal. Catch manually the mouse move events to update the selection instead. Reviewed-by: Thierry --- src/gui/widgets/qcombobox.cpp | 24 ++++------------ src/gui/widgets/qcombobox_p.h | 1 - tests/auto/qcombobox/tst_qcombobox.cpp | 52 ++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 19 deletions(-) diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 6dbf15a..1879db4 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -489,18 +489,6 @@ void QComboBoxPrivateContainer::viewDestroyed() } /* - Sets currentIndex on entered if the LeftButton is not pressed. This - means that if mouseTracking(...) is on, we setCurrentIndex and select - even when LeftButton is not pressed. -*/ -void QComboBoxPrivateContainer::setCurrentIndex(const QModelIndex &index) -{ - if (QComboBoxDelegate::isSeparator(index)) - return; - view->setCurrentIndex(index); -} - -/* Returns the item view used for the combobox popup. */ QAbstractItemView *QComboBoxPrivateContainer::itemView() const @@ -525,8 +513,6 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView) disconnect(view->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(updateScrollers())); #endif - disconnect(view, SIGNAL(entered(QModelIndex)), - this, SLOT(setCurrentIndex(QModelIndex))); disconnect(view, SIGNAL(destroyed()), this, SLOT(viewDestroyed())); @@ -563,8 +549,6 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView) connect(view->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(updateScrollers())); #endif - connect(view, SIGNAL(entered(QModelIndex)), - this, SLOT(setCurrentIndex(QModelIndex))); connect(view, SIGNAL(destroyed()), this, SLOT(viewDestroyed())); @@ -655,16 +639,20 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e) break; } break; - case QEvent::MouseMove: { + case QEvent::MouseMove: if (isVisible()) { QMouseEvent *m = static_cast(e); QWidget *widget = static_cast(o); QPoint vector = widget->mapToGlobal(m->pos()) - initialClickPosition; if (vector.manhattanLength() > 9 && blockMouseReleaseTimer.isActive()) blockMouseReleaseTimer.stop(); + QModelIndex indexUnderMouse = view->indexAt(m->pos()); + if (indexUnderMouse.isValid() && indexUnderMouse != view->currentIndex() + && !QComboBoxDelegate::isSeparator(indexUnderMouse)) { + view->setCurrentIndex(indexUnderMouse); + } } break; - } case QEvent::MouseButtonRelease: { QMouseEvent *m = static_cast(e); if (isVisible() && view->rect().contains(m->pos()) && view->currentIndex().isValid() diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h index 06e51e4..fe42c47 100644 --- a/src/gui/widgets/qcombobox_p.h +++ b/src/gui/widgets/qcombobox_p.h @@ -231,7 +231,6 @@ public: public Q_SLOTS: void scrollItemView(int action); void updateScrollers(); - void setCurrentIndex(const QModelIndex &index); void viewDestroyed(); protected: diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index 8acae7a..51a7ff8 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -153,6 +153,7 @@ private slots: void task260974_menuItemRectangleForComboBoxPopup(); void removeItem(); void resetModel(); + void keyBoardNavigationWithMouse(); protected slots: void onEditTextChanged( const QString &newString ); @@ -2448,6 +2449,57 @@ void tst_QComboBox::resetModel() } +void tst_QComboBox::keyBoardNavigationWithMouse() +{ + QComboBox combo; + combo.setEditable(false); + for (int i = 0; i < 80; i++) + combo.addItem( QString::number(i)); + combo.show(); + QApplication::setActiveWindow(&combo); + QTest::qWaitForWindowShown(&combo); + QTRY_COMPARE(QApplication::activeWindow(), static_cast(&combo)); + + QCOMPARE(combo.currentText(), QLatin1String("0")); + + combo.setFocus(); + QTRY_VERIFY(combo.hasFocus()); + + QTest::keyClick(testWidget->lineEdit(), Qt::Key_Space); + QTest::qWait(30); + QTRY_VERIFY(combo.view()); + QTRY_VERIFY(combo.view()->isVisible()); + QTest::qWait(130); + + QCOMPARE(combo.currentText(), QLatin1String("0")); + + QCursor::setPos(combo.view()->mapToGlobal(combo.view()->rect().center())); + QTest::qWait(200); + +#define GET_SELECTION(SEL) \ + QCOMPARE(combo.view()->selectionModel()->selection().count(), 1); \ + QCOMPARE(combo.view()->selectionModel()->selection().indexes().count(), 1); \ + SEL = combo.view()->selectionModel()->selection().indexes().first().row() + + int selection; + GET_SELECTION(selection); + + //since we moved the mouse is in the middle it should even be around 5; + QVERIFY(selection > 3); + + static const int final = 40; + for (int i = selection + 1; i <= final; i++) + { + QTest::keyClick(combo.view(), Qt::Key_Down); + QTest::qWait(20); + GET_SELECTION(selection); + QCOMPARE(selection, i); + } + + QTest::keyClick(combo.view(), Qt::Key_Enter); + QTRY_COMPARE(combo.currentText(), QString::number(final)); +} + QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" -- cgit v0.12 From 79a7c969983eafeef67cce28724c3981cf3af1ea Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 29 Oct 2009 16:25:56 +0100 Subject: QTreeView: fix drawing branches of model that adds or remove rows dynamically The lasts commits in the treeview did put the flags weither item has child or is the last in cache in the viewItem vector. But the cache was not updated while the model is modified. Reviewed-by: Thierry --- src/gui/itemviews/qtreeview.cpp | 38 ++++++++++++- src/gui/itemviews/qtreeview_p.h | 3 +- tests/auto/qtreeview/tst_qtreeview.cpp | 101 +++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+), 4 deletions(-) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index be64c46..3856293 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -2434,7 +2434,9 @@ void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end) return; } - if (parent != d->root && !d->isIndexExpanded(parent) && d->model->rowCount(parent) > (end - start) + 1) { + const int parentRowCount = d->model->rowCount(parent); + const int delta = end - start + 1; + if (parent != d->root && !d->isIndexExpanded(parent) && parentRowCount > delta) { QAbstractItemView::rowsInserted(parent, start, end); return; } @@ -2449,11 +2451,29 @@ void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end) ? d->viewItems.count() : d->viewItems.at(parentItem).total) - 1; - const int delta = end - start + 1; + if (parentRowCount == end + 1 && start > 0) { + //need to Update hasMoreSiblings + int previousRow = start - 1; + QModelIndex previousSibilingModelIndex = d->model->index(previousRow, 0, parent); + bool isHidden = d->isRowHidden(previousSibilingModelIndex); + while (isHidden && previousRow > 0) { + previousRow--; + previousSibilingModelIndex = d->model->index(previousRow, 0, parent); + isHidden = d->isRowHidden(previousSibilingModelIndex); + } + if (!isHidden) { + const int previousSibilling = d->viewIndex(previousSibilingModelIndex); + if(previousSibilling != -1) + d->viewItems[previousSibilling].hasMoreSiblings = true; + } + } + QVector insertedItems(delta); for (int i = 0; i < delta; ++i) { insertedItems[i].index = d->model->index(i + start, 0, parent); insertedItems[i].level = childLevel; + insertedItems[i].hasChildren = d->hasVisibleChildren(insertedItems[i].index); + insertedItems[i].hasMoreSiblings = !((i == delta - 1) && (parentRowCount == end +1)); } if (d->viewItems.isEmpty()) d->defaultItemHeight = indexRowSizeHint(insertedItems[0].index); @@ -2495,13 +2515,17 @@ void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end) d->viewItems.begin() + insertPos + 1); } + if (parentItem != -1) + d->viewItems[parentItem].hasChildren = true; d->updateChildCount(parentItem, delta); + updateGeometries(); viewport()->update(); } else if ((parentItem != -1) && d->viewItems.at(parentItem).expanded) { d->doDelayedItemsLayout(); } else if (parentItem != -1 && (d->model->rowCount(parent) == end - start + 1)) { - // the parent just went from 0 children to having some update to re-paint the decoration + // the parent just went from 0 children to more. update to re-paint the decoration + d->viewItems[parentItem].hasChildren = true; viewport()->update(); } QAbstractItemView::rowsInserted(parent, start, end); @@ -3706,6 +3730,7 @@ void QTreeViewPrivate::rowsRemoved(const QModelIndex &parent, const int delta = end - start + 1; + int previousSibiling = -1; int removedCount = 0; for (int item = firstChildItem; item <= lastChildItem; ) { Q_ASSERT(viewItems.at(item).level == childLevel); @@ -3713,6 +3738,7 @@ void QTreeViewPrivate::rowsRemoved(const QModelIndex &parent, //Q_ASSERT(modelIndex.parent() == parent); const int count = viewItems.at(item).total + 1; if (modelIndex.row() < start) { + previousSibiling = item; // not affected by the removal item += count; } else if (modelIndex.row() <= end) { @@ -3730,7 +3756,13 @@ void QTreeViewPrivate::rowsRemoved(const QModelIndex &parent, } } + if (previousSibiling != -1 && after && model->rowCount(parent) == start) + viewItems[previousSibiling].hasMoreSiblings = false; + + updateChildCount(parentItem, -removedCount); + if (parentItem != -1 && viewItems.at(parentItem).total == 0) + viewItems[parentItem].hasChildren = false; //every children have been removed; if (after) { q->updateGeometries(); viewport->update(); diff --git a/src/gui/itemviews/qtreeview_p.h b/src/gui/itemviews/qtreeview_p.h index 62676d8..aad5837 100644 --- a/src/gui/itemviews/qtreeview_p.h +++ b/src/gui/itemviews/qtreeview_p.h @@ -62,7 +62,8 @@ QT_BEGIN_NAMESPACE struct QTreeViewItem { - QTreeViewItem() : expanded(false), spanning(false), total(0), level(0), height(0) {} + QTreeViewItem() : expanded(false), spanning(false), hasChildren(false), + hasMoreSiblings(false), total(0), level(0), height(0) {} QModelIndex index; // we remove items whenever the indexes are invalidated uint expanded : 1; uint spanning : 1; diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index 75c02e9..90e6c5c 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -2892,6 +2892,8 @@ void tst_QTreeView::styleOptionViewItem() QVERIFY(!opt.text.isEmpty()); QCOMPARE(opt.index, index); + //qDebug() << index << opt.text; + if (allCollapsed) QCOMPARE(!(opt.features & QStyleOptionViewItemV2::Alternate), !(index.row() % 2)); QCOMPARE(!(opt.features & QStyleOptionViewItemV2::HasCheckIndicator), !opt.text.contains("Checkable")); @@ -2979,9 +2981,108 @@ void tst_QTreeView::styleOptionViewItem() view.expandAll(); QApplication::processEvents(); QTRY_VERIFY(delegate.count >= 13); + delegate.count = 0; view.collapse(par2->index()); QApplication::processEvents(); QTRY_VERIFY(delegate.count >= 4); + + + //test dynamic models + { + delegate.count = 0; + QStandardItemModel model2; + QStandardItem *item0 = new QStandardItem("OnlyOne Last"); + model2.appendRow(QList() << item0); + view.setModel(&model2); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 1); + QApplication::processEvents(); + + QStandardItem *item00 = new QStandardItem("OnlyOne Last"); + item0->appendRow(QList() << item00); + item0->setText("OnlyOne Last HasChildren"); + QApplication::processEvents(); + delegate.count = 0; + view.expandAll(); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 2); + QApplication::processEvents(); + + QStandardItem *item1 = new QStandardItem("OnlyOne Last"); + delegate.count = 0; + item0->setText("OnlyOne HasChildren"); + model2.appendRow(QList() << item1); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 3); + QApplication::processEvents(); + + QStandardItem *item01 = new QStandardItem("OnlyOne Last"); + delegate.count = 0; + item00->setText("OnlyOne"); + item0->appendRow(QList() << item01); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 4); + QApplication::processEvents(); + + QStandardItem *item000 = new QStandardItem("OnlyOne Last"); + delegate.count = 0; + item00->setText("OnlyOne HasChildren"); + item00->appendRow(QList() << item000); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 5); + QApplication::processEvents(); + + delegate.count = 0; + item0->removeRow(0); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 3); + QApplication::processEvents(); + + item00 = new QStandardItem("OnlyOne"); + item0->insertRow(0, QList() << item00); + QApplication::processEvents(); + delegate.count = 0; + view.expandAll(); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 4); + QApplication::processEvents(); + + delegate.count = 0; + item0->removeRow(1); + item00->setText("OnlyOne Last"); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 3); + QApplication::processEvents(); + + delegate.count = 0; + item0->removeRow(0); + item0->setText("OnlyOne"); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 2); + QApplication::processEvents(); + + //with hidden items + item0->setText("OnlyOne HasChildren"); + item00 = new QStandardItem("OnlyOne"); + item0->appendRow(QList() << item00); + item01 = new QStandardItem("Assert"); + item0->appendRow(QList() << item01); + view.setRowHidden(1, item0->index(), true); + view.expandAll(); + QStandardItem *item02 = new QStandardItem("OnlyOne Last"); + item0->appendRow(QList() << item02); + delegate.count = 0; + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 4); + QApplication::processEvents(); + + item0->removeRow(2); + item00->setText("OnlyOne Last"); + delegate.count = 0; + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 3); + QApplication::processEvents(); + } } class task174627_TreeView : public QTreeView -- cgit v0.12 From a8d1c0a7137b2d1f7ca74a24321cea41428ce0bd Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Mon, 26 Oct 2009 15:57:22 +0100 Subject: Rename qglEngineShaderSourceCode to qShaderSnippets This patch also adds a "snippetNameStr" helper for debugging. --- .../gl2paintengineex/qglengineshadermanager.cpp | 86 ++++++++++++---------- .../gl2paintengineex/qglengineshadermanager_p.h | 78 +++++++++++--------- 2 files changed, 93 insertions(+), 71 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 9dc2b53..be0e98a 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -66,7 +66,7 @@ QGLEngineSharedShaders *QGLEngineSharedShaders::shadersForContext(const QGLConte return p; } -const char* QGLEngineSharedShaders::qglEngineShaderSourceCode[] = { +const char* QGLEngineSharedShaders::qShaderSnippets[] = { 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, @@ -85,10 +85,10 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) around without having to change the order of the glsl strings. It is hoped this will make future hard-to-find runtime bugs more obvious and generally give more solid code. */ - static bool qglEngineShaderSourceCodePopulated = false; - if (!qglEngineShaderSourceCodePopulated) { + static bool snippetsPopulated = false; + if (!snippetsPopulated) { - const char** code = qglEngineShaderSourceCode; // shortcut + const char** code = qShaderSnippets; // shortcut code[MainVertexShader] = qglslMainVertexShader; code[MainWithTexCoordsVertexShader] = qglslMainWithTexCoordsVertexShader; @@ -130,11 +130,13 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) code[ConicalGradientBrushSrcFragmentShader] = qglslConicalGradientBrushSrcFragmentShader; code[ShockingPinkSrcFragmentShader] = qglslShockingPinkSrcFragmentShader; + code[NoMaskFragmentShader] = ""; code[MaskFragmentShader] = qglslMaskFragmentShader; code[RgbMaskFragmentShaderPass1] = qglslRgbMaskFragmentShaderPass1; code[RgbMaskFragmentShaderPass2] = qglslRgbMaskFragmentShaderPass2; code[RgbMaskWithGammaFragmentShader] = ""; //### + code[NoCompositionModeFragmentShader] = ""; code[MultiplyCompositionModeFragmentShader] = ""; //### code[ScreenCompositionModeFragmentShader] = ""; //### code[OverlayCompositionModeFragmentShader] = ""; //### @@ -149,17 +151,19 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) #if defined(QT_DEBUG) // Check that all the elements have been filled: - for (int i = 0; i < TotalShaderCount; ++i) { - if (qglEngineShaderSourceCode[i] == 0) { - int enumIndex = staticMetaObject.indexOfEnumerator("ShaderName"); - QMetaEnum m = staticMetaObject.enumerator(enumIndex); - - qCritical() << "qglEngineShaderSourceCode: Source for" << m.valueToKey(i) - << "(shader" << i << ") missing!"; + for (int i = 0; i < TotalSnippetCount; ++i) { + if (qShaderSnippets[i] == 0) { + QByteArray msg; + msg.append("Fatal: Shader Snippet for "); + msg.append(snippetNameStr(SnippetName(i))); + msg.append(" ("); + msg.append(QByteArray::number(i)); + msg.append(") is missing!"); + qFatal(msg.constData()); } } #endif - qglEngineShaderSourceCodePopulated = true; + snippetsPopulated = true; } QGLShader* fragShader; @@ -168,14 +172,14 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) // Compile up the simple shader: source.clear(); - source.append(qglEngineShaderSourceCode[MainVertexShader]); - source.append(qglEngineShaderSourceCode[PositionOnlyVertexShader]); + source.append(qShaderSnippets[MainVertexShader]); + source.append(qShaderSnippets[PositionOnlyVertexShader]); vertexShader = new QGLShader(QGLShader::VertexShader, context, this); vertexShader->compile(source); source.clear(); - source.append(qglEngineShaderSourceCode[MainFragmentShader]); - source.append(qglEngineShaderSourceCode[ShockingPinkSrcFragmentShader]); + source.append(qShaderSnippets[MainFragmentShader]); + source.append(qShaderSnippets[ShockingPinkSrcFragmentShader]); fragShader = new QGLShader(QGLShader::FragmentShader, context, this); fragShader->compile(source); @@ -191,14 +195,14 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) // Compile the blit shader: source.clear(); - source.append(qglEngineShaderSourceCode[MainWithTexCoordsVertexShader]); - source.append(qglEngineShaderSourceCode[UntransformedPositionVertexShader]); + source.append(qShaderSnippets[MainWithTexCoordsVertexShader]); + source.append(qShaderSnippets[UntransformedPositionVertexShader]); vertexShader = new QGLShader(QGLShader::VertexShader, context, this); vertexShader->compile(source); source.clear(); - source.append(qglEngineShaderSourceCode[MainFragmentShader]); - source.append(qglEngineShaderSourceCode[ImageSrcFragmentShader]); + source.append(qShaderSnippets[MainFragmentShader]); + source.append(qShaderSnippets[ImageSrcFragmentShader]); fragShader = new QGLShader(QGLShader::FragmentShader, context, this); fragShader->compile(source); @@ -215,6 +219,14 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) } +#if defined (QT_DEBUG) +QByteArray QGLEngineSharedShaders::snippetNameStr(SnippetName name) +{ + QMetaEnum m = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("SnippetName")); + return QByteArray(m.valueToKey(name)); +} +#endif + // The address returned here will only be valid until next time this function is called. QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineShaderProg &prog) { @@ -225,48 +237,46 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS cachedPrograms.append(prog); QGLEngineShaderProg &cached = cachedPrograms.last(); - QByteArray source; - source.append(qglEngineShaderSourceCode[prog.mainFragShader]); - source.append(qglEngineShaderSourceCode[prog.srcPixelFragShader]); + source.append(qShaderSnippets[prog.mainFragShader]); + source.append(qShaderSnippets[prog.srcPixelFragShader]); if (prog.srcPixelFragShader == CustomImageSrcFragmentShader) source.append(prog.customStageSource); if (prog.compositionFragShader) - source.append(qglEngineShaderSourceCode[prog.compositionFragShader]); + source.append(qShaderSnippets[prog.compositionFragShader]); if (prog.maskFragShader) - source.append(qglEngineShaderSourceCode[prog.maskFragShader]); + source.append(qShaderSnippets[prog.maskFragShader]); QGLShader* fragShader = new QGLShader(QGLShader::FragmentShader, ctxGuard.context(), this); fragShader->compile(source); source.clear(); - source.append(qglEngineShaderSourceCode[prog.mainVertexShader]); - source.append(qglEngineShaderSourceCode[prog.positionVertexShader]); + source.append(qShaderSnippets[prog.mainVertexShader]); + source.append(qShaderSnippets[prog.positionVertexShader]); QGLShader* vertexShader = new QGLShader(QGLShader::VertexShader, ctxGuard.context(), this); vertexShader->compile(source); #if defined(QT_DEBUG) // Name the shaders for easier debugging - QMetaEnum m = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("ShaderName")); QByteArray description; description.append("Fragment shader: main="); - description.append(m.valueToKey(prog.mainFragShader)); + description.append(snippetNameStr(prog.mainFragShader)); description.append(", srcPixel="); - description.append(m.valueToKey(prog.srcPixelFragShader)); + description.append(snippetNameStr(prog.srcPixelFragShader)); if (prog.compositionFragShader) { description.append(", composition="); - description.append(m.valueToKey(prog.compositionFragShader)); + description.append(snippetNameStr(prog.compositionFragShader)); } if (prog.maskFragShader) { description.append(", mask="); - description.append(m.valueToKey(prog.maskFragShader)); + description.append(snippetNameStr(prog.maskFragShader)); } fragShader->setObjectName(QString::fromLatin1(description)); description.clear(); description.append("Vertex shader: main="); - description.append(m.valueToKey(prog.mainVertexShader)); + description.append(snippetNameStr(prog.mainVertexShader)); description.append(", position="); - description.append(m.valueToKey(prog.positionVertexShader)); + description.append(snippetNameStr(prog.positionVertexShader)); vertexShader->setObjectName(QString::fromLatin1(description)); #endif @@ -483,8 +493,8 @@ bool QGLEngineShaderManager::useCorrectShaderProg() // Choose vertex shader shader position function (which typically also sets // varyings) and the source pixel (srcPixel) fragment shader function: - requiredProgram.positionVertexShader = QGLEngineSharedShaders::InvalidShaderName; - requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::InvalidShaderName; + requiredProgram.positionVertexShader = QGLEngineSharedShaders::InvalidSnippetName; + requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::InvalidSnippetName; bool isAffine = brushTransform.isAffine(); if ( (srcPixelType >= Qt::Dense1Pattern) && (srcPixelType <= Qt::DiagCrossPattern) ) { if (isAffine) @@ -594,7 +604,7 @@ bool QGLEngineShaderManager::useCorrectShaderProg() qCritical("QGLEngineShaderManager::useCorrectShaderProg() - Unknown mask type"); } } else { - requiredProgram.maskFragShader = 0; + requiredProgram.maskFragShader = QGLEngineSharedShaders::NoMaskFragmentShader; } if (hasCompose) { @@ -636,7 +646,7 @@ bool QGLEngineShaderManager::useCorrectShaderProg() qWarning("QGLEngineShaderManager::useCorrectShaderProg() - Unsupported composition mode"); } } else { - requiredProgram.compositionFragShader = 0; + requiredProgram.compositionFragShader = QGLEngineSharedShaders::NoCompositionModeFragmentShader; } // Choose vertex shader main function diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index e4f7aa6..fd73b44 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -235,35 +235,6 @@ QT_BEGIN_NAMESPACE QT_MODULE(OpenGL) -struct QGLEngineShaderProg -{ - int mainVertexShader; - int positionVertexShader; - int mainFragShader; - int srcPixelFragShader; - int maskFragShader; - int compositionFragShader; - QByteArray customStageSource; //TODO: Decent cache key for custom stages - QGLShaderProgram* program; - - QVector uniformLocations; - - bool useTextureCoords; - bool useOpacityAttribute; - - bool operator==(const QGLEngineShaderProg& other) { - // We don't care about the program - return ( mainVertexShader == other.mainVertexShader && - positionVertexShader == other.positionVertexShader && - mainFragShader == other.mainFragShader && - srcPixelFragShader == other.srcPixelFragShader && - maskFragShader == other.maskFragShader && - compositionFragShader == other.compositionFragShader && - customStageSource == other.customStageSource - ); - } -}; - /* struct QGLEngineCachedShaderProg { @@ -283,15 +254,19 @@ static const GLuint QT_VERTEX_COORDS_ATTR = 0; static const GLuint QT_TEXTURE_COORDS_ATTR = 1; static const GLuint QT_OPACITY_ATTR = 2; +struct QGLEngineShaderProg; + class QGLEngineSharedShaders : public QObject { Q_OBJECT public: - enum ShaderName { + + enum SnippetName { MainVertexShader, MainWithTexCoordsVertexShader, MainWithTexCoordsAndOpacityVertexShader, + // UntransformedPositionVertexShader must be first in the list: UntransformedPositionVertexShader, PositionOnlyVertexShader, PositionWithPatternBrushVertexShader, @@ -305,6 +280,7 @@ public: AffinePositionWithRadialGradientBrushVertexShader, AffinePositionWithTextureBrushVertexShader, + // MainFragmentShader_CMO must be first in the list: MainFragmentShader_CMO, MainFragmentShader_CM, MainFragmentShader_MO, @@ -315,6 +291,7 @@ public: MainFragmentShader, MainFragmentShader_ImageArrays, + // ImageSrcFragmentShader must be first in the list:: ImageSrcFragmentShader, ImageSrcWithPatternFragmentShader, NonPremultipliedImageSrcFragmentShader, @@ -328,11 +305,15 @@ public: ConicalGradientBrushSrcFragmentShader, ShockingPinkSrcFragmentShader, + // NoMaskFragmentShader must be first in the list: + NoMaskFragmentShader, MaskFragmentShader, RgbMaskFragmentShaderPass1, RgbMaskFragmentShaderPass2, RgbMaskWithGammaFragmentShader, + // NoCompositionModeFragmentShader must be first in the list: + NoCompositionModeFragmentShader, MultiplyCompositionModeFragmentShader, ScreenCompositionModeFragmentShader, OverlayCompositionModeFragmentShader, @@ -345,10 +326,11 @@ public: DifferenceCompositionModeFragmentShader, ExclusionCompositionModeFragmentShader, - TotalShaderCount, InvalidShaderName + TotalSnippetCount, InvalidSnippetName }; #if defined (QT_DEBUG) - Q_ENUMS(ShaderName) + Q_ENUMS(SnippetName) + static QByteArray snippetNameStr(SnippetName snippetName); #endif /* @@ -386,7 +368,37 @@ private: QGLShaderProgram *simpleShaderProg; QList cachedPrograms; - static const char* qglEngineShaderSourceCode[TotalShaderCount]; + static const char* qShaderSnippets[TotalSnippetCount]; +}; + +struct QGLEngineShaderProg +{ + QGLEngineSharedShaders::SnippetName mainVertexShader; + QGLEngineSharedShaders::SnippetName positionVertexShader; + QGLEngineSharedShaders::SnippetName mainFragShader; + QGLEngineSharedShaders::SnippetName srcPixelFragShader; + QGLEngineSharedShaders::SnippetName maskFragShader; + QGLEngineSharedShaders::SnippetName compositionFragShader; + + QByteArray customStageSource; //TODO: Decent cache key for custom stages + QGLShaderProgram* program; + + QVector uniformLocations; + + bool useTextureCoords; + bool useOpacityAttribute; + + bool operator==(const QGLEngineShaderProg& other) { + // We don't care about the program + return ( mainVertexShader == other.mainVertexShader && + positionVertexShader == other.positionVertexShader && + mainFragShader == other.mainFragShader && + srcPixelFragShader == other.srcPixelFragShader && + maskFragShader == other.maskFragShader && + compositionFragShader == other.compositionFragShader && + customStageSource == other.customStageSource + ); + } }; class Q_OPENGL_EXPORT QGLEngineShaderManager : public QObject -- cgit v0.12 From 90567274b900b22ab6b1c016ee66b7915aa994c8 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 30 Oct 2009 12:38:00 +0100 Subject: Implement a simple caching algorithm for shader programs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the number of programs held in the cache exceeds a threshold, the least frequantly used programs get deleted. This also covers programs with custom snippets of code. As a conequence, when a QGLCustomShaderStage gets deleted, any programs using that code will (eventually) be freed. Reviewed-By: Samuel Rødal --- .../gl2paintengineex/qglengineshadermanager.cpp | 71 +++++++++++++--------- .../gl2paintengineex/qglengineshadermanager_p.h | 13 +++- 2 files changed, 53 insertions(+), 31 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index be0e98a..34c448f 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -231,12 +231,14 @@ QByteArray QGLEngineSharedShaders::snippetNameStr(SnippetName name) QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineShaderProg &prog) { for (int i = 0; i < cachedPrograms.size(); ++i) { - if (cachedPrograms[i] == prog) - return &cachedPrograms[i]; + QGLEngineShaderProg *cachedProg = cachedPrograms[i]; + if (*cachedProg == prog) { + // Move the program to the top of the list as a poor-man's cache algo + cachedPrograms.move(i, 0); + return cachedProg; + } } - cachedPrograms.append(prog); - QGLEngineShaderProg &cached = cachedPrograms.last(); QByteArray source; source.append(qShaderSnippets[prog.mainFragShader]); source.append(qShaderSnippets[prog.srcPixelFragShader]); @@ -280,20 +282,22 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS vertexShader->setObjectName(QString::fromLatin1(description)); #endif + QGLEngineShaderProg* newProg = new QGLEngineShaderProg(prog); + // If the shader program's not found in the cache, create it now. - cached.program = new QGLShaderProgram(ctxGuard.context(), this); - cached.program->addShader(vertexShader); - cached.program->addShader(fragShader); + newProg->program = new QGLShaderProgram(ctxGuard.context(), this); + newProg->program->addShader(vertexShader); + newProg->program->addShader(fragShader); // We have to bind the vertex attribute names before the program is linked: - cached.program->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); - if (cached.useTextureCoords) - cached.program->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR); - if (cached.useOpacityAttribute) - cached.program->bindAttributeLocation("opacityArray", QT_OPACITY_ATTR); - - cached.program->link(); - if (!cached.program->isLinked()) { + newProg->program->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); + if (newProg->useTextureCoords) + newProg->program->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR); + if (newProg->useOpacityAttribute) + newProg->program->bindAttributeLocation("opacityArray", QT_OPACITY_ATTR); + + newProg->program->link(); + if (!newProg->program->isLinked()) { QLatin1String none("none"); QLatin1String br("\n"); QString error; @@ -307,32 +311,42 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS + QLatin1String(fragShader->sourceCode()) + br #endif + QLatin1String(" Error Log:\n") - + QLatin1String(" ") + cached.program->log(); + + QLatin1String(" ") + newProg->program->log(); qWarning() << error; - delete cached.program; - cachedPrograms.removeLast(); - return 0; - } else { - // taking the address here is safe since - // cachePrograms isn't resized anywhere else - return &cached; + delete newProg; // Deletes the QGLShaderProgram in it's destructor + newProg = 0; } -} + else { + if (cachedPrograms.count() > 30) { + // The cache is full, so delete the last 5 programs in the list. + // These programs will be least used, as a program us bumped to + // the top of the list when it's used. + for (int i = 0; i < 5; ++i) { + delete cachedPrograms.last(); + cachedPrograms.removeLast(); + } + } + cachedPrograms.insert(0, newProg); + } + + return newProg; +} void QGLEngineSharedShaders::cleanupCustomStage(QGLCustomShaderStage* stage) { // Remove any shader programs which has this as the custom shader src: for (int i = 0; i < cachedPrograms.size(); ++i) { - if (cachedPrograms.at(i).customStageSource == stage->source()) { - delete cachedPrograms.at(i).program; - cachedPrograms.removeAt(i--); + QGLEngineShaderProg *cachedProg = cachedPrograms[i]; + if (cachedProg->customStageSource == stage->source()) { + delete cachedProg; + cachedPrograms.removeAt(i); + i--; } } } - QGLEngineShaderManager::QGLEngineShaderManager(QGLContext* context) : ctx(context), shaderProgNeedsChanging(true), @@ -487,7 +501,6 @@ bool QGLEngineShaderManager::useCorrectShaderProg() } QGLEngineShaderProg requiredProgram; - requiredProgram.program = 0; bool texCoords = false; diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index fd73b44..59e50d0 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -366,13 +366,22 @@ private: QGLSharedResourceGuard ctxGuard; QGLShaderProgram *blitShaderProg; QGLShaderProgram *simpleShaderProg; - QList cachedPrograms; + QList cachedPrograms; static const char* qShaderSnippets[TotalSnippetCount]; }; -struct QGLEngineShaderProg + +class QGLEngineShaderProg { +public: + QGLEngineShaderProg() : program(0) {} + + ~QGLEngineShaderProg() { + if (program) + delete program; + } + QGLEngineSharedShaders::SnippetName mainVertexShader; QGLEngineSharedShaders::SnippetName positionVertexShader; QGLEngineSharedShaders::SnippetName mainFragShader; -- cgit v0.12 From 96799bf4da265835b5e574593bc5106712352ffc Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 30 Oct 2009 14:02:22 +0100 Subject: Update Polish translation --- translations/designer_pl.ts | 4 +- translations/linguist_pl.ts | 2 +- translations/qt_help_pl.ts | 58 +++++++++++++++++-------- translations/qt_pl.ts | 102 ++++++++++++++++++++++++-------------------- 4 files changed, 99 insertions(+), 67 deletions(-) diff --git a/translations/designer_pl.ts b/translations/designer_pl.ts index 0c196d8..f9c6dd0 100644 --- a/translations/designer_pl.ts +++ b/translations/designer_pl.ts @@ -6103,7 +6103,7 @@ Klasa: %2 Change toolTip... - Zmień tekst chmurki... + Zmień podpowiedź... @@ -6909,7 +6909,7 @@ Klasa: %2 Expand all - Rozszerz wszystkie + Rozwiń wszystkie diff --git a/translations/linguist_pl.ts b/translations/linguist_pl.ts index b59ebc3..cdff54b 100644 --- a/translations/linguist_pl.ts +++ b/translations/linguist_pl.ts @@ -312,7 +312,7 @@ Przyjmie on uniwersalną formę liczby pojedynczej. LRelease - + Dropped %n message(s) which had no ID. Opuszczono %n wyrażenie które nie miało identyfikatora. diff --git a/translations/qt_help_pl.ts b/translations/qt_help_pl.ts index 0e6bbbf..220f70c 100644 --- a/translations/qt_help_pl.ts +++ b/translations/qt_help_pl.ts @@ -32,33 +32,61 @@ QHelpCollectionHandler - The collection file is not set up yet! - Plik z kolekcją nie jest jeszcze ustawiony! + Plik z kolekcją nie jest jeszcze ustawiony! - + + The collection file '%1' is not set up yet! + + + + Cannot load sqlite database driver! Nie można załadować sterownika bazy danych sqlite! - + Cannot open collection file: %1 Nie można otworzyć pliku z kolekcją: %1 - + Cannot create tables in file %1! Nie można utworzyć tabel w pliku %1! + The collection file '%1' already exists! + + + + + Unknown filter '%1'! + + + + + Invalid documentation file '%1'! + + + + + Cannot register namespace '%1'! + + + + + Cannot open database '%1' to optimize! + + + The specified collection file already exists! - Podany plik z kolekcją już istnieje! + Podany plik z kolekcją już istnieje! - + Cannot create directory: %1 Nie można utworzyć katalogu: %1 @@ -68,12 +96,11 @@ Nie można skopiować pliku z kolekcją: %1 - Unknown filter! - Nieznany filtr! + Nieznany filtr! - + Cannot register filter %1! Nie można zarejestrować pliku %1! @@ -83,12 +110,11 @@ Nie można otworzyć pliku z dokumentacją %1! - Invalid documentation file! - Niepoprawny plik z dokumentacją! + Niepoprawny plik z dokumentacją! - + The namespace %1 was not registered! Przestrzeń nazw %1 nie została zarejestrowana! @@ -98,14 +124,12 @@ Przestrzeń nazw %1 już istnieje! - Cannot register namespace! - Nie można zarejestrować przestrzeni nazw! + Nie można zarejestrować przestrzeni nazw! - Cannot open database to optimize! - Nie można otworzyć bazy danych do zoptymalizowania! + Nie można otworzyć bazy danych do zoptymalizowania! diff --git a/translations/qt_pl.ts b/translations/qt_pl.ts index 424fd31..f79ecb0 100644 --- a/translations/qt_pl.ts +++ b/translations/qt_pl.ts @@ -12,7 +12,7 @@ FakeReply - + Fake error ! @@ -932,7 +932,7 @@ na Operacja na gnieździe nieobsługiwana - + Socket is not connected Gniazdo nie jest podłączone @@ -966,6 +966,14 @@ na + QAccessibleButton + + + Press + Wciśnij + + + QApplication @@ -988,7 +996,7 @@ na Niekompatybilność biblioteki Qt - + QT_LAYOUT_DIRECTION Translate this string to the string 'LTR' in left-to-right languages or to 'RTL' in right-to-left languages (such as Hebrew and Arabic) to get proper widget layout. LTR @@ -1020,7 +1028,7 @@ na QCheckBox - + Check Zaznacz @@ -1276,7 +1284,7 @@ na QDialogButtonBox - + Abort Przerwij @@ -1472,7 +1480,7 @@ na Błąd krytyczny: - + &OK &OK @@ -1482,7 +1490,7 @@ na &Pokaż ten komunikat ponownie - + Warning: Ostrzeżenie: @@ -1851,52 +1859,52 @@ Proszę o sprawdzenie podanej nazwy pliku. QFontDatabase - + Normal Normalny - + - + Bold Pogrubiony - - + + Demi Bold Na wpół pogrubiony - + - + Black it's about font weight Bardzo gruby - + Demi Na wpół - + Light it's about font weight Cienki - - + + Italic Kursywa - - + + Oblique Pochyły @@ -2340,7 +2348,7 @@ Proszę o sprawdzenie podanej nazwy pliku. Host %1 znaleziony - + Host %1 not found @@ -2360,7 +2368,7 @@ Proszę o sprawdzenie podanej nazwy pliku. Komenda HTTP zakończona błędem - + @@ -2374,7 +2382,7 @@ Proszę o sprawdzenie podanej nazwy pliku. Niepoprawny nagłówek odpowiedzi HTTP - + No server set to connect to Brak serwera do podłączenia @@ -2411,7 +2419,7 @@ Proszę o sprawdzenie podanej nazwy pliku. Błędna długość zawartości - + Unknown authentication method Nieznana metoda autoryzacji @@ -2456,7 +2464,7 @@ Proszę o sprawdzenie podanej nazwy pliku. Nawiązanie sesji SSL nie powiodło się - + Connection refused (or timed out) Połączenie odrzucone (przekroczony czas połączenia) @@ -3105,7 +3113,7 @@ Proszę o sprawdzenie podanej nazwy pliku. QMenuBar - + Actions Akcje @@ -4361,7 +4369,7 @@ Proszę wybrać inną nazwę pliku. Selection - Wybór + Wybrane strony @@ -4449,7 +4457,7 @@ Proszę wybrać inną nazwę pliku. Location: - Lokalizacja: + Położenie: @@ -4505,7 +4513,7 @@ Proszę wybrać inną nazwę pliku. Przekroczony czas operacji procesu - + @@ -4726,7 +4734,7 @@ Proszę wybrać inną nazwę pliku. Location - Miejsce + Położenie @@ -4967,7 +4975,7 @@ Proszę wybrać inną nazwę pliku. Location - Miejsce + Położenie @@ -5847,7 +5855,7 @@ Proszę wybrać inną nazwę pliku. Anuluj - + Exit Wyjście @@ -6071,7 +6079,7 @@ Proszę wybrać inną nazwę pliku. QTextControl - + &Copy S&kopiuj @@ -6114,7 +6122,7 @@ Proszę wybrać inną nazwę pliku. QToolButton - + Open Otwórz @@ -6229,7 +6237,7 @@ Proszę wybrać inną nazwę pliku. QWebFrame - + Request cancelled Prośba anulowana @@ -6262,7 +6270,7 @@ Proszę wybrać inną nazwę pliku. QWebPage - + Submit default label for Submit buttons in forms on web pages Wyślij @@ -6280,7 +6288,7 @@ Proszę wybrać inną nazwę pliku. Wyczyść - + Choose File title for file button used in HTML forms Wybierz plik @@ -6766,12 +6774,12 @@ Proszę wybrać inną nazwę pliku. Nieznany - + Web Inspector - %2 Wizytator sieciowy - %2 - + Bad HTTP request Niepoprawna komenda HTTP @@ -6875,7 +6883,7 @@ Proszę wybrać inną nazwę pliku. - + JavaScript Alert - %1 Ostrzeżenie JavaScript - %1 @@ -7121,7 +7129,7 @@ Proszę wybrać inną nazwę pliku. QWidget - + * * @@ -9596,32 +9604,32 @@ Proszę wybrać inną nazwę pliku. Duration content does not match the maxInclusive facet. - Wartość czasu trwania koliduje z aspektem "maxInclusive". + Wartość długości okresu czasu koliduje z aspektem "maxInclusive". Duration content does not match the maxExclusive facet. - Wartość czasu trwania koliduje z aspektem "maxExclusive". + Wartość długości okresu czasu koliduje z aspektem "maxExclusive". Duration content does not match the minInclusive facet. - Wartość czasu trwania koliduje z aspektem "minInclusive". + Wartość długości okresu czasu koliduje z aspektem "minInclusive". Duration content does not match the minExclusive facet. - Wartość czasu trwania koliduje z aspektem "minExclusive". + Wartość długości okresu czasu koliduje z aspektem "minExclusive". Duration content is not listed in the enumeration facet. - Wartość czasu trwania nie widnieje na liście aspektu "enumeration". + Wartość długości okresu czasu nie widnieje na liście aspektu "enumeration". Duration content does not match pattern facet. - Wartość czasu trwania koliduje z aspektem "pattern". + Wartość długości okresu czasu koliduje z aspektem "pattern". -- cgit v0.12 From 1c44377d84976afa10b5ebae7d6ede5f226a2b3e Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 30 Oct 2009 11:55:56 +0100 Subject: Fixed namespacing in qatomic_symbian.h The namespace needs to be there, even if empty, to avoid warnings. Also, the header declaration was moved to avoid nested header declarations. RevBy: hjk --- src/corelib/arch/qatomic_symbian.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/corelib/arch/qatomic_symbian.h b/src/corelib/arch/qatomic_symbian.h index 5880120..3721aca 100644 --- a/src/corelib/arch/qatomic_symbian.h +++ b/src/corelib/arch/qatomic_symbian.h @@ -42,8 +42,6 @@ #ifndef QATOMIC_SYMBIAN_H #define QATOMIC_SYMBIAN_H -QT_BEGIN_HEADER - #if defined(Q_CC_RVCT) # define QT_NO_ARM_EABI # include @@ -51,6 +49,16 @@ QT_BEGIN_HEADER # include #endif +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Core) + +// Empty, but needed to avoid warnings + +QT_END_NAMESPACE + QT_END_HEADER #endif // QATOMIC_SYMBIAN_H -- cgit v0.12 From fab1697ff467e6c9ec02ffe6eccf65a6e779fd6b Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 30 Oct 2009 13:50:04 +0100 Subject: Moved a resource file from the static wrapper app to QtGui. It's more appropriate to have it in QtGui after the framework classes were moved there. This also means that the rsgfix needed earlier is not necessary anymore, since QtGui is not a static library. RevBy: Janne Anttila --- src/gui/s60framework/s60framework.pri | 11 +++++ src/gui/s60framework/s60main.rss | 85 +++++++++++++++++++++++++++++++++++ src/s60main/s60main.pro | 20 --------- src/s60main/s60main.rss | 85 ----------------------------------- 4 files changed, 96 insertions(+), 105 deletions(-) create mode 100644 src/gui/s60framework/s60main.rss delete mode 100644 src/s60main/s60main.rss diff --git a/src/gui/s60framework/s60framework.pri b/src/gui/s60framework/s60framework.pri index fea74fe..5884b68 100644 --- a/src/gui/s60framework/s60framework.pri +++ b/src/gui/s60framework/s60framework.pri @@ -1,3 +1,14 @@ +# This block serves the minimalistic resource file for S60 3.1 platforms. +# Note there is no way to ifdef S60 version in mmp file, that is why the resource +# file is always compiled for WINSCW +minimalAppResource31 = \ + "SOURCEPATH s60framework" \ + "START RESOURCE s60main.rss" \ + "HEADER" \ + "TARGETPATH resource\apps" \ + "END" +MMP_RULES += minimalAppResource31 + SOURCES += s60framework/qs60mainapplication.cpp \ s60framework/qs60mainappui.cpp \ s60framework/qs60maindocument.cpp diff --git a/src/gui/s60framework/s60main.rss b/src/gui/s60framework/s60main.rss new file mode 100644 index 0000000..07dc6a1 --- /dev/null +++ b/src/gui/s60framework/s60main.rss @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Symbian application wrapper 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Even S60 application have ENoAppResourceFile and ENonStandardResourceFile +// flags set, the S60 3rd Edition FP1 emulator requires applications to have +// very minimalistic application resource file, otherwise apps refures to start +// This file serves the minimalistic resource file for S60 3.1 platforms. + +// RESOURCE IDENTIFIER +NAME QTMA // 4 letter ID + +// INCLUDES +//#include +#include +#include +#include +#include +#include + +// RESOURCE DEFINITIONS +RESOURCE RSS_SIGNATURE + { + } + +RESOURCE TBUF r_default_document_name + { + buf="QTMA"; + } + +RESOURCE EIK_APP_INFO + { + menubar = r_qt_wrapperapp_menubar; + cba = R_AVKON_SOFTKEYS_EXIT; + } + +RESOURCE MENU_BAR r_qt_wrapperapp_menubar + { + titles = + { + MENU_TITLE { menu_pane = r_qt_wrapperapp_menu; } + }; + } + +RESOURCE MENU_PANE r_qt_wrapperapp_menu + { + } +// End of File diff --git a/src/s60main/s60main.pro b/src/s60main/s60main.pro index cc3c547..47cf020 100644 --- a/src/s60main/s60main.pro +++ b/src/s60main/s60main.pro @@ -16,16 +16,6 @@ symbian { SOURCES = qts60main.cpp \ qts60main_mcrt0.cpp - # This block serves the minimalistic resource file for S60 3.1 platforms. - # Note there is no way to ifdef S60 version in mmp file, that is why the resource - # file is always compiled for WINSCW - minimalAppResource31 = \ - "START RESOURCE s60main.rss" \ - "HEADER" \ - "TARGETPATH resource\apps" \ - "END" - MMP_RULES += minimalAppResource31 - # s60main needs to be built in ARM mode for GCCE to work. MMP_RULES+="ALWAYS_BUILD_AS_ARM" @@ -36,14 +26,4 @@ symbian { error("$$_FILE_ is intended only for Symbian!") } -symbian-abld: { - # abld build commands generated resources after the static library is built, and - # we have dependency to resource from static lib -> resources need to be generated - # explicitly before library - rsgFix2.commands = "-$(DEL_FILE) $(EPOCROOT)Epoc32\Data\z\resource\apps\s60main.rsc >NUL 2>&1" - rsgFix.commands = "-$(ABLD) resource $(PLATFORM) $(CFG) 2>NUL" - QMAKE_EXTRA_TARGETS += rsgFix rsgFix2 - PRE_TARGETDEPS += rsgFix rsgFix2 -} - include(../qbase.pri) diff --git a/src/s60main/s60main.rss b/src/s60main/s60main.rss deleted file mode 100644 index 07dc6a1..0000000 --- a/src/s60main/s60main.rss +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Symbian application wrapper 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 Technology Preview License Agreement accompanying -** this package. -** -** 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// Even S60 application have ENoAppResourceFile and ENonStandardResourceFile -// flags set, the S60 3rd Edition FP1 emulator requires applications to have -// very minimalistic application resource file, otherwise apps refures to start -// This file serves the minimalistic resource file for S60 3.1 platforms. - -// RESOURCE IDENTIFIER -NAME QTMA // 4 letter ID - -// INCLUDES -//#include -#include -#include -#include -#include -#include - -// RESOURCE DEFINITIONS -RESOURCE RSS_SIGNATURE - { - } - -RESOURCE TBUF r_default_document_name - { - buf="QTMA"; - } - -RESOURCE EIK_APP_INFO - { - menubar = r_qt_wrapperapp_menubar; - cba = R_AVKON_SOFTKEYS_EXIT; - } - -RESOURCE MENU_BAR r_qt_wrapperapp_menubar - { - titles = - { - MENU_TITLE { menu_pane = r_qt_wrapperapp_menu; } - }; - } - -RESOURCE MENU_PANE r_qt_wrapperapp_menu - { - } -// End of File -- cgit v0.12 From 17a254a1b231393ada1f80f29d989ee71ff8fff4 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 30 Oct 2009 14:30:59 +0100 Subject: QTreeView navigation now inverts left and right in RTL Task-number: QTBUG-5007 Reviewed-by: ogoffart --- src/gui/itemviews/qtreeview.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 3856293..a3cbc0d 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -2113,6 +2113,12 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie if (vi < 0) vi = qMax(0, d->viewIndex(current)); + if (isRightToLeft()) { + if (cursorAction == MoveRight) + cursorAction = MoveLeft; + else if (cursorAction == MoveLeft) + cursorAction = MoveRight; + } switch (cursorAction) { case MoveNext: case MoveDown: -- cgit v0.12 From 8097fa53b5e0e6228bd5737de6de8cd77c04dddf Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 30 Oct 2009 13:23:28 +0100 Subject: Add QScriptString::toArrayIndex() function Avoid hacking a custom toArrayIndex() in the example; instead provide an ECMA-compliant conversion that's as fast as possible (having to convert the QScriptString to a QString and then convert the result to a number is considerably slower than calling JSC's Identifier::toArrayIndex() function directly). Reviewed-by: Olivier Goffart --- examples/script/customclass/bytearrayclass.cpp | 17 +++--------- src/script/api/qscriptstring.cpp | 29 ++++++++++++++++++++ src/script/api/qscriptstring.h | 2 ++ tests/auto/qscriptstring/tst_qscriptstring.cpp | 37 ++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 14 deletions(-) diff --git a/examples/script/customclass/bytearrayclass.cpp b/examples/script/customclass/bytearrayclass.cpp index 7291b97..bce69e4 100644 --- a/examples/script/customclass/bytearrayclass.cpp +++ b/examples/script/customclass/bytearrayclass.cpp @@ -72,18 +72,6 @@ private: int m_last; }; -static qint32 toArrayIndex(const QString &str) -{ - QByteArray bytes = str.toUtf8(); - char *eptr; - quint32 pos = strtoul(bytes.constData(), &eptr, 10); - if ((eptr == bytes.constData() + bytes.size()) - && (QByteArray::number(pos) == bytes)) { - return pos; - } - return -1; -} - //! [0] ByteArrayClass::ByteArrayClass(QScriptEngine *engine) : QObject(engine), QScriptClass(engine) @@ -120,8 +108,9 @@ QScriptClass::QueryFlags ByteArrayClass::queryProperty(const QScriptValue &objec if (name == length) { return flags; } else { - qint32 pos = toArrayIndex(name); - if (pos == -1) + bool isArrayIndex; + qint32 pos = name.toArrayIndex(&isArrayIndex); + if (!isArrayIndex) return 0; *id = pos; if ((flags & HandlesReadAccess) && (pos >= ba->size())) diff --git a/src/script/api/qscriptstring.cpp b/src/script/api/qscriptstring.cpp index 1ede51c..10fccd0 100644 --- a/src/script/api/qscriptstring.cpp +++ b/src/script/api/qscriptstring.cpp @@ -68,6 +68,10 @@ QT_BEGIN_NAMESPACE Call the toString() function to obtain the string that a QScriptString represents. + + Call the toArrayIndex() function to convert a QScriptString to an + array index. This is useful when using QScriptClass to implement + array-like objects. */ /*! @@ -164,6 +168,31 @@ bool QScriptString::operator!=(const QScriptString &other) const } /*! + \since 4.6 + + Attempts to convert this QScriptString to a QtScript array index, + and returns the result. + + If a conversion error occurs, *\a{ok} is set to false; otherwise + *\a{ok} is set to true. +*/ +quint32 QScriptString::toArrayIndex(bool *ok) const +{ + Q_D(const QScriptString); + if (!d) { + if (ok) + *ok = false; + return -1; + } + bool tmp; + bool *okok = ok ? ok : &tmp; + quint32 result = d->identifier.toArrayIndex(okok); + if (!*okok) + result = -1; + return result; +} + +/*! Returns the string that this QScriptString represents, or a null string if this QScriptString is not valid. diff --git a/src/script/api/qscriptstring.h b/src/script/api/qscriptstring.h index 40d156c..bf5d1d5 100644 --- a/src/script/api/qscriptstring.h +++ b/src/script/api/qscriptstring.h @@ -67,6 +67,8 @@ public: bool operator==(const QScriptString &other) const; bool operator!=(const QScriptString &other) const; + quint32 toArrayIndex(bool *ok = 0) const; + QString toString() const; operator QString() const; diff --git a/tests/auto/qscriptstring/tst_qscriptstring.cpp b/tests/auto/qscriptstring/tst_qscriptstring.cpp index e1a4bc1..1229f4a 100644 --- a/tests/auto/qscriptstring/tst_qscriptstring.cpp +++ b/tests/auto/qscriptstring/tst_qscriptstring.cpp @@ -59,6 +59,8 @@ public: private slots: void test(); void hash(); + void toArrayIndex_data(); + void toArrayIndex(); }; tst_QScriptString::tst_QScriptString() @@ -155,5 +157,40 @@ void tst_QScriptString::hash() QCOMPARE(stringToInt.value(foo), 123); } +void tst_QScriptString::toArrayIndex_data() +{ + QTest::addColumn("input"); + QTest::addColumn("expectSuccess"); + QTest::addColumn("expectedIndex"); + QTest::newRow("foo") << QString::fromLatin1("foo") << false << quint32(0xffffffff); + QTest::newRow("empty") << QString::fromLatin1("") << false << quint32(0xffffffff); + QTest::newRow("0") << QString::fromLatin1("0") << true << quint32(0); + QTest::newRow("00") << QString::fromLatin1("00") << false << quint32(0xffffffff); + QTest::newRow("1") << QString::fromLatin1("1") << true << quint32(1); + QTest::newRow("123") << QString::fromLatin1("123") << true << quint32(123); + QTest::newRow("-1") << QString::fromLatin1("-1") << false << quint32(0xffffffff); + QTest::newRow("0a") << QString::fromLatin1("0a") << false << quint32(0xffffffff); + QTest::newRow("0x1") << QString::fromLatin1("0x1") << false << quint32(0xffffffff); + QTest::newRow("01") << QString::fromLatin1("01") << false << quint32(0xffffffff); + QTest::newRow("4294967294") << QString::fromLatin1("4294967294") << true << quint32(0xfffffffe); + QTest::newRow("4294967295") << QString::fromLatin1("4294967295") << false << quint32(0xffffffff); +} + +void tst_QScriptString::toArrayIndex() +{ + QFETCH(QString, input); + QFETCH(bool, expectSuccess); + QFETCH(quint32, expectedIndex); + QScriptEngine engine; + for (int x = 0; x < 2; ++x) { + bool isArrayIndex; + bool *ptr = (x == 0) ? &isArrayIndex : (bool*)0; + quint32 result = engine.toStringHandle(input).toArrayIndex(ptr); + if (x == 0) + QCOMPARE(isArrayIndex, expectSuccess); + QCOMPARE(result, expectedIndex); + } +} + QTEST_MAIN(tst_QScriptString) #include "tst_qscriptstring.moc" -- cgit v0.12 From fad40eb6261ca72cda438c06dccebfc49e8d0a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 30 Oct 2009 14:34:18 +0100 Subject: Fix some test failures in the qgl test on 16 bit servers. These tests are designed to run in 24 or 32 bit mode, and won't work unless they do.. Reviewed-by: Samuel --- tests/auto/qgl/tst_qgl.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index e036e4b..e9f0476 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -118,6 +118,16 @@ public: void setAutoBufferSwap(bool on) { QGLWidget::setAutoBufferSwap(on); } }; +static int appDefaultDepth() +{ + static int depth = 0; + if (depth == 0) { + QPixmap pm(1, 1); + depth = pm.depth(); + } + return depth; +} + // Using INT_MIN and INT_MAX will cause failures on systems // where "int" is 64-bit, so use the explicit values instead. #define TEST_INT_MIN (-2147483647 - 1) @@ -714,6 +724,8 @@ public: void tst_QGL::graphicsViewClipping() { + if (appDefaultDepth() < 24) + QSKIP("This test won't work for bit depths < 24", SkipAll); const int size = 64; UnclippedWidget *widget = new UnclippedWidget; widget->setFixedSize(size, size); @@ -866,6 +878,8 @@ public: void tst_QGL::glWidgetRendering() { + if (appDefaultDepth() < 24) + QSKIP("This test won't work for bit depths < 24", SkipAll); GLWidget w; w.show(); @@ -1089,6 +1103,8 @@ protected: void tst_QGL::glFBOUseInGLWidget() { + if (appDefaultDepth() < 24) + QSKIP("This test won't work for bit depths < 24", SkipAll); if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()) QSKIP("QGLFramebufferObject not supported on this platform", SkipSingle); @@ -1116,6 +1132,8 @@ void tst_QGL::glFBOUseInGLWidget() void tst_QGL::glWidgetReparent() { + if (appDefaultDepth() < 24) + QSKIP("This test won't work for bit depths < 24", SkipAll); // Try it as a top-level first: GLWidget *widget = new GLWidget; widget->setGeometry(0, 0, 200, 30); @@ -1582,6 +1600,8 @@ protected: void tst_QGL::replaceClipping() { + if (appDefaultDepth() < 24) + QSKIP("This test won't work for bit depths < 24", SkipAll); ReplaceClippingGLWidget glw; glw.resize(300, 300); glw.show(); @@ -1707,6 +1727,8 @@ protected: void tst_QGL::clipTest() { + if (appDefaultDepth() < 24) + QSKIP("This test won't work for bit depths < 24", SkipAll); ClipTestGLWidget glw; glw.resize(220, 220); glw.show(); -- cgit v0.12 From acb10eefab985a32a619e2a1d590c93659732c00 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Fri, 30 Oct 2009 12:42:23 +0100 Subject: Fix unit test and add autoCancel test for graphicsview --- tests/auto/gestures/tst_gestures.cpp | 98 ++++++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 26 deletions(-) diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 02c8232..79de823 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -116,7 +116,7 @@ public: return new CustomGesture; } - QGestureRecognizer::Result filterEvent(QGesture *state, QObject*, QEvent *event) + QGestureRecognizer::Result filterEvent(QGesture *state, QObject*o , QEvent *event) { if (event->type() == CustomEvent::EventType) { QGestureRecognizer::Result result = 0; @@ -332,6 +332,7 @@ private slots: void consumeEventHint(); void unregisterRecognizer(); void autoCancelGestures(); + void autoCancelGestures2(); }; tst_Gestures::tst_Gestures() @@ -1295,20 +1296,6 @@ void tst_Gestures::unregisterRecognizer() // a method on QApplication void tst_Gestures::autoCancelGestures() { - class MockRecognizer : public QGestureRecognizer { - public: - QGestureRecognizer::Result filterEvent(QGesture *gesture, QObject *watched, QEvent *event) - { - Q_UNUSED(gesture); - Q_UNUSED(watched); - if (event->type() == QEvent::MouseButtonPress) - return QGestureRecognizer::GestureTriggered; - if (event->type() == QEvent::MouseButtonRelease) - return QGestureRecognizer::GestureFinished; - return QGestureRecognizer::Ignore; - } - }; - class MockWidget : public GestureWidget { public: MockWidget(const char *name) : GestureWidget(name) { } @@ -1324,14 +1311,18 @@ void tst_Gestures::autoCancelGestures() } }; + const Qt::GestureType secondGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + MockWidget parent("parent"); // this one sets the cancel policy to CancelAllInContext parent.resize(300, 100); + parent.setWindowFlags(Qt::X11BypassWindowManagerHint); GestureWidget *child = new GestureWidget("child", &parent); child->setGeometry(10, 10, 100, 80); - Qt::GestureType type = QApplication::registerGestureRecognizer(new MockRecognizer()); - parent.grabGesture(type, Qt::WidgetWithChildrenGesture); - child->grabGesture(type, Qt::WidgetWithChildrenGesture); + parent.grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture); + child->grabGesture(secondGesture, Qt::WidgetWithChildrenGesture); + parent.show(); + QTest::qWaitForWindowShown(&parent); /* An event is send to both the child and the parent, when the child gets it a gesture is triggered @@ -1340,18 +1331,73 @@ void tst_Gestures::autoCancelGestures() parent gets it he accepts it and that causes the cancel policy to activate. The cause of that is the gesture for the child is cancelled and send to the child as such. */ - QMouseEvent event(QEvent::MouseButtonPress, QPoint(20,20), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + CustomEvent event; + event.serial = CustomGesture::SerialStartedThreshold; QApplication::sendEvent(child, &event); + QCOMPARE(child->events.all.count(), 2); QCOMPARE(child->events.started.count(), 1); - QCOMPARE(child->events.all.count(), 1); - QCOMPARE(parent.events.all.count(), 0); - child->reset(); - QApplication::sendEvent(&parent, &event); + QCOMPARE(child->events.canceled.count(), 1); QCOMPARE(parent.events.all.count(), 1); - QCOMPARE(parent.events.started.count(), 1); - QCOMPARE(child->events.started.count(), 0); - QCOMPARE(child->events.all.count(), 1); + + // clean up, make the parent gesture finish + event.serial = CustomGesture::SerialFinishedThreshold; + QApplication::sendEvent(child, &event); + QCOMPARE(parent.events.all.count(), 2); +} + +void tst_Gestures::autoCancelGestures2() +{ + class MockItem : public GestureItem { + public: + MockItem(const char *name) : GestureItem(name) { } + + bool event(QEvent *event) { + if (event->type() == QEvent::Gesture) { + QGestureEvent *ge = static_cast(event); + Q_ASSERT(ge->allGestures().count() == 1); // can't use QCOMPARE here... + ge->allGestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext); + } + return GestureItem::event(event); + } + }; + + const Qt::GestureType secondGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + + QGraphicsScene scene; + QGraphicsView view(&scene); + view.setWindowFlags(Qt::X11BypassWindowManagerHint); + + MockItem *parent = new MockItem("parent"); + GestureItem *child = new GestureItem("child"); + child->setParentItem(parent); + parent->setPos(0, 0); + child->setPos(10, 10); + scene.addItem(parent); + view.viewport()->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + view.viewport()->grabGesture(secondGesture, Qt::WidgetGesture); + parent->grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture); + child->grabGesture(secondGesture, Qt::WidgetWithChildrenGesture); + + view.show(); + QTest::qWaitForWindowShown(&view); + view.ensureVisible(scene.sceneRect()); + + CustomEvent event; + event.serial = CustomGesture::SerialStartedThreshold; + event.hasHotSpot = true; + event.hotSpot = mapToGlobal(QPointF(5, 5), child, &view); + // qDebug() << event.hotSpot; + scene.sendEvent(child, &event); + //QEventLoop().exec(); + QCOMPARE(parent->events.all.count(), 1); + QCOMPARE(child->events.started.count(), 1); QCOMPARE(child->events.canceled.count(), 1); + QCOMPARE(child->events.all.count(), 2); + + // clean up, make the parent gesture finish + event.serial = CustomGesture::SerialFinishedThreshold; + scene.sendEvent(child, &event); + QCOMPARE(parent->events.all.count(), 2); } QTEST_MAIN(tst_Gestures) -- cgit v0.12 From da83365fbf7ff393f7dc99d28eda61b902081bb2 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Fri, 30 Oct 2009 12:42:49 +0100 Subject: Make GestureCancelPolicy work for graphicsview Reviewed-By: Denis --- src/gui/graphicsview/qgraphicsscene.cpp | 90 +++++++++++++++++++++++++++++++++ src/gui/graphicsview/qgraphicsscene_p.h | 1 + src/gui/kernel/qgesture.h | 1 + src/gui/kernel/qgesturemanager.cpp | 37 ++++++-------- src/gui/kernel/qgesturemanager_p.h | 2 + 5 files changed, 109 insertions(+), 22 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index c459d21..9279fe3 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5941,6 +5941,13 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) continue; } } + foreach (QGesture *g, startedGestures) { + if (g->gestureCancelPolicy() == QGesture::CancelAllInContext) { + DEBUG() << "lets try to cancel some"; + // find gestures in context in Qt::GestureStarted or Qt::GestureUpdated state and cancel them + cancelGesturesForChildren(g, event->widget()); + } + } // forget about targets for gestures that have ended foreach (QGesture *g, allGestures) { @@ -5955,6 +5962,89 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) } } +void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original, QWidget *viewport) +{ + Q_ASSERT(original); + QGraphicsItem *originalItem = gestureTargets.value(original); + Q_ASSERT(originalItem); + + // iterate over all active gestures and for each find the owner + // if the owner is part of our sub-hierarchy, cancel it. + + QSet canceledGestures; + QHash::Iterator iter = gestureTargets.begin(); + while (iter != gestureTargets.end()) { + QGraphicsObject *item = iter.value(); + // note that we don't touch the gestures for our originalItem + if (item != originalItem && originalItem->isAncestorOf(item)) { + DEBUG() << " found a gesture to cancel" << iter.key(); + iter.key()->d_func()->state = Qt::GestureCanceled; + canceledGestures << iter.key(); + } + ++iter; + } + + // sort them per target item by cherry picking from almostCanceledGestures and delivering + QSet almostCanceledGestures = canceledGestures; + QSet::Iterator setIter; + while (!almostCanceledGestures.isEmpty()) { + QGraphicsObject *target = 0; + QSet gestures; + setIter = almostCanceledGestures.begin(); + // sort per target item + while (setIter != almostCanceledGestures.end()) { + QGraphicsObject *item = gestureTargets.value(*setIter); + if (target == 0) + target = item; + if (target == item) { + gestures << *setIter; + setIter = almostCanceledGestures.erase(setIter); + } else { + ++setIter; + } + } + Q_ASSERT(target); + + QList list = gestures.toList(); + QGestureEvent ev(list); + sendEvent(target, &ev); + + foreach (QGesture *g, list) { + if (ev.isAccepted() || ev.isAccepted(g)) + gestures.remove(g); + } + + foreach (QGesture *g, gestures) { + if (!g->hasHotSpot()) + continue; + + QPoint screenPos = g->hotSpot().toPoint(); + QList items = itemsAtPosition(screenPos, QPointF(), viewport); + for (int j = 0; j < items.size(); ++j) { + QGraphicsObject *item = items.at(j)->toGraphicsObject(); + if (!item) + continue; + QGraphicsItemPrivate *d = item->QGraphicsItem::d_func(); + if (d->gestureContext.contains(g->gestureType())) { + QList list; + list << g; + QGestureEvent ev(list); + sendEvent(item, &ev); + if (ev.isAccepted() || ev.isAccepted(g)) + break; // successfully delivered + } + } + } + } + + QGestureManager *gm = QApplicationPrivate::instance()->gestureManager; + Q_ASSERT(gm); // it would be very odd if we got called without a manager. + for (setIter = canceledGestures.begin(); setIter != canceledGestures.end(); ++setIter) { + gm->recycle(*setIter); + gestureTargets.remove(*setIter); + } +} + QT_END_NAMESPACE #include "moc_qgraphicsscene.cpp" diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index cd20fd0..f8db084 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -288,6 +288,7 @@ public: QMap *conflictedGestures, QList > *conflictedItems, QHash *normalGestures); + void cancelGesturesForChildren(QGesture *original, QWidget *viewport); void updateInputMethodSensitivityInViews(); diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h index 524d26e..8614ecb 100644 --- a/src/gui/kernel/qgesture.h +++ b/src/gui/kernel/qgesture.h @@ -97,6 +97,7 @@ private: friend class QGestureEvent; friend class QGestureRecognizer; friend class QGestureManager; + friend class QGraphicsScenePrivate; }; class QPanGesturePrivate; diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index f1abc89..1d33c84 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -346,12 +346,7 @@ bool QGestureManager::filterEventThroughContexts(const QMultiHash endedGestures = finishedGestures + canceledGestures + undeliveredGestures; foreach (QGesture *gesture, endedGestures) { - if (QGestureRecognizer *recognizer = m_gestureToRecognizer.value(gesture, 0)) { - gesture->setGestureCancelPolicy(QGesture::CancelNone); - recognizer->reset(gesture); - } else { - cleanupGesturesForRemovedRecognizer(gesture); - } + recycle(gesture); m_gestureTargets.remove(gesture); } return ret; @@ -409,15 +404,8 @@ void QGestureManager::cancelGesturesForChildren(QGesture *original) deliverEvents(gestures, &undeliveredGestures); } - for (iter = cancelledGestures.begin(); iter != cancelledGestures.end(); ++iter) { - QGestureRecognizer *recognizer = m_gestureToRecognizer.value(*iter, 0); - if (recognizer) { - (*iter)->setGestureCancelPolicy(QGesture::CancelNone); - recognizer->reset(*iter); - } else { - cleanupGesturesForRemovedRecognizer(*iter); - } - } + for (iter = cancelledGestures.begin(); iter != cancelledGestures.end(); ++iter) + recycle(*iter); } void QGestureManager::cleanupGesturesForRemovedRecognizer(QGesture *gesture) @@ -667,19 +655,24 @@ void QGestureManager::timerEvent(QTimerEvent *event) it = m_maybeGestures.erase(it); DEBUG() << "QGestureManager::timerEvent: gesture stopped due to timeout:" << gesture; - QGestureRecognizer *recognizer = m_gestureToRecognizer.value(gesture, 0); - if (recognizer) { - gesture->setGestureCancelPolicy(QGesture::CancelNone); - recognizer->reset(gesture); - } else { - cleanupGesturesForRemovedRecognizer(gesture); - } + recycle(gesture); } else { ++it; } } } +void QGestureManager::recycle(QGesture *gesture) +{ + QGestureRecognizer *recognizer = m_gestureToRecognizer.value(gesture, 0); + if (recognizer) { + gesture->setGestureCancelPolicy(QGesture::CancelNone); + recognizer->reset(gesture); + } else { + cleanupGesturesForRemovedRecognizer(gesture); + } +} + QT_END_NAMESPACE #include "moc_qgesturemanager_p.cpp" diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index 4958cdb..d60aedc 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -81,6 +81,8 @@ public: void cleanupCachedGestures(QObject *target, Qt::GestureType type); + void recycle(QGesture *gesture); + protected: void timerEvent(QTimerEvent *event); bool filterEventThroughContexts(const QMultiHash &contexts, -- cgit v0.12 From 6584d601f9569ce7bfc704cb604472d324dfd253 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 30 Oct 2009 14:48:24 +0100 Subject: One signal/slot connection is enough, when exporting N signals to DBus When exporting an object to DBus, and the object has N signals, this code was connecting the QDBusConnectionPrivate multiple times to the destroyed signal of the object. Merge-request: 1961 Reviewed-by: Olivier Goffart --- 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 fb2dd77..686b56f 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1937,7 +1937,7 @@ void QDBusConnectionPrivate::connectSignal(const QString &key, const SignalHook { signalHooks.insertMulti(key, hook); connect(hook.obj, SIGNAL(destroyed(QObject*)), SLOT(objectDestroyed(QObject*)), - Qt::DirectConnection); + Qt::ConnectionType(Qt::DirectConnection | Qt::UniqueConnection)); MatchRefCountHash::iterator it = matchRefCounts.find(hook.matchRule); -- cgit v0.12 From 157e218d90ba832b2846889e9f7c94c95ed2cfbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 30 Oct 2009 14:18:43 +0100 Subject: Fix issue with wrong QMessagebox icons on Mac. Task: QTBUG-4988 68c0e6a8ba1e92bf0152adcaa86eebb83dcfd1d8 introduced a regression preventing the mac-spesific standardIcon code form being called. Call the Mac code if desktopSettingsAware is set. (QIcon::themeName() is only set on X11) --- src/gui/styles/qcommonstyle.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index 70d130a..1564a3f 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -5657,10 +5657,11 @@ QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, cons default: break; } - + } // if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) if (!icon.isNull()) return icon; #if defined(Q_WS_MAC) + if (QApplication::desktopSettingsAware()) { OSType iconType = 0; switch (standardIcon) { case QStyle::SP_MessageBoxQuestion: @@ -5751,8 +5752,8 @@ QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, cons ReleaseIconRef(overlayIcon); return retIcon; } + } // if (QApplication::desktopSettingsAware()) #endif // Q_WS_MAC - } switch (standardIcon) { #ifndef QT_NO_IMAGEFORMAT_PNG -- cgit v0.12 From 5cca60ad593cc5b8778d7be0b8137ffecd34b247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 30 Oct 2009 14:22:06 +0100 Subject: Fix indentation. --- src/gui/styles/qcommonstyle.cpp | 178 ++++++++++++++++++++-------------------- 1 file changed, 89 insertions(+), 89 deletions(-) diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index 1564a3f..84e046f 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -5662,96 +5662,96 @@ QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, cons return icon; #if defined(Q_WS_MAC) if (QApplication::desktopSettingsAware()) { - OSType iconType = 0; - switch (standardIcon) { - case QStyle::SP_MessageBoxQuestion: - case QStyle::SP_MessageBoxInformation: - case QStyle::SP_MessageBoxWarning: - case QStyle::SP_MessageBoxCritical: - iconType = kGenericApplicationIcon; - break; - case SP_DesktopIcon: - iconType = kDesktopIcon; - break; - case SP_TrashIcon: - iconType = kTrashIcon; - break; - case SP_ComputerIcon: - iconType = kComputerIcon; - break; - case SP_DriveFDIcon: - iconType = kGenericFloppyIcon; - break; - case SP_DriveHDIcon: - iconType = kGenericHardDiskIcon; - break; - case SP_DriveCDIcon: - case SP_DriveDVDIcon: - iconType = kGenericCDROMIcon; - break; - case SP_DriveNetIcon: - iconType = kGenericNetworkIcon; - break; - case SP_DirOpenIcon: - iconType = kOpenFolderIcon; - break; - case SP_DirClosedIcon: - case SP_DirLinkIcon: - iconType = kGenericFolderIcon; - break; - case SP_FileLinkIcon: - case SP_FileIcon: - iconType = kGenericDocumentIcon; - break; - case SP_DirIcon: { - // A rather special case - QIcon closeIcon = QStyle::standardIcon(SP_DirClosedIcon, option, widget); - QIcon openIcon = QStyle::standardIcon(SP_DirOpenIcon, option, widget); - closeIcon.addPixmap(openIcon.pixmap(16, 16), QIcon::Normal, QIcon::On); - closeIcon.addPixmap(openIcon.pixmap(32, 32), QIcon::Normal, QIcon::On); - closeIcon.addPixmap(openIcon.pixmap(64, 64), QIcon::Normal, QIcon::On); - closeIcon.addPixmap(openIcon.pixmap(128, 128), QIcon::Normal, QIcon::On); - return closeIcon; - } - case SP_TitleBarNormalButton: - case SP_TitleBarCloseButton: { - QIcon titleBarIcon; - if (standardIcon == SP_TitleBarCloseButton) { - titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/closedock-16.png")); - titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/closedock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On); - } else { - titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/dockdock-16.png")); - titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/dockdock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On); + OSType iconType = 0; + switch (standardIcon) { + case QStyle::SP_MessageBoxQuestion: + case QStyle::SP_MessageBoxInformation: + case QStyle::SP_MessageBoxWarning: + case QStyle::SP_MessageBoxCritical: + iconType = kGenericApplicationIcon; + break; + case SP_DesktopIcon: + iconType = kDesktopIcon; + break; + case SP_TrashIcon: + iconType = kTrashIcon; + break; + case SP_ComputerIcon: + iconType = kComputerIcon; + break; + case SP_DriveFDIcon: + iconType = kGenericFloppyIcon; + break; + case SP_DriveHDIcon: + iconType = kGenericHardDiskIcon; + break; + case SP_DriveCDIcon: + case SP_DriveDVDIcon: + iconType = kGenericCDROMIcon; + break; + case SP_DriveNetIcon: + iconType = kGenericNetworkIcon; + break; + case SP_DirOpenIcon: + iconType = kOpenFolderIcon; + break; + case SP_DirClosedIcon: + case SP_DirLinkIcon: + iconType = kGenericFolderIcon; + break; + case SP_FileLinkIcon: + case SP_FileIcon: + iconType = kGenericDocumentIcon; + break; + case SP_DirIcon: { + // A rather special case + QIcon closeIcon = QStyle::standardIcon(SP_DirClosedIcon, option, widget); + QIcon openIcon = QStyle::standardIcon(SP_DirOpenIcon, option, widget); + closeIcon.addPixmap(openIcon.pixmap(16, 16), QIcon::Normal, QIcon::On); + closeIcon.addPixmap(openIcon.pixmap(32, 32), QIcon::Normal, QIcon::On); + closeIcon.addPixmap(openIcon.pixmap(64, 64), QIcon::Normal, QIcon::On); + closeIcon.addPixmap(openIcon.pixmap(128, 128), QIcon::Normal, QIcon::On); + return closeIcon; + } + case SP_TitleBarNormalButton: + case SP_TitleBarCloseButton: { + QIcon titleBarIcon; + if (standardIcon == SP_TitleBarCloseButton) { + titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/closedock-16.png")); + titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/closedock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On); + } else { + titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/dockdock-16.png")); + titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/dockdock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On); + } + return titleBarIcon; + } + default: + break; + } + if (iconType != 0) { + QIcon retIcon; + IconRef icon; + IconRef overlayIcon = 0; + if (iconType != kGenericApplicationIcon) { + GetIconRef(kOnSystemDisk, kSystemIconsCreator, iconType, &icon); + } else { + FSRef fsRef; + ProcessSerialNumber psn = { 0, kCurrentProcess }; + GetProcessBundleLocation(&psn, &fsRef); + GetIconRefFromFileInfo(&fsRef, 0, 0, 0, 0, kIconServicesNormalUsageFlag, &icon, 0); + if (standardIcon == SP_MessageBoxCritical) { + overlayIcon = icon; + GetIconRef(kOnSystemDisk, kSystemIconsCreator, kAlertCautionIcon, &icon); + } + } + if (icon) { + qt_mac_constructQIconFromIconRef(icon, overlayIcon, &retIcon, standardIcon); + ReleaseIconRef(icon); + } + if (overlayIcon) + ReleaseIconRef(overlayIcon); + return retIcon; } - return titleBarIcon; - } - default: - break; - } - if (iconType != 0) { - QIcon retIcon; - IconRef icon; - IconRef overlayIcon = 0; - if (iconType != kGenericApplicationIcon) { - GetIconRef(kOnSystemDisk, kSystemIconsCreator, iconType, &icon); - } else { - FSRef fsRef; - ProcessSerialNumber psn = { 0, kCurrentProcess }; - GetProcessBundleLocation(&psn, &fsRef); - GetIconRefFromFileInfo(&fsRef, 0, 0, 0, 0, kIconServicesNormalUsageFlag, &icon, 0); - if (standardIcon == SP_MessageBoxCritical) { - overlayIcon = icon; - GetIconRef(kOnSystemDisk, kSystemIconsCreator, kAlertCautionIcon, &icon); - } - } - if (icon) { - qt_mac_constructQIconFromIconRef(icon, overlayIcon, &retIcon, standardIcon); - ReleaseIconRef(icon); - } - if (overlayIcon) - ReleaseIconRef(overlayIcon); - return retIcon; - } } // if (QApplication::desktopSettingsAware()) #endif // Q_WS_MAC -- cgit v0.12 From 4510c18ed3ffd2c01d11159fc2d2ec7f0eb48e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 30 Oct 2009 14:49:05 +0100 Subject: Fix QDesktopServices::DataLocation on Mac. DataLocation now behaves as on the other platforms, QCoreApplication::organizationName() and applicationName() is included in the returned path. --- dist/changes-4.6.0 | 4 ++++ src/gui/util/qdesktopservices.cpp | 9 --------- src/gui/util/qdesktopservices_mac.cpp | 9 ++++++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 7f723da..abe4427 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -143,3 +143,7 @@ information about a particular change. function setFloatingPointPrecision(). Set Qt_4_5 as the version of the QDataStream to get the behavior of previous versions. + - On Mac OS X, QDesktopServices::storageLocation(DataLocation) now includes + QCoreApplication::organizationName() and QCoreApplication::applicationName() + if those are set. This matches the behavior on the other platforms. + \ No newline at end of file diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp index 1690d87..85b539f 100644 --- a/src/gui/util/qdesktopservices.cpp +++ b/src/gui/util/qdesktopservices.cpp @@ -294,15 +294,6 @@ void QDesktopServices::unsetUrlHandler(const QString &scheme) Rest of the standard locations point to folder on same drive with executable, except that if executable is in ROM the folder from C drive is returned. - \note On Mac OS X, DataLocation does not include QCoreApplication::organizationName. - Use code like this to add it: - - \code - QString location = QDesktopServices::storageLocation(QDesktopServices::DataLocation); - #ifdef Q_WS_MAC - location.insert(location.count() - QCoreApplication::applicationName().count(), - QCoreApplication::organizationName() + "/"); - #endif \endcode */ diff --git a/src/gui/util/qdesktopservices_mac.cpp b/src/gui/util/qdesktopservices_mac.cpp index 0626e0a..23f9e60 100644 --- a/src/gui/util/qdesktopservices_mac.cpp +++ b/src/gui/util/qdesktopservices_mac.cpp @@ -153,9 +153,12 @@ QString QDesktopServices::storageLocation(StandardLocation type) QString path = getFullPath(ref); - QString appName = QCoreApplication::applicationName(); - if (!appName.isEmpty() && (type == DataLocation || type == CacheLocation)) - path += QLatin1Char('/') + appName; + if (type == DataLocation || type == CacheLocation) { + if (QCoreApplication::organizationName().isEmpty() == false) + path += QLatin1Char('/') + QCoreApplication::organizationName(); + if (QCoreApplication::applicationName().isEmpty() == false) + path += QLatin1Char('/') + QCoreApplication::applicationName(); + } return path; } -- cgit v0.12 From 4f10520a2a931ed0cccba3d36d9c196902049282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Fri, 30 Oct 2009 15:53:28 +0200 Subject: S60Style: User set header view palettes are ignored QS60Style ignores user defined palettes for QHeaderViews. With this fix, style takes palette changes into account and also draws QTableCornerButton correctly. Task-number: QTBUG-4522 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index dc38397..10a63a8 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1752,7 +1752,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, #endif //QT_NO_MENUBAR case CE_HeaderSection: - if ( const QStyleOptionHeader *header = qstyleoption_cast(option)) { + if (const QStyleOptionHeader *header = qstyleoption_cast(option)) { painter->save(); QPen linePen = QPen(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 1, header)); const int penWidth = (header->orientation == Qt::Horizontal) ? @@ -1770,6 +1770,25 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, } } painter->restore(); + + //Draw corner button as normal pushButton. + if (qobject_cast(widget)) { + //Make cornerButton slightly smaller so that it is not on top of table border graphic. + QStyleOptionHeader subopt = *header; + const int borderTweak = + QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth)>>1; + if (subopt.direction == Qt::LeftToRight) + subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak); + else + subopt.rect.adjust(0, borderTweak, -borderTweak, -borderTweak); + drawPrimitive(PE_PanelButtonBevel, &subopt, painter, widget); + } else if ((header->palette.brush(QPalette::Button) != Qt::transparent)) { + //Draw non-themed background. Background for theme is drawn in CE_ShapedFrame + //to get continuous theme graphic across all the header cells. + qDrawShadePanel(painter, header->rect, header->palette, + header->state & (State_Sunken | State_On), penWidth, + &header->palette.brush(QPalette::Button)); + } } break; case CE_HeaderEmptyArea: // no need to draw this @@ -1840,15 +1859,24 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, } else if (qobject_cast(widget)) { QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableItem, painter, option->rect, flags); } else if (const QHeaderView *header = qobject_cast(widget)) { - if (header->orientation() == Qt::Horizontal) { - QRect headerRect = option->rect; - const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); - headerRect.adjust(0,frameWidth,-2*frameWidth,0); - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, headerRect, flags); - } else { + //QS60style draws header background here instead of in each headersection, to get + //continuous graphic from section to section. + QS60StylePrivate::SkinElementFlags adjustableFlags = flags; + QRect headerRect = option->rect; + if (header->orientation() != Qt::Horizontal) { //todo: update to horizontal table graphic - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, option->rect, flags | QS60StylePrivate::SF_PointWest); + adjustableFlags = (adjustableFlags | QS60StylePrivate::SF_PointWest); + } else { + const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); + if (option->direction == Qt::LeftToRight) + headerRect.adjust(-2*frameWidth, 0, 0, 0); + else + headerRect.adjust(0, 0, 2*frameWidth, 0); } + if (option->palette.brush(QPalette::Button).color() == Qt::transparent) + QS60StylePrivate::drawSkinElement( + QS60StylePrivate::SE_TableHeaderItem, painter, headerRect, adjustableFlags); + } else if (qobject_cast(widget)) { QCommonStyle::drawControl(element, option, painter, widget); } -- cgit v0.12 From a3dbe4c00062ad78c924162841cc2d83709b1ea4 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 30 Oct 2009 15:07:47 +0100 Subject: Animations in mainwindow could sometimes misplace the tabbar We used to not start an animation of the current geometry was already set. The problem is that starting this animation might stop another animation. This has to happen. Otherwise subsequent calls to animate a widget might or might not be executed. Reviewed-by: ogoffart --- src/gui/widgets/qwidgetanimator.cpp | 7 ------- src/gui/widgets/qwidgetanimator_p.h | 1 - 2 files changed, 8 deletions(-) diff --git a/src/gui/widgets/qwidgetanimator.cpp b/src/gui/widgets/qwidgetanimator.cpp index f440961..4a7ae00 100644 --- a/src/gui/widgets/qwidgetanimator.cpp +++ b/src/gui/widgets/qwidgetanimator.cpp @@ -88,8 +88,6 @@ void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, boo const QRect final_geometry = _final_geometry.isValid() || widget->isWindow() ? _final_geometry : QRect(QPoint(-500 - widget->width(), -500 - widget->height()), widget->size()); - if (r == final_geometry) - return; //the widget is already where it should be #ifndef QT_NO_ANIMATION AnimationMap::const_iterator it = m_animation_map.constFind(widget); if (it != m_animation_map.constEnd() && (*it)->endValue().toRect() == final_geometry) @@ -114,9 +112,4 @@ bool QWidgetAnimator::animating() const return !m_animation_map.isEmpty(); } -bool QWidgetAnimator::animating(QWidget *widget) const -{ - return m_animation_map.contains(widget); -} - QT_END_NAMESPACE diff --git a/src/gui/widgets/qwidgetanimator_p.h b/src/gui/widgets/qwidgetanimator_p.h index 68d9344..095380f 100644 --- a/src/gui/widgets/qwidgetanimator_p.h +++ b/src/gui/widgets/qwidgetanimator_p.h @@ -70,7 +70,6 @@ public: QWidgetAnimator(QMainWindowLayout *layout); void animate(QWidget *widget, const QRect &final_geometry, bool animate); bool animating() const; - bool animating(QWidget *widget) const; void abort(QWidget *widget); -- cgit v0.12 From 8910b449dafcb3475ab8c6f90213cd632412da68 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Fri, 30 Oct 2009 16:08:46 +0200 Subject: Fixed statuspane visibility after dialog closed from fullsreen widget. - Comparing TBool == bool did not work correctly since TBool is effectively int. For example statusPane->IsVisible() in this particular case returns 2, which compared to true as an int fails. Casting to bool seems to solve the problem. Another possibility would be to use Symbian COMPARE_BOOLS macro. - Changing statuspane visibility now affects to widget size also - Some tab/space fixes Task-number: QTBUG-4876 Reviewed-by: Sami Merila --- src/gui/kernel/qapplication_s60.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 30bf99a..e5ee2f1 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -836,7 +836,7 @@ void QSymbianControl::Draw(const TRect& controlRect) const if (qwidget->d_func()->isOpaque) gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); gc.BitBlt(controlRect.iTl, bitmap, backingStoreRect); - } + } } else { surface->flush(qwidget, QRegion(qt_TRect2QRect(backingStoreRect)), QPoint()); } @@ -910,9 +910,9 @@ void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */) CEikStatusPane* statusPane = S60->statusPane(); CEikButtonGroupContainer* buttonGroup = S60->buttonGroupContainer(); bool isFullscreen = qwidget->windowState() & Qt::WindowFullScreen; - if (statusPane && (statusPane->IsVisible() == isFullscreen)) + if (statusPane && (bool)statusPane->IsVisible() == isFullscreen) statusPane->MakeVisible(!isFullscreen); - if (buttonGroup && (buttonGroup->IsVisible() == isFullscreen)) + if (buttonGroup && (bool)buttonGroup->IsVisible() == isFullscreen) buttonGroup->MakeVisible(!isFullscreen); #endif } else if (QApplication::activeWindow() == qwidget->window()) { @@ -925,6 +925,12 @@ void QSymbianControl::HandleResourceChange(int resourceType) { switch (resourceType) { case KInternalStatusPaneChange: + if (qwidget->isFullScreen()) { + SetExtentToWholeScreen(); + } else if (qwidget->isMaximized()) { + TRect r = static_cast(S60->appUi())->ClientRect(); + SetExtent(r.iTl, r.Size()); + } qwidget->d_func()->setWindowIcon_sys(true); break; case KUidValueCoeFontChangeEvent: @@ -1080,9 +1086,9 @@ void qt_init(QApplicationPrivate * /* priv */, int) // enable focus events - used to re-enable mouse after focus changed between mouse and non mouse app, // and for dimming behind modal windows - S60->windowGroup().EnableFocusChangeEvents(); + S60->windowGroup().EnableFocusChangeEvents(); - //Check if mouse interaction is supported (either EMouse=1 in the HAL, or EMachineUID is one of the phones known to support this) + //Check if mouse interaction is supported (either EMouse=1 in the HAL, or EMachineUID is one of the phones known to support this) const TInt KMachineUidSamsungI8510 = 0x2000C51E; // HAL::Get(HALData::EPen, TInt& result) may set 'result' to 1 on some 3.1 systems (e.g. N95). // But we know that S60 systems below 5.0 did not support touch. @@ -1560,7 +1566,7 @@ int QApplicationPrivate::symbianProcessWsEvent(const TWsEvent *event) } #endif break; - default: + default: break; } -- cgit v0.12 From e2b6e32fe128f094a47dad2be6b2ee797bfe3ff4 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 30 Oct 2009 17:16:49 +0100 Subject: Reduced file sizes. SVG graphics may contain much unneeded stuff. I used Inkscape's vacuum function and Ariya's svgmin. Much better now. Reviewed-By: trustme --- .../weatherinfo/icons/weather-few-clouds.svg | 791 +-- demos/embedded/weatherinfo/icons/weather-fog.svg | 1643 +----- demos/embedded/weatherinfo/icons/weather-haze.svg | 1231 +---- demos/embedded/weatherinfo/icons/weather-icy.svg | 278 +- .../weatherinfo/icons/weather-overcast.svg | 3131 +----------- .../embedded/weatherinfo/icons/weather-showers.svg | 4850 +----------------- demos/embedded/weatherinfo/icons/weather-sleet.svg | 5332 +------------------- demos/embedded/weatherinfo/icons/weather-snow.svg | 2076 +------- demos/embedded/weatherinfo/icons/weather-storm.svg | 4420 +--------------- .../icons/weather-sunny-very-few-clouds.svg | 626 +-- demos/embedded/weatherinfo/icons/weather-sunny.svg | 1328 +---- .../weatherinfo/icons/weather-thundershower.svg | 4725 +---------------- 12 files changed, 1446 insertions(+), 28985 deletions(-) diff --git a/demos/embedded/weatherinfo/icons/weather-few-clouds.svg b/demos/embedded/weatherinfo/icons/weather-few-clouds.svg index 57d45e9..a53e3d6 100644 --- a/demos/embedded/weatherinfo/icons/weather-few-clouds.svg +++ b/demos/embedded/weatherinfo/icons/weather-few-clouds.svg @@ -1,337 +1,70 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - - + + + + + - - - - - + + + + + - - - - + + + + - - - + + + - - + + - + image/svg+xml - + weather-clear January 2006 @@ -352,386 +85,88 @@ notification - + Garrett LeSage - - - - + + + + - - - - - - - + + + + + + + - - - - - + + + + + - - - + + + - - - + + + - - - - - + + + + + - - - - + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - + + + - - - + + + - - - - - + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-fog.svg b/demos/embedded/weatherinfo/icons/weather-fog.svg index a9a4ca8..56a2444 100644 --- a/demos/embedded/weatherinfo/icons/weather-fog.svg +++ b/demos/embedded/weatherinfo/icons/weather-fog.svg @@ -1,1585 +1,114 @@ - - - - - - + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - + + - + image/svg+xml - + - - - - - - - - + + + + + + + + - - - - - + + + + + - - - + + + - - - + + + - - - - - + + + + + - - - - - - - + + + + + + + - - - - - + + + + + - - - + + + - - - + + + - - - - - + + + + + - + diff --git a/demos/embedded/weatherinfo/icons/weather-haze.svg b/demos/embedded/weatherinfo/icons/weather-haze.svg index f2d6671..b31811f 100644 --- a/demos/embedded/weatherinfo/icons/weather-haze.svg +++ b/demos/embedded/weatherinfo/icons/weather-haze.svg @@ -1,1121 +1,162 @@ - - - - - - - + + + + + + - - - + + + - - - + + + - - - + + + + - - - + + + - - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + - + - + image/svg+xml - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - + + diff --git a/demos/embedded/weatherinfo/icons/weather-icy.svg b/demos/embedded/weatherinfo/icons/weather-icy.svg index fe42860..2c45b33 100644 --- a/demos/embedded/weatherinfo/icons/weather-icy.svg +++ b/demos/embedded/weatherinfo/icons/weather-icy.svg @@ -1,255 +1,51 @@ - - - - - - + + + + + - - - + + + - - - + + + - - - + + + - - - - - - + + + + + - - + + - + image/svg+xml - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-overcast.svg b/demos/embedded/weatherinfo/icons/weather-overcast.svg index 35fb4a4..cf77214 100644 --- a/demos/embedded/weatherinfo/icons/weather-overcast.svg +++ b/demos/embedded/weatherinfo/icons/weather-overcast.svg @@ -1,2554 +1,81 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + image/svg+xml - + weather-overcast January 2006 @@ -2569,466 +96,94 @@ notify - + - - - - + + + + - - - - - - - - + + + + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - - - + + + + + + - - - - - + + + + + - - - + + + - - - + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - + + + - - - + + + - - - - - + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-showers.svg b/demos/embedded/weatherinfo/icons/weather-showers.svg index c814571..017665d 100644 --- a/demos/embedded/weatherinfo/icons/weather-showers.svg +++ b/demos/embedded/weatherinfo/icons/weather-showers.svg @@ -1,4297 +1,83 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + image/svg+xml - + weather-showers January 2006 @@ -4312,441 +98,81 @@ notify - + - - - - + + + + - - - - - - - + + + + + + + - - - - - - - - + + + + + + + + - - - + + + - - - + + + - - - + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-sleet.svg b/demos/embedded/weatherinfo/icons/weather-sleet.svg index f1cb9eb..bf2306f 100644 --- a/demos/embedded/weatherinfo/icons/weather-sleet.svg +++ b/demos/embedded/weatherinfo/icons/weather-sleet.svg @@ -1,4573 +1,96 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + image/svg+xml - + weather-showers January 2006 @@ -4588,608 +111,119 @@ notify - + - - - - - - - + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - + + + - - - + + + - - - + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - - - - - + + + + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-snow.svg b/demos/embedded/weatherinfo/icons/weather-snow.svg index 6c7b4ad..a91946f 100644 --- a/demos/embedded/weatherinfo/icons/weather-snow.svg +++ b/demos/embedded/weatherinfo/icons/weather-snow.svg @@ -1,1418 +1,81 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + image/svg+xml - + weather-snow January 2006 @@ -1433,542 +96,105 @@ notification - + - - - - + + + + - - - - - - - - + + + + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - - - + + + + + + - - - - - + + + + + - - - + + + - - - + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - + + + - - - + + + - - - - - + + + + + - - - - - - - - + + + + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-storm.svg b/demos/embedded/weatherinfo/icons/weather-storm.svg index 4d8bfec..1ad47ab 100644 --- a/demos/embedded/weatherinfo/icons/weather-storm.svg +++ b/demos/embedded/weatherinfo/icons/weather-storm.svg @@ -1,3851 +1,94 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + image/svg+xml - + weather-storm January 2006 @@ -3866,443 +109,82 @@ notify - + - - - - + + + + - - - - - - - - + + + + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + diff --git a/demos/embedded/weatherinfo/icons/weather-sunny-very-few-clouds.svg b/demos/embedded/weatherinfo/icons/weather-sunny-very-few-clouds.svg index 93b0009..a27d30a 100644 --- a/demos/embedded/weatherinfo/icons/weather-sunny-very-few-clouds.svg +++ b/demos/embedded/weatherinfo/icons/weather-sunny-very-few-clouds.svg @@ -1,337 +1,63 @@ - - - - - - - - - - - - - - - + + + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - - + + + + + - - - - - + + + + + - - - - + + + + - - - + + + - - + + - + image/svg+xml - + weather-clear January 2006 @@ -352,241 +78,63 @@ notification - + Garrett LeSage - - - - - - - + + + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - + + + - - - + + + - - - - - + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-sunny.svg b/demos/embedded/weatherinfo/icons/weather-sunny.svg index 0360ac7..248199c 100644 --- a/demos/embedded/weatherinfo/icons/weather-sunny.svg +++ b/demos/embedded/weatherinfo/icons/weather-sunny.svg @@ -1,1225 +1,32 @@ - - - - - - - - + + + + + + - - - - - + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - + + - + image/svg+xml - + weather-clear January 2006 @@ -1240,89 +47,34 @@ notification - + Garrett LeSage - - - - - - - + + + + + + + - - - - - + + + + + - - - - - + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-thundershower.svg b/demos/embedded/weatherinfo/icons/weather-thundershower.svg index 406abfa..e1c2286 100644 --- a/demos/embedded/weatherinfo/icons/weather-thundershower.svg +++ b/demos/embedded/weatherinfo/icons/weather-thundershower.svg @@ -1,4064 +1,108 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + image/svg+xml - + weather-storm January 2006 @@ -4079,508 +123,101 @@ notify - + - - - - - - - + + + + + + + - - - - - - - - - + + + + + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - - + + + + - - - - + + + + -- cgit v0.12 From d5254dde567ef493d4df079a709b54c85e604a18 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 30 Oct 2009 17:18:02 +0100 Subject: Reducing file sizes. Using pngout to make the fluidlauncher a bit lighter. Reviewed-by: trustme --- .../fluidlauncher/screenshots/context2d_s60.png | Bin 39405 -> 39185 bytes .../screenshots/desktopservices_s60.png | Bin 31757 -> 31504 bytes .../fluidlauncher/screenshots/digiflip.png | Bin 3508 -> 2039 bytes .../fluidlauncher/screenshots/flickable.png | Bin 21107 -> 14141 bytes .../fluidlauncher/screenshots/flightinfo_s60.png | Bin 24473 -> 20482 bytes .../fluidlauncher/screenshots/lightmaps.png | Bin 114178 -> 79501 bytes .../fluidlauncher/screenshots/mediaplayer.png | Bin 98092 -> 80411 bytes .../fluidlauncher/screenshots/raycasting.png | Bin 43006 -> 11984 bytes .../fluidlauncher/screenshots/weatherinfo.png | Bin 38521 -> 34472 bytes demos/embedded/fluidlauncher/slides/demo_1.png | Bin 23539 -> 20560 bytes demos/embedded/fluidlauncher/slides/demo_2.png | Bin 11745 -> 5209 bytes demos/embedded/fluidlauncher/slides/demo_5.png | Bin 15890 -> 6130 bytes demos/embedded/fluidlauncher/slides/demo_6.png | Bin 14992 -> 5826 bytes 13 files changed, 0 insertions(+), 0 deletions(-) diff --git a/demos/embedded/fluidlauncher/screenshots/context2d_s60.png b/demos/embedded/fluidlauncher/screenshots/context2d_s60.png index c7225c7..9c288c9 100644 Binary files a/demos/embedded/fluidlauncher/screenshots/context2d_s60.png and b/demos/embedded/fluidlauncher/screenshots/context2d_s60.png differ diff --git a/demos/embedded/fluidlauncher/screenshots/desktopservices_s60.png b/demos/embedded/fluidlauncher/screenshots/desktopservices_s60.png index a429be3..64018f4 100644 Binary files a/demos/embedded/fluidlauncher/screenshots/desktopservices_s60.png and b/demos/embedded/fluidlauncher/screenshots/desktopservices_s60.png differ diff --git a/demos/embedded/fluidlauncher/screenshots/digiflip.png b/demos/embedded/fluidlauncher/screenshots/digiflip.png index 117b61b..c31a6f8 100644 Binary files a/demos/embedded/fluidlauncher/screenshots/digiflip.png and b/demos/embedded/fluidlauncher/screenshots/digiflip.png differ diff --git a/demos/embedded/fluidlauncher/screenshots/flickable.png b/demos/embedded/fluidlauncher/screenshots/flickable.png index 7080fc1..bad14bf 100644 Binary files a/demos/embedded/fluidlauncher/screenshots/flickable.png and b/demos/embedded/fluidlauncher/screenshots/flickable.png differ diff --git a/demos/embedded/fluidlauncher/screenshots/flightinfo_s60.png b/demos/embedded/fluidlauncher/screenshots/flightinfo_s60.png index 8a304eb..8e74d77 100644 Binary files a/demos/embedded/fluidlauncher/screenshots/flightinfo_s60.png and b/demos/embedded/fluidlauncher/screenshots/flightinfo_s60.png differ diff --git a/demos/embedded/fluidlauncher/screenshots/lightmaps.png b/demos/embedded/fluidlauncher/screenshots/lightmaps.png index 7cbe2e4..18aa74d 100644 Binary files a/demos/embedded/fluidlauncher/screenshots/lightmaps.png and b/demos/embedded/fluidlauncher/screenshots/lightmaps.png differ diff --git a/demos/embedded/fluidlauncher/screenshots/mediaplayer.png b/demos/embedded/fluidlauncher/screenshots/mediaplayer.png index 2d8a637..c9fd43c 100644 Binary files a/demos/embedded/fluidlauncher/screenshots/mediaplayer.png and b/demos/embedded/fluidlauncher/screenshots/mediaplayer.png differ diff --git a/demos/embedded/fluidlauncher/screenshots/raycasting.png b/demos/embedded/fluidlauncher/screenshots/raycasting.png index d3c86e9..b6b738a 100644 Binary files a/demos/embedded/fluidlauncher/screenshots/raycasting.png and b/demos/embedded/fluidlauncher/screenshots/raycasting.png differ diff --git a/demos/embedded/fluidlauncher/screenshots/weatherinfo.png b/demos/embedded/fluidlauncher/screenshots/weatherinfo.png index b18608d..7e23891 100644 Binary files a/demos/embedded/fluidlauncher/screenshots/weatherinfo.png and b/demos/embedded/fluidlauncher/screenshots/weatherinfo.png differ diff --git a/demos/embedded/fluidlauncher/slides/demo_1.png b/demos/embedded/fluidlauncher/slides/demo_1.png index d2952e5..d53d19d 100644 Binary files a/demos/embedded/fluidlauncher/slides/demo_1.png and b/demos/embedded/fluidlauncher/slides/demo_1.png differ diff --git a/demos/embedded/fluidlauncher/slides/demo_2.png b/demos/embedded/fluidlauncher/slides/demo_2.png index 1899825..f137de0 100644 Binary files a/demos/embedded/fluidlauncher/slides/demo_2.png and b/demos/embedded/fluidlauncher/slides/demo_2.png differ diff --git a/demos/embedded/fluidlauncher/slides/demo_5.png b/demos/embedded/fluidlauncher/slides/demo_5.png index 239f08a..0bb1781 100644 Binary files a/demos/embedded/fluidlauncher/slides/demo_5.png and b/demos/embedded/fluidlauncher/slides/demo_5.png differ diff --git a/demos/embedded/fluidlauncher/slides/demo_6.png b/demos/embedded/fluidlauncher/slides/demo_6.png index 0addf37..9daba67 100644 Binary files a/demos/embedded/fluidlauncher/slides/demo_6.png and b/demos/embedded/fluidlauncher/slides/demo_6.png differ -- cgit v0.12 From 9fd3e4746d9b65fa049664ce6d075f1027443fef Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 30 Oct 2009 17:19:34 +0100 Subject: Reducing file sizes. Using pngout to make the fluidlauncher a bit lighter. And to reduce Anomalies memory footprint. Reviewed-by: trustme --- demos/embedded/anomaly/src/images/edit-find.png | Bin 1636 -> 1495 bytes demos/embedded/anomaly/src/images/go-next.png | Bin 1219 -> 1150 bytes demos/embedded/anomaly/src/images/go-previous.png | Bin 1200 -> 1135 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/demos/embedded/anomaly/src/images/edit-find.png b/demos/embedded/anomaly/src/images/edit-find.png index 5594785..b84b1e2 100644 Binary files a/demos/embedded/anomaly/src/images/edit-find.png and b/demos/embedded/anomaly/src/images/edit-find.png differ diff --git a/demos/embedded/anomaly/src/images/go-next.png b/demos/embedded/anomaly/src/images/go-next.png index a68e2db..ed89a36 100644 Binary files a/demos/embedded/anomaly/src/images/go-next.png and b/demos/embedded/anomaly/src/images/go-next.png differ diff --git a/demos/embedded/anomaly/src/images/go-previous.png b/demos/embedded/anomaly/src/images/go-previous.png index c37bc04..44e803d 100644 Binary files a/demos/embedded/anomaly/src/images/go-previous.png and b/demos/embedded/anomaly/src/images/go-previous.png differ -- cgit v0.12 From 9b2d899499c60535a1c9af6dcc48dfa5184dd363 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 30 Oct 2009 17:19:57 +0100 Subject: Reducing file sizes. Using pngout to make the fluidlauncher a bit lighter. Reviewed-by: trustme --- demos/embedded/desktopservices/data/designer.png | Bin 4205 -> 2529 bytes demos/embedded/desktopservices/resources/browser.png | Bin 2739 -> 2525 bytes demos/embedded/desktopservices/resources/message.png | Bin 2234 -> 1989 bytes demos/embedded/desktopservices/resources/music.png | Bin 2322 -> 2123 bytes demos/embedded/desktopservices/resources/photo.png | Bin 2430 -> 2233 bytes 5 files changed, 0 insertions(+), 0 deletions(-) diff --git a/demos/embedded/desktopservices/data/designer.png b/demos/embedded/desktopservices/data/designer.png index 0988fce..1485efa 100644 Binary files a/demos/embedded/desktopservices/data/designer.png and b/demos/embedded/desktopservices/data/designer.png differ diff --git a/demos/embedded/desktopservices/resources/browser.png b/demos/embedded/desktopservices/resources/browser.png index 28561e1..9ecda6b 100644 Binary files a/demos/embedded/desktopservices/resources/browser.png and b/demos/embedded/desktopservices/resources/browser.png differ diff --git a/demos/embedded/desktopservices/resources/message.png b/demos/embedded/desktopservices/resources/message.png index e30052b..78917c7 100644 Binary files a/demos/embedded/desktopservices/resources/message.png and b/demos/embedded/desktopservices/resources/message.png differ diff --git a/demos/embedded/desktopservices/resources/music.png b/demos/embedded/desktopservices/resources/music.png index 11a57bb..cc569cb 100644 Binary files a/demos/embedded/desktopservices/resources/music.png and b/demos/embedded/desktopservices/resources/music.png differ diff --git a/demos/embedded/desktopservices/resources/photo.png b/demos/embedded/desktopservices/resources/photo.png index 5ba15c1..ac81cf3 100644 Binary files a/demos/embedded/desktopservices/resources/photo.png and b/demos/embedded/desktopservices/resources/photo.png differ -- cgit v0.12 From 9440e6a1b3ce4da0a832afeef23e69d9fc55bb47 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 30 Oct 2009 17:20:08 +0100 Subject: Reducing file sizes. Using pngout to make the fluidlauncher a bit lighter. Reviewed-by: trustme --- demos/embedded/flightinfo/aircraft.png | Bin 28713 -> 20200 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/demos/embedded/flightinfo/aircraft.png b/demos/embedded/flightinfo/aircraft.png index 0845cb4..2312bcc 100644 Binary files a/demos/embedded/flightinfo/aircraft.png and b/demos/embedded/flightinfo/aircraft.png differ -- cgit v0.12 From a647abd3d108eb6ce45642713b5786240659816f Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 30 Oct 2009 17:20:17 +0100 Subject: Reducing file sizes. Using pngout to make the fluidlauncher a bit lighter. Reviewed-by: trustme --- demos/embedded/raycasting/textures.png | Bin 42319 -> 17669 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/demos/embedded/raycasting/textures.png b/demos/embedded/raycasting/textures.png index 839488b..2eb1ba7 100644 Binary files a/demos/embedded/raycasting/textures.png and b/demos/embedded/raycasting/textures.png differ -- cgit v0.12 From fd0b91269e1cb46961414d689615ea3f17f6a524 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 30 Oct 2009 17:40:53 +0100 Subject: Reducing file size. Stripping 350k off by reencoding the mp3. 32 Kbps, mono, 22.05 KHz. Reviewed-by: trustme --- demos/embedded/desktopservices/data/sax.mp3 | Bin 417844 -> 104104 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/demos/embedded/desktopservices/data/sax.mp3 b/demos/embedded/desktopservices/data/sax.mp3 index 0a078b1..d77c817 100644 Binary files a/demos/embedded/desktopservices/data/sax.mp3 and b/demos/embedded/desktopservices/data/sax.mp3 differ -- cgit v0.12 From 243bd8c8f47f37b7a066a99bad180310dba2edcb Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 30 Oct 2009 18:36:37 +0100 Subject: Added manual text performance test. Small application that simulates different text rendering scenarios and displays the Fps. Reviewed-by: trustme --- .../manual/textrendering/textperformance/main.cpp | 231 +++++++++++++++++++++ .../textperformance/textperformance.pro | 1 + 2 files changed, 232 insertions(+) create mode 100644 tests/manual/textrendering/textperformance/main.cpp create mode 100644 tests/manual/textrendering/textperformance/textperformance.pro diff --git a/tests/manual/textrendering/textperformance/main.cpp b/tests/manual/textrendering/textperformance/main.cpp new file mode 100644 index 0000000..3019ebf --- /dev/null +++ b/tests/manual/textrendering/textperformance/main.cpp @@ -0,0 +1,231 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +static const int lastMeasurementsCount = 50; + +class FontBlaster: public QWidget +{ + Q_OBJECT + +public: + FontBlaster(QWidget *parent = 0) + : QWidget(parent) + , m_currentMode(0) + { + setFocusPolicy(Qt::StrongFocus); + } + + void paintEvent(QPaintEvent *event) + { + Q_UNUSED(event); + QPainter p(this); + + if (!m_timer.isNull()) + m_lastMeasurements.append(m_timer.elapsed()); + m_timer.start(); + + p.save(); + m_modes[m_currentMode].function(p, size()); + p.restore(); + + const QFontMetrics fm = p.fontMetrics(); + p.setOpacity(0.7); + p.fillRect(0, 0, width(), fm.height(), Qt::gray); + p.fillRect(0, height() - fm.height(), width(), height(), Qt::gray); + p.setOpacity(1); + p.setPen(palette().color(QPalette::Text)); + p.drawText(2, fm.ascent(), m_modes[m_currentMode].name); + + if (m_lastMeasurements.count() == lastMeasurementsCount) { + m_lastMeasurements.removeFirst(); + int lastMsecsSum = 0; + foreach(const int measurement, m_lastMeasurements) + lastMsecsSum += measurement; + + p.drawText(2, height() - fm.descent(), + QLatin1String("Fps: ") + + QString::number(1000 / (qreal)(lastMsecsSum / lastMeasurementsCount), 'f', 1) + ); + } + + QTimer::singleShot(0, this, SLOT(repaint())); + } + + /* + Creating all kinds of size/weight/italic combinations, stress testing + the glyph cache. + Also: painting with different opacities, stress testing blitting. + */ + static void paintDifferentFontStyles(QPainter &p, const QSize &size) + { + static const QString text = QLatin1String("Qt rocks!!!"); + static const int textsPerPaint = 30; + for (int i = 0; i < textsPerPaint; i++) { + const int fontSize = 4 + (qrand() % 5); + const int fontWeight = (qrand() % 2) == 1 ? QFont::Normal : QFont::Bold; + const bool fontItalic = (qrand() % 2) == 1; + const QFont font("Default", fontSize, fontWeight, fontItalic); + p.setFont(font); + p.setPen(QColor::fromHsv(qrand() % 359, 155 + qrand() % 100, + 155 + qrand() % 100, 100 + qrand() % 155)); + const QSize textSize(p.fontMetrics().boundingRect(text).size()); + const QPoint position( + -textSize.width() / 2 + (qrand() % size.width()), + textSize.height() / 2 + (qrand() % size.height())); + p.drawText(position, text); + } + } + + /* + Drawing a multiline latin text, stress testing the text layout system. + */ + static void paintLongLatinText(QPainter &p, const QSize &size) + { + static const char* const pieces[] = { + "lorem ipsum", + "dolor sit amet", + "consectetuer", + "sed diam nonumy", + "eos et accusam", + "sea takimata sanctus" + }; + static const int piecesCount = (int)(sizeof pieces / sizeof pieces[0]); + static const int piecesPerPaint = 30; + + QString text; + for (int i = 0; i < piecesPerPaint; ++i) { + QString piece = QLatin1String(pieces[qrand() % piecesCount]); + if (i == 0 || qrand() % 2) { + // Make this piece the beginning of a new sentence. + piece[0] = piece[0].toUpper(); + if (i > 0) + piece.prepend(QLatin1String(". ")); + } else { + piece.prepend(QLatin1String(", ")); + } + text.append(piece); + } + text.append(QLatin1Char('.')); + + p.drawText(QRectF(QPointF(0, 0), QSizeF(size)), + Qt::AlignTop | Qt::AlignAbsolute | Qt::TextWordWrap, text); + } + + /* + Drawing one text with several snippets of different writingSystems, stress + testing the font merging in the font database. + */ + static void paintInternationalText(QPainter &p, const QSize &size) + { + static QStringList samples; + if (samples.isEmpty()) { + foreach (const QFontDatabase::WritingSystem system, QFontDatabase().writingSystems()) + if (system != QFontDatabase::Ogham && system != QFontDatabase::Runic) + samples.append(QFontDatabase::writingSystemSample(system)); + } + static const int systemsPerPaint = 65; + QString text; + for (int i = 0; i < systemsPerPaint; i++) { + if (i > 0) + text.append(QLatin1Char(' ')); + text.append(samples.at(qrand() % samples.count())); + } + p.drawText(QRectF(QPointF(0, 0), QSizeF(size)), + Qt::AlignTop | Qt::AlignAbsolute | Qt::TextWordWrap, text); + } + +protected: + void nextMode() + { + m_currentMode = (m_currentMode + 1) % m_modesCount; + m_lastMeasurements.clear(); + } + + void keyPressEvent(QKeyEvent *event) + { + Q_UNUSED(event); + nextMode(); + } + + void mousePressEvent(QMouseEvent *event) + { + Q_UNUSED(event); + nextMode(); + } + +private: + static const struct mode { + QString name; + void (*function)(QPainter &, const QSize&); + } m_modes[]; + static const int m_modesCount; + + int m_currentMode; + QList m_lastMeasurements; + QTime m_timer; +}; + +const struct FontBlaster::mode FontBlaster::m_modes[] = { + { QLatin1String("Qt rocks!!!"), FontBlaster::paintDifferentFontStyles }, + { QLatin1String("Latin"), FontBlaster::paintLongLatinText }, + { QLatin1String("International"), FontBlaster::paintInternationalText } +}; + +const int FontBlaster::m_modesCount = + (int)(sizeof m_modes / sizeof m_modes[0]); + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + FontBlaster dlg; +#ifdef Q_OS_SYMBIAN + dlg.showFullScreen(); +#else + dlg.show(); +#endif + + return a.exec(); +} + +#include "main.moc" diff --git a/tests/manual/textrendering/textperformance/textperformance.pro b/tests/manual/textrendering/textperformance/textperformance.pro new file mode 100644 index 0000000..bba41b9 --- /dev/null +++ b/tests/manual/textrendering/textperformance/textperformance.pro @@ -0,0 +1 @@ +SOURCES = main.cpp -- cgit v0.12 From d6254cb596a8e320959a8bbc0310cf43f16657ba Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 30 Oct 2009 18:57:16 +0100 Subject: Fix a rounding error. Reviewed-by: trustme --- tests/manual/textrendering/textperformance/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/manual/textrendering/textperformance/main.cpp b/tests/manual/textrendering/textperformance/main.cpp index 3019ebf..47e0a88 100644 --- a/tests/manual/textrendering/textperformance/main.cpp +++ b/tests/manual/textrendering/textperformance/main.cpp @@ -84,7 +84,7 @@ public: p.drawText(2, height() - fm.descent(), QLatin1String("Fps: ") + - QString::number(1000 / (qreal)(lastMsecsSum / lastMeasurementsCount), 'f', 1) + QString::number(1000 / ((qreal)lastMsecsSum / lastMeasurementsCount), 'f', 1) ); } -- cgit v0.12 From 42342c76c86a368b78c55fefc28c4bca1c010d03 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Thu, 29 Oct 2009 22:22:32 +0100 Subject: Make Linguist on Mac use the unified toolbar, like Assistant. Reviewed-By: Oswald Buddenhagen --- tools/linguist/linguist/mainwindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/linguist/linguist/mainwindow.cpp b/tools/linguist/linguist/mainwindow.cpp index 9bc6641..7f09a1c 100644 --- a/tools/linguist/linguist/mainwindow.cpp +++ b/tools/linguist/linguist/mainwindow.cpp @@ -269,6 +269,7 @@ MainWindow::MainWindow() m_editActiveModel(-1), m_statistics(0) { + setUnifiedTitleAndToolBarOnMac(true); m_ui.setupUi(this); #ifndef Q_WS_MAC -- cgit v0.12 From f914536c1c472cd7e0e21252c83447da7618c2cb Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Fri, 30 Oct 2009 19:41:48 +0100 Subject: Add a French translation to Assistant. Update the phrase book. Reviewed-by: Pierre Rossi --- tools/assistant/translations/translations.pro | 1 + tools/linguist/phrasebooks/french.qph | 20 + translations/assistant_fr.ts | 1080 +++++++++++++++++++++++++ 3 files changed, 1101 insertions(+) create mode 100644 translations/assistant_fr.ts diff --git a/tools/assistant/translations/translations.pro b/tools/assistant/translations/translations.pro index 6ff1fc9..95501ab 100644 --- a/tools/assistant/translations/translations.pro +++ b/tools/assistant/translations/translations.pro @@ -44,6 +44,7 @@ TR_DIR = $$PWD/../../../translations TRANSLATIONS = \ $$TR_DIR/assistant_da.ts \ $$TR_DIR/assistant_de.ts \ + $$TR_DIR/assistant_fr.ts \ $$TR_DIR/assistant_ja.ts \ $$TR_DIR/assistant_pl.ts \ $$TR_DIR/assistant_ru.ts \ diff --git a/tools/linguist/phrasebooks/french.qph b/tools/linguist/phrasebooks/french.qph index d38da5a..9440345 100644 --- a/tools/linguist/phrasebooks/french.qph +++ b/tools/linguist/phrasebooks/french.qph @@ -1326,4 +1326,24 @@ Close All Except %1 Fermer tout sauf %1 + + Remove + Suppression + + + About... + À propos… + + + Minimize + Minimiser + + + Remove + Supprimer + + + Select All + Sélectionner tout + diff --git a/translations/assistant_fr.ts b/translations/assistant_fr.ts new file mode 100644 index 0000000..91fcc1a --- /dev/null +++ b/translations/assistant_fr.ts @@ -0,0 +1,1080 @@ + + + + + AboutDialog + + + &Close + &Fermer + + + + AboutLabel + + + Warning + Avertissement + + + + Unable to launch external application. + + Impossible d'ouvrir l'application externe. + + + + + OK + OK + + + + BookmarkDialog + + + Add Bookmark + Ajouter un signet + + + + Bookmark: + Signet : + + + + Add in Folder: + Ajouter dans le dossier : + + + + + + + + + + + New Folder + Nouveau dossier + + + + + + + + Bookmarks + Signets + + + + Delete Folder + Supprimer le dossier + + + + Rename Folder + Renommer le dossier + + + + BookmarkManager + + + Bookmarks + Signets + + + + Remove + Suppression + + + + You are going to delete a Folder, this will also<br>remove it's content. Are you sure to continue? + Vous allez supprimer un dossier, ceci va aussi<br>supprimer son contenu. Voulez-vous continuer? + + + + + New Folder + Nouveau dossier + + + + BookmarkWidget + + + Delete Folder + Supprimer le dossier + + + + Rename Folder + Renommer le dossier + + + + Show Bookmark + Afficher le signet + + + + Show Bookmark in New Tab + Afficher le signet dans un nouvel onglet + + + + Delete Bookmark + Supprimer le signet + + + + Rename Bookmark + Renommer le signet + + + + Filter: + Filtre : + + + + Add + Ajouter + + + + Remove + Retirer + + + + CentralWidget + + + Add new page + Créer une nouvelle page + + + + Close current page + Fermer la page courante + + + + Print Document + Imprimer le document + + + + + unknown + inconnu + + + + Add New Page + Créer une nouvelle page + + + + Close This Page + Fermer cette page + + + + Close Other Pages + Fermer les autres pages + + + + Add Bookmark for this Page... + Ajouter un signet pour cette page... + + + + Search + Recherche + + + + ContentWindow + + + Open Link + Ouvrir le lien + + + + Open Link in New Tab + Ouvrir le lien dans un nouvel onglet + + + + FilterNameDialogClass + + + Add Filter Name + Ajouter un filtre + + + + Filter Name: + Nom du filtre : + + + + FindWidget + + + Previous + Précédent + + + + Next + Suivant + + + + Case Sensitive + Sensible à la casse + + + + Whole words + Mots complets + + + + <img src=":/trolltech/assistant/images/wrap.png">&nbsp;Search wrapped + <img src=":/trolltech/assistant/images/wrap.png">&nbsp;Recherche à partir du début + + + + FontPanel + + + Font + Police + + + + &Writing system + &Système d'écriture + + + + &Family + &Famille + + + + &Style + &Style + + + + &Point size + &Taille en points + + + + HelpViewer + + + Open Link in New Tab + Ouvrir le lien dans un nouvel onglet + + + + <title>Error 404...</title><div align="center"><br><br><h1>The page could not be found</h1><br><h3>'%1'</h3></div> + <title>Erreur 404...</title><div align="center"><br><br><h1>La page n'a pas pu être trouvée</h1><br><h3>'%1'</h3></div> + + + + Help + Aide + + + + Unable to launch external application. + + Impossible de lancer l'application externe. + + + + + OK + OK + + + + Copy &Link Location + Copier l'&adresse cible + + + + Open Link in New Tab Ctrl+LMB + LMB? ← ouais exactement pareil... + Ouvrir dans un nouvel onglet Ctrl+clic gauche + + + + IndexWindow + + + &Look for: + &Rechercher : + + + + Open Link + Ouvrir le lien + + + + Open Link in New Tab + Ouvrir le lien dans un nouvel onglet + + + + InstallDialog + + + + Install Documentation + Installer la documentation + + + + Available Documentation: + Documentation disponible : + + + + Install + Installer + + + + Cancel + Annuler + + + + Close + Fermer + + + + Installation Path: + Chemin d'installation : + + + + ... + + + + + Downloading documentation info... + Téléchargement des informations de la documentation… + + + + Download canceled. + Téléchargement annulé. + + + + + + Done. + Terminé. + + + + The file %1 already exists. Do you want to overwrite it? + Le fichier %1 existe déjà. Voulez-vous l'écraser? + + + + Unable to save the file %1: %2. + Impossible de sauver le fichier %1 : %2. + + + + Downloading %1... + Téléchargement de %1 en cours… + + + + + + Download failed: %1. + Échec du téléchargement : %1. + + + + Documentation info file is corrupt! + Le fichier d'information de documentation est corrompu! + + + + Download failed: Downloaded file is corrupted. + Échec du téléchargement : le fichier téléchargé est corrompu. + + + + Installing documentation %1... + Installation de la documentation %1… + + + + Error while installing documentation: +%1 + Erreur durant l'installation de la documentation : +%1 + + + + MainWindow + + + + Index + Index + + + + + Contents + Sommaire + + + + + Bookmarks + Signets + + + + + + Qt Assistant + Qt Assistant + + + + + Unfiltered + Non-filtré + + + + Looking for Qt Documentation... + Recherche la documentation de Qt… + + + + &File + &Fichier + + + + Page Set&up... + &Mise en page… + + + + Print Preview... + Aperçu avant impression… + + + + &Print... + &Imprimer… + + + + New &Tab + Nouvel ongle&t + + + + &Close Tab + &Fermer l'onglet + + + + &Quit + &Quitter + + + + &Edit + &Édition + + + + &Copy selected Text + &Copier le texte selectionné + + + + &Find in Text... + &Trouver dans le texte… + + + + Find &Next + Rechercher le suiva&nt + + + + Find &Previous + Rechercher le &précédent + + + + Preferences... + Préférences… + + + + &View + &Affichage + + + + Zoom &in + Zoom &avant + + + + Zoom &out + Zoom a&rrière + + + + Normal &Size + &Taille normale + + + + Ctrl+0 + Ctrl+0 + + + + ALT+C + ALT+C + + + + ALT+I + ALT+I + + + + ALT+O + ALT+O + + + + Search + Recherche + + + + ALT+S + ALT+S + + + + &Go + &Aller + + + + &Home + &Accueil + + + + ALT+Home + ALT+Home + + + + &Back + &Précédent + + + + &Forward + &Suivant + + + + Sync with Table of Contents + Synchroniser la table des matières + + + + Next Page + Page suivante + + + + Ctrl+Alt+Right + Ctrl+Alt+Right + + + + Previous Page + Page précédente + + + + Ctrl+Alt+Left + Ctrl+Alt+Left + + + + &Bookmarks + &Signets + + + + Add Bookmark... + Ajouter un signet… + + + + CTRL+D + CTRL+D + + + + &Help + &Aide + + + + About... + À propos… + + + + Navigation Toolbar + Barre d'outils de navigation + + + + &Window + &Fenêtre + + + + Zoom + Zoom + + + + Minimize + Minimiser + + + + Ctrl+M + Ctrl+M + + + + Toolbars + Barres d'outils + + + + Filter Toolbar + Barre d'outils de filtrage + + + + Filtered by: + Filtré par : + + + + Address Toolbar + Barre d'outils d'adresse + + + + Address: + Adresse : + + + + Could not find the associated content item. + what is item in this context? ← same question here + Impossible de trouver l'élément de contenu associé. + + + + About %1 + À propos de %1 + + + + Updating search index + Mise à jour de l'index de recherche + + + + PreferencesDialog + + + + Add Documentation + Ajouter de la documentation + + + + Qt Compressed Help Files (*.qch) + Fichiers d'aide Qt compressés (*.qch) + + + + The namespace %1 is already registered! + L'espace de nom %1 existe déjà! + + + + The specified file is not a valid Qt Help File! + Le fichier spécifié n'est pas un fichier d'aide Qt valide! + + + + Remove Documentation + Supprimer la documentation + + + + Some documents currently opened in Assistant reference the documentation you are attempting to remove. Removing the documentation will close those documents. + Certains documents ouverts dans Assistant ont des références vers la documentation que vous allez supprimer. Supprimer la documentation fermera ces documents. + + + + Cancel + Annuler + + + + OK + OK + + + + Use custom settings + Utiliser des paramètres personnalisés + + + + PreferencesDialogClass + + + Preferences + Préférences + + + + Fonts + Polices + + + + Font settings: + Configuration des polices : + + + + Browser + Navigateur + + + + Application + Application + + + + Filters + Filtres + + + + Filter: + Filtre : + + + + Attributes: + Attributs : + + + + 1 + 1 + + + + Add + Ajouter + + + + + Remove + Supprimer + + + + Documentation + Documentation + + + + Registered Documentation: + documentation enregistrée ? ← je préfère référencée pour les deux... + Documentation référencée : + + + + Add... + Ajouter… + + + + Options + Options + + + + On help start: + Au démarrage : + + + + Show my home page + Afficher ma page d'accueil + + + + Show a blank page + Afficher une page blanche + + + + Show my tabs from last session + Afficher mes onglets de la dernière session + + + + Homepage + Page d'accueil + + + + Current Page + Page courante + + + + Blank Page + Page blanche + + + + Restore to default + Restaurer les valeurs par défaut + + + + QObject + + + The specified collection file does not exist! + Le fichier de collection spécifié n'existe pas! + + + + Missing collection file! + Fichier de collection manquant! + + + + Invalid URL! + URL invalide! + + + + Missing URL! + URL manquante! + + + + + + Unknown widget: %1 + Widget inconnu : %1 + + + + + + Missing widget! + Widget manquant! + + + + + The specified Qt help file does not exist! + Le fichier d'aide Qt spécifié n'existe pas! + + + + + Missing help file! + Fichier d'aide manquant! + + + + Missing filter argument! + Argument de filtre manquant! + + + + Unknown option: %1 + Option inconnue : %1 + + + + + Qt Assistant + Qt Assistant + + + + Could not register documentation file +%1 + +Reason: +%2 + Impossible d'enregistrer le fichier de documentation +%1 + +Raison : +%2 + + + + Documentation successfully registered. + Documentation enregistrée avec succès. + + + + Documentation successfully unregistered. + Documentation retirée avec succès. + + + + Could not unregister documentation file +%1 + +Reason: +%2 + Impossible d'enregistrer le fichier de documentation +%1 + +Raison : +%2 + + + + Cannot load sqlite database driver! + Impossible de charger le driver de la base de données sqlite! + + + + The specified collection file could not be read! + Le fichier de collection spécifié ne peut pas être lu! + + + + RemoteControl + + + Debugging Remote Control + Débogage du contrôle à distance + + + + Received Command: %1 %2 + Commande reçue : %1 %2 + + + + SearchWidget + + + &Copy + &Copier + + + + Copy &Link Location + Copier &l'adresse du lien + + + + Open Link in New Tab + Ouvrir le lien dans un nouvel onglet + + + + Select All + Sélectionner tout + + + + TopicChooser + + + Choose Topic + Choisir le domaine + + + + &Topics + &Domaines + + + + &Display + &Afficher + + + + &Close + &Fermer + + + + Choose a topic for <b>%1</b>: + Choisir le domaine pour <b>%1</b> : + + + -- cgit v0.12 From 0e02c54e7e56ee091aeeb6342faa2df163fbbd74 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 2 Nov 2009 07:51:09 +1000 Subject: Remove partial shader support from QGLShader/QGLShaderProgram Reviewed-by: trustme --- src/opengl/qglshaderprogram.cpp | 182 ++-------------------------------------- src/opengl/qglshaderprogram.h | 9 +- 2 files changed, 6 insertions(+), 185 deletions(-) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index 90b496e..080c3b2 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -106,30 +106,6 @@ QT_BEGIN_NAMESPACE \snippet doc/src/snippets/code/src_opengl_qglshaderprogram.cpp 2 - \section1 Partial shaders - - Desktop GLSL can attach an arbitrary number of vertex and fragment - shaders to a shader program. Embedded GLSL/ES on the other hand - supports only a single shader of each type on a shader program. - - Multiple shaders of the same type can be useful when large libraries - of shaders are needed. Common functions can be factored out into - library shaders that can be reused in multiple shader programs. - - To support this use of shaders, the application programmer can - create shaders with the QGLShader::PartialVertexShader and - QGLShader::PartialFragmentShader types. These types direct - QGLShader and QGLShaderProgram to delay shader compilation until - link time. - - When link() is called, the sources for the partial shaders are - concatenated, and a single vertex or fragment shader is compiled - and linked into the shader program. - - It is more efficient to use the QGLShader::VertexShader and - QGLShader::FragmentShader when there is only one shader of that - type in the program. - \sa QGLShader */ @@ -154,11 +130,6 @@ QT_BEGIN_NAMESPACE \value VertexShader Vertex shader written in the OpenGL Shading Language (GLSL). \value FragmentShader Fragment shader written in the OpenGL Shading Language (GLSL). - - \value PartialVertexShader Partial vertex shader that will be concatenated with all other partial vertex shaders at link time. - \value PartialFragmentShader Partial fragment shader that will be concatenated with all other partial fragment shaders at link time. - - \omitvalue PartialShader */ #ifndef GL_FRAGMENT_SHADER @@ -209,8 +180,6 @@ public: : shaderGuard(context) , shaderType(type) , compiled(false) - , isPartial((type & QGLShader::PartialShader) != 0) - , hasPartialSource(false) { } ~QGLShaderPrivate(); @@ -218,10 +187,7 @@ public: QGLSharedResourceGuard shaderGuard; QGLShader::ShaderType shaderType; bool compiled; - bool isPartial; - bool hasPartialSource; QString log; - QByteArray partialSource; bool create(); bool compile(QGLShader *q); @@ -243,8 +209,6 @@ bool QGLShaderPrivate::create() const QGLContext *context = shaderGuard.context(); if (!context) return false; - if (isPartial) - return true; if (qt_resolve_glsl_extensions(const_cast(context))) { GLuint shader; if (shaderType == QGLShader::VertexShader) @@ -264,11 +228,6 @@ bool QGLShaderPrivate::create() bool QGLShaderPrivate::compile(QGLShader *q) { - // Partial shaders are compiled during QGLShaderProgram::link(). - if (isPartial && hasPartialSource) { - compiled = true; - return true; - } GLuint shader = shaderGuard.id(); if (!shader) return false; @@ -441,21 +400,12 @@ static const char redefineHighp[] = Sets the \a source code for this shader and compiles it. Returns true if the source was successfully compiled, false otherwise. - If shaderType() is PartialVertexShader or PartialFragmentShader, - then this function will always return true, even if the source code - is invalid. Partial shaders are compiled when QGLShaderProgram::link() - is called. - \sa compileFile() */ bool QGLShader::compile(const char *source) { Q_D(QGLShader); - if (d->isPartial) { - d->partialSource = QByteArray(source); - d->hasPartialSource = true; - return d->compile(this); - } else if (d->shaderGuard.id()) { + if (d->shaderGuard.id()) { QVarLengthArray src; QVarLengthArray srclen; int headerLen = 0; @@ -481,8 +431,7 @@ bool QGLShader::compile(const char *source) srclen.append(GLint(sizeof(qualifierDefines) - 1)); #endif #ifdef QGL_REDEFINE_HIGHP - if (d->shaderType == FragmentShader || - d->shaderType == PartialFragmentShader) { + if (d->shaderType == FragmentShader) { src.append(redefineHighp); srclen.append(GLint(sizeof(redefineHighp) - 1)); } @@ -497,71 +446,11 @@ bool QGLShader::compile(const char *source) } /*! - \internal -*/ -bool QGLShader::compile - (const QList& shaders, QGLShader::ShaderType type) -{ - Q_D(QGLShader); - QVarLengthArray src; - QVarLengthArray srclen; - if (!d->shaderGuard.id()) - return false; - foreach (QGLShader *shader, shaders) { - if (shader->shaderType() != type) - continue; - const char *source = shader->d_func()->partialSource.constData(); - int headerLen = 0; - if (src.isEmpty()) { - // First shader: handle the #version and #extension tags - // plus the precision qualifiers. - while (source && source[headerLen] == '#') { - // Skip #version and #extension directives at the start of - // the shader code. We need to insert the qualifierDefines - // and redefineHighp just after them. - if (qstrncmp(source + headerLen, "#version", 8) != 0 && - qstrncmp(source + headerLen, "#extension", 10) != 0) { - break; - } - while (source[headerLen] != '\0' && source[headerLen] != '\n') - ++headerLen; - if (source[headerLen] == '\n') - ++headerLen; - } - if (headerLen > 0) { - src.append(source); - srclen.append(GLint(headerLen)); - } -#ifdef QGL_DEFINE_QUALIFIERS - src.append(qualifierDefines); - srclen.append(GLint(sizeof(qualifierDefines) - 1)); -#endif -#ifdef QGL_REDEFINE_HIGHP - if (d->shaderType == FragmentShader || - d->shaderType == PartialFragmentShader) { - src.append(redefineHighp); - srclen.append(GLint(sizeof(redefineHighp) - 1)); - } -#endif - } - src.append(source + headerLen); - srclen.append(GLint(qstrlen(source + headerLen))); - } - glShaderSource(d->shaderGuard.id(), src.size(), src.data(), srclen.data()); - return d->compile(this); -} - -/*! \overload Sets the \a source code for this shader and compiles it. Returns true if the source was successfully compiled, false otherwise. - If shaderType() is PartialVertexShader or PartialFragmentShader, - then this function will always return true, even if the source code - is invalid. Partial shaders are compiled when QGLShaderProgram::link() - is called. - \sa compileFile() */ bool QGLShader::compile(const QByteArray& source) @@ -575,11 +464,6 @@ bool QGLShader::compile(const QByteArray& source) Sets the \a source code for this shader and compiles it. Returns true if the source was successfully compiled, false otherwise. - If shaderType() is PartialVertexShader or PartialFragmentShader, - then this function will always return true, even if the source code - is invalid. Partial shaders are compiled when QGLShaderProgram::link() - is called. - \sa compileFile() */ bool QGLShader::compile(const QString& source) @@ -592,11 +476,6 @@ bool QGLShader::compile(const QString& source) and compiles it. Returns true if the file could be opened and the source compiled, false otherwise. - If shaderType() is PartialVertexShader or PartialFragmentShader, - then this function will always return true, even if the source code - is invalid. Partial shaders are compiled when QGLShaderProgram::link() - is called. - \sa compile() */ bool QGLShader::compileFile(const QString& fileName) @@ -619,8 +498,6 @@ bool QGLShader::compileFile(const QString& fileName) QByteArray QGLShader::sourceCode() const { Q_D(const QGLShader); - if (d->isPartial) - return d->partialSource; GLuint shader = d->shaderGuard.id(); if (!shader) return QByteArray(); @@ -661,10 +538,6 @@ QString QGLShader::log() const /*! Returns the OpenGL identifier associated with this shader. - If shaderType() is PartialVertexShader or PartialFragmentShader, - this function will always return zero. Partial shaders are - created and compiled when QGLShaderProgram::link() is called. - \sa QGLShaderProgram::programId() */ GLuint QGLShader::shaderId() const @@ -684,7 +557,6 @@ public: : programGuard(context) , linked(false) , inited(false) - , hasPartialShaders(false) , removingShaders(false) , vertexShader(0) , fragmentShader(0) @@ -695,7 +567,6 @@ public: QGLSharedResourceGuard programGuard; bool linked; bool inited; - bool hasPartialShaders; bool removingShaders; QString log; QList shaders; @@ -812,13 +683,9 @@ bool QGLShaderProgram::addShader(QGLShader *shader) } if (!shader->d_func()->compiled) return false; - if (!shader->d_func()->isPartial) { - if (!shader->d_func()->shaderGuard.id()) - return false; - glAttachShader(d->programGuard.id(), shader->d_func()->shaderGuard.id()); - } else { - d->hasPartialShaders = true; - } + if (!shader->d_func()->shaderGuard.id()) + return false; + glAttachShader(d->programGuard.id(), shader->d_func()->shaderGuard.id()); d->linked = false; // Program needs to be relinked. d->shaders.append(shader); connect(shader, SIGNAL(destroyed()), this, SLOT(shaderDestroyed())); @@ -999,45 +866,6 @@ bool QGLShaderProgram::link() GLuint program = d->programGuard.id(); if (!program) return false; - if (d->hasPartialShaders) { - // Compile the partial vertex and fragment shaders. - if (d->hasShader(QGLShader::PartialVertexShader)) { - if (!d->vertexShader) { - d->vertexShader = - new QGLShader(QGLShader::VertexShader, this); - } - if (!d->vertexShader->compile - (d->shaders, QGLShader::PartialVertexShader)) { - d->log = d->vertexShader->log(); - return false; - } - glAttachShader(program, d->vertexShader->d_func()->shaderGuard.id()); - } else { - if (d->vertexShader) { - glDetachShader(program, d->vertexShader->d_func()->shaderGuard.id()); - delete d->vertexShader; - d->vertexShader = 0; - } - } - if (d->hasShader(QGLShader::PartialFragmentShader)) { - if (!d->fragmentShader) { - d->fragmentShader = - new QGLShader(QGLShader::FragmentShader, this); - } - if (!d->fragmentShader->compile - (d->shaders, QGLShader::PartialFragmentShader)) { - d->log = d->fragmentShader->log(); - return false; - } - glAttachShader(program, d->fragmentShader->d_func()->shaderGuard.id()); - } else { - if (d->fragmentShader) { - glDetachShader(program, d->fragmentShader->d_func()->shaderGuard.id()); - delete d->fragmentShader; - d->fragmentShader = 0; - } - } - } glLinkProgram(program); GLint value = 0; glGetProgramiv(program, GL_LINK_STATUS, &value); diff --git a/src/opengl/qglshaderprogram.h b/src/opengl/qglshaderprogram.h index 708cf09..b7bd2d7 100644 --- a/src/opengl/qglshaderprogram.h +++ b/src/opengl/qglshaderprogram.h @@ -66,12 +66,7 @@ public: enum ShaderTypeBits { VertexShader = 0x0001, - FragmentShader = 0x0002, - - PartialShader = 0x1000, - - PartialVertexShader = PartialShader | VertexShader, - PartialFragmentShader = PartialShader | FragmentShader + FragmentShader = 0x0002 }; Q_DECLARE_FLAGS(ShaderType, ShaderTypeBits) @@ -100,8 +95,6 @@ private: Q_DISABLE_COPY(QGLShader) Q_DECLARE_PRIVATE(QGLShader) - - bool compile(const QList& shaders, QGLShader::ShaderType type); }; Q_DECLARE_OPERATORS_FOR_FLAGS(QGLShader::ShaderType) -- cgit v0.12 From acde9118f87ebd5aba5904072e40997a2a155d13 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 2 Nov 2009 09:09:06 +1000 Subject: Make screen rotation work properly with the PowerVR screen driver Task-number: QT-2261 Reviewed-by: Tom Back port of 75719e4e06882825fe056935d782b4153bf0ac5b --- .../gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c | 10 ++++ .../gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h | 3 + .../gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h | 1 + .../gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c | 14 ++++- src/plugins/gfxdrivers/powervr/README | 5 ++ .../powervr/pvreglscreen/pvreglscreen.cpp | 67 +++++++++++++++++++++- .../gfxdrivers/powervr/pvreglscreen/pvreglscreen.h | 9 ++- .../powervr/pvreglscreen/pvreglwindowsurface.cpp | 54 ++++++++++++++++- .../powervr/pvreglscreen/pvreglwindowsurface.h | 8 ++- 9 files changed, 162 insertions(+), 9 deletions(-) diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c index ac9dc8d..c1b655a 100644 --- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c +++ b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c @@ -617,6 +617,16 @@ void pvrQwsGetGeometry(PvrQwsDrawable *drawable, PvrQwsRect *rect) *rect = drawable->rect; } +void pvrQwsSetRotation(PvrQwsDrawable *drawable, int angle) +{ + if (drawable->rotationAngle != angle) { + drawable->rotationAngle = angle; + + /* Force the buffers to be recreated if the rotation angle changes */ + pvrQwsInvalidateBuffers(drawable); + } +} + int pvrQwsGetStride(PvrQwsDrawable *drawable) { if (drawable->backBuffersValid) diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h index 952ff6f..b9e035f 100644 --- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h +++ b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h @@ -126,6 +126,9 @@ void pvrQwsSetGeometry(PvrQwsDrawable *drawable, const PvrQwsRect *rect); /* Get the current geometry for a drawable */ void pvrQwsGetGeometry(PvrQwsDrawable *drawable, PvrQwsRect *rect); +/* Set the rotation angle in degrees */ +void pvrQwsSetRotation(PvrQwsDrawable *drawable, int angle); + /* Get the line stride for a drawable. Returns zero if the buffers are not allocated or have been invalidated */ int pvrQwsGetStride(PvrQwsDrawable *drawable); diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h index cf80a90..dcd4e4f 100644 --- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h +++ b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h @@ -114,6 +114,7 @@ struct _PvrQwsDrawable int isFullScreen; int strideBytes; int stridePixels; + int rotationAngle; PvrQwsSwapFunction swapFunction; void *userData; PvrQwsDrawable *nextWinId; diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c index 253f39f..28b2251 100644 --- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c +++ b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c @@ -132,6 +132,16 @@ static WSEGLError wseglCloseDisplay(WSEGLDisplayHandle display) return WSEGL_SUCCESS; } +static WSEGLRotationAngle wseglRotationValue(int degrees) +{ + switch (degrees) { + case 90: return WSEGL_ROTATE_90; + case 180: return WSEGL_ROTATE_180; + case 270: return WSEGL_ROTATE_270; + default: return WSEGL_ROTATE_0; + } +} + /* Create the WSEGL drawable version of a native window */ static WSEGLError wseglCreateWindowDrawable (WSEGLDisplayHandle display, WSEGLConfig *config, @@ -152,7 +162,7 @@ static WSEGLError wseglCreateWindowDrawable *drawable = (WSEGLDrawableHandle)screen; if (!pvrQwsAllocBuffers(screen)) return WSEGL_OUT_OF_MEMORY; - *rotationAngle = WSEGL_ROTATE_0; + *rotationAngle = wseglRotationValue(screen->rotationAngle); return WSEGL_SUCCESS; } @@ -163,7 +173,7 @@ static WSEGLError wseglCreateWindowDrawable /* The drawable is ready to go */ *drawable = (WSEGLDrawableHandle)draw; - *rotationAngle = WSEGL_ROTATE_0; + *rotationAngle = wseglRotationValue(draw->rotationAngle); if (!pvrQwsAllocBuffers(draw)) return WSEGL_OUT_OF_MEMORY; return WSEGL_SUCCESS; diff --git a/src/plugins/gfxdrivers/powervr/README b/src/plugins/gfxdrivers/powervr/README index 4dce87f..322a6b2 100644 --- a/src/plugins/gfxdrivers/powervr/README +++ b/src/plugins/gfxdrivers/powervr/README @@ -51,6 +51,11 @@ on the device with: hellogl_es -qws +The driver also supports screen rotation if Qt is configured with the +-qt-gfx-transformed option and the QWS_DISPLAY variable is wrapped in a +"Transformed" declaration: + + Transformed:powervr:mmWidth40:mmHeight54:Rot90:0 Know Issues: * A QGLWidget may not have window decorations if it is a top-level window. diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp index 6696672..2e4c6d1 100644 --- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp +++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp @@ -44,6 +44,9 @@ #include "pvrqwsdrawable_p.h" #include #include +#ifndef QT_NO_QWS_TRANSFORMED +#include +#endif #include #include #include @@ -60,6 +63,7 @@ PvrEglScreen::PvrEglScreen(int displayId) ttyfd = -1; doGraphicsMode = true; oldKdMode = KD_TEXT; + parent = 0; // Make sure that the EGL layer is initialized and the drivers loaded. EGLDisplay dpy = eglGetDisplay((EGLNativeDisplayType)EGL_DEFAULT_DISPLAY); @@ -189,7 +193,7 @@ bool PvrEglScreen::hasOpenGL() QWSWindowSurface* PvrEglScreen::createSurface(QWidget *widget) const { if (qobject_cast(widget)) - return new PvrEglWindowSurface(widget, (QScreen *)this, displayId); + return new PvrEglWindowSurface(widget, (PvrEglScreen *)this, displayId); return QScreen::createSurface(widget); } @@ -202,6 +206,67 @@ QWSWindowSurface* PvrEglScreen::createSurface(const QString &key) const return QScreen::createSurface(key); } +#ifndef QT_NO_QWS_TRANSFORMED + +static const QScreen *parentScreen + (const QScreen *current, const QScreen *lookingFor) +{ + if (!current) + return 0; + switch (current->classId()) { + case QScreen::ProxyClass: + case QScreen::TransformedClass: { + const QScreen *child = + static_cast(current)->screen(); + if (child == lookingFor) + return current; + else + return parentScreen(child, lookingFor); + } + // Not reached. + + case QScreen::MultiClass: { + QList screens = current->subScreens(); + foreach (QScreen *screen, screens) { + if (screen == lookingFor) + return current; + const QScreen *parent = parentScreen(screen, lookingFor); + if (parent) + return parent; + } + } + break; + + default: break; + } + return 0; +} + +int PvrEglScreen::transformation() const +{ + // We need to search for our parent screen, which is assumed to be + // "Transformed". If it isn't, then there is no transformation. + // There is no direct method to get the parent screen so we need + // to search every screen until we find ourselves. + if (!parent && qt_screen != this) + parent = parentScreen(qt_screen, this); + if (!parent) + return 0; + if (parent->classId() != QScreen::TransformedClass) + return 0; + return 90 * static_cast(parent) + ->transformation(); +} + +#else + +int PvrEglScreen::transformation() const +{ + return 0; +} + +#endif + void PvrEglScreen::sync() { // Put code here to synchronize 2D and 3D operations if necessary. diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h index 8bf42c7..5769e70 100644 --- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h +++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h @@ -46,16 +46,18 @@ #include #include "pvrqwsdrawable.h" +class PvrEglScreen; + class PvrEglScreenSurfaceFunctions : public QGLScreenSurfaceFunctions { public: - PvrEglScreenSurfaceFunctions(QScreen *s, int screenNum) + PvrEglScreenSurfaceFunctions(PvrEglScreen *s, int screenNum) : screen(s), displayId(screenNum) {} bool createNativeWindow(QWidget *widget, EGLNativeWindowType *native); private: - QScreen *screen; + PvrEglScreen *screen; int displayId; }; @@ -80,6 +82,8 @@ public: QWSWindowSurface* createSurface(QWidget *widget) const; QWSWindowSurface* createSurface(const QString &key) const; + int transformation() const; + private: void sync(); void openTty(); @@ -89,6 +93,7 @@ private: int ttyfd, oldKdMode; QString ttyDevice; bool doGraphicsMode; + mutable const QScreen *parent; }; #endif diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp index 2c5ac21..4a3787f 100644 --- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp +++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp @@ -46,7 +46,7 @@ #include PvrEglWindowSurface::PvrEglWindowSurface - (QWidget *widget, QScreen *screen, int screenNum) + (QWidget *widget, PvrEglScreen *screen, int screenNum) : QWSGLWindowSurface(widget) { setSurfaceFlags(QWSWindowSurface::Opaque); @@ -63,6 +63,7 @@ PvrEglWindowSurface::PvrEglWindowSurface pvrRect.y = pos.y(); pvrRect.width = size.width(); pvrRect.height = size.height(); + transformRects(&pvrRect, 1); // Try to recover a previous PvrQwsDrawable object for the widget // if there is one. This can happen when a PvrEglWindowSurface @@ -75,6 +76,7 @@ PvrEglWindowSurface::PvrEglWindowSurface pvrQwsSetGeometry(drawable, &pvrRect); else drawable = pvrQwsCreateWindow(screenNum, (long)widget, &pvrRect); + pvrQwsSetRotation(drawable, screen->transformation()); } PvrEglWindowSurface::PvrEglWindowSurface() @@ -113,7 +115,9 @@ void PvrEglWindowSurface::setGeometry(const QRect &rect) pvrRect.y = rect.y(); pvrRect.width = rect.width(); pvrRect.height = rect.height(); + transformRects(&pvrRect, 1); pvrQwsSetGeometry(drawable, &pvrRect); + pvrQwsSetRotation(drawable, screen->transformation()); } QWSGLWindowSurface::setGeometry(rect); } @@ -127,7 +131,9 @@ bool PvrEglWindowSurface::move(const QPoint &offset) pvrRect.y = rect.y(); pvrRect.width = rect.width(); pvrRect.height = rect.height(); + transformRects(&pvrRect, 1); pvrQwsSetGeometry(drawable, &pvrRect); + pvrQwsSetRotation(drawable, screen->transformation()); } return QWSGLWindowSurface::move(offset); } @@ -200,7 +206,9 @@ void PvrEglWindowSurface::setDirectRegion(const QRegion &r, int id) pvrRect.y = rect.y(); pvrRect.width = rect.width(); pvrRect.height = rect.height(); + transformRects(&pvrRect, 1); pvrQwsSetVisibleRegion(drawable, &pvrRect, 1); + pvrQwsSetRotation(drawable, screen->transformation()); if (!pvrQwsSwapBuffers(drawable, 1)) screen->solidFill(QColor(0, 0, 0), region); } else { @@ -213,9 +221,53 @@ void PvrEglWindowSurface::setDirectRegion(const QRegion &r, int id) pvrRects[index].width = rect.width(); pvrRects[index].height = rect.height(); } + transformRects(pvrRects, rects.size()); pvrQwsSetVisibleRegion(drawable, pvrRects, rects.size()); + pvrQwsSetRotation(drawable, screen->transformation()); if (!pvrQwsSwapBuffers(drawable, 1)) screen->solidFill(QColor(0, 0, 0), region); delete [] pvrRects; } } + +void PvrEglWindowSurface::transformRects(PvrQwsRect *rects, int count) const +{ + switch (screen->transformation()) { + case 0: break; + + case 90: + { + for (int index = 0; index < count; ++index) { + int x = rects[index].y; + int y = screen->height() - (rects[index].x + rects[index].width); + rects[index].x = x; + rects[index].y = y; + qSwap(rects[index].width, rects[index].height); + } + } + break; + + case 180: + { + for (int index = 0; index < count; ++index) { + int x = screen->width() - (rects[index].x + rects[index].width); + int y = screen->height() - (rects[index].y + rects[index].height); + rects[index].x = x; + rects[index].y = y; + } + } + break; + + case 270: + { + for (int index = 0; index < count; ++index) { + int x = screen->width() - (rects[index].y + rects[index].height); + int y = rects[index].x; + rects[index].x = x; + rects[index].y = y; + qSwap(rects[index].width, rects[index].height); + } + } + break; + } +} diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h index 58a5fb2..b0a161c 100644 --- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h +++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h @@ -45,12 +45,12 @@ #include #include "pvrqwsdrawable.h" -class QScreen; +class PvrEglScreen; class PvrEglWindowSurface : public QWSGLWindowSurface { public: - PvrEglWindowSurface(QWidget *widget, QScreen *screen, int screenNum); + PvrEglWindowSurface(QWidget *widget, PvrEglScreen *screen, int screenNum); PvrEglWindowSurface(); ~PvrEglWindowSurface(); @@ -76,8 +76,10 @@ public: private: QWidget *widget; PvrQwsDrawable *drawable; - QScreen *screen; + PvrEglScreen *screen; QPaintDevice *pdevice; + + void transformRects(PvrQwsRect *rects, int count) const; }; #endif -- cgit v0.12 From 24c05a4db9ad398139de8d660347513b301aa911 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 2 Nov 2009 09:09:34 +1000 Subject: Remove unnecessary PowerVR helper functions The cross-process memory sharing code never really worked in the way we needed it to - so remove it until something better comes along. Reviewed-by: trustme Back port of 04648b44f0784223122a782320d0b09b5c1e9497 --- .../gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c | 60 ---------------------- .../gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h | 15 ------ 2 files changed, 75 deletions(-) diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c index c1b655a..17345a9 100644 --- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c +++ b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c @@ -828,63 +828,3 @@ void pvrQwsSetSwapFunction drawable->swapFunction = func; drawable->userData = userData; } - -unsigned long pvrQwsGetMemoryId(PvrQwsDrawable *drawable) -{ - unsigned long addr; - unsigned long start; - unsigned long end; - unsigned long off; - unsigned long offset; - FILE *file; - char buffer[BUFSIZ]; - char flags[16]; - - if (!drawable->backBuffersValid) - return 0; - addr = (unsigned long) - (drawable->backBuffers[drawable->currentBackBuffer]->pBase); - - /* Search /proc/self/maps for the memory region that contains "addr". - The file offset for that memory region is the identifier we need */ - file = fopen("/proc/self/maps", "r"); - if (!file) { - perror("/proc/self/maps"); - return 0; - } - offset = 0; - while (fgets(buffer, sizeof(buffer), file)) { - if (sscanf(buffer, "%lx-%lx %s %lx", - &start, &end, flags, &off) < 4) - continue; - if (start <= addr && addr < end) { - offset = off; - break; - } - } - fclose(file); - return offset; -} - -void *pvrQwsMapMemory(unsigned long id, int size) -{ - void *addr; - int fd = open("/dev/pvrsrv", O_RDWR, 0); - if (fd < 0) { - perror("/dev/pvrsrv"); - return 0; - } - addr = mmap(0, (size_t)size, PROT_READ | PROT_WRITE, - MAP_SHARED, fd, (off_t)id); - if (addr == (void *)(-1)) { - perror("mmap pvr memory region"); - addr = 0; - } - close(fd); - return addr; -} - -void pvrQwsUnmapMemory(void *addr, int size) -{ - munmap(addr, size); -} diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h index b9e035f..55e0310 100644 --- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h +++ b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h @@ -162,21 +162,6 @@ int pvrQwsSwapBuffers(PvrQwsDrawable *drawable, int repaintOnly); void pvrQwsSetSwapFunction (PvrQwsDrawable *drawable, PvrQwsSwapFunction func, void *userData); -/* Get a memory identifier for the indicated drawable's buffer. - The identifier can be passed to another process and then - passed to pvrQwsMapMemory() to map the drawable's buffer into - the other process's address space. Returns zero if the - memory identifier could not be determined. This should only - be used for pixmap drawables */ -unsigned long pvrQwsGetMemoryId(PvrQwsDrawable *drawable); - -/* Map the memory buffer of a foreign application's drawable, as - indicated by "id" and "size". Returns null if the map failed */ -void *pvrQwsMapMemory(unsigned long id, int size); - -/* Unmap the memory obtained from pvrQwsMapMemory() */ -void pvrQwsUnmapMemory(void *addr, int size); - #ifdef __cplusplus }; #endif -- cgit v0.12 From 49134383c2fd81b9253207b70aaf2530526b044d Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 2 Nov 2009 09:09:51 +1000 Subject: The shipped pvr2d.h/wsegl.h for PowerVR do not work with MBX Reviewed-by: trustme Back port of 4ae09215de36fcfd17dc6875aca102d784d65012 --- src/plugins/gfxdrivers/powervr/README | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/gfxdrivers/powervr/README b/src/plugins/gfxdrivers/powervr/README index 322a6b2..513e7f5 100644 --- a/src/plugins/gfxdrivers/powervr/README +++ b/src/plugins/gfxdrivers/powervr/README @@ -31,9 +31,10 @@ strictly Unix-style markers. * IMPORTANT: To build the QScreen plugin and the WSEGL library it depends * * on, the pvr2d.h, wsegl.h headers for your platform are required. You * * can find a copy of these headers in src/3rdparty/powervr for SGX based * -* platforms like the TI OMAP3xxx. They may also work on MBX platforms too * -* depending on how old your libEGL is. You can tell Qt where to find * -* these headers by setting QMAKE_INCDIR_POWERVR in the mkspec. * +* platforms like the TI OMAP3xxx. They probably will not work on MBX * +* because of differences in the layout of certain PVR2D structures. * +* You can tell Qt where to find the actual headers for your system by * +* setting QMAKE_INCDIR_POWERVR in the mkspec. * *************************************************************************** When you start a Qt/Embedded application, you should modify the QWS_DISPLAY -- cgit v0.12 From 0dc3e7f6b482d359b10bfe4e0a3032644b77c94b Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 2 Nov 2009 09:10:09 +1000 Subject: Increase PowerVR memory alignment from 8 to 32 for SGX systems. Increasing the alignment does not seem to affect MBX. Back port of 7997279bc22d30bf1d1a30a567bda33ecc9aeb2d --- src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c index 17345a9..a9c22ef 100644 --- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c +++ b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c @@ -662,7 +662,7 @@ int pvrQwsAllocBuffers(PvrQwsDrawable *drawable) PVR2DMemFree(pvrQwsDisplay.context, drawable->backBuffers[index]); } } - drawable->stridePixels = (drawable->rect.width + 7) & ~7; + drawable->stridePixels = (drawable->rect.width + 31) & ~31; drawable->strideBytes = drawable->stridePixels * pvrQwsDisplay.screens[drawable->screen].bytesPerPixel; -- cgit v0.12 From 6991cf4fe678427aec370f1abb217591987d3a7e Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 2 Nov 2009 11:31:42 +1000 Subject: Add missing QENUM declarations (needed by declarative). --- src/corelib/animation/qabstractanimation.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h index 50b07d7..3d608b6 100644 --- a/src/corelib/animation/qabstractanimation.h +++ b/src/corelib/animation/qabstractanimation.h @@ -59,6 +59,8 @@ class QAbstractAnimationPrivate; class Q_CORE_EXPORT QAbstractAnimation : public QObject { Q_OBJECT + Q_ENUMS(State) + Q_ENUMS(Direction) Q_PROPERTY(State state READ state NOTIFY stateChanged) Q_PROPERTY(int loopCount READ loopCount WRITE setLoopCount) Q_PROPERTY(int currentTime READ currentTime WRITE setCurrentTime) -- cgit v0.12 From debc67d6183631339b910c52261a6bc7b7a7ae50 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 2 Nov 2009 11:33:09 +1000 Subject: Track declarative changes --- src/gui/graphicsview/qgraphicsitem_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 183e95b..ca56c18 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -607,7 +607,7 @@ public: return item->type() == QGraphicsPixmapItem::Type && !(item->flags() & QGraphicsItem::ItemIsSelectable) && item->d_ptr->children.size() == 0; - //|| (item->d_ptr->isObject && qobject_cast(q_func())); + //|| (item->d_ptr->isObject && qobject_cast(q_func())); } inline const QStyleOption *styleOption() const -- cgit v0.12 From 9f2a0c09a90daa46b7432037595b750406bbd506 Mon Sep 17 00:00:00 2001 From: Peter Yard Date: Mon, 2 Nov 2009 11:44:21 +1000 Subject: Added documentation of RPATH defines. --- doc/src/development/qmake-manual.qdoc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc index 6c53242..352db75 100644 --- a/doc/src/development/qmake-manual.qdoc +++ b/doc/src/development/qmake-manual.qdoc @@ -2342,6 +2342,8 @@ For example: \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_LFLAGS_RPATH + + \e {This is used on Unix platforms only.} Library paths in this definition are added to the executable at link time so that the added paths will be preferentially searched at runtime. @@ -2673,11 +2675,15 @@ For example: \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 45 \section1 QMAKE_RPATH + + \e {This is used on Unix platforms only.} Is equivalent to \l QMAKE_LFLAGS_RPATH. \section1 QMAKE_RPATHDIR + \e {This is used on Unix platforms only.} + A list of library directory paths, these paths are added to the executable at link time so that the paths will be preferentially searched at runtime. -- cgit v0.12 From ae576ea123d0625eceb9904e2039b2183cb82a0b Mon Sep 17 00:00:00 2001 From: Bill King Date: Mon, 2 Nov 2009 12:41:25 +1000 Subject: Fixes Floating point number truncation in qsqlpsql plugin under linux replaces strtod call with locale aware QString::toDouble() Task-number: QTBUG-5179 Reviewed-by: Justin McPherson --- src/sql/drivers/psql/qsql_psql.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp index 4b7c2b5..1e41571 100644 --- a/src/sql/drivers/psql/qsql_psql.cpp +++ b/src/sql/drivers/psql/qsql_psql.cpp @@ -357,7 +357,7 @@ QVariant QPSQLResult::data(int i) } return QString::fromAscii(val); } - return strtod(val, 0); + return QString::fromAscii(val).toDouble(); case QVariant::Date: if (val[0] == '\0') { return QVariant(QDate()); -- cgit v0.12 From 55dcc5551e338ba16c0db8c7d6593554d3d019b8 Mon Sep 17 00:00:00 2001 From: Keith Isdale Date: Mon, 2 Nov 2009 14:29:05 +1000 Subject: Compilation error qegl_p.h not found for OpenGL ES enabled build of Qt for WindowsCE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Be more consistant in the usage of vs "foo_p.h" Task-number: QTBUG-5149 Reviewed-by: Trond Kjernåsen --- src/opengl/qgl_wince.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/opengl/qgl_wince.cpp b/src/opengl/qgl_wince.cpp index 53b9e27..fea2d3a 100644 --- a/src/opengl/qgl_wince.cpp +++ b/src/opengl/qgl_wince.cpp @@ -54,9 +54,9 @@ #include -#include "qegl_p.h" -#include "qgl_egl_p.h" -#include "qgl_cl_p.h" +#include +#include +#include QT_BEGIN_NAMESPACE -- cgit v0.12 From 504ac5668c7308dc67233ed8589eeadcd23e7cdd Mon Sep 17 00:00:00 2001 From: Keith Isdale Date: Mon, 2 Nov 2009 14:59:24 +1000 Subject: Compilation failure QtOpenGL when Opengl ES is used on Qt for Windows CE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enable building egl/qegl_wince.cpp when a wince* mkspec is used Add "egl" to QT_CONFIG when any of the OpenGL ES variants is used Task-number: QTBUG-5073 Reviewed-by: Trond Kjernåsen --- src/gui/egl/egl.pri | 2 +- tools/configure/configureapp.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/egl/egl.pri b/src/gui/egl/egl.pri index ba991bd..627d511 100644 --- a/src/gui/egl/egl.pri +++ b/src/gui/egl/egl.pri @@ -6,7 +6,7 @@ SOURCES += \ egl/qegl.cpp \ egl/qeglproperties.cpp -contains(QT_CONFIG, wince*): SOURCES += egl/qegl_wince.cpp +wince*: SOURCES += egl/qegl_wince.cpp unix { embedded { diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 6d46c18..dd3823b 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -2438,14 +2438,17 @@ void Configure::generateOutputVars() if ( dictionary["OPENGL_ES_CM"] == "yes" ) { qtConfig += "opengles1"; + qtConfig += "egl"; } if ( dictionary["OPENGL_ES_2"] == "yes" ) { qtConfig += "opengles2"; + qtConfig += "egl"; } if ( dictionary["OPENGL_ES_CL"] == "yes" ) { qtConfig += "opengles1cl"; + qtConfig += "egl"; } if ( dictionary["OPENVG"] == "yes" ) { -- cgit v0.12 From d26bc43093cc6ed8d387abedcde0952ec24c0e0b Mon Sep 17 00:00:00 2001 From: Keith Isdale Date: Mon, 2 Nov 2009 15:17:12 +1000 Subject: Compilation failure for OpenGL and OpenVG graphic system plugins when Opengl ES is used on Qt for Windows CE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For WindowsCE plugins do not support version 1.x of OpenGL ES Task-number : QTBUG-5080 Reviewed-by : Trond Kjernåsen --- src/plugins/graphicssystems/graphicssystems.pro | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/graphicssystems/graphicssystems.pro b/src/plugins/graphicssystems/graphicssystems.pro index 14e3cfc..ca87b98 100644 --- a/src/plugins/graphicssystems/graphicssystems.pro +++ b/src/plugins/graphicssystems/graphicssystems.pro @@ -1,7 +1,13 @@ TEMPLATE = subdirs SUBDIRS += trace -contains(QT_CONFIG, opengl):SUBDIRS += opengl -contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl):SUBDIRS += openvg +!wince*{ + contains(QT_CONFIG, opengl):SUBDIRS += opengl + contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl):SUBDIRS += openvg +}else { + # For WindowsCE only 2.x of OpenGL ES is supported by these plugins at this time + contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles1):!contains(QT_CONFIG, opengles1cl):SUBDIRS += opengl + contains(QT_CONFIG, openvg):!contains(QT_CONFIG, opengles1):!contains(QT_CONFIG, opengles1cl):contains(QT_CONFIG, egl):SUBDIRS += openvg +} contains(QT_CONFIG, shivavg) { # Only works under X11 at present -- cgit v0.12 From 2c99050cbf88325f0316159ac35bd34010035bf9 Mon Sep 17 00:00:00 2001 From: Yuecel Ahi Date: Mon, 2 Nov 2009 15:49:55 +1000 Subject: Fixed handling of database level precision policy for sqlite driver. Reviewed-by: Bill King --- src/sql/drivers/sqlite/qsql_sqlite.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp index 2766cca..8355de2 100644 --- a/src/sql/drivers/sqlite/qsql_sqlite.cpp +++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp @@ -228,13 +228,9 @@ bool QSQLiteResultPrivate::fetchNext(QSqlCachedResult::ValueCache &values, int i values[i + idx] = sqlite3_column_int64(stmt, i); break; case QSql::LowPrecisionDouble: - values[i + idx] = sqlite3_column_double(stmt, i); - break; case QSql::HighPrecision: default: - values[i + idx] = QString::fromUtf16(static_cast( - sqlite3_column_text16(stmt, i)), - sqlite3_column_bytes16(stmt, i) / sizeof(ushort)); + values[i + idx] = sqlite3_column_double(stmt, i); break; }; break; -- cgit v0.12 From 2f97ddf87f817ce8ae42095d96644ff5fca131e6 Mon Sep 17 00:00:00 2001 From: Bill King Date: Mon, 2 Nov 2009 16:06:05 +1000 Subject: Fixes testing of sqlite against the real(floating pt) datatype --- tests/auto/qsqldatabase/tst_qsqldatabase.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index 82b6066..fe7c3ea 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -1234,6 +1234,7 @@ void tst_QSqlDatabase::recordSQLite() FieldDef("integer", QVariant::Int, QVariant(13)), FieldDef("int", QVariant::Int, QVariant(12)), + FieldDef("real", QVariant::String, QVariant(1.234567890123456)), FieldDef() }; -- cgit v0.12 From d47bc05931004c7384e77ff358d67feddb84d501 Mon Sep 17 00:00:00 2001 From: Keith Isdale Date: Mon, 2 Nov 2009 17:11:28 +1000 Subject: Compilation failure for OpenGL and OpenVG graphic system plugins when Opengl ES is used on Qt for Windows CE Simplify logic as OpenGL graphic system is not supported for WindowsCE Task-number: QTBUG-5080 Reviewed-by: Rhys Weatherley --- src/plugins/graphicssystems/graphicssystems.pro | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/plugins/graphicssystems/graphicssystems.pro b/src/plugins/graphicssystems/graphicssystems.pro index ca87b98..0788933 100644 --- a/src/plugins/graphicssystems/graphicssystems.pro +++ b/src/plugins/graphicssystems/graphicssystems.pro @@ -1,13 +1,7 @@ TEMPLATE = subdirs SUBDIRS += trace -!wince*{ - contains(QT_CONFIG, opengl):SUBDIRS += opengl - contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl):SUBDIRS += openvg -}else { - # For WindowsCE only 2.x of OpenGL ES is supported by these plugins at this time - contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles1):!contains(QT_CONFIG, opengles1cl):SUBDIRS += opengl - contains(QT_CONFIG, openvg):!contains(QT_CONFIG, opengles1):!contains(QT_CONFIG, opengles1cl):contains(QT_CONFIG, egl):SUBDIRS += openvg -} +!wince*:contains(QT_CONFIG, opengl):SUBDIRS += opengl +contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl):SUBDIRS += openvg contains(QT_CONFIG, shivavg) { # Only works under X11 at present -- cgit v0.12 From 5d7e254583551659df42e59fab4756994d4211ed Mon Sep 17 00:00:00 2001 From: Keith Isdale Date: Mon, 2 Nov 2009 18:03:28 +1000 Subject: Compilation error due to undefined EGL_BIND_TO_TEXTURE_RGB for OpenGL ES enabled build of Qt for Windows CE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add #ifdef guards around EGL_BIND_TO_TEXTURE_RGB useage Task-number: QTBUG-5152 Reviewed-by: Trond Kjernåsen --- src/gui/egl/qeglproperties.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/egl/qeglproperties.cpp b/src/gui/egl/qeglproperties.cpp index c61e1d3..2d37edb 100644 --- a/src/gui/egl/qeglproperties.cpp +++ b/src/gui/egl/qeglproperties.cpp @@ -88,8 +88,12 @@ int QEglProperties::value(int name) const #if defined(EGL_ALPHA_MASK_SIZE) case EGL_ALPHA_MASK_SIZE: return 0; #endif +#if defined(EGL_BIND_TO_TEXTURE_RGB) case EGL_BIND_TO_TEXTURE_RGB: return EGL_DONT_CARE; +#endif +#if defined(EGL_BIND_TO_TEXTURE_RGBA) case EGL_BIND_TO_TEXTURE_RGBA: return EGL_DONT_CARE; +#endif #if defined(EGL_COLOR_BUFFER_TYPE) case EGL_COLOR_BUFFER_TYPE: return EGL_RGB_BUFFER; #endif -- cgit v0.12 From fc6822cb2c1a09b018189168965a8ade23cf1074 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Mon, 2 Nov 2009 10:23:12 +0200 Subject: Fix for static QSound::play in Symbian and code style fixes. Static QSound::play(const QString& filename) API did work for Symbian, since local stack variable was deleted before asynchronous play completed. This happened with the following seqeunce: - void QAuServer::play() is called and creates a QSound on the stack - QAuBucketS60::play() is called - m_prepared is false, so the actual play will happen a bit later - The QSound created on the stack is deleted -> Silence This scenario is now fixed by making copy of QSound object to internal list, and temp object is being deleted when play is completed either successfully or unsuccessfully. Added also manual test case for static play. Task-number: QTBUG-5217 Reviewed-by: Miikka Heikkinen --- src/gui/kernel/qsound_s60.cpp | 94 ++++++++++++++++++++++++---------------- tests/auto/qsound/tst_qsound.cpp | 26 ++++++++--- 2 files changed, 75 insertions(+), 45 deletions(-) diff --git a/src/gui/kernel/qsound_s60.cpp b/src/gui/kernel/qsound_s60.cpp index 352580e..e4b7cec 100644 --- a/src/gui/kernel/qsound_s60.cpp +++ b/src/gui/kernel/qsound_s60.cpp @@ -60,13 +60,13 @@ class QAuServerS60; class QAuBucketS60 : public QAuBucket, public MMdaAudioPlayerCallback { public: - QAuBucketS60( QAuServerS60 *server, QSound *sound); + QAuBucketS60(QAuServerS60 *server, QSound *sound); ~QAuBucketS60(); void play(); void stop(); - inline QSound* sound() const { return m_sound; } + inline QSound *sound() const { return m_sound; } public: // from MMdaAudioPlayerCallback void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration); @@ -77,88 +77,106 @@ private: QAuServerS60 *m_server; bool m_prepared; bool m_playCalled; - CMdaAudioPlayerUtility* m_playUtility; + CMdaAudioPlayerUtility *m_playUtility; }; class QAuServerS60 : public QAuServer { public: - QAuServerS60( QObject* parent ); + QAuServerS60(QObject *parent); - void init( QSound* s ) + void init(QSound *s) { - QAuBucketS60 *bucket = new QAuBucketS60( this, s ); - setBucket( s, bucket ); + QAuBucketS60 *bucket = new QAuBucketS60(this, s); + setBucket(s, bucket); } - void play( QSound* s ) + void play(QSound *s) { - bucket( s )->play(); + bucket(s)->play(); } - void stop( QSound* s ) + void stop(QSound *s) { - bucket( s )->stop(); + bucket(s)->stop(); } bool okay() { return true; } + void play(const QString& filename); + protected: - void playCompleted(QAuBucketS60* bucket, int error) - { - QSound *sound = bucket->sound(); - if(!error) { - // We need to handle repeats by ourselves, since with Symbian API we don't - // know how many loops have been played when user asks it - if( decLoop( sound ) ) { - play( sound ); - } - } else { - // We don't have a way to inform about errors -> just decrement loops - // in order that QSound::isFinished will return true; - while(decLoop(sound)) {} - } - } + void playCompleted(QAuBucketS60 *bucket, int error); protected: - QAuBucketS60* bucket( QSound *s ) + QAuBucketS60 *bucket(QSound *s) { - return (QAuBucketS60*)QAuServer::bucket( s ); + return (QAuBucketS60 *)QAuServer::bucket( s ); } friend class QAuBucketS60; + // static QSound::play(filename) cannot be stopped, meaning that playCompleted + // will get always called and QSound gets removed form this list. + QList staticPlayingSounds; }; -QAuServerS60::QAuServerS60(QObject* parent) : +QAuServerS60::QAuServerS60(QObject *parent) : QAuServer(parent) { setObjectName(QLatin1String("QAuServerS60")); } +void QAuServerS60::play(const QString& filename) +{ + QSound *s = new QSound(filename); + staticPlayingSounds.append(s); + play(s); +} + +void QAuServerS60::playCompleted(QAuBucketS60 *bucket, int error) +{ + QSound *sound = bucket->sound(); + if (!error) { + // We need to handle repeats by ourselves, since with Symbian API we don't + // know how many loops have been played when user asks it + if (decLoop(sound)) { + play(sound); + } else { + if (staticPlayingSounds.removeAll(sound)) + delete sound; + } + } else { + // We don't have a way to inform about errors -> just decrement loops + // in order that QSound::isFinished will return true; + while (decLoop(sound)) {} + if (staticPlayingSounds.removeAll(sound)) + delete sound; + } +} -QAuServer* qt_new_audio_server() +QAuServer *qt_new_audio_server() { return new QAuServerS60(qApp); } -QAuBucketS60::QAuBucketS60( QAuServerS60 *server, QSound *sound ) - : m_sound( sound ), m_server( server ), m_prepared(false), m_playCalled(false) +QAuBucketS60::QAuBucketS60(QAuServerS60 *server, QSound *sound) + : m_sound(sound), m_server(server), m_prepared(false), m_playCalled(false) { - QString filepath = QFileInfo( m_sound->fileName() ).absoluteFilePath(); + QString filepath = QFileInfo(m_sound->fileName()).absoluteFilePath(); filepath = QDir::toNativeSeparators(filepath); TPtrC filepathPtr(qt_QString2TPtrC(filepath)); TRAPD(err, m_playUtility = CMdaAudioPlayerUtility::NewL(*this); m_playUtility->OpenFileL(filepathPtr)); - if(err){ + if (err) { m_server->playCompleted(this, err); } } void QAuBucketS60::play() { - if(m_prepared) { + if (m_prepared) { // OpenFileL call is completed we can start playing immediately m_playUtility->Play(); } else { @@ -180,11 +198,11 @@ void QAuBucketS60::MapcPlayComplete(TInt aError) void QAuBucketS60::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/) { - if(aError) { + if (aError) { m_server->playCompleted(this, aError); } else { m_prepared = true; - if(m_playCalled){ + if (m_playCalled){ play(); } } @@ -192,7 +210,7 @@ void QAuBucketS60::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds QAuBucketS60::~QAuBucketS60() { - if(m_playUtility){ + if (m_playUtility){ m_playUtility->Stop(); m_playUtility->Close(); } diff --git a/tests/auto/qsound/tst_qsound.cpp b/tests/auto/qsound/tst_qsound.cpp index 56a330b..73eca98 100644 --- a/tests/auto/qsound/tst_qsound.cpp +++ b/tests/auto/qsound/tst_qsound.cpp @@ -55,20 +55,32 @@ public: tst_QSound( QObject* parent=0) : QObject(parent) {} private slots: - void checkFinished(); + void checkFinished(); + + // Manual tests + void staticPlay(); }; void tst_QSound::checkFinished() { - QSound sound(SRCDIR"4.wav"); - sound.setLoops(3); - sound.play(); - QTest::qWait(5000); + QSound sound(SRCDIR"4.wav"); + sound.setLoops(3); + sound.play(); + QTest::qWait(5000); #if defined(Q_WS_QWS) - QEXPECT_FAIL("", "QSound buggy on embedded (task QTBUG-157)", Abort); + QEXPECT_FAIL("", "QSound buggy on embedded (task QTBUG-157)", Abort); #endif - QVERIFY(sound.isFinished() ); + QVERIFY(sound.isFinished() ); +} + +void tst_QSound::staticPlay() +{ + QSKIP("Test disabled -- only for manual purposes", SkipAll); + + // Check that you hear sound with static play also. + QSound::play(SRCDIR"4.wav"); + QTest::qWait(2000); } QTEST_MAIN(tst_QSound); -- cgit v0.12 From 17cda5c55273813cbedcced3a511f1c222978182 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 2 Nov 2009 10:51:08 +0100 Subject: Check for null pixmap Reviewed-by: Trond --- src/gui/painting/qwindowsurface_x11.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qwindowsurface_x11.cpp b/src/gui/painting/qwindowsurface_x11.cpp index 46c4c42..77e019c 100644 --- a/src/gui/painting/qwindowsurface_x11.cpp +++ b/src/gui/painting/qwindowsurface_x11.cpp @@ -94,6 +94,8 @@ QPaintDevice *QX11WindowSurface::paintDevice() void QX11WindowSurface::beginPaint(const QRegion &rgn) { #ifndef QT_NO_XRENDER + Q_ASSERT(!d_ptr->device.isNull()); + if (d_ptr->translucentBackground) { if (d_ptr->device.depth() != 32) static_cast(d_ptr->device.data_ptr().data())->convertToARGB32(); @@ -157,8 +159,8 @@ void QX11WindowSurface::setGeometry(const QRect &rect) QPixmap::x11SetDefaultScreen(d_ptr->widget->x11Info().screen()); QX11PixmapData *oldData = static_cast(d_ptr->device.pixmapData()); - Q_ASSERT(oldData); - if (!(oldData->flags & QX11PixmapData::Uninitialized) && hasStaticContents()) { + + if (oldData && !(oldData->flags & QX11PixmapData::Uninitialized) && hasStaticContents()) { // Copy the content of the old pixmap into the new one. QX11PixmapData *newData = new QX11PixmapData(QPixmapData::PixmapType); newData->resize(size.width(), size.height()); -- cgit v0.12 From e1a08048f29174c01e289a4f608aaa283819c5d5 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 2 Nov 2009 10:51:47 +0100 Subject: QStyleSheetStyle: fixes QPushButton { text-alignement:top } The vertial alignement was correctly set later in the function but Qt::AlignVCenter was always set, conflicting with the flags from textAlignment Reviewed-by: Gabriel Task-number: QTBUG-5110 Task-number: 240367 --- src/gui/styles/qstylesheetstyle.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 2d90aa1..2ae9f6a 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -3370,7 +3370,9 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if (rule.hasPosition() && rule.position()->textAlignment != 0) { Qt::Alignment textAlignment = rule.position()->textAlignment; QRect textRect = button->rect; - uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic; + uint tf = Qt::TextShowMnemonic; + const uint verticalAlignMask = Qt::AlignVCenter | Qt::AlignTop | Qt::AlignLeft; + tf |= (textAlignment & verticalAlignMask) ? (textAlignment & verticalAlignMask) : Qt::AlignVCenter; if (!styleHint(SH_UnderlineShortcut, button, w)) tf |= Qt::TextHideMnemonic; if (!button->icon.isNull()) { -- cgit v0.12 From a80e58335e69c8ce96d1596e0ed2d14e424a0d5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Mon, 2 Nov 2009 12:03:52 +0200 Subject: Style's theme palette hash is lost after orientation switch Currently, after orientation switch when new theme background is applied, it is done using QApplication::setPalette(). This unfortunately tosses away the palette hash. So instead directly calling QApplication::setPalette(), the fix is to call the style's internal setThemePalette(), which copies the hash also to QApplication palette. This is related to bug QT-1478 in Private JIRA. Task-number: QT-1478 Reviewed-by: Shane Kearns --- src/gui/styles/qs60style.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 10a63a8..48f7042 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -499,7 +499,7 @@ void QS60StylePrivate::setBackgroundTexture(QApplication *app) const Q_UNUSED(app) QPalette applicationPalette = QApplication::palette(); applicationPalette.setBrush(QPalette::Window, backgroundTexture()); - QApplication::setPalette(applicationPalette); + setThemePalette(app); } void QS60StylePrivate::deleteBackground() -- cgit v0.12 From be651bb65e952743f4bc31a970750be501bcf978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Mon, 2 Nov 2009 11:31:01 +0100 Subject: Enable the RightToLeft (mirrored) test for basic layout tests. --- tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp index 1c7a159..1a19162 100644 --- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp +++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -1715,8 +1715,6 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() QCOMPARE(widgets[item.index]->geometry(), item.rect); } - // ###: not supported yet -/* // Test mirrored mode widget->setLayoutDirection(Qt::RightToLeft); layout->activate(); @@ -1731,7 +1729,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() QCOMPARE(widgets[item.index]->geometry(), mirroredRect); delete widgets[item.index]; } -*/ + delete widget; } -- cgit v0.12 From 016c06f8988c50f0f8309b1b5054ea99ecd1bc6c Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 2 Nov 2009 12:05:03 +0100 Subject: Manual glyph shaping test. It tests the glyph shaper in Qt by rendering a couple of glyph combinations that are known to be strongly shaped. For now, this test is manual and simply generates an html report for a visual test. It can, however also be implemented as auto test. The test data contains Vietnamese and Tamil data sets, more will follow. Reviewed-by: trustme --- .../textrendering/glyphshaping/glyphshaping.pro | 5 + .../glyphshaping/glyphshaping_data.xml | 251 +++++++++++++++++++ tests/manual/textrendering/glyphshaping/main.cpp | 269 +++++++++++++++++++++ 3 files changed, 525 insertions(+) create mode 100644 tests/manual/textrendering/glyphshaping/glyphshaping.pro create mode 100644 tests/manual/textrendering/glyphshaping/glyphshaping_data.xml create mode 100644 tests/manual/textrendering/glyphshaping/main.cpp diff --git a/tests/manual/textrendering/glyphshaping/glyphshaping.pro b/tests/manual/textrendering/glyphshaping/glyphshaping.pro new file mode 100644 index 0000000..caa9028 --- /dev/null +++ b/tests/manual/textrendering/glyphshaping/glyphshaping.pro @@ -0,0 +1,5 @@ +SOURCES = main.cpp +OTHER_FILES = glyphshaping_data.xml +glyphshaping_data.path = . +glyphshaping_data.sources = $$PWD/glyphshaping_data.xml +DEPLOYMENT += glyphshaping_data diff --git a/tests/manual/textrendering/glyphshaping/glyphshaping_data.xml b/tests/manual/textrendering/glyphshaping/glyphshaping_data.xml new file mode 100644 index 0000000..040804e --- /dev/null +++ b/tests/manual/textrendering/glyphshaping/glyphshaping_data.xml @@ -0,0 +1,251 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/manual/textrendering/glyphshaping/main.cpp b/tests/manual/textrendering/glyphshaping/main.cpp new file mode 100644 index 0000000..d2b53a0 --- /dev/null +++ b/tests/manual/textrendering/glyphshaping/main.cpp @@ -0,0 +1,269 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +static const int fontPixelSize = 25; +static const QLatin1String fontFamily("Series 60 Sans"); + +struct testDataSet +{ + QString language; + QString name; + QString input; + QString inputOriginal; + QString output; + QString outputOriginal; + QVector outputGlyphIDs; + QString outputGlyphIDsOriginal; +}; + +QString charHexCsv2String(const QString &csv) +{ + QString result; + foreach (const QString &charString, csv.split(QLatin1Char(','), QString::SkipEmptyParts)) { + bool isOk; + const uint charUInt = charString.toUInt(&isOk, 16); + Q_ASSERT(isOk); + const int size = charUInt >= SHRT_MAX ? 2:1; + result.append(QString::fromUtf16((const ushort*)&charUInt, size)); + } + return result; +} + +QList testDataSetList() +{ + QList result; + QFile file("glyphshaping_data.xml"); + const bool success = file.open(QIODevice::ReadOnly); + Q_ASSERT(success); + + const QLatin1String language("language"); + const QLatin1String test("test"); + const QLatin1String inputUtf16("inpututf16"); + const QLatin1String outputUtf16("outpututf16"); + const QLatin1String outputGlyphIDs("outputglyphids"); + const QLatin1String name("name"); + + QString languageName; + + QXmlStreamReader reader(&file); + while (!reader.atEnd()) { + const QXmlStreamReader::TokenType token = reader.readNext(); + switch (token) { + case QXmlStreamReader::StartElement: + if (reader.name() == language) { + Q_ASSERT(reader.attributes().hasAttribute(name)); + languageName = reader.attributes().value(name).toString(); + } else if (reader.name() == test) { + if (!reader.attributes().hasAttribute(outputUtf16) + && !reader.attributes().hasAttribute(outputGlyphIDs)) + continue; + Q_ASSERT(!languageName.isEmpty()); + Q_ASSERT(reader.attributes().hasAttribute(name)); + Q_ASSERT(reader.attributes().hasAttribute(inputUtf16)); + testDataSet set; + set.language = languageName; + set.name = reader.attributes().value(name).toString(); + set.inputOriginal = reader.attributes().value(inputUtf16).toString(); + set.input = charHexCsv2String(set.inputOriginal); + set.outputOriginal = reader.attributes().value(outputUtf16).toString(); + set.output = charHexCsv2String(set.outputOriginal); + set.outputGlyphIDsOriginal = reader.attributes().value(outputGlyphIDs).toString(); + result.append(set); + } + break; + default: + break; + } + } + return result; +} + +QImage renderedText(const QString &text, const QFont &font) +{ + const QFontMetrics metrics(font); + const QRect boundingRect = metrics.boundingRect(text); + QImage result(boundingRect.size(), QImage::Format_ARGB32); + result.fill(0); + + QPainter p(&result); + p.setFont(font); + p.drawText(boundingRect.translated(-boundingRect.topLeft()), text); + + return result; +} + +QString dumpImageHtml(const QString &text, const QString &pathName) +{ + if (text.isEmpty()) + return QLatin1String(""); + QFont font(fontFamily); + font.setPixelSize(fontPixelSize); + const QImage textImage = renderedText(text, font); + const QString imageFileName = + (pathName + QDir::separator() + QLatin1String("%1.png")) + .arg(textImage.cacheKey()); + const bool success = textImage.save(imageFileName); + Q_ASSERT(success); + return + QString::fromLatin1("\"%2\"") + .arg(QDir::cleanPath(imageFileName)).arg(text).arg(textImage.width()).arg(textImage.height()); +} + +QString dlItem(const QString &dt, const QString &dd) +{ + if (!dd.trimmed().isEmpty()) + return QString::fromLatin1("\t\t\t\t\t\t
%1
%2
\n").arg(dt).arg(dd); + return QString(); +} + +bool dumpHtml(const QString &pathName) +{ + QFile htmlPage(pathName + QDir::separator() + QLatin1String("index.html")); + if (!htmlPage.open(QFile::WriteOnly)) + return false; + + QString platformName = QString::fromLatin1( +#if defined(Q_OS_WIN) + "Win32" +#elif defined(Q_WS_X11) + "X11" +#elif defined(Q_OS_SYMBIAN) + "Symbian" +#else + "" +#endif + ); + + QString result = QString::fromLatin1( + "\n\n" + "\n" + "\t\n" + "\t\tQt on %1 glyph shaping (%2)\n" + "\t\t\n" + "\t\t\n" + "\t\n" + "\t\n" + "\t\t

Qt on %1 glyph shaping (%2)

\n" + "\t\t
\n" + "\t\t\t
I
Input Utf-16 to shaper
\n" + "\t\t\t
O-Utf
expected output Utf-16
\n" + "\t\t\t
O-ID
expected output Glyph IDs for \"Series 60 Sans\"
\n" + "\t\t
\n" + "\t\t\n" + ).arg(platformName).arg(fontFamily).arg(fontPixelSize); + + QString languageName; + foreach (const testDataSet &dataSet, testDataSetList()) { + if (languageName != dataSet.language) { + result.append(QString::fromLatin1( + "\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\n" + ).arg(dataSet.language).arg(platformName)); + languageName = dataSet.language; + } + QString glyphsData; + if (!dataSet.inputOriginal.isEmpty()) + glyphsData.append(dlItem(QLatin1String("I"), dataSet.inputOriginal)); + if (!dataSet.outputOriginal.isEmpty()) + glyphsData.append(dlItem(QLatin1String("O-Utf"), dataSet.outputOriginal)); + if (!dataSet.outputGlyphIDsOriginal.isEmpty()) + glyphsData.append(dlItem(QLatin1String("O-ID"), dataSet.outputGlyphIDsOriginal)); + if (!glyphsData.isEmpty()) { + glyphsData.prepend(QLatin1String("\t\t\t\t\t
\n")); + glyphsData.append(QLatin1String("\t\t\t\t\t
\n")); + } + result.append(QString::fromLatin1( + "\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t%2\n" + "\t\t\t\t%3\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\n" + ).arg(dataSet.name) + .arg(dumpImageHtml(dataSet.input, pathName)) + .arg(dumpImageHtml(dataSet.output, pathName)) + .arg(glyphsData) + .arg(dataSet.input) + .arg(dataSet.output) + ); + } + + result.append(QString::fromLatin1( + "\t\t

%1

Qt/%2GlyphsBrowser
InOutInOut
%1\n" + "%4" + "\t\t\t\t%5%6
\n" + "\t\n" + "") + ); + + htmlPage.write(result.toUtf8()); + + return true; +} + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + return dumpHtml(QLatin1String(".")) ? 0 : 1; +} -- cgit v0.12 From 85e41590732f15cec16909bf1121d944ae684373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 30 Oct 2009 13:37:05 +0100 Subject: Optimized graphics effects to not needlessly invalidate cache. When the effect rect changes we only need to invalidate the cache if the mode is ExpandToEffectRectPadMode. Reviewed-by: Gunnar Sletta --- src/gui/effects/qgraphicseffect.cpp | 9 ++++++++- src/gui/effects/qgraphicseffect_p.h | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 3a6bab5..c8e39da 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -279,6 +279,13 @@ QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offse return pm; } +void QGraphicsEffectSourcePrivate::invalidateCache(bool effectRectChanged) const +{ + if (effectRectChanged && m_cachedMode != QGraphicsEffectSource::ExpandToEffectRectPadMode) + return; + QPixmapCache::remove(m_cacheKey); +} + /*! Constructs a new QGraphicsEffect instance having the specified \a parent. @@ -418,7 +425,7 @@ void QGraphicsEffect::updateBoundingRect() Q_D(QGraphicsEffect); if (d->source) { d->source->d_func()->effectBoundingRectChanged(); - d->source->d_func()->invalidateCache(); + d->source->d_func()->invalidateCache(true); } } diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h index 1ed7103..0ff5794 100644 --- a/src/gui/effects/qgraphicseffect_p.h +++ b/src/gui/effects/qgraphicseffect_p.h @@ -85,7 +85,7 @@ public: virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = 0, QGraphicsEffectSource::PixmapPadMode mode = QGraphicsEffectSource::ExpandToTransparentBorderPadMode) const = 0; virtual void effectBoundingRectChanged() = 0; - void invalidateCache() const { QPixmapCache::remove(m_cacheKey); } + void invalidateCache(bool effectRectChanged = false) const; friend class QGraphicsScenePrivate; friend class QGraphicsItem; -- cgit v0.12 From 70b7f26c3155e83d59cae7b89ed1af3b57797a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 30 Oct 2009 13:59:41 +0100 Subject: Added strict size parameter to QGLFramebufferObject pool. The strict size parameter can be used when it's critical that we get the exact size we ask for. Reviewed-by: Gunnar Sletta --- src/opengl/qpixmapdata_gl.cpp | 19 ++++++++++++++++--- src/opengl/qpixmapdata_gl_p.h | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index c965947..5ca37ef 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -89,13 +89,22 @@ static inline QSize maybeRoundToNextPowerOfTwo(const QSize &sz) } -QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize, const QGLFramebufferObjectFormat &requestFormat) +QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize, const QGLFramebufferObjectFormat &requestFormat, bool strictSize) { QGLFramebufferObject *chosen = 0; QGLFramebufferObject *candidate = 0; for (int i = 0; !chosen && i < m_fbos.size(); ++i) { QGLFramebufferObject *fbo = m_fbos.at(i); + if (strictSize) { + if (fbo->size() == requestSize && fbo->format() == requestFormat) { + chosen = fbo; + break; + } else { + continue; + } + } + if (fbo->format() == requestFormat) { // choose the fbo with a matching format and the closest size if (!candidate || areaDiff(requestSize, candidate) > areaDiff(requestSize, fbo)) @@ -127,7 +136,10 @@ QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize } if (!chosen) { - chosen = new QGLFramebufferObject(maybeRoundToNextPowerOfTwo(requestSize), requestFormat); + if (strictSize) + chosen = new QGLFramebufferObject(requestSize, requestFormat); + else + chosen = new QGLFramebufferObject(maybeRoundToNextPowerOfTwo(requestSize), requestFormat); } if (!chosen->isValid()) { @@ -140,7 +152,8 @@ QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize void QGLFramebufferObjectPool::release(QGLFramebufferObject *fbo) { - m_fbos << fbo; + if (fbo) + m_fbos << fbo; } diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h index 6190d38..8a13e03 100644 --- a/src/opengl/qpixmapdata_gl_p.h +++ b/src/opengl/qpixmapdata_gl_p.h @@ -69,7 +69,7 @@ class QGLPixmapData; class QGLFramebufferObjectPool { public: - QGLFramebufferObject *acquire(const QSize &size, const QGLFramebufferObjectFormat &format); + QGLFramebufferObject *acquire(const QSize &size, const QGLFramebufferObjectFormat &format, bool strictSize = false); void release(QGLFramebufferObject *fbo); private: -- cgit v0.12 From 2a902676b74d0aa3482e722602879f7a02be1103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 30 Oct 2009 14:26:55 +0100 Subject: Moved Qt::RenderHint back into QGraphicsBlurEffect and added a hint. Added AnimationHint, which didn't make too much sense in a generic enum, so Qt::RenderHint was moved back into QGraphicsBlurEffect as QGraphicsBlurEffect::BlurHint. Reviewed-by: Gunnar Sletta --- dist/changes-4.6.0 | 4 ++++ src/corelib/global/qnamespace.h | 5 ----- src/corelib/global/qnamespace.qdoc | 15 --------------- src/gui/effects/qgraphicseffect.cpp | 37 ++++++++++++++++++++++++++++--------- src/gui/effects/qgraphicseffect.h | 14 ++++++++++---- src/gui/image/qpixmapfilter.cpp | 18 ++++++++++++------ src/gui/image/qpixmapfilter_p.h | 5 +++-- src/opengl/qglpixmapfilter.cpp | 28 ++++++++++++++-------------- 8 files changed, 71 insertions(+), 55 deletions(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 7f723da..c7f9ad7 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -30,6 +30,10 @@ information about a particular change. * [245219] Added QXmlQuery::setFocus(const QString &focus); + - QGraphicsBlurEffect + * Since the 4.6 beta Qt::RenderHint has been moved to + QGraphicsBlurEffect::BlurHint. + - QVariant * Many optimisations * Added QVariant::toFloat() and QVariant::toReal() diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 2b62c6b..42dd3a2 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1645,11 +1645,6 @@ public: NavigationModeCursorAuto, NavigationModeCursorForceVisible }; - - enum RenderHint { - QualityHint, - PerformanceHint - }; } #ifdef Q_MOC_RUN ; diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 5f9d01d..e3e881d 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2873,18 +2873,3 @@ \sa QApplication::setNavigationMode() \sa QApplication::navigationMode() */ - -/*! - \enum Qt::RenderHint - \since 4.6 - - This enum describes the possible hints that can be used to control various - rendering operations. - - \value QualityHint Indicates that rendering quality is the most important factor, - at the potential cost of lower performance. - - \value PerformanceHint Indicates that rendering performance is the most important factor, - at the potential cost of lower quality. -*/ - diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index c8e39da..e181b18 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -613,6 +613,26 @@ void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *sou */ /*! + \enum QGraphicsBlurEffect::BlurHint + \since 4.6 + + This enum describes the possible hints that can be used to control how + blur effects are applied. The hints might not have an effect in all the + paint engines. + + \value QualityHint Indicates that rendering quality is the most important factor, + at the potential cost of lower performance. + + \value PerformanceHint Indicates that rendering performance is the most important factor, + at the potential cost of lower quality. + + \value AnimationHint Indicates that the blur radius is going to be animated, hinting + that the implementation can keep a cache of blurred verisons of the source pixmap. + Do not use this hint if the source item is going to be dynamically changing. +*/ + + +/*! Constructs a new QGraphicsBlurEffect instance. The \a parent parameter is passed to QGraphicsEffect's constructor. */ @@ -620,7 +640,7 @@ QGraphicsBlurEffect::QGraphicsBlurEffect(QObject *parent) : QGraphicsEffect(*new QGraphicsBlurEffectPrivate, parent) { Q_D(QGraphicsBlurEffect); - d->filter->setBlurHint(Qt::PerformanceHint); + d->filter->setBlurHint(QGraphicsBlurEffect::PerformanceHint); } /*! @@ -667,20 +687,19 @@ void QGraphicsBlurEffect::setBlurRadius(qreal radius) \property QGraphicsBlurEffect::blurHint \brief the blur hint of the effect. - Use the Qt::PerformanceHint hint to say that you want a faster blur, - and the Qt::QualityHint hint to say that you prefer a higher quality blur. - - When animating the blur radius it's recommended to use Qt::PerformanceHint. + Use the PerformanceHint hint to say that you want a faster blur, + the QualityHint hint to say that you prefer a higher quality blur, + or the AnimationHint when you want to animate the blur radius. - By default, the blur hint is Qt::PerformanceHint. + By default, the blur hint is PerformanceHint. */ -Qt::RenderHint QGraphicsBlurEffect::blurHint() const +QGraphicsBlurEffect::BlurHint QGraphicsBlurEffect::blurHint() const { Q_D(const QGraphicsBlurEffect); return d->filter->blurHint(); } -void QGraphicsBlurEffect::setBlurHint(Qt::RenderHint hint) +void QGraphicsBlurEffect::setBlurHint(QGraphicsBlurEffect::BlurHint hint) { Q_D(QGraphicsBlurEffect); if (d->filter->blurHint() == hint) @@ -691,7 +710,7 @@ void QGraphicsBlurEffect::setBlurHint(Qt::RenderHint hint) } /*! - \fn void QGraphicsBlurEffect::blurHintChanged(Qt::RenderHint hint) + \fn void QGraphicsBlurEffect::blurHintChanged(Qt::BlurHint hint) This signal is emitted whenever the effect's blur hint changes. The \a hint parameter holds the effect's new blur hint. diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h index bf18581..7335a25 100644 --- a/src/gui/effects/qgraphicseffect.h +++ b/src/gui/effects/qgraphicseffect.h @@ -183,22 +183,28 @@ class Q_GUI_EXPORT QGraphicsBlurEffect: public QGraphicsEffect { Q_OBJECT Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) - Q_PROPERTY(Qt::RenderHint blurHint READ blurHint WRITE setBlurHint NOTIFY blurHintChanged) + Q_PROPERTY(BlurHint blurHint READ blurHint WRITE setBlurHint NOTIFY blurHintChanged) public: + enum BlurHint { + QualityHint, + PerformanceHint, + AnimationHint + }; + QGraphicsBlurEffect(QObject *parent = 0); ~QGraphicsBlurEffect(); QRectF boundingRectFor(const QRectF &rect) const; qreal blurRadius() const; - Qt::RenderHint blurHint() const; + BlurHint blurHint() const; public Q_SLOTS: void setBlurRadius(qreal blurRadius); - void setBlurHint(Qt::RenderHint hint); + void setBlurHint(BlurHint hint); Q_SIGNALS: void blurRadiusChanged(qreal blurRadius); - void blurHintChanged(Qt::RenderHint hint); + void blurHintChanged(BlurHint hint); protected: void draw(QPainter *painter, QGraphicsEffectSource *source); diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp index d0de03e..e50cc8b 100644 --- a/src/gui/image/qpixmapfilter.cpp +++ b/src/gui/image/qpixmapfilter.cpp @@ -504,10 +504,10 @@ void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const Q class QPixmapBlurFilterPrivate : public QPixmapFilterPrivate { public: - QPixmapBlurFilterPrivate() : radius(5), hint(Qt::PerformanceHint) {} + QPixmapBlurFilterPrivate() : radius(5), hint(QGraphicsBlurEffect::PerformanceHint) {} qreal radius; - Qt::RenderHint hint; + QGraphicsBlurEffect::BlurHint hint; }; @@ -556,12 +556,18 @@ qreal QPixmapBlurFilter::radius() const Setting the blur hint to PerformanceHint causes the implementation to trade off visual quality to blur the image faster. Setting the blur hint to QualityHint causes the implementation to improve - visual quality at the expense of speed. The implementation is free - to ignore this value if it only has a single blur algorithm. + visual quality at the expense of speed. + + AnimationHint causes the implementation to optimize for animating + the blur radius, possibly by caching blurred versions of the source + pixmap. + + The implementation is free to ignore this value if it only has a single + blur algorithm. \internal */ -void QPixmapBlurFilter::setBlurHint(Qt::RenderHint hint) +void QPixmapBlurFilter::setBlurHint(QGraphicsBlurEffect::BlurHint hint) { Q_D(QPixmapBlurFilter); d->hint = hint; @@ -572,7 +578,7 @@ void QPixmapBlurFilter::setBlurHint(Qt::RenderHint hint) \internal */ -Qt::RenderHint QPixmapBlurFilter::blurHint() const +QGraphicsBlurEffect::BlurHint QPixmapBlurFilter::blurHint() const { Q_D(const QPixmapBlurFilter); return d->hint; diff --git a/src/gui/image/qpixmapfilter_p.h b/src/gui/image/qpixmapfilter_p.h index fc70795..6a96676 100644 --- a/src/gui/image/qpixmapfilter_p.h +++ b/src/gui/image/qpixmapfilter_p.h @@ -55,6 +55,7 @@ #include #include +#include QT_BEGIN_HEADER @@ -130,10 +131,10 @@ public: ~QPixmapBlurFilter(); void setRadius(qreal radius); - void setBlurHint(Qt::RenderHint hint); + void setBlurHint(QGraphicsBlurEffect::BlurHint hint); qreal radius() const; - Qt::RenderHint blurHint() const; + QGraphicsBlurEffect::BlurHint blurHint() const; QRectF boundingRectFor(const QRectF &rect) const; void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const; diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index 2af69e0..3b94ad3 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -100,7 +100,7 @@ private: class QGLPixmapBlurFilter : public QGLCustomShaderStage, public QGLPixmapFilter { public: - QGLPixmapBlurFilter(Qt::RenderHint hint); + QGLPixmapBlurFilter(QGraphicsBlurEffect::BlurHint hint); void setUniforms(QGLShaderProgram *program); @@ -117,13 +117,13 @@ private: mutable bool m_haveCached; mutable int m_cachedRadius; - mutable Qt::RenderHint m_hint; + mutable QGraphicsBlurEffect::BlurHint m_hint; }; class QGLPixmapDropShadowFilter : public QGLCustomShaderStage, public QGLPixmapFilter { public: - QGLPixmapDropShadowFilter(Qt::RenderHint hint); + QGLPixmapDropShadowFilter(QGraphicsBlurEffect::BlurHint hint); void setUniforms(QGLShaderProgram *program); @@ -137,7 +137,7 @@ private: mutable bool m_haveCached; mutable int m_cachedRadius; - mutable Qt::RenderHint m_hint; + mutable QGraphicsBlurEffect::BlurHint m_hint; }; extern QGLWidget *qt_gl_share_widget(); @@ -153,13 +153,13 @@ QPixmapFilter *QGL2PaintEngineEx::pixmapFilter(int type, const QPixmapFilter *pr case QPixmapFilter::BlurFilter: { const QPixmapBlurFilter *proto = static_cast(prototype); - if (proto->blurHint() == Qt::PerformanceHint || proto->radius() <= 5) { + if (proto->blurHint() == QGraphicsBlurEffect::PerformanceHint || proto->radius() <= 5) { if (!d->fastBlurFilter) - d->fastBlurFilter.reset(new QGLPixmapBlurFilter(Qt::PerformanceHint)); + d->fastBlurFilter.reset(new QGLPixmapBlurFilter(QGraphicsBlurEffect::PerformanceHint)); return d->fastBlurFilter.data(); } if (!d->blurFilter) - d->blurFilter.reset(new QGLPixmapBlurFilter(Qt::QualityHint)); + d->blurFilter.reset(new QGLPixmapBlurFilter(QGraphicsBlurEffect::QualityHint)); return d->blurFilter.data(); } @@ -167,11 +167,11 @@ QPixmapFilter *QGL2PaintEngineEx::pixmapFilter(int type, const QPixmapFilter *pr const QPixmapDropShadowFilter *proto = static_cast(prototype); if (proto->blurRadius() <= 5) { if (!d->fastDropShadowFilter) - d->fastDropShadowFilter.reset(new QGLPixmapDropShadowFilter(Qt::PerformanceHint)); + d->fastDropShadowFilter.reset(new QGLPixmapDropShadowFilter(QGraphicsBlurEffect::PerformanceHint)); return d->fastDropShadowFilter.data(); } if (!d->dropShadowFilter) - d->dropShadowFilter.reset(new QGLPixmapDropShadowFilter(Qt::QualityHint)); + d->dropShadowFilter.reset(new QGLPixmapDropShadowFilter(QGraphicsBlurEffect::QualityHint)); return d->dropShadowFilter.data(); } @@ -327,7 +327,7 @@ static QByteArray qt_gl_convertToClamped(const QByteArray &source) return result; } -QGLPixmapBlurFilter::QGLPixmapBlurFilter(Qt::RenderHint hint) +QGLPixmapBlurFilter::QGLPixmapBlurFilter(QGraphicsBlurEffect::BlurHint hint) : m_haveCached(false) , m_cachedRadius(0) , m_hint(hint) @@ -341,7 +341,7 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const int actualRadius = qRound(radius()); int filterRadius = actualRadius; int fastRadii[] = { 1, 2, 3, 5, 8, 15, 25 }; - if (m_hint == Qt::PerformanceHint) { + if (m_hint == QGraphicsBlurEffect::PerformanceHint) { uint i = 0; for (; i < (sizeof(fastRadii)/sizeof(*fastRadii))-1; ++i) { if (fastRadii[i+1] > filterRadius) @@ -428,7 +428,7 @@ void QGLPixmapBlurFilter::setUniforms(QGLShaderProgram *program) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - if (m_hint == Qt::QualityHint) { + if (m_hint == QGraphicsBlurEffect::QualityHint) { if (m_singlePass) program->setUniformValue("delta", 1.0 / m_textureSize.width(), 1.0 / m_textureSize.height()); else if (m_horizontalBlur) @@ -578,7 +578,7 @@ QByteArray QGLPixmapBlurFilter::generateGaussianShader(int radius, bool singlePa return source; } -QGLPixmapDropShadowFilter::QGLPixmapDropShadowFilter(Qt::RenderHint hint) +QGLPixmapDropShadowFilter::QGLPixmapDropShadowFilter(QGraphicsBlurEffect::BlurHint hint) : m_haveCached(false) , m_cachedRadius(0) , m_hint(hint) @@ -685,7 +685,7 @@ void QGLPixmapDropShadowFilter::setUniforms(QGLShaderProgram *program) alpha); } - if (m_hint == Qt::QualityHint) { + if (m_hint == QGraphicsBlurEffect::QualityHint) { if (m_singlePass) program->setUniformValue("delta", 1.0 / m_textureSize.width(), 1.0 / m_textureSize.height()); else if (m_horizontalBlur) -- cgit v0.12 From 64fbefa605d976ab752149bb39880893c82ad8c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 30 Oct 2009 14:00:35 +0100 Subject: Optimized animated blur radii in the GL 2 paint engine. We add an internal cache which keeps four half-scaled versions of the source pixmap at different blur radii, then we simply interpolate between the two pixmaps around the desired blur radius, or between the base source pixmap and the first blurred version. Reviewed-by: Gunnar Sletta --- .../gl2paintengineex/qpaintengineex_opengl2_p.h | 1 + src/opengl/qgl.h | 1 + src/opengl/qglpixmapfilter.cpp | 379 ++++++++++++++++++++- 3 files changed, 369 insertions(+), 12 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 209cd36..4cf2a83 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -289,6 +289,7 @@ public: QScopedPointer convolutionFilter; QScopedPointer colorizeFilter; QScopedPointer blurFilter; + QScopedPointer animationBlurFilter; QScopedPointer fastBlurFilter; QScopedPointer dropShadowFilter; QScopedPointer fastDropShadowFilter; diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index e14e7fb..079953f 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -399,6 +399,7 @@ private: friend class QGLTextureGlyphCache; friend class QGLShareRegister; friend class QGLSharedResourceGuard; + friend class QGLPixmapBlurFilter; friend QGLFormat::OpenGLVersionFlags QGLFormat::openGLVersionFlags(); #ifdef Q_WS_MAC public: diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index 3b94ad3..ff19e06 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -43,6 +43,8 @@ #include "private/qpixmapdata_gl_p.h" #include "private/qpaintengineex_opengl2_p.h" #include "private/qglengineshadermanager_p.h" +#include "private/qpixmapdata_p.h" +#include "private/qimagepixmapcleanuphooks_p.h" #include "qglpixmapfilter_p.h" #include "qgraphicssystem_gl_p.h" #include "qpaintengine_opengl_p.h" @@ -54,7 +56,7 @@ #include "private/qapplication_p.h" #include "private/qmath_p.h" - +#include "qmath.h" QT_BEGIN_NAMESPACE @@ -114,6 +116,10 @@ private: mutable QSize m_textureSize; mutable bool m_horizontalBlur; mutable bool m_singlePass; + mutable bool m_animatedBlur; + + mutable qreal m_t; + mutable QSize m_targetSize; mutable bool m_haveCached; mutable int m_cachedRadius; @@ -153,6 +159,11 @@ QPixmapFilter *QGL2PaintEngineEx::pixmapFilter(int type, const QPixmapFilter *pr case QPixmapFilter::BlurFilter: { const QPixmapBlurFilter *proto = static_cast(prototype); + if (proto->blurHint() == QGraphicsBlurEffect::AnimationHint) { + if (!d->animationBlurFilter) + d->animationBlurFilter.reset(new QGLPixmapBlurFilter(proto->blurHint())); + return d->animationBlurFilter.data(); + } if (proto->blurHint() == QGraphicsBlurEffect::PerformanceHint || proto->radius() <= 5) { if (!d->fastBlurFilter) d->fastBlurFilter.reset(new QGLPixmapBlurFilter(QGraphicsBlurEffect::PerformanceHint)); @@ -328,20 +339,343 @@ static QByteArray qt_gl_convertToClamped(const QByteArray &source) } QGLPixmapBlurFilter::QGLPixmapBlurFilter(QGraphicsBlurEffect::BlurHint hint) - : m_haveCached(false) + : m_animatedBlur(false) + , m_haveCached(false) , m_cachedRadius(0) , m_hint(hint) { } +// should be even numbers as they will be divided by two +static const int qCachedBlurLevels[] = { 6, 14, 30 }; +static const int qNumCachedBlurTextures = sizeof(qCachedBlurLevels) / sizeof(*qCachedBlurLevels); +static const int qMaxCachedBlurLevel = qCachedBlurLevels[qNumCachedBlurTextures - 1]; + +static qreal qLogBlurLevel(int level) +{ + static bool initialized = false; + static qreal logBlurLevelCache[qNumCachedBlurTextures]; + if (!initialized) { + for (int i = 0; i < qNumCachedBlurTextures; ++i) + logBlurLevelCache[i] = qLn(qCachedBlurLevels[i]); + initialized = true; + } + return logBlurLevelCache[level]; +} + +class QGLBlurTextureInfo +{ +public: + QGLBlurTextureInfo(QSize size, GLuint textureIds[]) + : m_size(size) + { + for (int i = 0; i < qNumCachedBlurTextures; ++i) + m_textureIds[i] = textureIds[i]; + } + + ~QGLBlurTextureInfo() + { + glDeleteTextures(qNumCachedBlurTextures, m_textureIds); + } + + QSize size() const { return m_size; } + GLuint textureId(int i) const { return m_textureIds[i]; } + +private: + GLuint m_textureIds[qNumCachedBlurTextures]; + QSize m_size; +}; + +class QGLBlurTextureCache : public QObject +{ +public: + static QGLBlurTextureCache *cacheForContext(const QGLContext *context); + + QGLBlurTextureCache(); + ~QGLBlurTextureCache(); + + QGLBlurTextureInfo *takeBlurTextureInfo(const QPixmap &pixmap); + bool fitsInCache(const QPixmap &pixmap) const; + bool hasBlurTextureInfo(const QPixmap &pixmap) const; + void insertBlurTextureInfo(const QPixmap &pixmap, QGLBlurTextureInfo *info); + void clearBlurTextureInfo(const QPixmap &pixmap); + + void timerEvent(QTimerEvent *event); + +private: + static void pixmapDestroyed(QPixmap *pixmap); + + QCache cache; + + static QList blurTextureCaches; + + int timerId; +}; + +QList QGLBlurTextureCache::blurTextureCaches; + +static void QGLBlurTextureCache_free(void *ptr) +{ + delete reinterpret_cast(ptr); +} + +Q_GLOBAL_STATIC_WITH_ARGS(QGLContextResource, qt_blur_texture_caches, (QGLBlurTextureCache_free)) + +QGLBlurTextureCache::QGLBlurTextureCache() + : timerId(0) +{ + cache.setMaxCost(4 * 1024 * 1024); + blurTextureCaches.append(this); +} + +QGLBlurTextureCache::~QGLBlurTextureCache() +{ + blurTextureCaches.removeAt(blurTextureCaches.indexOf(this)); +} + +void QGLBlurTextureCache::timerEvent(QTimerEvent *event) +{ + killTimer(timerId); + timerId = 0; + + cache.clear(); +} + +QGLBlurTextureCache *QGLBlurTextureCache::cacheForContext(const QGLContext *context) +{ + QGLBlurTextureCache *p = reinterpret_cast(qt_blur_texture_caches()->value(context)); + if (!p) { + p = new QGLBlurTextureCache; + qt_blur_texture_caches()->insert(context, p); + } + return p; +} + +QGLBlurTextureInfo *QGLBlurTextureCache::takeBlurTextureInfo(const QPixmap &pixmap) +{ + return cache.take(pixmap.cacheKey()); +} + +void QGLBlurTextureCache::clearBlurTextureInfo(const QPixmap &pixmap) +{ + cache.remove(pixmap.cacheKey()); +} + +bool QGLBlurTextureCache::hasBlurTextureInfo(const QPixmap &pixmap) const +{ + return cache.contains(pixmap.cacheKey()); +} + +void QGLBlurTextureCache::insertBlurTextureInfo(const QPixmap &pixmap, QGLBlurTextureInfo *info) +{ + static bool hookAdded = false; + if (!hookAdded) { + QImagePixmapCleanupHooks::instance()->addPixmapDestructionHook(pixmapDestroyed); + hookAdded = true; + } + + QImagePixmapCleanupHooks::enableCleanupHooks(pixmap); + cache.insert(pixmap.cacheKey(), info, pixmap.width() * pixmap.height()); + + if (timerId) + killTimer(timerId); + + timerId = startTimer(1000); +} + +bool QGLBlurTextureCache::fitsInCache(const QPixmap &pixmap) const +{ + return pixmap.width() * pixmap.height() <= cache.maxCost(); +} + +void QGLBlurTextureCache::pixmapDestroyed(QPixmap *pixmap) +{ + foreach (QGLBlurTextureCache *cache, blurTextureCaches) { + if (cache->hasBlurTextureInfo(*pixmap)) + cache->clearBlurTextureInfo(*pixmap); + } +} + +static const char *qt_gl_interpolate_filter = + "uniform lowp float interpolationValue;" + "uniform lowp sampler2D interpolateTarget;" + "uniform highp vec4 interpolateMapping;" + "lowp vec4 customShader(lowp sampler2D src, highp vec2 srcCoords)" + "{" + " return mix(texture2D(interpolateTarget, interpolateMapping.xy + interpolateMapping.zw * srcCoords)," + " texture2D(src, srcCoords), interpolationValue);" + "}"; + +static void initializeTexture(GLuint id, int width, int height) +{ + glBindTexture(GL_TEXTURE_2D, id); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glBindTexture(GL_TEXTURE_2D, 0); +} + bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const QPixmap &src, const QRectF &) const { QGLPixmapBlurFilter *filter = const_cast(this); + QGLContext *ctx = const_cast(QGLContext::currentContext()); + QGLBlurTextureCache *blurTextureCache = QGLBlurTextureCache::cacheForContext(ctx); + + if (m_hint == QGraphicsBlurEffect::AnimationHint && blurTextureCache->fitsInCache(src)) { + QRect targetRect = src.rect().adjusted(-qMaxCachedBlurLevel, -qMaxCachedBlurLevel, qMaxCachedBlurLevel, qMaxCachedBlurLevel); + // ensure even dimensions (going to divide by two) + targetRect.setWidth((targetRect.width() + 1) & ~1); + targetRect.setHeight((targetRect.height() + 1) & ~1); + + QGLBlurTextureInfo *info = 0; + if (blurTextureCache->hasBlurTextureInfo(src)) { + info = blurTextureCache->takeBlurTextureInfo(src); + } else { + m_animatedBlur = false; + m_hint = QGraphicsBlurEffect::QualityHint; + m_singlePass = false; + + QGLFramebufferObjectFormat format; + format.setInternalTextureFormat(GL_RGBA); + QGLFramebufferObject *fbo = qgl_fbo_pool()->acquire(targetRect.size() / 2, format, true); + + if (!fbo) + return false; + + QPainter fboPainter(fbo); + QGL2PaintEngineEx *engine = static_cast(fboPainter.paintEngine()); + + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); + + // ensure GL_LINEAR filtering is used for scaling down to half the size + fboPainter.setRenderHint(QPainter::SmoothPixmapTransform); + fboPainter.setCompositionMode(QPainter::CompositionMode_Source); + fboPainter.drawPixmap(qMaxCachedBlurLevel / 2, qMaxCachedBlurLevel / 2, + targetRect.width() / 2 - qMaxCachedBlurLevel, targetRect.height() / 2 - qMaxCachedBlurLevel, src); + + GLuint textures[qNumCachedBlurTextures]; // blur textures + glGenTextures(qNumCachedBlurTextures, textures); + GLuint temp; // temp texture + glGenTextures(1, &temp); + + initializeTexture(temp, fbo->width(), fbo->height()); + m_textureSize = fbo->size(); + + int currentBlur = 0; + + QRect fboRect(0, 0, fbo->width(), fbo->height()); + GLuint sourceTexture = fbo->texture(); + for (int i = 0; i < qNumCachedBlurTextures; ++i) { + int targetBlur = qCachedBlurLevels[i] / 2; + + int blurDelta = qRound(qSqrt(targetBlur * targetBlur - currentBlur * currentBlur)); + QByteArray source = generateGaussianShader(blurDelta); + filter->setSource(source); + + currentBlur = targetBlur; + + // now we're going to be nasty and keep using the same FBO with different textures + glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + GL_TEXTURE_2D, temp, 0); + + m_horizontalBlur = true; + filter->setOnPainter(&fboPainter); + engine->drawTexture(fboRect, sourceTexture, fbo->size(), fboRect); + filter->removeFromPainter(&fboPainter); + + sourceTexture = textures[i]; + initializeTexture(sourceTexture, fbo->width(), fbo->height()); + + glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + GL_TEXTURE_2D, textures[i], 0); + + m_horizontalBlur = false; + filter->setOnPainter(&fboPainter); + engine->drawTexture(fboRect, temp, fbo->size(), fboRect); + filter->removeFromPainter(&fboPainter); + } + + glDeleteTextures(1, &temp); + + // reattach the original FBO texture + glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + GL_TEXTURE_2D, fbo->texture(), 0); + + fboPainter.end(); + + qgl_fbo_pool()->release(fbo); + + info = new QGLBlurTextureInfo(fboRect.size(), textures); + } + + if (!m_haveCached || !m_animatedBlur) { + m_haveCached = true; + m_animatedBlur = true; + m_hint = QGraphicsBlurEffect::AnimationHint; + filter->setSource(qt_gl_interpolate_filter); + } + + QGL2PaintEngineEx *engine = static_cast(painter->paintEngine()); + painter->setRenderHint(QPainter::SmoothPixmapTransform); + filter->setOnPainter(painter); + + qreal logRadius = qLn(radius()); + + int t; + for (t = -1; t < qNumCachedBlurTextures - 2; ++t) { + if (logRadius < qLogBlurLevel(t+1)) + break; + } + + qreal logBase = t >= 0 ? qLogBlurLevel(t) : 0; + m_t = qBound(qreal(0), (logRadius - logBase) / (qLogBlurLevel(t+1) - logBase), qreal(1)); + + m_textureSize = info->size(); + + glActiveTexture(GL_TEXTURE0 + 3); + if (t >= 0) { + glBindTexture(GL_TEXTURE_2D, info->textureId(t)); + m_targetSize = info->size(); + } else { + QGLTexture *texture = + ctx->d_func()->bindTexture(src, GL_TEXTURE_2D, GL_RGBA, + QGLContext::InternalBindOption + | QGLContext::CanFlipNativePixmapBindOption); + m_targetSize = src.size(); + if (!(texture->options & QGLContext::InvertedYBindOption)) + m_targetSize.setHeight(-m_targetSize.height()); + } + + // restrict the target rect to the max of the radii we are interpolating between + int radiusDelta = qMaxCachedBlurLevel - qCachedBlurLevels[t+1]; + targetRect = targetRect.translated(pos.toPoint()).adjusted(radiusDelta, radiusDelta, -radiusDelta, -radiusDelta); + + radiusDelta /= 2; + QRect sourceRect = QRect(QPoint(), m_textureSize).adjusted(radiusDelta, radiusDelta, -radiusDelta, -radiusDelta); + + engine->drawTexture(targetRect, info->textureId(t+1), m_textureSize, sourceRect); + + glActiveTexture(GL_TEXTURE0 + 3); + glBindTexture(GL_TEXTURE_2D, 0); + + filter->removeFromPainter(painter); + blurTextureCache->insertBlurTextureInfo(src, info); + + return true; + } + + if (blurTextureCache->hasBlurTextureInfo(src)) + blurTextureCache->clearBlurTextureInfo(src); + int actualRadius = qRound(radius()); int filterRadius = actualRadius; int fastRadii[] = { 1, 2, 3, 5, 8, 15, 25 }; - if (m_hint == QGraphicsBlurEffect::PerformanceHint) { + if (m_hint != QGraphicsBlurEffect::QualityHint) { uint i = 0; for (; i < (sizeof(fastRadii)/sizeof(*fastRadii))-1; ++i) { if (fastRadii[i+1] > filterRadius) @@ -352,9 +686,10 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const m_singlePass = filterRadius <= 3; - if (!m_haveCached || filterRadius != m_cachedRadius) { + if (!m_haveCached || m_animatedBlur || filterRadius != m_cachedRadius) { // Only regenerate the shader from source if parameters have changed. m_haveCached = true; + m_animatedBlur = false; m_cachedRadius = filterRadius; QByteArray source = generateGaussianShader(filterRadius, m_singlePass); filter->setSource(source); @@ -389,13 +724,12 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const QPainter fboPainter(fbo); - if (src.hasAlphaChannel()) { - glClearColor(0, 0, 0, 0); - glClear(GL_COLOR_BUFFER_BIT); - } + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); // ensure GL_LINEAR filtering is used fboPainter.setRenderHint(QPainter::SmoothPixmapTransform); + fboPainter.setCompositionMode(QPainter::CompositionMode_Source); filter->setOnPainter(&fboPainter); QBrush pixmapBrush = src; pixmapBrush.setTransform(QTransform::fromTranslate(actualRadius, actualRadius)); @@ -428,6 +762,28 @@ void QGLPixmapBlurFilter::setUniforms(QGLShaderProgram *program) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + if (m_animatedBlur) { + program->setUniformValue("interpolateTarget", 3); + program->setUniformValue("interpolationValue", GLfloat(m_t)); + + if (m_textureSize == m_targetSize) { + program->setUniformValue("interpolateMapping", 0.0f, 0.0f, 1.0f, 1.0f); + } else { + float offsetX = (-qMaxCachedBlurLevel - 0.5) / qreal(m_targetSize.width()); + float offsetY = (-qMaxCachedBlurLevel - 0.5) / qreal(m_targetSize.height()); + + if (m_targetSize.height() < 0) + offsetY = 1 + offsetY; + + float scaleX = 2.0f * qreal(m_textureSize.width()) / qreal(m_targetSize.width()); + float scaleY = 2.0f * qreal(m_textureSize.height()) / qreal(m_targetSize.height()); + + program->setUniformValue("interpolateMapping", offsetX, offsetY, scaleX, scaleY); + } + + return; + } + if (m_hint == QGraphicsBlurEffect::QualityHint) { if (m_singlePass) program->setUniformValue("delta", 1.0 / m_textureSize.width(), 1.0 / m_textureSize.height()); @@ -632,13 +988,12 @@ bool QGLPixmapDropShadowFilter::processGL(QPainter *painter, const QPointF &pos, QPainter fboPainter(fbo); - if (src.hasAlphaChannel()) { - glClearColor(0, 0, 0, 0); - glClear(GL_COLOR_BUFFER_BIT); - } + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); // ensure GL_LINEAR filtering is used fboPainter.setRenderHint(QPainter::SmoothPixmapTransform); + fboPainter.setCompositionMode(QPainter::CompositionMode_Source); filter->setOnPainter(&fboPainter); QBrush pixmapBrush = src; pixmapBrush.setTransform(QTransform::fromTranslate(actualRadius, actualRadius)); -- cgit v0.12 From cb357aad0f26c36eb1f942ae37647f9de071c948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 30 Oct 2009 19:28:43 +0100 Subject: Made QGraphicsEffectSource::draw() use cached pixmap if possible. Small optimization for the case where the source pixmap is cached. Reviewed-by: Gunnar Sletta --- src/gui/effects/qgraphicseffect.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index e181b18..78a18d3 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -210,7 +210,23 @@ const QStyleOption *QGraphicsEffectSource::styleOption() const */ void QGraphicsEffectSource::draw(QPainter *painter) { - d_func()->draw(painter); + Q_D(const QGraphicsEffectSource); + + QPixmap pm; + if (QPixmapCache::find(d->m_cacheKey, &pm)) { + QTransform restoreTransform; + if (d->m_cachedSystem == Qt::DeviceCoordinates) { + restoreTransform = painter->worldTransform(); + painter->setWorldTransform(QTransform()); + } + + painter->drawPixmap(d->m_cachedOffset, pm); + + if (d->m_cachedSystem == Qt::DeviceCoordinates) + painter->setWorldTransform(restoreTransform); + } else { + d_func()->draw(painter); + } } /*! -- cgit v0.12 From 7f9c446f53ba89fb5add8ff6a62088eaa93d3460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 2 Nov 2009 10:14:34 +0100 Subject: Fixed compiler warning on GCC about empty while statement. --- src/opengl/qgl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 3fec1f0..2a57468 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2158,7 +2158,7 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G #ifndef QT_NO_DEBUG // Reset the gl error stack...git - while (glGetError() != GL_NO_ERROR); + while (glGetError() != GL_NO_ERROR) ; #endif // Scale the pixmap if needed. GL textures needs to have the -- cgit v0.12 From 83b5ae49a1778a815a98dd7094822588e82aef3c Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Mon, 2 Nov 2009 11:51:53 +0100 Subject: QNetworkReply autotests: move performance tests to benchmarks Move the performance tests from tests/auto/qnetworkreply to tests/benchmarks/qnetworkreply, because they belong there and they were crashing from time to time. Reviewed-by: Markus Goetz --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 479 ------------------- .../benchmarks/qnetworkreply/tst_qnetworkreply.cpp | 530 +++++++++++++++++++++ 2 files changed, 530 insertions(+), 479 deletions(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 7adb67f..0b61dcd 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -227,12 +227,6 @@ private Q_SLOTS: void rateControl_data(); void rateControl(); - void downloadPerformance(); - void uploadPerformance(); - void performanceControlRate(); - void httpUploadPerformance(); - void httpDownloadPerformance_data(); - void httpDownloadPerformance(); void downloadProgress_data(); void downloadProgress(); @@ -413,93 +407,6 @@ public slots: } }; -class FixedSizeDataGenerator : public QIODevice -{ - Q_OBJECT - enum { Idle, Started, Stopped } state; -public: - FixedSizeDataGenerator(qint64 size) : state(Idle) - { open(ReadOnly | Unbuffered); - toBeGeneratedTotalCount = toBeGeneratedCount = size; - } - - virtual qint64 bytesAvailable() const - { - return state == Started ? toBeGeneratedCount + QIODevice::bytesAvailable() : 0; - } - - virtual bool isSequential() const{ - return false; - } - - virtual bool reset() const{ - return false; - } - - qint64 size() const { - return toBeGeneratedTotalCount; - } - -public slots: - void start() { state = Started; emit readyRead(); } - -protected: - virtual qint64 readData(char *data, qint64 maxlen) - { - memset(data, '@', maxlen); - - if (toBeGeneratedCount <= 0) { - return -1; - } - - qint64 n = qMin(maxlen, toBeGeneratedCount); - toBeGeneratedCount -= n; - - if (toBeGeneratedCount <= 0) { - // make sure this is a queued connection! - emit readChannelFinished(); - } - - return n; - } - virtual qint64 writeData(const char *, qint64) - { return -1; } - - qint64 toBeGeneratedCount; - qint64 toBeGeneratedTotalCount; -}; - - -class DataGenerator: public QIODevice -{ - Q_OBJECT - enum { Idle, Started, Stopped } state; -public: - DataGenerator() : state(Idle) - { open(ReadOnly); } - - virtual bool isSequential() const { return true; } - virtual qint64 bytesAvailable() const { return state == Started ? 1024*1024 : 0; } - -public slots: - void start() { state = Started; emit readyRead(); } - void stop() { state = Stopped; emit readyRead(); } - -protected: - virtual qint64 readData(char *data, qint64 maxlen) - { - if (state == Stopped) - return -1; // EOF - - // return as many bytes as are wanted - memset(data, '@', maxlen); - return maxlen; - } - virtual qint64 writeData(const char *, qint64) - { return -1; } -}; - - class SocketPair: public QObject { @@ -692,255 +599,6 @@ protected: } }; -class TimedSender: public QThread -{ - Q_OBJECT - qint64 totalBytes; - QSemaphore ready; - QByteArray dataToSend; - QTcpSocket *client; - int timeout; - int port; -public: - int transferRate; - TimedSender(int ms) - : totalBytes(0), timeout(ms), port(-1), transferRate(-1) - { - dataToSend = QByteArray(16*1024, '@'); - start(); - ready.acquire(); - } - - inline int serverPort() const { return port; } - -private slots: - void writeMore() - { - while (client->bytesToWrite() < 128 * 1024) { - writePacket(dataToSend); - } - } - -protected: - void run() - { - QTcpServer server; - server.listen(); - port = server.serverPort(); - ready.release(); - - server.waitForNewConnection(-1); - client = server.nextPendingConnection(); - - writeMore(); - connect(client, SIGNAL(bytesWritten(qint64)), SLOT(writeMore()), Qt::DirectConnection); - - QEventLoop eventLoop; - QTimer::singleShot(timeout, &eventLoop, SLOT(quit())); - - QTime timer; - timer.start(); - eventLoop.exec(); - disconnect(client, SIGNAL(bytesWritten(qint64)), this, 0); - - // wait for the connection to shut down - client->disconnectFromHost(); - if (!client->waitForDisconnected(10000)) - return; - - transferRate = totalBytes * 1000 / timer.elapsed(); - qDebug() << "TimedSender::run" << "receive rate:" << (transferRate / 1024) << "kB/s in" - << timer.elapsed() << "ms"; - } - - void writePacket(const QByteArray &array) - { - client->write(array); - totalBytes += array.size(); - } -}; - -class ThreadedDataReader: public QThread -{ - Q_OBJECT - // used to make the constructor only return after the tcp server started listening - QSemaphore ready; - QTcpSocket *client; - int timeout; - int port; -public: - qint64 transferRate; - ThreadedDataReader() - : port(-1), transferRate(-1) - { - start(); - ready.acquire(); - } - - inline int serverPort() const { return port; } - -protected: - void run() - { - QTcpServer server; - server.listen(); - port = server.serverPort(); - ready.release(); - - server.waitForNewConnection(-1); - client = server.nextPendingConnection(); - - QEventLoop eventLoop; - DataReader reader(client, false); - QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit())); - - QTime timer; - timer.start(); - eventLoop.exec(); - qint64 elapsed = timer.elapsed(); - - transferRate = reader.totalBytes * 1000 / elapsed; - qDebug() << "ThreadedDataReader::run" << "send rate:" << (transferRate / 1024) << "kB/s in" << elapsed << "msec"; - } -}; - -class ThreadedDataReaderHttpServer: public QThread -{ - Q_OBJECT - // used to make the constructor only return after the tcp server started listening - QSemaphore ready; - QTcpSocket *client; - int timeout; - int port; -public: - qint64 transferRate; - ThreadedDataReaderHttpServer() - : port(-1), transferRate(-1) - { - start(); - ready.acquire(); - } - - inline int serverPort() const { return port; } - -protected: - void run() - { - QTcpServer server; - server.listen(); - port = server.serverPort(); - ready.release(); - - server.waitForNewConnection(-1); - client = server.nextPendingConnection(); - client->write("HTTP/1.0 200 OK\r\n"); - client->write("Content-length: 0\r\n"); - client->write("\r\n"); - client->flush(); - - QCoreApplication::processEvents(); - - QEventLoop eventLoop; - DataReader reader(client, false); - QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit())); - - QTime timer; - timer.start(); - eventLoop.exec(); - qint64 elapsed = timer.elapsed(); - - transferRate = reader.totalBytes * 1000 / elapsed; - qDebug() << "ThreadedDataReaderHttpServer::run" << "send rate:" << (transferRate / 1024) << "kB/s in" << elapsed << "msec"; - } -}; - -class HttpDownloadPerformanceClient : QObject { - Q_OBJECT; - QIODevice *device; - public: - HttpDownloadPerformanceClient (QIODevice *dev) : device(dev){ - connect(dev, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); - } - - public slots: - void readyReadSlot() { - device->readAll(); - } - -}; - -class HttpDownloadPerformanceServer : QObject { - Q_OBJECT; - qint64 dataSize; - qint64 dataSent; - QTcpServer server; - QTcpSocket *client; - bool serverSendsContentLength; - bool chunkedEncoding; - -public: - HttpDownloadPerformanceServer (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0), - client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) { - server.listen(); - connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot())); - } - - int serverPort() { - return server.serverPort(); - } - -public slots: - - void newConnectionSlot() { - client = server.nextPendingConnection(); - client->setParent(this); - connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); - connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64))); - } - - void readyReadSlot() { - client->readAll(); - client->write("HTTP/1.0 200 OK\n"); - if (serverSendsContentLength) - client->write(QString("Content-Length: " + QString::number(dataSize) + "\n").toAscii()); - if (chunkedEncoding) - client->write(QString("Transfer-Encoding: chunked\n").toAscii()); - client->write("Connection: close\n\n"); - } - - void bytesWrittenSlot(qint64 amount) { - Q_UNUSED(amount); - if (dataSent == dataSize && client) { - // close eventually - - // chunked encoding: we have to send a last "empty" chunk - if (chunkedEncoding) - client->write(QString("0\r\n\r\n").toAscii()); - - client->disconnectFromHost(); - server.close(); - client = 0; - return; - } - - // send data - if (client && client->bytesToWrite() < 100*1024 && dataSent < dataSize) { - qint64 amount = qMin(qint64(16*1024), dataSize - dataSent); - QByteArray data(amount, '@'); - - if (chunkedEncoding) { - client->write(QString(QString("%1").arg(amount,0,16).toUpper() + "\r\n").toAscii()); - client->write(data.constData(), amount); - client->write(QString("\r\n").toAscii()); - } else { - client->write(data.constData(), amount); - } - - dataSent += amount; - } - } -}; - tst_QNetworkReply::tst_QNetworkReply() { @@ -3311,7 +2969,6 @@ void tst_QNetworkReply::ioPostToHttpEmtpyUploadProgress() server.close(); } - void tst_QNetworkReply::rateControl_data() { QTest::addColumn("rate"); @@ -3365,142 +3022,6 @@ void tst_QNetworkReply::rateControl() QVERIFY(sender.transferRate <= maxRate); } -void tst_QNetworkReply::downloadPerformance() -{ - // unlike the above function, this one tries to send as fast as possible - // and measures how fast it was. - TimedSender sender(5000); - QNetworkRequest request("debugpipe://127.0.0.1:" + QString::number(sender.serverPort()) + "/?bare=1"); - QNetworkReplyPtr reply = manager.get(request); - DataReader reader(reply, false); - - QTime loopTime; - connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - loopTime.start(); - QTestEventLoop::instance().enterLoop(40); - int elapsedTime = loopTime.elapsed(); - sender.wait(); - - qint64 receivedBytes = reader.totalBytes; - qDebug() << "tst_QNetworkReply::downloadPerformance" << "receive rate:" << (receivedBytes * 1000 / elapsedTime / 1024) << "kB/s and" - << elapsedTime << "ms"; -} - -void tst_QNetworkReply::uploadPerformance() -{ - ThreadedDataReader reader; - DataGenerator generator; - - - QNetworkRequest request("debugpipe://127.0.0.1:" + QString::number(reader.serverPort()) + "/?bare=1"); - QNetworkReplyPtr reply = manager.put(request, &generator); - generator.start(); - connect(&reader, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - QTimer::singleShot(5000, &generator, SLOT(stop())); - - QTestEventLoop::instance().enterLoop(30); - QCOMPARE(reply->error(), QNetworkReply::NoError); - QVERIFY(!QTestEventLoop::instance().timeout()); -} - -void tst_QNetworkReply::httpUploadPerformance() -{ -#ifdef Q_OS_SYMBIAN - // SHow some mercy for non-desktop platform/s - enum {UploadSize = 4*1024*1024}; // 4 MB -#else - enum {UploadSize = 128*1024*1024}; // 128 MB -#endif - ThreadedDataReaderHttpServer reader; - FixedSizeDataGenerator generator(UploadSize); - - QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(reader.serverPort()) + "/?bare=1")); - request.setHeader(QNetworkRequest::ContentLengthHeader,UploadSize); - - QNetworkReplyPtr reply = manager.put(request, &generator); - - connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - - QTime time; - generator.start(); - time.start(); - QTestEventLoop::instance().enterLoop(40); - QCOMPARE(reply->error(), QNetworkReply::NoError); - QVERIFY(!QTestEventLoop::instance().timeout()); - - qint64 elapsed = time.elapsed(); - qDebug() << "tst_QNetworkReply::httpUploadPerformance" << elapsed << "msec, " - << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; - - reader.exit(); - reader.wait(); -} - - -void tst_QNetworkReply::performanceControlRate() -{ - // this is a control comparison for the other two above - // it does the same thing, but instead bypasses the QNetworkAccess system - qDebug() << "The following are the maximum transfer rates that we can get in this system" - " (bypassing QNetworkAccess)"; - - TimedSender sender(5000); - QTcpSocket sink; - sink.connectToHost("127.0.0.1", sender.serverPort()); - DataReader reader(&sink, false); - - QTime loopTime; - connect(&sink, SIGNAL(disconnected()), &QTestEventLoop::instance(), SLOT(exitLoop())); - loopTime.start(); - QTestEventLoop::instance().enterLoop(40); - int elapsedTime = loopTime.elapsed(); - sender.wait(); - - qint64 receivedBytes = reader.totalBytes; - qDebug() << "tst_QNetworkReply::performanceControlRate" << "receive rate:" << (receivedBytes * 1000 / elapsedTime / 1024) << "kB/s and" - << elapsedTime << "ms"; -} - -void tst_QNetworkReply::httpDownloadPerformance_data() -{ - QTest::addColumn("serverSendsContentLength"); - QTest::addColumn("chunkedEncoding"); - - QTest::newRow("Server sends no Content-Length") << false << false; - QTest::newRow("Server sends Content-Length") << true << false; - QTest::newRow("Server uses chunked encoding") << false << true; - -} - -void tst_QNetworkReply::httpDownloadPerformance() -{ - QFETCH(bool, serverSendsContentLength); - QFETCH(bool, chunkedEncoding); -#ifdef Q_OS_SYMBIAN - // Show some mercy to non-desktop platform/s - enum {UploadSize = 4*1024*1024}; // 4 MB -#else - enum {UploadSize = 128*1024*1024}; // 128 MB -#endif - HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding); - - QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1")); - QNetworkReplyPtr reply = manager.get(request); - - connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); - HttpDownloadPerformanceClient client(reply); - - QTime time; - time.start(); - QTestEventLoop::instance().enterLoop(40); - QCOMPARE(reply->error(), QNetworkReply::NoError); - QVERIFY(!QTestEventLoop::instance().timeout()); - - qint64 elapsed = time.elapsed(); - qDebug() << "tst_QNetworkReply::httpDownloadPerformance" << elapsed << "msec, " - << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; -} - void tst_QNetworkReply::downloadProgress_data() { QTest::addColumn("loopCount"); diff --git a/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp index 993db52..1d50013 100644 --- a/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp @@ -46,11 +46,397 @@ #include #include #include +#include +#include #include "../../auto/network-settings.h" + +class TimedSender: public QThread +{ + Q_OBJECT + qint64 totalBytes; + QSemaphore ready; + QByteArray dataToSend; + QTcpSocket *client; + int timeout; + int port; +public: + int transferRate; + TimedSender(int ms) + : totalBytes(0), timeout(ms), port(-1), transferRate(-1) + { + dataToSend = QByteArray(16*1024, '@'); + start(); + ready.acquire(); + } + + inline int serverPort() const { return port; } + +private slots: + void writeMore() + { + while (client->bytesToWrite() < 128 * 1024) { + writePacket(dataToSend); + } + } + +protected: + void run() + { + QTcpServer server; + server.listen(); + port = server.serverPort(); + ready.release(); + + server.waitForNewConnection(-1); + client = server.nextPendingConnection(); + + writeMore(); + connect(client, SIGNAL(bytesWritten(qint64)), SLOT(writeMore()), Qt::DirectConnection); + + QEventLoop eventLoop; + QTimer::singleShot(timeout, &eventLoop, SLOT(quit())); + + QTime timer; + timer.start(); + eventLoop.exec(); + disconnect(client, SIGNAL(bytesWritten(qint64)), this, 0); + + // wait for the connection to shut down + client->disconnectFromHost(); + if (!client->waitForDisconnected(10000)) + return; + + transferRate = totalBytes * 1000 / timer.elapsed(); + qDebug() << "TimedSender::run" << "receive rate:" << (transferRate / 1024) << "kB/s in" + << timer.elapsed() << "ms"; + } + + void writePacket(const QByteArray &array) + { + client->write(array); + totalBytes += array.size(); + } +}; + + +class QNetworkReplyPtr: public QSharedPointer +{ +public: + inline QNetworkReplyPtr(QNetworkReply *ptr = 0) + : QSharedPointer(ptr) + { } + + inline operator QNetworkReply *() const { return data(); } +}; + + +class DataReader: public QObject +{ + Q_OBJECT +public: + qint64 totalBytes; + QByteArray data; + QIODevice *device; + bool accumulate; + DataReader(QIODevice *dev, bool acc = true) : totalBytes(0), device(dev), accumulate(acc) + { + connect(device, SIGNAL(readyRead()), SLOT(doRead())); + } + +public slots: + void doRead() + { + QByteArray buffer; + buffer.resize(device->bytesAvailable()); + qint64 bytesRead = device->read(buffer.data(), device->bytesAvailable()); + if (bytesRead == -1) { + QTestEventLoop::instance().exitLoop(); + return; + } + buffer.truncate(bytesRead); + totalBytes += bytesRead; + + if (accumulate) + data += buffer; + } +}; + +class ThreadedDataReader: public QThread +{ + Q_OBJECT + // used to make the constructor only return after the tcp server started listening + QSemaphore ready; + QTcpSocket *client; + int timeout; + int port; +public: + qint64 transferRate; + ThreadedDataReader() + : port(-1), transferRate(-1) + { + start(); + ready.acquire(); + } + + inline int serverPort() const { return port; } + +protected: + void run() + { + QTcpServer server; + server.listen(); + port = server.serverPort(); + ready.release(); + + server.waitForNewConnection(-1); + client = server.nextPendingConnection(); + + QEventLoop eventLoop; + DataReader reader(client, false); + QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit())); + + QTime timer; + timer.start(); + eventLoop.exec(); + qint64 elapsed = timer.elapsed(); + + transferRate = reader.totalBytes * 1000 / elapsed; + qDebug() << "ThreadedDataReader::run" << "send rate:" << (transferRate / 1024) << "kB/s in" << elapsed << "msec"; + } +}; + +class DataGenerator: public QIODevice +{ + Q_OBJECT + enum { Idle, Started, Stopped } state; +public: + DataGenerator() : state(Idle) + { open(ReadOnly); } + + virtual bool isSequential() const { return true; } + virtual qint64 bytesAvailable() const { return state == Started ? 1024*1024 : 0; } + +public slots: + void start() { state = Started; emit readyRead(); } + void stop() { state = Stopped; emit readyRead(); } + +protected: + virtual qint64 readData(char *data, qint64 maxlen) + { + if (state == Stopped) + return -1; // EOF + + // return as many bytes as are wanted + memset(data, '@', maxlen); + return maxlen; + } + virtual qint64 writeData(const char *, qint64) + { return -1; } +}; + +class ThreadedDataReaderHttpServer: public QThread +{ + Q_OBJECT + // used to make the constructor only return after the tcp server started listening + QSemaphore ready; + QTcpSocket *client; + int timeout; + int port; +public: + qint64 transferRate; + ThreadedDataReaderHttpServer() + : port(-1), transferRate(-1) + { + start(); + ready.acquire(); + } + + inline int serverPort() const { return port; } + +protected: + void run() + { + QTcpServer server; + server.listen(); + port = server.serverPort(); + ready.release(); + + server.waitForNewConnection(-1); + client = server.nextPendingConnection(); + client->write("HTTP/1.0 200 OK\r\n"); + client->write("Content-length: 0\r\n"); + client->write("\r\n"); + client->flush(); + + QCoreApplication::processEvents(); + + QEventLoop eventLoop; + DataReader reader(client, false); + QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit())); + + QTime timer; + timer.start(); + eventLoop.exec(); + qint64 elapsed = timer.elapsed(); + + transferRate = reader.totalBytes * 1000 / elapsed; + qDebug() << "ThreadedDataReaderHttpServer::run" << "send rate:" << (transferRate / 1024) << "kB/s in" << elapsed << "msec"; + } +}; + + +class FixedSizeDataGenerator : public QIODevice +{ + Q_OBJECT + enum { Idle, Started, Stopped } state; +public: + FixedSizeDataGenerator(qint64 size) : state(Idle) + { open(ReadOnly | Unbuffered); + toBeGeneratedTotalCount = toBeGeneratedCount = size; + } + + virtual qint64 bytesAvailable() const + { + return state == Started ? toBeGeneratedCount + QIODevice::bytesAvailable() : 0; + } + + virtual bool isSequential() const{ + return false; + } + + virtual bool reset() const{ + return false; + } + + qint64 size() const { + return toBeGeneratedTotalCount; + } + +public slots: + void start() { state = Started; emit readyRead(); } + +protected: + virtual qint64 readData(char *data, qint64 maxlen) + { + memset(data, '@', maxlen); + + if (toBeGeneratedCount <= 0) { + return -1; + } + + qint64 n = qMin(maxlen, toBeGeneratedCount); + toBeGeneratedCount -= n; + + if (toBeGeneratedCount <= 0) { + // make sure this is a queued connection! + emit readChannelFinished(); + } + + return n; + } + virtual qint64 writeData(const char *, qint64) + { return -1; } + + qint64 toBeGeneratedCount; + qint64 toBeGeneratedTotalCount; +}; + +class HttpDownloadPerformanceServer : QObject { + Q_OBJECT; + qint64 dataSize; + qint64 dataSent; + QTcpServer server; + QTcpSocket *client; + bool serverSendsContentLength; + bool chunkedEncoding; + +public: + HttpDownloadPerformanceServer (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0), + client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) { + server.listen(); + connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot())); + } + + int serverPort() { + return server.serverPort(); + } + +public slots: + + void newConnectionSlot() { + client = server.nextPendingConnection(); + client->setParent(this); + connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); + connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64))); + } + + void readyReadSlot() { + client->readAll(); + client->write("HTTP/1.0 200 OK\n"); + if (serverSendsContentLength) + client->write(QString("Content-Length: " + QString::number(dataSize) + "\n").toAscii()); + if (chunkedEncoding) + client->write(QString("Transfer-Encoding: chunked\n").toAscii()); + client->write("Connection: close\n\n"); + } + + void bytesWrittenSlot(qint64 amount) { + Q_UNUSED(amount); + if (dataSent == dataSize && client) { + // close eventually + + // chunked encoding: we have to send a last "empty" chunk + if (chunkedEncoding) + client->write(QString("0\r\n\r\n").toAscii()); + + client->disconnectFromHost(); + server.close(); + client = 0; + return; + } + + // send data + if (client && client->bytesToWrite() < 100*1024 && dataSent < dataSize) { + qint64 amount = qMin(qint64(16*1024), dataSize - dataSent); + QByteArray data(amount, '@'); + + if (chunkedEncoding) { + client->write(QString(QString("%1").arg(amount,0,16).toUpper() + "\r\n").toAscii()); + client->write(data.constData(), amount); + client->write(QString("\r\n").toAscii()); + } else { + client->write(data.constData(), amount); + } + + dataSent += amount; + } + } +}; + +class HttpDownloadPerformanceClient : QObject { + Q_OBJECT; + QIODevice *device; + public: + HttpDownloadPerformanceClient (QIODevice *dev) : device(dev){ + connect(dev, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); + } + + public slots: + void readyReadSlot() { + device->readAll(); + } + +}; + + + + class tst_qnetworkreply : public QObject { Q_OBJECT + + QNetworkAccessManager manager; private slots: void httpLatency(); @@ -58,6 +444,14 @@ private slots: void echoPerformance_data(); void echoPerformance(); #endif + + void downloadPerformance(); + void uploadPerformance(); + void performanceControlRate(); + void httpUploadPerformance(); + void httpDownloadPerformance_data(); + void httpDownloadPerformance(); + }; void tst_qnetworkreply::httpLatency() @@ -107,6 +501,142 @@ void tst_qnetworkreply::echoPerformance() } #endif +void tst_qnetworkreply::downloadPerformance() +{ + // unlike the above function, this one tries to send as fast as possible + // and measures how fast it was. + TimedSender sender(5000); + QNetworkRequest request("debugpipe://127.0.0.1:" + QString::number(sender.serverPort()) + "/?bare=1"); + QNetworkReplyPtr reply = manager.get(request); + DataReader reader(reply, false); + + QTime loopTime; + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + loopTime.start(); + QTestEventLoop::instance().enterLoop(40); + int elapsedTime = loopTime.elapsed(); + sender.wait(); + + qint64 receivedBytes = reader.totalBytes; + qDebug() << "tst_QNetworkReply::downloadPerformance" << "receive rate:" << (receivedBytes * 1000 / elapsedTime / 1024) << "kB/s and" + << elapsedTime << "ms"; +} + +void tst_qnetworkreply::uploadPerformance() +{ + ThreadedDataReader reader; + DataGenerator generator; + + + QNetworkRequest request("debugpipe://127.0.0.1:" + QString::number(reader.serverPort()) + "/?bare=1"); + QNetworkReplyPtr reply = manager.put(request, &generator); + generator.start(); + connect(&reader, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTimer::singleShot(5000, &generator, SLOT(stop())); + + QTestEventLoop::instance().enterLoop(30); + QCOMPARE(reply->error(), QNetworkReply::NoError); + QVERIFY(!QTestEventLoop::instance().timeout()); +} + +void tst_qnetworkreply::httpUploadPerformance() +{ +#ifdef Q_OS_SYMBIAN + // SHow some mercy for non-desktop platform/s + enum {UploadSize = 4*1024*1024}; // 4 MB +#else + enum {UploadSize = 128*1024*1024}; // 128 MB +#endif + ThreadedDataReaderHttpServer reader; + FixedSizeDataGenerator generator(UploadSize); + + QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(reader.serverPort()) + "/?bare=1")); + request.setHeader(QNetworkRequest::ContentLengthHeader,UploadSize); + + QNetworkReplyPtr reply = manager.put(request, &generator); + + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + + QTime time; + generator.start(); + time.start(); + QTestEventLoop::instance().enterLoop(40); + QCOMPARE(reply->error(), QNetworkReply::NoError); + QVERIFY(!QTestEventLoop::instance().timeout()); + + qint64 elapsed = time.elapsed(); + qDebug() << "tst_QNetworkReply::httpUploadPerformance" << elapsed << "msec, " + << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; + + reader.exit(); + reader.wait(); +} + + +void tst_qnetworkreply::performanceControlRate() +{ + // this is a control comparison for the other two above + // it does the same thing, but instead bypasses the QNetworkAccess system + qDebug() << "The following are the maximum transfer rates that we can get in this system" + " (bypassing QNetworkAccess)"; + + TimedSender sender(5000); + QTcpSocket sink; + sink.connectToHost("127.0.0.1", sender.serverPort()); + DataReader reader(&sink, false); + + QTime loopTime; + connect(&sink, SIGNAL(disconnected()), &QTestEventLoop::instance(), SLOT(exitLoop())); + loopTime.start(); + QTestEventLoop::instance().enterLoop(40); + int elapsedTime = loopTime.elapsed(); + sender.wait(); + + qint64 receivedBytes = reader.totalBytes; + qDebug() << "tst_QNetworkReply::performanceControlRate" << "receive rate:" << (receivedBytes * 1000 / elapsedTime / 1024) << "kB/s and" + << elapsedTime << "ms"; +} + +void tst_qnetworkreply::httpDownloadPerformance_data() +{ + QTest::addColumn("serverSendsContentLength"); + QTest::addColumn("chunkedEncoding"); + + QTest::newRow("Server sends no Content-Length") << false << false; + QTest::newRow("Server sends Content-Length") << true << false; + QTest::newRow("Server uses chunked encoding") << false << true; + +} + +void tst_qnetworkreply::httpDownloadPerformance() +{ + QFETCH(bool, serverSendsContentLength); + QFETCH(bool, chunkedEncoding); +#ifdef Q_OS_SYMBIAN + // Show some mercy to non-desktop platform/s + enum {UploadSize = 4*1024*1024}; // 4 MB +#else + enum {UploadSize = 128*1024*1024}; // 128 MB +#endif + HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding); + + QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1")); + QNetworkReplyPtr reply = manager.get(request); + + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); + HttpDownloadPerformanceClient client(reply); + + QTime time; + time.start(); + QTestEventLoop::instance().enterLoop(40); + QCOMPARE(reply->error(), QNetworkReply::NoError); + QVERIFY(!QTestEventLoop::instance().timeout()); + + qint64 elapsed = time.elapsed(); + qDebug() << "tst_QNetworkReply::httpDownloadPerformance" << elapsed << "msec, " + << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; +} + QTEST_MAIN(tst_qnetworkreply) #include "tst_qnetworkreply.moc" -- cgit v0.12 From d4ea57ff9022305437fb371802b41120074d3467 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 2 Nov 2009 13:56:40 +0100 Subject: Safeguard isNull() pixmaps in bindTexture and remove a compile warning Reviewed-by: TrustMe --- .../gl2paintengineex/qglengineshadermanager_p.h | 2 +- src/opengl/qgl.cpp | 39 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index 59e50d0..50c1432 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -254,7 +254,7 @@ static const GLuint QT_VERTEX_COORDS_ATTR = 0; static const GLuint QT_TEXTURE_COORDS_ATTR = 1; static const GLuint QT_OPACITY_ATTR = 2; -struct QGLEngineShaderProg; +class QGLEngineShaderProg; class QGLEngineSharedShaders : public QObject { diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 3fec1f0..621d926 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2445,6 +2445,9 @@ int QGLContextPrivate::maxTextureSize() */ GLuint QGLContext::bindTexture(const QImage &image, GLenum target, GLint format) { + if (image.isNull()) + return 0; + Q_D(QGLContext); QGLTexture *texture = d->bindTexture(image, target, format, false, DefaultBindOption); return texture->id; @@ -2477,6 +2480,9 @@ GLuint QGLContext::bindTexture(const QImage &image, GLenum target, GLint format) */ GLuint QGLContext::bindTexture(const QImage &image, GLenum target, GLint format, BindOptions options) { + if (image.isNull()) + return 0; + Q_D(QGLContext); QGLTexture *texture = d->bindTexture(image, target, format, false, options); return texture->id; @@ -2486,6 +2492,9 @@ GLuint QGLContext::bindTexture(const QImage &image, GLenum target, GLint format, /*! \internal */ GLuint QGLContext::bindTexture(const QImage &image, QMacCompatGLenum target, QMacCompatGLint format) { + if (image.isNull()) + return 0; + Q_D(QGLContext); QGLTexture *texture = d->bindTexture(image, GLenum(target), GLint(format), false, DefaultBindOption); return texture->id; @@ -2495,6 +2504,9 @@ GLuint QGLContext::bindTexture(const QImage &image, QMacCompatGLenum target, QMa GLuint QGLContext::bindTexture(const QImage &image, QMacCompatGLenum target, QMacCompatGLint format, BindOptions options) { + if (image.isNull()) + return 0; + Q_D(QGLContext); QGLTexture *texture = d->bindTexture(image, GLenum(target), GLint(format), false, options); return texture->id; @@ -2507,6 +2519,9 @@ GLuint QGLContext::bindTexture(const QImage &image, QMacCompatGLenum target, QMa */ GLuint QGLContext::bindTexture(const QPixmap &pixmap, GLenum target, GLint format) { + if (pixmap.isNull()) + return 0; + Q_D(QGLContext); QGLTexture *texture = d->bindTexture(pixmap, target, format, DefaultBindOption); return texture->id; @@ -2521,6 +2536,9 @@ GLuint QGLContext::bindTexture(const QPixmap &pixmap, GLenum target, GLint forma */ GLuint QGLContext::bindTexture(const QPixmap &pixmap, GLenum target, GLint format, BindOptions options) { + if (pixmap.isNull()) + return 0; + Q_D(QGLContext); QGLTexture *texture = d->bindTexture(pixmap, target, format, options); return texture->id; @@ -2530,6 +2548,9 @@ GLuint QGLContext::bindTexture(const QPixmap &pixmap, GLenum target, GLint forma /*! \internal */ GLuint QGLContext::bindTexture(const QPixmap &pixmap, QMacCompatGLenum target, QMacCompatGLint format) { + if (pixmap.isNull()) + return 0; + Q_D(QGLContext); QGLTexture *texture = d->bindTexture(pixmap, GLenum(target), GLint(format), DefaultBindOption); return texture->id; @@ -2538,6 +2559,9 @@ GLuint QGLContext::bindTexture(const QPixmap &pixmap, QMacCompatGLenum target, Q GLuint QGLContext::bindTexture(const QPixmap &pixmap, QMacCompatGLenum target, QMacCompatGLint format, BindOptions options) { + if (pixmap.isNull()) + return 0; + Q_D(QGLContext); QGLTexture *texture = d->bindTexture(pixmap, GLenum(target), GLint(format), options); return texture->id; @@ -4595,6 +4619,9 @@ bool QGLWidget::autoBufferSwap() const */ GLuint QGLWidget::bindTexture(const QImage &image, GLenum target, GLint format) { + if (image.isNull()) + return 0; + Q_D(QGLWidget); return d->glcx->bindTexture(image, target, format, QGLContext::DefaultBindOption); } @@ -4608,6 +4635,9 @@ GLuint QGLWidget::bindTexture(const QImage &image, GLenum target, GLint format) */ GLuint QGLWidget::bindTexture(const QImage &image, GLenum target, GLint format, QGLContext::BindOptions options) { + if (image.isNull()) + return 0; + Q_D(QGLWidget); return d->glcx->bindTexture(image, target, format, options); } @@ -4617,6 +4647,9 @@ GLuint QGLWidget::bindTexture(const QImage &image, GLenum target, GLint format, /*! \internal */ GLuint QGLWidget::bindTexture(const QImage &image, QMacCompatGLenum target, QMacCompatGLint format) { + if (image.isNull()) + return 0; + Q_D(QGLWidget); return d->glcx->bindTexture(image, GLenum(target), GLint(format), QGLContext::DefaultBindOption); } @@ -4624,6 +4657,9 @@ GLuint QGLWidget::bindTexture(const QImage &image, QMacCompatGLenum target, QMac GLuint QGLWidget::bindTexture(const QImage &image, QMacCompatGLenum target, QMacCompatGLint format, QGLContext::BindOptions options) { + if (image.isNull()) + return 0; + Q_D(QGLWidget); return d->glcx->bindTexture(image, GLenum(target), GLint(format), options); } @@ -4637,6 +4673,9 @@ GLuint QGLWidget::bindTexture(const QImage &image, QMacCompatGLenum target, QMac */ GLuint QGLWidget::bindTexture(const QPixmap &pixmap, GLenum target, GLint format) { + if (pixmap.isNull()) + return 0; + Q_D(QGLWidget); return d->glcx->bindTexture(pixmap, target, format, QGLContext::DefaultBindOption); } -- cgit v0.12 From bdcde683bc863d0c574b1e4d64b5a16ba0130596 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 2 Nov 2009 14:04:21 +0100 Subject: Make animation timer slightly more accurate with default interval of 15 On windows this will make it much more accurate Reviewed-by: ogoffart --- src/corelib/animation/qabstractanimation.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index a4c7e29..7fa3ae3 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -156,7 +156,8 @@ #ifndef QT_NO_ANIMATION -#define DEFAULT_TIMER_INTERVAL 16 +//with 15 ms we get more accuracy on windows (it uses the multimedia timer) +#define DEFAULT_TIMER_INTERVAL 15 #define STARTSTOP_TIMER_DELAY 0 QT_BEGIN_NAMESPACE -- cgit v0.12 From 99bbe6fa6c2322449bb8ab7dda09c53b18cde68d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 2 Nov 2009 14:13:05 +0100 Subject: Minor doc fixes for QGLContext::BindOption. Reviewed-by: Gunnar Sletta --- src/opengl/qgl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 2a57468..6370afd 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1773,10 +1773,12 @@ Q_OPENGL_EXPORT QGLShareRegister* qgl_share_reg() /*! \enum QGLContext::BindOption + \since 4.6 + A set of options to decide how to bind a texture using bindTexture(). \value NoBindOption Don't do anything, pass the texture straight - thru. + through. \value InvertedYBindOption Specifies that the texture should be flipped over the X axis so that the texture coordinate 0,0 corresponds to -- cgit v0.12 From 5b21746da4899a7d6dd78cf949e0a918c127fd49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Luthi?= Date: Wed, 26 Aug 2009 13:13:36 +0200 Subject: Fix a freeze in QFileDialog (Mac) Running an open file dialog, for example with QFileDialog::getOpenFileName() can lead to a freeze if the user selects a folder, then selects a file in the parent folder and finally confirms the open dialog. Merge-request: 1327 Reviewed-by: Richard Moe Gustavsen --- src/gui/dialogs/qfiledialog_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm index 3914ab1..8bca025 100644 --- a/src/gui/dialogs/qfiledialog_mac.mm +++ b/src/gui/dialogs/qfiledialog_mac.mm @@ -819,8 +819,8 @@ void QFileDialogPrivate::qt_mac_filedialog_event_proc(const NavEventCallbackMess || mode == QFileDialog::ExistingFiles){ // When changing directory, the current selection is cleared if // we are supposed to be selecting files only: - fileDialogPrivate->mCurrentSelectionList.clear(); if (!fileDialogPrivate->mCurrentSelection.isEmpty()){ + fileDialogPrivate->mCurrentSelectionList.clear(); fileDialogPrivate->mCurrentSelection.clear(); emit fileDialogPrivate->q_func()->currentChanged(fileDialogPrivate->mCurrentSelection); } -- cgit v0.12 From e6da35f6055d3ae7acf38d89456d3047f055a9cd Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 2 Nov 2009 14:07:15 +0100 Subject: QStyleSheetStyle: ItemViews: Fixes drawing of items and branches. I am not sure why the code was there, but after some testing, it is better to remove it: - While painting the branch, we should not look at the ::item pseudo class at all. - Items specific stuff is drawn in PE_PanelItemViewItem, not PE_PanelItemViewRow - Selection is handled his way by the native style. background-color is not for selection and should not depends on SH_ItemView_ShowDecorationSelected Reviewed-by: Thierry Task-number: QTBUG-5228 Task-number: 258382 Task-number: QTBUG-4338 --- src/gui/styles/qstylesheetstyle.cpp | 30 +--- .../uiloader/baseline/css_itemview_task258382.ui | 179 +++++++++++++++++++++ 2 files changed, 180 insertions(+), 29 deletions(-) create mode 100644 tests/auto/uiloader/baseline/css_itemview_task258382.ui diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 32f259b..a224218 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -4277,23 +4277,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op p->fillRect(v2->rect, v2->palette.alternateBase()); subRule.drawRule(p, opt->rect); } else { - QStyleOptionViewItemV2 v2Copy(*v2); - if (v2->showDecorationSelected) { - QRenderRule subRule2 = renderRule(w, opt, PseudoElement_ViewItem); - if (v2->state & QStyle::State_Selected) { - subRule2.configurePalette(&v2Copy.palette, QPalette::NoRole, QPalette::Highlight); - } else if (v2->features & QStyleOptionViewItemV2::Alternate) { - subRule2.configurePalette(&v2Copy.palette, QPalette::NoRole, QPalette::AlternateBase); - } else if (subRule2.hasBackground()) { - p->fillRect(v2->rect, subRule2.background()->brush); - } - } else if (v2->features & QStyleOptionViewItemV2::Alternate) { - quint64 pc = v2->state & QStyle::State_Enabled ? PseudoClass_Enabled : PseudoClass_Disabled; - pc |= PseudoClass_Alternate; - QRenderRule subRule2 = renderRule(w, PseudoElement_ViewItem, pc); - subRule2.configurePalette(&v2Copy.palette, QPalette::NoRole, QPalette::AlternateBase); - } - baseStyle()->drawPrimitive(pe, &v2Copy, p, w); + baseStyle()->drawPrimitive(pe, v2, p, w); } } return; @@ -4358,18 +4342,6 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op break; case PE_PanelItemViewItem: - if (!styleHint(SH_ItemView_ShowDecorationSelected, opt, w)) { - rect = subElementRect(QStyle::SE_ItemViewItemText, opt, w) - | subElementRect(QStyle::SE_ItemViewItemDecoration, opt, w) - | subElementRect(QStyle::SE_ItemViewItemCheckIndicator, opt, w); - } - pseudoElement = PseudoElement_ViewItem; - break; - - case PE_PanelItemViewRow: - ParentStyle::drawPrimitive(pe, opt, p, w); - if (!styleHint(SH_ItemView_ShowDecorationSelected, opt, w)) - return; pseudoElement = PseudoElement_ViewItem; break; diff --git a/tests/auto/uiloader/baseline/css_itemview_task258382.ui b/tests/auto/uiloader/baseline/css_itemview_task258382.ui new file mode 100644 index 0000000..11c56b4 --- /dev/null +++ b/tests/auto/uiloader/baseline/css_itemview_task258382.ui @@ -0,0 +1,179 @@ + + + Form + + + + 0 + 0 + 437 + 352 + + + + Form + + + ::item { border: 1px solid black; background-color: purple; } +::item {margin-left: 20px; } + +QAbstractItemView { selection-background-color: red; +show-decoration- selected: 0; + } + +::item:selected { background-color: yellow; } + + + + + + + 1 + + + + + New Column + + + + + New Item + + + + + New Item + + + + + New Item + + + + New Subitem + + + + New Subitem + + + + + New Item + + + + + New Item + + + + + + + + + + + New Row + + + + + New Row + + + + + New Row + + + + + New Row + + + + + New Row + + + + + New Column + + + + + New Column + + + + + New Column + + + + + New Column + + + + + mljkh mh mjl + + + + + h jlh mjklh + + + + + mjklh mlhj mjlh m + + + + + mlhj lmhj + + + + + mlkj l + + + + + mlkj + + + + + mlkj lmkj + + + + + mlkhj mlh + + + + + mlkj lmkj + + + + + mlkj lmkj + + + + + + + + + -- cgit v0.12 From 56da3aca1fc8a7c269acf3cf1d4c3586ea8cdfd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Mon, 2 Nov 2009 15:37:17 +0200 Subject: QS60Style - TabWidget text changes color when widget becomes dimmed Style sets the tabWidget palette hash only for QPalette::Active. So, when widget becomes disabled, text color changes back to default. Task-number: QTBUG-4625 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 48f7042..949dfcb 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -743,7 +743,7 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const const QColor mainAreaTextColor = s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0); - widgetPalette.setColor(QPalette::All, QPalette::WindowText, + widgetPalette.setColor(QPalette::WindowText, s60Color(QS60StyleEnums::CL_QsnLineColors, 8, 0)); QApplication::setPalette(widgetPalette, "QSlider"); // return to original palette after each widget @@ -767,34 +767,34 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const QApplication::setPalette(widgetPalette, "QHeaderView"); widgetPalette = *palette; - widgetPalette.setColor(QPalette::All, QPalette::ButtonText, + widgetPalette.setColor(QPalette::ButtonText, s60Color(QS60StyleEnums::CL_QsnTextColors, 8, 0)); QApplication::setPalette(widgetPalette, "QMenuBar"); widgetPalette = *palette; - widgetPalette.setColor(QPalette::Active, QPalette::WindowText, + widgetPalette.setColor(QPalette::WindowText, s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0)); QApplication::setPalette(widgetPalette, "QTabBar"); widgetPalette = *palette; - widgetPalette.setColor(QPalette::All, QPalette::Text, + widgetPalette.setColor(QPalette::Text, s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0)); QApplication::setPalette(widgetPalette, "QTableView"); widgetPalette = *palette; - widgetPalette.setColor(QPalette::All, QPalette::HighlightedText, + widgetPalette.setColor(QPalette::HighlightedText, s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); QApplication::setPalette(widgetPalette, "QLineEdit"); widgetPalette = *palette; - widgetPalette.setColor(QPalette::All, QPalette::Text, + widgetPalette.setColor(QPalette::Text, s60Color(QS60StyleEnums::CL_QsnTextColors, 34, 0)); - widgetPalette.setColor(QPalette::All, QPalette::HighlightedText, + widgetPalette.setColor(QPalette::HighlightedText, s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); QApplication::setPalette(widgetPalette, "QTextEdit"); widgetPalette = *palette; - widgetPalette.setColor(QPalette::All, QPalette::HighlightedText, + widgetPalette.setColor(QPalette::HighlightedText, s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); QApplication::setPalette(widgetPalette, "QComboBox"); widgetPalette = *palette; -- cgit v0.12 From 298e0d28106fd7ef3fe7232c71dd05a57b5d1d90 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 2 Nov 2009 15:35:56 +0200 Subject: Re-added checking for existence of sqlite3 binaries to Symbian builds Always adding export for sqlite3 binaries will cause cleanup of platform provided versions on platforms that provide them. Fixed by adding check for existence of sqlite3.dso before adding the export statement to bld.inf. Task-number: QT-2419 Reviewed-by: Janne Koskinen --- src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro index 4734144..158633d 100644 --- a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro +++ b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro @@ -1,5 +1,7 @@ # Use subdirs template to suppress generation of unnecessary files TEMPLATE = subdirs -# We just want to extract the zip file containing sqlite binaries for Symbian -BLD_INF_RULES.prj_exports += ":zip SQLite3_v9.2.zip" +# We just want to export the sqlite3 binaries for Symbian for platforms that do not have them. +!exists($${EPOCROOT}epoc32/release/armv5/lib/sqlite3.dso) { + BLD_INF_RULES.prj_exports += ":zip SQLite3_v9.2.zip" +} -- cgit v0.12 From 5f7d92b32e375aa7c2d0acf69d1fc033c6fd476a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 2 Nov 2009 14:54:23 +0100 Subject: Disable the move-by-scrolling optimization. The current implementation fails when moving the widget onto an area that has just been exposed as a part of a window resize operation. --- src/gui/kernel/qwidget_mac.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index db11815..89f2d02 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3756,7 +3756,7 @@ void QWidgetPrivate::stackUnder_sys(QWidget *w) /* Modifies the bounds for a widgets backing HIView during moves and resizes. Also updates the widget, either by scrolling its contents or repainting, depending on the WA_StaticContents - and QWidgetPrivate::isOpaque flags. + flag */ static void qt_mac_update_widget_posisiton(QWidget *q, QRect oldRect, QRect newRect) { @@ -3773,8 +3773,8 @@ static void qt_mac_update_widget_posisiton(QWidget *q, QRect oldRect, QRect newR // Perform a normal (complete repaint) update in some cases: if ( - // move-by-scroll requires QWidgetPrivate::isOpaque set - (isMove && q->testAttribute(Qt::WA_OpaquePaintEvent) == false) || + // always repaint on move. + (isMove) || // limited update on resize requires WA_StaticContents. (isResize && q->testAttribute(Qt::WA_StaticContents) == false) || -- cgit v0.12 From 8d01f436451071a917c147a96a979ccdaee106f9 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 2 Nov 2009 14:49:33 +0100 Subject: QCSSParser: Fixes the way spaces are handled in font family. We cannot simplify spaces because a font may have several spaces in its name. If we only add spaces when needed when merging tokens, we don't need to simplyfy the string later The CSS tokenizer will already make sure that spaces are removed if there is no quotes (btw, the CSS specification says that there must be quotes if there is spaces, but we tollerate if there is no quotes) Reviewed-by: Jocelyn Turcotte Task-number: QTBUG-4344 Task-number: 258586 --- src/gui/text/qcssparser.cpp | 7 +++++-- tests/auto/qcssparser/tst_qcssparser.cpp | 3 +++ tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp | 10 ++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 6db86bd..93b9fc6 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -1129,19 +1129,22 @@ static bool setFontWeightFromValue(const Value &value, QFont *font) static bool setFontFamilyFromValues(const QVector &values, QFont *font, int start = 0) { QString family; + bool shouldAddSpace = false; for (int i = start; i < values.count(); ++i) { const Value &v = values.at(i); if (v.type == Value::TermOperatorComma) { family += QLatin1Char(','); + shouldAddSpace = false; continue; } const QString str = v.variant.toString(); if (str.isEmpty()) break; + if (shouldAddSpace) + family += QLatin1Char(' '); family += str; - family += QLatin1Char(' '); + shouldAddSpace = true; } - family = family.simplified(); if (family.isEmpty()) return false; font->setFamily(family); diff --git a/tests/auto/qcssparser/tst_qcssparser.cpp b/tests/auto/qcssparser/tst_qcssparser.cpp index 150f131..3580252 100644 --- a/tests/auto/qcssparser/tst_qcssparser.cpp +++ b/tests/auto/qcssparser/tst_qcssparser.cpp @@ -1556,8 +1556,11 @@ void tst_QCssParser::extractFontFamily_data() QTest::newRow("shorthand") << "font: 12pt Times New Roman" << QString("Times New Roman"); QTest::newRow("shorthand multiple quote") << "font: 12pt invalid, \"Times New Roman\" " << QString("Times New Roman"); QTest::newRow("shorthand multiple") << "font: 12pt invalid, Times New Roman " << QString("Times New Roman"); + QTest::newRow("invalid spaces") << "font-family: invalid spaces, Times New Roman " << QString("Times New Roman"); + QTest::newRow("invalid spaces quotes") << "font-family: 'invalid spaces', 'Times New Roman' " << QString("Times New Roman"); } + void tst_QCssParser::extractFontFamily() { QFETCH(QString, css); diff --git a/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp index 8c4d8fd..4dc732c 100644 --- a/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp +++ b/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp @@ -2197,6 +2197,16 @@ void tst_QTextDocumentFragment::html_quotedFontFamily() setHtml("
Test
"); QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar")); + + setHtml("
Test
"); + QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar")); + + setHtml("
Test
"); + QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar")); + + setHtml("
Test
"); + QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar,serif,bar foo")); + } void tst_QTextDocumentFragment::defaultFont() -- cgit v0.12 From c55c08b38dd902765f476f62369378813c8e804f Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 2 Nov 2009 15:27:59 +0100 Subject: Doc: i18n overhaul for QObject::tr() and the Qt Linguist manual. Reviewed-by: Trust Me --- doc/src/internationalization/i18n.qdoc | 267 ++++++++++++++- doc/src/internationalization/linguist-manual.qdoc | 368 ++------------------- doc/src/snippets/code/doc_src_i18n.qdoc | 2 +- .../snippets/code/src_corelib_kernel_qobject.cpp | 3 +- examples/mainwindows/sdi/mainwindow.h | 2 + src/corelib/kernel/qobject.cpp | 146 +------- 6 files changed, 310 insertions(+), 478 deletions(-) diff --git a/doc/src/internationalization/i18n.qdoc b/doc/src/internationalization/i18n.qdoc index e873f4e..1a2839d 100644 --- a/doc/src/internationalization/i18n.qdoc +++ b/doc/src/internationalization/i18n.qdoc @@ -51,6 +51,7 @@ \page internationalization.html \title Internationalization with Qt \brief Information about Qt's support for internationalization and multiple languages. + \nextpage Writing Source Code for Translation \keyword internationalization \keyword i18n @@ -59,11 +60,11 @@ the application usable by people in countries other than one's own. \tableofcontents - + \section1 Relevant Qt Classes and APIs These classes support internationalizing of Qt applications. - + \annotatedlist i18n \section1 Languages and Writing Systems @@ -516,3 +517,265 @@ For details on Mac-specific translation, refer to the Qt/Mac Specific Issues document \l{Qt for Mac OS X - Specific Issues#Translating the Application Menu and Native Dialogs}{here}. */ + +/*! + \page i18n-source-translation.html + \title Writing Source Code for Translation + \ingroup i18n + \previouspage Internationalization with Qt + \contentspage Internationalization with Qt + \nextpage Translation Rules for Plurals + \brief How to write source code in a way that makes it possible for user-visible text to be translated. + + \tableofcontents + + \section1 The Basics + + Developers use the \l{QObject::}{tr()} function to obtain translated text + for their classes, typically for display purposes. This function is also + used to indicate which text strings in an application are translatable. + + Qt indexes each translatable string by the \e{translation context} it is + associated with; this is generally the name of the QObject subclass it is + used in. + + Translation contexts are defined for new QObject-based classes by the use + of the Q_OBJECT macro in each new class definition. + + When tr() is called, it looks up the translatable string using a QTranslator + object. For translation to work, one or more of these must have been + installed on the application object in the way described in the + \l{#Enabling Translation}{Enabling Translation} section below. + + \section1 Defining a Translation Context + + The translation context for QObject and each QObject subclass is the + class name itself. Developers subclassing QObject must use the + Q_OBJECT macro in their class definition to override the translation + context. This macro sets the context to the name of the subclass. + + For example, the following class definition includes the Q_OBJECT macro, + implementing a new tr() that uses the \c MainWindow context: + + \snippet mainwindows/sdi/mainwindow.h class definition with macro + \dots + + If Q_OBJECT is not used in a class definition, the context will be + inherited from the base class. For example, since all QObject-based + classes in Qt provide a context, a new QWidget subclass defined without + a Q_OBJECT macro will use the \c QWidget context if its tr() function + is invoked. + + \section1 Using tr() to Obtain a Translation + + The following example shows how a translation is obtained for the + class shown in the previous section: + + \snippet mainwindows/sdi/mainwindow.cpp implicit tr context + \dots + + Here, the translation context is \c MainWindow because it is the + \c MainWindow::tr() function that is invoked. The text returned + by the tr() function is a translation of "&File" obtained from + the \c MainWindow context. + + When Qt's translation tool, \l lupdate, is used to process a set of source + files, the text wrapped in tr() calls is stored in a section of the translation + file that corresponds to its translation context. + + In some situations, it is useful to give a translation context explicitly + by fully qualifying the call to tr(); for example: + + \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp explicit tr context + + This call obtains the translated text for "Page up" from the \c QScrollBar + context. Developers can also use the QCoreApplication::translate() function + to obtain a translation for a particular translation context. + + \section1 Translator Comments + + Developers can include information about each translatable string to + help translators with the translation process. These are extracted + when \l lupdate is used to process the source files. The recommended + way to add comments is to annotate the tr() calls in your code with + comments of the form: + + \tt{//: ...} + + or + + \tt{\begincomment: ... \endcomment} + + Examples: + + \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 40 + + In these examples, the comments will be associated with the strings + passed to tr() in the context of each call. + + \section1 Adding Meta-Data to Strings + + Additional data can be attached to each translatable message. These are + extracted when \l lupdate is used to process the source files. The + recommended way to add meta-data is to annotate the tr() calls in your code + with comments of the form: + + \tt{//= } + + This can be used to give the message a unique identifier to support tools + which need it. + + An alternative way to attach meta-data is to use the following syntax: + + \tt{//~ } + + This can be used to attach meta-data to the message. The field name should + consist of a domain prefix (possibly the conventional file extension of the + file format the field is inspired by), a hyphen and the actual field name + in underscore-delimited notation. For storage in TS files, the field name + together with the prefix "extra-" will form an XML element name. The field + contents will be XML-escaped, but otherwise appear verbatim as the + element's contents. Any number of unique fields can be added to each + message. + + Example: + + \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp meta data + + Meta-data appearing right in front of a magic TRANSLATOR comment applies to + the whole TS file. + + \section1 Disambiguation + + If the same translatable string is used in different roles within the same + translation context, an additional identifying string may be passed in + the call to \l{QObject::}{tr()}. This optional disambiguation argument + is used to distinguish between otherwise identical strings. + + Example: + + \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 17 + \dots + + In Qt 4.4 and earlier, this disambiguation parameter was the preferred + way to specify comments to translators. + + \section1 Character Encodings + + You can set the encoding for the source text by calling QTextCodec::setCodecForTr(). + By default, the source text is assumed to be in Latin-1 encoding. + + \section1 Handling Plurals + + Some translatable strings contain placeholders for integer values and need + to be translated differently depending on the values in use. + + To help with this problem, developers pass an additional integer argument + to the \l{QObject::}{tr()} function, and typically use a special notation + for plurals in each translatable string. + + If this argument is equal or greater than zero, all occurrences of + \c %n in the resulting string are replaced with a decimal representation + of the value supplied. In addition, the translation used will adapt to the + value according to the rules for each language. + + Example: + + \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 18 + + The table below shows what string is returned depending on the + active translation: + + \table + \header \o \o{3,1} Active Translation + \header \o \a n \o No Translation \o French \o English + \row \o 0 \o "0 message(s) saved" \o "0 message sauvegard\unicode{0xE9}" \o "0 message\bold{s} saved" + \row \o 1 \o "1 message(s) saved" \o "1 message sauvegard\unicode{0xE9}" \o "1 message saved" + \row \o 2 \o "2 message(s) saved" \o "2 message\bold{s} sauvegard\unicode{0xE9}\bold{s}" \o "2 message\bold{s} saved" + \row \o 37 \o "37 message(s) saved" \o "37 message\bold{s} sauvegard\unicode{0xE9}\bold{s}" \o "37 message\bold{s} saved" + \endtable + + This idiom is more flexible than the traditional approach; e.g., + + \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 19 + + because it also works with target languages that have several + plural forms (e.g., Irish has a special "dual" form that should + be used when \c n is 2), and it handles the \e n == 0 case + correctly for languages such as French that require the singular. + See the \l{Qt Linguist Manual} for details. + + Instead of \c %n, you can use \c %Ln to produce a localized + representation of \a n. The conversion uses the default locale, + set using QLocale::setDefault(). (If no default locale was + specified, the "C" locale is used.) + + A summary of the rules used to translate strings containing plurals can be + found in the \l{Translation Rules for Plurals} document. + + \section1 Enabling Translation + + Typically, your application's \c main() function will look like + this: + + \snippet doc/src/snippets/code/doc_src_i18n.qdoc 8 + + Note the use of QLibraryInfo::location() to locate the Qt translations. + Developers should request the path to the translations at run-time by + passing QLibraryInfo::TranslationsPath to this function instead of + using the \c QTDIR environment variable in their applications. + + \section1 Further Reading + + \l{Qt Linguist Manual}, \l{Hello tr Example}, \l{Translation Rules for Plurals} +*/ + +/*! + \page i18n-plural-rules.html + \title Translation Rules for Plurals + \ingroup i18n + \previouspage Writing Source Code for Translation + \contentspage Internationalization with Qt + \brief A summary of the translation rules for plurals produced by Qt's i18n tools. + + The table below shows the specific rules that are produced by Qt Linguist + and \c lrelease for a selection of languages. Cells marked \e otherwise + indicate the form used when none of the other rules are appropriate for a + specific language. + + \table 80% + \header \o Language \o Rule 1 \o Rule 2 \o Rule 3 + \row \o English \o \c{n == 1} + \o \e{otherwise} \o N/A + \row \o French \o \c{n < 2} + \o \e{otherwise} \o N/A + \row \o Czech \o \c{n % 100 == 1} + \o \c{n % 100 >= 2 && n % 100 <= 4} + \o \e{otherwise} + \row \o Irish \o \c{n == 1} + \o \c{n == 2} \o \e{otherwise} + \row \o Latvian \o \c{n % 10 == 1&& n % 100 != 11} + \o \c{n != 0} \o \e{otherwise} + \row \o Lithuanian \o \c{n % 10 == 1&& n % 100 != 11} + \o \c{n % 100 != 12 && n % 10 == 2} + \o \e{otherwise} + \row \o Macedonian \o \c{n % 10 == 1} + \o \c{n % 10 == 2} \o \e{otherwise} + \row \o Polish \o \c{n == 1} + \o \c{n % 10 >= 2 && n % 10 <= 4 + && (n % 100 < 10 || n % 100 > 20)} + \o \e{otherwise} + \row \o Romanian \o \c{n == 1} + \o \c{n == 0|| (n % 100 >= 1 && n % 100 <= 20)} + \o \e{otherwise} + \row \o Russian \o \c{n % 10 == 1&& n % 100 != 11} + \o \c{n % 10 >= 2 && n % 10 <= 4 + && (n % 100 < 10 || n % 100 > 20)} + \o \e{otherwise} + \row \o Slovak \o \c{n == 1} \o \c{n >= 2 && n <= 4} + \o \e{otherwise} + \row \o Japanese \o \e{otherwise} \o N/A \o N/A + \endtable + + The rules themselves are not documented and are internal to Qt Linguist and \c lrelease. +*/ diff --git a/doc/src/internationalization/linguist-manual.qdoc b/doc/src/internationalization/linguist-manual.qdoc index 5d388f1..3e06a2f 100644 --- a/doc/src/internationalization/linguist-manual.qdoc +++ b/doc/src/internationalization/linguist-manual.qdoc @@ -62,7 +62,7 @@ software engineers and the translator. The chapter describes the use of two tools. The \l{lupdate} tool is used to synchronize source code and translations. The \l{lrelease} tool is used to - create runtime translation files for use by the released + create run-time translation files for use by the released application. The \l{linguist-translators.html}{Translators} chapter is for @@ -119,7 +119,7 @@ \o Phrases that contain variables, for example, "The 25 files selected will take 63 seconds to process", where the two numbers - are inserted programmatically at runtime may need to be reworded + are inserted programmatically at run-time may need to be reworded because in a different language the word order and therefore the placement of the variables may have to change. @@ -147,7 +147,7 @@ \row \o{1,2} \inlineimage wVista-Cert-border-small.png \o \e{Qt Linguist 4.3 is Certified for Windows Vista} - + \row \o Windows Vista and the Windows Vista Start button are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. @@ -508,7 +508,7 @@ translation. The state is reset to \inlineimage linguist-danger.png , and the number of accepted translations in the \e{Items} column of the \l{Context Window} {context list} is decremented by 1. - + \row \o Not Accepted \o \inlineimage linguist-check-off.png @@ -781,7 +781,7 @@ changed. Whichever character (alpha or digit) is chosen, the translation must be in the form "Ctrl+" followed by the upper case character. \e{Qt} will automatically display the correct name at - runtime. As with Alt key accelerators, if the translator changes + run-time. As with Alt key accelerators, if the translator changes the character, the new character must not conflict with any other Ctrl key accelerator. @@ -790,14 +790,14 @@ supported languages, \e {Qt} automatically translates these strings. - \section2 Handling Numbered Arguments + \section2 Handling Numbered Arguments and Plurals Some phrases contain numbered arguments. A numbered argument is a - placeholder that will be replaced with text at runtime. A numbered + placeholder that will be replaced with text at run-time. A numbered argument appears in a source string as a percent sign followed by a digit. Consider an example: \c{After processing file %1, file %2 is next in line}. In this string to be translated, \c{%1} and - \c{%2} are numbered arguments. At runtime, \c{%1} and \c{%2} will + \c{%2} are numbered arguments. At run-time, \c{%1} and \c{%2} will be replaced with the first and next file names respectively. The same numbered arguments must appear in the translation, but not necessarily in the same order. A German translation of the string @@ -808,336 +808,14 @@ of where argument \e{i} appears in the argument sequence in the source string. - \section2 Plurals - - The problem of plurals in output is resolved by using an overload of - the \c tr() function with the signature - \code - QString tr(const char *text, const char *comment, int n); - \endcode - Using built in comparisons for the value of \c n the tr() function will - translate the phrase to the plural form for the target language. - - Different languages have various forms for plurals beyond simply - \e singular and \e plural. The rules for determining which form of the - plural to use are encoded as conditional tests. Below is a table - representing the numbers associated with the forms rather than the - conditional tests themselves. - - - - \table 90% - \header - \o Language - \o Form 1 - \o Form 2 - \o Form 3 - \o Form 4 - \row - \o Arabic - \o 0, 1, 11-102, 111-202... - \o 2 - \o 3-10, 103-110, 203-210... - \o - \row - \o Basque - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o Bulgarian - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o Catalan - \o 1 - \o 11, 11 000-11 999, 11 000 000-11 999 999... - \o 0, 2-10, 12-10 999, 12-10 999 999... - \o - \row - \o Chinese-CN - \o 0- - \o - \o - \o - \row - \o Chinese-HK - \o 0- - \o - \o - \o - \row - \o Chinese-TW - \o 0- - \o - \o - \o - \row - \o Croation - \o 1, 21, 31, 41, 51, 61, 71, 81, 91, 101... - \o 2-4, 22-24, 32-34, 42-44... - \o 0, 5-20, 25-30, 35-40... - \o - \row - \o Czech - \o 1 - \o 2-4 - \o 0, 5- - \o - \row - \o Danish - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o Dutch - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o English - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o English-US - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o Estonian - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o Finnish - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o French-CA - \o 0, 1 - \o 2-100, 101- - \o - \o - \row - \o French-FR - \o 0, 1 - \o 2-100, 101- - \o - \o - \row - \o Galician - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o German - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o Greek - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o Hebrew - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o Hungarian - \o 0- - \o - \o - \o - \row - \o Icelandic - \o 1, 21, 31, 41, 51....101, 121, 131... - \o 0, 2-20, 22-30, 32-40...102-120... - \o - \o - \row - \o Indonesian - \o 0- - \o - \o - \o - \row - \o Italian - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o Japanese - \o 0- - \o - \o - \o - \row - \o Korean - \o 0- - \o - \o - \o - \row - \o Latvian - \o 0 - \o 1, 21, 31, 41, 51, 61, 71, 81, 91, 101, 131, 141... - \o 2-20, 22-30, 32-40, 42-50...202-220, 222-230... - \o - \row - \o Lithuanian - \o 1, 21, 31, 41, 51...101, 121, 131... - \o 2-9, 22-29, 32-39...102-109, 122-129, 132-139... - \o 0, 10-20, 30, 40, 50...110-120, 130, 140... - \o - \row - \o Malay - \o 0- - \o - \o - \o - \row - \o Norwegian - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o Persian - \o 0- - \o - \o - \o - \row - \o Polish - \o 1 - \o 2-4, 22-24, 32-34... - \o 5-21, 25-31, 35-41... - \o - \row - \o Portugese-BR - \o 0, 1 - \o 2-100, 101- - \o - \o - \row - \o Portugese-PT - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o Romanian - \o 1 - \o 0, 2-19, 101-119, 201-219... - \o 20-100, 120-200, 220-300... - \o - \row - \o Russian - \o 1, 21, 31, 41, 51, 61, 71, 81, 91, 101... - \o 2-4, 22-24, 32-34... - \o 0, 5-20, 25-30, 35-40... - \o - \row - \o Serbian - \o 1, 21, 31, 41, 51, 61, 71, 81, 91, 101... - \o 2-4, 22-24, 32-34... - \o 0, 5-20, 25-30, 35-40... - \o - \row - \o Slovak - \o 1 - \o 2-4 - \o 0, 5-20, 25-30, 35-40... - \o - \row - \o Slovene - \o 1, 101, 201, 301... - \o 2, 102, 202, 302... - \o 3, 4, 103, 104, 203, 204, 303, 304... - \o 0, 5-100, 105-200, 205-300... - \row - \o Spanish-US - \o 1 - \o 0, 2- - \o - \o - \row - \o Spanish-ES - \o 1 - \o 0, 2- - \o - \o - \row - \o Swedish - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o Tagalog - \o 0, 1 - \o 2, 3, 5, 7-8, 10-13, 15, 17-18, 20-23...101...1001 - \o 4, 6, 9, 14, 16, 19, 24, 26, 29...104, 106, 109... - \o - \row - \o Thai - \o 0- - \o - \o - \o - \row - \o Turkish - \o 0- - \o - \o - \o - \row - \o Ukrainian - \o 1, 21, 31, 41, 51, 61, 71, 81, 91, 101... - \o 2-4, 22-24, 32-34... - \o 0, 5-20, 25-30, 35-40... - \o - \row - \o Urdu - \o 1 - \o 0, 2-100, 101- - \o - \o - \row - \o Vietnamese - \o 0- - \o - \o - \o - \endtable - - These rules are embedded within the Qt libraries, there is no need for - the developer to know them. Merely to use the correct \c tr() call. - + The use of numbered arguments is often accompanied by the use of + plurals in the source text. In many languages, the form of the + text will depend on the value shown, and more than one translation + is required. If the developers have marked up the source text in + correct way, fields for each of the possible plural forms will be + available in the translation area. (The + \l{Writing Source Code for Translation#Handling Plurals}{Writing Source Code for Translation} + document contains details about this feature for developers.) \section2 Reusing Translations @@ -1157,7 +835,7 @@ {translation area}, and adapts the number of input fields for plural forms accordingly. If not explicitly set, \QL guesses the target language and country by evaluating the translation source - file name: E.g. \c app_de.ts sets the target language to German, + file name. For example, \c app_de.ts sets the target language to German, and \c app_de_ch.ts sets the target language to German and the target country to Switzerland (this also helps loading translations for the current locale automatically; see @@ -1287,7 +965,7 @@ can be used to edit XLIFF files generated by other programs. For standard Qt projects, however, only the TS file format is used. \o QM \e {Qt message files} \BR are binary files that contain - translations used by an application at runtime. These files are + translations used by an application at run-time. These files are generated by \l lrelease, but can also be generated by \QL. \o \c .qph \e {Qt phrase book files} \BR are human-readable XML files containing standard phrases and their translations. These files @@ -1416,7 +1094,7 @@ \endlist - \o \gui {Tools} + \o \gui {Tools} \list \o \gui {Batch Translation...} \BR Opens a \l{Batch @@ -1427,7 +1105,7 @@ Preview}. This window let you instantly see translations for forms created with \QD. \endlist - \o \gui {View} + \o \gui {View} \list \o \gui {Revert Sorting} \BR puts the items in the \l{Context @@ -1449,7 +1127,7 @@ \endlist - \o \gui {Help} + \o \gui {Help} \list \o \gui {Manual F1} \BR opens this manual. \o \gui {About Qt Linguist} \BR Shows information about \QL. @@ -1621,7 +1299,7 @@ \code CODECFORTR = UTF-8 \endcode - + See the \l lupdate and \l lrelease sections. \section2 Loading Translations @@ -1683,7 +1361,7 @@ \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 9 - \section2 Distinguishing Identical Strings That Require Different Translations + \section2 Distinguishing Between Identical Translatable Strings The \l lupdate program automatically provides a \e context for every source text. This context is the class name of the class that contains diff --git a/doc/src/snippets/code/doc_src_i18n.qdoc b/doc/src/snippets/code/doc_src_i18n.qdoc index eca2868..80faabc 100644 --- a/doc/src/snippets/code/doc_src_i18n.qdoc +++ b/doc/src/snippets/code/doc_src_i18n.qdoc @@ -184,7 +184,7 @@ void Clock::setTime(const QTime &time) //! [12] -void QWidget::changeEvent(QEvent *event) +void MyWidget::changeEvent(QEvent *event) { if (e->type() == QEvent::LanguageChange) { titleLabel->setText(tr("Document Title")); diff --git a/doc/src/snippets/code/src_corelib_kernel_qobject.cpp b/doc/src/snippets/code/src_corelib_kernel_qobject.cpp index 4c64374..88d8025 100644 --- a/doc/src/snippets/code/src_corelib_kernel_qobject.cpp +++ b/doc/src/snippets/code/src_corelib_kernel_qobject.cpp @@ -235,9 +235,8 @@ MyWindow::MyWindow() { QLabel *senderLabel = new QLabel(tr("Name:")); QLabel *recipientLabel = new QLabel(tr("Name:", "recipient")); - ... -} //! [17] +} //! [18] diff --git a/examples/mainwindows/sdi/mainwindow.h b/examples/mainwindows/sdi/mainwindow.h index ca478df..a925e2f 100644 --- a/examples/mainwindows/sdi/mainwindow.h +++ b/examples/mainwindows/sdi/mainwindow.h @@ -50,12 +50,14 @@ class QMenu; class QTextEdit; QT_END_NAMESPACE +//! [class definition with macro] class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(); +//! [class definition with macro] MainWindow(const QString &fileName); protected: diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 7be19b3..7031957 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -582,7 +582,7 @@ int QMetaCallEvent::placeMetaCall(QObject *object) QObjects organize themselves in object trees. When you create a QObject with another object as parent, the object will automatically add itself to the parent's children() list. The - parent takes ownership of the object i.e. it will automatically + parent takes ownership of the object; i.e., it will automatically delete its children in its destructor. You can look for an object by name and optionally type using findChild() or findChildren(). @@ -646,7 +646,7 @@ int QMetaCallEvent::placeMetaCall(QObject *object) to be stored in one of the container classes. You must store pointers. - \section2 Auto-Connection + \section1 Auto-Connection Qt's meta-object system provides a mechanism to automatically connect signals and slots between QObject subclasses and their children. As long @@ -660,7 +660,7 @@ int QMetaCallEvent::placeMetaCall(QObject *object) given in the \l{Using a Designer UI File in Your Application} section of the \QD manual. - \section2 Dynamic Properties + \section1 Dynamic Properties From Qt 4.2, dynamic properties can be added to and removed from QObject instances at run-time. Dynamic properties do not need to be declared at @@ -673,6 +673,15 @@ int QMetaCallEvent::placeMetaCall(QObject *object) and both standard Qt widgets and user-created forms can be given dynamic properties. + \section1 Internationalization (i18n) + + All QObject subclasses support Qt's translation features, making it possible + to translate an application's user interface into different languages. + + To make user-visible text translatable, it must be wrapped in calls to + the tr() function. This is explained in detail in the + \l{Writing Source Code for Translation} document. + \sa QMetaObject, QPointer, QObjectCleanupHandler, Q_DISABLE_COPY() {Object Trees and Object Ownership} */ @@ -2157,65 +2166,10 @@ void QObject::deleteLater() otherwise returns \a sourceText itself if no appropriate translated string is available. - See the sections below on Disambiguation and Handling Plurals for more - information about the optional \a disambiguation and \a n parameters. - - QObject and its subclasses obtain translated strings from any translator - objects that have been installed on the application object; see the - QTranslator documentation for details about this mechanism. - - A translatable string is referenced by its translation context; - this is the name of the QObject subclass whose tr() function is invoked, - as in the following example: - + Example: \snippet mainwindows/sdi/mainwindow.cpp implicit tr context \dots - Here, the context is \c MainWindow because it is the \c MainWindow::tr() - function that is invoked. Translation contexts can be given explicitly - by fully qualifying the call to tr(); for example: - - \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp explicit tr context - - This call obtains the translated text for "Page up" from the \c QScrollBar - context. - - \section1 Defining Translation Contexts - - The translation context for QObject and each QObject subclass is the - class name itself. Developers subclassing QObject must use the - Q_OBJECT macro in their class definition to override the translation - context. This macro sets the context to the name of the subclass. - - If Q_OBJECT is not used in a class definition, the context will be - inherited from the base class. For example, since all QObject-based - classes in Qt provide a context, a new QWidget subclass defined without - a Q_OBJECT macro will use the "QWidget" context if its tr() function - is invoked. - - \section1 Translator Comments - - Developers can include information about each translatable string to - help translators with the translation process. These are extracted - when \l lupdate is used to process the source files. The recommended - way to add comments is to annotate the tr() calls in your code with - comments of the form: - - \tt{//: ...} - - or - - \tt{\begincomment: ... \endcomment} - - Examples: - - \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 40 - - In these examples, the comments will be associated with the strings - passed to tr() in the context of each call. - - \section1 Disambiguation - If the same \a sourceText is used in different roles within the same context, an additional identifying string may be passed in \a disambiguation (0 by default). In Qt 4.4 and earlier, this was @@ -2224,76 +2178,12 @@ void QObject::deleteLater() Example: \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 17 + \dots - \section1 Meta Data - - Additional data can be attached to each translatable message. - The syntax: - - \tt{//= } - - can be used to give the message a unique identifier to support tools - which need it. - The syntax: - - \tt{//~ } - - can be used to attach meta data to the message. The field name should consist - of a domain prefix (possibly the conventional file extension of the file format - the field is inspired by), a hyphen and the actual field name in - underscore-delimited notation. For storage in TS files, the field name together - with the prefix "extra-" will form an XML element name. The field contents will - be XML-escaped, but otherwise appear verbatim as the element's contents. - Any number of unique fields can be added to each message. - - Example: - - \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp meta data - - Meta data appearing right in front of a magic TRANSLATOR comment applies to the - whole TS file. - - \section1 Character Encodings - - You can set the encoding for \a sourceText by calling QTextCodec::setCodecForTr(). - By default \a sourceText is assumed to be in Latin-1 encoding. - - \section1 Handling Plurals - - If \a n >= 0, all occurrences of \c %n in the resulting string - are replaced with a decimal representation of \a n. In addition, - depending on \a n's value, the translation text may vary. - - Example: - - \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 18 - - The table below shows what string is returned depending on the - active translation: - - \table - \header \o \o{3,1} Active Translation - \header \o \a n \o No Translation \o French \o English - \row \o 0 \o "0 message(s) saved" \o "0 message sauvegard\unicode{0xE9}" \o "0 message\bold{s} saved" - \row \o 1 \o "1 message(s) saved" \o "1 message sauvegard\unicode{0xE9}" \o "1 message saved" - \row \o 2 \o "2 message(s) saved" \o "2 message\bold{s} sauvegard\unicode{0xE9}\bold{s}" \o "2 message\bold{s} saved" - \row \o 37 \o "37 message(s) saved" \o "37 message\bold{s} sauvegard\unicode{0xE9}\bold{s}" \o "37 message\bold{s} saved" - \endtable - - This idiom is more flexible than the traditional approach; e.g., - - \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 19 - - because it also works with target languages that have several - plural forms (e.g., Irish has a special "dual" form that should - be used when \c n is 2), and it handles the \e n == 0 case - correctly for languages such as French that require the singular. - See the \l{Qt Linguist Manual} for details. - - Instead of \c %n, you can use \c %Ln to produce a localized - representation of \a n. The conversion uses the default locale, - set using QLocale::setDefault(). (If no default locale was - specified, the "C" locale is used.) + See \l{Writing Source Code for Translation} for a detailed description of + Qt's translation mechanisms in general, and the + \l{Writing Source Code for Translation#Disambiguation}{Disambiguation} + section for information on disambiguation. \warning This method is reentrant only if all translators are installed \e before calling this method. Installing or removing -- cgit v0.12 From 50a745d31e348c113d42444d527b4286b7064e3e Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 2 Nov 2009 15:30:15 +0100 Subject: Doc: Fixed qdoc warnings. Reviewed-by: Trust Me --- src/gui/kernel/qevent.cpp | 2 +- src/gui/symbian/qsymbianevent.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 065bd09..617d016 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4330,7 +4330,7 @@ bool QGestureEvent::isAccepted(QGesture *gesture) const } /*! - Sets the widget for this event. + Sets the widget for this event to the \a widget specified. */ void QGestureEvent::setWidget(QWidget *widget) { diff --git a/src/gui/symbian/qsymbianevent.cpp b/src/gui/symbian/qsymbianevent.cpp index af2c861..2799e6f 100644 --- a/src/gui/symbian/qsymbianevent.cpp +++ b/src/gui/symbian/qsymbianevent.cpp @@ -66,13 +66,13 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QSymbianEvent::type() + \fn QSymbianEvent::type() const Returns the event type contained in the QSymbianEvent instance. */ /*! - \fn QSymbianEvent::isValid() + \fn QSymbianEvent::isValid() const Returns whether this QSymbianEvent instance contains a valid event. */ -- cgit v0.12 From cf800465369fb1ef84e8bddbbbfa7128d95afd27 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Mon, 2 Nov 2009 15:34:27 +0100 Subject: Sanitize building Qt with OpenGL ES support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit introduce QMAKE_LIBS_OPENGL_ES1, QMAKE_LIBS_OPENGL_ES1CL and QMAKE_LIBS_OPENGL_ES2 so we do not have to force users to copy/paste around entire mkspecs just to change the OpenGL backend. This should make the "-opengl es2" (and friends) configure option work out of the box with any mkspec on Linux+WinCE. Also removes a WinCE specific hack that is not required anymore. Reviewed-by: Tom Cooksey Reviewed-by: Trond Kjernåsen Approved-by: Lars Knoll --- config.tests/unix/opengles1/opengles1.pro | 6 +++--- config.tests/unix/opengles1cl/opengles1cl.pro | 6 +++--- config.tests/unix/opengles2/opengles2.pro | 6 +++--- doc/src/development/qmake-manual.qdoc | 23 +++++++++++++++++++++++ mkspecs/common/linux.conf | 9 +++++++++ mkspecs/common/wince/qmake.conf | 4 ++++ mkspecs/features/unix/opengl.prf | 26 ++++++++++++++++++++++---- src/opengl/opengl.pro | 22 ++++++++++------------ 8 files changed, 77 insertions(+), 25 deletions(-) diff --git a/config.tests/unix/opengles1/opengles1.pro b/config.tests/unix/opengles1/opengles1.pro index ad8dd31..1469aa9 100644 --- a/config.tests/unix/opengles1/opengles1.pro +++ b/config.tests/unix/opengles1/opengles1.pro @@ -1,9 +1,9 @@ SOURCES = opengles1.cpp -INCLUDEPATH += $$QMAKE_INCDIR_OPENGL +INCLUDEPATH += $$QMAKE_INCDIR_OPENGL_ES1 -for(p, QMAKE_LIBDIR_OPENGL) { +for(p, QMAKE_LIBDIR_OPENGL_ES1) { exists($$p):LIBS += -L$$p } CONFIG -= qt -LIBS += $$QMAKE_LIBS_OPENGL_QT +LIBS += $$QMAKE_LIBS_OPENGL_ES1 diff --git a/config.tests/unix/opengles1cl/opengles1cl.pro b/config.tests/unix/opengles1cl/opengles1cl.pro index 415cdbb..c4c069e 100644 --- a/config.tests/unix/opengles1cl/opengles1cl.pro +++ b/config.tests/unix/opengles1cl/opengles1cl.pro @@ -1,9 +1,9 @@ SOURCES = opengles1cl.cpp -INCLUDEPATH += $$QMAKE_INCDIR_OPENGL +INCLUDEPATH += $$QMAKE_INCDIR_OPENGL_ES1CL -for(p, QMAKE_LIBDIR_OPENGL) { +for(p, QMAKE_LIBDIR_OPENGL_ES1CL) { exists($$p):LIBS += -L$$p } CONFIG -= qt -LIBS += $$QMAKE_LIBS_OPENGL_QT +LIBS += $$QMAKE_LIBS_OPENGL_ES1CL diff --git a/config.tests/unix/opengles2/opengles2.pro b/config.tests/unix/opengles2/opengles2.pro index 0dfae42..c383fd0 100644 --- a/config.tests/unix/opengles2/opengles2.pro +++ b/config.tests/unix/opengles2/opengles2.pro @@ -1,9 +1,9 @@ SOURCES = opengles2.cpp -INCLUDEPATH += $$QMAKE_INCDIR_OPENGL +INCLUDEPATH += $$QMAKE_INCDIR_OPENGL_ES2 -for(p, QMAKE_LIBDIR_OPENGL) { +for(p, QMAKE_LIBDIR_OPENGL_ES2) { exists($$p):LIBS += -L$$p } CONFIG -= qt -LIBS += $$QMAKE_LIBS_OPENGL_QT +LIBS += $$QMAKE_LIBS_OPENGL_ES2 diff --git a/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc index 6c53242..09f1b9b 100644 --- a/doc/src/development/qmake-manual.qdoc +++ b/doc/src/development/qmake-manual.qdoc @@ -2252,6 +2252,18 @@ For example: If the OpenGL implementation uses EGL (most OpenGL/ES systems), then QMAKE_INCDIR_EGL may also need to be set. + \section1 QMAKE_INCDIR_OPENGL_ES1, QMAKE_INCDIR_OPENGL_ES1CL, QMAKE_INCDIR_OPENGL_ES2 + + These variables contain the location of OpenGL headers files to be added + to INCLUDEPATH when building an application with OpenGL ES 1, OpenGL ES 1 Common + Lite or OpenGL ES 2 support respectively. + + The value of this variable is typically handled by \c qmake or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + + If the OpenGL implementation uses EGL (most OpenGL/ES systems), + then QMAKE_INCDIR_EGL may also need to be set. + \target QMAKE_INCDIR_OPENVG \section1 QMAKE_INCDIR_OPENVG @@ -2496,6 +2508,17 @@ For example: variable is typically handled by \c qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + \section1 QMAKE_LIBS_OPENGL_ES1, QMAKE_LIBS_OPENGL_ES1CL, QMAKE_LIBS_OPENGL_ES2 + + These variables contain all the OpenGL libraries for OpenGL ES 1, + OpenGL ES 1 Common Lite profile and OpenGL ES 2. + + The value of these variables is typically handled by \c qmake or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + + If the OpenGL implementation uses EGL (most OpenGL/ES systems), + then QMAKE_LIBS_EGL may also need to be set. + \section1 QMAKE_LIBS_OPENVG This variable contains all OpenVG libraries. The value of this diff --git a/mkspecs/common/linux.conf b/mkspecs/common/linux.conf index cc5c38b..1ae5608 100644 --- a/mkspecs/common/linux.conf +++ b/mkspecs/common/linux.conf @@ -13,6 +13,12 @@ QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] QMAKE_INCDIR_OPENGL = /usr/X11R6/include QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib +QMAKE_INCDIR_OPENGL_ES1 = $$QMAKE_INCDIR_OPENGL +QMAKE_LIBDIR_OPENGL_ES1 = $$QMAKE_LIBDIR_OPENGL +QMAKE_INCDIR_OPENGL_ES1CL = $$QMAKE_INCDIR_OPENGL +QMAKE_LIBDIR_OPENGL_ES1CL = $$QMAKE_LIBDIR_OPENGL +QMAKE_INCDIR_OPENGL_ES2 = $$QMAKE_INCDIR_OPENGL +QMAKE_LIBDIR_OPENGL_ES2 = $$QMAKE_LIBDIR_OPENGL QMAKE_INCDIR_EGL = QMAKE_LIBDIR_EGL = QMAKE_INCDIR_OPENVG = @@ -26,6 +32,9 @@ QMAKE_LIBS_NIS = -lnsl QMAKE_LIBS_EGL = -lEGL QMAKE_LIBS_OPENGL = -lGLU -lGL QMAKE_LIBS_OPENGL_QT = -lGL +QMAKE_LIBS_OPENGL_ES1 = -lGLES_CM +QMAKE_LIBS_OPENGL_ES1CL = -lGLES_CL +QMAKE_LIBS_OPENGL_ES2 = -lGLESv2 QMAKE_LIBS_OPENVG = -lOpenVG QMAKE_LIBS_THREAD = -lpthread diff --git a/mkspecs/common/wince/qmake.conf b/mkspecs/common/wince/qmake.conf index d6e4ba7..d87be02 100644 --- a/mkspecs/common/wince/qmake.conf +++ b/mkspecs/common/wince/qmake.conf @@ -64,6 +64,10 @@ QMAKE_LIBS_NETWORK = ws2.lib QMAKE_LIBS_OPENGL = QMAKE_LIBS_COMPAT = +QMAKE_LIBS_OPENGL_ES1 = libGLES_CM.lib +QMAKE_LIBS_OPENGL_ES1CL = libGLES_CL.lib +QMAKE_LIBS_OPENGL_ES2 = libGLESv2.lib + QMAKE_LIBS_QT_ENTRY = -lqtmain QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe diff --git a/mkspecs/features/unix/opengl.prf b/mkspecs/features/unix/opengl.prf index 2fdf324..f2db819 100644 --- a/mkspecs/features/unix/opengl.prf +++ b/mkspecs/features/unix/opengl.prf @@ -1,4 +1,22 @@ -INCLUDEPATH += $$QMAKE_INCDIR_OPENGL -!isEmpty(QMAKE_LIBDIR_OPENGL):QMAKE_LIBDIR += $$QMAKE_LIBDIR_OPENGL -target_qt:LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL_QT -else:LIBS += $$QMAKE_LIBS_OPENGL +contains(QT_CONFIG, opengles1) { + INCLUDEPATH += $$QMAKE_INCDIR_OPENGL_ES1 + !isEmpty(QMAKE_LIBDIR_OPENGL_ES1):QMAKE_LIBDIR += $$QMAKE_LIBDIR_OPENGL_ES1 + target_qt:LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL_ES1 + else:LIBS += $$QMAKE_LIBS_OPENGL_ES1 +} else:contains(QT_CONFIG, opengles1cl) { + INCLUDEPATH += $$QMAKE_INCDIR_OPENGL_ES1CL + !isEmpty(QMAKE_LIBDIR_OPENGL_ES1CL):QMAKE_LIBDIR += $$QMAKE_LIBDIR_OPENGL_ES1CL + target_qt:LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL_ES1CL + else:LIBS += $$QMAKE_LIBS_OPENGL_ES1CL +} else:contains(QT_CONFIG, opengles2) { + INCLUDEPATH += $$QMAKE_INCDIR_OPENGL_ES2 + !isEmpty(QMAKE_LIBDIR_OPENGL_ES2):QMAKE_LIBDIR += $$QMAKE_LIBDIR_OPENGL_ES2 + target_qt:LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL_ES2 + else:LIBS += $$QMAKE_LIBS_OPENGL_ES2 +} else { + INCLUDEPATH += $$QMAKE_INCDIR_OPENGL + !isEmpty(QMAKE_LIBDIR_OPENGL):QMAKE_LIBDIR += $$QMAKE_LIBDIR_OPENGL + target_qt:LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL_QT + else:LIBS += $$QMAKE_LIBS_OPENGL +} + diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index a212675..7d6052b 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -103,7 +103,7 @@ x11 { LIBS_PRIVATE += -lfreetype } else { ### Note: how does this compile with a non-system freetype? - # This probably doesn't compile + # This probably does not compile } } else { DEFINES *= QT_NO_FREETYPE @@ -150,17 +150,15 @@ embedded { INCLUDEPATH += ../3rdparty/harfbuzz/src -wince*: { - contains(QT_CONFIG,opengles1) { - QMAKE_LIBS += "libGLES_CM.lib" - } - contains(QT_CONFIG,opengles1cl) { - QMAKE_LIBS += "libGLES_CL.lib" - } - contains(QT_CONFIG,opengles2) { - QMAKE_LIBS += "libGLESv2.lib" - } - +contains(QT_CONFIG,opengles1) { + LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL_ES1 + LIBS += $$QMAKE_LFLAGS_OPENGL_ES1 +} else:contains(QT_CONFIG,opengles1cl) { + LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL_ES1CL + LIBS += $$QMAKE_LFLAGS_OPENGL_ES1CL +} else:contains(QT_CONFIG,opengles2) { + LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL_ES2 + LIBS += $$QMAKE_LFLAGS_OPENGL_ES2 } else { LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL LIBS += $$QMAKE_LFLAGS_OPENGL -- cgit v0.12 From 8abe466caa1b38f4cc1f95fba83d5e61e611e931 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 2 Nov 2009 15:45:49 +0100 Subject: Make the combobox emit activated when it loses focus Task-number: QTBUG-1071 Reviewed-by: ogoffart --- src/gui/widgets/qcombobox.cpp | 37 ++++++++++++++++++++++++++-------- src/gui/widgets/qcombobox.h | 1 + src/gui/widgets/qcombobox_p.h | 2 ++ tests/auto/qcombobox/tst_qcombobox.cpp | 31 ++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 8 deletions(-) diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 1879db4..bd1d8ba 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -1111,6 +1111,32 @@ void QComboBoxPrivate::updateLineEditGeometry() lineEdit->setGeometry(editRect); } +Qt::MatchFlags QComboBoxPrivate::matchFlags() const +{ + // Base how duplicates are determined on the autocompletion case sensitivity + Qt::MatchFlags flags = Qt::MatchFixedString; +#ifndef QT_NO_COMPLETER + if (!lineEdit->completer() || lineEdit->completer()->caseSensitivity() == Qt::CaseSensitive) +#endif + flags |= Qt::MatchCaseSensitive; + return flags; +} + + +void QComboBoxPrivate::_q_editingFinished() +{ + Q_Q(QComboBox); + if (lineEdit && !lineEdit->text().isEmpty()) { + //here we just check if the current item was entered + const int index = q_func()->findText(lineEdit->text(), matchFlags()); + if (index != -1 && itemText(currentIndex) != lineEdit->text()) { + q->setCurrentIndex(index); + emitActivated(currentIndex); + } + } + +} + void QComboBoxPrivate::_q_returnPressed() { Q_Q(QComboBox); @@ -1123,13 +1149,7 @@ void QComboBoxPrivate::_q_returnPressed() // check for duplicates (if not enabled) and quit int index = -1; if (!duplicatesEnabled) { - // Base how duplicates are determined on the autocompletion case sensitivity - Qt::MatchFlags flags = Qt::MatchFixedString; -#ifndef QT_NO_COMPLETER - if (!lineEdit->completer() || lineEdit->completer()->caseSensitivity() == Qt::CaseSensitive) -#endif - flags |= Qt::MatchCaseSensitive; - index = q->findText(text, flags); + index = q->findText(text, matchFlags()); if (index != -1) { q->setCurrentIndex(index); emitActivated(currentIndex); @@ -1664,6 +1684,7 @@ void QComboBox::setLineEdit(QLineEdit *edit) if (d->lineEdit->parent() != this) d->lineEdit->setParent(this); connect(d->lineEdit, SIGNAL(returnPressed()), this, SLOT(_q_returnPressed())); + connect(d->lineEdit, SIGNAL(editingFinished()), this, SLOT(_q_editingFinished())); connect(d->lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(editTextChanged(QString))); #ifdef QT3_SUPPORT connect(d->lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(textChanged(QString))); @@ -1960,7 +1981,7 @@ void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi) if (lineEdit) { QString newText = q->itemText(currentIndex.row()); if (lineEdit->text() != newText) - lineEdit->setText(q->itemText(currentIndex.row())); + lineEdit->setText(newText); updateLineEditGeometry(); } if (indexChanged) { diff --git a/src/gui/widgets/qcombobox.h b/src/gui/widgets/qcombobox.h index 4089a09..485e562 100644 --- a/src/gui/widgets/qcombobox.h +++ b/src/gui/widgets/qcombobox.h @@ -305,6 +305,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_itemSelected(const QModelIndex &item)) Q_PRIVATE_SLOT(d_func(), void _q_emitHighlighted(const QModelIndex &)) Q_PRIVATE_SLOT(d_func(), void _q_emitCurrentIndexChanged(const QModelIndex &index)) + Q_PRIVATE_SLOT(d_func(), void _q_editingFinished()) Q_PRIVATE_SLOT(d_func(), void _q_returnPressed()) Q_PRIVATE_SLOT(d_func(), void _q_resetButton()) Q_PRIVATE_SLOT(d_func(), void _q_dataChanged(const QModelIndex &, const QModelIndex &)) diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h index fe42c47..f6ba57c 100644 --- a/src/gui/widgets/qcombobox_p.h +++ b/src/gui/widgets/qcombobox_p.h @@ -342,6 +342,8 @@ public: void init(); QComboBoxPrivateContainer* viewContainer(); void updateLineEditGeometry(); + Qt::MatchFlags matchFlags() const; + void _q_editingFinished(); void _q_returnPressed(); void _q_complete(); void _q_itemSelected(const QModelIndex &item); diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index 51a7ff8..06c632d 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -57,6 +57,7 @@ #include #include #include +#include #ifdef Q_WS_MAC #include #elif defined Q_WS_X11 @@ -154,6 +155,7 @@ private slots: void removeItem(); void resetModel(); void keyBoardNavigationWithMouse(); + void task_QTBUG_1071_changingFocusEmitsActivated(); protected slots: void onEditTextChanged( const QString &newString ); @@ -813,21 +815,25 @@ void tst_QComboBox::autoCompletionCaseSensitivity() // case insensitive testWidget->clearEditText(); + QSignalSpy spyReturn(testWidget, SIGNAL(activated(int))); testWidget->setAutoCompletionCaseSensitivity(Qt::CaseInsensitive); QVERIFY(testWidget->autoCompletionCaseSensitivity() == Qt::CaseInsensitive); QTest::keyClick(testWidget->lineEdit(), Qt::Key_A); qApp->processEvents(); QCOMPARE(testWidget->currentText(), QString("aww")); + QCOMPARE(spyReturn.count(), 0); QTest::keyClick(testWidget->lineEdit(), Qt::Key_B); qApp->processEvents(); // autocompletions preserve userkey-case from 4.2 QCOMPARE(testWidget->currentText(), QString("abCDEF")); + QCOMPARE(spyReturn.count(), 0); QTest::keyClick(testWidget->lineEdit(), Qt::Key_Enter); qApp->processEvents(); QCOMPARE(testWidget->currentText(), QString("aBCDEF")); // case restored to item's case + QCOMPARE(spyReturn.count(), 1); testWidget->clearEditText(); QTest::keyClick(testWidget->lineEdit(), 'c'); @@ -2500,6 +2506,31 @@ void tst_QComboBox::keyBoardNavigationWithMouse() QTRY_COMPARE(combo.currentText(), QString::number(final)); } +void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated() +{ + QWidget w; + QVBoxLayout layout(&w); + QComboBox cb; + cb.setEditable(true); + QSignalSpy spy(&cb, SIGNAL(activated(int))); + cb.addItem("0"); + cb.addItem("1"); + cb.addItem("2"); + QLineEdit edit; + layout.add(&cb); + layout.add(&edit); + + w.show(); + QTest::qWaitForWindowShown(&w); + cb.clearEditText(); + cb.setFocus(); + QApplication::processEvents(); + QTest::keyClick(0, '1'); + QCOMPARE(spy.count(), 0); + edit.setFocus(); + QTRY_VERIFY(edit.hasFocus()); + QCOMPARE(spy.count(), 1); +} QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" -- cgit v0.12 From f1132e60e0759d8be043a2c4312915b3103004ff Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Mon, 2 Nov 2009 15:34:15 +0100 Subject: Titlebar icon (for e.g. Assistant) not visible in Cocoa. standardWindowButton:NSWindowDocumentIconButton will not return a valid NSButton unless you call setRepresentedURL or setRepresentedFilename for the NSWindow. This patch makes sure that setWindowIcon_sys() sets the icon using a valid NSButton. Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qcocoawindowdelegate_mac.mm | 23 +++++++++++++++++++++++ src/gui/kernel/qcocoawindowdelegate_mac_p.h | 2 ++ src/gui/kernel/qwidget_mac.mm | 6 ++++++ 3 files changed, 31 insertions(+) diff --git a/src/gui/kernel/qcocoawindowdelegate_mac.mm b/src/gui/kernel/qcocoawindowdelegate_mac.mm index 95c89e5..803a1b1 100644 --- a/src/gui/kernel/qcocoawindowdelegate_mac.mm +++ b/src/gui/kernel/qcocoawindowdelegate_mac.mm @@ -346,5 +346,28 @@ static void cleanupCocoaWindowDelegate() m_drawerHash->remove(drawer); } +- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu +{ + Q_UNUSED(menu); + QWidget *qwidget = m_windowHash->value(window); + if (qwidget && !qwidget->windowFilePath().isEmpty()) { + return YES; + } + return NO; +} + +- (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event + from:(NSPoint)dragImageLocation + withPasteboard:(NSPasteboard *)pasteboard +{ + Q_UNUSED(event); + Q_UNUSED(dragImageLocation); + Q_UNUSED(pasteboard); + QWidget *qwidget = m_windowHash->value(window); + if (qwidget && !qwidget->windowFilePath().isEmpty()) { + return YES; + } + return NO; +} @end #endif// QT_MAC_USE_COCOA diff --git a/src/gui/kernel/qcocoawindowdelegate_mac_p.h b/src/gui/kernel/qcocoawindowdelegate_mac_p.h index a06c516..3728002 100644 --- a/src/gui/kernel/qcocoawindowdelegate_mac_p.h +++ b/src/gui/kernel/qcocoawindowdelegate_mac_p.h @@ -76,6 +76,8 @@ QT_FORWARD_DECLARE_CLASS(QWidgetData) - (void)windowDidResignMain:(NSNotification*)notification; - (void)windowDidBecomeKey:(NSNotification*)notification; - (void)windowDidResignKey:(NSNotification*)notification; +- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu; +- (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event from:(NSPoint)dragImageLocation withPasteboard:(NSPasteboard *)pasteboard; @end @protocol NSDrawerDelegate diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 58252ca..79f55a1 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3017,6 +3017,12 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset) #else QMacCocoaAutoReleasePool pool; NSButton *iconButton = [qt_mac_window_for(q) standardWindowButton:NSWindowDocumentIconButton]; + if (iconButton == nil) { + QCFString string(q->windowTitle()); + const NSString *tmpString = reinterpret_cast((CFStringRef)string); + [qt_mac_window_for(q) setRepresentedURL:[NSURL fileURLWithPath:tmpString]]; + iconButton = [qt_mac_window_for(q) standardWindowButton:NSWindowDocumentIconButton]; + } if (icon.isNull()) { [iconButton setImage:nil]; } else { -- cgit v0.12 From ab473d6a8e4fa619537c4cdaaf1b6a9d8544b30a Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 2 Nov 2009 15:30:55 +0100 Subject: Fixed holes in thick strokes. When stroking small paths with a thick pen, it looked like the winding fill rule was ignored. The bug was in the stroke generator which generated paths where the winding number could incorrectly become zero. Task-number: QTBUG-1537 Reviewed-by: Gunnar --- src/gui/painting/qstroker.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index c57b3c1..228a6b1 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -452,6 +452,17 @@ void QStroker::joinPoints(qfixed focal_x, qfixed focal_y, const QLineF &nextLine #endif if (join == FlatJoin) { + QLineF prevLine(qt_fixed_to_real(m_back2X), qt_fixed_to_real(m_back2Y), + qt_fixed_to_real(m_back1X), qt_fixed_to_real(m_back1Y)); + QPointF isect; + QLineF::IntersectType type = prevLine.intersect(nextLine, &isect); + QLineF shortCut(prevLine.p2(), nextLine.p1()); + qreal angle = shortCut.angleTo(prevLine); + if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) { + emitLineTo(focal_x, focal_y); + emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); + return; + } emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); @@ -468,8 +479,8 @@ void QStroker::joinPoints(qfixed focal_x, qfixed focal_y, const QLineF &nextLine // If we are on the inside, do the short cut... QLineF shortCut(prevLine.p2(), nextLine.p1()); qreal angle = shortCut.angleTo(prevLine); - if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) { + emitLineTo(focal_x, focal_y); emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); return; } @@ -509,8 +520,9 @@ void QStroker::joinPoints(qfixed focal_x, qfixed focal_y, const QLineF &nextLine qfixed offset = m_strokeWidth / 2; QLineF shortCut(prevLine.p2(), nextLine.p1()); - qreal angle = prevLine.angle(shortCut); + qreal angle = shortCut.angleTo(prevLine); if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) { + emitLineTo(focal_x, focal_y); emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); return; } @@ -581,6 +593,13 @@ void QStroker::joinPoints(qfixed focal_x, qfixed focal_y, const QLineF &nextLine qt_real_to_fixed(l1.x1()), qt_real_to_fixed(l1.y1())); } else if (join == SvgMiterJoin) { + QLineF shortCut(prevLine.p2(), nextLine.p1()); + qreal angle = shortCut.angleTo(prevLine); + if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) { + emitLineTo(focal_x, focal_y); + emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); + return; + } QLineF miterLine(QPointF(qt_fixed_to_real(focal_x), qt_fixed_to_real(focal_y)), isect); if (miterLine.length() > qt_fixed_to_real(m_strokeWidth * m_miterLimit) / 2) { -- cgit v0.12 From 11dea4a8b227801c110f791f350632bf6f0c958d Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 2 Nov 2009 15:25:19 +0100 Subject: Fixed spacing display in QListView with wrapped text. The spacing was not being substracted from the viewport width when calculating the available space for items. Auto-test included. Reviewed-by: Olivier Task-number: QTBUG-2678 --- src/gui/itemviews/qlistview.cpp | 10 +++++----- tests/auto/qlistview/tst_qlistview.cpp | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index d680af8..15db9a6 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -357,7 +357,7 @@ QListView::LayoutMode QListView::layoutMode() const /*! \property QListView::spacing - \brief the space between items in the layout + \brief the space around the items in the layout This property is the size of the empty space that is padded around an item in the layout. @@ -972,9 +972,9 @@ void QListView::paintEvent(QPaintEvent *e) option.rect = visualRect(*it); if (flow() == TopToBottom) - option.rect.setWidth(qMin(viewport()->size().width(), option.rect.width())); + option.rect.setWidth(qMin(viewport()->size().width() - 2 * d->spacing(), option.rect.width())); else - option.rect.setHeight(qMin(viewport()->size().height(), option.rect.height())); + option.rect.setHeight(qMin(viewport()->size().height() - 2 * d->spacing(), option.rect.height())); option.state = state; if (selections && selections->isSelected(*it)) @@ -1837,14 +1837,14 @@ void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step) { horizontalScrollBar()->setSingleStep(step.width() + spacing()); horizontalScrollBar()->setPageStep(viewport()->width()); - horizontalScrollBar()->setRange(0, contentsSize.width() - viewport()->width()); + horizontalScrollBar()->setRange(0, contentsSize.width() - viewport()->width() - 2 * spacing()); } void QCommonListViewBase::updateVerticalScrollBar(const QSize &step) { verticalScrollBar()->setSingleStep(step.height() + spacing()); verticalScrollBar()->setPageStep(viewport()->height()); - verticalScrollBar()->setRange(0, contentsSize.height() - viewport()->height()); + verticalScrollBar()->setRange(0, contentsSize.height() - viewport()->height() - 2 * spacing()); } void QCommonListViewBase::scrollContentsBy(int dx, int dy, bool /*scrollElasticBand*/) diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index a5ff153..246f092 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -121,6 +121,7 @@ private slots: void taskQTBUG_2233_scrollHiddenItems(); void taskQTBUG_633_changeModelData(); void taskQTBUG_435_deselectOnViewportClick(); + void taskQTBUG_2678_spacingAndWrappedText(); }; // Testing get/set functions @@ -1876,5 +1877,19 @@ void tst_QListView::taskQTBUG_435_deselectOnViewportClick() QVERIFY(!view.selectionModel()->hasSelection()); } +void tst_QListView::taskQTBUG_2678_spacingAndWrappedText() +{ + static const QString lorem("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."); + QStringListModel model(QStringList() << lorem << lorem << "foo" << lorem << "bar" << lorem << lorem); + QListView w; + w.setModel(&model); + w.setViewMode(QListView::ListMode); + w.setWordWrap(true); + w.setSpacing(10); + w.show(); + QTest::qWaitForWindowShown(&w); + QCOMPARE(w.horizontalScrollBar()->minimum(), w.horizontalScrollBar()->maximum()); +} + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" -- cgit v0.12 From 243163c3f61c79146c37da0a4da4bacafa8e1321 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 2 Nov 2009 16:06:06 +0100 Subject: Fixed test, QGraphicsSourceEffect::pixmap(), caching caused failure. Reviewed-by: Samuel --- src/gui/effects/qgraphicseffect.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 3a6bab5..f24d424 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -97,6 +97,8 @@ */ #include "qgraphicseffect_p.h" +#include "private/qgraphicsitem_p.h" + #include #include @@ -260,6 +262,12 @@ QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offse return ((QGraphicsPixmapItem *) item)->pixmap(); } + if (system == Qt::DeviceCoordinates && item + && !static_cast(d_func())->info) { + qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context"); + return QPixmap(); + } + QPixmap pm; if (d->m_cachedSystem == system && d->m_cachedMode == mode) QPixmapCache::find(d->m_cacheKey, &pm); -- cgit v0.12 From c4ce16e1eaa4504787f4cc739f3af7d1fdea8351 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 2 Nov 2009 16:11:49 +0100 Subject: Fixed main window closing when subwindows cancel their close events. Reviewed-by: Trust Me Reported-here: http://lists.trolltech.com/pipermail/qt4-preview-feedback /2009-October/001023.html --- examples/mainwindows/mdi/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/mainwindows/mdi/mainwindow.cpp b/examples/mainwindows/mdi/mainwindow.cpp index 712d91f..edb33b7 100644 --- a/examples/mainwindows/mdi/mainwindow.cpp +++ b/examples/mainwindows/mdi/mainwindow.cpp @@ -71,7 +71,7 @@ MainWindow::MainWindow() void MainWindow::closeEvent(QCloseEvent *event) { mdiArea->closeAllSubWindows(); - if (activeMdiChild()) { + if (mdiArea->currentSubWindow()) { event->ignore(); } else { writeSettings(); -- cgit v0.12 From 915f20bb167aa09ca8c8db478a2a78d5e357b67e Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 2 Nov 2009 16:58:56 +0100 Subject: Better cosmetic pen scaling for beziers in tristroker. Reviewed-By: Samuel --- src/opengl/gl2paintengineex/qtriangulatingstroker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp index ad18a51..1163eba 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp @@ -114,7 +114,7 @@ void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen) if (m_join_style == Qt::RoundJoin) m_join_style = Qt::MiterJoin; m_curvyness_add = 0.5; - m_curvyness_mul = CURVE_FLATNESS; + m_curvyness_mul = CURVE_FLATNESS / m_inv_scale; m_roundness = 1; } else if (cosmetic) { m_curvyness_add = realWidth / 2; -- cgit v0.12 From 803fb60b1e98beddf4ebb8ea1a9224889c392e4e Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 2 Nov 2009 17:34:41 +0100 Subject: Doc: Added a note about QApplication::installTranslator(). Reviewed-by: Alessandro Portale --- doc/src/internationalization/i18n.qdoc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/src/internationalization/i18n.qdoc b/doc/src/internationalization/i18n.qdoc index 1a2839d..2d1b8cc 100644 --- a/doc/src/internationalization/i18n.qdoc +++ b/doc/src/internationalization/i18n.qdoc @@ -439,9 +439,13 @@ application language. The default event handler for QWidget subclasses responds to the - QEvent::LanguageChange event, and will call this function when necessary; - other application components can also force widgets to update themselves - by posting the \l{QEvent::LanguageChange}{LanguageChange} event to them. + QEvent::LanguageChange event, and will call this function when necessary. + + \l{QEvent::LanguageChange}{LanguageChange} events are posted when a new + translation is installed using the QCoreApplication::installTranslator() + function. Additionally, other application components can also force + widgets to update themselves by posting LanguageChange events to them. + \section1 Translating Non-Qt Classes -- cgit v0.12 From 83e497fdae56e11c79d913cdc665e78615291e9c Mon Sep 17 00:00:00 2001 From: Jure Repinc Date: Mon, 2 Nov 2009 17:48:36 +0100 Subject: Updated Slovenian translation of Qt libraries Merge-request: 1977 Reviewed-by: Oswald Buddenhagen --- translations/qt_sl.ts | 1785 +++++++++++++++++++++++++++---------------------- 1 file changed, 986 insertions(+), 799 deletions(-) diff --git a/translations/qt_sl.ts b/translations/qt_sl.ts index 517ce71..c7684e3 100644 --- a/translations/qt_sl.ts +++ b/translations/qt_sl.ts @@ -12,7 +12,7 @@ FakeReply - + Fake error ! Lažna napaka. @@ -23,14 +23,6 @@
- InputPrivate - - - PUSH: read in bytes = %1 (frames=%2) - - - - Phonon:: @@ -117,10 +109,10 @@ da je nameščen paket libgstreamer-plugins-base. Manjka potreben kodek. Za predvajanje te vsebine morate namestiti sledeče kodeke: %0 - + - + @@ -129,12 +121,12 @@ da je nameščen paket libgstreamer-plugins-base. Ni moč odpreti večpredstavnostnega vira. - + Invalid source type. Neveljavna vrsta vira. - + Could not locate media source. Ni moč najti večpredstavnostnega vira. @@ -150,11 +142,63 @@ da je nameščen paket libgstreamer-plugins-base. + Phonon::MMF + + + Audio Output + Predvajanje zvoka + + + + The audio output device + Naprava za predvajanje zvoka + + + Phonon::MMF::AudioEqualizer - + Frequency band, %1 Hz - + Frekvenčni pas, %1 Hz + + + + Phonon::MMF::EffectFactory + + + audio equalizer + izenačevalnik zvoka + + + + Bass boost + Ojačanje basov + + + + Distance Attenuation + Utišanje zaradi razdalje + + + + + Environmental Reverb + Okoljsko odmevanje + + + + Loudness + Glasnost + + + + Source Orientation + Usmerjenost vira + + + + Stereo Widening + Razširitev sterea @@ -888,7 +932,7 @@ v Dejanje na vtičnici ni podprto - + Socket operation timed out Čas za dejanje na vtičnici je potekel @@ -922,6 +966,14 @@ v + QAccessibleButton + + + Press + Pritisni + + + QApplication @@ -939,7 +991,7 @@ v Napaka nezdružljivosti knjižnice Qt - + QT_LAYOUT_DIRECTION Translate this string to the string 'LTR' in left-to-right languages or to 'RTL' in right-to-left languages (such as Hebrew and Arabic) to get proper widget layout. LTR @@ -951,117 +1003,6 @@ v - QAudioInputPrivate - - - QAudioInput: snd_pcm_hw_params_any: err = %1 - - - - - QAudioInput: snd_pcm_hw_params_set_rate_resample: err = %1 - - - - - QAudioInput: snd_pcm_hw_params_set_access: err = %1 - - - - - QAudioInput: snd_pcm_hw_params_set_format: err = %1 - - - - - QAudioInput: snd_pcm_hw_params_set_channels: err = %1 - - - - - QAudioInput: snd_pcm_hw_params_set_rate_near: err = %1 - - - - - QAudioInput: snd_pcm_hw_params_set_buffer_time_near: err = %1 - - - - - QAudioInput: snd_pcm_hw_params_set_period_time_near: err = %1 - - - - - QAudioInput: snd_pcm_hw_params_set_periods_near: err = %1 - - - - - QAudioInput: snd_pcm_hw_params: err = %1 - - - - - PULL: read in bytes = %1 (frames=%2) - - - - - QAudioOutputPrivate - - - QAudioOutput: snd_pcm_hw_params_any: err = %1 - - - - - QAudioOutput: snd_pcm_hw_params_set_rate_resample: err = %1 - - - - - QAudioOutput: snd_pcm_hw_params_set_access: err = %1 - - - - - QAudioOutput: snd_pcm_hw_params_set_format: err = %1 - - - - - QAudioOutput: snd_pcm_hw_params_set_channels: err = %1 - - - - - QAudioOutput: snd_pcm_hw_params_set_rate_near: err = %1 - - - - - QAudioOutput: snd_pcm_hw_params_set_buffer_time_near: err = %1 - - - - - QAudioOutput: snd_pcm_hw_params_set_period_time_near: err = %1 - - - - - QAudioOutput: snd_pcm_hw_params_set_periods_near: err = %1 - - - - - QAudioOutput: snd_pcm_hw_params: err = %1 - - - - QAxSelect @@ -1087,7 +1028,7 @@ v QCheckBox - + Uncheck Odznači @@ -1105,7 +1046,7 @@ v QColorDialog - + Hu&e: &Odtenek: @@ -1145,7 +1086,7 @@ v Izberite barvo - + &Basic colors &Osnovne barve @@ -1214,7 +1155,7 @@ v %1: does not exist QSystemSemaphore - %1: ne obstaja + %1: ne obstaja @@ -1345,7 +1286,7 @@ v - + OK V redu @@ -1544,7 +1485,7 @@ v Usodna napaka: - + &Show this message again &To sporočilo naslednjič spet prikaži @@ -1565,7 +1506,7 @@ v Will not rename sequential file using block copy - + Sekvenčna datoteka ne bo preimenovana z uporabo kopiranja blokov @@ -1596,7 +1537,7 @@ v QFileDialog - + All Files (*) Vse datoteke (*) @@ -1724,7 +1665,7 @@ Ali jo kljub temu želite izbrisati? Ni bilo moč izbrisati mape. - + Recent Places Nedavna mesta @@ -1734,12 +1675,12 @@ Ali jo kljub temu želite izbrisati? Vse datoteke (*.*) - + Save As Shrani kot - + Drive Pogon @@ -1918,50 +1859,50 @@ Ali jo kljub temu želite izbrisati? QFontDatabase - + Normal Normalno - + - + Bold Polkrepko - - + + Demi Bold - + - + Black Črni - + Demi - + Light Lahko - - + + Italic Ležeče - - + + Oblique Nagnjeno @@ -2063,32 +2004,32 @@ Ali jo kljub temu želite izbrisati? Thai - Tajski + Tajska Lao - Laoška + Laoška Tibetan - tibetansko + Tibetanska Myanmar - Mjanmar + Mjanmarska Georgian - gruzijsko + Gruzijska Khmer - Kmersko + Kmerska @@ -2118,7 +2059,7 @@ Ali jo kljub temu želite izbrisati? Symbol - Znak + Simbol @@ -2134,7 +2075,7 @@ Ali jo kljub temu želite izbrisati? QFontDialog - + &Font &Pisava @@ -2174,7 +2115,7 @@ Ali jo kljub temu želite izbrisati? S&istem pisanja - + Select Font Izberite pisavo @@ -2337,13 +2278,9 @@ Ali jo kljub temu želite izbrisati? QHostInfoAgent - - - + - - - + Host not found Ni moč najti gostitelja @@ -2364,20 +2301,20 @@ Ali jo kljub temu želite izbrisati? Neznana napaka - + No host name given - Podano ni bilo nobeno ime gostitelja + Podano ni bilo nobeno ime gostitelja Invalid hostname - Neveljavno ime gostitelja + Neveljavno ime gostitelja QHttp - + @@ -2409,7 +2346,7 @@ Ali jo kljub temu želite izbrisati? Strežnik je nepričakovano prekinil povezavo - + Unknown authentication method Neznan način overjanja @@ -2419,13 +2356,13 @@ Ali jo kljub temu želite izbrisati? Napaka pri pisanju odziva na napravo - + Connection refused Povezava je zavrnjena - + Host %1 not found @@ -2440,7 +2377,7 @@ Ali jo kljub temu želite izbrisati? Zahtevek HTTP ni uspel - + Invalid HTTP response header Neveljavna glava odgovora HTTP @@ -2495,7 +2432,7 @@ Ali jo kljub temu želite izbrisati? Potrebna je overitev - + Connection refused (or timed out) Povezava je bila zavrnjena (ali pa je potekel čas) @@ -2694,7 +2631,7 @@ Ali jo kljub temu želite izbrisati? QIODevice - + Permission denied Nimate dovoljenja @@ -3174,7 +3111,7 @@ Ali jo kljub temu želite izbrisati? QMenuBar - + Actions Dejanja @@ -3527,7 +3464,7 @@ Ali jo kljub temu želite izbrisati? Unable to alloc statement - + Ni moč dodeliti izjave @@ -3553,7 +3490,7 @@ Ali jo kljub temu želite izbrisati? QODBCDriver - + Unable to connect Ni moč vzpostaviti povezave @@ -3586,7 +3523,7 @@ Ali jo kljub temu želite izbrisati? QODBCResult - + QODBCResult::reset: Unable to set 'SQL_CURSOR_STATIC' as statement attribute. Please check your ODBC driver configuration QODBCResult::reset: ni moč nastaviti 'SQL_CURSOR_STATIC' kot lastnosti izjave. Preverite nastavitve gonilnika ODBC @@ -3638,7 +3575,7 @@ Ali jo kljub temu želite izbrisati? QObject - + Invalid hostname Neveljavno ime gostitelja @@ -3668,42 +3605,6 @@ Ali jo kljub temu želite izbrisati? No host name given Podano ni bilo nobeno ime gostitelja - - - audio equalizer - - - - - Bass boost - - - - - Distance Attenuation - - - - - - Environmental Reverb - - - - - Loudness - - - - - Source Orientation - - - - - Stereo Widening - - QPPDOptionsModel @@ -4050,7 +3951,7 @@ Ali jo kljub temu želite izbrisati? US Common #10 Envelope (105 x 241 mm) - + OK V redu @@ -4610,7 +4511,7 @@ Izberite drugo ime datoteke. Čas za dejanje procesa je potekel - + @@ -4826,32 +4727,32 @@ Izberite drugo ime datoteke. ID - + ID Location - + Lokacija Condition - + Pogoj Ignore-count - + Število prezrtij Single-shot - + Enojen zadetek Hit-count - + Število zadetkov @@ -4859,12 +4760,12 @@ Izberite drugo ime datoteke. New - + Nova Delete - Izbriši + Izbriši @@ -4873,17 +4774,17 @@ Izberite drugo ime datoteke. Go to Line - + Pojdi v vrstico Line: - + Vrstica: Interrupt - + Prekini @@ -4893,7 +4794,7 @@ Izberite drugo ime datoteke. Continue - Nadaljuj + Nadaljuj @@ -4903,7 +4804,7 @@ Izberite drugo ime datoteke. Step Into - + Vstopi @@ -4913,7 +4814,7 @@ Izberite drugo ime datoteke. Step Over - + Prestopi @@ -4923,7 +4824,7 @@ Izberite drugo ime datoteke. Step Out - + Izstopi @@ -4933,7 +4834,7 @@ Izberite drugo ime datoteke. Run to Cursor - + Zaženi do kazalca @@ -4943,12 +4844,12 @@ Izberite drugo ime datoteke. Run to New Script - + Zaženi do novega skripta Toggle Breakpoint - + Preklopi prekinitveno točko @@ -4958,22 +4859,22 @@ Izberite drugo ime datoteke. Clear Debug Output - + Počisti razhroščevalni izhod Clear Error Log - + Počisti dnevnik napak Clear Console - + Počisti konzolo &Find in Script... - + Najdi v &skriptu ... @@ -4983,7 +4884,7 @@ Izberite drugo ime datoteke. Find &Next - + Najdi &naslednje @@ -4993,7 +4894,7 @@ Izberite drugo ime datoteke. Find &Previous - + Najdi &predhodno @@ -5008,7 +4909,7 @@ Izberite drugo ime datoteke. Debug - + Razhrošči @@ -5016,32 +4917,32 @@ Izberite drugo ime datoteke. Close - Zapri + Zapri Previous - + Predhodno Next - + Naslednje Case Sensitive - + Občutljivo na velikost črk Whole words - + Cele besede <img src=":/qt/scripttools/debugging/images/wrap.png">&nbsp;Search wrapped - + <img src=":/qt/scripttools/debugging/images/wrap.png">&nbsp;Iskanje se nadaljuje na drugem koncu @@ -5049,12 +4950,12 @@ Izberite drugo ime datoteke. Name - Ime + Ime Value - Vrednost + Vrednost @@ -5062,17 +4963,17 @@ Izberite drugo ime datoteke. Level - + Stopnja Name - Ime + Ime Location - + Lokacija @@ -5080,22 +4981,22 @@ Izberite drugo ime datoteke. Toggle Breakpoint - + Preklopi prekinitveno točko Disable Breakpoint - + Onemogoči prekinitveno točko Enable Breakpoint - + Omogoči prekinitveno točko Breakpoint Condition: - + Pogoj za prelomno točko: @@ -5103,52 +5004,52 @@ Izberite drugo ime datoteke. Loaded Scripts - + Naloženi skripti Breakpoints - + Prelomne točke Stack - + Sklad Locals - + Krajevno Console - + Konzola Debug Output - + Razhroščevalni izhod Error Log - + Dnevnik napak Search - Išči + Išči View - + Videz Qt Script Debugger - + Razhroščevalnik za Qt Script @@ -5156,7 +5057,7 @@ Izberite drugo ime datoteke. Close - Zapri + Zapri @@ -5521,7 +5422,7 @@ Izberite drugo ime datoteke. Bass Boost - + Ojačanje basov @@ -5536,12 +5437,12 @@ Izberite drugo ime datoteke. Treble Up - + Več visokih tonov Treble Down - + Manj visokih tonov @@ -5736,7 +5637,7 @@ Izberite drugo ime datoteke. Select - Izberi + Izberi @@ -5771,17 +5672,17 @@ Izberite drugo ime datoteke. Call - Pokliči + Pokliči Hangup - Odloži + Odloži Flip - Obrni + Obrni @@ -5954,7 +5855,7 @@ Izberite drugo ime datoteke. Exit - Končaj + Končaj @@ -6176,7 +6077,7 @@ Izberite drugo ime datoteke. QTextControl - + &Undo &Razveljavi @@ -6219,7 +6120,7 @@ Izberite drugo ime datoteke. QToolButton - + Press Pritisni @@ -6334,12 +6235,12 @@ Izberite drugo ime datoteke. QWebFrame - + Request cancelled Zahtevek je bil preklican - + Request blocked Zahtevek je bil blokiran @@ -6367,12 +6268,12 @@ Izberite drugo ime datoteke. QWebPage - + Bad HTTP request Napačen zahtevek HTTP - + Submit default label for Submit buttons in forms on web pages Pošlji @@ -6390,7 +6291,7 @@ Izberite drugo ime datoteke. Ponastavi - + This is a searchable index. Enter search keywords: text that appears at the start of nearly-obsolete web pages in the form of a 'searchable index' To je stvarno kazalo z iskanjem. Vnesite iskane besede: @@ -6777,7 +6678,7 @@ Izberite drugo ime datoteke. Movie time scrubber Media controller element - + @@ -6805,7 +6706,7 @@ Izberite drugo ime datoteke. - Remaining move time + Remaining movie time Media controller element Preostali čas filma @@ -6900,7 +6801,7 @@ Izberite drugo ime datoteke. %1 (%2×%3 pik) - + Web Inspector - %2 Web Inspector - %2 @@ -6974,24 +6875,24 @@ Izberite drugo ime datoteke. %n file(s) number of chosen file - %n datotek - %n datotek - %n datotek + %n datoteka + %n datoteki + %n datoteke %n datotek - + JavaScript Alert - %1 Opozorilo JavaScript - %1 - + JavaScript Confirm - %1 Potrditev JavaScript - %1 - + JavaScript Prompt - %1 Poziv JavaScript - %1 @@ -7006,7 +6907,7 @@ Izberite drugo ime datoteke. Kot kaže ima skript na tej strani težavo. Ali želite ustaviti skript? - + Move the cursor to the next character Premakni kazalec na naslednji znak @@ -7215,6 +7116,12 @@ Izberite drugo ime datoteke. Align Right Poravnaj desno + + + Remaining move time + Media controller element + Preostali čas filma + QWhatsThisAction @@ -7227,7 +7134,7 @@ Izberite drugo ime datoteke. QWidget - + * * @@ -7902,20 +7809,20 @@ Izberite drugo ime datoteke. %1 takes at most %n argument(s). %2 is therefore invalid. + %1 potrebuje največ %n argument. %2 zato ni veljavno. + %1 potrebuje največ %n argumenta. %2 zato ni veljavno. + %1 potrebuje največ %n argumente. %2 zato ni veljavno. %1 potrebuje največ %n argumentov. %2 zato ni veljavno. - - - %1 requires at least %n argument(s). %2 is therefore invalid. + %1 potrebuje najmanj %n argument. %2 zato ni veljavno. + %1 potrebuje najmanj %n argumenta. %2 zato ni veljavno. + %1 potrebuje najmanj %n argumente. %2 zato ni veljavno. %1 potrebuje najmanj %n argumentov. %2 zato ni veljavno. - - - @@ -8613,277 +8520,207 @@ Izberite drugo ime datoteke. - - empty particle cannot be derived from non-empty particle - - - - - derived particle is missing element %1 - - - - - derived element %1 is missing value constraint as defined in base particle - - - - - derived element %1 has weaker value constraint than base particle - - - - - fixed value constraint of element %1 differs from value constraint in base particle - - - - - derived element %1 cannot be nillable as base element is not nillable - - - - - block constraints of derived element %1 must not be more weaker than in the base element - - - - - simple type of derived element %1 cannot be validly derived from base element - - - - - complex type of derived element %1 cannot be validly derived from base element - - - - - element %1 is missing in derived particle - - - - - element %1 does not match namespace constraint of wildcard in base particle - - - - - wildcard in derived particle is not a valid subset of wildcard in base particle - - - - - processContent of wildcard in derived particle is weaker than wildcard in base particle - - - - - derived particle allows content that is not allowed in the base particle - - - - %1 has inheritance loop in its base type %2 + %1 has inheritance loop in its base type %2. - circular inheritance of base type %1 + Circular inheritance of base type %1. - circular inheritance of union %1 + Circular inheritance of union %1. - %1 is not allowed to derive from %2 by restriction as the latter defines it as final + %1 is not allowed to derive from %2 by restriction as the latter defines it as final. - %1 is not allowed to derive from %2 by extension as the latter defines it as final + %1 is not allowed to derive from %2 by extension as the latter defines it as final. - base type of simple type %1 cannot be complex type %2 + Base type of simple type %1 cannot be complex type %2. - simple type %1 cannot have direct base type %2 + Simple type %1 cannot have direct base type %2. - simple type %1 is not allowed to have base type %2 + Simple type %1 is not allowed to have base type %2. - simple type %1 can only have simple atomic type as base type + Simple type %1 can only have simple atomic type as base type. - simple type %1 cannot derive from %2 as the latter defines restriction as final + Simple type %1 cannot derive from %2 as the latter defines restriction as final. - variety of item type of %1 must be either atomic or union + Variety of item type of %1 must be either atomic or union. - variety of member types of %1 must be atomic + Variety of member types of %1 must be atomic. - %1 is not allowed to derive from %2 by list as the latter defines it as final + %1 is not allowed to derive from %2 by list as the latter defines it as final. - simple type %1 is only allowed to have %2 facet + Simple type %1 is only allowed to have %2 facet. - base type of simple type %1 must have variety of type list + Base type of simple type %1 must have variety of type list. - base type of simple type %1 has defined derivation by restriction as final + Base type of simple type %1 has defined derivation by restriction as final. - item type of base type does not match item type of %1 + Item type of base type does not match item type of %1. - simple type %1 contains not allowed facet type %2 + Simple type %1 contains not allowed facet type %2. - %1 is not allowed to derive from %2 by union as the latter defines it as final + %1 is not allowed to derive from %2 by union as the latter defines it as final. - %1 is not allowed to have any facets + %1 is not allowed to have any facets. - base type %1 of simple type %2 must have variety of union + Base type %1 of simple type %2 must have variety of union. - base type %1 of simple type %2 is not allowed to have restriction in %3 attribute + Base type %1 of simple type %2 is not allowed to have restriction in %3 attribute. - member type %1 cannot be derived from member type %2 of %3's base type %4 + Member type %1 cannot be derived from member type %2 of %3's base type %4. - derivation method of %1 must be extension because the base type %2 is a simple type + Derivation method of %1 must be extension because the base type %2 is a simple type. - complex type %1 has duplicated element %2 in its content model + Complex type %1 has duplicated element %2 in its content model. - complex type %1 has non-deterministic content + Complex type %1 has non-deterministic content. - attributes of complex type %1 are not a valid extension of the attributes of base type %2: %3 + Attributes of complex type %1 are not a valid extension of the attributes of base type %2: %3. - content model of complex type %1 is not a valid extension of content model of %2 + Content model of complex type %1 is not a valid extension of content model of %2. - complex type %1 must have simple content + Complex type %1 must have simple content. - complex type %1 must have the same simple type as its base class %2 + Complex type %1 must have the same simple type as its base class %2. - complex type %1 cannot be derived from base type %2%3 + Complex type %1 cannot be derived from base type %2%3. - attributes of complex type %1 are not a valid restriction from the attributes of base type %2: %3 + Attributes of complex type %1 are not a valid restriction from the attributes of base type %2: %3. - complex type %1 with simple content cannot be derived from complex base type %2 + Complex type %1 with simple content cannot be derived from complex base type %2. - item type of simple type %1 cannot be a complex type + Item type of simple type %1 cannot be a complex type. - member type of simple type %1 cannot be a complex type + Member type of simple type %1 cannot be a complex type. - %1 is not allowed to have a member type with the same name as itself + %1 is not allowed to have a member type with the same name as itself. - %1 facet collides with %2 facet + %1 facet collides with %2 facet. - %1 facet must have the same value as %2 facet of base type + %1 facet must have the same value as %2 facet of base type. - %1 facet must be equal or greater than %2 facet of base type + %1 facet must be equal or greater than %2 facet of base type. @@ -8895,7 +8732,7 @@ Izberite drugo ime datoteke. - %1 facet must be less than or equal to %2 facet of base type + %1 facet must be less than or equal to %2 facet of base type. @@ -8905,225 +8742,225 @@ Izberite drugo ime datoteke. - unknown notation %1 used in %2 facet + Unknown notation %1 used in %2 facet. - %1 facet contains invalid value %2: %3 + %1 facet contains invalid value %2: %3. - %1 facet cannot be %2 or %3 if %4 facet of base type is %5 + %1 facet cannot be %2 or %3 if %4 facet of base type is %5. - %1 facet cannot be %2 if %3 facet of base type is %4 + %1 facet cannot be %2 if %3 facet of base type is %4. - %1 facet must be less than or equal to %2 facet + %1 facet must be less than or equal to %2 facet. - %1 facet must be less than %2 facet of base type + %1 facet must be less than %2 facet of base type. - %1 facet and %2 facet cannot appear together + %1 facet and %2 facet cannot appear together. - %1 facet must be greater than %2 facet of base type + %1 facet must be greater than %2 facet of base type. - %1 facet must be less than %2 facet + %1 facet must be less than %2 facet. - %1 facet must be greater than or equal to %2 facet of base type + %1 facet must be greater than or equal to %2 facet of base type. - simple type contains not allowed facet %1 + Simple type contains not allowed facet %1. - %1, %2, %3, %4, %5 and %6 facets are not allowed when derived by list + %1, %2, %3, %4, %5 and %6 facets are not allowed when derived by list. - only %1 and %2 facets are allowed when derived by union + Only %1 and %2 facets are allowed when derived by union. - %1 contains %2 facet with invalid data: %3 + %1 contains %2 facet with invalid data: %3. - attribute group %1 contains attribute %2 twice - skupina lastnosti %1 dvakrat vsebuje lastnost %2 + Attribute group %1 contains attribute %2 twice. + Skupina lastnosti %1 dvakrat vsebuje lastnost %2. - attribute group %1 contains two different attributes that both have types derived from %2 + Attribute group %1 contains two different attributes that both have types derived from %2. - attribute group %1 contains attribute %2 that has value constraint but type that inherits from %3 + Attribute group %1 contains attribute %2 that has value constraint but type that inherits from %3. - complex type %1 contains attribute %2 twice - kompleksna vrsta %1 dvakrat vsebuje lastnost %2 + Complex type %1 contains attribute %2 twice. + Kompleksna vrsta %1 dvakrat vsebuje lastnost %2. - complex type %1 contains two different attributes that both have types derived from %2 + Complex type %1 contains two different attributes that both have types derived from %2. - complex type %1 contains attribute %2 that has value constraint but type that inherits from %3 + Complex type %1 contains attribute %2 that has value constraint but type that inherits from %3. - element %1 is not allowed to have a value constraint if its base type is complex + Element %1 is not allowed to have a value constraint if its base type is complex. - element %1 is not allowed to have a value constraint if its type is derived from %2 + Element %1 is not allowed to have a value constraint if its type is derived from %2. - value constraint of element %1 is not of elements type: %2 + Value constraint of element %1 is not of elements type: %2. - element %1 is not allowed to have substitution group affiliation as it is no global element + Element %1 is not allowed to have substitution group affiliation as it is no global element. - type of element %1 cannot be derived from type of substitution group affiliation + Type of element %1 cannot be derived from type of substitution group affiliation. - value constraint of attribute %1 is not of attributes type: %2 + Value constraint of attribute %1 is not of attributes type: %2. - attribute %1 has value constraint but has type derived from %2 + Attribute %1 has value constraint but has type derived from %2. - %1 attribute in derived complex type must be %2 like in base type + %1 attribute in derived complex type must be %2 like in base type. - attribute %1 in derived complex type must have %2 value constraint like in base type + Attribute %1 in derived complex type must have %2 value constraint like in base type. - attribute %1 in derived complex type must have the same %2 value constraint like in base type + Attribute %1 in derived complex type must have the same %2 value constraint like in base type. - attribute %1 in derived complex type must have %2 value constraint + Attribute %1 in derived complex type must have %2 value constraint. - processContent of base wildcard must be weaker than derived wildcard + processContent of base wildcard must be weaker than derived wildcard. - element %1 exists twice with different types - element %1 obstaja dvakrat, z različnima vrstama + Element %1 exists twice with different types. + Element %1 obstaja dvakrat, z različnima vrstama. - particle contains non-deterministic wildcards + Particle contains non-deterministic wildcards. - base attribute %1 is required but derived attribute is not + Base attribute %1 is required but derived attribute is not. - type of derived attribute %1 cannot be validly derived from type of base attribute + Type of derived attribute %1 cannot be validly derived from type of base attribute. - value constraint of derived attribute %1 does not match value constraint of base attribute + Value constraint of derived attribute %1 does not match value constraint of base attribute. - derived attribute %1 does not exists in the base definition + Derived attribute %1 does not exists in the base definition. - derived attribute %1 does not match the wildcard in the base definition + Derived attribute %1 does not match the wildcard in the base definition. - base attribute %1 is required but missing in derived definition + Base attribute %1 is required but missing in derived definition. - derived definition contains an %1 element that does not exists in the base definition + Derived definition contains an %1 element that does not exists in the base definition - derived wildcard is not a subset of the base wildcard + Derived wildcard is not a subset of the base wildcard. @@ -9133,905 +8970,1255 @@ Izberite drugo ime datoteke. - attribute %1 from base type is missing in derived type + Attribute %1 from base type is missing in derived type. - type of derived attribute %1 differs from type of base attribute + Type of derived attribute %1 differs from type of base attribute. - base definition contains an %1 element that is missing in the derived definition + Base definition contains an %1 element that is missing in the derived definition - - can not process unknown element %1, expected elements are: %2 - ni moč obdelati neznanega elementa %1, pričakovani elementi so: %2 - - - - element %1 is not allowed in this scope, possible elements are: %2 - element %1 v tem obsegu ni dovoljen, možni elementi so: %2 + + %1 references unknown %2 or %3 element %4. + - - child element is missing in that scope, possible child elements are: %1 - v tem obsegu manjka podelement, možni podelementi so: %1 + + %1 references identity constraint %2 that is no %3 or %4 element. + - - document is not a XML schema - dokument ni shema XML + + %1 has a different number of fields from the identity constraint %2 that it references. + - - %1 attribute of %2 element contains invalid content: {%3} is not a value of type %4 - lastnost %1 elementa %2 vsebuje neveljavno vsebino: {%3} ni vrednost vrste %4 + + Base type %1 of %2 element cannot be resolved. + - - %1 attribute of %2 element contains invalid content: {%3} - lastnost %1 elementa %2 vsebuje neveljavno vsebino: {%3} + + Item type %1 of %2 element cannot be resolved. + - - target namespace %1 of included schema is different from the target namespace %2 as defined by the including schema + + Member type %1 of %2 element cannot be resolved. - - - target namespace %1 of imported schema is different from the target namespace %2 as defined by the importing schema + + + + Type %1 of %2 element cannot be resolved. - - %1 element is not allowed to have the same %2 attribute value as the target namespace %3 + + Base type %1 of complex type cannot be resolved. - - %1 element without %2 attribute is not allowed inside schema without target namespace + + %1 cannot have complex base type that has a %2. - - - %1 element is not allowed inside %2 element if %3 attribute is present - element %1 znotraj elementa %2 ni dovoljen, če je prisotna lastnost %3 + + Content model of complex type %1 contains %2 element so it cannot be derived by extension from a non-empty type. + - - - - %1 element has neither %2 attribute nor %3 child element - element %1 nima niti lastnosti %2 niti podelementa %3 + + Complex type %1 cannot be derived by extension from %2 as the latter contains %3 element in its content model. + - - - - - - - - - - - - - - - %1 element with %2 child element must not have a %3 attribute - element %1 s podelementom %2 ne sme imeti lastnosti %3 + + Type of %1 element must be a simple type, %2 is not. + Vrsta elementa %1 mora biti preprosta, %2 to ni. - - %1 attribute of %2 element must be %3 or %4 - lastnost %1 elementa %2 mora biti %3 ali %4 + + Substitution group %1 of %2 element cannot be resolved. + - - %1 attribute of %2 element must have a value of %3 - lastnost %1 elementa %2 mora imeti vrednost %3 + + Substitution group %1 has circular definition. + + - - %1 attribute of %2 element must have a value of %3 or %4 - lastnost %1 elementa %2 mora imeti vrednost %3 ali %4 + Duplicated element names %1 in %2 element. + Podvojeni imeni elementov %1 v elementu %2. - - - - - - - - - - - - - - - %1 element must not have %2 and %3 attribute together - element %1 hkrati ne sme imeti lastnosti %2 in %3 + + + + + Reference %1 of %2 element cannot be resolved. + - - - content of %1 attribute of %2 element must not be from namespace %3 - vsebina lastnosti %1 elementa %2 ne sme biti iz imenskega prostora %3 + + Circular group reference for %1. + - - - %1 attribute of %2 element must not be %3 - lastnost %1 elementa %2 ne sme biti %3 + + %1 element is not allowed in this scope + Element %1 v tem obsegu ni dovoljen - - %1 attribute of %2 element must have the value %3 because the %4 attribute is set + + %1 element cannot have %2 attribute with value other than %3. - - specifying use='prohibited' inside an attribute group has no effect + + %1 element cannot have %2 attribute with value other than %3 or %4. - - %1 element must have either %2 or %3 attribute - element %1 mora imeti lastnost %2 ali %3 + + %1 or %2 attribute of reference %3 does not match with the attribute declaration %4. + - - %1 element must have either %2 attribute or %3 or %4 as child element + + Attribute group %1 has circular reference. - - %1 element requires either %2 or %3 attribute - element %1 potrebuje vsaj lastnost %2 ali %3 + + %1 attribute in %2 must have %3 use like in base type %4. + - - text or entity references not allowed inside %1 element + + Attribute wildcard of %1 is not a valid restriction of attribute wildcard of base type %2. - - - %1 attribute of %2 element must contain %3, %4 or a list of URIs + + %1 has attribute wildcard but its base type %2 has not. - - %1 element is not allowed in this context - element %1 v tem kontekstu ni dovoljen + + Union of attribute wildcard of type %1 and attribute wildcard of its base type %2 is not expressible. + - - %1 attribute of %2 element has larger value than %3 attribute + + Enumeration facet contains invalid content: {%1} is not a value of type %2. - - prefix of qualified name %1 is not defined + + Namespace prefix of qualified name %1 is not defined. - - - %1 attribute of %2 element must either contain %3 or the other values + + + %1 element %2 is not a valid restriction of the %3 element it redefines: %4. - - component with id %1 has been defined previously - komponenta z ID-jem %1 je že bila definirana + + Empty particle cannot be derived from non-empty particle. + - - element %1 already defined - element %1 je že definiran + + Derived particle is missing element %1. + - - attribute %1 already defined - lastnost %1 je že definirana + + Derived element %1 is missing value constraint as defined in base particle. + - - type %1 already defined - vrsta %1 je že definirana + + Derived element %1 has weaker value constraint than base particle. + - - attribute group %1 already defined - skupina lastnosti %1 je že definirana + + Fixed value constraint of element %1 differs from value constraint in base particle. + - - element group %1 already defined - skupina elementov %1 je že definirana + + Derived element %1 cannot be nillable as base element is not nillable. + - - notation %1 already defined - zapis %1 je že definiran + + Block constraints of derived element %1 must not be more weaker than in the base element. + - identity constraint %1 already defined + Simple type of derived element %1 cannot be validly derived from base element. - - duplicated facets in simple type %1 + + Complex type of derived element %1 cannot be validly derived from base element. - - %1 references unknown %2 or %3 element %4 + + Element %1 is missing in derived particle. - - %1 references identity constraint %2 that is no %3 or %4 element + + Element %1 does not match namespace constraint of wildcard in base particle. - - %1 has a different number of fields from the identity constraint %2 that it references + + Wildcard in derived particle is not a valid subset of wildcard in base particle. - - base type %1 of %2 element cannot be resolved + + processContent of wildcard in derived particle is weaker than wildcard in base particle. - - item type %1 of %2 element cannot be resolved + + Derived particle allows content that is not allowed in the base particle. - - member type %1 of %2 element cannot be resolved - + + Can not process unknown element %1, expected elements are: %2. + Ni moč obdelati neznanega elementa %1, pričakovani elementi so: %2. - - - - type %1 of %2 element cannot be resolved - + + Element %1 is not allowed in this scope, possible elements are: %2. + Element %1 v tem obsegu ni dovoljen, možni elementi so: %2. - - base type %1 of complex type cannot be resolved - + + Child element is missing in that scope, possible child elements are: %1. + V tem obsegu manjka podelement, možni podelementi so: %1. - - %1 cannot have complex base type that has a %2 - + + Document is not a XML schema. + Dokument ni shema XML. - - content model of complex type %1 contains %2 element so it cannot be derived by extension from a non-empty type - + + %1 attribute of %2 element contains invalid content: {%3} is not a value of type %4. + Lastnost %1 elementa %2 vsebuje neveljavno vsebino: {%3} ni vrednost vrste %4. - complex type %1 cannot be derived by extension from %2 as the latter contains %3 element in its content model - + %1 attribute of %2 element contains invalid content: {%3}. + Lastnost %1 elementa %2 vsebuje neveljavno vsebino: {%3}. - - type of %1 element must be a simple type, %2 is not - vrsta elementa %1 mora biti preprosta, %2 to ni + + Target namespace %1 of included schema is different from the target namespace %2 as defined by the including schema. + - - substitution group %1 of %2 element cannot be resolved + + + Target namespace %1 of imported schema is different from the target namespace %2 as defined by the importing schema. - - substitution group %1 has circular definition + + %1 element is not allowed to have the same %2 attribute value as the target namespace %3. - + + %1 element without %2 attribute is not allowed inside schema without target namespace. + + + + + + %1 element is not allowed inside %2 element if %3 attribute is present. + Element %1 znotraj elementa %2 ni dovoljen, če je prisotna lastnost %3. + + + + + + %1 element has neither %2 attribute nor %3 child element. + Element %1 nima niti lastnosti %2 niti podelementa %3. + + + + + - duplicated element names %1 in %2 element - podvojeni imeni elementov %1 v elementu %2 + + + + + + + + + + + %1 element with %2 child element must not have a %3 attribute. + Element %1 s podelementom %2 ne sme imeti lastnosti %3. - - - - - reference %1 of %2 element cannot be resolved - + + %1 attribute of %2 element must be %3 or %4. + Lastnost %1 elementa %2 mora biti %3 ali %4. - - circular group reference for %1 - + + %1 attribute of %2 element must have a value of %3. + Lastnost %1 elementa %2 mora imeti vrednost %3. - - %1 element is not allowed in this scope - element %1 v tem obsegu ni dovoljen + + + %1 attribute of %2 element must have a value of %3 or %4. + Lastnost %1 elementa %2 mora imeti vrednost %3 ali %4. - - %1 element cannot have %2 attribute with value other than %3 - + + + + + + + + + + + + + + + %1 element must not have %2 and %3 attribute together. + Element %1 hkrati ne sme imeti lastnosti %2 in %3. - - %1 element cannot have %2 attribute with value other than %3 or %4 + + + Content of %1 attribute of %2 element must not be from namespace %3. + Vsebina lastnosti %1 elementa %2 ne sme biti iz imenskega prostora %3. + + + + + %1 attribute of %2 element must not be %3. + Lastnost %1 elementa %2 ne sme biti %3. + + + + %1 attribute of %2 element must have the value %3 because the %4 attribute is set. - - %1 or %2 attribute of reference %3 does not match with the attribute declaration %4 + + Specifying use='prohibited' inside an attribute group has no effect. - - attribute group %1 has circular reference + + %1 element must have either %2 or %3 attribute. + Element %1 mora imeti lastnost %2 ali %3. + + + + %1 element must have either %2 attribute or %3 or %4 as child element. - - %1 attribute in %2 must have %3 use like in base type %4 + + %1 element requires either %2 or %3 attribute. + Element %1 potrebuje vsaj lastnost %2 ali %3. + + + + Text or entity references not allowed inside %1 element - - attribute wildcard of %1 is not a valid restriction of attribute wildcard of base type %2 + + + %1 attribute of %2 element must contain %3, %4 or a list of URIs. - - %1 has attribute wildcard but its base type %2 has not + + %1 element is not allowed in this context. + Element %1 v tem kontekstu ni dovoljen. + + + + %1 attribute of %2 element has larger value than %3 attribute. - - union of attribute wildcard of type %1 and attribute wildcard of its base type %2 is not expressible + + Prefix of qualified name %1 is not defined. - - enumeration facet contains invalid content: {%1} is not a value of type %2 + + + %1 attribute of %2 element must either contain %3 or the other values. - - namespace prefix of qualified name %1 is not defined + + Component with id %1 has been defined previously. + Komponenta z ID-jem %1 je že bila definirana. + + + + Element %1 already defined. + Element %1 je že definiran. + + + + Attribute %1 already defined. + Lastnost %1 je že definirana. + + + + Type %1 already defined. + Vrsta %1 je že definirana. + + + + Attribute group %1 already defined. + Skupina lastnosti %1 je že definirana. + + + + Element group %1 already defined. + Skupina elementov %1 je že definirana. + + + + Notation %1 already defined. + Zapis %1 je že definiran. + + + + Identity constraint %1 already defined. - - - %1 element %2 is not a valid restriction of the %3 element it redefines: %4 + + Duplicated facets in simple type %1. - %1 is not valid according to %2 - %1 glede na %2 ni veljaven + %1 is not valid according to %2. + %1 glede na %2 ni veljaven. - string content does not match the length facet + String content does not match the length facet. - string content does not match the minLength facet + String content does not match the minLength facet. - string content does not match the maxLength facet + String content does not match the maxLength facet. - string content does not match pattern facet + String content does not match pattern facet. - string content is not listed in the enumeration facet + String content is not listed in the enumeration facet. - signed integer content does not match the maxInclusive facet + Signed integer content does not match the maxInclusive facet. - signed integer content does not match the maxExclusive facet + Signed integer content does not match the maxExclusive facet. - signed integer content does not match the minInclusive facet + Signed integer content does not match the minInclusive facet. - signed integer content does not match the minExclusive facet + Signed integer content does not match the minExclusive facet. - signed integer content is not listed in the enumeration facet + Signed integer content is not listed in the enumeration facet. - signed integer content does not match pattern facet + Signed integer content does not match pattern facet. - signed integer content does not match in the totalDigits facet + Signed integer content does not match in the totalDigits facet. - unsigned integer content does not match the maxInclusive facet + Unsigned integer content does not match the maxInclusive facet. - unsigned integer content does not match the maxExclusive facet + Unsigned integer content does not match the maxExclusive facet. - unsigned integer content does not match the minInclusive facet + Unsigned integer content does not match the minInclusive facet. - unsigned integer content does not match the minExclusive facet + Unsigned integer content does not match the minExclusive facet. - unsigned integer content is not listed in the enumeration facet + Unsigned integer content is not listed in the enumeration facet. - unsigned integer content does not match pattern facet + Unsigned integer content does not match pattern facet. - unsigned integer content does not match in the totalDigits facet + Unsigned integer content does not match in the totalDigits facet. - double content does not match the maxInclusive facet + Double content does not match the maxInclusive facet. - double content does not match the maxExclusive facet + Double content does not match the maxExclusive facet. - double content does not match the minInclusive facet + Double content does not match the minInclusive facet. - double content does not match the minExclusive facet + Double content does not match the minExclusive facet. - double content is not listed in the enumeration facet + Double content is not listed in the enumeration facet. - double content does not match pattern facet + Double content does not match pattern facet. - decimal content does not match in the fractionDigits facet + Decimal content does not match in the fractionDigits facet. - decimal content does not match in the totalDigits facet + Decimal content does not match in the totalDigits facet. - date time content does not match the maxInclusive facet + Date time content does not match the maxInclusive facet. - date time content does not match the maxExclusive facet + Date time content does not match the maxExclusive facet. - date time content does not match the minInclusive facet + Date time content does not match the minInclusive facet. - date time content does not match the minExclusive facet + Date time content does not match the minExclusive facet. - date time content is not listed in the enumeration facet + Date time content is not listed in the enumeration facet. - date time content does not match pattern facet + Date time content does not match pattern facet. - duration content does not match the maxInclusive facet + Duration content does not match the maxInclusive facet. - duration content does not match the maxExclusive facet + Duration content does not match the maxExclusive facet. - duration content does not match the minInclusive facet + Duration content does not match the minInclusive facet. - duration content does not match the minExclusive facet + Duration content does not match the minExclusive facet. - duration content is not listed in the enumeration facet + Duration content is not listed in the enumeration facet. - duration content does not match pattern facet + Duration content does not match pattern facet. - boolean content does not match pattern facet + Boolean content does not match pattern facet. - binary content does not match the length facet + Binary content does not match the length facet. - binary content does not match the minLength facet + Binary content does not match the minLength facet. - binary content does not match the maxLength facet + Binary content does not match the maxLength facet. - binary content is not listed in the enumeration facet + Binary content is not listed in the enumeration facet. - invalid QName content: %1 - neveljavna vsebina QName: %1 + Invalid QName content: %1. + Neveljavna vsebina QName: %1. - QName content is not listed in the enumeration facet + QName content is not listed in the enumeration facet. - QName content does not match pattern facet + QName content does not match pattern facet. - notation content is not listed in the enumeration facet + Notation content is not listed in the enumeration facet. - list content does not match length facet + List content does not match length facet. - list content does not match minLength facet + List content does not match minLength facet. - list content does not match maxLength facet + List content does not match maxLength facet. - list content is not listed in the enumeration facet + List content is not listed in the enumeration facet. - list content does not match pattern facet + List content does not match pattern facet. - union content is not listed in the enumeration facet + Union content is not listed in the enumeration facet. - union content does not match pattern facet + Union content does not match pattern facet. - data of type %1 are not allowed to be empty - podatki vrste %1 ne smejo biti prazni + Data of type %1 are not allowed to be empty. + Podatki vrste %1 ne smejo biti prazni. - element %1 is missing child element - elementu %1 manjka podelement + Element %1 is missing child element. + Elementu %1 manjka podelement. - there is one IDREF value with no corresponding ID: %1 + There is one IDREF value with no corresponding ID: %1. - loaded schema file is invalid + Loaded schema file is invalid. - %1 contains invalid data - %1 vsebuje neveljavne podatke + %1 contains invalid data. + %1 vsebuje neveljavne podatke. - xsi:schemaLocation namespace %1 has already appeared earlier in the instance document + xsi:schemaLocation namespace %1 has already appeared earlier in the instance document. - xsi:noNamespaceSchemaLocation cannot appear after the first no-namespace element or attribute + xsi:noNamespaceSchemaLocation cannot appear after the first no-namespace element or attribute. - no schema defined for validation + No schema defined for validation. - no definition for element %1 available - definicija za element %1 ni na voljo + No definition for element %1 available. + Definicija za element %1 ni na voljo. - specified type %1 is not known to the schema + Specified type %1 is not known to the schema. - element %1 is not defined in this scope - element %1 v tem obsegu ni definiran + Element %1 is not defined in this scope. + Element %1 v tem obsegu ni definiran. - declaration for element %1 does not exist - deklaracija elementa %1 ne obstaja + Declaration for element %1 does not exist. + Deklaracija elementa %1 ne obstaja. - element %1 contains invalid content - element %1 vsebuje neveljavno vsebino + Element %1 contains invalid content. + Element %1 vsebuje neveljavno vsebino. - element %1 is declared as abstract - element %1 je deklariran kot abstrakten + Element %1 is declared as abstract. + Element %1 je deklariran kot abstrakten. - element %1 is not nillable + Element %1 is not nillable. - attribute %1 contains invalid data: %2 - + Attribute %1 contains invalid data: %2 + Lastnost %1 vsebuje neveljavne podatke: %2 - element contains content although it is nillable + Element contains content although it is nillable. - fixed value constrained not allowed if element is nillable + Fixed value constrained not allowed if element is nillable. - specified type %1 is not validly substitutable with element type %2 + Specified type %1 is not validly substitutable with element type %2. - complex type %1 is not allowed to be abstract - kompleksna vrsta %1 ne sme biti abstraktna + Complex type %1 is not allowed to be abstract. + Kompleksna vrsta %1 ne sme biti abstraktna. - element %1 contains not allowed attributes - element %1 vsebuje nedovoljene lastnosti + Element %1 contains not allowed attributes. + Element %1 vsebuje nedovoljene lastnosti. - element %1 contains not allowed child element - element %1 vsebuje nedovoljen podelement + Element %1 contains not allowed child element. + Element %1 vsebuje nedovoljen podelement. - content of element %1 does not match its type definition: %2 - vsebina elementa %1 ne ustreza zanj določeni vrsti: %2 + Content of element %1 does not match its type definition: %2. + Vsebina elementa %1 ne ustreza zanj določeni vrsti: %2. - content of element %1 does not match defined value constraint + Content of element %1 does not match defined value constraint. - element %1 contains not allowed child content - element %1 vsebuje nedovoljeno vsebino v podelementih + Element %1 contains not allowed child content. + Element %1 vsebuje nedovoljeno vsebino v podelementih. - element %1 contains not allowed text content - element %1 vsebuje nedovoljeno besedilno vsebino + Element %1 contains not allowed text content. + Element %1 vsebuje nedovoljeno besedilno vsebino. - element %1 can not contain other elements, as it has a fixed content - element %1 ne more vsebovati drugih elementov, ker ima fiksno vsebino + Element %1 can not contain other elements, as it has a fixed content. + Element %1 ne more vsebovati drugih elementov, ker ima fiksno vsebino. - element %1 is missing required attribute %2 - elementu %1 manjka obvezna lastnost %2 + Element %1 is missing required attribute %2. + Elementu %1 manjka obvezna lastnost %2. - attribute %1 does not match the attribute wildcard + Attribute %1 does not match the attribute wildcard. - declaration for attribute %1 does not exist - deklaracija lastnosti %1 ne obstaja + Declaration for attribute %1 does not exist. + Deklaracija lastnosti %1 ne obstaja. - element %1 contains two attributes of type %2 - element %1 vsebuje dve lastnosti vrste %2 + Element %1 contains two attributes of type %2. + Element %1 vsebuje dve lastnosti vrste %2. - attribute %1 contains invalid content - lastnost %1 vsebuje neveljavno vsebino + Attribute %1 contains invalid content. + Lastnost %1 vsebuje neveljavno vsebino. - element %1 contains unknown attribute %2 - element %1 vsebuje neznano lastnost %2 + Element %1 contains unknown attribute %2. + Element %1 vsebuje neznano lastnost %2. - content of attribute %1 does not match its type definition: %2 + Content of attribute %1 does not match its type definition: %2. - content of attribute %1 does not match defined value constraint + Content of attribute %1 does not match defined value constraint. - non-unique value found for constraint %1 + Non-unique value found for constraint %1. - key constraint %1 contains absent fields + Key constraint %1 contains absent fields. - key constraint %1 contains references nillable element %2 + Key constraint %1 contains references nillable element %2. - no referenced value found for key reference %1 + No referenced value found for key reference %1. - more than one value found for field %1 - za polje %1 je bila najdena več kot ena vrednost + More than one value found for field %1. + Za polje %1 je bila najdena več kot ena vrednost. - field %1 has no simple type - polje %1 nima preproste vrste + Field %1 has no simple type. + Polje %1 nima preproste vrste. - ID value '%1' is not unique - Vrednost ID »%1« ni edinstvena + ID value '%1' is not unique. + Vrednost ID »%1« ni edinstvena. + '%1' attribute contains invalid QName content: %2. + Lastnost »%1« vsebuje neveljavno vsebino QName: %2. + + + + attribute group %1 contains attribute %2 twice + skupina lastnosti %1 dvakrat vsebuje lastnost %2 + + + + complex type %1 contains attribute %2 twice + kompleksna vrsta %1 dvakrat vsebuje lastnost %2 + + + + element %1 exists twice with different types + element %1 obstaja dvakrat, z različnima vrstama + + + + can not process unknown element %1, expected elements are: %2 + ni moč obdelati neznanega elementa %1, pričakovani elementi so: %2 + + + + element %1 is not allowed in this scope, possible elements are: %2 + element %1 v tem obsegu ni dovoljen, možni elementi so: %2 + + + + child element is missing in that scope, possible child elements are: %1 + v tem obsegu manjka podelement, možni podelementi so: %1 + + + + document is not a XML schema + dokument ni shema XML + + + + %1 attribute of %2 element contains invalid content: {%3} is not a value of type %4 + lastnost %1 elementa %2 vsebuje neveljavno vsebino: {%3} ni vrednost vrste %4 + + + + %1 attribute of %2 element contains invalid content: {%3} + lastnost %1 elementa %2 vsebuje neveljavno vsebino: {%3} + + + + %1 element is not allowed inside %2 element if %3 attribute is present + element %1 znotraj elementa %2 ni dovoljen, če je prisotna lastnost %3 + + + + %1 element has neither %2 attribute nor %3 child element + element %1 nima niti lastnosti %2 niti podelementa %3 + + + + %1 element with %2 child element must not have a %3 attribute + element %1 s podelementom %2 ne sme imeti lastnosti %3 + + + + %1 attribute of %2 element must be %3 or %4 + lastnost %1 elementa %2 mora biti %3 ali %4 + + + + %1 attribute of %2 element must have a value of %3 + lastnost %1 elementa %2 mora imeti vrednost %3 + + + + %1 attribute of %2 element must have a value of %3 or %4 + lastnost %1 elementa %2 mora imeti vrednost %3 ali %4 + + + + %1 element must not have %2 and %3 attribute together + element %1 hkrati ne sme imeti lastnosti %2 in %3 + + + + content of %1 attribute of %2 element must not be from namespace %3 + vsebina lastnosti %1 elementa %2 ne sme biti iz imenskega prostora %3 + + + + %1 attribute of %2 element must not be %3 + lastnost %1 elementa %2 ne sme biti %3 + + + + %1 element must have either %2 or %3 attribute + element %1 mora imeti lastnost %2 ali %3 + + + + %1 element requires either %2 or %3 attribute + element %1 potrebuje vsaj lastnost %2 ali %3 + + + + %1 element is not allowed in this context + element %1 v tem kontekstu ni dovoljen + + + + component with id %1 has been defined previously + komponenta z ID-jem %1 je že bila definirana + + + + element %1 already defined + element %1 je že definiran + + + + attribute %1 already defined + lastnost %1 je že definirana + + + + type %1 already defined + vrsta %1 je že definirana + + + + attribute group %1 already defined + skupina lastnosti %1 je že definirana + + + + element group %1 already defined + skupina elementov %1 je že definirana + + + + notation %1 already defined + zapis %1 je že definiran + + + + type of %1 element must be a simple type, %2 is not + vrsta elementa %1 mora biti preprosta, %2 to ni + + + + duplicated element names %1 in %2 element + podvojeni imeni elementov %1 v elementu %2 + + + + %1 is not valid according to %2 + %1 glede na %2 ni veljaven + + + + invalid QName content: %1 + neveljavna vsebina QName: %1 + + + + data of type %1 are not allowed to be empty + podatki vrste %1 ne smejo biti prazni + + + + element %1 is missing child element + elementu %1 manjka podelement + + + + %1 contains invalid data + %1 vsebuje neveljavne podatke + + + + no definition for element %1 available + definicija za element %1 ni na voljo + + + + element %1 is not defined in this scope + element %1 v tem obsegu ni definiran + + + + declaration for element %1 does not exist + deklaracija elementa %1 ne obstaja + + + + element %1 contains invalid content + element %1 vsebuje neveljavno vsebino + + + + element %1 is declared as abstract + element %1 je deklariran kot abstrakten + + + + complex type %1 is not allowed to be abstract + kompleksna vrsta %1 ne sme biti abstraktna + + + + element %1 contains not allowed attributes + element %1 vsebuje nedovoljene lastnosti + + + + element %1 contains not allowed child element + element %1 vsebuje nedovoljen podelement + + + + content of element %1 does not match its type definition: %2 + vsebina elementa %1 ne ustreza zanj določeni vrsti: %2 + + + + element %1 contains not allowed child content + element %1 vsebuje nedovoljeno vsebino v podelementih + + + + element %1 contains not allowed text content + element %1 vsebuje nedovoljeno besedilno vsebino + + + + element %1 can not contain other elements, as it has a fixed content + element %1 ne more vsebovati drugih elementov, ker ima fiksno vsebino + + + + element %1 is missing required attribute %2 + elementu %1 manjka obvezna lastnost %2 + + + + declaration for attribute %1 does not exist + deklaracija lastnosti %1 ne obstaja + + + + element %1 contains two attributes of type %2 + element %1 vsebuje dve lastnosti vrste %2 + + + + attribute %1 contains invalid content + lastnost %1 vsebuje neveljavno vsebino + + + + element %1 contains unknown attribute %2 + element %1 vsebuje neznano lastnost %2 + + + + more than one value found for field %1 + za polje %1 je bila najdena več kot ena vrednost + + + + field %1 has no simple type + polje %1 nima preproste vrste + + + + ID value '%1' is not unique + Vrednost ID »%1« ni edinstvena + + + '%1' attribute contains invalid QName content: %2 - Lastnost »%1« vsebuje neveljavno vsebino QName: %2 + Lastnost »%1« vsebuje neveljavno vsebino QName: %2 -- cgit v0.12 From b72d41cf30f82c74c10c31808907cc990c86efe6 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 3 Nov 2009 08:23:18 +1000 Subject: Protect the OpenVG engine from null QPixmapData objects Reviewed-by: Sarah Smith --- src/openvg/qpaintengine_vg.cpp | 10 ++++++++++ src/openvg/qpixmapdata_vg.cpp | 2 ++ src/openvg/qpixmapfilter_vg.cpp | 12 ++++++++++++ 3 files changed, 24 insertions(+) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 8a485a0..047d9d8 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -1178,6 +1178,8 @@ VGPaintType QVGPaintEnginePrivate::setBrush case Qt::TexturePattern: { // The brush is a texture specified by a QPixmap/QImage. QPixmapData *pd = brush.texture().pixmapData(); + if (!pd) + break; // null QPixmap VGImage vgImg; bool deref = false; if (pd->pixelType() == QPixmapData::BitmapType) { @@ -2893,6 +2895,8 @@ void qt_vg_drawVGImageStencil void QVGPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) { QPixmapData *pd = pm.pixmapData(); + if (!pd) + return; // null QPixmap if (pd->classId() == QPixmapData::OpenVGClass) { Q_D(QVGPaintEngine); QVGPixmapData *vgpd = static_cast(pd); @@ -2910,6 +2914,8 @@ void QVGPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF void QVGPaintEngine::drawPixmap(const QPointF &pos, const QPixmap &pm) { QPixmapData *pd = pm.pixmapData(); + if (!pd) + return; // null QPixmap if (pd->classId() == QPixmapData::OpenVGClass) { Q_D(QVGPaintEngine); QVGPixmapData *vgpd = static_cast(pd); @@ -2985,6 +2991,8 @@ void QVGPaintEngine::drawPixmaps // If the pixmap is not VG, or the transformation is projective, // then fall back to the default implementation. QPixmapData *pd = pixmap.pixmapData(); + if (!pd) + return; // null QPixmap if (pd->classId() != QPixmapData::OpenVGClass || !d->simpleTransform) { QPaintEngineEx::drawPixmaps(drawingData, dataCount, pixmap, hints); return; @@ -3581,6 +3589,8 @@ void QVGCompositionHelper::drawCursorPixmap // Fetch the VGImage from the pixmap if possible. QPixmapData *pd = pixmap.pixmapData(); + if (!pd) + return; // null QPixmap if (pd->classId() == QPixmapData::OpenVGClass) { QVGPixmapData *vgpd = static_cast(pd); if (vgpd->isValid()) diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp index f86e116..3254aa3 100644 --- a/src/openvg/qpixmapdata_vg.cpp +++ b/src/openvg/qpixmapdata_vg.cpp @@ -369,6 +369,8 @@ QImage::Format QVGPixmapData::sourceFormat() const Q_OPENVG_EXPORT VGImage qPixmapToVGImage(const QPixmap& pixmap) { QPixmapData *pd = pixmap.pixmapData(); + if (!pd) + return VG_INVALID_HANDLE; // null QPixmap if (pd->classId() == QPixmapData::OpenVGClass) { QVGPixmapData *vgpd = static_cast(pd); if (vgpd->isValid()) diff --git a/src/openvg/qpixmapfilter_vg.cpp b/src/openvg/qpixmapfilter_vg.cpp index 8e104db..e17c728 100644 --- a/src/openvg/qpixmapfilter_vg.cpp +++ b/src/openvg/qpixmapfilter_vg.cpp @@ -65,6 +65,9 @@ void QVGPixmapConvolutionFilter::draw (QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const { + if (src.isNull()) + return; + if (src.pixmapData()->classId() != QPixmapData::OpenVGClass) { // The pixmap data is not an instance of QVGPixmapData, so fall // back to the default convolution filter implementation. @@ -135,6 +138,9 @@ QVGPixmapColorizeFilter::~QVGPixmapColorizeFilter() void QVGPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const { + if (src.isNull()) + return; + if (src.pixmapData()->classId() != QPixmapData::OpenVGClass) { // The pixmap data is not an instance of QVGPixmapData, so fall // back to the default colorize filter implementation. @@ -225,6 +231,9 @@ QVGPixmapDropShadowFilter::~QVGPixmapDropShadowFilter() void QVGPixmapDropShadowFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const { + if (src.isNull()) + return; + if (src.pixmapData()->classId() != QPixmapData::OpenVGClass) { // The pixmap data is not an instance of QVGPixmapData, so fall // back to the default drop shadow filter implementation. @@ -290,6 +299,9 @@ QVGPixmapBlurFilter::~QVGPixmapBlurFilter() void QVGPixmapBlurFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const { + if (src.isNull()) + return; + if (src.pixmapData()->classId() != QPixmapData::OpenVGClass) { // The pixmap data is not an instance of QVGPixmapData, so fall // back to the default blur filter implementation. -- cgit v0.12 From f72c2d50b6ab7fc4a8ea3524e22de63ca8a366f7 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Tue, 3 Nov 2009 12:47:48 +1000 Subject: Fixed qrand global static related problem. qrand() uses global static seed storage, but if used from destructors of other global static objects (directly or via ~QSettings() or QMap::insert()) the global static seed storage can be already deleted. Fallback to plain rand() in this case. Task-number: QTBUG-5218 Reviewed-by: Justin McPherson --- src/corelib/global/qglobal.cpp | 59 ++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 7d47944..36e15b9 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2513,10 +2513,19 @@ Q_GLOBAL_STATIC(SeedStorage, randTLS) // Thread Local Storage for seed value void qsrand(uint seed) { #if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN) - SeedStorageType *pseed = randTLS()->localData(); - if (!pseed) - randTLS()->setLocalData(pseed = new SeedStorageType); - *pseed = seed; + SeedStorage *seedStorage = randTLS(); + if (seedStorage) { + SeedStorageType *pseed = seedStorage->localData(); + if (!pseed) + seedStorage->setLocalData(pseed = new SeedStorageType); + *pseed = seed; + } else { + //golbal static seed storage should always exist, + //except after being deleted by QGlobalStaticDeleter. + //But since it still can be called from destructor of another + //global static object, fallback to sqrand(seed) + srand(seed); + } #else // On Windows srand() and rand() already use Thread-Local-Storage // to store the seed between calls @@ -2536,17 +2545,20 @@ void qsrand(uint seed) void qsrand() { #if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN) - SeedStorageType *pseed = randTLS()->localData(); - if (pseed) { - // already seeded - return; + SeedStorage *seedStorage = randTLS(); + if (seedStorage) { + SeedStorageType *pseed = seedStorage->localData(); + if (pseed) { + // already seeded + return; + } + seedStorage->setLocalData(pseed = new SeedStorageType); + // start beyond 1 to avoid the sequence reset + static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(2); + *pseed = QDateTime::currentDateTime().toTime_t() + + quintptr(&pseed) + + serial.fetchAndAddRelaxed(1); } - randTLS()->setLocalData(pseed = new SeedStorageType); - // start beyond 1 to avoid the sequence reset - static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(2); - *pseed = QDateTime::currentDateTime().toTime_t() - + quintptr(&pseed) - + serial.fetchAndAddRelaxed(1); #if defined(Q_OS_WIN) // for Windows the srand function must still be called. srand(*pseed); @@ -2584,12 +2596,21 @@ void qsrand() int qrand() { #if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN) - SeedStorageType *pseed = randTLS()->localData(); - if (!pseed) { - randTLS()->setLocalData(pseed = new SeedStorageType); - *pseed = 1; + SeedStorage *seedStorage = randTLS(); + if (seedStorage) { + SeedStorageType *pseed = seedStorage->localData(); + if (!pseed) { + seedStorage->setLocalData(pseed = new SeedStorageType); + *pseed = 1; + } + return rand_r(pseed); + } else { + //golbal static seed storage should always exist, + //except after being deleted by QGlobalStaticDeleter. + //But since it still can be called from destructor of another + //global static object, fallback to qrand() + return rand(); } - return rand_r(pseed); #else // On Windows srand() and rand() already use Thread-Local-Storage // to store the seed between calls -- cgit v0.12 From 88f668430023acd3fbad3543a57198a4cf0255c2 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Tue, 3 Nov 2009 17:22:01 +1000 Subject: Fixed compilation on windows. Reviewed-by: trustme --- src/corelib/global/qglobal.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 36e15b9..33c6a34 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2558,11 +2558,11 @@ void qsrand() *pseed = QDateTime::currentDateTime().toTime_t() + quintptr(&pseed) + serial.fetchAndAddRelaxed(1); - } #if defined(Q_OS_WIN) - // for Windows the srand function must still be called. - srand(*pseed); + // for Windows the srand function must still be called. + srand(*pseed); #endif + } #elif defined(Q_OS_WIN) static unsigned int seed = 0; -- cgit v0.12 From 02b16c259cf268903823304e02d308cbbd043194 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 2 Nov 2009 15:46:53 +0100 Subject: Cocoa: fix double emit bug from file dialog For some reason, Cocoa tells us twize whenever a selection change occurs in the native file dialog. This patch inserts a check that the selection actually changed before emitting any signals Rev-By: Prasanth --- src/gui/dialogs/qfiledialog_mac.mm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm index d9bec27..4af5688 100644 --- a/src/gui/dialogs/qfiledialog_mac.mm +++ b/src/gui/dialogs/qfiledialog_mac.mm @@ -399,9 +399,13 @@ QT_USE_NAMESPACE - (void)panelSelectionDidChange:(id)sender { Q_UNUSED(sender); - *mCurrentSelection = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString([mSavePanel filename])); - if (mPriv) - mPriv->QNSOpenSavePanelDelegate_selectionChanged(*mCurrentSelection); + if (mPriv) { + QString selection = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString([mSavePanel filename])); + if (selection != mCurrentSelection) { + *mCurrentSelection = selection; + mPriv->QNSOpenSavePanelDelegate_selectionChanged(selection); + } + } } - (void)openPanelDidEnd:(NSOpenPanel *)panel returnCode:(int)returnCode contextInfo:(void *)contextInfo -- cgit v0.12 From 5dddf56e703bca59b874e46d3cabd2eba6fbb55e Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 13 Aug 2009 15:08:24 +0200 Subject: qdoc: Disabled reporting the NOTIFY signal until I know what it broke. Task-number: 259071 --- tools/qdoc3/cppcodeparser.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp index 84ec3f4..843bec8 100644 --- a/tools/qdoc3/cppcodeparser.cpp +++ b/tools/qdoc3/cppcodeparser.cpp @@ -1759,7 +1759,6 @@ bool CppCodeParser::matchProperty(InnerNode *parent) property->setDesignable(value.toLower() == "true"); else if (key == "RESET") tre->addPropertyFunction(property, value, PropertyNode::Resetter); - else if (key == "NOTIFY") { tre->addPropertyFunction(property, value, PropertyNode::Notifier); } -- cgit v0.12 From e7a10b00be3e4aa197900ecf424e6d44b07248ae Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 20 Oct 2009 18:03:10 +0300 Subject: Fixed QGraphicsScene::clear() not to crash if related top level items happen to delete each others. Merge-Request: 1863 Reviewed-by: Andreas Reviewed-by: Olivier --- src/gui/graphicsview/qgraphicsscene.cpp | 5 +++-- tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index a62e486..a4965e4 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -2292,8 +2292,9 @@ void QGraphicsScene::clear() // NB! We have to clear the index before deleting items; otherwise the // index might try to access dangling item pointers. d->index->clear(); - const QList items = d->topLevelItems; - qDeleteAll(items); + // NB! QGraphicsScenePrivate::unregisterTopLevelItem() removes items + while (!d->topLevelItems.isEmpty()) + delete d->topLevelItems.first(); Q_ASSERT(d->topLevelItems.isEmpty()); d->lastItemCount = 0; d->allItemsIgnoreHoverEvents = true; diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 0589994..4f76ddd 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -1453,6 +1453,13 @@ void tst_QGraphicsScene::focusItemLostFocus() item->clearFocus(); } +class ClearTestItem : public QGraphicsRectItem +{ +public: + ~ClearTestItem() { qDeleteAll(items); } + QList items; +}; + void tst_QGraphicsScene::clear() { QGraphicsScene scene; @@ -1463,6 +1470,19 @@ void tst_QGraphicsScene::clear() scene.clear(); QVERIFY(scene.items().isEmpty()); QCOMPARE(scene.sceneRect(), QRectF(0, 0, 100, 100)); + + ClearTestItem *firstItem = new ClearTestItem; + QGraphicsItem *secondItem = new QGraphicsRectItem; + firstItem->items += secondItem; + + scene.setItemIndexMethod(QGraphicsScene::NoIndex); + scene.addItem(firstItem); + scene.addItem(secondItem); + QCOMPARE(scene.items().at(0), firstItem); + QCOMPARE(scene.items().at(1), secondItem); + // must not crash even if firstItem deletes secondItem + scene.clear(); + QVERIFY(scene.items().isEmpty()); } void tst_QGraphicsScene::setFocusItem() -- cgit v0.12 From 4eff66941486568cd25dc9aaa372f9d36b84dad8 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 3 Nov 2009 10:05:11 +0100 Subject: doc: Polish documentation for state machine framework Fix some examples and wording, and add some clarification based on comments in documentation review session. Reviewed-by: Kent Hansen --- doc/src/frameworks-technologies/statemachine.qdoc | 104 +++++++++++----------- doc/src/snippets/statemachine/main2.cpp | 11 +-- doc/src/snippets/statemachine/main5.cpp | 44 +++++++-- 3 files changed, 93 insertions(+), 66 deletions(-) diff --git a/doc/src/frameworks-technologies/statemachine.qdoc b/doc/src/frameworks-technologies/statemachine.qdoc index ed8bc85..ac10314 100644 --- a/doc/src/frameworks-technologies/statemachine.qdoc +++ b/doc/src/frameworks-technologies/statemachine.qdoc @@ -75,6 +75,11 @@ states can be configured to set properties and invoke methods on QObjects. Qt's event system is used to drive the state machines. + The state graph in the State Machine framework is hierarchical. States can be nested inside of + other states, and the current configuration of the state machine consists of the set of states + which are currently active. All the states in a valid configuration of the state machine will + have a common ancestor. + \section1 Classes in the State Machine Framework These classes are provided by qt for creating event-driven state machines. @@ -269,9 +274,17 @@ When a parallel state group is entered, all its child states will be simultaneously entered. Transitions within the individual child states - operate normally. However, any of the child states may take a transition - outside the parent state. When this happens, the parent state and all of its - child states are exited. + operate normally. However, any of the child states may take a transition which exits the parent + state. When this happens, the parent state and all of its child states are exited. + + The parallelism in the State Machine framework follows an interleaved semantics. All parallel + operations will be executed in a single, atomic step of the event processing, so no event can + interrupt the parallel operations. However, events will still be processed sequentially, since + the machine itself is single threaded. As an example: Consider the situation where there are two + transitions that exit the same parallel state group, and their conditions become true + simultaneously. In this case, the event that is processed last of the two will not have any + effect, since the first event will already have caused the machine to exit from the parallel + state. \section1 Detecting that a Composite State has Finished @@ -414,16 +427,7 @@ Take the following code: \code - QStateMachine machine; - machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties); - - QState *s1 = new QState(); - s1->assignProperty(object, "fooBar", 1.0); - machine.addState(s1); - machine.setInitialState(s1); - - QState *s2 = new QState(); - machine.addState(s2); + \snippet doc/src/snippets/statemachine/main5.cpp 0 \endcode Lets say the property \c fooBar is 0.0 when the machine starts. When the machine is in state @@ -434,19 +438,7 @@ If we are using nested states, the parent defines a value for the property which is inherited by all descendants that do not explicitly assign a value to the property. \code - QStateMachine machine; - machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties); - - QState *s1 = new QState(); - s1->assignProperty(object, "fooBar", 1.0); - machine.addState(s1); - machine.setInitialState(s1); - - QState *s2 = new QState(s1); - s2->assignProperty(object, "fooBar", 2.0); - s1->setInitialState(s2); - - QState *s3 = new QState(s1); + \snippet doc/src/snippets/statemachine/main5.cpp 2 \endcode Here \c s1 has two children: \c s2 and \c s3. When \c s2 is entered, the property \c fooBar @@ -461,13 +453,7 @@ Say we have the following code: \code - QState *s1 = new QState(); - QState *s2 = new QState(); - - s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50)); - s2->assignProperty(button, "geometry", QRectF(0, 0, 100, 100)); - - s1->addTransition(button, SIGNAL(clicked()), s2); + \snippet doc/src/snippets/statemachine/main5.cpp 3 \endcode Here we define two states of a user interface. In \c s1 the \c button is small, and in \c s2 @@ -477,14 +463,7 @@ object. \code - QState *s1 = new QState(); - QState *s2 = new QState(); - - s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50)); - s2->assignProperty(button, "geometry", QRectF(0, 0, 100, 100)); - - QSignalTransition *transition = s1->addTransition(button, SIGNAL(clicked()), s2); - transition->addAnimation(new QPropertyAnimation(button, "geometry")); + \snippet doc/src/snippets/statemachine/main5.cpp 4 \endcode Adding an animation for the property in question means that the property assignment will no @@ -504,28 +483,45 @@ property can potentially have any value, depending on the animation. In some cases, it can be useful to be able to detect when the property has actually been assigned - the value defined by a state. For this, we can use the state's polished() signal. + the value defined by a state. + + Say we have the following code: \code - QState *s1 = new QState(); - s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50)); + \snippet doc/src/snippets/statemachine/main5.cpp 5 + \endcode - QState *s2 = new QState(); + When \c button is clicked, the machine will transition into state \c s2, which will set the + geometry of the button, and then pop up a message box to alert the user that the geometry has + been changed. + + In the normal case, where animations are not used, this will operate as expected. However, if + an animation for the \c geometry of \c button is set on the transition between \c s1 and \c s2, + the animation will be started when \c s2 is entered, but the \c geometry property will not + actually reach its defined value before the animation is finished running. In this case, the + message box will pop up before the geometry of the button has actually been set. - s1->addTransition(s1, SIGNAL(polished()), s2); + To ensure that the message box does not pop up until the geometry actually reaches its final + value, we can use the state's polished() signal. The polished() signal will be emitted when the + the property is assigned its final value, whether this is done immediately or after the animation + has finished playing. + \code + \snippet doc/src/snippets/statemachine/main5.cpp 6 \endcode - The machine will be in state \c s1 until the \c geometry property has been set. Then it will - immediately transition into \c s2. If the transition into \c s1 has an animation for the \c - geometry property, then the machine will stay in \c s1 until the animation has finished. If there - is no animation, it will simply set the property and immediately enter state \c s2. + In this example, when \c button is clicked, the machine will enter \c s2. It will remain in state + \c s2 until the \c geometry property has been set to \c QRect(0, 0, 50, 50). Then it will + transition into \c s3. When \c s3 is entered, the message box will pop up. If the transition into + \c s2 has an animation for the \c geometry property, then the machine will stay in \c s2 until the + animation has finished playing. If there is no such animation, it will simply set the property and + immediately enter state \c s3. - Either way, when the machine is in state \c s2, the property \c geometry has been assigned the - defined value. + Either way, when the machine is in state \c s3, you are guaranteed that the property \c geometry + has been assigned the defined value. If the global restore policy is set to QStateMachine::RestoreProperties, the state will not emit the polished() signal until these have been executed as well. - \section1 What happens if a state is exited before the animation has finished + \section1 What Happens If A State Is Exited Before The Animation Has Finished If a state has property assignments, and the transition into the state has animations for the properties, the state can potentially be exited before the properties have been assigned to the @@ -545,7 +541,7 @@ If the target state does not assign any value to the property, there are two options: By default, the property will be assigned the value defined by the state it is leaving - (the value it would have been assigned if the animation had been permitted to finish playing.) If + (the value it would have been assigned if the animation had been permitted to finish playing). If a global restore policy is set, however, this will take precedence, and the property will be restored as usual. diff --git a/doc/src/snippets/statemachine/main2.cpp b/doc/src/snippets/statemachine/main2.cpp index 2419dc2..9a2890f 100644 --- a/doc/src/snippets/statemachine/main2.cpp +++ b/doc/src/snippets/statemachine/main2.cpp @@ -69,17 +69,18 @@ int main(int argv, char **args) //![1] QButton *interruptButton = new QPushButton("Interrupt Button"); + QWidget *mainWindow = new QWidget(); //![3] QHistoryState *s1h = new QHistoryState(s1); QState *s3 = new QState(); s3->assignProperty(label, "text", "In s3"); - QMessageBox mbox; - mbox.addButton(QMessageBox::Ok); - mbox.setText("Interrupted!"); - mbox.setIcon(QMessageBox::Information); - QObject::connect(s3, SIGNAL(entered()), &mbox, SLOT(exec())); + QMessageBox *mbox = new QMessageBox(mainWindow); + mbox->addButton(QMessageBox::Ok); + mbox->setText("Interrupted!"); + mbox->setIcon(QMessageBox::Information); + QObject::connect(s3, SIGNAL(entered()), mbox, SLOT(exec())); s3->addTransition(s1h); machine.addState(s3); diff --git a/doc/src/snippets/statemachine/main5.cpp b/doc/src/snippets/statemachine/main5.cpp index a9d4091..346cbce 100644 --- a/doc/src/snippets/statemachine/main5.cpp +++ b/doc/src/snippets/statemachine/main5.cpp @@ -44,14 +44,13 @@ int main(int argv, char **args) { QApplication app(argv, args); + QWidget *button; { //![0] QStateMachine machine; machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties); -//![0] -//![1] QState *s1 = new QState(); s1->assignProperty(object, "fooBar", 1.0); machine.addState(s1); @@ -59,7 +58,7 @@ int main(int argv, char **args) QState *s2 = new QState(); machine.addState(s2); -//![1] +//![0] } { @@ -110,21 +109,50 @@ int main(int argv, char **args) } { + QMainWindow *mainWindow = 0; //![5] + QMessageBox *messageBox = new QMessageBox(mainWindow); + messageBox->addButton(QMessageBox::Ok); + messageBox->setText("Button geometry has been set!"); + messageBox->setIcon(QMessageBox::Information); + QState *s1 = new QState(); - s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50)); QState *s2 = new QState(); + s2->assignProperty(button, "geometry", QRectF(0, 0, 50, 50)); + connect(s2, SIGNAL(entered()), messageBox, SLOT(exec())); - s1->addTransition(s1, SIGNAL(polished()), s2); + s1->addTransition(button, SIGNAL(clicked()), s2); //![5] - } { + QMainWindow *mainWindow = 0; + +//![6] + QMessageBox *messageBox = new QMessageBox(mainWindow); + messageBox->addButton(QMessageBox::Ok); + messageBox->setText("Button geometry has been set!"); + messageBox->setIcon(QMessageBox::Information); + + QState *s1 = new QState(); + + QState *s2 = new QState(); + s2->assignProperty(button, "geometry", QRectF(0, 0, 50, 50)); + + QState *s3 = new QState(); + connect(s3, SIGNAL(entered()), messageBox, SLOT(exec())); + s1->addTransition(button, SIGNAL(clicked()), s2); + s2->addTransition(s2, SIGNAL(polished()), s3); //![6] + + } + + { + +//![7] QState *s1 = new QState(); QState *s2 = new QState(); @@ -134,10 +162,12 @@ int main(int argv, char **args) QStateMachine machine; machine.setInitialState(s1); machine.addDefaultAnimation(new QPropertyAnimation(object, "fooBar")); -//![6] +//![7] } + + return app.exec(); } -- cgit v0.12 From d54a1241a4470c73ccdac4b1a90264a9eaa28478 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 26 Oct 2009 12:22:13 +0100 Subject: disable link time code generation by default on Windows CE To be consistent with desktop Windows Qt, we also disable LTCG by default. To turn it on, use the -ltcg configure switch. Reviewed-by: mauricek --- tools/configure/configureapp.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index dd3823b..28645a0 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -1412,7 +1412,6 @@ void Configure::applySpecSpecifics() dictionary[ "WEBKIT" ] = "no"; dictionary[ "PHONON" ] = "yes"; dictionary[ "DIRECTSHOW" ] = "no"; - dictionary[ "LTCG" ] = "yes"; // We only apply MMX/IWMMXT for mkspecs we know they work if (dictionary[ "XQMAKESPEC" ].startsWith("wincewm")) { dictionary[ "MMX" ] = "yes"; -- cgit v0.12 From 0aade44ed9a2f223c603984a84ab012eadc5c388 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 26 Oct 2009 14:05:16 +0100 Subject: document the -no-ltcg default for Windows CE in changes-4.6.0 --- dist/changes-4.6.0 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index ba2b051..5a15cdb 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -58,6 +58,9 @@ information about a particular change. - The reading code of QLocalSocket on Windows has been rewritten to improve reading performance. + - On Windows CE the link time code geration has been disabled by default to + be consistent with win32-msvc200x. + **************************************************************************** * Important Behavior Changes * **************************************************************************** -- cgit v0.12 From fa1856bcb2eff41dadf0900202dd43f44ddb2343 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 27 Oct 2009 16:19:19 +0100 Subject: WebKit compile fix for Windows CE Not sure if this is right fix. We could also disable PLUGIN_PACKAGE_SIMPLE_HASH. But this is automatically enabled when NETSCAPE_PLUGIN_API is disabled. Reviewed-by: thartman --- src/3rdparty/webkit/WebCore/platform/FileSystem.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/3rdparty/webkit/WebCore/platform/FileSystem.h b/src/3rdparty/webkit/WebCore/platform/FileSystem.h index 958eb73..d144990 100644 --- a/src/3rdparty/webkit/WebCore/platform/FileSystem.h +++ b/src/3rdparty/webkit/WebCore/platform/FileSystem.h @@ -90,6 +90,17 @@ struct PlatformModuleVersion { { } + bool operator != (const PlatformModuleVersion& rhs) const + { + return mostSig != rhs.mostSig && leastSig != rhs.leastSig; + } + + + bool operator > (const PlatformModuleVersion& rhs) const + { + return mostSig > rhs.mostSig && leastSig > rhs.leastSig; + } + }; #else typedef QLibrary* PlatformModule; -- cgit v0.12 From 9fab0ede200960f0dbec1457757a6ba3214c3ce6 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 28 Oct 2009 10:03:12 +0100 Subject: fix font height calculation on QWS fontDef.pixelSize is a qreal now and we should round it after multiplication to avoid an accuracy loss. Reviewed-by: mae --- src/gui/text/qfontengine_qpf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp index 6ff0fbd..94974fc 100644 --- a/src/gui/text/qfontengine_qpf.cpp +++ b/src/gui/text/qfontengine_qpf.cpp @@ -819,7 +819,7 @@ FT_Face QFontEngineQPF::lockFace() const FT_Face face = freetype->face; // ### not perfect - const int ysize = int(fontDef.pixelSize) << 6; + const int ysize = qRound(fontDef.pixelSize * qreal(64)); const int xsize = ysize; if (freetype->xsize != xsize || freetype->ysize != ysize) { -- cgit v0.12 From 553d7f7416eca57b63992a453ceb3b333749c11a Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 28 Oct 2009 16:15:06 +0200 Subject: Introduced QGraphicsItem::ItemSendsScenePositionChanges and QGraphicsItem::ItemScenePositionHasChanged Merge-Request: 1945 Reviewed-By: Andreas --- src/gui/graphicsview/qgraphicsitem.cpp | 63 ++++++++++++++++++++-- src/gui/graphicsview/qgraphicsitem.h | 6 ++- src/gui/graphicsview/qgraphicsitem_p.h | 7 ++- src/gui/graphicsview/qgraphicsscene.cpp | 56 +++++++++++++++++++ src/gui/graphicsview/qgraphicsscene.h | 1 + src/gui/graphicsview/qgraphicsscene_p.h | 7 +++ tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 74 ++++++++++++++++++++++++++ 7 files changed, 206 insertions(+), 8 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 4665916..93b9ba9 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -386,6 +386,12 @@ introduced in Qt 4.6. \omitvalue ItemIsFocusScope Internal only (for now). + + \value ItemSendsScenePositionChanges The item enables itemChange() + notifications for ItemScenePositionHasChanged. For performance reasons, + these notifications are disabled by default. You must enable this flag + to receive notifications for scene position changes. This flag was + introduced in Qt 4.6. */ /*! @@ -562,6 +568,14 @@ \value ItemOpacityHasChanged The item's opacity has changed. The value argument is the new opacity (i.e., a double). Do not call setOpacity() as this notification is delivered. The return value is ignored. + + \value ItemScenePositionHasChanged The item's scene position has changed. + This notification is sent if the ItemSendsScenePositionChanges flag is + enabled, and after the item's scene position has changed (i.e., the + position or transformation of the item itself or the position or + transformation of any ancestor has changed). The value argument is the + new scene position (the same as scenePos()), and QGraphicsItem ignores + the return value for this notification (i.e., a read-only notification). */ /*! @@ -990,6 +1004,10 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) if (scene) { // Deliver the change to the index scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParentVariant); + + // Disable scene pos notifications for old ancestors + if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges)) + scene->d_func()->setScenePosItemEnabled(q, false); } if (subFocusItem && parent) { @@ -1084,10 +1102,15 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) parent->d_ptr->addChild(q); parent->itemChange(QGraphicsItem::ItemChildAddedChange, thisPointerVariant); - if (!implicitUpdate && scene) { - scene->d_func()->markDirty(q_ptr, QRect(), - /*invalidateChildren=*/false, - /*maybeDirtyClipPath=*/true); + if (scene) { + if (!implicitUpdate) + scene->d_func()->markDirty(q_ptr, QRect(), + /*invalidateChildren=*/false, + /*maybeDirtyClipPath=*/true); + + // Re-enable scene pos notifications for new ancestors + if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges)) + scene->d_func()->setScenePosItemEnabled(q, true); } // Inherit ancestor flags from the new parent. @@ -1746,6 +1769,12 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) } if (d_ptr->scene) { + if ((flags & ItemSendsScenePositionChanges) != (oldFlags & ItemSendsScenePositionChanges)) { + if (flags & ItemSendsScenePositionChanges) + d_ptr->scene->d_func()->registerScenePosItem(this); + else + d_ptr->scene->d_func()->unregisterScenePosItem(this); + } d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true, /*maybeDirtyClipPath*/true); @@ -3412,6 +3441,7 @@ void QGraphicsItem::setPos(const QPointF &pos) // Send post-notification. itemChange(QGraphicsItem::ItemPositionHasChanged, newPosVariant); + d_ptr->sendScenePosChange(); } /*! @@ -4022,6 +4052,7 @@ void QGraphicsItem::setTransform(const QTransform &matrix, bool combine) // Send post-notification. itemChange(ItemTransformHasChanged, newTransformVariant); + d_ptr->sendScenePosChange(); } /*! @@ -4246,6 +4277,24 @@ void QGraphicsItemPrivate::ensureSequentialSiblingIndex() } /*! + \internal +*/ +inline void QGraphicsItemPrivate::sendScenePosChange() +{ + Q_Q(QGraphicsItem); + if (scene) { + if (flags & QGraphicsItem::ItemSendsScenePositionChanges) + q->itemChange(QGraphicsItem::ItemScenePositionHasChanged, q->scenePos()); + if (scenePosDescendants) { + foreach (QGraphicsItem *item, scene->d_func()->scenePosItems) { + if (q->isAncestorOf(item)) + item->itemChange(QGraphicsItem::ItemScenePositionHasChanged, item->scenePos()); + } + } + } +} + +/*! \since 4.6 Stacks this item before \a sibling, which must be a sibling item (i.e., the @@ -10925,6 +10974,9 @@ QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemChange change) case QGraphicsItem::ItemOpacityHasChanged: str = "ItemOpacityHasChanged"; break; + case QGraphicsItem::ItemScenePositionHasChanged: + str = "ItemScenePositionHasChanged"; + break; } debug << str; return debug; @@ -10982,6 +11034,9 @@ QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag) case QGraphicsItem::ItemIsFocusScope: str = "ItemIsFocusScope"; break; + case QGraphicsItem::ItemSendsScenePositionChanges: + str = "ItemSendsScenePositionChanges"; + break; } debug << str; return debug; diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index f3fe99c..6e1c632 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -105,7 +105,8 @@ public: ItemAcceptsInputMethod = 0x1000, ItemNegativeZStacksBehindParent = 0x2000, ItemIsPanel = 0x4000, - ItemIsFocusScope = 0x8000 // internal + ItemIsFocusScope = 0x8000, // internal + ItemSendsScenePositionChanges = 0x10000 // NB! Don't forget to increase the d_ptr->flags bit field by 1 when adding a new flag. }; Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag) @@ -137,7 +138,8 @@ public: ItemZValueChange, ItemZValueHasChanged, ItemOpacityChange, - ItemOpacityHasChanged + ItemOpacityHasChanged, + ItemScenePositionHasChanged }; enum CacheMode { diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index ca56c18..92d45f6 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -179,6 +179,7 @@ public: holesInSiblingIndex(0), sequentialOrdering(1), updateDueToGraphicsEffect(0), + scenePosDescendants(0), globalStackingOrder(-1), q_ptr(0) { @@ -429,6 +430,7 @@ public: inline void ensureSortedChildren(); static inline bool insertionOrder(QGraphicsItem *a, QGraphicsItem *b); void ensureSequentialSiblingIndex(); + inline void sendScenePosChange(); QPainterPath cachedClipPath; QRectF childrenBoundingRect; @@ -483,7 +485,7 @@ public: // Packed 32 bits quint32 fullUpdatePending : 1; - quint32 flags : 16; + quint32 flags : 17; quint32 dirtyChildrenBoundingRect : 1; quint32 paintedViewBoundingRectsNeedRepaint : 1; quint32 dirtySceneTransform : 1; @@ -498,14 +500,15 @@ public: quint32 sceneTransformTranslateOnly : 1; quint32 notifyBoundingRectChanged : 1; quint32 notifyInvalidated : 1; - quint32 mouseSetsFocus : 1; // New 32 bits + quint32 mouseSetsFocus : 1; quint32 explicitActivate : 1; quint32 wantsActive : 1; quint32 holesInSiblingIndex : 1; quint32 sequentialOrdering : 1; quint32 updateDueToGraphicsEffect : 1; + quint32 scenePosDescendants : 1; // Optional stacking order int globalStackingOrder; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index a4965e4..b992398 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -294,6 +294,7 @@ QGraphicsScenePrivate::QGraphicsScenePrivate() needSortTopLevelItems(true), holesInTopLevelSiblingIndex(false), topLevelSequentialOrdering(true), + scenePosDescendantsUpdatePending(false), stickyFocus(false), hasFocus(false), focusItem(0), @@ -488,6 +489,55 @@ void QGraphicsScenePrivate::_q_processDirtyItems() /*! \internal +*/ +void QGraphicsScenePrivate::setScenePosItemEnabled(QGraphicsItem *item, bool enabled) +{ + QGraphicsItem *p = item->d_ptr->parent; + while (p) { + p->d_ptr->scenePosDescendants = enabled; + p = p->d_ptr->parent; + } + if (!enabled && !scenePosDescendantsUpdatePending) { + scenePosDescendantsUpdatePending = true; + QMetaObject::invokeMethod(q_func(), "_q_updateScenePosDescendants", Qt::QueuedConnection); + } +} + +/*! + \internal +*/ +void QGraphicsScenePrivate::registerScenePosItem(QGraphicsItem *item) +{ + scenePosItems.insert(item); + setScenePosItemEnabled(item, true); +} + +/*! + \internal +*/ +void QGraphicsScenePrivate::unregisterScenePosItem(QGraphicsItem *item) +{ + scenePosItems.remove(item); + setScenePosItemEnabled(item, false); +} + +/*! + \internal +*/ +void QGraphicsScenePrivate::_q_updateScenePosDescendants() +{ + foreach (QGraphicsItem *item, scenePosItems) { + QGraphicsItem *p = item->d_ptr->parent; + while (p) { + p->d_ptr->scenePosDescendants = 1; + p = p->d_ptr->parent; + } + } + scenePosDescendantsUpdatePending = false; +} + +/*! + \internal Schedules an item for removal. This function leaves some stale indexes around in the BSP tree if called from the item's destructor; these will @@ -523,6 +573,9 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) widget->d_func()->fixFocusChainBeforeReparenting(0, 0); } + if (item->flags() & QGraphicsItem::ItemSendsScenePositionChanges) + unregisterScenePosItem(item); + item->d_func()->scene = 0; //We need to remove all children first because they might use their parent @@ -2540,6 +2593,9 @@ void QGraphicsScene::addItem(QGraphicsItem *item) } } + if (item->flags() & QGraphicsItem::ItemSendsScenePositionChanges) + d->registerScenePosItem(item); + // Ensure that newly added items that have subfocus set, gain // focus automatically if there isn't a focus item already. if (!d->focusItem && item != d->lastFocusItem && item->focusItem() == item) diff --git a/src/gui/graphicsview/qgraphicsscene.h b/src/gui/graphicsview/qgraphicsscene.h index d6d48d7..a47574e 100644 --- a/src/gui/graphicsview/qgraphicsscene.h +++ b/src/gui/graphicsview/qgraphicsscene.h @@ -299,6 +299,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_emitUpdated()) Q_PRIVATE_SLOT(d_func(), void _q_polishItems()) Q_PRIVATE_SLOT(d_func(), void _q_processDirtyItems()) + Q_PRIVATE_SLOT(d_func(), void _q_updateScenePosDescendants()) friend class QGraphicsItem; friend class QGraphicsItemPrivate; friend class QGraphicsView; diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index cd20fd0..6d46db5 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -122,6 +122,13 @@ public: void _q_processDirtyItems(); + QSet scenePosItems; + bool scenePosDescendantsUpdatePending; + void setScenePosItemEnabled(QGraphicsItem *item, bool enabled); + void registerScenePosItem(QGraphicsItem *item); + void unregisterScenePosItem(QGraphicsItem *item); + void _q_updateScenePosDescendants(); + void removeItemHelper(QGraphicsItem *item); QBrush backgroundBrush; diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 684ad4f..1081fd5 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -401,6 +401,7 @@ private slots: void modality_clickFocus(); void modality_keyEvents(); void itemIsInFront(); + void scenePosChange(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -4229,6 +4230,8 @@ protected: break; case QGraphicsItem::ItemOpacityHasChanged: break; + case QGraphicsItem::ItemScenePositionHasChanged: + break; } return itemChangeReturnValue.isValid() ? itemChangeReturnValue : value; } @@ -9691,5 +9694,76 @@ void tst_QGraphicsItem::itemIsInFront() QCOMPARE(qt_closestItemFirst(rect1child1_2, rect2child1), false); } +class ScenePosChangeTester : public ItemChangeTester +{ +public: + ScenePosChangeTester() + { } + ScenePosChangeTester(QGraphicsItem *parent) : ItemChangeTester(parent) + { } +}; + +void tst_QGraphicsItem::scenePosChange() +{ + ScenePosChangeTester* root = new ScenePosChangeTester; + ScenePosChangeTester* child1 = new ScenePosChangeTester(root); + ScenePosChangeTester* grandChild1 = new ScenePosChangeTester(child1); + ScenePosChangeTester* child2 = new ScenePosChangeTester(root); + ScenePosChangeTester* grandChild2 = new ScenePosChangeTester(child2); + + child1->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true); + grandChild2->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true); + + QGraphicsScene scene; + scene.addItem(root); + + // ignore uninteresting changes + child1->clear(); + child2->clear(); + grandChild1->clear(); + grandChild2->clear(); + + // move whole tree + root->moveBy(1.0, 1.0); + QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1); + QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); + QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); + QCOMPARE(grandChild2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1); + + // move subtree + child2->moveBy(1.0, 1.0); + QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1); + QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); + QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); + QCOMPARE(grandChild2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 2); + + // reparent + grandChild2->setParentItem(child1); + child1->moveBy(1.0, 1.0); + QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 2); + QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); + QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); + QCOMPARE(grandChild2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 3); + + // change flags + grandChild1->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true); + grandChild2->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false); + QCoreApplication::processEvents(); // QGraphicsScenePrivate::_q_updateScenePosDescendants() + child1->moveBy(1.0, 1.0); + QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 3); + QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1); + QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); + QCOMPARE(grandChild2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 3); + + // remove + scene.removeItem(grandChild1); + delete grandChild2; grandChild2 = 0; + QCoreApplication::processEvents(); // QGraphicsScenePrivate::_q_updateScenePosDescendants() + root->moveBy(1.0, 1.0); + QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 4); + QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1); + QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" -- cgit v0.12 From b22f7a8af0a781885a64d0cd1001192c99872aef Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Thu, 29 Oct 2009 17:55:06 +0100 Subject: QLocalSocket test: stabilize test by calling waitFor... function ... to make sure bytes are availabe to read Reviewed-by: Aleksandar Sasha Babic --- tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index ab7b0ac..5ead049 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -587,14 +587,16 @@ void tst_QLocalSocket::readBufferOverflow() char buffer[dataBufferSize]; memset(buffer, 0, dataBufferSize); serverSocket->write(buffer, dataBufferSize); - serverSocket->flush(); + serverSocket->waitForBytesWritten(); + // wait until the first 128 bytes are ready to read QVERIFY(client.waitForReadyRead()); QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize)); -#if defined(QT_LOCALSOCKET_TCP) || defined(Q_OS_SYMBIAN) - QTest::qWait(250); -#endif + // wait until the second 128 bytes are ready to read + QVERIFY(client.waitForReadyRead()); QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize)); + // no more bytes available + QVERIFY(client.bytesAvailable() == 0); } // QLocalSocket/Server can take a name or path, check that it works as expected -- cgit v0.12 From 2a0d6bf8d3f7c92667512d2222cf2304e06130b4 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 3 Nov 2009 10:56:06 +0100 Subject: Adapt testcase to cosmetic pen workarounds in code Reviewed-by: Samuel --- tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp index fbeb425..55294d5 100644 --- a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp +++ b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp @@ -357,7 +357,7 @@ void tst_QGraphicsEffectSource::pixmapPadding_data() QTest::newRow("log,transparent") << int(Qt::LogicalCoordinates) << int(QGraphicsEffectSource::ExpandToTransparentBorderPadMode) - << QSize(12, 12) << QPoint(-1, -1) + << QSize(14, 14) << QPoint(-2, -2) << 0x00000000u; QTest::newRow("log,effectrect") << int(Qt::LogicalCoordinates) @@ -372,7 +372,7 @@ void tst_QGraphicsEffectSource::pixmapPadding_data() QTest::newRow("dev,transparent") << int(Qt::DeviceCoordinates) << int(QGraphicsEffectSource::ExpandToTransparentBorderPadMode) - << QSize(22, 22) << QPoint(39, 39) + << QSize(24, 24) << QPoint(38, 38) << 0x00000000u; QTest::newRow("dev,effectrect") << int(Qt::DeviceCoordinates) -- cgit v0.12 From 83b069307781f138394d29540a35c62d1dc584c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Tue, 3 Nov 2009 11:58:53 +0200 Subject: Build break fix for S60Simulated style S60Simulated style broke down after change SHA da9880eaed0d09338717db1a73db01e6b0ab080d, because part()-method call in simulated style was not updated to have additional parameter. Task-number: None Reviewed-by: Shane Kearns --- src/gui/styles/qs60style_simulated.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp index 14f0424..706b4e9 100644 --- a/src/gui/styles/qs60style_simulated.cpp +++ b/src/gui/styles/qs60style_simulated.cpp @@ -322,7 +322,7 @@ QPixmap QS60StylePrivate::backgroundTexture() { if (!m_background) { const QSize size = QApplication::desktop()->screen()->size(); - QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen, size); + QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen, size, 0); m_background = new QPixmap(background); } return *m_background; -- cgit v0.12 From 1ef5dddf91c666664911686ca77cb6c1b2cde828 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 3 Nov 2009 12:06:35 +0200 Subject: Force Qt libs to install on phone memory in Symbian. Starting Qt apps when Qt libs are installed on a memory card takes ages (15-20 seconds), because Symbian recalculates hash of the dll every time it loads it from a non-system drive. Worked around this issue by forcing installation of Qt libs to the C-drive. Task-number: QT-690 Reviewed-by: Janne Koskinen --- src/s60installs/s60installs.pro | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 022a072..9c53167 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -12,7 +12,7 @@ symbian: { VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} qtresources.sources = $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/s60main.rsc - qtresources.path = $$APP_RESOURCE_DIR + qtresources.path = c:$$APP_RESOURCE_DIR qtlibraries.sources = \ QtCore.dll \ @@ -24,24 +24,24 @@ symbian: { qts60plugindeployment = \ "IF package(0x1028315F)" \ - " \"$${EPOCROOT}epoc32/release/$(PLATFORM)/$(TARGET)/qts60plugin_5_0.dll\" - \"!:\\sys\\bin\\qts60plugin_5_0.dll\"" \ + " \"$${EPOCROOT}epoc32/release/$(PLATFORM)/$(TARGET)/qts60plugin_5_0.dll\" - \"c:\\sys\\bin\\qts60plugin_5_0.dll\"" \ "ELSEIF package(0x102752AE)" \ - " \"$${EPOCROOT}epoc32/release/$(PLATFORM)/$(TARGET)/qts60plugin_3_2.dll\" - \"!:\\sys\\bin\\qts60plugin_3_2.dll\"" \ + " \"$${EPOCROOT}epoc32/release/$(PLATFORM)/$(TARGET)/qts60plugin_3_2.dll\" - \"c:\\sys\\bin\\qts60plugin_3_2.dll\"" \ "ELSEIF package(0x102032BE)" \ - " \"$${EPOCROOT}epoc32/release/$(PLATFORM)/$(TARGET)/qts60plugin_3_1.dll\" - \"!:\\sys\\bin\\qts60plugin_3_1.dll\"" \ + " \"$${EPOCROOT}epoc32/release/$(PLATFORM)/$(TARGET)/qts60plugin_3_1.dll\" - \"c:\\sys\\bin\\qts60plugin_3_1.dll\"" \ "ELSE" \ - " \"$${EPOCROOT}epoc32/release/$(PLATFORM)/$(TARGET)/qts60plugin_5_0.dll\" - \"!:\\sys\\bin\\qts60plugin_5_0.dll\"" \ + " \"$${EPOCROOT}epoc32/release/$(PLATFORM)/$(TARGET)/qts60plugin_5_0.dll\" - \"c:\\sys\\bin\\qts60plugin_5_0.dll\"" \ "ENDIF" qtlibraries.pkg_postrules += qts60plugindeployment sqlitedeployment = \ "; Deploy sqlite onto phone that does not have it (this should be replaced with embedded sis file when available)" \ "IF NOT package(0x2002533b) " \ - "\"$${EPOCROOT}epoc32/release/$(PLATFORM)/$(TARGET)/sqlite3.dll\" - \"!:\\sys\\bin\\sqlite3.dll\"" \ + "\"$${EPOCROOT}epoc32/release/$(PLATFORM)/$(TARGET)/sqlite3.dll\" - \"c:\\sys\\bin\\sqlite3.dll\"" \ "ENDIF" qtlibraries.pkg_postrules += sqlitedeployment - qtlibraries.path = /sys/bin + qtlibraries.path = c:/sys/bin vendorinfo = \ "; Localised Vendor name" \ @@ -67,15 +67,15 @@ symbian: { !contains(QT_CONFIG, no-mng): imageformats_plugins.sources += qmng.dll !contains(QT_CONFIG, no-tiff): imageformats_plugins.sources += qtiff.dll !contains(QT_CONFIG, no-ico): imageformats_plugins.sources += qico.dll - imageformats_plugins.path = $$QT_PLUGINS_BASE_DIR/imageformats + imageformats_plugins.path = c:$$QT_PLUGINS_BASE_DIR/imageformats codecs_plugins.sources = qcncodecs.dll qjpcodecs.dll qtwcodecs.dll qkrcodecs.dll - codecs_plugins.path = $$QT_PLUGINS_BASE_DIR/codecs + codecs_plugins.path = c:$$QT_PLUGINS_BASE_DIR/codecs contains(QT_CONFIG, phonon-backend) { phonon_backend_plugins.sources += phonon_mmf.dll - phonon_backend_plugins.path = $$QT_PLUGINS_BASE_DIR/phonon_backend + phonon_backend_plugins.path = c:$$QT_PLUGINS_BASE_DIR/phonon_backend DEPLOYMENT += phonon_backend_plugins } @@ -85,7 +85,7 @@ symbian: { qtlibraries.sources += QtSvg.dll imageformats_plugins.sources += qsvg.dll iconengines_plugins.sources = qsvgicon.dll - iconengines_plugins.path = $$QT_PLUGINS_BASE_DIR/iconengines + iconengines_plugins.path = c:$$QT_PLUGINS_BASE_DIR/iconengines DEPLOYMENT += iconengines_plugins } @@ -105,7 +105,7 @@ symbian: { qtlibraries.sources += QtWebKit.dll } - graphicssystems_plugins.path = $$QT_PLUGINS_BASE_DIR/graphicssystems + graphicssystems_plugins.path = c:$$QT_PLUGINS_BASE_DIR/graphicssystems contains(QT_CONFIG, openvg) { qtlibraries.sources = QtOpenVG.dll graphicssystems_plugins.sources += qvggraphicssystem.dll -- cgit v0.12 From 29ddc44a11e16347212fccd3d81c4e0c91bf61a1 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 2 Nov 2009 12:37:41 +0100 Subject: Documentation fixes related to gestures doc. Reviewed-by: David Boddie --- doc/src/frameworks-technologies/gestures.qdoc | 4 ++-- src/gui/kernel/qevent.cpp | 5 +++-- src/gui/kernel/qgesture.cpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/src/frameworks-technologies/gestures.qdoc b/doc/src/frameworks-technologies/gestures.qdoc index a619fe8..f64e301 100644 --- a/doc/src/frameworks-technologies/gestures.qdoc +++ b/doc/src/frameworks-technologies/gestures.qdoc @@ -168,6 +168,6 @@ \section1 Further Reading - The \l{Image Gestures Example} shows how to enable gestures for a widget in - a simple image viewer application. + The \l{gestures/imagegestures}{Image Gestures Example} shows how to enable + gestures for a widget in a simple image viewer application. */ diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index ab43e79..6757fa2 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4344,8 +4344,9 @@ bool QGestureEvent::isAccepted(QGesture *gesture) const Sets the accept flag of the given \a gestureType object to the specified \a value. - Setting the accept flag indicates that the event receiver wants the \a gesture. - Unwanted gestures may be propagated to the parent widget. + Setting the accept flag indicates that the event receiver wants the gesture + of type \a gestureType. Unwanted gestures may be propagated to the parent + widget. By default, gestures in events of type QEvent::Gesture are accepted, and gestures in QEvent::GestureOverride events are ignored. diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index 850f22c..df99746 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -217,7 +217,7 @@ QGesture::GestureCancelPolicy QGesture::gestureCancelPolicy() const */ /*! - \property QGesture::GestureCancelPolicy + \property QGesture::gestureCancelPolicy \brief the policy for deciding what happens on accepting a gesture On accepting one gesture Qt can automatically cancel other gestures -- cgit v0.12 From b112af4614dffcb230956bfa319c37fc00e6a13c Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 2 Nov 2009 14:13:17 +0100 Subject: Added QGraphicsObject::ungrabGesture() Oops, apparently we forgot to add a function for unsubscribing a graphics object from a gesture. Fixing it now. Reviewed-by: trustme --- src/gui/graphicsview/qgraphicsitem.cpp | 17 +++++++++++++++-- src/gui/graphicsview/qgraphicsitem.h | 1 + src/gui/kernel/qwidget.cpp | 4 ++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 738c6e3..58d7e7d 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -7322,9 +7322,8 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent /*! Subscribes the graphics object to the given \a gesture for the specified \a context. - \sa QGestureEvent + \sa ungrabGesture(), QGestureEvent */ - void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureContext context) { QGraphicsItemPrivate * const d = QGraphicsItem::d_func(); @@ -7333,6 +7332,20 @@ void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureContext co } /*! + Unsubscribes the graphics object from the given \a gesture. + + \sa grabGesture(), QGestureEvent +*/ +void QGraphicsObject::ungrabGesture(Qt::GestureType gesture) +{ + QGraphicsItemPrivate * const d = QGraphicsItem::d_func(); + if (d->gestureContext.remove(gesture)) { + QGestureManager *manager = QGestureManager::instance(); + manager->cleanupCachedGestures(this, gesture); + } +} + +/*! \property QGraphicsObject::parent \brief the parent of the item diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index f3fe99c..fc180f3 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -556,6 +556,7 @@ public: #endif void grabGesture(Qt::GestureType type, Qt::GestureContext context = Qt::ItemWithChildrenGesture); + void ungrabGesture(Qt::GestureType type); Q_SIGNALS: void parentChanged(); diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 14f3bfe..ac2808c 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -11712,7 +11712,7 @@ QGraphicsProxyWidget *QWidget::graphicsProxyWidget() const /*! Subscribes the widget to a given \a gesture with a \a context. - \sa QGestureEvent + \sa ungrabGesture(), QGestureEvent \since 4.6 */ void QWidget::grabGesture(Qt::GestureType gesture, Qt::GestureContext context) @@ -11725,7 +11725,7 @@ void QWidget::grabGesture(Qt::GestureType gesture, Qt::GestureContext context) /*! Unsubscribes the widget to a given \a gesture type - \sa QGestureEvent + \sa grabGesture(), QGestureEvent \since 4.6 */ void QWidget::ungrabGesture(Qt::GestureType gesture) -- cgit v0.12 From 0222f4f55d6af9ad4f4ca1ee07ae9810ff9256a2 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 30 Oct 2009 13:57:34 +0100 Subject: Improved gesture scrollarea manualtest. Reviewed-by: trustme --- tests/manual/gestures/scrollarea/main.cpp | 30 +++++++++++++++------- .../scrollarea/mousepangesturerecognizer.cpp | 14 ++++++++-- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/tests/manual/gestures/scrollarea/main.cpp b/tests/manual/gestures/scrollarea/main.cpp index f90f6c6..9a5eb02 100644 --- a/tests/manual/gestures/scrollarea/main.cpp +++ b/tests/manual/gestures/scrollarea/main.cpp @@ -73,11 +73,11 @@ protected: QPanGesture *pan = static_cast(event->gesture(Qt::PanGesture)); if (pan) { switch(pan->state()) { - case Qt::GestureStarted: qDebug("area: Pan: started"); break; - case Qt::GestureFinished: qDebug("area: Pan: finished"); break; - case Qt::GestureCanceled: qDebug("area: Pan: canceled"); break; + case Qt::GestureStarted: qDebug() << this << "Pan: started"; break; + case Qt::GestureFinished: qDebug() << this << "Pan: finished"; break; + case Qt::GestureCanceled: qDebug() << this << "Pan: canceled"; break; case Qt::GestureUpdated: break; - default: qDebug("area: Pan: "); break; + default: qDebug() << this << "Pan: "; break; } if (pan->state() == Qt::GestureStarted) @@ -134,11 +134,11 @@ protected: QPanGesture *pan = static_cast(event->gesture(Qt::PanGesture)); if (pan) { switch (pan->state()) { - case Qt::GestureStarted: qDebug("slider: Pan: started"); break; - case Qt::GestureFinished: qDebug("slider: Pan: finished"); break; - case Qt::GestureCanceled: qDebug("slider: Pan: canceled"); break; + case Qt::GestureStarted: qDebug() << this << "Pan: started"; break; + case Qt::GestureFinished: qDebug() << this << "Pan: finished"; break; + case Qt::GestureCanceled: qDebug() << this << "Pan: canceled"; break; case Qt::GestureUpdated: break; - default: qDebug("slider: Pan: "); break; + default: qDebug() << this << "Pan: "; break; } if (pan->state() == Qt::GestureStarted) @@ -186,6 +186,7 @@ public: MainWindow() { rootScrollArea = new ScrollArea; + rootScrollArea->setObjectName(QLatin1String("rootScrollArea")); setCentralWidget(rootScrollArea); QWidget *root = new QWidget; @@ -193,14 +194,17 @@ public: rootScrollArea->setWidget(root); Slider *verticalSlider = new Slider(Qt::Vertical, root); + verticalSlider->setObjectName(QLatin1String("verticalSlider")); verticalSlider ->move(650, 1100); Slider *horizontalSlider = new Slider(Qt::Horizontal, root); + horizontalSlider->setObjectName(QLatin1String("horizontalSlider")); horizontalSlider ->move(600, 1000); childScrollArea = new ScrollArea(root); + childScrollArea->setObjectName(QLatin1String("childScrollArea")); childScrollArea->move(500, 500); QWidget *w = new QWidget; - w->setMinimumWidth(400); + w->setMinimumWidth(700); QVBoxLayout *l = new QVBoxLayout(w); l->setMargin(20); for (int i = 0; i < 100; ++i) { @@ -211,6 +215,14 @@ public: l->addWidget(w); } childScrollArea->setWidget(w); +#if defined(Q_OS_WIN) + // Windows can force Qt to create a native window handle for an + // intermediate widget and that will block gesture to get touch events. + // So this hack to make sure gestures get all touch events they need. + foreach (QObject *w, children()) + if (w->isWidgetType()) + static_cast(w)->setAttribute(Qt::WA_AcceptTouchEvents); +#endif } private: ScrollArea *rootScrollArea; diff --git a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp index 63d3e76..ce5ef57 100644 --- a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp +++ b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp @@ -57,8 +57,16 @@ QGesture* MousePanGestureRecognizer::createGesture(QObject *) QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event) { QPanGesture *g = static_cast(state); + if (event->type() == QEvent::TouchBegin) { + // ignore the following mousepress event + g->setProperty("ignoreMousePress", QVariant::fromValue(true)); + } else if (event->type() == QEvent::TouchEnd) { + g->setProperty("ignoreMousePress", QVariant::fromValue(false)); + } QMouseEvent *me = static_cast(event); - if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick) { + if (event->type() == QEvent::MouseButtonPress) { + if (g->property("ignoreMousePress").toBool()) + return QGestureRecognizer::Ignore; g->setHotSpot(me->globalPos()); g->setProperty("lastPos", me->globalPos()); g->setProperty("pressed", QVariant::fromValue(true)); @@ -76,7 +84,8 @@ QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *stat } return QGestureRecognizer::NotGesture; } else if (event->type() == QEvent::MouseButtonRelease) { - return QGestureRecognizer::GestureFinished | QGestureRecognizer::ConsumeEventHint; + if (g->property("pressed").toBool()) + return QGestureRecognizer::GestureFinished | QGestureRecognizer::ConsumeEventHint; } return QGestureRecognizer::Ignore; } @@ -90,5 +99,6 @@ void MousePanGestureRecognizer::reset(QGesture *state) g->setAcceleration(0); g->setProperty("lastPos", QVariant()); g->setProperty("pressed", QVariant::fromValue(false)); + g->setProperty("ignoreMousePress", QVariant::fromValue(false)); QGestureRecognizer::reset(state); } -- cgit v0.12 From b7b4df9c87805be372fa6f74422e0f4648a5d520 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 30 Oct 2009 14:01:41 +0100 Subject: Fixed the imagegestures project file. Reviewed-by: trustme --- examples/gestures/imagegestures/imagegestures.pro | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/gestures/imagegestures/imagegestures.pro b/examples/gestures/imagegestures/imagegestures.pro index 7780ad9..8c947e4 100644 --- a/examples/gestures/imagegestures/imagegestures.pro +++ b/examples/gestures/imagegestures/imagegestures.pro @@ -5,12 +5,12 @@ SOURCES = imagewidget.cpp \ mainwidget.cpp # install -target.path = $$[QT_INSTALL_EXAMPLES]/gestures/imageviewer +target.path = $$[QT_INSTALL_EXAMPLES]/gestures/imagegestures sources.files = $$SOURCES \ $$HEADERS \ $$RESOURCES \ $$FORMS \ - imageviewer.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/gestures/imageviewer + imagegestures.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/gestures/imagegestures INSTALLS += target \ sources -- cgit v0.12 From 54db3afc9797a3adf5a38f35f6338960924e9e1a Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 30 Oct 2009 17:14:53 +0100 Subject: Implemented pinch gesture recognizer. Reviewed-by: trustme --- examples/gestures/imagegestures/imagewidget.cpp | 18 +-- src/gui/kernel/qgesture_p.h | 3 + src/gui/kernel/qgesturemanager.cpp | 1 + src/gui/kernel/qstandardgestures.cpp | 177 ++++++++++++--------- src/gui/kernel/qstandardgestures_p.h | 11 ++ src/gui/kernel/qwidget.cpp | 1 + src/gui/kernel/qwidget_win.cpp | 11 -- .../kernel/qwinnativepangesturerecognizer_win.cpp | 8 +- .../kernel/qwinnativepangesturerecognizer_win_p.h | 2 +- 9 files changed, 130 insertions(+), 102 deletions(-) diff --git a/examples/gestures/imagegestures/imagewidget.cpp b/examples/gestures/imagegestures/imagewidget.cpp index 28de6da..c798fcc 100644 --- a/examples/gestures/imagegestures/imagewidget.cpp +++ b/examples/gestures/imagegestures/imagewidget.cpp @@ -102,17 +102,13 @@ void ImageWidget::mouseDoubleClickEvent(QMouseEvent *) //! [gesture event handler] bool ImageWidget::gestureEvent(QGestureEvent *event) { - if (QGesture *pan = event->gesture(Qt::PanGesture)) { - panTriggered(static_cast(pan)); - return true; - } else if (QGesture *pinch = event->gesture(Qt::PinchGesture)) { - pinchTriggered(static_cast(pinch)); - return true; - } else if (QGesture *swipe = event->gesture(Qt::SwipeGesture)) { - swipeTriggered(static_cast(swipe)); - return true; - } - return false; + if (QGesture *pan = event->gesture(Qt::PanGesture)) + panTriggered(static_cast(pan)); + if (QGesture *pinch = event->gesture(Qt::PinchGesture)) + pinchTriggered(static_cast(pinch)); + if (QGesture *swipe = event->gesture(Qt::SwipeGesture)) + swipeTriggered(static_cast(swipe)); + return true; } //! [gesture event handler] diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h index 34fbb26..73a6bcf 100644 --- a/src/gui/kernel/qgesture_p.h +++ b/src/gui/kernel/qgesture_p.h @@ -121,6 +121,9 @@ public: qreal totalRotationAngle; qreal lastRotationAngle; qreal rotationAngle; + + bool isNewSequence; + QPointF startPosition[2]; }; class QSwipeGesturePrivate : public QGesturePrivate diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 1d33c84..6ea350b 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -77,6 +77,7 @@ QGestureManager::QGestureManager(QObject *parent) #endif #else registerGestureRecognizer(new QPanGestureRecognizer); + registerGestureRecognizer(new QPinchGestureRecognizer); #endif } diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index dec2311..57cf12d 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -44,6 +44,7 @@ #include "qgesture_p.h" #include "qevent.h" #include "qwidget.h" +#include "qabstractscrollarea.h" QT_BEGIN_NAMESPACE @@ -54,7 +55,13 @@ QPanGestureRecognizer::QPanGestureRecognizer() QGesture *QPanGestureRecognizer::createGesture(QObject *target) { if (target && target->isWidgetType()) { +#if defined(Q_OS_WIN) + // for scroll areas on Windows we want to use native gestures instead + if (!qobject_cast(target->parent())) + static_cast(target)->setAttribute(Qt::WA_AcceptTouchEvents); +#else static_cast(target)->setAttribute(Qt::WA_AcceptTouchEvents); +#endif } return new QPanGesture; } @@ -132,104 +139,124 @@ void QPanGestureRecognizer::reset(QGesture *state) d->lastPosition = QPoint(); d->acceleration = 0; -//#if defined(QT_MAC_USE_COCOA) -// d->singleTouchPanTimer.stop(); -// d->prevMousePos = QPointF(0, 0); -//#endif - QGestureRecognizer::reset(state); } -/* -bool QPanGestureRecognizer::event(QEvent *event) + +// +// QPinchGestureRecognizer +// + +QPinchGestureRecognizer::QPinchGestureRecognizer() { -#if defined(QT_MAC_USE_COCOA) - Q_D(QPanGesture); - if (event->type() == QEvent::Timer) { - const QTimerEvent *te = static_cast(event); - if (te->timerId() == d->singleTouchPanTimer.timerId()) { - d->singleTouchPanTimer.stop(); - updateState(Qt::GestureStarted); - } +} + +QGesture *QPinchGestureRecognizer::createGesture(QObject *target) +{ + if (target && target->isWidgetType()) { + static_cast(target)->setAttribute(Qt::WA_AcceptTouchEvents); } -#endif + return new QPinchGesture; +} - bool consume = false; +QGestureRecognizer::Result QPinchGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event) +{ + QPinchGesture *q = static_cast(state); + QPinchGesturePrivate *d = q->d_func(); -#if defined(Q_WS_WIN) -#elif defined(QT_MAC_USE_COCOA) - // The following implements single touch - // panning on Mac: - const int panBeginDelay = 300; - const int panBeginRadius = 3; - const QTouchEvent *ev = static_cast(event); + const QTouchEvent *ev = static_cast(event); + + QGestureRecognizer::Result result; switch (event->type()) { case QEvent::TouchBegin: { - if (ev->touchPoints().size() == 1) { - d->delayManager->setEnabled(true); - consume = d->delayManager->append(d->gestureTarget, *event); - d->lastPosition = QCursor::pos(); - d->singleTouchPanTimer.start(panBeginDelay, this); - } - break;} + result = QGestureRecognizer::MaybeGesture; + break; + } case QEvent::TouchEnd: { - d->delayManager->setEnabled(false); - if (state() != Qt::NoGesture) { - updateState(Qt::GestureFinished); - consume = true; - d->delayManager->clear(); + if (q->state() != Qt::NoGesture) { + result = QGestureRecognizer::GestureFinished; } else { - d->delayManager->replay(); + result = QGestureRecognizer::NotGesture; } - reset(); - break;} + break; + } case QEvent::TouchUpdate: { - consume = d->delayManager->append(d->gestureTarget, *event); - if (ev->touchPoints().size() == 1) { - if (state() == Qt::NoGesture) { - // INVARIANT: The singleTouchTimer has still not fired. - // Lets check if the user moved his finger so much from - // the starting point that it makes sense to cancel: - const QPointF startPos = ev->touchPoints().at(0).startPos().toPoint(); - const QPointF p = ev->touchPoints().at(0).pos().toPoint(); - if ((startPos - p).manhattanLength() > panBeginRadius) { - d->delayManager->replay(); - consume = false; - reset(); - } else { - d->lastPosition = QCursor::pos(); - } + d->whatChanged = 0; + if (ev->touchPoints().size() == 2) { + QTouchEvent::TouchPoint p1 = ev->touchPoints().at(0); + QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1); + + d->hotSpot = p1.screenPos(); + d->isHotSpotSet = true; + + if (d->isNewSequence) { + d->startPosition[0] = p1.screenPos(); + d->startPosition[1] = p2.screenPos(); + } + QLineF line(p1.screenPos(), p2.screenPos()); + QLineF tmp(line); + tmp.setLength(line.length() / 2.); + QPointF centerPoint = tmp.p2(); + + d->lastCenterPoint = d->centerPoint; + d->centerPoint = centerPoint; + d->whatChanged |= QPinchGesture::CenterPointChanged; + + const qreal scaleFactor = QLineF(p1.pos(), p2.pos()).length() + / QLineF(d->startPosition[0], d->startPosition[1]).length(); + if (d->isNewSequence) { + d->lastScaleFactor = scaleFactor; } else { - d->delayManager->clear(); - QPointF mousePos = QCursor::pos(); - QPointF dist = mousePos - d->lastPosition; - d->lastPosition = mousePos; - d->lastOffset = d->offset; - d->offset = QSizeF(dist.x(), dist.y()); - d->totalOffset += d->offset; - updateState(Qt::GestureUpdated); + d->lastScaleFactor = d->scaleFactor; } - } else if (state() == Qt::NoGesture) { - d->delayManager->replay(); - consume = false; - reset(); + d->scaleFactor = scaleFactor; + d->totalScaleFactor += d->scaleFactor - d->lastScaleFactor; + d->whatChanged |= QPinchGesture::ScaleFactorChanged; + + const qreal rotationAngle = -line.angle(); + if (d->isNewSequence) + d->lastRotationAngle = rotationAngle; + else + d->lastRotationAngle = d->rotationAngle; + d->rotationAngle = rotationAngle; + d->totalRotationAngle += d->rotationAngle - d->lastRotationAngle; + d->whatChanged |= QPinchGesture::RotationAngleChanged; + + d->isNewSequence = false; + result = QGestureRecognizer::GestureTriggered; + } else { + d->isNewSequence = true; + result = QGestureRecognizer::MaybeGesture; } - break;} + break; + } case QEvent::MouseButtonPress: case QEvent::MouseMove: case QEvent::MouseButtonRelease: - if (d->delayManager->isEnabled()) - consume = d->delayManager->append(d->gestureTarget, *event); + result = QGestureRecognizer::Ignore; break; default: - return false; + result = QGestureRecognizer::Ignore; + break; } -#else - Q_UNUSED(event); -#endif - return QGestureRecognizer::Ignore; + return result; +} + +void QPinchGestureRecognizer::reset(QGesture *state) +{ + QPinchGesture *pinch = static_cast(state); + QPinchGesturePrivate *d = pinch->d_func(); + + d->whatChanged = 0; + + d->startCenterPoint = d->lastCenterPoint = d->centerPoint = QPointF(); + d->totalScaleFactor = d->lastScaleFactor = d->scaleFactor = 0; + d->totalRotationAngle = d->lastRotationAngle = d->rotationAngle = 0; + + d->isNewSequence = true; + + QGestureRecognizer::reset(state); } - */ QT_END_NAMESPACE diff --git a/src/gui/kernel/qstandardgestures_p.h b/src/gui/kernel/qstandardgestures_p.h index fec5c2f..827b2a2 100644 --- a/src/gui/kernel/qstandardgestures_p.h +++ b/src/gui/kernel/qstandardgestures_p.h @@ -69,6 +69,17 @@ public: void reset(QGesture *state); }; +class QPinchGestureRecognizer : public QGestureRecognizer +{ +public: + QPinchGestureRecognizer(); + + QGesture *createGesture(QObject *target); + + QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event); + void reset(QGesture *state); +}; + QT_END_NAMESPACE #endif // QSTANDARDGESTURES_P_H diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index ac2808c..00d9a99 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -197,6 +197,7 @@ QWidgetPrivate::QWidgetPrivate(int version) , picture(0) #elif defined(Q_WS_WIN) , noPaintOnScreen(0) + , nativeGesturePanEnabled(0) #elif defined(Q_WS_MAC) , needWindowChange(0) , isGLWidget(0) diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 5bf7649..3a92735 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -2071,17 +2071,6 @@ void QWidgetPrivate::winSetupGestures() gc[0].dwBlock = GC_PAN; } -// gc[1].dwID = GID_ZOOM; -// if (gestures.pinch) -// gc[1].dwWant = GC_ZOOM; -// else -// gc[1].dwBlock = GC_ZOOM; -// gc[2].dwID = GID_ROTATE; -// if (gestures.pinch) -// gc[2].dwWant = GC_ROTATE; -// else -// gc[2].dwBlock = GC_ROTATE; - qAppPriv->SetGestureConfig(winid, 0, sizeof(gc)/sizeof(gc[0]), gc, sizeof(gc[0])); } } diff --git a/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp b/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp index 12d3058..c3c8a28 100644 --- a/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp +++ b/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp @@ -56,16 +56,16 @@ QWinNativePanGestureRecognizer::QWinNativePanGestureRecognizer() { } -QGesture* QWinNativePanGestureRecognizer::createGesture(QObject *target) const +QGesture *QWinNativePanGestureRecognizer::createGesture(QObject *target) { if (!target) return new QPanGesture; // a special case - if (qobject_cast(target)) - return 0; if (!target->isWidgetType()) return 0; + if (qobject_cast(target)) + return 0; - QWidget *q = static_cast(target); + QWidget *q = static_cast(target); QWidgetPrivate *d = q->d_func(); d->nativeGesturePanEnabled = true; d->winSetupGestures(); diff --git a/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h b/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h index a1e8511..1d723da 100644 --- a/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h +++ b/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h @@ -62,7 +62,7 @@ class QWinNativePanGestureRecognizer : public QGestureRecognizer public: QWinNativePanGestureRecognizer(); - QGesture* createGesture(QObject *target) const; + QGesture *createGesture(QObject *target); QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event); void reset(QGesture *state); -- cgit v0.12 From 4843b437b90800d238f14e7a4558045ddc37cd4b Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 2 Nov 2009 11:13:39 +0100 Subject: Made native Pan gesture work on Windows. Reviewed-by: trustme --- src/gui/kernel/qapplication.cpp | 1 + src/gui/kernel/qapplication_p.h | 1 + src/gui/kernel/qapplication_win.cpp | 36 ++++++++++----------- src/gui/kernel/qgesturemanager.cpp | 6 ++++ src/gui/kernel/qwidget_win.cpp | 4 ++- src/gui/widgets/qabstractscrollarea.cpp | 55 +++++++++++++++++++-------------- src/gui/widgets/qplaintextedit.cpp | 53 ++++++++++++++++--------------- src/gui/widgets/qtextedit.cpp | 6 ++-- 8 files changed, 90 insertions(+), 72 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 1ec51da..06787eb 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -186,6 +186,7 @@ QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::T #endif gestureManager = 0; + gestureWidget = 0; if (!self) self = this; diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 0fa7269..2c57238 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -511,6 +511,7 @@ public: #endif QGestureManager *gestureManager; + QWidget *gestureWidget; QMap widgetForTouchPointId; QMap appCurrentTouchPoints; diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index d98ecbb..387c29b 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -2499,24 +2499,24 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam if (qAppPriv->GetGestureInfo) bResult = qAppPriv->GetGestureInfo((HANDLE)msg.lParam, &gi); if (bResult) { -// if (gi.dwID == GID_BEGIN) { -// // find the alien widget for the gesture position. -// // This might not be accurate as the position is the center -// // point of two fingers for multi-finger gestures. -// QPoint pt(gi.ptsLocation.x, gi.ptsLocation.y); -// QWidget *w = widget->childAt(widget->mapFromGlobal(pt)); -// qAppPriv->gestureWidget = w ? w : widget; -// } -// if (qAppPriv->gestureWidget) -// static_cast(qAppPriv->gestureWidget)->translateGestureEvent(msg, gi); -// if (qAppPriv->CloseGestureInfoHandle) -// qAppPriv->CloseGestureInfoHandle((HANDLE)msg.lParam); -// if (gi.dwID == GID_END) -// qAppPriv->gestureWidget = 0; -// } else { -// DWORD dwErr = GetLastError(); -// if (dwErr > 0) -// qWarning() << "translateGestureEvent: error = " << dwErr; + if (gi.dwID == GID_BEGIN) { + // find the alien widget for the gesture position. + // This might not be accurate as the position is the center + // point of two fingers for multi-finger gestures. + QPoint pt(gi.ptsLocation.x, gi.ptsLocation.y); + QWidget *w = widget->childAt(widget->mapFromGlobal(pt)); + qAppPriv->gestureWidget = w ? w : widget; + } + if (qAppPriv->gestureWidget) + static_cast(qAppPriv->gestureWidget)->translateGestureEvent(msg, gi); + if (qAppPriv->CloseGestureInfoHandle) + qAppPriv->CloseGestureInfoHandle((HANDLE)msg.lParam); + if (gi.dwID == GID_END) + qAppPriv->gestureWidget = 0; + } else { + DWORD dwErr = GetLastError(); + if (dwErr > 0) + qWarning() << "translateGestureEvent: error = " << dwErr; } result = true; break; diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 6ea350b..318d4b5 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -52,6 +52,9 @@ #ifdef Q_WS_MAC #include "qmacgesturerecognizer_mac_p.h" #endif +#if defined(Q_OS_WIN) +#include "qwinnativepangesturerecognizer_win_p.h" +#endif #include "qdebug.h" @@ -78,6 +81,9 @@ QGestureManager::QGestureManager(QObject *parent) #else registerGestureRecognizer(new QPanGestureRecognizer); registerGestureRecognizer(new QPinchGestureRecognizer); +#if defined(Q_OS_WIN) + registerGestureRecognizer(new QWinNativePanGestureRecognizer); +#endif #endif } diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 3a92735..22a94b9 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -2036,7 +2036,7 @@ void QWidgetPrivate::winSetupGestures() if (!q || !q->isVisible()) return; QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); - WId winid = q->effectiveWinId(); + WId winid = q->internalWinId(); bool needh = false; bool needv = false; @@ -2052,6 +2052,8 @@ void QWidgetPrivate::winSetupGestures() needv = (vbarpolicy == Qt::ScrollBarAlwaysOn || (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum())); singleFingerPanEnabled = asa->d_func()->singleFingerPanEnabled; + if (!winid) + winid = q->winId(); // enforces the native winid on the viewport } if (winid && qAppPriv->SetGestureConfig) { GESTURECONFIG gc[1]; diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp index 0896256..7d81d5a 100644 --- a/src/gui/widgets/qabstractscrollarea.cpp +++ b/src/gui/widgets/qabstractscrollarea.cpp @@ -293,13 +293,16 @@ void QAbstractScrollAreaPrivate::init() q->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); layoutChildren(); + viewport->grabGesture(Qt::PanGesture); } #ifdef Q_WS_WIN void QAbstractScrollAreaPrivate::setSingleFingerPanEnabled(bool on) { singleFingerPanEnabled = on; - winSetupGestures(); + QWidgetPrivate *dd = static_cast(QObjectPrivate::get(viewport)); + if (dd) + dd->winSetupGestures(); } #endif // Q_WS_WIN @@ -539,6 +542,7 @@ void QAbstractScrollArea::setViewport(QWidget *widget) d->viewport->setParent(this); d->viewport->setFocusProxy(this); d->viewport->installEventFilter(d->viewportFilter.data()); + d->viewport->grabGesture(Qt::PanGesture); d->layoutChildren(); if (isVisible()) d->viewport->show(); @@ -935,6 +939,26 @@ bool QAbstractScrollArea::event(QEvent *e) case QEvent::TouchUpdate: case QEvent::TouchEnd: return false; + case QEvent::Gesture: + { + QGestureEvent *ge = static_cast(e); + QPanGesture *g = static_cast(ge->gesture(Qt::PanGesture)); + if (g) { + QScrollBar *hBar = horizontalScrollBar(); + QScrollBar *vBar = verticalScrollBar(); + QPointF delta = g->lastOffset(); + if (!delta.isNull()) { + if (QApplication::isRightToLeft()) + delta.rx() *= -1; + int newX = hBar->value() - delta.x(); + int newY = vBar->value() - delta.y(); + hBar->setValue(newX); + vBar->setValue(newY); + } + return true; + } + return false; + } case QEvent::StyleChange: case QEvent::LayoutDirectionChange: case QEvent::ApplicationLayoutDirectionChange: @@ -990,6 +1014,8 @@ bool QAbstractScrollArea::viewportEvent(QEvent *e) #endif return QFrame::event(e); case QEvent::LayoutRequest: + case QEvent::Gesture: + case QEvent::GestureOverride: return event(e); default: break; @@ -1266,11 +1292,13 @@ void QAbstractScrollAreaPrivate::_q_vslide(int y) void QAbstractScrollAreaPrivate::_q_showOrHideScrollBars() { layoutChildren(); -#ifdef Q_OS_WIN +#ifdef Q_WS_WIN // Need to re-subscribe to gestures as the content changes to make sure we // enable/disable panning when needed. - winSetupGestures(); -#endif // Q_OS_WIN + QWidgetPrivate *dd = static_cast(QObjectPrivate::get(viewport)); + if (dd) + dd->winSetupGestures(); +#endif // Q_WS_WIN } QPoint QAbstractScrollAreaPrivate::contentsOffset() const @@ -1335,25 +1363,6 @@ void QAbstractScrollArea::setupViewport(QWidget *viewport) Q_UNUSED(viewport); } -//void QAbstractScrollAreaPrivate::_q_gestureTriggered() -//{ -// Q_Q(QAbstractScrollArea); -// QPanGesture *g = qobject_cast(q->sender()); -// if (!g) -// return; -// QScrollBar *hBar = q->horizontalScrollBar(); -// QScrollBar *vBar = q->verticalScrollBar(); -// QSizeF delta = g->lastOffset(); -// if (!delta.isNull()) { -// if (QApplication::isRightToLeft()) -// delta.rwidth() *= -1; -// int newX = hBar->value() - delta.width(); -// int newY = vBar->value() - delta.height(); -// hbar->setValue(newX); -// vbar->setValue(newY); -// } -//} - QT_END_NAMESPACE #include "moc_qabstractscrollarea.cpp" diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index fc61889..0e5ee46 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -730,9 +730,6 @@ QPlainTextEditPrivate::QPlainTextEditPrivate() backgroundVisible = false; centerOnScroll = false; inDrag = false; -#ifdef Q_WS_WIN - singleFingerPanEnabled = true; -#endif } @@ -789,6 +786,9 @@ void QPlainTextEditPrivate::init(const QString &txt) viewport->setCursor(Qt::IBeamCursor); #endif originalOffsetY = 0; +#ifdef Q_WS_WIN + setSingleFingerPanEnabled(true); +#endif } void QPlainTextEditPrivate::_q_repaintContents(const QRectF &contentsRect) @@ -1450,6 +1450,29 @@ bool QPlainTextEdit::event(QEvent *e) d->sendControlEvent(e); } #endif + else if (e->type() == QEvent::Gesture) { + QGestureEvent *ge = static_cast(e); + QPanGesture *g = static_cast(ge->gesture(Qt::PanGesture)); + if (g) { + QScrollBar *hBar = horizontalScrollBar(); + QScrollBar *vBar = verticalScrollBar(); + if (g->state() == Qt::GestureStarted) + d->originalOffsetY = vBar->value(); + QPointF totalOffset = g->totalOffset(); + if (!totalOffset.isNull()) { + if (QApplication::isRightToLeft()) + totalOffset.rx() *= -1; + // QPlainTextEdit scrolls by lines only in vertical direction + QFontMetrics fm(document()->defaultFont()); + int lineHeight = fm.height(); + int newX = hBar->value() - g->lastOffset().x(); + int newY = d->originalOffsetY - totalOffset.y()/lineHeight; + hBar->setValue(newX); + vBar->setValue(newY); + } + } + return true; + } return QAbstractScrollArea::event(e); } @@ -2929,30 +2952,6 @@ QAbstractTextDocumentLayout::PaintContext QPlainTextEdit::getPaintContext() cons (\a available is true) or unavailable (\a available is false). */ -//void QPlainTextEditPrivate::_q_gestureTriggered() -//{ -// Q_Q(QPlainTextEdit); -// QPanGesture *g = qobject_cast(q->sender()); -// if (!g) -// return; -// QScrollBar *hBar = q->horizontalScrollBar(); -// QScrollBar *vBar = q->verticalScrollBar(); -// if (g->state() == Qt::GestureStarted) -// originalOffsetY = vBar->value(); -// QSizeF totalOffset = g->totalOffset(); -// if (!totalOffset.isNull()) { -// if (QApplication::isRightToLeft()) -// totalOffset.rwidth() *= -1; -// // QPlainTextEdit scrolls by lines only in vertical direction -// QFontMetrics fm(q->document()->defaultFont()); -// int lineHeight = fm.height(); -// int newX = hBar->value() - g->lastOffset().width(); -// int newY = originalOffsetY - totalOffset.height()/lineHeight; -// hbar->setValue(newX); -// vbar->setValue(newY); -// } -//} - QT_END_NAMESPACE #include "moc_qplaintextedit.cpp" diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp index f477fee..355b678 100644 --- a/src/gui/widgets/qtextedit.cpp +++ b/src/gui/widgets/qtextedit.cpp @@ -116,9 +116,6 @@ QTextEditPrivate::QTextEditPrivate() preferRichText = false; showCursorOnInitialShow = true; inDrag = false; -#ifdef Q_WS_WIN - setSingleFingerPanEnabled(true); -#endif } void QTextEditPrivate::createAutoBulletList() @@ -186,6 +183,9 @@ void QTextEditPrivate::init(const QString &html) #ifndef QT_NO_CURSOR viewport->setCursor(Qt::IBeamCursor); #endif +#ifdef Q_WS_WIN + setSingleFingerPanEnabled(true); +#endif } void QTextEditPrivate::_q_repaintContents(const QRectF &contentsRect) -- cgit v0.12 From cfcfae65778f2e1e7fc3936c66689e3685f1cc77 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 28 Oct 2009 21:40:14 +0100 Subject: Modified gesture events propagation. By default if the gesture is ignored, only gestures in the started state are propagated, and accepting a gesture in the started state adds an implicit grab meaning all the following events in the gesture sequence will be delivered to that widget. This is similar to the way QTouchEvent is propagated. Also added a hint, which specifies if gestures in any state can be propagated to the widget which has enabled the hint. Reviewed-by: Thomas Zander --- src/corelib/global/qnamespace.h | 12 +++- src/corelib/global/qnamespace.qdoc | 18 ++++- src/gui/graphicsview/qgraphicsscene.cpp | 13 +++- src/gui/kernel/qapplication.cpp | 7 +- src/gui/kernel/qgesturemanager.cpp | 16 ++++- tests/auto/gestures/tst_gestures.cpp | 121 +++++++++++++++++++++++++------- 6 files changed, 150 insertions(+), 37 deletions(-) diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index aeaca54..561ffc1 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1715,14 +1715,19 @@ public: LastGestureType = ~0u }; - enum GestureContext + enum GestureContextFlag { WidgetGesture = 0, WidgetWithChildrenGesture = 3, - ItemGesture = WidgetGesture, - ItemWithChildrenGesture = WidgetWithChildrenGesture + ItemGesture = WidgetGesture, + ItemWithChildrenGesture = WidgetWithChildrenGesture, + + GestureContext_Mask = 0x00ff, + AcceptPartialGesturesHint = 0x0100, + GestureContextHint_Mask = 0xff00 }; + Q_DECLARE_FLAGS(GestureContext, GestureContextFlag) enum NavigationMode { @@ -1757,6 +1762,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::MatchFlags) Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::TextInteractionFlags) Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::InputMethodHints) Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::TouchPointStates) +Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::GestureContext) typedef bool (*qInternalCallback)(void **); diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 3fcbe57..f2a8882 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2917,11 +2917,11 @@ QApplication::registerGestureRecognizer() function which generates a custom gesture ID in the range of values from CustomGesture to LastGestureType. - \sa QGesture, QWidget::grabGesture() + \sa QGesture, QWidget::grabGesture(), QGraphicsObject::grabGesture() */ /*! - \enum Qt::GestureContext + \enum Qt::GestureContextFlag \since 4.6 This enum type describes the context of a gesture. @@ -2937,7 +2937,19 @@ \value ItemWithChildrenGesture Gestures can start on the item or over any of its children. - \sa QWidget::grabGesture() + \value AcceptPartialGesturesHint Allows any ignored gesture events to be + propagated to parent widgets which have specified this hint. By default + only gestures that are in the Qt::GestureStarted state are propagated and + the widget only gets the full gesture sequence starting with a gesture in + the Qt::GestureStarted state and ending with a gesture in the + Qt::GestureFinished or Qt::GestureCanceled states. + + \value GestureContext_Mask A mask for extracting the context type of the + context flags. + \value GestureContextHint_Mask A mask for extracting additional hints for + the context. + + \sa QWidget::grabGesture(), QGraphicsObject::grabGesture() */ /*! diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 9279fe3..f5bb408 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5900,7 +5900,12 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) QGraphicsItemPrivate *gid = item->QGraphicsItem::d_func(); foreach(QGesture *g, alreadyIgnoredGestures) { - if (gid->gestureContext.contains(g->gestureType())) + QMap::iterator contextit = + gid->gestureContext.find(g->gestureType()); + bool deliver = contextit != gid->gestureContext.end() && + (g->state() == Qt::GestureStarted || + (contextit.value() & Qt::GestureContextHint_Mask) & Qt::AcceptPartialGesturesHint); + if (deliver) gestures += g; } if (gestures.isEmpty()) @@ -5913,8 +5918,12 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) sendEvent(item, &ev); QSet ignoredGestures; foreach (QGesture *g, gestures) { - if (!ev.isAccepted() && !ev.isAccepted(g)) + if (!ev.isAccepted() && !ev.isAccepted(g)) { ignoredGestures.insert(g); + } else { + if (g->state() == Qt::GestureStarted) + gestureTargets[g] = item; + } } if (!ignoredGestures.isEmpty()) { // get a list of items under the (current) hotspot of each ignored diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 06787eb..b9e7d52 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -4161,7 +4161,12 @@ bool QApplication::notify(QObject *receiver, QEvent *e) for (int i = 0; i < allGestures.size();) { QGesture *g = allGestures.at(i); Qt::GestureType type = g->gestureType(); - if (wd->gestureContext.contains(type)) { + QMap::iterator contextit = + wd->gestureContext.find(type); + bool deliver = contextit != wd->gestureContext.end() && + (g->state() == Qt::GestureStarted || w == receiver || + (contextit.value() & Qt::GestureContextHint_Mask) & Qt::AcceptPartialGesturesHint); + if (deliver) { allGestures.removeAt(i); gestures.append(g); } else { diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 318d4b5..e4a1eb4 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -448,7 +448,7 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) { for (ContextIterator it = w->d_func()->gestureContext.begin(), e = w->d_func()->gestureContext.end(); it != e; ++it) { - if (it.value() == Qt::WidgetWithChildrenGesture) { + if ((it.value() & Qt::GestureContext_Mask) == Qt::WidgetWithChildrenGesture) { if (!types.contains(it.key())) { types.insert(it.key()); contexts.insertMulti(w, it.key()); @@ -482,7 +482,7 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) typedef QMap::const_iterator ContextIterator; for (ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.begin(), e = item->QGraphicsItem::d_func()->gestureContext.end(); it != e; ++it) { - if (it.value() == Qt::ItemWithChildrenGesture) { + if ((it.value() & Qt::GestureContext_Mask) == Qt::ItemWithChildrenGesture) { if (!types.contains(it.key())) { types.insert(it.key()); contexts.insertMulti(item, it.key()); @@ -525,7 +525,7 @@ void QGestureManager::getGestureTargets(const QSet &gestures, = w->d_func()->gestureContext.find(type); if (it != w->d_func()->gestureContext.end()) { // i.e. 'w' listens to gesture 'type' - Qt::GestureContext context = it.value(); + Qt::GestureContext context = it.value() & Qt::GestureContext_Mask; if (context == Qt::WidgetWithChildrenGesture && w != widget) { // conflicting gesture! (*conflicts)[widget].append(gestures[widget]); @@ -645,6 +645,16 @@ void QGestureManager::deliverEvents(const QSet &gestures, << "gestures:" << it.value(); QGestureEvent event(it.value()); QApplication::sendEvent(it.key(), &event); + bool eventAccepted = event.isAccepted(); + foreach (QGesture *gesture, event.allGestures()) { + if (gesture->state() == Qt::GestureStarted && + (eventAccepted || event.isAccepted(gesture))) { + QWidget *w = event.d_func()->targetWidgets.value(gesture->gestureType(), 0); + Q_ASSERT(w); + DEBUG() << "started gesture was delivered and accepted by" << w; + m_gestureTargets[gesture] = w; + } + } } } } diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 79de823..9b2bc57 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -543,7 +543,9 @@ void tst_Gestures::conflictingGestures() parent.reset(); child->reset(); - // nobody accepts the override, we will send normal events to the closest context (to the child) + // nobody accepts the override, we will send normal events to the closest + // context (i.e. to the child widget) and it will be propagated and + // accepted by the parent widget parent.acceptGestureOverride = false; child->acceptGestureOverride = false; child->ignoredGestures << CustomGesture::GestureType; @@ -552,6 +554,41 @@ void tst_Gestures::conflictingGestures() sendCustomGesture(&event, child); QCOMPARE(child->gestureOverrideEventsReceived, 1); + QCOMPARE(child->gestureEventsReceived, 1); + QCOMPARE(parent.gestureOverrideEventsReceived, 1); + QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount); + + parent.reset(); + child->reset(); + + // nobody accepts the override, and nobody accepts the gesture event + parent.acceptGestureOverride = false; + child->acceptGestureOverride = false; + parent.ignoredGestures << CustomGesture::GestureType; + child->ignoredGestures << CustomGesture::GestureType; + + // sending events to the child and making sure there is no conflict + sendCustomGesture(&event, child); + + QCOMPARE(child->gestureOverrideEventsReceived, 1); + QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(parent.gestureOverrideEventsReceived, 1); + QCOMPARE(parent.gestureEventsReceived, 1); + + parent.reset(); + child->reset(); + + // we set an attribute to make sure all gesture events are propagated + parent.grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture | Qt::AcceptPartialGesturesHint); + parent.acceptGestureOverride = false; + child->acceptGestureOverride = false; + parent.ignoredGestures << CustomGesture::GestureType; + child->ignoredGestures << CustomGesture::GestureType; + + // sending events to the child and making sure there is no conflict + sendCustomGesture(&event, child); + + QCOMPARE(child->gestureOverrideEventsReceived, 1); QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount); QCOMPARE(parent.gestureOverrideEventsReceived, 1); QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount); @@ -851,7 +888,7 @@ void tst_Gestures::graphicsItemTreeGesture() QCOMPARE(item1_child2->gestureEventsReceived, 0); QCOMPARE(item1_child2->gestureOverrideEventsReceived, 0); QCOMPARE(item1->gestureOverrideEventsReceived, 1); - QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item1->gestureEventsReceived, 1); } void tst_Gestures::explicitGraphicsObjectTarget() @@ -966,7 +1003,39 @@ void tst_Gestures::gestureOverChildGraphicsItem() event.hasHotSpot = true; sendCustomGesture(&event, item0, &scene); - QCOMPARE(item0->customEventsReceived, TotalCustomEventsCount); + QCOMPARE(item2_child1->gestureEventsReceived, 0); + QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0); + QCOMPARE(item2->gestureEventsReceived, 1); + QCOMPARE(item2->gestureOverrideEventsReceived, 1); + QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item1->gestureOverrideEventsReceived, 1); + + item0->reset(); item1->reset(); item2->reset(); item2_child1->reset(); + item2->grabGesture(CustomGesture::GestureType); + item2->ignoredGestures << CustomGesture::GestureType; + item1->ignoredGestures << CustomGesture::GestureType; + + event.hotSpot = mapToGlobal(QPointF(10, 10), item2_child1, &view); + event.hasHotSpot = true; + sendCustomGesture(&event, item0, &scene); + + QCOMPARE(item2_child1->gestureEventsReceived, 0); + QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0); + QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item2->gestureOverrideEventsReceived, 1); + QCOMPARE(item1->gestureEventsReceived, 1); + QCOMPARE(item1->gestureOverrideEventsReceived, 1); + + item0->reset(); item1->reset(); item2->reset(); item2_child1->reset(); + item2->grabGesture(CustomGesture::GestureType); + item2->ignoredGestures << CustomGesture::GestureType; + item1->ignoredGestures << CustomGesture::GestureType; + item1->grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture | Qt::AcceptPartialGesturesHint); + + event.hotSpot = mapToGlobal(QPointF(10, 10), item2_child1, &view); + event.hasHotSpot = true; + sendCustomGesture(&event, item0, &scene); + QCOMPARE(item2_child1->gestureEventsReceived, 0); QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0); QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount); @@ -1025,15 +1094,16 @@ void tst_Gestures::multipleGesturesInTree() Qt::GestureType SecondGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); Qt::GestureType ThirdGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); - A->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // A [1 3] - A->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // | - B->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture); // B [ 2 3] - B->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // | - C->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // C [1 2 3] - C->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture); // | - C->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // D [1 3] - D->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); - D->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); + Qt::GestureContext context = Qt::WidgetWithChildrenGesture | Qt::AcceptPartialGesturesHint; + A->grabGesture(FirstGesture, context); // A [1 3] + A->grabGesture(ThirdGesture, context); // | + B->grabGesture(SecondGesture, context); // B [ 2 3] + B->grabGesture(ThirdGesture, context); // | + C->grabGesture(FirstGesture, context); // C [1 2 3] + C->grabGesture(SecondGesture, context); // | + C->grabGesture(ThirdGesture, context); // D [1 3] + D->grabGesture(FirstGesture, context); + D->grabGesture(ThirdGesture, context); // make sure all widgets ignore events, so they get propagated. A->ignoredGestures << FirstGesture << ThirdGesture; @@ -1100,19 +1170,20 @@ void tst_Gestures::multipleGesturesInComplexTree() Qt::GestureType SixthGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); Qt::GestureType SeventhGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); - A->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // A [1,3,4] - A->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // | - A->grabGesture(FourthGesture, Qt::WidgetWithChildrenGesture); // B [2,3,5] - B->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture); // | - B->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // C [1,2,3,6] - B->grabGesture(FifthGesture, Qt::WidgetWithChildrenGesture); // | - C->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // D [1,3,7] - C->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture); - C->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); - C->grabGesture(SixthGesture, Qt::WidgetWithChildrenGesture); - D->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); - D->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); - D->grabGesture(SeventhGesture, Qt::WidgetWithChildrenGesture); + Qt::GestureContext context = Qt::WidgetWithChildrenGesture | Qt::AcceptPartialGesturesHint; + A->grabGesture(FirstGesture, context); // A [1,3,4] + A->grabGesture(ThirdGesture, context); // | + A->grabGesture(FourthGesture, context); // B [2,3,5] + B->grabGesture(SecondGesture, context); // | + B->grabGesture(ThirdGesture, context); // C [1,2,3,6] + B->grabGesture(FifthGesture, context); // | + C->grabGesture(FirstGesture, context); // D [1,3,7] + C->grabGesture(SecondGesture, context); + C->grabGesture(ThirdGesture, context); + C->grabGesture(SixthGesture, context); + D->grabGesture(FirstGesture, context); + D->grabGesture(ThirdGesture, context); + D->grabGesture(SeventhGesture, context); // make sure all widgets ignore events, so they get propagated. QSet allGestureTypes; -- cgit v0.12 From 93e9bc06427c6a8e1b6d6f939cf53ae5c95e0827 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 2 Nov 2009 19:26:44 +0100 Subject: Gesture api review. Changes to the gesture api after the review. Reviewed-by: Jasmin Blanchette --- doc/src/frameworks-technologies/gestures.qdoc | 14 +- examples/gestures/imagegestures/imagewidget.cpp | 6 +- src/corelib/global/qnamespace.h | 17 +- src/corelib/global/qnamespace.qdoc | 36 ++-- src/gui/graphicsview/qgraphicsitem.cpp | 6 +- src/gui/graphicsview/qgraphicsitem.h | 2 +- src/gui/graphicsview/qgraphicsitem_p.h | 2 +- src/gui/graphicsview/qgraphicsscene.cpp | 16 +- src/gui/kernel/qapplication.cpp | 54 +----- src/gui/kernel/qapplication.h | 4 - src/gui/kernel/qapplication_p.h | 2 - src/gui/kernel/qevent.cpp | 22 ++- src/gui/kernel/qevent.h | 4 +- src/gui/kernel/qgesture.cpp | 89 +++++---- src/gui/kernel/qgesture.h | 21 +- src/gui/kernel/qgesture_p.h | 10 +- src/gui/kernel/qgesturemanager.cpp | 44 +++-- src/gui/kernel/qgesturemanager_p.h | 3 +- src/gui/kernel/qgesturerecognizer.cpp | 86 ++++++--- src/gui/kernel/qgesturerecognizer.h | 25 ++- src/gui/kernel/qstandardgestures.cpp | 63 +++--- src/gui/kernel/qstandardgestures_p.h | 9 +- src/gui/kernel/qwidget.cpp | 8 +- src/gui/kernel/qwidget.h | 2 +- src/gui/kernel/qwidget_p.h | 2 +- src/gui/widgets/qplaintextedit.cpp | 8 +- tests/auto/gestures/tst_gestures.cpp | 212 ++++++++++----------- tests/manual/gestures/graphicsview/gestures.cpp | 24 +-- tests/manual/gestures/graphicsview/gestures.h | 8 +- tests/manual/gestures/graphicsview/main.cpp | 10 +- .../graphicsview/mousepangesturerecognizer.cpp | 25 +-- .../graphicsview/mousepangesturerecognizer.h | 4 +- tests/manual/gestures/scrollarea/main.cpp | 20 +- .../scrollarea/mousepangesturerecognizer.cpp | 25 +-- .../scrollarea/mousepangesturerecognizer.h | 4 +- 35 files changed, 441 insertions(+), 446 deletions(-) diff --git a/doc/src/frameworks-technologies/gestures.qdoc b/doc/src/frameworks-technologies/gestures.qdoc index f64e301..2fa8dab 100644 --- a/doc/src/frameworks-technologies/gestures.qdoc +++ b/doc/src/frameworks-technologies/gestures.qdoc @@ -122,7 +122,7 @@ \section2 Filtering Input Events - The \l{QGestureRecognizer::}{filterEvent()} function must be reimplemented. + The \l{QGestureRecognizer::}{recognize()} function must be reimplemented. This function handles and filters the incoming input events for the target objects and determines whether or not they correspond to the gesture the recognizer is looking for. @@ -132,15 +132,15 @@ persistent information about the state of the recognition process in the QGesture object supplied. - Your \l{QGestureRecognizer::}{filterEvent()} function must return a value of - Qt::GestureState that indicates the state of recognition for a given gesture and + Your \l{QGestureRecognizer::}{recognize()} function must return a value of + QGestureRecognizer::Result that indicates the state of recognition for a given gesture and target object. This determines whether or not a gesture event will be delivered to a target object. \section2 Custom Gestures If you choose to represent a gesture by a custom QGesture subclass, you will need to - reimplement the \l{QGestureRecognizer::}{createGesture()} function to construct + reimplement the \l{QGestureRecognizer::}{create()} function to construct instances of your gesture class instead of standard QGesture instances. Alternatively, you may want to use standard QGesture instances, but add additional dynamic properties to them to express specific details of the gesture you want to handle. @@ -152,7 +152,7 @@ \l{QGestureRecognizer::}{reset()} function to perform these special tasks. Note that QGesture objects are only created once for each combination of target object - and gesture type, and they are reused every time the user attempts to perform the + and gesture type, and they might be reused every time the user attempts to perform the same gesture type on the target object. As a result, it can be useful to reimplement the \l{QGestureRecognizer::}{reset()} function to clean up after each previous attempt at recognizing a gesture. @@ -162,8 +162,8 @@ To use a gesture recognizer, construct an instance of your QGestureRecognizer subclass, and register it with the application with - QApplication::registerGestureRecognizer(). A recognizer for a given type of - gesture can be removed with QApplication::unregisterGestureRecognizer(). + QGestureRecognizer::registerRecognizer(). A recognizer for a given type of + gesture can be removed with QGestureRecognizer::unregisterRecognizer(). \section1 Further Reading diff --git a/examples/gestures/imagegestures/imagewidget.cpp b/examples/gestures/imagegestures/imagewidget.cpp index c798fcc..da9daae 100644 --- a/examples/gestures/imagegestures/imagewidget.cpp +++ b/examples/gestures/imagegestures/imagewidget.cpp @@ -132,13 +132,13 @@ void ImageWidget::panTriggered(QPanGesture *gesture) void ImageWidget::pinchTriggered(QPinchGesture *gesture) { - QPinchGesture::WhatChanged whatChanged = gesture->whatChanged(); - if (whatChanged & QPinchGesture::RotationAngleChanged) { + QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags(); + if (changeFlags & QPinchGesture::RotationAngleChanged) { qreal value = gesture->property("rotationAngle").toReal(); qreal lastValue = gesture->property("lastRotationAngle").toReal(); rotationAngle += value - lastValue; } - if (whatChanged & QPinchGesture::ScaleFactorChanged) { + if (changeFlags & QPinchGesture::ScaleFactorChanged) { qreal value = gesture->property("scaleFactor").toReal(); qreal lastValue = gesture->property("lastScaleFactor").toReal(); scaleFactor += value - lastValue; diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 561ffc1..efa6cc7 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1715,19 +1715,12 @@ public: LastGestureType = ~0u }; - enum GestureContextFlag + enum GestureFlag { - WidgetGesture = 0, - WidgetWithChildrenGesture = 3, - - ItemGesture = WidgetGesture, - ItemWithChildrenGesture = WidgetWithChildrenGesture, - - GestureContext_Mask = 0x00ff, - AcceptPartialGesturesHint = 0x0100, - GestureContextHint_Mask = 0xff00 + DontStartGestureOnChildren = 0x01, + ReceivePartialGestures = 0x02 }; - Q_DECLARE_FLAGS(GestureContext, GestureContextFlag) + Q_DECLARE_FLAGS(GestureFlags, GestureFlag) enum NavigationMode { @@ -1762,7 +1755,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::MatchFlags) Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::TextInteractionFlags) Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::InputMethodHints) Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::TouchPointStates) -Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::GestureContext) +Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::GestureFlags) typedef bool (*qInternalCallback)(void **); diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index f2a8882..a00a72b 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2910,45 +2910,35 @@ \value PanGesture A Pan gesture. \value PinchGesture A Pinch gesture. \value SwipeGesture A Swipe gesture. - \value CustomGesture User-defined gesture ID. - \value LastGestureType Last user gesture ID. + \value CustomGesture A flag that can be used to test if the gesture is a + user-defined gesture ID. + \omitvalue LastGestureType User-defined gestures are registered with the - QApplication::registerGestureRecognizer() function which generates a custom gesture ID - in the range of values from CustomGesture to LastGestureType. + QGestureRecognizer::registerRecognizer() function which generates a custom + gesture ID with the Qt::CustomGesture flag set. \sa QGesture, QWidget::grabGesture(), QGraphicsObject::grabGesture() */ /*! - \enum Qt::GestureContextFlag + \enum Qt::GestureFlag \since 4.6 - This enum type describes the context of a gesture. + This enum type describes additional flags that can be used when subscribing + to a gesture. - For a QGesture to trigger, the gesture recognizer should filter events for - a widget tree. This enum describes for which widget the gesture recognizer - should filter events: + \value DontStartGestureOnChildren By default gestures can start on the + widget or over any of its children. Use this flag to disable this and allow + a gesture to start on the widget only. - \value WidgetGesture Gestures can only start over the widget itself. - \value WidgetWithChildrenGesture Gestures can start on the widget or over - any of its children. - \value ItemGesture Gestures can only start over the item itself. - \value ItemWithChildrenGesture Gestures can start on the item or over - any of its children. - - \value AcceptPartialGesturesHint Allows any ignored gesture events to be + \value ReceivePartialGestures Allows any ignored gesture events to be propagated to parent widgets which have specified this hint. By default only gestures that are in the Qt::GestureStarted state are propagated and - the widget only gets the full gesture sequence starting with a gesture in + the widget always gets the full gesture sequence starting with a gesture in the Qt::GestureStarted state and ending with a gesture in the Qt::GestureFinished or Qt::GestureCanceled states. - \value GestureContext_Mask A mask for extracting the context type of the - context flags. - \value GestureContextHint_Mask A mask for extracting additional hints for - the context. - \sa QWidget::grabGesture(), QGraphicsObject::grabGesture() */ diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 58d7e7d..72f08d5 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -7320,14 +7320,14 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent } /*! - Subscribes the graphics object to the given \a gesture for the specified \a context. + Subscribes the graphics object to the given \a gesture with specific \a flags. \sa ungrabGesture(), QGestureEvent */ -void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureContext context) +void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags) { QGraphicsItemPrivate * const d = QGraphicsItem::d_func(); - d->gestureContext.insert(gesture, context); + d->gestureContext.insert(gesture, flags); (void)QGestureManager::instance(); // create a gesture manager } diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index fc180f3..f091e34 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -555,7 +555,7 @@ public: using QObject::children; #endif - void grabGesture(Qt::GestureType type, Qt::GestureContext context = Qt::ItemWithChildrenGesture); + void grabGesture(Qt::GestureType type, Qt::GestureFlags flags = Qt::GestureFlags()); void ungrabGesture(Qt::GestureType type); Q_SIGNALS: diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 183e95b..90e4631 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -453,7 +453,7 @@ public: QGraphicsItem *focusScopeItem; Qt::InputMethodHints imHints; QGraphicsItem::PanelModality panelModality; - QMap gestureContext; + QMap gestureContext; // Packed 32 bits quint32 acceptedMouseButtons : 5; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index f5bb408..aed2837 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -1060,9 +1060,8 @@ bool QGraphicsScenePrivate::filterEvent(QGraphicsItem *item, QEvent *event) bool QGraphicsScenePrivate::sendEvent(QGraphicsItem *item, QEvent *event) { if (QGraphicsObject *object = item->toGraphicsObject()) { - QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); - if (qAppPriv->gestureManager) { - if (qAppPriv->gestureManager->filterEvent(object, event)) + if (qt_gestureManager) { + if (qt_gestureManager->filterEvent(object, event)) return true; } } @@ -5761,7 +5760,7 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) QWidget *viewport = event->widget(); if (!viewport) return; - QList allGestures = event->allGestures(); + QList allGestures = event->gestures(); DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:" << "Delivering gestures:" << allGestures; @@ -5900,11 +5899,11 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) QGraphicsItemPrivate *gid = item->QGraphicsItem::d_func(); foreach(QGesture *g, alreadyIgnoredGestures) { - QMap::iterator contextit = + QMap::iterator contextit = gid->gestureContext.find(g->gestureType()); bool deliver = contextit != gid->gestureContext.end() && (g->state() == Qt::GestureStarted || - (contextit.value() & Qt::GestureContextHint_Mask) & Qt::AcceptPartialGesturesHint); + (contextit.value() & Qt::ReceivePartialGestures)); if (deliver) gestures += g; } @@ -6046,10 +6045,9 @@ void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original, QWidge } } - QGestureManager *gm = QApplicationPrivate::instance()->gestureManager; - Q_ASSERT(gm); // it would be very odd if we got called without a manager. + Q_ASSERT(qt_gestureManager); // it would be very odd if we got called without a manager. for (setIter = canceledGestures.begin(); setIter != canceledGestures.end(); ++setIter) { - gm->recycle(*setIter); + qt_gestureManager->recycle(*setIter); gestureTargets.remove(*setIter); } } diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index b9e7d52..60ab05a 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -154,14 +154,6 @@ bool QApplicationPrivate::autoSipEnabled = false; bool QApplicationPrivate::autoSipEnabled = true; #endif -QGestureManager* QGestureManager::instance() -{ - QApplicationPrivate *d = qApp->d_func(); - if (!d->gestureManager) - d->gestureManager = new QGestureManager(qApp); - return d->gestureManager; -} - QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::Type type) : QCoreApplicationPrivate(argc, argv) { @@ -185,7 +177,6 @@ QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::T directPainters = 0; #endif - gestureManager = 0; gestureWidget = 0; if (!self) @@ -3632,12 +3623,12 @@ bool QApplication::notify(QObject *receiver, QEvent *e) } // walk through parents and check for gestures - if (d->gestureManager) { + if (qt_gestureManager) { if (receiver->isWidgetType()) { - if (d->gestureManager->filterEvent(static_cast(receiver), e)) + if (qt_gestureManager->filterEvent(static_cast(receiver), e)) return true; } else if (QGesture *gesture = qobject_cast(receiver)) { - if (d->gestureManager->filterEvent(gesture, e)) + if (qt_gestureManager->filterEvent(gesture, e)) return true; } } @@ -4150,7 +4141,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) if (receiver->isWidgetType()) { QWidget *w = static_cast(receiver); QGestureEvent *gestureEvent = static_cast(e); - QList allGestures = gestureEvent->allGestures(); + QList allGestures = gestureEvent->gestures(); bool eventAccepted = gestureEvent->isAccepted(); bool wasAccepted = eventAccepted; @@ -4161,11 +4152,11 @@ bool QApplication::notify(QObject *receiver, QEvent *e) for (int i = 0; i < allGestures.size();) { QGesture *g = allGestures.at(i); Qt::GestureType type = g->gestureType(); - QMap::iterator contextit = + QMap::iterator contextit = wd->gestureContext.find(type); bool deliver = contextit != wd->gestureContext.end() && (g->state() == Qt::GestureStarted || w == receiver || - (contextit.value() & Qt::GestureContextHint_Mask) & Qt::AcceptPartialGesturesHint); + (contextit.value() & Qt::ReceivePartialGestures)); if (deliver) { allGestures.removeAt(i); gestures.append(g); @@ -5616,39 +5607,6 @@ Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window, QApplicationPrivate::translateRawTouchEvent(window, deviceType, touchPoints); } -/*! - \since 4.6 - - Registers the given \a recognizer in the gesture framework and returns a gesture ID - for it. - - The application takes ownership of the \a recognizer and returns the gesture type - ID associated with it. For gesture recognizers which handle custom QGesture - objects (i.e., those which return Qt::CustomGesture in a QGesture::gestureType() - function) the return value is a gesture ID between Qt::CustomGesture and - Qt::LastGestureType, inclusive. - - \sa unregisterGestureRecognizer(), QGestureRecognizer::createGesture(), QGesture -*/ -Qt::GestureType QApplication::registerGestureRecognizer(QGestureRecognizer *recognizer) -{ - return QGestureManager::instance()->registerGestureRecognizer(recognizer); -} - -/*! - \since 4.6 - - Unregisters all gesture recognizers of the specified \a type. - - \sa registerGestureRecognizer() -*/ -void QApplication::unregisterGestureRecognizer(Qt::GestureType type) -{ - QApplicationPrivate *d = qApp->d_func(); - if (d->gestureManager) - d->gestureManager->unregisterGestureRecognizer(type); -} - QT_END_NAMESPACE #include "moc_qapplication.cpp" diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h index 5877ba4..e8c1281 100644 --- a/src/gui/kernel/qapplication.h +++ b/src/gui/kernel/qapplication.h @@ -86,7 +86,6 @@ class QSymbianEvent; class QApplication; class QApplicationPrivate; -class QGestureRecognizer; #if defined(qApp) #undef qApp #endif @@ -288,9 +287,6 @@ public: static Qt::NavigationMode navigationMode(); #endif - static Qt::GestureType registerGestureRecognizer(QGestureRecognizer *recognizer); - static void unregisterGestureRecognizer(Qt::GestureType type); - Q_SIGNALS: void lastWindowClosed(); void focusChanged(QWidget *old, QWidget *now); diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 2c57238..8df4d08 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -84,7 +84,6 @@ class QInputContext; class QObject; class QWidget; class QSocketNotifier; -class QGestureManager; extern bool qt_is_gui_used; #ifndef QT_NO_CLIPBOARD @@ -510,7 +509,6 @@ public: void sendSyntheticEnterLeave(QWidget *widget); #endif - QGestureManager *gestureManager; QWidget *gestureWidget; QMap widgetForTouchPointId; diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 6757fa2..763b681 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4202,7 +4202,7 @@ QTouchEvent::TouchPoint &QTouchEvent::TouchPoint::operator=(const QTouchEvent::T \brief The QGestureEvent class provides the description of triggered gestures. The QGestureEvent class contains a list of gestures, which can be obtained using the - allGestures() function. + gestures() function. The gestures are either active or canceled. A list of those that are currently being executed can be obtained using the activeGestures() function. A list of those which @@ -4211,10 +4211,11 @@ QTouchEvent::TouchPoint &QTouchEvent::TouchPoint::operator=(const QTouchEvent::T focus, for example, or because of a timeout, or for other reasons. If the event handler does not accept the event by calling the generic - QEvent::accept() function, all individual QGesture object that were not accepted - will be propagated up the parent widget chain until a widget accepts them - individually, by calling QGestureEvent::accept() for each of them, or an event - filter consumes the event. + QEvent::accept() function, all individual QGesture object that were not + accepted and in the Qt::GestureStarted state will be propagated up the + parent widget chain until a widget accepts them individually, by calling + QGestureEvent::accept() for each of them, or an event filter consumes the + event. \sa QGesture, QGestureRecognizer, QWidget::grabGesture(), QGraphicsObject::grabGesture() @@ -4240,7 +4241,7 @@ QGestureEvent::~QGestureEvent() /*! Returns all gestures that are delivered in the event. */ -QList QGestureEvent::allGestures() const +QList QGestureEvent::gestures() const { return d_func()->gestures; } @@ -4417,11 +4418,16 @@ QWidget *QGestureEvent::widget() const } /*! - Returns the scene-local coordinates if the \a gesturePoint is inside a graphics view. + Returns the scene-local coordinates if the \a gesturePoint is inside a + graphics view. + + This functional might be useful when the gesture event is delivered to a + QGraphicsObject to translate a point in screen coordinates to scene-local + coordinates. \sa QPointF::isNull(). */ -QPointF QGestureEvent::mapToScene(const QPointF &gesturePoint) const +QPointF QGestureEvent::mapToGraphicsScene(const QPointF &gesturePoint) const { QWidget *w = widget(); if (w) // we get the viewport as widget, not the graphics view diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index fb245c0..dfd0f33 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -827,7 +827,7 @@ public: QGestureEvent(const QList &gestures); ~QGestureEvent(); - QList allGestures() const; + QList gestures() const; QGesture *gesture(Qt::GestureType type) const; QList activeGestures() const; @@ -859,7 +859,7 @@ public: void setWidget(QWidget *widget); QWidget *widget() const; - QPointF mapToScene(const QPointF &gesturePoint) const; + QPointF mapToGraphicsScene(const QPointF &gesturePoint) const; private: QGestureEventPrivate *d_func(); diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index df99746..e322af2 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE Gesture objects are not constructed directly by developers. They are created by the QGestureRecognizer object that is registered with the application; see - QApplication::registerGestureRecognizer(). + QGestureRecognizer::registerRecognizer(). \section1 Gesture Properties @@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE destroy particular instances of them and create new ones to replace them. The registered gesture recognizer monitors the input events for the target - object via its \l{QGestureRecognizer::}{filterEvent()} function, updating the + object via its \l{QGestureRecognizer::}{recognize()} function, updating the properties of the gesture object as required. The gesture object may be delivered to the target object in a QGestureEvent if @@ -90,7 +90,7 @@ QT_BEGIN_NAMESPACE Constructs a new gesture object with the given \a parent. QGesture objects are created by gesture recognizers in the - QGestureRecognizer::createGesture() function. + QGestureRecognizer::create() function. */ QGesture::QGesture(QObject *parent) : QObject(*new QGesturePrivate, parent) @@ -129,7 +129,7 @@ QGesture::~QGesture() \brief The point that is used to find the receiver for the gesture event. The hot-spot is a point in the global coordinate system, use - QWidget::mapFromGlobal() or QGestureEvent::mapToScene() to get a + QWidget::mapFromGlobal() or QGestureEvent::mapToGraphicsScene() to get a local hot-spot. The hot-spot should be set by the gesture recognizer to allow gesture event @@ -180,8 +180,10 @@ void QGesture::unsetHotSpot() automatically. \value CancelNone On accepting this gesture no other gestures will be affected. - \value CancelAllInContext On accepting this gesture all gestures that are active - in the context (Qt::GestureContext) will be cancelled. + + \value CancelAllInContext On accepting this gesture all gestures that are + active in the context (respecting the Qt::GestureFlag that were specified + when subscribed to the gesture) will be cancelled. */ void QGesture::setGestureCancelPolicy(GestureCancelPolicy policy) @@ -208,15 +210,6 @@ QGesture::GestureCancelPolicy QGesture::gestureCancelPolicy() const */ /*! - \property QPanGesture::totalOffset - \brief the total offset from the first input position to the current input - position - - The total offset measures the total change in position of the user's input - covered by the gesture on the input device. -*/ - -/*! \property QGesture::gestureCancelPolicy \brief the policy for deciding what happens on accepting a gesture @@ -241,11 +234,19 @@ QGesture::GestureCancelPolicy QGesture::gestureCancelPolicy() const /*! \property QPanGesture::offset - \brief the offset from the previous input position to the current input + \brief the total offset from the first input position to the current input position - The offset measures the change in position of the user's input on the - input device. + The offset measures the total change in position of the user's input + covered by the gesture on the input device. +*/ + +/*! + \property QPanGesture::delta + \brief the offset from the previous input position to the current input + + This is essentially the same as the difference between offset() and + lastOffset(). */ /*! @@ -261,10 +262,6 @@ QPanGesture::QPanGesture(QObject *parent) d_func()->gestureType = Qt::PanGesture; } -QPointF QPanGesture::totalOffset() const -{ - return d_func()->totalOffset; -} QPointF QPanGesture::lastOffset() const { @@ -276,15 +273,15 @@ QPointF QPanGesture::offset() const return d_func()->offset; } -qreal QPanGesture::acceleration() const +QPointF QPanGesture::delta() const { - return d_func()->acceleration; + Q_D(const QPanGesture); + return d->offset - d->lastOffset; } - -void QPanGesture::setTotalOffset(const QPointF &value) +qreal QPanGesture::acceleration() const { - d_func()->totalOffset = value; + return d_func()->acceleration; } void QPanGesture::setLastOffset(const QPointF &value) @@ -326,7 +323,7 @@ void QPanGesture::setAcceleration(qreal value) */ /*! - \enum QPinchGesture::WhatChange + \enum QPinchGesture::ChangeFlag This enum describes the changes that can occur to the properties of the gesture object. @@ -335,19 +332,30 @@ void QPanGesture::setAcceleration(qreal value) \value RotationAngleChanged The rotation angle held by rotationAngle changed. \value CenterPointChanged The center point held by centerPoint changed. - \sa whatChanged + \sa changeFlags, totalChangeFlags +*/ + +/*! + \property QPinchGesture::totalChangeFlags + \brief the property of the gesture that has change + + This property indicates which of the other properties has changed since the + gesture has started. You can use this information to determine which aspect + of your user interface needs to be updated. + + \sa changeFlags, scaleFactor, rotationAngle, centerPoint */ /*! - \property QPinchGesture::whatChanged - \brief the property of the gesture that has changed + \property QPinchGesture::changeFlags + \brief the property of the gesture that has changed in the current step This property indicates which of the other properties has changed since the previous gesture event included information about this gesture. You can use this information to determine which aspect of your user interface needs to be updated. - \sa scaleFactor, rotationAngle, centerPoint + \sa totalChangeFlags, scaleFactor, rotationAngle, centerPoint */ /*! @@ -441,16 +449,25 @@ QPinchGesture::QPinchGesture(QObject *parent) d_func()->gestureType = Qt::PinchGesture; } -QPinchGesture::WhatChanged QPinchGesture::whatChanged() const +QPinchGesture::ChangeFlags QPinchGesture::totalChangeFlags() const +{ + return d_func()->totalChangeFlags; +} + +void QPinchGesture::setTotalChangeFlags(QPinchGesture::ChangeFlags value) { - return d_func()->whatChanged; + d_func()->totalChangeFlags = value; } -void QPinchGesture::setWhatChanged(QPinchGesture::WhatChanged value) +QPinchGesture::ChangeFlags QPinchGesture::changeFlags() const { - d_func()->whatChanged = value; + return d_func()->changeFlags; } +void QPinchGesture::setChangeFlags(QPinchGesture::ChangeFlags value) +{ + d_func()->changeFlags = value; +} QPointF QPinchGesture::startCenterPoint() const { diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h index 8614ecb..dd322ad 100644 --- a/src/gui/kernel/qgesture.h +++ b/src/gui/kernel/qgesture.h @@ -106,20 +106,19 @@ class Q_GUI_EXPORT QPanGesture : public QGesture Q_OBJECT Q_DECLARE_PRIVATE(QPanGesture) - Q_PROPERTY(QPointF totalOffset READ totalOffset WRITE setTotalOffset) Q_PROPERTY(QPointF lastOffset READ lastOffset WRITE setLastOffset) Q_PROPERTY(QPointF offset READ offset WRITE setOffset) + Q_PROPERTY(QPointF delta READ delta STORED false) Q_PROPERTY(qreal acceleration READ acceleration WRITE setAcceleration) public: QPanGesture(QObject *parent = 0); - QPointF totalOffset() const; QPointF lastOffset() const; QPointF offset() const; + QPointF delta() const; qreal acceleration() const; - void setTotalOffset(const QPointF &value); void setLastOffset(const QPointF &value); void setOffset(const QPointF &value); void setAcceleration(qreal value); @@ -135,14 +134,15 @@ class Q_GUI_EXPORT QPinchGesture : public QGesture Q_DECLARE_PRIVATE(QPinchGesture) public: - enum WhatChange { + enum ChangeFlag { ScaleFactorChanged = 0x1, RotationAngleChanged = 0x2, CenterPointChanged = 0x4 }; - Q_DECLARE_FLAGS(WhatChanged, WhatChange) + Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag) - Q_PROPERTY(WhatChanged whatChanged READ whatChanged WRITE setWhatChanged) + Q_PROPERTY(ChangeFlags totalChangeFlags READ totalChangeFlags WRITE setTotalChangeFlags) + Q_PROPERTY(ChangeFlags changeFlags READ changeFlags WRITE setChangeFlags) Q_PROPERTY(qreal totalScaleFactor READ totalScaleFactor WRITE setTotalScaleFactor) Q_PROPERTY(qreal lastScaleFactor READ lastScaleFactor WRITE setLastScaleFactor) @@ -159,8 +159,11 @@ public: public: QPinchGesture(QObject *parent = 0); - WhatChanged whatChanged() const; - void setWhatChanged(WhatChanged value); + ChangeFlags totalChangeFlags() const; + void setTotalChangeFlags(ChangeFlags value); + + ChangeFlags changeFlags() const; + void setChangeFlags(ChangeFlags value); QPointF startCenterPoint() const; QPointF lastCenterPoint() const; @@ -188,7 +191,7 @@ public: QT_END_NAMESPACE -Q_DECLARE_METATYPE(QPinchGesture::WhatChanged) +Q_DECLARE_METATYPE(QPinchGesture::ChangeFlags) QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h index 73a6bcf..96fd64d 100644 --- a/src/gui/kernel/qgesture_p.h +++ b/src/gui/kernel/qgesture_p.h @@ -90,7 +90,6 @@ public: { } - QPointF totalOffset; QPointF lastOffset; QPointF offset; QPoint lastPosition; @@ -103,12 +102,15 @@ class QPinchGesturePrivate : public QGesturePrivate public: QPinchGesturePrivate() - : whatChanged(0), totalScaleFactor(0), lastScaleFactor(0), scaleFactor(0), - totalRotationAngle(0), lastRotationAngle(0), rotationAngle(0) + : totalChangeFlags(0), changeFlags(0), + totalScaleFactor(0), lastScaleFactor(0), scaleFactor(0), + totalRotationAngle(0), lastRotationAngle(0), rotationAngle(0), + isNewSequence(true) { } - QPinchGesture::WhatChanged whatChanged; + QPinchGesture::ChangeFlags totalChangeFlags; + QPinchGesture::ChangeFlags changeFlags; QPointF startCenterPoint; QPointF lastCenterPoint; diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index e4a1eb4..d2939f0 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -67,6 +67,15 @@ QT_BEGIN_NAMESPACE +QGestureManager *qt_gestureManager = 0; + +QGestureManager* QGestureManager::instance() +{ + if (!qt_gestureManager) + qt_gestureManager = new QGestureManager(qApp); + return qt_gestureManager; +} + QGestureManager::QGestureManager(QObject *parent) : QObject(parent), state(NotGesture), m_lastCustomGestureId(0) { @@ -99,7 +108,7 @@ QGestureManager::~QGestureManager() Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *recognizer) { - QGesture *dummy = recognizer->createGesture(0); + QGesture *dummy = recognizer->create(0); if (!dummy) { qWarning("QGestureManager::registerGestureRecognizer: " "the recognizer fails to create a gesture object, skipping registration."); @@ -179,7 +188,7 @@ QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recogni } Q_ASSERT(recognizer); - QGesture *state = recognizer->createGesture(object); + QGesture *state = recognizer->create(object); if (!state) return 0; state->setParent(this); @@ -226,18 +235,19 @@ bool QGestureManager::filterEventThroughContexts(const QMultiHashfilterEvent(state, target, event); + QGestureRecognizer::Result result = recognizer->recognize(state, target, event); QGestureRecognizer::Result type = result & QGestureRecognizer::ResultState_Mask; - if (type == QGestureRecognizer::GestureTriggered) { + result &= QGestureRecognizer::ResultHint_Mask; + if (type == QGestureRecognizer::TriggerGesture) { DEBUG() << "QGestureManager:Recognizer: gesture triggered: " << state; triggeredGestures << state; - } else if (type == QGestureRecognizer::GestureFinished) { + } else if (type == QGestureRecognizer::FinishGesture) { DEBUG() << "QGestureManager:Recognizer: gesture finished: " << state; finishedGestures << state; - } else if (type == QGestureRecognizer::MaybeGesture) { + } else if (type == QGestureRecognizer::MayBeGesture) { DEBUG() << "QGestureManager:Recognizer: maybe gesture: " << state; newMaybeGestures << state; - } else if (type == QGestureRecognizer::NotGesture) { + } else if (type == QGestureRecognizer::CancelGesture) { DEBUG() << "QGestureManager:Recognizer: not gesture: " << state; notGestures << state; } else if (type == QGestureRecognizer::Ignore) { @@ -434,7 +444,7 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) QSet types; QMultiHash contexts; QWidget *w = receiver; - typedef QMap::const_iterator ContextIterator; + typedef QMap::const_iterator ContextIterator; if (!w->d_func()->gestureContext.isEmpty()) { for(ContextIterator it = w->d_func()->gestureContext.begin(), e = w->d_func()->gestureContext.end(); it != e; ++it) { @@ -448,7 +458,7 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) { for (ContextIterator it = w->d_func()->gestureContext.begin(), e = w->d_func()->gestureContext.end(); it != e; ++it) { - if ((it.value() & Qt::GestureContext_Mask) == Qt::WidgetWithChildrenGesture) { + if (!(it.value() & Qt::DontStartGestureOnChildren)) { if (!types.contains(it.key())) { types.insert(it.key()); contexts.insertMulti(w, it.key()); @@ -468,7 +478,7 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) QMultiHash contexts; QGraphicsObject *item = receiver; if (!item->QGraphicsItem::d_func()->gestureContext.isEmpty()) { - typedef QMap::const_iterator ContextIterator; + typedef QMap::const_iterator ContextIterator; for(ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.begin(), e = item->QGraphicsItem::d_func()->gestureContext.end(); it != e; ++it) { types.insert(it.key()); @@ -479,10 +489,10 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) item = item->parentObject(); while (item) { - typedef QMap::const_iterator ContextIterator; + typedef QMap::const_iterator ContextIterator; for (ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.begin(), e = item->QGraphicsItem::d_func()->gestureContext.end(); it != e; ++it) { - if ((it.value() & Qt::GestureContext_Mask) == Qt::ItemWithChildrenGesture) { + if (!(it.value() & Qt::DontStartGestureOnChildren)) { if (!types.contains(it.key())) { types.insert(it.key()); contexts.insertMulti(item, it.key()); @@ -521,12 +531,12 @@ void QGestureManager::getGestureTargets(const QSet &gestures, foreach (QWidget *widget, gestures.keys()) { QWidget *w = widget->parentWidget(); while (w) { - QMap::const_iterator it + QMap::const_iterator it = w->d_func()->gestureContext.find(type); if (it != w->d_func()->gestureContext.end()) { // i.e. 'w' listens to gesture 'type' - Qt::GestureContext context = it.value() & Qt::GestureContext_Mask; - if (context == Qt::WidgetWithChildrenGesture && w != widget) { + Qt::GestureFlags flags = it.value(); + if (!(it.value() & Qt::DontStartGestureOnChildren) && w != widget) { // conflicting gesture! (*conflicts)[widget].append(gestures[widget]); break; @@ -620,7 +630,7 @@ void QGestureManager::deliverEvents(const QSet &gestures, QApplication::sendEvent(receiver, &event); bool eventAccepted = event.isAccepted(); - foreach(QGesture *gesture, event.allGestures()) { + foreach(QGesture *gesture, event.gestures()) { if (eventAccepted || event.isAccepted(gesture)) { QWidget *w = event.d_func()->targetWidgets.value(gesture->gestureType(), 0); Q_ASSERT(w); @@ -646,7 +656,7 @@ void QGestureManager::deliverEvents(const QSet &gestures, QGestureEvent event(it.value()); QApplication::sendEvent(it.key(), &event); bool eventAccepted = event.isAccepted(); - foreach (QGesture *gesture, event.allGestures()) { + foreach (QGesture *gesture, event.gestures()) { if (gesture->state() == Qt::GestureStarted && (eventAccepted || event.isAccepted(gesture))) { QWidget *w = event.d_func()->targetWidgets.value(gesture->gestureType(), 0); diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index d60aedc..27cc8fc 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -76,7 +76,6 @@ public: bool filterEvent(QGesture *receiver, QEvent *event); bool filterEvent(QGraphicsObject *receiver, QEvent *event); - // declared in qapplication.cpp static QGestureManager* instance(); void cleanupCachedGestures(QObject *target, Qt::GestureType type); @@ -141,6 +140,8 @@ private: void cancelGesturesForChildren(QGesture *originatingGesture); }; +extern QGestureManager *qt_gestureManager; + QT_END_NAMESPACE #endif // QGESTUREMANAGER_P_H diff --git a/src/gui/kernel/qgesturerecognizer.cpp b/src/gui/kernel/qgesturerecognizer.cpp index 2673be3..ed0bdcc 100644 --- a/src/gui/kernel/qgesturerecognizer.cpp +++ b/src/gui/kernel/qgesturerecognizer.cpp @@ -42,6 +42,7 @@ #include "qgesturerecognizer.h" #include "private/qgesture_p.h" +#include "private/qgesturemanager_p.h" QT_BEGIN_NAMESPACE @@ -65,12 +66,12 @@ QT_BEGIN_NAMESPACE objects, and modifying the associated QGesture objects to include relevant information about the user's input. - Gestures are created when the framework calls createGesture() to handle user input + Gestures are created when the framework calls create() to handle user input for a particular instance of a QWidget or QGraphicsObject subclass. A QGesture object is created for each widget or item that is configured to use gestures. Once a QGesture has been created for a target object, the gesture recognizer will - receive events for it in its filterEvent() handler function. + receive events for it in its recognize() handler function. When a gesture is canceled, the reset() function is called, giving the recognizer the chance to update the appropriate properties in the corresponding QGesture object. @@ -79,20 +80,22 @@ QT_BEGIN_NAMESPACE To add support for new gestures, you need to derive from QGestureRecognizer to create a custom recognizer class, construct an instance of this class, and register it with - the application by calling QApplication::registerGestureRecognizer(). You can also + the application by calling QGestureRecognizer::registerRecognizer(). You can also subclass QGesture to create a custom gesture class, or rely on dynamic properties to express specific details of the gesture you want to handle. - Your custom QGestureRecognizer subclass needs to reimplement the filterEvent() function - to handle and filter the incoming input events for QWidget and QGraphicsObject subclasses. - Although the logic for gesture recognition is implemented in this function, you can - store persistent information about the state of the recognition process in the QGesture - object supplied. The filterEvent() function must return a value of Qt::GestureState that - indicates the state of recognition for a given gesture and target object. This determines - whether or not a gesture event will be delivered to a target object. + Your custom QGestureRecognizer subclass needs to reimplement the recognize() + function to handle and filter the incoming input events for QWidget and + QGraphicsObject subclasses. Although the logic for gesture recognition is + implemented in this function, you can store persistent information about the + state of the recognition process in the QGesture object supplied. The + recognize() function must return a value of QGestureRecognizer::Result that + indicates the state of recognition for a given gesture and target object. + This determines whether or not a gesture event will be delivered to a target + object. If you choose to represent a gesture by a custom QGesture subclass, you will need to - reimplement the createGesture() function to construct instances of your gesture class. + reimplement the create() function to construct instances of your gesture class. Similarly, you may need to reimplement the reset() function if your custom gesture objects need to be specially handled when a gesture is canceled. @@ -105,37 +108,37 @@ QT_BEGIN_NAMESPACE This enum describes the result of the current event filtering step in a gesture recognizer state machine. - The result consists of a state value (one of Ignore, NotGesture, - MaybeGesture, GestureTriggered, GestureFinished) and an optional hint + The result consists of a state value (one of Ignore, MayBeGesture, + TriggerGesture, FinishGesture, CancelGesture) and an optional hint (ConsumeEventHint). \value Ignore The event does not change the state of the recognizer. - \value NotGesture The event made it clear that it is not a gesture. If the - gesture recognizer was in GestureTriggered state before, then the gesture - is canceled and the appropriate QGesture object will be delivered to the - target as a part of a QGestureEvent. - - \value MaybeGesture The event changed the internal state of the recognizer, + \value MayBeGesture The event changed the internal state of the recognizer, but it isn't clear yet if it is a gesture or not. The recognizer needs to - filter more events to decide. Gesture recognizers in the MaybeGesture state + filter more events to decide. Gesture recognizers in the MayBeGesture state may be reset automatically if they take too long to recognize gestures. - \value GestureTriggered The gesture has been triggered and the appropriate + \value TriggerGesture The gesture has been triggered and the appropriate QGesture object will be delivered to the target as a part of a QGestureEvent. - \value GestureFinished The gesture has been finished successfully and the + \value FinishGesture The gesture has been finished successfully and the appropriate QGesture object will be delivered to the target as a part of a QGestureEvent. - \value ConsumeEventHint This hint specifies that the gesture framework should - consume the filtered event and not deliver it to the receiver. + \value CancelGesture The event made it clear that it is not a gesture. If + the gesture recognizer was in GestureTriggered state before, then the + gesture is canceled and the appropriate QGesture object will be delivered + to the target as a part of a QGestureEvent. + + \value ConsumeEventHint This hint specifies that the gesture framework + should consume the filtered event and not deliver it to the receiver. \omitvalue ResultState_Mask \omitvalue ResultHint_Mask - \sa QGestureRecognizer::filterEvent() + \sa QGestureRecognizer::recognize() */ /*! @@ -159,7 +162,7 @@ QGestureRecognizer::~QGestureRecognizer() Reimplement this function to create a custom QGesture-derived gesture object if necessary. */ -QGesture *QGestureRecognizer::createGesture(QObject *target) +QGesture *QGestureRecognizer::create(QObject *target) { Q_UNUSED(target); return new QGesture; @@ -183,7 +186,7 @@ void QGestureRecognizer::reset(QGesture *gesture) } /*! - \fn QGestureRecognizer::filterEvent(QGesture *gesture, QObject *watched, QEvent *event) + \fn QGestureRecognizer::recognize(QGesture *gesture, QObject *watched, QEvent *event) Handles the given \a event for the \a watched object, updating the state of the \a gesture object as required, and returns a suitable result for the current recognition step. @@ -194,7 +197,34 @@ void QGestureRecognizer::reset(QGesture *gesture) The result reflects how much of the gesture has been recognized. The state of the \a gesture object is set depending on the result. - \sa Qt::GestureState + \sa QGestureRecognizer::Result +*/ + +/*! + Registers the given \a recognizer in the gesture framework and returns a gesture ID + for it. + + The application takes ownership of the \a recognizer and returns the gesture type + ID associated with it. For gesture recognizers which handle custom QGesture + objects (i.e., those which return Qt::CustomGesture in a QGesture::gestureType() + function) the return value is a generated gesture ID with the Qt::CustomGesture + flag set. + + \sa unregisterRecognizer(), QGestureRecognizer::create(), QGesture */ +Qt::GestureType QGestureRecognizer::registerRecognizer(QGestureRecognizer *recognizer) +{ + return QGestureManager::instance()->registerGestureRecognizer(recognizer); +} + +/*! + Unregisters all gesture recognizers of the specified \a type. + + \sa registerRecognizer() +*/ +void QGestureRecognizer::unregisterRecognizer(Qt::GestureType type) +{ + QGestureManager::instance()->unregisterGestureRecognizer(type); +} QT_END_NAMESPACE diff --git a/src/gui/kernel/qgesturerecognizer.h b/src/gui/kernel/qgesturerecognizer.h index a3c990d..4eebf7c 100644 --- a/src/gui/kernel/qgesturerecognizer.h +++ b/src/gui/kernel/qgesturerecognizer.h @@ -43,6 +43,7 @@ #define QGESTURERECOGNIZER_H #include +#include QT_BEGIN_HEADER @@ -58,30 +59,34 @@ class Q_GUI_EXPORT QGestureRecognizer public: enum ResultFlag { - Ignore = 0x0001, - NotGesture = 0x0002, - MaybeGesture = 0x0004, - GestureTriggered = 0x0008, // Gesture started or updated - GestureFinished = 0x0010, + Ignore = 0x0001, - ResultState_Mask = 0x00ff, + MayBeGesture = 0x0002, + TriggerGesture = 0x0004, + FinishGesture = 0x0008, + CancelGesture = 0x0010, + + ResultState_Mask = 0x00ff, ConsumeEventHint = 0x0100, // StoreEventHint = 0x0200, // ReplayStoredEventsHint = 0x0400, // DiscardStoredEventsHint = 0x0800, - ResultHint_Mask = 0xff00 + ResultHint_Mask = 0xff00 }; Q_DECLARE_FLAGS(Result, ResultFlag) QGestureRecognizer(); virtual ~QGestureRecognizer(); - virtual QGesture *createGesture(QObject *target); - virtual QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event) = 0; - + virtual QGesture *create(QObject *target); + virtual Result recognize(QGesture *state, QObject *watched, + QEvent *event) = 0; virtual void reset(QGesture *state); + + static Qt::GestureType registerRecognizer(QGestureRecognizer *recognizer); + static void unregisterRecognizer(Qt::GestureType type); }; Q_DECLARE_OPERATORS_FOR_FLAGS(QGestureRecognizer::Result) diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index 57cf12d..ba00a90 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -52,7 +52,7 @@ QPanGestureRecognizer::QPanGestureRecognizer() { } -QGesture *QPanGestureRecognizer::createGesture(QObject *target) +QGesture *QPanGestureRecognizer::create(QObject *target) { if (target && target->isWidgetType()) { #if defined(Q_OS_WIN) @@ -66,21 +66,21 @@ QGesture *QPanGestureRecognizer::createGesture(QObject *target) return new QPanGesture; } -QGestureRecognizer::Result QPanGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event) +QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state, QObject *, QEvent *event) { - QPanGesture *q = static_cast(state); + QPanGesture *q = static_cast(state); QPanGesturePrivate *d = q->d_func(); - const QTouchEvent *ev = static_cast(event); + const QTouchEvent *ev = static_cast(event); QGestureRecognizer::Result result; switch (event->type()) { case QEvent::TouchBegin: { - result = QGestureRecognizer::MaybeGesture; + result = QGestureRecognizer::MayBeGesture; QTouchEvent::TouchPoint p = ev->touchPoints().at(0); d->lastPosition = p.pos().toPoint(); - d->lastOffset = d->totalOffset = d->offset = QPointF(); + d->lastOffset = d->offset = QPointF(); break; } case QEvent::TouchEnd: { @@ -90,13 +90,12 @@ QGestureRecognizer::Result QPanGestureRecognizer::filterEvent(QGesture *state, Q QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1); d->lastOffset = d->offset; d->offset = - QPointF(p1.pos().x() - p1.lastPos().x() + p2.pos().x() - p2.lastPos().x(), - p1.pos().y() - p1.lastPos().y() + p2.pos().y() - p2.lastPos().y()) / 2; - d->totalOffset += d->offset; + QPointF(p1.pos().x() - p1.startPos().x() + p2.pos().x() - p2.startPos().x(), + p1.pos().y() - p1.startPos().y() + p2.pos().y() - p2.startPos().y()) / 2; } - result = QGestureRecognizer::GestureFinished; + result = QGestureRecognizer::FinishGesture; } else { - result = QGestureRecognizer::NotGesture; + result = QGestureRecognizer::CancelGesture; } break; } @@ -106,14 +105,13 @@ QGestureRecognizer::Result QPanGestureRecognizer::filterEvent(QGesture *state, Q QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1); d->lastOffset = d->offset; d->offset = - QPointF(p1.pos().x() - p1.lastPos().x() + p2.pos().x() - p2.lastPos().x(), - p1.pos().y() - p1.lastPos().y() + p2.pos().y() - p2.lastPos().y()) / 2; - d->totalOffset += d->offset; - if (d->totalOffset.x() > 10 || d->totalOffset.y() > 10 || - d->totalOffset.x() < -10 || d->totalOffset.y() < -10) { - result = QGestureRecognizer::GestureTriggered; + QPointF(p1.pos().x() - p1.startPos().x() + p2.pos().x() - p2.startPos().x(), + p1.pos().y() - p1.startPos().y() + p2.pos().y() - p2.startPos().y()) / 2; + if (d->offset.x() > 10 || d->offset.y() > 10 || + d->offset.x() < -10 || d->offset.y() < -10) { + result = QGestureRecognizer::TriggerGesture; } else { - result = QGestureRecognizer::MaybeGesture; + result = QGestureRecognizer::MayBeGesture; } } break; @@ -135,7 +133,7 @@ void QPanGestureRecognizer::reset(QGesture *state) QPanGesture *pan = static_cast(state); QPanGesturePrivate *d = pan->d_func(); - d->totalOffset = d->lastOffset = d->offset = QPointF(); + d->lastOffset = d->offset = QPointF(); d->lastPosition = QPoint(); d->acceleration = 0; @@ -151,7 +149,7 @@ QPinchGestureRecognizer::QPinchGestureRecognizer() { } -QGesture *QPinchGestureRecognizer::createGesture(QObject *target) +QGesture *QPinchGestureRecognizer::create(QObject *target) { if (target && target->isWidgetType()) { static_cast(target)->setAttribute(Qt::WA_AcceptTouchEvents); @@ -159,7 +157,7 @@ QGesture *QPinchGestureRecognizer::createGesture(QObject *target) return new QPinchGesture; } -QGestureRecognizer::Result QPinchGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event) +QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state, QObject *, QEvent *event) { QPinchGesture *q = static_cast(state); QPinchGesturePrivate *d = q->d_func(); @@ -170,19 +168,19 @@ QGestureRecognizer::Result QPinchGestureRecognizer::filterEvent(QGesture *state, switch (event->type()) { case QEvent::TouchBegin: { - result = QGestureRecognizer::MaybeGesture; + result = QGestureRecognizer::MayBeGesture; break; } case QEvent::TouchEnd: { if (q->state() != Qt::NoGesture) { - result = QGestureRecognizer::GestureFinished; + result = QGestureRecognizer::FinishGesture; } else { - result = QGestureRecognizer::NotGesture; + result = QGestureRecognizer::CancelGesture; } break; } case QEvent::TouchUpdate: { - d->whatChanged = 0; + d->changeFlags = 0; if (ev->touchPoints().size() == 2) { QTouchEvent::TouchPoint p1 = ev->touchPoints().at(0); QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1); @@ -201,7 +199,7 @@ QGestureRecognizer::Result QPinchGestureRecognizer::filterEvent(QGesture *state, d->lastCenterPoint = d->centerPoint; d->centerPoint = centerPoint; - d->whatChanged |= QPinchGesture::CenterPointChanged; + d->changeFlags |= QPinchGesture::CenterPointChanged; const qreal scaleFactor = QLineF(p1.pos(), p2.pos()).length() / QLineF(d->startPosition[0], d->startPosition[1]).length(); @@ -212,7 +210,7 @@ QGestureRecognizer::Result QPinchGestureRecognizer::filterEvent(QGesture *state, } d->scaleFactor = scaleFactor; d->totalScaleFactor += d->scaleFactor - d->lastScaleFactor; - d->whatChanged |= QPinchGesture::ScaleFactorChanged; + d->changeFlags |= QPinchGesture::ScaleFactorChanged; const qreal rotationAngle = -line.angle(); if (d->isNewSequence) @@ -221,13 +219,14 @@ QGestureRecognizer::Result QPinchGestureRecognizer::filterEvent(QGesture *state, d->lastRotationAngle = d->rotationAngle; d->rotationAngle = rotationAngle; d->totalRotationAngle += d->rotationAngle - d->lastRotationAngle; - d->whatChanged |= QPinchGesture::RotationAngleChanged; + d->changeFlags |= QPinchGesture::RotationAngleChanged; + d->totalChangeFlags |= d->changeFlags; d->isNewSequence = false; - result = QGestureRecognizer::GestureTriggered; + result = QGestureRecognizer::TriggerGesture; } else { d->isNewSequence = true; - result = QGestureRecognizer::MaybeGesture; + result = QGestureRecognizer::MayBeGesture; } break; } @@ -245,10 +244,10 @@ QGestureRecognizer::Result QPinchGestureRecognizer::filterEvent(QGesture *state, void QPinchGestureRecognizer::reset(QGesture *state) { - QPinchGesture *pinch = static_cast(state); + QPinchGesture *pinch = static_cast(state); QPinchGesturePrivate *d = pinch->d_func(); - d->whatChanged = 0; + d->totalChangeFlags = d->changeFlags = 0; d->startCenterPoint = d->lastCenterPoint = d->centerPoint = QPointF(); d->totalScaleFactor = d->lastScaleFactor = d->scaleFactor = 0; diff --git a/src/gui/kernel/qstandardgestures_p.h b/src/gui/kernel/qstandardgestures_p.h index 827b2a2..e6f346c 100644 --- a/src/gui/kernel/qstandardgestures_p.h +++ b/src/gui/kernel/qstandardgestures_p.h @@ -63,9 +63,8 @@ class QPanGestureRecognizer : public QGestureRecognizer public: QPanGestureRecognizer(); - QGesture *createGesture(QObject *target); - - QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event); + QGesture *create(QObject *target); + QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event); void reset(QGesture *state); }; @@ -74,9 +73,9 @@ class QPinchGestureRecognizer : public QGestureRecognizer public: QPinchGestureRecognizer(); - QGesture *createGesture(QObject *target); + QGesture *create(QObject *target); - QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event); + QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event); void reset(QGesture *state); }; diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 00d9a99..25284e4 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -11711,20 +11711,20 @@ QGraphicsProxyWidget *QWidget::graphicsProxyWidget() const */ /*! - Subscribes the widget to a given \a gesture with a \a context. + Subscribes the widget to a given \a gesture with specific \a flags. \sa ungrabGesture(), QGestureEvent \since 4.6 */ -void QWidget::grabGesture(Qt::GestureType gesture, Qt::GestureContext context) +void QWidget::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags) { Q_D(QWidget); - d->gestureContext.insert(gesture, context); + d->gestureContext.insert(gesture, flags); (void)QGestureManager::instance(); // create a gesture manager } /*! - Unsubscribes the widget to a given \a gesture type + Unsubscribes the widget from a given \a gesture type \sa grabGesture(), QGestureEvent \since 4.6 diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index fce3f09..05f0069 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -354,7 +354,7 @@ public: QGraphicsEffect *graphicsEffect() const; void setGraphicsEffect(QGraphicsEffect *effect); - void grabGesture(Qt::GestureType type, Qt::GestureContext context = Qt::WidgetWithChildrenGesture); + void grabGesture(Qt::GestureType type, Qt::GestureFlags flags = Qt::GestureFlags()); void ungrabGesture(Qt::GestureType type); public Q_SLOTS: diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 616a972..dd859a7 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -631,7 +631,7 @@ public: #ifndef QT_NO_ACTION QList actions; #endif - QMap gestureContext; + QMap gestureContext; // Bit fields. uint high_attributes[3]; // the low ones are in QWidget::widget_attributes diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index 0e5ee46..44feaaf 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -1458,15 +1458,15 @@ bool QPlainTextEdit::event(QEvent *e) QScrollBar *vBar = verticalScrollBar(); if (g->state() == Qt::GestureStarted) d->originalOffsetY = vBar->value(); - QPointF totalOffset = g->totalOffset(); - if (!totalOffset.isNull()) { + QPointF offset = g->offset(); + if (!offset.isNull()) { if (QApplication::isRightToLeft()) - totalOffset.rx() *= -1; + offset.rx() *= -1; // QPlainTextEdit scrolls by lines only in vertical direction QFontMetrics fm(document()->defaultFont()); int lineHeight = fm.height(); int newX = hBar->value() - g->lastOffset().x(); - int newY = d->originalOffsetY - totalOffset.y()/lineHeight; + int newY = d->originalOffsetY - offset.y()/lineHeight; hBar->setValue(newX); vBar->setValue(newY); } diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 9b2bc57..20b53f2 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -111,12 +111,12 @@ public: CustomEvent::EventType = QEvent::registerEventType(); } - QGesture* createGesture(QObject *) + QGesture* create(QObject *) { return new CustomGesture; } - QGestureRecognizer::Result filterEvent(QGesture *state, QObject*o , QEvent *event) + QGestureRecognizer::Result recognize(QGesture *state, QObject*, QEvent *event) { if (event->type() == CustomEvent::EventType) { QGestureRecognizer::Result result = 0; @@ -128,13 +128,13 @@ public: if (e->hasHotSpot) g->setHotSpot(e->hotSpot); if (g->serial >= CustomGesture::SerialFinishedThreshold) - result |= QGestureRecognizer::GestureFinished; + result |= QGestureRecognizer::FinishGesture; else if (g->serial >= CustomGesture::SerialStartedThreshold) - result |= QGestureRecognizer::GestureTriggered; + result |= QGestureRecognizer::TriggerGesture; else if (g->serial >= CustomGesture::SerialMaybeThreshold) - result |= QGestureRecognizer::MaybeGesture; + result |= QGestureRecognizer::MayBeGesture; else - result = QGestureRecognizer::NotGesture; + result = QGestureRecognizer::CancelGesture; return result; } return QGestureRecognizer::Ignore; @@ -142,7 +142,7 @@ public: void reset(QGesture *state) { - CustomGesture *g = static_cast(state); + CustomGesture *g = static_cast(state); g->serial = 0; QGestureRecognizer::reset(state); } @@ -159,26 +159,26 @@ public: CustomEvent::EventType = QEvent::registerEventType(); } - QGesture* createGesture(QObject *) + QGesture* create(QObject *) { return new CustomGesture; } - QGestureRecognizer::Result filterEvent(QGesture *state, QObject*, QEvent *event) + QGestureRecognizer::Result recognize(QGesture *state, QObject*, QEvent *event) { if (event->type() == CustomEvent::EventType) { QGestureRecognizer::Result result = QGestureRecognizer::ConsumeEventHint; - CustomGesture *g = static_cast(state); - CustomEvent *e = static_cast(event); + CustomGesture *g = static_cast(state); + CustomEvent *e = static_cast(event); g->serial = e->serial; if (e->hasHotSpot) g->setHotSpot(e->hotSpot); if (g->serial >= CustomGesture::SerialFinishedThreshold) - result |= QGestureRecognizer::GestureFinished; + result |= QGestureRecognizer::FinishGesture; else if (g->serial >= CustomGesture::SerialMaybeThreshold) - result |= QGestureRecognizer::GestureTriggered; + result |= QGestureRecognizer::TriggerGesture; else - result = QGestureRecognizer::NotGesture; + result = QGestureRecognizer::CancelGesture; return result; } return QGestureRecognizer::Ignore; @@ -186,7 +186,7 @@ public: void reset(QGesture *state) { - CustomGesture *g = static_cast(state); + CustomGesture *g = static_cast(state); g->serial = 0; QGestureRecognizer::reset(state); } @@ -256,7 +256,7 @@ protected: } if (eventsPtr) { QGestureEvent *e = static_cast(event); - QList gestures = e->allGestures(); + QList gestures = e->gestures(); foreach(QGesture *g, gestures) { eventsPtr->all << g->gestureType(); switch(g->state()) { @@ -345,14 +345,14 @@ tst_Gestures::~tst_Gestures() void tst_Gestures::initTestCase() { - CustomGesture::GestureType = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + CustomGesture::GestureType = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); QVERIFY(CustomGesture::GestureType != Qt::GestureType(0)); QVERIFY(CustomGesture::GestureType != Qt::CustomGesture); } void tst_Gestures::cleanupTestCase() { - QApplication::unregisterGestureRecognizer(CustomGesture::GestureType); + QGestureRecognizer::unregisterRecognizer(CustomGesture::GestureType); } void tst_Gestures::init() @@ -366,7 +366,7 @@ void tst_Gestures::cleanup() void tst_Gestures::customGesture() { GestureWidget widget; - widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); CustomEvent event; sendCustomGesture(&event, &widget); @@ -387,7 +387,7 @@ void tst_Gestures::customGesture() void tst_Gestures::consumeEventHint() { GestureWidget widget; - widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); CustomGestureRecognizer::ConsumeEvents = true; CustomEvent event; @@ -400,7 +400,7 @@ void tst_Gestures::consumeEventHint() void tst_Gestures::autoCancelingGestures() { GestureWidget widget; - widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); // send partial gesture. The gesture will be in the "maybe" state, but will // never get enough events to fire, so Qt will have to kill it. CustomEvent ev; @@ -424,7 +424,7 @@ void tst_Gestures::gestureOverChild() GestureWidget *child = new GestureWidget("child"); l->addWidget(child); - widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); CustomEvent event; sendCustomGesture(&event, child); @@ -440,7 +440,7 @@ void tst_Gestures::gestureOverChild() QCOMPARE(widget.gestureOverrideEventsReceived, 0); // enable gestures over the children - widget.grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture); + widget.grabGesture(CustomGesture::GestureType); widget.reset(); child->reset(); @@ -469,8 +469,8 @@ void tst_Gestures::multipleWidgetOnlyGestureInTree() GestureWidget *child = new GestureWidget("child"); l->addWidget(child); - parent.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); - child->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + parent.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); + child->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; @@ -507,8 +507,8 @@ void tst_Gestures::conflictingGestures() GestureWidget *child = new GestureWidget("child"); l->addWidget(child); - parent.grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture); - child->grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture); + parent.grabGesture(CustomGesture::GestureType); + child->grabGesture(CustomGesture::GestureType); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -579,7 +579,7 @@ void tst_Gestures::conflictingGestures() child->reset(); // we set an attribute to make sure all gesture events are propagated - parent.grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture | Qt::AcceptPartialGesturesHint); + parent.grabGesture(CustomGesture::GestureType, Qt::ReceivePartialGestures); parent.acceptGestureOverride = false; child->acceptGestureOverride = false; parent.ignoredGestures << CustomGesture::GestureType; @@ -596,7 +596,7 @@ void tst_Gestures::conflictingGestures() parent.reset(); child->reset(); - Qt::GestureType ContinuousGesture = QApplication::registerGestureRecognizer(new CustomContinuousGestureRecognizer); + Qt::GestureType ContinuousGesture = QGestureRecognizer::registerRecognizer(new CustomContinuousGestureRecognizer); static const int ContinuousGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; child->grabGesture(ContinuousGesture); // child accepts override. And it also receives another custom gesture. @@ -610,13 +610,13 @@ void tst_Gestures::conflictingGestures() QCOMPARE(parent.gestureOverrideEventsReceived, 0); QCOMPARE(parent.gestureEventsReceived, 0); - QApplication::unregisterGestureRecognizer(ContinuousGesture); + QGestureRecognizer::unregisterRecognizer(ContinuousGesture); } void tst_Gestures::finishedWithoutStarted() { GestureWidget widget; - widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); // the gesture will claim it finished, but it was never started. CustomEvent ev; @@ -636,9 +636,9 @@ void tst_Gestures::finishedWithoutStarted() void tst_Gestures::unknownGesture() { GestureWidget widget; - widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); - widget.grabGesture(Qt::CustomGesture, Qt::WidgetGesture); - widget.grabGesture(Qt::GestureType(Qt::PanGesture+512), Qt::WidgetGesture); + widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); + widget.grabGesture(Qt::CustomGesture, Qt::DontStartGestureOnChildren); + widget.grabGesture(Qt::GestureType(Qt::PanGesture+512), Qt::DontStartGestureOnChildren); CustomEvent event; sendCustomGesture(&event, &widget); @@ -740,7 +740,7 @@ protected: } if (eventsPtr) { QGestureEvent *e = static_cast(event); - QList gestures = e->allGestures(); + QList gestures = e->gestures(); foreach(QGesture *g, gestures) { eventsPtr->all << g->gestureType(); switch(g->state()) { @@ -784,7 +784,7 @@ void tst_Gestures::graphicsItemGesture() QTest::qWaitForWindowShown(&view); view.ensureVisible(scene.sceneRect()); - view.viewport()->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); item->grabGesture(CustomGesture::GestureType); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -858,7 +858,7 @@ void tst_Gestures::graphicsItemTreeGesture() QTest::qWaitForWindowShown(&view); view.ensureVisible(scene.sceneRect()); - view.viewport()->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); item1->grabGesture(CustomGesture::GestureType); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -916,10 +916,10 @@ void tst_Gestures::explicitGraphicsObjectTarget() QTest::qWaitForWindowShown(&view); view.ensureVisible(scene.sceneRect()); - view.viewport()->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); - item1->grabGesture(CustomGesture::GestureType, Qt::ItemGesture); - item2->grabGesture(CustomGesture::GestureType, Qt::ItemGesture); - item2_child1->grabGesture(CustomGesture::GestureType, Qt::ItemGesture); + view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); + item1->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); + item2->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); + item2_child1->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -976,7 +976,7 @@ void tst_Gestures::gestureOverChildGraphicsItem() QTest::qWaitForWindowShown(&view); view.ensureVisible(scene.sceneRect()); - view.viewport()->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); item1->grabGesture(CustomGesture::GestureType); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -1030,7 +1030,7 @@ void tst_Gestures::gestureOverChildGraphicsItem() item2->grabGesture(CustomGesture::GestureType); item2->ignoredGestures << CustomGesture::GestureType; item1->ignoredGestures << CustomGesture::GestureType; - item1->grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture | Qt::AcceptPartialGesturesHint); + item1->grabGesture(CustomGesture::GestureType, Qt::ReceivePartialGestures); event.hotSpot = mapToGlobal(QPointF(10, 10), item2_child1, &view); event.hasHotSpot = true; @@ -1051,10 +1051,10 @@ void tst_Gestures::twoGesturesOnDifferentLevel() GestureWidget *child = new GestureWidget("child"); l->addWidget(child); - Qt::GestureType SecondGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType SecondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); - parent.grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture); - child->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture); + parent.grabGesture(CustomGesture::GestureType); + child->grabGesture(SecondGesture); CustomEvent event; // sending events that form a gesture to one widget, but they will be @@ -1079,7 +1079,7 @@ void tst_Gestures::twoGesturesOnDifferentLevel() for(int i = 0; i < child->events.all.size(); ++i) QCOMPARE(parent.events.all.at(i), CustomGesture::GestureType); - QApplication::unregisterGestureRecognizer(SecondGesture); + QGestureRecognizer::unregisterRecognizer(SecondGesture); } void tst_Gestures::multipleGesturesInTree() @@ -1091,19 +1091,19 @@ void tst_Gestures::multipleGesturesInTree() GestureWidget *D = new GestureWidget("D", C); Qt::GestureType FirstGesture = CustomGesture::GestureType; - Qt::GestureType SecondGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType ThirdGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); - - Qt::GestureContext context = Qt::WidgetWithChildrenGesture | Qt::AcceptPartialGesturesHint; - A->grabGesture(FirstGesture, context); // A [1 3] - A->grabGesture(ThirdGesture, context); // | - B->grabGesture(SecondGesture, context); // B [ 2 3] - B->grabGesture(ThirdGesture, context); // | - C->grabGesture(FirstGesture, context); // C [1 2 3] - C->grabGesture(SecondGesture, context); // | - C->grabGesture(ThirdGesture, context); // D [1 3] - D->grabGesture(FirstGesture, context); - D->grabGesture(ThirdGesture, context); + Qt::GestureType SecondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); + Qt::GestureType ThirdGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); + + Qt::GestureFlags flags = Qt::ReceivePartialGestures; + A->grabGesture(FirstGesture, flags); // A [1 3] + A->grabGesture(ThirdGesture, flags); // | + B->grabGesture(SecondGesture, flags); // B [ 2 3] + B->grabGesture(ThirdGesture, flags); // | + C->grabGesture(FirstGesture, flags); // C [1 2 3] + C->grabGesture(SecondGesture, flags); // | + C->grabGesture(ThirdGesture, flags); // D [1 3] + D->grabGesture(FirstGesture, flags); + D->grabGesture(ThirdGesture, flags); // make sure all widgets ignore events, so they get propagated. A->ignoredGestures << FirstGesture << ThirdGesture; @@ -1150,8 +1150,8 @@ void tst_Gestures::multipleGesturesInTree() QCOMPARE(A->events.all.count(SecondGesture), 0); QCOMPARE(A->events.all.count(ThirdGesture), TotalGestureEventsCount); - QApplication::unregisterGestureRecognizer(SecondGesture); - QApplication::unregisterGestureRecognizer(ThirdGesture); + QGestureRecognizer::unregisterRecognizer(SecondGesture); + QGestureRecognizer::unregisterRecognizer(ThirdGesture); } void tst_Gestures::multipleGesturesInComplexTree() @@ -1163,27 +1163,27 @@ void tst_Gestures::multipleGesturesInComplexTree() GestureWidget *D = new GestureWidget("D", C); Qt::GestureType FirstGesture = CustomGesture::GestureType; - Qt::GestureType SecondGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType ThirdGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType FourthGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType FifthGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType SixthGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType SeventhGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); - - Qt::GestureContext context = Qt::WidgetWithChildrenGesture | Qt::AcceptPartialGesturesHint; - A->grabGesture(FirstGesture, context); // A [1,3,4] - A->grabGesture(ThirdGesture, context); // | - A->grabGesture(FourthGesture, context); // B [2,3,5] - B->grabGesture(SecondGesture, context); // | - B->grabGesture(ThirdGesture, context); // C [1,2,3,6] - B->grabGesture(FifthGesture, context); // | - C->grabGesture(FirstGesture, context); // D [1,3,7] - C->grabGesture(SecondGesture, context); - C->grabGesture(ThirdGesture, context); - C->grabGesture(SixthGesture, context); - D->grabGesture(FirstGesture, context); - D->grabGesture(ThirdGesture, context); - D->grabGesture(SeventhGesture, context); + Qt::GestureType SecondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); + Qt::GestureType ThirdGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); + Qt::GestureType FourthGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); + Qt::GestureType FifthGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); + Qt::GestureType SixthGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); + Qt::GestureType SeventhGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); + + Qt::GestureFlags flags = Qt::ReceivePartialGestures; + A->grabGesture(FirstGesture, flags); // A [1,3,4] + A->grabGesture(ThirdGesture, flags); // | + A->grabGesture(FourthGesture, flags); // B [2,3,5] + B->grabGesture(SecondGesture, flags); // | + B->grabGesture(ThirdGesture, flags); // C [1,2,3,6] + B->grabGesture(FifthGesture, flags); // | + C->grabGesture(FirstGesture, flags); // D [1,3,7] + C->grabGesture(SecondGesture, flags); + C->grabGesture(ThirdGesture, flags); + C->grabGesture(SixthGesture, flags); + D->grabGesture(FirstGesture, flags); + D->grabGesture(ThirdGesture, flags); + D->grabGesture(SeventhGesture, flags); // make sure all widgets ignore events, so they get propagated. QSet allGestureTypes; @@ -1247,12 +1247,12 @@ void tst_Gestures::multipleGesturesInComplexTree() QCOMPARE(A->events.all.count(SixthGesture), 0); QCOMPARE(A->events.all.count(SeventhGesture), 0); - QApplication::unregisterGestureRecognizer(SecondGesture); - QApplication::unregisterGestureRecognizer(ThirdGesture); - QApplication::unregisterGestureRecognizer(FourthGesture); - QApplication::unregisterGestureRecognizer(FifthGesture); - QApplication::unregisterGestureRecognizer(SixthGesture); - QApplication::unregisterGestureRecognizer(SeventhGesture); + QGestureRecognizer::unregisterRecognizer(SecondGesture); + QGestureRecognizer::unregisterRecognizer(ThirdGesture); + QGestureRecognizer::unregisterRecognizer(FourthGesture); + QGestureRecognizer::unregisterRecognizer(FifthGesture); + QGestureRecognizer::unregisterRecognizer(SixthGesture); + QGestureRecognizer::unregisterRecognizer(SeventhGesture); } void tst_Gestures::testMapToScene() @@ -1261,7 +1261,7 @@ void tst_Gestures::testMapToScene() QList list; list << &gesture; QGestureEvent event(list); - QCOMPARE(event.mapToScene(gesture.hotSpot()), QPointF()); // not set, can't do much + QCOMPARE(event.mapToGraphicsScene(gesture.hotSpot()), QPointF()); // not set, can't do much QGraphicsScene scene; QGraphicsView view(&scene); @@ -1278,7 +1278,7 @@ void tst_Gestures::testMapToScene() QPoint origin = view.mapToGlobal(QPoint()); event.setWidget(view.viewport()); - QCOMPARE(event.mapToScene(origin + QPoint(100, 200)), view.mapToScene(QPoint(100, 200))); + QCOMPARE(event.mapToGraphicsScene(origin + QPoint(100, 200)), view.mapToScene(QPoint(100, 200))); } void tst_Gestures::ungrabGesture() // a method on QWidget @@ -1296,7 +1296,7 @@ void tst_Gestures::ungrabGesture() // a method on QWidget if (event->type() == QEvent::Gesture) { QGestureEvent *gestureEvent = static_cast(event); if (gestureEvent) - foreach (QGesture *g, gestureEvent->allGestures()) + foreach (QGesture *g, gestureEvent->gestures()) gestures.insert(g); } return GestureWidget::event(event); @@ -1307,8 +1307,8 @@ void tst_Gestures::ungrabGesture() // a method on QWidget MockGestureWidget *a = &parent; MockGestureWidget *b = new MockGestureWidget("B", a); - a->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); - b->grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture); + a->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); + b->grabGesture(CustomGesture::GestureType); b->ignoredGestures << CustomGesture::GestureType; CustomEvent event; @@ -1375,14 +1375,14 @@ void tst_Gestures::autoCancelGestures() { if (event->type() == QEvent::Gesture) { QGestureEvent *ge = static_cast(event); - Q_ASSERT(ge->allGestures().count() == 1); // can't use QCOMPARE here... - ge->allGestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext); + Q_ASSERT(ge->gestures().count() == 1); // can't use QCOMPARE here... + ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext); } return GestureWidget::event(event); } }; - const Qt::GestureType secondGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + const Qt::GestureType secondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); MockWidget parent("parent"); // this one sets the cancel policy to CancelAllInContext parent.resize(300, 100); @@ -1390,8 +1390,8 @@ void tst_Gestures::autoCancelGestures() GestureWidget *child = new GestureWidget("child", &parent); child->setGeometry(10, 10, 100, 80); - parent.grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture); - child->grabGesture(secondGesture, Qt::WidgetWithChildrenGesture); + parent.grabGesture(CustomGesture::GestureType); + child->grabGesture(secondGesture); parent.show(); QTest::qWaitForWindowShown(&parent); @@ -1425,14 +1425,14 @@ void tst_Gestures::autoCancelGestures2() bool event(QEvent *event) { if (event->type() == QEvent::Gesture) { QGestureEvent *ge = static_cast(event); - Q_ASSERT(ge->allGestures().count() == 1); // can't use QCOMPARE here... - ge->allGestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext); + Q_ASSERT(ge->gestures().count() == 1); // can't use QCOMPARE here... + ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext); } return GestureItem::event(event); } }; - const Qt::GestureType secondGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + const Qt::GestureType secondGesture = QGestureRecognizer ::registerRecognizer(new CustomGestureRecognizer); QGraphicsScene scene; QGraphicsView view(&scene); @@ -1444,10 +1444,10 @@ void tst_Gestures::autoCancelGestures2() parent->setPos(0, 0); child->setPos(10, 10); scene.addItem(parent); - view.viewport()->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); - view.viewport()->grabGesture(secondGesture, Qt::WidgetGesture); - parent->grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture); - child->grabGesture(secondGesture, Qt::WidgetWithChildrenGesture); + view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); + view.viewport()->grabGesture(secondGesture, Qt::DontStartGestureOnChildren); + parent->grabGesture(CustomGesture::GestureType); + child->grabGesture(secondGesture); view.show(); QTest::qWaitForWindowShown(&view); diff --git a/tests/manual/gestures/graphicsview/gestures.cpp b/tests/manual/gestures/graphicsview/gestures.cpp index 5416457..4c21712 100644 --- a/tests/manual/gestures/graphicsview/gestures.cpp +++ b/tests/manual/gestures/graphicsview/gestures.cpp @@ -45,41 +45,41 @@ Qt::GestureType ThreeFingerSlideGesture::Type = Qt::CustomGesture; -QGesture *ThreeFingerSlideGestureRecognizer::createGesture(QObject *) +QGesture *ThreeFingerSlideGestureRecognizer::create(QObject *) { return new ThreeFingerSlideGesture; } -QGestureRecognizer::Result ThreeFingerSlideGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event) +QGestureRecognizer::Result ThreeFingerSlideGestureRecognizer::recognize(QGesture *state, QObject *, QEvent *event) { ThreeFingerSlideGesture *d = static_cast(state); QGestureRecognizer::Result result; switch (event->type()) { case QEvent::TouchBegin: - result = QGestureRecognizer::MaybeGesture; + result = QGestureRecognizer::MayBeGesture; case QEvent::TouchEnd: if (d->gestureFired) - result = QGestureRecognizer::GestureFinished; + result = QGestureRecognizer::FinishGesture; else - result = QGestureRecognizer::NotGesture; + result = QGestureRecognizer::CancelGesture; case QEvent::TouchUpdate: if (d->state() != Qt::NoGesture) { QTouchEvent *ev = static_cast(event); if (ev->touchPoints().size() == 3) { d->gestureFired = true; - result = QGestureRecognizer::GestureTriggered; + result = QGestureRecognizer::TriggerGesture; } else { - result = QGestureRecognizer::MaybeGesture; + result = QGestureRecognizer::MayBeGesture; for (int i = 0; i < ev->touchPoints().size(); ++i) { const QTouchEvent::TouchPoint &pt = ev->touchPoints().at(i); const int distance = (pt.pos().toPoint() - pt.startPos().toPoint()).manhattanLength(); if (distance > 20) { - result = QGestureRecognizer::NotGesture; + result = QGestureRecognizer::CancelGesture; } } } } else { - result = QGestureRecognizer::NotGesture; + result = QGestureRecognizer::CancelGesture; } break; @@ -89,7 +89,7 @@ QGestureRecognizer::Result ThreeFingerSlideGestureRecognizer::filterEvent(QGestu if (d->state() != Qt::NoGesture) result = QGestureRecognizer::Ignore; else - result = QGestureRecognizer::NotGesture; + result = QGestureRecognizer::CancelGesture; break; default: result = QGestureRecognizer::Ignore; @@ -105,12 +105,12 @@ void ThreeFingerSlideGestureRecognizer::reset(QGesture *state) } -QGesture *RotateGestureRecognizer::createGesture(QObject *) +QGesture *RotateGestureRecognizer::create(QObject *) { return new QGesture; } -QGestureRecognizer::Result RotateGestureRecognizer::filterEvent(QGesture *, QObject *, QEvent *event) +QGestureRecognizer::Result RotateGestureRecognizer::recognize(QGesture *, QObject *, QEvent *event) { switch (event->type()) { case QEvent::TouchBegin: diff --git a/tests/manual/gestures/graphicsview/gestures.h b/tests/manual/gestures/graphicsview/gestures.h index 6140b12..8a31b71 100644 --- a/tests/manual/gestures/graphicsview/gestures.h +++ b/tests/manual/gestures/graphicsview/gestures.h @@ -59,8 +59,8 @@ public: class ThreeFingerSlideGestureRecognizer : public QGestureRecognizer { private: - QGesture* createGesture(QObject *target); - QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event); + QGesture *create(QObject *target); + QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event); void reset(QGesture *state); }; @@ -70,8 +70,8 @@ public: RotateGestureRecognizer(); private: - QGesture* createGesture(QObject *target); - QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event); + QGesture *create(QObject *target); + QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event); void reset(QGesture *state); }; diff --git a/tests/manual/gestures/graphicsview/main.cpp b/tests/manual/gestures/graphicsview/main.cpp index de92afe..f8433b5 100644 --- a/tests/manual/gestures/graphicsview/main.cpp +++ b/tests/manual/gestures/graphicsview/main.cpp @@ -66,11 +66,11 @@ protected: default: qDebug("view: Pan: "); break; } - const QPointF offset = pan->offset(); + const QPointF delta = pan->delta(); QScrollBar *vbar = verticalScrollBar(); QScrollBar *hbar = horizontalScrollBar(); - vbar->setValue(vbar->value() - offset.y()); - hbar->setValue(hbar->value() - offset.x()); + vbar->setValue(vbar->value() - delta.y()); + hbar->setValue(hbar->value() - delta.x()); ge->accept(pan); return true; } @@ -152,8 +152,8 @@ private: MainWindow::MainWindow() { - (void)QApplication::registerGestureRecognizer(new MousePanGestureRecognizer); - ThreeFingerSlideGesture::Type = QApplication::registerGestureRecognizer(new ThreeFingerSlideGestureRecognizer); + (void)QGestureRecognizer::registerRecognizer(new MousePanGestureRecognizer); + ThreeFingerSlideGesture::Type = QGestureRecognizer::registerRecognizer(new ThreeFingerSlideGestureRecognizer); tabWidget = new QTabWidget; diff --git a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp index 6cdbe12..82adfbd 100644 --- a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp +++ b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp @@ -51,12 +51,12 @@ MousePanGestureRecognizer::MousePanGestureRecognizer() { } -QGesture* MousePanGestureRecognizer::createGesture(QObject *) +QGesture* MousePanGestureRecognizer::create(QObject *) { return new QPanGesture; } -QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event) +QGestureRecognizer::Result MousePanGestureRecognizer::recognize(QGesture *state, QObject *, QEvent *event) { QPanGesture *g = static_cast(state); QPoint globalPos; @@ -78,23 +78,19 @@ QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *stat if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick || event->type() == QEvent::GraphicsSceneMousePress || event->type() == QEvent::GraphicsSceneMouseDoubleClick) { g->setHotSpot(globalPos); - g->setProperty("lastPos", globalPos); + g->setProperty("startPos", globalPos); g->setProperty("pressed", QVariant::fromValue(true)); - return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; + return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint; } else if (event->type() == QEvent::MouseMove || event->type() == QEvent::GraphicsSceneMouseMove) { if (g->property("pressed").toBool()) { - QPoint pos = globalPos; - QPoint lastPos = g->property("lastPos").toPoint(); + QPoint offset = globalPos - g->property("startPos").toPoint(); g->setLastOffset(g->offset()); - lastPos = pos - lastPos; - g->setOffset(QPointF(lastPos.x(), lastPos.y())); - g->setTotalOffset(g->totalOffset() + QPointF(lastPos.x(), lastPos.y())); - g->setProperty("lastPos", pos); - return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; + g->setOffset(QPointF(offset.x(), offset.y())); + return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint; } - return QGestureRecognizer::NotGesture; + return QGestureRecognizer::CancelGesture; } else if (event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::GraphicsSceneMouseRelease) { - return QGestureRecognizer::GestureFinished | QGestureRecognizer::ConsumeEventHint; + return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint; } return QGestureRecognizer::Ignore; } @@ -102,11 +98,10 @@ QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *stat void MousePanGestureRecognizer::reset(QGesture *state) { QPanGesture *g = static_cast(state); - g->setTotalOffset(QPointF()); g->setLastOffset(QPointF()); g->setOffset(QPointF()); g->setAcceleration(0); - g->setProperty("lastPos", QVariant()); + g->setProperty("startPos", QVariant()); g->setProperty("pressed", QVariant::fromValue(false)); QGestureRecognizer::reset(state); } diff --git a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.h b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.h index b062fd0..6e04621 100644 --- a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.h +++ b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.h @@ -49,8 +49,8 @@ class MousePanGestureRecognizer : public QGestureRecognizer public: MousePanGestureRecognizer(); - QGesture* createGesture(QObject *target); - QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event); + QGesture* create(QObject *target); + QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event); void reset(QGesture *state); }; diff --git a/tests/manual/gestures/scrollarea/main.cpp b/tests/manual/gestures/scrollarea/main.cpp index 9a5eb02..4f33b28 100644 --- a/tests/manual/gestures/scrollarea/main.cpp +++ b/tests/manual/gestures/scrollarea/main.cpp @@ -50,7 +50,7 @@ public: ScrollArea(QWidget *parent = 0) : QScrollArea(parent), outside(false) { - viewport()->grabGesture(Qt::PanGesture); + viewport()->grabGesture(Qt::PanGesture, Qt::ReceivePartialGestures); } protected: @@ -87,8 +87,8 @@ protected: if (outside) return; - const QPointF offset = pan->offset(); - const QPointF totalOffset = pan->totalOffset(); + const QPointF delta = pan->delta(); + const QPointF totalOffset = pan->offset(); QScrollBar *vbar = verticalScrollBar(); QScrollBar *hbar = horizontalScrollBar(); @@ -102,8 +102,8 @@ protected: outside = true; return; } - vbar->setValue(vbar->value() - offset.y()); - hbar->setValue(hbar->value() - offset.x()); + vbar->setValue(vbar->value() - delta.y()); + hbar->setValue(hbar->value() - delta.x()); event->accept(pan); } } @@ -147,8 +147,8 @@ protected: event->ignore(pan); if (outside) return; - const QPointF offset = pan->offset(); - const QPointF totalOffset = pan->totalOffset(); + const QPointF delta = pan->delta(); + const QPointF totalOffset = pan->offset(); if (orientation() == Qt::Horizontal) { if ((value() == minimum() && totalOffset.x() < -10) || (value() == maximum() && totalOffset.x() > 10)) { @@ -156,7 +156,7 @@ protected: return; } if (totalOffset.y() < 40 && totalOffset.y() > -40) { - setValue(value() + offset.x()); + setValue(value() + delta.x()); event->accept(pan); } else { outside = true; @@ -168,7 +168,7 @@ protected: return; } if (totalOffset.x() < 40 && totalOffset.x() > -40) { - setValue(value() - offset.y()); + setValue(value() - delta.y()); event->accept(pan); } else { outside = true; @@ -232,7 +232,7 @@ private: int main(int argc, char **argv) { QApplication app(argc, argv); - app.registerGestureRecognizer(new MousePanGestureRecognizer); + QGestureRecognizer::registerRecognizer(new MousePanGestureRecognizer); MainWindow w; w.show(); return app.exec(); diff --git a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp index ce5ef57..66fcf18 100644 --- a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp +++ b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp @@ -49,12 +49,12 @@ MousePanGestureRecognizer::MousePanGestureRecognizer() { } -QGesture* MousePanGestureRecognizer::createGesture(QObject *) +QGesture *MousePanGestureRecognizer::create(QObject *) { return new QPanGesture; } -QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event) +QGestureRecognizer::Result MousePanGestureRecognizer::recognize(QGesture *state, QObject *, QEvent *event) { QPanGesture *g = static_cast(state); if (event->type() == QEvent::TouchBegin) { @@ -68,24 +68,20 @@ QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *stat if (g->property("ignoreMousePress").toBool()) return QGestureRecognizer::Ignore; g->setHotSpot(me->globalPos()); - g->setProperty("lastPos", me->globalPos()); + g->setProperty("startPos", me->globalPos()); g->setProperty("pressed", QVariant::fromValue(true)); - return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; + return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint; } else if (event->type() == QEvent::MouseMove) { if (g->property("pressed").toBool()) { - QPoint pos = me->globalPos(); - QPoint lastPos = g->property("lastPos").toPoint(); + QPoint offset = me->globalPos() - g->property("startPos").toPoint(); g->setLastOffset(g->offset()); - lastPos = pos - lastPos; - g->setOffset(QPointF(lastPos.x(), lastPos.y())); - g->setTotalOffset(g->totalOffset() + QPointF(lastPos.x(), lastPos.y())); - g->setProperty("lastPos", pos); - return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; + g->setOffset(QPointF(offset.x(), offset.y())); + return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint; } - return QGestureRecognizer::NotGesture; + return QGestureRecognizer::CancelGesture; } else if (event->type() == QEvent::MouseButtonRelease) { if (g->property("pressed").toBool()) - return QGestureRecognizer::GestureFinished | QGestureRecognizer::ConsumeEventHint; + return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint; } return QGestureRecognizer::Ignore; } @@ -93,11 +89,10 @@ QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *stat void MousePanGestureRecognizer::reset(QGesture *state) { QPanGesture *g = static_cast(state); - g->setTotalOffset(QPointF()); g->setLastOffset(QPointF()); g->setOffset(QPointF()); g->setAcceleration(0); - g->setProperty("lastPos", QVariant()); + g->setProperty("startPos", QVariant()); g->setProperty("pressed", QVariant::fromValue(false)); g->setProperty("ignoreMousePress", QVariant::fromValue(false)); QGestureRecognizer::reset(state); diff --git a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h index b062fd0..6e04621 100644 --- a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h +++ b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h @@ -49,8 +49,8 @@ class MousePanGestureRecognizer : public QGestureRecognizer public: MousePanGestureRecognizer(); - QGesture* createGesture(QObject *target); - QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event); + QGesture* create(QObject *target); + QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event); void reset(QGesture *state); }; -- cgit v0.12 From a3b84f683e0baae34dc37c85a40dcae3e5306419 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 3 Nov 2009 11:24:02 +0100 Subject: QStyleSheetStyle: CE_PushButton Do not call the parent style if we have nothing to draw This fixes the focus rect that appears on buttons with GtkStyle if a stylesheet is used. Task-number: QTBUG-4488 Reviewed-by: Gabriel --- src/gui/styles/qstylesheetstyle.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index a224218..dfe5209 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -3325,9 +3325,14 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q break; case CE_PushButton: - ParentStyle::drawControl(ce, opt, p, w); - return; - + if (const QStyleOptionButton *btn = qstyleoption_cast(opt)) { + if (rule.hasDrawable() || rule.hasBox() || rule.hasPosition() || rule.hasPalette() || + ((btn->features & QStyleOptionButton::HasMenu) && hasStyleRule(w, PseudoElement_PushButtonMenuIndicator))) { + ParentStyle::drawControl(ce, opt, p, w); + return; + } + } + break; case CE_PushButtonBevel: if (const QStyleOptionButton *btn = qstyleoption_cast(opt)) { QStyleOptionButton btnOpt(*btn); -- cgit v0.12 From c8a7b0430120b391e356a821390aaaebacbbb006 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 3 Nov 2009 11:15:38 +0100 Subject: Toolbar Icons are clipped on Leopard in Cocoa port. Scale the pixmap to correct size (16,16) before setting as the image for the Document Icon button. Reviewed-by: Denis --- src/gui/kernel/qwidget_mac.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 79f55a1..9270220 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3026,7 +3026,8 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset) if (icon.isNull()) { [iconButton setImage:nil]; } else { - NSImage *image = static_cast(qt_mac_create_nsimage(*pm)); + QPixmap scaled = pm->scaled(QSize(16,16), Qt::KeepAspectRatio, Qt::SmoothTransformation); + NSImage *image = static_cast(qt_mac_create_nsimage(scaled)); [iconButton setImage:image]; [image release]; } -- cgit v0.12 From 14a1a9af8ae1b3d2379e6f8c24536afb20b39509 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 3 Nov 2009 11:16:39 +0100 Subject: Cocoa: fix q3filedialog autotest Q3FileDialog does not exist in the cocoa port. Do ifdef this test out on cocoa Rev-by: prasanth --- tests/auto/q3filedialog/tst_q3filedialog.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/auto/q3filedialog/tst_q3filedialog.cpp b/tests/auto/q3filedialog/tst_q3filedialog.cpp index 2585f60..e2686eb 100644 --- a/tests/auto/q3filedialog/tst_q3filedialog.cpp +++ b/tests/auto/q3filedialog/tst_q3filedialog.cpp @@ -59,7 +59,9 @@ public: virtual ~tst_Q3FileDialog(); private slots: +#ifndef QT_MAC_USE_COCOA void getSetCheck(); +#endif }; tst_Q3FileDialog::tst_Q3FileDialog() @@ -70,6 +72,7 @@ tst_Q3FileDialog::~tst_Q3FileDialog() { } +#ifndef QT_MAC_USE_COCOA class Preview : public QLabel, public Q3FilePreview { public: @@ -125,6 +128,7 @@ void tst_Q3FileDialog::getSetCheck() obj1.setPreviewMode(Q3FileDialog::PreviewMode(Q3FileDialog::Info)); QCOMPARE(obj1.previewMode(), Q3FileDialog::PreviewMode(Q3FileDialog::Info)); } +#endif QTEST_MAIN(tst_Q3FileDialog) #include "tst_q3filedialog.moc" -- cgit v0.12 From 1fd46b4495241ed03371fb5c86965b788791b363 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 3 Nov 2009 11:45:16 +0100 Subject: Embed code examples in state machine overview If you put \snippet inside \code tags, it's interpreted as code, not as a tag. Reviewed-by: Trust me --- doc/src/frameworks-technologies/statemachine.qdoc | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/doc/src/frameworks-technologies/statemachine.qdoc b/doc/src/frameworks-technologies/statemachine.qdoc index ac10314..9614dd3 100644 --- a/doc/src/frameworks-technologies/statemachine.qdoc +++ b/doc/src/frameworks-technologies/statemachine.qdoc @@ -426,9 +426,8 @@ value of the property before any property assignments in states were executed.) Take the following code: - \code - \snippet doc/src/snippets/statemachine/main5.cpp 0 - \endcode + + \snippet doc/src/snippets/statemachine/main5.cpp 0 Lets say the property \c fooBar is 0.0 when the machine starts. When the machine is in state \c s1, the property will be 1.0, since the state explicitly assigns this value to it. When the @@ -437,9 +436,8 @@ If we are using nested states, the parent defines a value for the property which is inherited by all descendants that do not explicitly assign a value to the property. - \code + \snippet doc/src/snippets/statemachine/main5.cpp 2 - \endcode Here \c s1 has two children: \c s2 and \c s3. When \c s2 is entered, the property \c fooBar will have the value 2.0, since this is explicitly defined for the state. When the machine is in @@ -452,9 +450,8 @@ properties as they are assigned in states. Say we have the following code: - \code + \snippet doc/src/snippets/statemachine/main5.cpp 3 - \endcode Here we define two states of a user interface. In \c s1 the \c button is small, and in \c s2 it is bigger. If we click the button to transition from \c s1 to \c s2, the geometry of the button @@ -462,9 +459,7 @@ smooth, however, all we need to do is make a QPropertyAnimation and add this to the transition object. - \code \snippet doc/src/snippets/statemachine/main5.cpp 4 - \endcode Adding an animation for the property in question means that the property assignment will no longer take immediate effect when the state has been entered. Instead, the animation will start @@ -486,9 +481,8 @@ the value defined by a state. Say we have the following code: - \code + \snippet doc/src/snippets/statemachine/main5.cpp 5 - \endcode When \c button is clicked, the machine will transition into state \c s2, which will set the geometry of the button, and then pop up a message box to alert the user that the geometry has @@ -504,9 +498,8 @@ value, we can use the state's polished() signal. The polished() signal will be emitted when the the property is assigned its final value, whether this is done immediately or after the animation has finished playing. - \code + \snippet doc/src/snippets/statemachine/main5.cpp 6 - \endcode In this example, when \c button is clicked, the machine will enter \c s2. It will remain in state \c s2 until the \c geometry property has been set to \c QRect(0, 0, 50, 50). Then it will -- cgit v0.12 From 04d5735a608aeeab259463b1bc80842b5134ede6 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Mon, 2 Nov 2009 16:36:41 +0100 Subject: Prepend qt_instdate when using configure.exe as well. Rebuilt configure.exe Rebuilt using VS2008. Reviewed-By: Alessandro Portale --- configure.exe | Bin 1169408 -> 1171968 bytes tools/configure/configureapp.cpp | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.exe b/configure.exe index f433888..7c11fec 100755 Binary files a/configure.exe and b/configure.exe differ diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 28645a0..3f891f6 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -3032,7 +3032,7 @@ void Configure::generateConfigfiles() << "static const char qt_configure_licensed_products_str [512 + 12] = \"qt_lcnsprod=" << dictionary["EDITION"] << "\";" << endl << endl << "/* Build date */" << endl - << "static const char qt_configure_installation [11 + 12] = \"" << QDate::currentDate().toString(Qt::ISODate) << "\";" << endl + << "static const char qt_configure_installation [11 + 12] = \"qt_instdate=" << QDate::currentDate().toString(Qt::ISODate) << "\";" << endl << endl; if(!dictionary[ "QT_HOST_PREFIX" ].isNull()) tmpStream << "#if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE)" << endl; -- cgit v0.12 From 1db4a133a9d35e00bad50541fb8d64079a7debea Mon Sep 17 00:00:00 2001 From: Liang QI Date: Tue, 3 Nov 2009 12:05:50 +0100 Subject: Fix tst_qwebpage and tst_qwebframe compilation on Symbian. RevBy: TrustMe --- src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro | 2 +- src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp | 4 ++++ src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro | 2 +- src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro index 4c92e91..df447d8 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro @@ -5,6 +5,6 @@ SOURCES += tst_qwebframe.cpp RESOURCES += qwebframe.qrc QT += testlib network QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR -DEFINES += SRCDIR=\\\"$$PWD/resources\\\" +!symbian:DEFINES += SRCDIR=\\\"$$PWD/resources\\\" symbian:TARGET.UID3 = 0xA000E53D diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp index 100f272..f8c3440 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp @@ -38,6 +38,10 @@ #endif #include "../util.h" +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif + //TESTED_CLASS= //TESTED_FILES= diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro index 101837a..7d581cd 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro @@ -5,6 +5,6 @@ SOURCES += tst_qwebpage.cpp RESOURCES += tst_qwebpage.qrc QT += testlib network QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR -DEFINES += SRCDIR=\\\"$$PWD/\\\" +!symbian:DEFINES += SRCDIR=\\\"$$PWD/\\\" symbian:TARGET.UID3 = 0xA000E53E diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index 21b3bc7..51611b0 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -37,6 +37,10 @@ #include #include +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif + // Will try to wait for the condition while allowing event processing #define QTRY_COMPARE(__expr, __expected) \ do { \ -- cgit v0.12 From 93ec4104781d7f9929b8b8a05dee3d94f8cd4b17 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Tue, 3 Nov 2009 12:06:00 +0100 Subject: Revert "Compile fix until configure.exe is rebuilt for Windows" since the required changes to configure.exe have been added. You will need to run configure after updating! Reviewed-By: Alessandro Portale This reverts commit 94be7bf47fe93ca4fa6ae90f5906f6ef711f558e. --- src/corelib/global/qlibraryinfo.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 32693e0..15a06d7 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -215,8 +215,7 @@ QLibraryInfo::buildKey() QDate QLibraryInfo::buildDate() { - return QDate(); - //return QDate::fromString(QString::fromLatin1(qt_configure_installation + 12), Qt::ISODate); + return QDate::fromString(QString::fromLatin1(qt_configure_installation + 12), Qt::ISODate); } /*! -- cgit v0.12 From 68be6457f6732437b485812ab2db11c147a24b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 3 Nov 2009 12:15:53 +0100 Subject: Removed usage of CompositionMode_Source in QGraphicsView for X11. Due to the rendering model in XRender ((src IN mask) OP dest) we can't support the PorterDuff composition modes natively under X11. They just behave differently than what we've defined them to do in QPainter, and there is no apparent workaround. Task-number: QTBUG-4829 Reviewed-by: Gunnar --- src/gui/graphicsview/qgraphicsview.cpp | 8 +++++++- src/gui/painting/qpainter.cpp | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 710c745..8945f51 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -281,6 +281,7 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime < #include #include #ifdef Q_WS_X11 +#include #include #endif @@ -3294,7 +3295,12 @@ void QGraphicsView::paintEvent(QPaintEvent *event) backgroundPainter.setClipRegion(d->backgroundPixmapExposed, Qt::ReplaceClip); if (viewTransformed) backgroundPainter.setTransform(viewTransform); - backgroundPainter.setCompositionMode(QPainter::CompositionMode_Source); +#ifdef Q_WS_X11 +#undef X11 + if (backgroundPainter.paintEngine()->type() != QPaintEngine::X11) +#define X11 qt_x11Data +#endif + backgroundPainter.setCompositionMode(QPainter::CompositionMode_Source); drawBackground(&backgroundPainter, exposedSceneRect); d->backgroundPixmapExposed = QRegion(); } diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index cddad7d..8d6cad3 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -2275,8 +2275,9 @@ void QPainter::setBrushOrigin(const QPointF &p) /*! Sets the composition mode to the given \a mode. - \warning You can only set the composition mode for QPainter - objects that operates on a QImage. + \warning Only a QPainter operating on a QImage fully supports all + composition modes. The RasterOp modes are supported for X11 as + described in compositionMode(). \sa compositionMode() */ -- cgit v0.12 From cb396cf4851b961fb42e21866d7467efb3642a04 Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 3 Nov 2009 12:45:44 +0100 Subject: Fixed compile error on Symbian emulator. RevBy: Trust me --- src/gui/itemviews/qabstractitemview.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/itemviews/qabstractitemview.h b/src/gui/itemviews/qabstractitemview.h index 7a0509b..ea5d259 100644 --- a/src/gui/itemviews/qabstractitemview.h +++ b/src/gui/itemviews/qabstractitemview.h @@ -363,6 +363,7 @@ private: friend class QTreeViewPrivate; // needed to compile with MSVC friend class QAccessibleItemRow; friend class QListModeViewBase; + friend class QListViewPrivate; // needed to compile for Symbian emulator }; Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractItemView::EditTriggers) -- cgit v0.12 From dc89c842779f87ce69882ba54fa8d5bb79e0edbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Tue, 3 Nov 2009 14:02:03 +0200 Subject: QS60Style: impossible to open menu from styled QToolButton QS60Style ignores toolButton's menu indicator rect. This means that the button's menu cannot be triggered by the user, as the style does not draw the indicator at all. With this fix, style calculates a rect (including margins) for menu indicator and draws that (arrow down) into toolButton (by making the button bevel larger). Task-number: QTBUG-5266 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 949dfcb..350a8e6 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -994,6 +994,10 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast(option)) { const State bflags = toolBtn->state; const QRect button(subControlRect(control, toolBtn, SC_ToolButton, widget)); + QRect menuRect = QRect(); + if (toolBtn->subControls & SC_ToolButtonMenu) + menuRect = subControlRect(control, toolBtn, SC_ToolButtonMenu, widget); + QStyleOptionToolButton toolButton = *toolBtn; if (sub&SC_ToolButton) { @@ -1006,7 +1010,7 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom toolBar = qobject_cast(widget->parentWidget()); if (bflags & (State_Sunken | State_On | State_Raised)) { - tool.rect = button; + tool.rect = button.unite(menuRect); tool.state = bflags; // todo: I'd like to move extension button next to where last button is @@ -1061,6 +1065,12 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom } else { drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); } + + if (toolButton.subControls & SC_ToolButtonMenu) { + tool.rect = menuRect; + tool.state = bflags; + drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); + } } } @@ -2232,7 +2242,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti // todo: items are below with #ifdefs "just in case". in final version, remove all non-required cases case PE_FrameLineEdit: - case PE_IndicatorButtonDropDown: case PE_IndicatorDockWidgetResizeHandle: case PE_PanelTipLabel: case PE_PanelScrollAreaCorner: @@ -2561,6 +2570,29 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple } } break; + case CC_ToolButton: + if (const QStyleOptionToolButton *toolButton = qstyleoption_cast(option)) { + const int indicatorRect = pixelMetric(PM_MenuButtonIndicator, toolButton, widget) + + 2*pixelMetric(PM_ButtonMargin, toolButton, widget); + ret = toolButton->rect; + const bool popup = (toolButton->features & + (QStyleOptionToolButton::MenuButtonPopup | QStyleOptionToolButton::PopupDelay)) + == QStyleOptionToolButton::MenuButtonPopup; + switch (scontrol) { + case SC_ToolButton: + if (popup) + ret.adjust(0, 0, -indicatorRect, 0); + break; + case SC_ToolButtonMenu: + if (popup) + ret.adjust(ret.width() - indicatorRect, ret.height() - indicatorRect, 0, 0); + break; + default: + break; + } + ret = visualRect(toolButton->direction, toolButton->rect, ret); + } + break; default: ret = QCommonStyle::subControlRect(control, option, scontrol, widget); } -- cgit v0.12 From 0ae2258c6cf89349e795b6af95455e29d2a1fa70 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 30 Oct 2009 17:28:51 +0000 Subject: Fix for unresponsive sliders after orientation switch or full-screen video playback During the switch to full-screen video playback, the following happens: 1. Double-tapping to enable full-screen results in a call to QSymbianControl::HandleLongTapL 2. This modifies the global variable QApplication::mouse_buttons, OR'ing in Qt::RightButton 3. QWidgetPrivate::create_sys, called as a result of the call to setWindowFlags made by Phonon::VideoWIdget::setFullScreen, schedules a delayed deletion of the same control as in step (1) above 4. The control gets deleted before it receives a HandlePointerEventL for the long tap release, which would have removed Qt::RightButton from the mouse_button bitmask 5. In subsequent calls to QSlider::mousePressEvent, the test (ev->buttons() ^ ev->button()) is false, which results in the event being ignored. Ideally, we would fix this by propagating the m_previousEventLongPress flag from the deleted QSymbianControl to the newly created one. However, this does not work because the new control does not receive the HandlePointerEventL callback for the long press release. We therefore fix the bug by checking for m_previousEventLondPress in the QSymbianControl destructor; if it is set, we clear the Qt::RightButton bit from the QApplication::mouse_buttons mask. Note that QTBUG-5309 (Cannot interact with sliders after orientation switch during audio playback) is still seen after applying this patch. Task-number: QTBUG-5242, QTBUG-5308 Reviewed-by: axis --- src/gui/kernel/qapplication_s60.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 689429e..e2106ea 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -357,6 +357,9 @@ QSymbianControl::~QSymbianControl() setFocusSafely(false); S60->appUi()->RemoveFromStack(this); delete m_longTapDetector; + + if(m_previousEventLongTap) + QApplicationPrivate::mouse_buttons = QApplicationPrivate::mouse_buttons & ~Qt::RightButton; } void QSymbianControl::setWidget(QWidget *w) -- cgit v0.12 From 159350b766299fee1bfa44410c19500335267fd8 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 3 Nov 2009 13:04:39 +0100 Subject: Fixed crash in QPixmap::fromImage with an Indexed8 without a colortable. Reviewed-by: Trond --- src/gui/image/qpixmap_mac.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp index 15350e8..9209d45 100644 --- a/src/gui/image/qpixmap_mac.cpp +++ b/src/gui/image/qpixmap_mac.cpp @@ -305,11 +305,15 @@ void QMacPixmapData::fromImage(const QImage &img, } break; } - case QImage::Format_Indexed8: - for (int x = 0; x < w; ++x) { - *(drow+x) = PREMUL(image.color(*(srow + x))); + case QImage::Format_Indexed8: { + int numColors = image.numColors(); + if (numColors > 0) { + for (int x = 0; x < w; ++x) { + int index = *(srow + x); + *(drow+x) = PREMUL(image.color(qMin(index, numColors))); + } } - break; + } break; case QImage::Format_RGB32: for (int x = 0; x < w; ++x) *(drow+x) = *(((quint32*)srow) + x) | 0xFF000000; -- cgit v0.12 From 0c7190fa5b6fd5d401854f689676eee8d8591b75 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 2 Nov 2009 14:08:48 +0000 Subject: Fixed state bug in Phonon MMF backend This fixes a bug introduced by 58efa8aa, which meant that, when a new clip was opened: 1. Playback did not start automatically 2. The current volume setting in the app UI was not applied to the MMF client API Task-number: QTBUG-4999 Reviewed-by: trustme --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 998e861..b8c6fb0 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -373,12 +373,12 @@ void MMF::AbstractMediaPlayer::changeState(PrivateState newState) { TRACE_CONTEXT(AbstractMediaPlayer::changeState, EAudioInternal); - // TODO: add some invariants to check that the transition is valid - AbstractPlayer::changeState(newState); - const Phonon::State oldPhononState = phononState(privateState()); const Phonon::State newPhononState = phononState(newState); + // TODO: add some invariants to check that the transition is valid + AbstractPlayer::changeState(newState); + if (LoadingState == oldPhononState && StoppedState == newPhononState) { // Ensure initial volume is set on MMF API before starting playback doVolumeChanged(); -- cgit v0.12 From 8ffbb2e7bd2ba0b92aef8d7212ddd47bdcc4411e Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 3 Nov 2009 07:43:11 +0000 Subject: Fixed volume calculation in Phonon MMF backend Task-number: QTBUG-4777 Reviewed-by: trustme --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index b8c6fb0..b443194 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -318,7 +318,8 @@ void MMF::AbstractMediaPlayer::doVolumeChanged() case PausedState: case PlayingState: case BufferingState: { - const int err = setDeviceVolume(m_volume * m_mmfMaxVolume); + const qreal volume = (m_volume * m_mmfMaxVolume) + 0.5; + const int err = setDeviceVolume(volume); if (KErrNone != err) { setError(NormalError); -- cgit v0.12 From 6a89291da7e1322ad81c4939cc9d69db01957a4c Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 2 Nov 2009 13:58:52 +0000 Subject: Fix for defect introduced by dd48c27f This change causes some applications to crash due to a null pointer dereference in QSoftKeyManagerPrivate::updateSoftKeys_sys. f3854db6 fixes the crash, but introduces incorrect behaviour: the softkey labels are not updated. To see this: 1. Launch qmediaplayer 2. Open a video clip 3. Video clip starts playing but softkeys still have labels "Open" and "Cancel" Reviewed-by: Janne Anttila --- src/gui/kernel/qsoftkeymanager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index fac936f..8612e64 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -237,7 +237,10 @@ void QSoftKeyManagerPrivate::updateSoftKeys_sys(const QList &softkeys) } } - Qt::WindowType sourceWindowType = QSoftKeyManagerPrivate::softKeySource->window()->windowType(); + const Qt::WindowType sourceWindowType = QSoftKeyManagerPrivate::softKeySource + ? QSoftKeyManagerPrivate::softKeySource->window()->windowType() + : Qt::Widget; + if (needsExitButton && sourceWindowType != Qt::Dialog && sourceWindowType != Qt::Popup) QT_TRAP_THROWING(nativeContainer->SetCommandL(2, EAknSoftkeyExit, qt_QString2TPtrC(QSoftKeyManager::tr("Exit")))); -- cgit v0.12 From 6ec05db9b819a23ebac5a5908b8e3ca56b251e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 3 Nov 2009 12:39:46 +0100 Subject: Made QPainter::drawText() respect Qt::TextDontClip flag. The flag was not respected in the vertical direction for any text lines completely outside the bounding rect. Task-number: QTBUG-1666 Reviewed-by: Trond --- src/gui/painting/qpainter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 8d6cad3..e0423f3 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7604,7 +7604,7 @@ start_lengthVariant: l.setPosition(QPointF(0., height)); height += l.height(); width = qMax(width, l.naturalTextWidth()); - if (!brect && height >= r.height()) + if (!dontclip && !brect && height >= r.height()) break; } textLayout.endLayout(); -- cgit v0.12 From 0a24f29a0f53716f9c9e000f5bb55ac5d925df5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 3 Nov 2009 12:11:50 +0100 Subject: Fixed some compiler warnings. Reviewed-by: Trond --- src/gui/painting/qpainterpath_p.h | 9 ++++---- .../gl2paintengineex/qglengineshadermanager.cpp | 9 ++------ src/opengl/qglpixmapfilter.cpp | 24 +--------------------- 3 files changed, 7 insertions(+), 35 deletions(-) diff --git a/src/gui/painting/qpainterpath_p.h b/src/gui/painting/qpainterpath_p.h index 112c2bd..54b9392 100644 --- a/src/gui/painting/qpainterpath_p.h +++ b/src/gui/painting/qpainterpath_p.h @@ -132,10 +132,9 @@ public: QPainterPathData() : cStart(0), fillRule(Qt::OddEvenFill), - pathConverter(0), dirtyBounds(false), - dirtyControlBounds(false) - + dirtyControlBounds(false), + pathConverter(0) { ref = 1; require_moveTo = false; @@ -146,10 +145,10 @@ public: QPainterPathPrivate(), cStart(other.cStart), fillRule(other.fillRule), bounds(other.bounds), controlBounds(other.controlBounds), - pathConverter(0), dirtyBounds(other.dirtyBounds), dirtyControlBounds(other.dirtyControlBounds), - convex(other.convex) + convex(other.convex), + pathConverter(0) { ref = 1; require_moveTo = false; diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 34c448f..40a6241 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -153,13 +153,8 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) // Check that all the elements have been filled: for (int i = 0; i < TotalSnippetCount; ++i) { if (qShaderSnippets[i] == 0) { - QByteArray msg; - msg.append("Fatal: Shader Snippet for "); - msg.append(snippetNameStr(SnippetName(i))); - msg.append(" ("); - msg.append(QByteArray::number(i)); - msg.append(") is missing!"); - qFatal(msg.constData()); + qFatal("Shader snippet for %s (#%d) is missing!", + snippetNameStr(SnippetName(i)).constData(), i); } } #endif diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index ff19e06..8768fbc 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -316,28 +316,6 @@ static const char *qt_gl_texture_sampling_helper = " return texture2D(src, srcCoords).a;\n" "}\n"; -static const char *qt_gl_clamped_texture_sampling_helper = - "highp vec4 texture_dimensions;\n" // x = width, y = height, z = 0.5/width, w = 0.5/height - "lowp float clampedTexture2DAlpha(lowp sampler2D src, highp vec2 srcCoords) {\n" - " highp vec2 clampedCoords = clamp(srcCoords, texture_dimensions.zw, vec2(1.0) - texture_dimensions.zw);\n" - " highp vec2 t = clamp(min(srcCoords, vec2(1.0) - srcCoords) * srcDim + 0.5, 0.0, 1.0);\n" - " return texture2D(src, clampedCoords).a * t.x * t.y;\n" - "}\n" - "lowp vec4 clampedTexture2D(lowp sampler2D src, highp vec2 srcCoords) {\n" - " highp vec2 clampedCoords = clamp(srcCoords, texture_dimensions.zw, vec2(1.0) - texture_dimensions.zw);\n" - " highp vec2 t = clamp(min(srcCoords, vec2(1.0) - srcCoords) * srcDim + 0.5, 0.0, 1.0);\n" - " return texture2D(src, clampedCoords) * t.x * t.y;\n" - "}\n"; - -static QByteArray qt_gl_convertToClamped(const QByteArray &source) -{ - QByteArray result; - result.append(qt_gl_clamped_texture_sampling_helper); - result.append(QByteArray(source).replace("texture2DAlpha", "clampedTexture2DAlpha") - .replace("texture2D", "clampedTexture2D")); - return result; -} - QGLPixmapBlurFilter::QGLPixmapBlurFilter(QGraphicsBlurEffect::BlurHint hint) : m_animatedBlur(false) , m_haveCached(false) @@ -433,7 +411,7 @@ QGLBlurTextureCache::~QGLBlurTextureCache() blurTextureCaches.removeAt(blurTextureCaches.indexOf(this)); } -void QGLBlurTextureCache::timerEvent(QTimerEvent *event) +void QGLBlurTextureCache::timerEvent(QTimerEvent *) { killTimer(timerId); timerId = 0; -- cgit v0.12 From 51c9b68425c1d3fe64a08e6ef0357fbd6bdd8f8a Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 3 Nov 2009 12:55:19 +0100 Subject: Compile fix after the last gesture api change Reviewed-by: trustme --- examples/gestures/imagegestures/imagewidget.cpp | 6 +-- src/gui/kernel/qgesture_p.h | 2 +- src/gui/kernel/qmacgesturerecognizer_mac.mm | 57 ++++++++++------------ src/gui/kernel/qmacgesturerecognizer_mac_p.h | 13 +++-- src/gui/kernel/qstandardgestures.cpp | 2 - .../kernel/qwinnativepangesturerecognizer_win.cpp | 23 ++++----- .../kernel/qwinnativepangesturerecognizer_win_p.h | 5 +- 7 files changed, 50 insertions(+), 58 deletions(-) diff --git a/examples/gestures/imagegestures/imagewidget.cpp b/examples/gestures/imagegestures/imagewidget.cpp index da9daae..f615129 100644 --- a/examples/gestures/imagegestures/imagewidget.cpp +++ b/examples/gestures/imagegestures/imagewidget.cpp @@ -124,9 +124,9 @@ void ImageWidget::panTriggered(QPanGesture *gesture) setCursor(Qt::ArrowCursor); } #endif - QPointF lastOffset = gesture->offset(); - horizontalOffset += lastOffset.x(); - verticalOffset += lastOffset.y(); + QPointF delta = gesture->delta(); + horizontalOffset += delta.x(); + verticalOffset += delta.y(); update(); } diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h index 96fd64d..ae2e287 100644 --- a/src/gui/kernel/qgesture_p.h +++ b/src/gui/kernel/qgesture_p.h @@ -92,7 +92,7 @@ public: QPointF lastOffset; QPointF offset; - QPoint lastPosition; + QPoint startPosition; qreal acceleration; }; diff --git a/src/gui/kernel/qmacgesturerecognizer_mac.mm b/src/gui/kernel/qmacgesturerecognizer_mac.mm index 7019580..d842322 100644 --- a/src/gui/kernel/qmacgesturerecognizer_mac.mm +++ b/src/gui/kernel/qmacgesturerecognizer_mac.mm @@ -53,13 +53,13 @@ QMacSwipeGestureRecognizer::QMacSwipeGestureRecognizer() { } -QGesture *QMacSwipeGestureRecognizer::createGesture(QObject * /*target*/) +QGesture *QMacSwipeGestureRecognizer::create(QObject * /*target*/) { return new QSwipeGesture; } QGestureRecognizer::Result -QMacSwipeGestureRecognizer::filterEvent(QGesture *gesture, QObject *obj, QEvent *event) +QMacSwipeGestureRecognizer::recognize(QGesture *gesture, QObject *obj, QEvent *event) { if (event->type() == QEvent::NativeGesture && obj->isWidgetType()) { QNativeGestureEvent *ev = static_cast(event); @@ -67,7 +67,7 @@ QMacSwipeGestureRecognizer::filterEvent(QGesture *gesture, QObject *obj, QEvent case QNativeGestureEvent::Swipe: { QSwipeGesture *g = static_cast(gesture); g->setSwipeAngle(ev->angle); - return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; + return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint; break; } default: break; @@ -90,13 +90,13 @@ QMacPinchGestureRecognizer::QMacPinchGestureRecognizer() { } -QGesture *QMacPinchGestureRecognizer::createGesture(QObject * /*target*/) +QGesture *QMacPinchGestureRecognizer::create(QObject * /*target*/) { return new QPinchGesture; } QGestureRecognizer::Result -QMacPinchGestureRecognizer::filterEvent(QGesture *gesture, QObject *obj, QEvent *event) +QMacPinchGestureRecognizer::recognize(QGesture *gesture, QObject *obj, QEvent *event) { if (event->type() == QEvent::NativeGesture && obj->isWidgetType()) { QPinchGesture *g = static_cast(gesture); @@ -106,26 +106,26 @@ QMacPinchGestureRecognizer::filterEvent(QGesture *gesture, QObject *obj, QEvent reset(gesture); g->setStartCenterPoint(static_cast(obj)->mapFromGlobal(ev->position)); g->setCenterPoint(g->startCenterPoint()); - g->setWhatChanged(QPinchGesture::CenterPointChanged); - return QGestureRecognizer::MaybeGesture | QGestureRecognizer::ConsumeEventHint; + g->setChangeFlags(QPinchGesture::CenterPointChanged); + g->setTotalChangeFlags(g->totalChangeFlags() | g->changeFlags()); + return QGestureRecognizer::MayBeGesture | QGestureRecognizer::ConsumeEventHint; case QNativeGestureEvent::Rotate: { g->setLastScaleFactor(g->scaleFactor()); g->setLastRotationAngle(g->rotationAngle()); g->setRotationAngle(g->rotationAngle() + ev->percentage); - g->setWhatChanged(QPinchGesture::RotationAngleChanged); - return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; - break; + g->setChangeFlags(QPinchGesture::RotationAngleChanged); + g->setTotalChangeFlags(g->totalChangeFlags() | g->changeFlags()); + return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint; } case QNativeGestureEvent::Zoom: g->setLastScaleFactor(g->scaleFactor()); g->setLastRotationAngle(g->rotationAngle()); g->setScaleFactor(g->scaleFactor() + ev->percentage); - g->setWhatChanged(QPinchGesture::ScaleFactorChanged); - return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; - break; + g->setChangeFlags(QPinchGesture::ScaleFactorChanged); + g->setTotalChangeFlags(g->totalChangeFlags() | g->changeFlags()); + return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint; case QNativeGestureEvent::GestureEnd: - return QGestureRecognizer::GestureFinished | QGestureRecognizer::ConsumeEventHint; - break; + return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint; default: break; } @@ -137,7 +137,8 @@ QMacPinchGestureRecognizer::filterEvent(QGesture *gesture, QObject *obj, QEvent void QMacPinchGestureRecognizer::reset(QGesture *gesture) { QPinchGesture *g = static_cast(gesture); - g->setWhatChanged(0); + g->setChangeFlags(0); + g->setTotalChangeFlags(0); g->setScaleFactor(1.0f); g->setTotalScaleFactor(1.0f); g->setLastScaleFactor(1.0f); @@ -158,7 +159,7 @@ QMacPanGestureRecognizer::QMacPanGestureRecognizer() : _panCanceled(true) { } -QGesture *QMacPanGestureRecognizer::createGesture(QObject *target) +QGesture *QMacPanGestureRecognizer::create(QObject *target) { if (!target) return new QPanGesture; @@ -172,7 +173,7 @@ QGesture *QMacPanGestureRecognizer::createGesture(QObject *target) } QGestureRecognizer::Result -QMacPanGestureRecognizer::filterEvent(QGesture *gesture, QObject *target, QEvent *event) +QMacPanGestureRecognizer::recognize(QGesture *gesture, QObject *target, QEvent *event) { const int panBeginDelay = 300; const int panBeginRadius = 3; @@ -185,10 +186,9 @@ QMacPanGestureRecognizer::filterEvent(QGesture *gesture, QObject *target, QEvent if (ev->touchPoints().size() == 1) { reset(gesture); _startPos = QCursor::pos(); - _lastPos = _startPos; _panTimer.start(panBeginDelay, target); _panCanceled = false; - return QGestureRecognizer::MaybeGesture; + return QGestureRecognizer::MayBeGesture; } break;} case QEvent::TouchEnd: { @@ -197,7 +197,7 @@ QMacPanGestureRecognizer::filterEvent(QGesture *gesture, QObject *target, QEvent const QTouchEvent *ev = static_cast(event); if (ev->touchPoints().size() == 1) - return QGestureRecognizer::GestureFinished; + return QGestureRecognizer::FinishGesture; break;} case QEvent::TouchUpdate: { if (_panCanceled) @@ -212,23 +212,21 @@ QMacPanGestureRecognizer::filterEvent(QGesture *gesture, QObject *target, QEvent if ((p - _startPos).manhattanLength() > panBeginRadius) { _panCanceled = true; _panTimer.stop(); - return QGestureRecognizer::NotGesture; + return QGestureRecognizer::CancelGesture; } } else { const QPointF p = QCursor::pos(); - const QPointF posOffset = p - _lastPos; + const QPointF posOffset = p - _startPos; g->setLastOffset(g->offset()); g->setOffset(QPointF(posOffset.x(), posOffset.y())); - g->setTotalOffset(g->lastOffset() + g->offset()); - _lastPos = p; - return QGestureRecognizer::GestureTriggered; + return QGestureRecognizer::TriggerGesture; } } else if (_panTimer.isActive()) { // I only want to cancel the pan if the user is pressing // more than one finger, and the pan hasn't started yet: _panCanceled = true; _panTimer.stop(); - return QGestureRecognizer::NotGesture; + return QGestureRecognizer::CancelGesture; } break;} case QEvent::Timer: { @@ -239,8 +237,7 @@ QMacPanGestureRecognizer::filterEvent(QGesture *gesture, QObject *target, QEvent break; // Begin new pan session! _startPos = QCursor::pos(); - _lastPos = _startPos; - return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; + return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint; } break; } default: @@ -254,11 +251,9 @@ void QMacPanGestureRecognizer::reset(QGesture *gesture) { QPanGesture *g = static_cast(gesture); _startPos = QPointF(); - _lastPos = QPointF(); _panCanceled = true; g->setOffset(QPointF(0, 0)); g->setLastOffset(QPointF(0, 0)); - g->setTotalOffset(QPointF(0, 0)); g->setAcceleration(qreal(1)); QGestureRecognizer::reset(gesture); } diff --git a/src/gui/kernel/qmacgesturerecognizer_mac_p.h b/src/gui/kernel/qmacgesturerecognizer_mac_p.h index bdc2e08..2dac56a 100644 --- a/src/gui/kernel/qmacgesturerecognizer_mac_p.h +++ b/src/gui/kernel/qmacgesturerecognizer_mac_p.h @@ -64,8 +64,8 @@ class QMacSwipeGestureRecognizer : public QGestureRecognizer public: QMacSwipeGestureRecognizer(); - QGesture *createGesture(QObject *target); - QGestureRecognizer::Result filterEvent(QGesture *gesture, QObject *watched, QEvent *event); + QGesture *create(QObject *target); + QGestureRecognizer::Result recognize(QGesture *gesture, QObject *watched, QEvent *event); void reset(QGesture *gesture); }; @@ -74,8 +74,8 @@ class QMacPinchGestureRecognizer : public QGestureRecognizer public: QMacPinchGestureRecognizer(); - QGesture *createGesture(QObject *target); - QGestureRecognizer::Result filterEvent(QGesture *gesture, QObject *watched, QEvent *event); + QGesture *create(QObject *target); + QGestureRecognizer::Result recognize(QGesture *gesture, QObject *watched, QEvent *event); void reset(QGesture *gesture); }; @@ -86,12 +86,11 @@ class QMacPanGestureRecognizer : public QObject, public QGestureRecognizer public: QMacPanGestureRecognizer(); - QGesture *createGesture(QObject *target); - QGestureRecognizer::Result filterEvent(QGesture *gesture, QObject *watched, QEvent *event); + QGesture *create(QObject *target); + QGestureRecognizer::Result recognize(QGesture *gesture, QObject *watched, QEvent *event); void reset(QGesture *gesture); private: QPointF _startPos; - QPointF _lastPos; QBasicTimer _panTimer; bool _panCanceled; }; diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index ba00a90..dfd49eb 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -79,7 +79,6 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state, QOb case QEvent::TouchBegin: { result = QGestureRecognizer::MayBeGesture; QTouchEvent::TouchPoint p = ev->touchPoints().at(0); - d->lastPosition = p.pos().toPoint(); d->lastOffset = d->offset = QPointF(); break; } @@ -134,7 +133,6 @@ void QPanGestureRecognizer::reset(QGesture *state) QPanGesturePrivate *d = pan->d_func(); d->lastOffset = d->offset = QPointF(); - d->lastPosition = QPoint(); d->acceleration = 0; QGestureRecognizer::reset(state); diff --git a/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp b/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp index c3c8a28..5fceb13 100644 --- a/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp +++ b/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp @@ -56,7 +56,7 @@ QWinNativePanGestureRecognizer::QWinNativePanGestureRecognizer() { } -QGesture *QWinNativePanGestureRecognizer::createGesture(QObject *target) +QGesture *QWinNativePanGestureRecognizer::create(QObject *target) { if (!target) return new QPanGesture; // a special case @@ -73,7 +73,9 @@ QGesture *QWinNativePanGestureRecognizer::createGesture(QObject *target) return new QPanGesture; } -QGestureRecognizer::Result QWinNativePanGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event) +QGestureRecognizer::Result QWinNativePanGestureRecognizer::recognize(QGesture *state, + QObject *, + QEvent *event) { QPanGesture *q = static_cast(state); QPanGesturePrivate *d = q->d_func(); @@ -85,26 +87,25 @@ QGestureRecognizer::Result QWinNativePanGestureRecognizer::filterEvent(QGesture case QNativeGestureEvent::GestureBegin: break; case QNativeGestureEvent::Pan: - result = QGestureRecognizer::GestureTriggered; + result = QGestureRecognizer::TriggerGesture; event->accept(); break; case QNativeGestureEvent::GestureEnd: if (q->state() == Qt::NoGesture) return QGestureRecognizer::Ignore; // some other gesture has ended - result = QGestureRecognizer::GestureFinished; + result = QGestureRecognizer::FinishGesture; break; default: return QGestureRecognizer::Ignore; } if (q->state() == Qt::NoGesture) { - d->lastOffset = d->totalOffset = d->offset = QPointF(); + d->lastOffset = d->offset = QPointF(); + d->startPosition = ev->position; } else { d->lastOffset = d->offset; - d->offset = QPointF(ev->position.x() - d->lastPosition.x(), - ev->position.y() - d->lastPosition.y()); - d->totalOffset += d->offset; + d->offset = QPointF(ev->position.x() - d->startPosition.x(), + ev->position.y() - d->startPosition.y()); } - d->lastPosition = ev->position; } return result; } @@ -114,8 +115,8 @@ void QWinNativePanGestureRecognizer::reset(QGesture *state) QPanGesture *pan = static_cast(state); QPanGesturePrivate *d = pan->d_func(); - d->totalOffset = d->lastOffset = d->offset = QPointF(); - d->lastPosition = QPoint(); + d->lastOffset = d->offset = QPointF(); + d->startPosition = QPoint(); d->acceleration = 0; QGestureRecognizer::reset(state); diff --git a/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h b/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h index 1d723da..8fb0d50 100644 --- a/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h +++ b/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h @@ -62,9 +62,8 @@ class QWinNativePanGestureRecognizer : public QGestureRecognizer public: QWinNativePanGestureRecognizer(); - QGesture *createGesture(QObject *target); - - QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event); + QGesture *create(QObject *target); + QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event); void reset(QGesture *state); }; -- cgit v0.12 From f080d232ef072976b28ca4b448dcb210b5941b2e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 2 Nov 2009 22:30:09 +0100 Subject: fix canReadLine() erroneously returning true the indexOf() call did not consider actualReadBufferSize and thus scanned uninitialized memory for newlines. Reviewed-by: phartman --- src/corelib/tools/qringbuffer_p.h | 27 +++++++++++++++++++++++++++ src/network/socket/qlocalsocket_win.cpp | 3 ++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h index c44346c..7c766cb 100644 --- a/src/corelib/tools/qringbuffer_p.h +++ b/src/corelib/tools/qringbuffer_p.h @@ -287,6 +287,33 @@ public: return -1; } + inline int indexOf(char c, int maxLength) const { + int index = 0; + int remain = qMin(size(), maxLength); + for (int i = 0; remain && i < buffers.size(); ++i) { + int start = 0; + int end = buffers.at(i).size(); + + if (i == 0) + start = head; + if (i == tailBuffer) + end = tail; + if (remain < end - start) { + end = start + remain; + remain = 0; + } else { + remain -= end - start; + } + const char *ptr = buffers.at(i).data() + start; + for (int j = start; j < end; ++j) { + if (*ptr++ == c) + return index; + ++index; + } + } + return -1; + } + inline int read(char *data, int maxLength) { int bytesToRead = qMin(size(), maxLength); int readSoFar = 0; diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 8a745ab..d812d88 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -363,7 +363,8 @@ bool QLocalSocket::canReadLine() const Q_D(const QLocalSocket); if (state() != ConnectedState) return false; - return (d->readBuffer.indexOf('\n') != -1 || QIODevice::canReadLine()); + return (QIODevice::canReadLine() + || d->readBuffer.indexOf('\n', d->actualReadBufferSize) != -1); } void QLocalSocket::close() -- cgit v0.12 From ddbccf7f066d26d3420c9ed18d8c930200814ce1 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 30 Oct 2009 12:14:39 +0100 Subject: Add the Symbian Foundation OS versions Symbian^1 - SV_SF_1 Symbian^2 - SV_SF_2 etc. This is for the benefit of developers working with the Symbian master codelines. Reviewed-by: axis --- src/corelib/global/qglobal.cpp | 22 +++++++++++++++------- src/corelib/global/qglobal.h | 17 +++++++++++++---- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 33c6a34..5578091 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -960,7 +960,7 @@ QT_BEGIN_NAMESPACE \relates Turns the major, minor and patch numbers of a version into an - integer, 0xMMNNPP (MM = major, NN = minor, PP = patch). This can + integer, 0xMMNNPP (MM = major, NN = minor, PP = patch). This can be compared with another similarly processed version id. \sa QT_VERSION @@ -1795,7 +1795,7 @@ QSysInfo::S60Version QSysInfo::s60Version() TInt err = fileFinder.FindWildByDir(qt_S60Filter, qt_S60SystemInstallDir, contents); if (err == KErrNone) { err = contents->Sort(EDescending|ESortByName); - if (err == KErrNone) { + if (err == KErrNone && contents->Count() > 0 && (*contents)[0].iName.Length() >= 12) { TInt major = (*contents)[0].iName[9] - '0'; TInt minor = (*contents)[0].iName[11] - '0'; if (major == 3) { @@ -1808,6 +1808,12 @@ QSysInfo::S60Version QSysInfo::s60Version() if (minor == 0) { return cachedS60Version = SV_S60_5_0; } + else if (minor == 1) { + return cachedS60Version = SV_S60_5_1; + } + else if (minor == 2) { + return cachedS60Version = SV_S60_5_2; + } } } delete contents; @@ -1822,12 +1828,10 @@ QSysInfo::S60Version QSysInfo::s60Version() return cachedS60Version = SV_S60_3_2; # elif defined(__S60_50__) return cachedS60Version = SV_S60_5_0; -# else - return cachedS60Version = SV_S60_Unknown; # endif -# else - return cachedS60Version = SV_S60_Unknown; # endif + //If reaching here, it was not possible to determine the version + return cachedS60Version = SV_S60_Unknown; } QSysInfo::SymbianVersion QSysInfo::symbianVersion() { @@ -1838,6 +1842,10 @@ QSysInfo::SymbianVersion QSysInfo::symbianVersion() return SV_9_3; case SV_S60_5_0: return SV_9_4; + case SV_S60_5_1: + return SV_9_4; + case SV_S60_5_2: + return SV_9_4; default: return SV_Unknown; } @@ -2572,7 +2580,7 @@ void qsrand() seed = GetTickCount(); srand(seed); -#else +#else // Symbian? #endif // defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index cbb8fda..95f09ea 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1478,17 +1478,26 @@ public: #ifdef Q_OS_SYMBIAN enum SymbianVersion { SV_Unknown = 0x0000, + //These are the Symbian Ltd versions 9.2-9.4 SV_9_2 = 10, SV_9_3 = 20, - SV_9_4 = 30 + SV_9_4 = 30, + //Following values are the symbian foundation versions, i.e. Symbian^1 == SV_SF_1 + SV_SF_1 = SV_9_4, + SV_SF_2 = 40, + SV_SF_3 = 50, + SV_SF_4 = 60 }; static SymbianVersion symbianVersion(); enum S60Version { SV_S60_None = 0, SV_S60_Unknown = 1, - SV_S60_3_1 = 10, - SV_S60_3_2 = 20, - SV_S60_5_0 = 30 + SV_S60_3_1 = SV_9_2, + SV_S60_3_2 = SV_9_3, + SV_S60_5_0 = SV_9_4, + //versions beyond 5.0 are to be confirmed - it is better to use symbian version + SV_S60_5_1 = SV_SF_2, + SV_S60_5_2 = SV_SF_3 }; static S60Version s60Version(); #endif -- cgit v0.12 From 92a393940d2dc3a9e2cd4f27e4ca62643c816f6f Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 30 Oct 2009 17:43:45 +0100 Subject: Fix crash in QApplication autotest introduced by native pixmaps (S60 3.1) Problem was caused by S60 closing a handle under our feet when QApplication is destroyed. To avoid this, we open our own handle for the global lock instead of using the shared one inside CFbsBitmap. Also the global unlock/relock is not needed on S60 3.2 so this can be eliminated and save a few cycles (the function call was a no-op before) Reviewed-by: Jani Hautakangas --- src/gui/image/qpixmap_s60.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index 7086341..5c7e93f 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -73,27 +73,27 @@ const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08, used to lock the global bitmap heap. Only used in S60 v3.1 and S60 v3.2. */ +_LIT(KFBSERVLargeBitmapAccessName,"FbsLargeBitmapAccess"); class QSymbianFbsClient { public: - QSymbianFbsClient() : heapLock(0), heapLocked(false) + QSymbianFbsClient() : heapLocked(false) { - QT_TRAP_THROWING(heapLock = new(ELeave) CFbsBitmap); - heapLock->Create(TSize(0,0), S60->screenDevice()->DisplayMode()); + heapLock.OpenGlobal(KFBSERVLargeBitmapAccessName); } ~QSymbianFbsClient() { - delete heapLock; + heapLock.Close(); } bool lockHeap() { bool wasLocked = heapLocked; - if (heapLock && !heapLocked) { - heapLock->LockHeap(ETrue); + if (heapLock.Handle() && !heapLocked) { + heapLock.Wait(); heapLocked = true; } @@ -104,8 +104,8 @@ public: { bool wasLocked = heapLocked; - if (heapLock && heapLocked) { - heapLock->UnlockHeap(ETrue); + if (heapLock.Handle() && heapLocked) { + heapLock.Signal(); heapLocked = false; } @@ -115,7 +115,7 @@ public: private: - CFbsBitmap *heapLock; + RMutex heapLock; bool heapLocked; }; @@ -169,7 +169,7 @@ public: inline void beginDataAccess(CFbsBitmap *bitmap) { - if (symbianVersion == QSysInfo::SV_9_2 || symbianVersion == QSysInfo::SV_9_3) + if (symbianVersion == QSysInfo::SV_9_2) heapWasLocked = qt_symbianFbsClient()->lockHeap(); else bitmap->LockHeap(ETrue); @@ -177,7 +177,7 @@ public: inline void endDataAccess(CFbsBitmap *bitmap) { - if (symbianVersion == QSysInfo::SV_9_2 || symbianVersion == QSysInfo::SV_9_3) { + if (symbianVersion == QSysInfo::SV_9_2) { if (!heapWasLocked) qt_symbianFbsClient()->unlockHeap(); } else { -- cgit v0.12 From 5308b1c607c1209822078d8aae329308c8017636 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 3 Nov 2009 09:47:25 +0100 Subject: Fix for potential crash in S60 style Leaving function called without a TRAP Reviewed-by: Sami Merila --- src/gui/styles/qs60style_s60.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 678844c..0cd87bd 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -1382,13 +1382,13 @@ QSize QS60StylePrivate::naviPaneSize() QSize QS60StyleModeSpecifics::naviPaneSize() { CAknNavigationControlContainer* naviContainer; - if (S60->statusPane()) - naviContainer = static_cast - (S60->statusPane()->ControlL(TUid::Uid(EEikStatusPaneUidNavi))); - if (naviContainer) - return QSize(naviContainer->Size().iWidth, naviContainer->Size().iHeight); - else - return QSize(0,0); + if (S60->statusPane()) { + TRAPD(err, naviContainer = static_cast + (S60->statusPane()->ControlL(TUid::Uid(EEikStatusPaneUidNavi)))); + if (err==KErrNone) + return QSize(naviContainer->Size().iWidth, naviContainer->Size().iHeight); + } + return QSize(0,0); } #endif // Q_WS_S60 -- cgit v0.12 From 3769f290ccc20ff92dd43038743f96097d9fabd0 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 3 Nov 2009 13:03:11 +0100 Subject: Fix cleanupstack crash on exit in Symbian OS 9.2 Destroying the control environment also pops items from the original cleanup stack which is not owned by the control environment. This is a platform issue (and does not occur in 9.3 & 9.4). To avoid this causing a panic, the s60main is changed to not push items on the cleanup stack (instead, it TRAPs the call to main(), and deletes its allocations manually). A further 9.2 cleanup stack crash was caused when application construction fails (because of missing resource files). The resulting exception would bypass deleting the control environment, and return from main with the wrong cleanup stack active. This is resolved by doing the TRAP / cleanup / throw manually instead of using qt_trap_throwing (The control environment cannot be pushed to the cleanup stack, because it owns the cleanup stack at that time). This isn't a 9.2 specific bug, but rather is revealed by 9.2 because the missing resource file is non fatal in 9.3 and 9.4. Fixes many autotests which have crashed on S60 3.1 since the cleanup stack swapping patch. Reviewed-by: axis --- src/gui/kernel/qapplication_s60.cpp | 11 ++++++++++- src/s60main/qts60main_mcrt0.cpp | 8 +++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index e5ee2f1..1b0659a 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1052,8 +1052,17 @@ void qt_init(QApplicationPrivate * /* priv */, int) // After this construction, CEikonEnv will be available from CEikonEnv::Static(). // (much like our qApp). CEikonEnv* coe = new CEikonEnv; - QT_TRAP_THROWING(coe->ConstructAppFromCommandLineL(factory,*commandLine)); + //not using QT_TRAP_THROWING, because coe owns the cleanupstack so it can't be pushed there. + if(err == KErrNone) + TRAP(err, coe->ConstructAppFromCommandLineL(factory,*commandLine)); delete commandLine; + if(err != KErrNone) { + qWarning() << "qt_init: Eikon application construct failed (" + << err + << "), maybe missing resource file on S60 3.1?"; + delete coe; + qt_symbian_throwIfError(err); + } S60->s60InstalledTrapHandler = User::SetTrapHandler(origTrapHandler); diff --git a/src/s60main/qts60main_mcrt0.cpp b/src/s60main/qts60main_mcrt0.cpp index d30e07a..edc2fb8 100644 --- a/src/s60main/qts60main_mcrt0.cpp +++ b/src/s60main/qts60main_mcrt0.cpp @@ -83,12 +83,10 @@ GLDEF_C TInt QtMainWrapper() char **envp = 0; // get args & environment __crt0(argc, argv, envp); - CleanupArrayDelete::PushL(argv); - CleanupArrayDelete::PushL(envp); //Call user(application)'s main - int ret = 0; - QT_TRYCATCH_LEAVING(ret = CALLMAIN(argc, argv, envp);); - CleanupStack::PopAndDestroy(2, argv); + TRAPD(ret, QT_TRYCATCH_LEAVING(ret = CALLMAIN(argc, argv, envp);)); + delete[] argv; + delete[] envp; return ret; } -- cgit v0.12 From 5919feba122d0e5a696a72a3d1e2eff6928824f8 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 3 Nov 2009 13:49:32 +0100 Subject: Fix qclipboard autotest on s60 3.1 It launches 2 subprocesses that use QApplication. Added the resource files to deployment so that construction does not fail Reviewed-by: axis --- tests/auto/qclipboard/test/test.pro | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/auto/qclipboard/test/test.pro b/tests/auto/qclipboard/test/test.pro index 508eba1..62a38af 100644 --- a/tests/auto/qclipboard/test/test.pro +++ b/tests/auto/qclipboard/test/test.pro @@ -13,7 +13,18 @@ win32 { wince*|symbian*: { copier.sources = ../copier/copier.exe copier.path = copier - paster.sources = ../paster/paster.exe + paster.sources = ../paster/paster.exe paster.path = paster - DEPLOYMENT = copier paster + + symbian*: { + load(data_caging_paths) + rsc.sources = $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/copier.rsc + rsc.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/paster.rsc + rsc.path = $$APP_RESOURCE_DIR + reg_resource.sources = $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/copier_reg.rsc + reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/paster_reg.rsc + reg_resource.path = $$REG_RESOURCE_IMPORT_DIR + } + + DEPLOYMENT = copier paster rsc reg_resource } \ No newline at end of file -- cgit v0.12 From 95f7076937065a78029fc50d506fba58f8c6199c Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 3 Nov 2009 13:51:49 +0100 Subject: Fix qdatetime autotest regression My previous addition to the test case to validate local time was too strict for all platforms. Reviewed-by: Paul --- tests/auto/qdatetime/tst_qdatetime.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp index c53780e..1140402 100644 --- a/tests/auto/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/qdatetime/tst_qdatetime.cpp @@ -450,11 +450,12 @@ void tst_QDateTime::toString_enumformat() qDebug() << str3; QVERIFY(!str3.isEmpty()); //check for date/time components in any order - QVERIFY(str3.contains("1995")); + //year may be 2 or 4 digits + QVERIFY(str3.contains("95")); //day and month may be in numeric or word form QVERIFY(str3.contains("12")); QVERIFY(str3.contains("34")); - QVERIFY(str3.contains("56")); + //seconds may be absent } void tst_QDateTime::addDays() -- cgit v0.12 From 4c011468bb93a3d0b8e5cc0d9dd16e7528079119 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 3 Nov 2009 14:05:00 +0100 Subject: Compile... Reviewed-by: TrustMe --- src/gui/styles/qwindowsxpstyle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index 9fd9ce9..fe7f5d7 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -2926,10 +2926,10 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo } // Draw arrow p->save(); - p->setPen(option->palette.dark()); + p->setPen(option->palette.dark().color()); p->drawLine(menuarea.left(), menuarea.top() + 3, menuarea.left(), menuarea.bottom() - 3); - p->setPen(option->palette.light()); + p->setPen(option->palette.light().color()); p->drawLine(menuarea.left() - 1, menuarea.top() + 3, menuarea.left() - 1, menuarea.bottom() - 3); -- cgit v0.12 From 4d0735b98a9bd6b440adf63725e6062b601ed442 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 3 Nov 2009 14:05:31 +0100 Subject: Check for QPixmap::isNull() in QPainter::drawPixmap() Reviewed-by: Samuel --- src/gui/painting/qpainter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 8d6cad3..cbae5b6 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5164,7 +5164,7 @@ void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm) Q_D(QPainter); - if (!d->engine) + if (!d->engine || pm.isNull()) return; #ifndef QT_NO_DEBUG -- cgit v0.12 From 381247326743888075979664f50ea804d6123c42 Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 3 Nov 2009 13:56:42 +0100 Subject: Fixed an input method bug when erasing the last character. Previously we didn't update the editor contents if the new preedit string was empty. However, it could be empty because the user just erased it, so the bug was fixed by checking whether the preedit string in the event and in the editor are different. RevBy: Denis Dzyubenko --- src/gui/text/qtextcontrol.cpp | 3 ++- src/gui/widgets/qlinecontrol.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index 3f6545c..9497b6f 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -1831,7 +1831,8 @@ void QTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) e->ignore(); return; } - bool isGettingInput = !e->commitString().isEmpty() || !e->preeditString().isEmpty() + bool isGettingInput = !e->commitString().isEmpty() + || e->preeditString() != cursor.block().layout()->preeditAreaText() || e->replacementLength() > 0; if (isGettingInput) { diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 8f17e98..0fc94c9 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -401,7 +401,8 @@ void QLineControl::moveCursor(int pos, bool mark) void QLineControl::processInputMethodEvent(QInputMethodEvent *event) { int priorState = 0; - bool isGettingInput = !event->commitString().isEmpty() || !event->preeditString().isEmpty() + bool isGettingInput = !event->commitString().isEmpty() + || event->preeditString() != preeditAreaText() || event->replacementLength() > 0; bool cursorPositionChanged = false; -- cgit v0.12 From 53e486c0e8d23d535711debdd3a71c8ef2211c58 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 3 Nov 2009 14:41:22 +0100 Subject: Fixed tst_qgraphicsitem::hitTestGraphicsEffectItem, caching makes testcase invalid... Reviewed-by: Samuel --- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 684ad4f..3bc6db5 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -7676,20 +7676,6 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() QCOMPARE(items.size(), 1); QCOMPARE(items.at(0), static_cast(item3)); - item1->repaints = 0; - item2->repaints = 0; - item3->repaints = 0; - - view.viewport()->update(75, 75, 20, 20); - QTest::qWait(50); - - // item1 is the effect source and must therefore be repainted. - // item2 intersects with the exposed region - // item3 is just another child outside the exposed region - QCOMPARE(item1->repaints, 1); - QCOMPARE(item2->repaints, 1); - QCOMPARE(item3->repaints, 0); - scene.setItemIndexMethod(QGraphicsScene::NoIndex); QTest::qWait(100); -- cgit v0.12 From edec363cd4dfcb01c488be7f66bdfa2ca93f48bf Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 3 Nov 2009 14:53:19 +0100 Subject: Doc: Added links to the SQL documentation and corrected license info. Reviewed-by: Trust Me --- doc/src/modules.qdoc | 5 ++++- doc/src/sql-programming/sql-programming.qdoc | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/src/modules.qdoc b/doc/src/modules.qdoc index 9c92a31..ea5a9dc 100644 --- a/doc/src/modules.qdoc +++ b/doc/src/modules.qdoc @@ -367,6 +367,9 @@ The QtSql module is part of the \l{Qt Full Framework Edition} and the \l{Open Source Versions of Qt}. + + See the \l{SQL Programming} guide for information about using this + module in your applications. */ /*! @@ -576,7 +579,7 @@ the module under the appropriate version of the GNU LGPL; version 2.1 for applications and libraries licensed under the GNU GPL version 2, or version 3 for applications and libraries licensed under the GNU - GPL version 2. + GPL version 3. \legalese This file is part of the KDE project diff --git a/doc/src/sql-programming/sql-programming.qdoc b/doc/src/sql-programming/sql-programming.qdoc index d0b6776..3aceb17 100644 --- a/doc/src/sql-programming/sql-programming.qdoc +++ b/doc/src/sql-programming/sql-programming.qdoc @@ -49,6 +49,7 @@ /*! \page sql-programming.html \title SQL Programming + \nextpage Connecting to Databases \brief Database integration for Qt applications. @@ -95,7 +96,7 @@ and the SQL API layer. See \l{SQL Database Drivers} for more information. \section2 SQL API Layer - + These classes provide access to databases. Connections are made using the QSqlDatabase class. Database interaction is achieved by using the QSqlQuery class. @@ -119,6 +120,7 @@ \title Connecting to Databases \contentspage SQL Programming + \previouspage SQL Programming \nextpage Executing SQL Statements To access a database with QSqlQuery or QSqlQueryModel, create and -- cgit v0.12 From 03c5d276c6ffc16c43ac554aa2e22b5824c35c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Tue, 3 Nov 2009 16:03:10 +0200 Subject: Inclusion of QtOpenVg overwrites all other modules in s60install.pro The pro-file is missing '+' when it is adding QtOpenVg support for sis file. Task-number: None Reviewed-by: Janne Koskinen --- src/s60installs/s60installs.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 9c53167..90c9f27 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -107,7 +107,7 @@ symbian: { graphicssystems_plugins.path = c:$$QT_PLUGINS_BASE_DIR/graphicssystems contains(QT_CONFIG, openvg) { - qtlibraries.sources = QtOpenVG.dll + qtlibraries.sources += QtOpenVG.dll graphicssystems_plugins.sources += qvggraphicssystem.dll } -- cgit v0.12 From 8325c15b21cd49287160c8dfb31ebf56ba3090ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 3 Nov 2009 15:34:35 +0100 Subject: Fix memory leak in the Mac accessibility module. Remove duplicate AXUIElement initialization in QAElment. (The duplicate code was erroneously merged in with the cocoa port.) RevBy: Richard Moe Gustavsen --- src/gui/accessible/qaccessible_mac.mm | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/gui/accessible/qaccessible_mac.mm b/src/gui/accessible/qaccessible_mac.mm index 46ef1e5..a875a5c 100644 --- a/src/gui/accessible/qaccessible_mac.mm +++ b/src/gui/accessible/qaccessible_mac.mm @@ -504,11 +504,6 @@ QAElement::QAElement(const QAElement &element) } QAElement::QAElement(HIObjectRef object, int child) - :elementRef( -#ifndef QT_MAC_USE_COCOA - AXUIElementCreateWithHIObjectAndIdentifier(object, child) -#endif -) { #ifndef QT_MAC_USE_COCOA if (object == 0) { -- cgit v0.12 From 9bd330756bc8e0fac9919da0b1068096ee91cb24 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 3 Nov 2009 15:09:09 +0100 Subject: Pressing return in a QWizard would erase the active password entry. When echo mode was set to PasswordEchoOnEdit in a QLineEdit, and its text selected, pressing the return key would erase the text and start editing it instead of validating the password. Auto-test included. Reviewed-by: Olivier Task-number: QTBUG-4401 --- src/gui/widgets/qlinecontrol.cpp | 23 ++++++++++++----------- tests/auto/qlineedit/tst_qlineedit.cpp | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 7f9ff82..26b9c95 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -1509,6 +1509,18 @@ void QLineControl::processKeyEvent(QKeyEvent* event) } #endif // QT_NO_COMPLETER + if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { + if (hasAcceptableInput() || fixup()) { + emit accepted(); + emit editingFinished(); + } + if (inlineCompletionAccepted) + event->accept(); + else + event->ignore(); + return; + } + if (echoMode() == QLineEdit::PasswordEchoOnEdit && !passwordEchoEditing() && !isReadOnly() @@ -1529,17 +1541,6 @@ void QLineControl::processKeyEvent(QKeyEvent* event) clear(); } - if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { - if (hasAcceptableInput() || fixup()) { - emit accepted(); - emit editingFinished(); - } - if (inlineCompletionAccepted) - event->accept(); - else - event->ignore(); - return; - } bool unknown = false; if (false) { diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index c676959..b4dfbba 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -260,6 +260,7 @@ private slots: void task233101_cursorPosAfterInputMethod(); void task241436_passwordEchoOnEditRestoreEchoMode(); void task248948_redoRemovedSelection(); + void taskQTBUG_4401_enterKeyClearsPassword(); protected slots: #ifdef QT3_SUPPORT @@ -3532,5 +3533,20 @@ void tst_QLineEdit::task248948_redoRemovedSelection() QCOMPARE(testWidget->text(), QLatin1String("ab")); } +void tst_QLineEdit::taskQTBUG_4401_enterKeyClearsPassword() +{ + QString password("Wanna guess?"); + + testWidget->setText(password); + testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit); + testWidget->setFocus(); + testWidget->selectAll(); + QApplication::setActiveWindow(testWidget); + QTRY_VERIFY(testWidget->hasFocus()); + + QTest::keyPress(testWidget, Qt::Key_Enter); + QTRY_COMPARE(testWidget->text(), password); +} + QTEST_MAIN(tst_QLineEdit) #include "tst_qlineedit.moc" -- cgit v0.12 From 86e074f47848955cd0ffbc78112493af46c2ed12 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 3 Nov 2009 15:45:32 +0100 Subject: Doc: Fixed license information. Reviewed-by: Trust Me --- src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc index 09dfae5..408478c 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc +++ b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc @@ -31,7 +31,7 @@ the module under the appropriate version of the GNU LGPL; version 2.1 for applications and libraries licensed under the GNU GPL version 2, or version 3 for applications and libraries licensed under the GNU - GPL version 2. + GPL version 3. \legalese WebKit is licensed under the GNU Library General Public License. -- cgit v0.12 From fc45c07c27100591750ad5c360fde535e15b9dbd Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 3 Nov 2009 16:45:10 +0200 Subject: Made xmlpatterns autotests compile for Symbian Fixed xmlpatterns autotests so that they compile for Symbian with both RVCT and NokiaX86 compilers. Reviewed-by: Janne Koskinen --- src/xmlpatterns/acceltree/qacceltree_p.h | 2 +- src/xmlpatterns/acceltree/qcompressedwhitespace_p.h | 2 +- tests/auto/checkxmlfiles/checkxmlfiles.pro | 2 +- tests/auto/qxmlnodemodelindex/tst_qxmlnodemodelindex.cpp | 2 +- tests/auto/qxmlquery/tst_qxmlquery.cpp | 14 +++++++------- tests/auto/qxmlschema/tst_qxmlschema.cpp | 4 ++-- tests/auto/qxmlschemavalidator/tst_qxmlschemavalidator.cpp | 12 ++++++------ tests/auto/qxmlserializer/tst_qxmlserializer.cpp | 4 ++-- tests/auto/xmlpatterns.pri | 5 +++-- tests/auto/xmlpatterns/tst_xmlpatterns.cpp | 10 +++++++++- tests/auto/xmlpatterns/xmlpatterns.pro | 6 +++--- tests/auto/xmlpatternsdiagnosticsts/test/test.pro | 4 ++-- tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro | 5 +++-- tests/auto/xmlpatternsxqts/lib/Global.h | 2 +- tests/auto/xmlpatternsxqts/lib/lib.pro | 6 ++++++ 15 files changed, 48 insertions(+), 32 deletions(-) diff --git a/src/xmlpatterns/acceltree/qacceltree_p.h b/src/xmlpatterns/acceltree/qacceltree_p.h index 8da61c9..ee7d6f6 100644 --- a/src/xmlpatterns/acceltree/qacceltree_p.h +++ b/src/xmlpatterns/acceltree/qacceltree_p.h @@ -89,7 +89,7 @@ namespace QPatternist * @see Accelerating * XPath Evaluation in Any RDBMS, Torsten Grust */ - class AccelTree : public QAbstractXmlNodeModel + class Q_AUTOTEST_EXPORT AccelTree : public QAbstractXmlNodeModel { friend class AccelTreePrivate; public: diff --git a/src/xmlpatterns/acceltree/qcompressedwhitespace_p.h b/src/xmlpatterns/acceltree/qcompressedwhitespace_p.h index bb547bd..27e3c22 100644 --- a/src/xmlpatterns/acceltree/qcompressedwhitespace_p.h +++ b/src/xmlpatterns/acceltree/qcompressedwhitespace_p.h @@ -84,7 +84,7 @@ namespace QPatternist * * @author Frans Englich */ - class CompressedWhitespace + class Q_AUTOTEST_EXPORT CompressedWhitespace { public: /** diff --git a/tests/auto/checkxmlfiles/checkxmlfiles.pro b/tests/auto/checkxmlfiles/checkxmlfiles.pro index c368c02..d53c11c 100644 --- a/tests/auto/checkxmlfiles/checkxmlfiles.pro +++ b/tests/auto/checkxmlfiles/checkxmlfiles.pro @@ -12,7 +12,7 @@ addFiles.sources = \ $$QT_SOURCE_TREE/examples/sql/masterdetail/albumdetails.xml \ $$QT_SOURCE_TREE/examples/xmlpatterns/xquery/globalVariables/globals.gccxml \ $$QT_SOURCE_TREE/doc/src/diagrams/stylesheet/treeview.svg \ - $$QT_SOURCE_TREE/doc/src/diagrams/designer-mainwindow-actions.ui \ + $$QT_SOURCE_TREE/doc/src/diagrams/designer-manual/designer-mainwindow-actions.ui \ $$QT_SOURCE_TREE/demos/undo/undo.qrc addFiles.path = xmlfiles DEPLOYMENT += addFiles diff --git a/tests/auto/qxmlnodemodelindex/tst_qxmlnodemodelindex.cpp b/tests/auto/qxmlnodemodelindex/tst_qxmlnodemodelindex.cpp index cb6bd4d..c19deb6 100644 --- a/tests/auto/qxmlnodemodelindex/tst_qxmlnodemodelindex.cpp +++ b/tests/auto/qxmlnodemodelindex/tst_qxmlnodemodelindex.cpp @@ -178,7 +178,7 @@ void tst_QXmlNodeModelIndex::model() const /* Check default value. */ { const QXmlNodeModelIndex index; - QCOMPARE(index.model(), static_cast(0)); + QCOMPARE(index.model(), static_cast(0)); } } diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp index 8a9d4ef..49f2b08 100644 --- a/tests/auto/qxmlquery/tst_qxmlquery.cpp +++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp @@ -345,8 +345,8 @@ void tst_QXmlQuery::copyConstructor() const query1.setInitialTemplateName(name); const QXmlQuery query2(query1); - QCOMPARE(query2.messageHandler(), &silencer); - QCOMPARE(query2.uriResolver(), &resolver); + QCOMPARE(query2.messageHandler(), static_cast(&silencer)); + QCOMPARE(query2.uriResolver(), static_cast(&resolver)); QCOMPARE(query2.queryLanguage(), QXmlQuery::XSLT20); QCOMPARE(query2.initialTemplateName(), name); QCOMPARE(query2.networkAccessManager(), &networkManager); @@ -522,7 +522,7 @@ void tst_QXmlQuery::assignmentOperator() const QVERIFY(copy.isValid()); QCOMPARE(copy.uriResolver(), static_cast(&returnURI)); - QCOMPARE(copy.messageHandler(), &silencer); + QCOMPARE(copy.messageHandler(), static_cast(&silencer)); QCOMPARE(testName.localName(copy.namePool()), QString::fromLatin1("somethingToCheck")); QXmlResultItems result; @@ -559,7 +559,7 @@ void tst_QXmlQuery::assignmentOperator() const /* Check that the copy picked up the new things. */ QVERIFY(copy.isValid()); QCOMPARE(copy.uriResolver(), static_cast(&secondUriResolver)); - QCOMPARE(copy.messageHandler(), &secondSilencer); + QCOMPARE(copy.messageHandler(), static_cast(&secondSilencer)); QXmlResultItems resultCopy; copy.evaluateTo(&resultCopy); @@ -577,7 +577,7 @@ void tst_QXmlQuery::assignmentOperator() const /* Check that the original is unchanged. */ QVERIFY(original.isValid()); QCOMPARE(original.uriResolver(), static_cast(&returnURI)); - QCOMPARE(original.messageHandler(), &silencer); + QCOMPARE(original.messageHandler(), static_cast(&silencer)); QXmlResultItems resultOriginal; original.evaluateTo(&resultOriginal); @@ -931,7 +931,7 @@ void tst_QXmlQuery::setMessageHandler() const QXmlQuery query; MessageSilencer silencer; query.setMessageHandler(&silencer); - QCOMPARE(&silencer, query.messageHandler()); + QCOMPARE(static_cast(&silencer), query.messageHandler()); } void tst_QXmlQuery::evaluateToReceiver() @@ -1691,7 +1691,7 @@ void tst_QXmlQuery::setUriResolver() const TestURIResolver resolver; QXmlQuery query; query.setUriResolver(&resolver); - QCOMPARE(query.uriResolver(), &resolver); + QCOMPARE(query.uriResolver(), static_cast(&resolver)); } } diff --git a/tests/auto/qxmlschema/tst_qxmlschema.cpp b/tests/auto/qxmlschema/tst_qxmlschema.cpp index 79f5587..ec91f88 100644 --- a/tests/auto/qxmlschema/tst_qxmlschema.cpp +++ b/tests/auto/qxmlschema/tst_qxmlschema.cpp @@ -357,7 +357,7 @@ void tst_QXmlSchema::messageHandler() const QXmlSchema schema; schema.setMessageHandler(&handler); - QCOMPARE(schema.messageHandler(), &handler); + QCOMPARE(schema.messageHandler(), static_cast(&handler)); } } @@ -394,7 +394,7 @@ void tst_QXmlSchema::uriResolver() const QXmlSchema schema; schema.setUriResolver(&resolver); - QCOMPARE(schema.uriResolver(), &resolver); + QCOMPARE(schema.uriResolver(), static_cast(&resolver)); } } diff --git a/tests/auto/qxmlschemavalidator/tst_qxmlschemavalidator.cpp b/tests/auto/qxmlschemavalidator/tst_qxmlschemavalidator.cpp index 519f864..9fc784b 100644 --- a/tests/auto/qxmlschemavalidator/tst_qxmlschemavalidator.cpp +++ b/tests/auto/qxmlschemavalidator/tst_qxmlschemavalidator.cpp @@ -149,8 +149,8 @@ void tst_QXmlSchemaValidator::propertyInitialization() const schema.setNetworkAccessManager(&manager); QXmlSchemaValidator validator(schema); - QCOMPARE(validator.messageHandler(), &handler); - QCOMPARE(validator.uriResolver(), &resolver); + QCOMPARE(validator.messageHandler(), static_cast(&handler)); + QCOMPARE(validator.uriResolver(), static_cast(&resolver)); QCOMPARE(validator.networkAccessManager(), &manager); } } @@ -384,7 +384,7 @@ void tst_QXmlSchemaValidator::messageHandler() const QXmlSchemaValidator validator(schema); validator.setMessageHandler(&handler); - QCOMPARE(validator.messageHandler(), &handler); + QCOMPARE(validator.messageHandler(), static_cast(&handler)); } /* Test that we return the message handler that was set, even if the schema changed in between. */ @@ -399,7 +399,7 @@ void tst_QXmlSchemaValidator::messageHandler() const const QXmlSchema schema2; validator.setSchema(schema2); - QCOMPARE(validator.messageHandler(), &handler); + QCOMPARE(validator.messageHandler(), static_cast(&handler)); } } @@ -452,7 +452,7 @@ void tst_QXmlSchemaValidator::uriResolver() const QXmlSchemaValidator validator(schema); validator.setUriResolver(&resolver); - QCOMPARE(validator.uriResolver(), &resolver); + QCOMPARE(validator.uriResolver(), static_cast(&resolver)); } /* Test that we return the uri resolver that was set, even if the schema changed in between. */ @@ -467,7 +467,7 @@ void tst_QXmlSchemaValidator::uriResolver() const const QXmlSchema schema2; validator.setSchema(schema2); - QCOMPARE(validator.uriResolver(), &resolver); + QCOMPARE(validator.uriResolver(), static_cast(&resolver)); } } diff --git a/tests/auto/qxmlserializer/tst_qxmlserializer.cpp b/tests/auto/qxmlserializer/tst_qxmlserializer.cpp index aeca140..51044ff 100644 --- a/tests/auto/qxmlserializer/tst_qxmlserializer.cpp +++ b/tests/auto/qxmlserializer/tst_qxmlserializer.cpp @@ -148,7 +148,7 @@ void tst_QXmlSerializer::outputDevice() const { const QXmlQuery query; const QXmlSerializer serializer(query, &file); - QCOMPARE(serializer.outputDevice(), &file); + QCOMPARE(serializer.outputDevice(), static_cast< QIODevice *>(&file)); } } @@ -158,7 +158,7 @@ void tst_QXmlSerializer::serializationError() const QXmlQuery query; MessageSilencer silencer; query.setMessageHandler(&silencer); - + query.setQuery(queryString); QByteArray output; diff --git a/tests/auto/xmlpatterns.pri b/tests/auto/xmlpatterns.pri index 7cdd67f..8c8ccad 100644 --- a/tests/auto/xmlpatterns.pri +++ b/tests/auto/xmlpatterns.pri @@ -15,8 +15,9 @@ QT -= gui XMLPATTERNS_SDK = QtXmlPatternsSDK if(!debug_and_release|build_pass):CONFIG(debug, debug|release) { - win32:XMLPATTERNS_SDK = $${XMLPATTERNS_SDK}d - else: XMLPATTERNS_SDK = $${XMLPATTERNS_SDK}_debug + symbian: XMLPATTERNS_SDK = $${XMLPATTERNS_SDK} + else:win32: XMLPATTERNS_SDK = $${XMLPATTERNS_SDK}d + else: XMLPATTERNS_SDK = $${XMLPATTERNS_SDK}_debug } INCLUDEPATH += \ diff --git a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp index 0dcb070..22f6693 100644 --- a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp +++ b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp @@ -48,6 +48,10 @@ #include "../qxmlquery/TestFundament.h" #include "../network-settings.h" +#if defined(Q_OS_SYMBIAN) +#define SRCDIR "" +#endif + /*! \class tst_XmlPatterns \internal @@ -130,6 +134,8 @@ void tst_XmlPatterns::xquerySupport() #ifdef Q_OS_WINCE QSKIP("WinCE: This test uses unsupported WinCE functionality", SkipAll); +#elif defined(Q_OS_SYMBIAN) + QSKIP("Symbian: This test uses unsupported Symbian functionality (QProcess with std streams)", SkipAll); #endif QFETCH(int, expectedExitCode); @@ -218,7 +224,7 @@ void tst_XmlPatterns::xquerySupport() void tst_XmlPatterns::xquerySupport_data() const { -#ifdef Q_OS_WINCE +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) return; #endif @@ -849,6 +855,8 @@ void tst_XmlPatterns::xsltSupport_data() const #ifdef Q_OS_WINCE QSKIP("WinCE: This test uses unsupported WinCE functionality", SkipAll); +#elif defined(Q_OS_SYMBIAN) + QSKIP("Symbian: This test uses unsupported Symbian functionality (QProcess with std streams)", SkipAll); #endif QTest::addColumn("expectedExitCode"); diff --git a/tests/auto/xmlpatterns/xmlpatterns.pro b/tests/auto/xmlpatterns/xmlpatterns.pro index 01e3b2b..54dd9aa 100644 --- a/tests/auto/xmlpatterns/xmlpatterns.pro +++ b/tests/auto/xmlpatterns/xmlpatterns.pro @@ -2,10 +2,10 @@ load(qttest_p4) SOURCES += tst_xmlpatterns.cpp \ ../qxmlquery/TestFundament.cpp -!wince* { -DEFINES += SRCDIR=\\\"$$PWD/\\\" -} else { +wince* { DEFINES += SRCDIR=\\\"./\\\" +} else:!symbian { +DEFINES += SRCDIR=\\\"$$PWD/\\\" } include (../xmlpatterns.pri) diff --git a/tests/auto/xmlpatternsdiagnosticsts/test/test.pro b/tests/auto/xmlpatternsdiagnosticsts/test/test.pro index aeff896..acd71e4 100644 --- a/tests/auto/xmlpatternsdiagnosticsts/test/test.pro +++ b/tests/auto/xmlpatternsdiagnosticsts/test/test.pro @@ -25,8 +25,8 @@ INCLUDEPATH += $$(QTSRCDIR)/tests/auto/xmlpatternsxqts/lib/ \ ../../xmlpatternsxqts/test \ ../../xmlpatternsxqts/lib -wince*: { - catalog.sources = TestSuite Baseline.xml +wince*|symbian { + catalog.sources = ../TestSuite ../Baseline.xml catalog.path = . DEPLOYMENT += catalog } diff --git a/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro b/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro index bcc988a..0f55078 100644 --- a/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro +++ b/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro @@ -11,8 +11,9 @@ SOURCES += ../xmlpatternsxqts/test/tst_suitetest.cpp PATTERNIST_SDK = QtXmlPatternsSDK if(!debug_and_release|build_pass):CONFIG(debug, debug|release) { - win32:PATTERNIST_SDK = $${PATTERNIST_SDK}d - else: PATTERNIST_SDK = $${PATTERNIST_SDK}_debug + symbian: PATTERNIST_SDK = $${PATTERNIST_SDK} + else:win32: PATTERNIST_SDK = $${PATTERNIST_SDK}d + else: PATTERNIST_SDK = $${PATTERNIST_SDK}_debug } LIBS += -l$$PATTERNIST_SDK diff --git a/tests/auto/xmlpatternsxqts/lib/Global.h b/tests/auto/xmlpatternsxqts/lib/Global.h index eadb940..a620417 100644 --- a/tests/auto/xmlpatternsxqts/lib/Global.h +++ b/tests/auto/xmlpatternsxqts/lib/Global.h @@ -47,7 +47,7 @@ #include "private/qitem_p.h" #include "private/qnamepool_p.h" -#ifdef Q_WS_WIN +#if defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) # ifdef Q_PATTERNISTSDK_BUILDING #define Q_PATTERNISTSDK_EXPORT __declspec(dllexport) #else diff --git a/tests/auto/xmlpatternsxqts/lib/lib.pro b/tests/auto/xmlpatternsxqts/lib/lib.pro index cb9453a..f5b0a06 100644 --- a/tests/auto/xmlpatternsxqts/lib/lib.pro +++ b/tests/auto/xmlpatternsxqts/lib/lib.pro @@ -13,6 +13,12 @@ mac { INSTALLS += target } +symbian { + TARGET.EPOCALLOWDLLDATA=1 + TARGET.CAPABILITY = All -Tcb + MMP_RULES += EXPORTUNFROZEN +} + # We add gui, because xmlpatterns.pri pull it out. QT += xmlpatterns xml network testlib gui -- cgit v0.12 From c95a0e6e8eb8ba5fd2a4412b318ad998b3ccb4fc Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 3 Nov 2009 16:06:05 +0100 Subject: Doc/i18n: Fixed source strings for translation. Reviewed-by: Oswald Buddenhagen --- src/3rdparty/phonon/gstreamer/mediaobject.cpp | 2 +- src/3rdparty/phonon/mmf/effectfactory.cpp | 4 ++-- .../WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp | 4 ++-- src/gui/itemviews/qdirmodel.cpp | 2 +- src/network/ssl/qsslerror.cpp | 4 ++-- src/network/ssl/qsslsocket_openssl.cpp | 2 +- src/xmlpatterns/expr/qncnameconstructor_p.h | 2 +- src/xmlpatterns/parser/qquerytransformparser.cpp | 18 +++++++++--------- src/xmlpatterns/schema/qxsdschemahelper.cpp | 2 +- src/xmlpatterns/schema/qxsdschemaparser.cpp | 2 +- .../schema/qxsdvalidatinginstancereader.cpp | 4 ++-- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/3rdparty/phonon/gstreamer/mediaobject.cpp b/src/3rdparty/phonon/gstreamer/mediaobject.cpp index 5dcbd42..0eb34b0 100644 --- a/src/3rdparty/phonon/gstreamer/mediaobject.cpp +++ b/src/3rdparty/phonon/gstreamer/mediaobject.cpp @@ -87,7 +87,7 @@ MediaObject::MediaObject(Backend *backend, QObject *parent) m_name = "MediaObject" + QString::number(count++); if (!m_backend->isValid()) { - setError(tr("Cannot start playback. \n\nCheck your Gstreamer installation and make sure you " + setError(tr("Cannot start playback. \n\nCheck your GStreamer installation and make sure you " "\nhave libgstreamer-plugins-base installed."), Phonon::FatalError); } else { m_root = this; diff --git a/src/3rdparty/phonon/mmf/effectfactory.cpp b/src/3rdparty/phonon/mmf/effectfactory.cpp index 214baa0..e9c5e27 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.cpp +++ b/src/3rdparty/phonon/mmf/effectfactory.cpp @@ -62,9 +62,9 @@ QHash EffectFactory::audioEffectDescriptions(AbstractAudio switch (type) { case AbstractAudioEffect::EffectAudioEqualizer: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "audio equalizer"), "Audio equalizer."); + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Audio Equalizer"), "Audio equalizer."); case AbstractAudioEffect::EffectBassBoost: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Bass boost"), "Bass boost."); + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Bass Boost"), "Bass boost."); case AbstractAudioEffect::EffectDistanceAttenuation: return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Distance Attenuation"), "Distance Attenuation."); case AbstractAudioEffect::EffectEnvironmentalReverb: diff --git a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp index 81ccbe8..1ed9b21 100644 --- a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp +++ b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp @@ -708,7 +708,7 @@ void FrameLoaderClientQt::committedLoad(WebCore::DocumentLoader* loader, const c WebCore::ResourceError FrameLoaderClientQt::cancelledError(const WebCore::ResourceRequest& request) { ResourceError error = ResourceError("QtNetwork", QNetworkReply::OperationCanceledError, request.url().prettyURL(), - QCoreApplication::translate("QWebFrame", "Request cancelled", 0, QCoreApplication::UnicodeUTF8)); + QCoreApplication::translate("QWebFrame", "Request canceled", 0, QCoreApplication::UnicodeUTF8)); error.setIsCancellation(true); return error; } @@ -746,7 +746,7 @@ WebCore::ResourceError FrameLoaderClientQt::interruptForPolicyChangeError(const WebCore::ResourceError FrameLoaderClientQt::cannotShowMIMETypeError(const WebCore::ResourceResponse& response) { return ResourceError("WebKit", WebKitErrorCannotShowMIMEType, response.url().string(), - QCoreApplication::translate("QWebFrame", "Cannot show mimetype", 0, QCoreApplication::UnicodeUTF8)); + QCoreApplication::translate("QWebFrame", "Cannot show MIME type", 0, QCoreApplication::UnicodeUTF8)); } WebCore::ResourceError FrameLoaderClientQt::fileDoesNotExistError(const WebCore::ResourceResponse& response) diff --git a/src/gui/itemviews/qdirmodel.cpp b/src/gui/itemviews/qdirmodel.cpp index 2973741..942cfd7 100644 --- a/src/gui/itemviews/qdirmodel.cpp +++ b/src/gui/itemviews/qdirmodel.cpp @@ -1351,7 +1351,7 @@ QString QDirModelPrivate::size(const QModelIndex &index) const return QFileSystemModel::tr("%1 MB").arg(QLocale().toString(qreal(bytes) / mb, 'f', 1)); if (bytes >= kb) return QFileSystemModel::tr("%1 KB").arg(QLocale().toString(bytes / kb)); - return QFileSystemModel::tr("%1 bytes").arg(QLocale().toString(bytes)); + return QFileSystemModel::tr("%1 byte(s)").arg(QLocale().toString(bytes)); } QString QDirModelPrivate::type(const QModelIndex &index) const diff --git a/src/network/ssl/qsslerror.cpp b/src/network/ssl/qsslerror.cpp index 62fcd4c..8fb605c 100644 --- a/src/network/ssl/qsslerror.cpp +++ b/src/network/ssl/qsslerror.cpp @@ -251,10 +251,10 @@ QString QSslError::errorString() const errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "One of the CA certificates is invalid")); break; case PathLengthExceeded: - errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The basicConstraints pathlength parameter has been exceeded")); + errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The basicConstraints path length parameter has been exceeded")); break; case InvalidPurpose: - errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The supplied certificate is unsuited for this purpose")); + errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The supplied certificate is unsuitable for this purpose")); break; case CertificateUntrusted: errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The root CA certificate is not trusted for this purpose")); diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 6f7e55a..743722f 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -324,7 +324,7 @@ init_context: // Check if the certificate matches the private key. if (!q_SSL_CTX_check_private_key(ctx)) { - q->setErrorString(QSslSocket::tr("Private key does not certificate public key, %1").arg(SSL_ERRORSTR())); + q->setErrorString(QSslSocket::tr("Private key does not certify public key, %1").arg(SSL_ERRORSTR())); emit q->error(QAbstractSocket::UnknownSocketError); return false; } diff --git a/src/xmlpatterns/expr/qncnameconstructor_p.h b/src/xmlpatterns/expr/qncnameconstructor_p.h index 6875c48..bbf9726 100644 --- a/src/xmlpatterns/expr/qncnameconstructor_p.h +++ b/src/xmlpatterns/expr/qncnameconstructor_p.h @@ -112,7 +112,7 @@ namespace QPatternist { return QtXmlPatterns::tr("The target name in a processing instruction " "cannot be %1 in any combination of upper " - "and lower case. Therefore, is %2 invalid.") + "and lower case. Therefore, %2 is invalid.") .arg(formatKeyword("xml"), formatKeyword(lexTarget)); } }; diff --git a/src/xmlpatterns/parser/qquerytransformparser.cpp b/src/xmlpatterns/parser/qquerytransformparser.cpp index 5894b83..c250d0c 100644 --- a/src/xmlpatterns/parser/qquerytransformparser.cpp +++ b/src/xmlpatterns/parser/qquerytransformparser.cpp @@ -418,7 +418,7 @@ static void registerNamedTemplate(const QXmlName &name, if(e) { - parseInfo->staticContext->error(QtXmlPatterns::tr("A template by name %1 " + parseInfo->staticContext->error(QtXmlPatterns::tr("A template with name %1 " "has already been declared.") .arg(formatKeyword(parseInfo->staticContext->namePool(), name)), @@ -882,7 +882,7 @@ static void variableUnavailable(const QXmlName &variableName, const ParserContext *const parseInfo, const YYLTYPE &location) { - parseInfo->staticContext->error(QtXmlPatterns::tr("No variable by name %1 exists") + parseInfo->staticContext->error(QtXmlPatterns::tr("No variable with name %1 exists") .arg(formatKeyword(parseInfo->staticContext->namePool(), variableName)), ReportContext::XPST0008, fromYYLTYPE(location, parseInfo)); } @@ -4028,7 +4028,7 @@ yyreduce: const AtomicValue::Ptr val(Decimal::fromLexical((yyvsp[(2) - (2)].sval))); if(val->hasError()) { - parseInfo->staticContext->error(QtXmlPatterns::tr("The value of attribute %1 must of type %2, which %3 isn't.") + parseInfo->staticContext->error(QtXmlPatterns::tr("The value of attribute %1 must be of type %2, which %3 isn't.") .arg(formatKeyword(QLatin1String("priority")), formatType(parseInfo->staticContext->namePool(), BuiltinTypes::xsDecimal), formatData((yyvsp[(2) - (2)].sval))), @@ -4104,7 +4104,7 @@ yyreduce: else if ((yyvsp[(5) - (7)].sval) == CommonNamespaces::XML || (yyvsp[(3) - (7)].sval) == QLatin1String("xml")) { parseInfo->staticContext->error(QtXmlPatterns::tr( - "The prefix %1 can not be bound. By default, it is already bound " + "The prefix %1 cannot be bound. By default, it is already bound " "to the namespace %2.") .arg(formatKeyword("xml")) .arg(formatURI(CommonNamespaces::XML)), @@ -4415,7 +4415,7 @@ yyreduce: allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc), (yyvsp[(3) - (9)].enums.Bool)); if(variableByName((yyvsp[(5) - (9)].qName), parseInfo)) { - parseInfo->staticContext->error(QtXmlPatterns::tr("A variable by name %1 has already " + parseInfo->staticContext->error(QtXmlPatterns::tr("A variable with name %1 has already " "been declared.") .arg(formatKeyword(parseInfo->staticContext->namePool()->toLexical((yyvsp[(5) - (9)].qName)))), parseInfo->isXSLT() ? ReportContext::XTSE0630 : ReportContext::XQST0049, @@ -4455,7 +4455,7 @@ yyreduce: else { parseInfo->staticContext->error(QtXmlPatterns::tr("No value is available for the external " - "variable by name %1.") + "variable with name %1.") .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(5) - (9)].qName))), parseInfo->isXSLT() ? ReportContext::XTDE0050 : ReportContext::XPDY0002, fromYYLTYPE((yyloc), parseInfo)); @@ -4674,7 +4674,7 @@ yyreduce: { if((*it)->name() == (yyvsp[(3) - (3)].functionArgument)->name()) { - parseInfo->staticContext->error(QtXmlPatterns::tr("An argument by name %1 has already " + parseInfo->staticContext->error(QtXmlPatterns::tr("An argument with name %1 has already " "been declared. Every argument name " "must be unique.") .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(3) - (3)].functionArgument)->name())), @@ -6679,7 +6679,7 @@ yyreduce: (yyval.expr) = create(func, (yyloc), parseInfo); else { - parseInfo->staticContext->error(QtXmlPatterns::tr("No function by name %1 is available.") + parseInfo->staticContext->error(QtXmlPatterns::tr("No function with name %1 is available.") .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(1) - (4)].qName))), ReportContext::XPST0017, fromYYLTYPE((yyloc), parseInfo)); } @@ -6929,7 +6929,7 @@ yyreduce: &ryy, true); if(declaredAttributes.contains(att)) { - parseInfo->staticContext->error(QtXmlPatterns::tr("An attribute by name %1 has already appeared on this element.") + parseInfo->staticContext->error(QtXmlPatterns::tr("An attribute with name %1 has already appeared on this element.") .arg(formatKeyword(parseInfo->staticContext->namePool(), att)), ReportContext::XQST0040, fromYYLTYPE((yyloc), parseInfo)); diff --git a/src/xmlpatterns/schema/qxsdschemahelper.cpp b/src/xmlpatterns/schema/qxsdschemahelper.cpp index e9f32c2..7813808 100644 --- a/src/xmlpatterns/schema/qxsdschemahelper.cpp +++ b/src/xmlpatterns/schema/qxsdschemahelper.cpp @@ -727,7 +727,7 @@ bool XsdSchemaHelper::isValidAttributeUsesRestriction(const XsdAttributeUse::Lis } } else { if (!wildcard) { - errorMsg = QtXmlPatterns::tr("Derived attribute %1 does not exists in the base definition.").arg(formatAttribute(derivedAttributeUse->attribute()->displayName(namePool))); + errorMsg = QtXmlPatterns::tr("Derived attribute %1 does not exist in the base definition.").arg(formatAttribute(derivedAttributeUse->attribute()->displayName(namePool))); return false; } diff --git a/src/xmlpatterns/schema/qxsdschemaparser.cpp b/src/xmlpatterns/schema/qxsdschemaparser.cpp index 41c6b82..beb28bb 100644 --- a/src/xmlpatterns/schema/qxsdschemaparser.cpp +++ b/src/xmlpatterns/schema/qxsdschemaparser.cpp @@ -5959,7 +5959,7 @@ void XsdSchemaParser::validateIdAttribute(const char *elementName) attributeContentError("id", elementName, value, BuiltinTypes::xsID); } else { if (m_idCache->hasId(value)) { - error(QtXmlPatterns::tr("Component with id %1 has been defined previously.").arg(formatData(value))); + error(QtXmlPatterns::tr("Component with ID %1 has been defined previously.").arg(formatData(value))); } else { m_idCache->addId(value); } diff --git a/src/xmlpatterns/schema/qxsdvalidatinginstancereader.cpp b/src/xmlpatterns/schema/qxsdvalidatinginstancereader.cpp index fda3548..622a39f 100644 --- a/src/xmlpatterns/schema/qxsdvalidatinginstancereader.cpp +++ b/src/xmlpatterns/schema/qxsdvalidatinginstancereader.cpp @@ -469,7 +469,7 @@ bool XsdValidatingInstanceReader::validateElement(const XsdElement::Ptr &declara // 3.2.3.2 if (declaration->valueConstraint() && declaration->valueConstraint()->variety() == XsdElement::ValueConstraint::Fixed) { - error(QtXmlPatterns::tr("Fixed value constrained not allowed if element is nillable.")); + error(QtXmlPatterns::tr("Fixed value constraint not allowed if element is nillable.")); return false; } } @@ -699,7 +699,7 @@ bool XsdValidatingInstanceReader::validateElementComplexType(const XsdElement::P if (complexType->contentType()->variety() == XsdComplexType::ContentType::Mixed) { if (declaration->valueConstraint() && declaration->valueConstraint()->variety() == XsdElement::ValueConstraint::Fixed) { if (hasChildElement()) { - error(QtXmlPatterns::tr("Element %1 can not contain other elements, as it has a fixed content.").arg(formatKeyword(declaration->displayName(m_namePool)))); + error(QtXmlPatterns::tr("Element %1 cannot contain other elements, as it has a fixed content.").arg(formatKeyword(declaration->displayName(m_namePool)))); return false; } -- cgit v0.12 From a4e7db378ecd11bc858f76beb33c56ccebef6308 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Tue, 3 Nov 2009 15:59:41 +0100 Subject: Fixed fillRect on QImage::Format_ARGB32 images. With composition mode set to QPainter::CompositionMode_Source, the raster paint engine's fillRect function filled images which had non-premultiplied format with premultiplied colours. This was fixed by converting the premultiplied colour back to non-premultiplied before writing to the image. Task-number: QTBUG-5189 Reviewed-by: Trond --- src/gui/painting/qdrawhelper.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 53edbb0..41602a1 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -7424,6 +7424,14 @@ QT_RECTFILL(qrgb444) QT_RECTFILL(qargb4444) #undef QT_RECTFILL +inline static void qt_rectfill_nonpremul_quint32(QRasterBuffer *rasterBuffer, + int x, int y, int width, int height, + quint32 color) +{ + qt_rectfill(reinterpret_cast(rasterBuffer->buffer()), + INV_PREMUL(color), x, y, width, height, rasterBuffer->bytesPerLine()); +} + // Map table for destination image format. Contains function pointers // for blends of various types unto the destination @@ -7466,7 +7474,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = qt_bitmapblit_quint32, qt_alphamapblit_quint32, qt_alphargbblit_quint32, - qt_rectfill_quint32 + qt_rectfill_nonpremul_quint32 }, // Format_ARGB32_Premultiplied { -- cgit v0.12 From 9f62759028b0bdb8fb7991c349d58a89323b8567 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 3 Nov 2009 11:04:07 +0100 Subject: Change name of QStateMachine::animationsEnabled property to "animated" The name "animated" is consistent with naming in Qt otherwise, as in QTreeView::animated and QMainWindow::animated. Reviewed-by: Kent Hansen --- src/corelib/statemachine/qstatemachine.cpp | 14 +++++++------- src/corelib/statemachine/qstatemachine.h | 6 +++--- src/corelib/statemachine/qstatemachine_p.h | 2 +- tests/auto/qstatemachine/tst_qstatemachine.cpp | 10 +++++----- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 689967a..322e24a 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -164,7 +164,7 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_ANIMATION /*! - \property QStateMachine::animationsEnabled + \property QStateMachine::animated \brief whether animations are enabled @@ -188,7 +188,7 @@ QStateMachinePrivate::QStateMachinePrivate() globalRestorePolicy = QStateMachine::DoNotRestoreProperties; signalEventGenerator = 0; #ifndef QT_NO_ANIMATION - animationsEnabled = true; + animated = true; #endif } @@ -742,7 +742,7 @@ void QStateMachinePrivate::applyProperties(const QList &tr // Find the animations to use for the state change. QList selectedAnimations; - if (animationsEnabled) { + if (animated) { for (int i = 0; i < transitionList.size(); ++i) { QAbstractTransition *transition = transitionList.at(i); @@ -2116,19 +2116,19 @@ void QStateMachine::onExit(QEvent *event) /*! Returns whether animations are enabled for this state machine. */ -bool QStateMachine::animationsEnabled() const +bool QStateMachine::isAnimated() const { Q_D(const QStateMachine); - return d->animationsEnabled; + return d->animated; } /*! Sets whether animations are \a enabled for this state machine. */ -void QStateMachine::setAnimationsEnabled(bool enabled) +void QStateMachine::setAnimated(bool enabled) { Q_D(QStateMachine); - d->animationsEnabled = enabled; + d->animated = enabled; } /*! diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h index 13b6fe2..f7ceba1 100644 --- a/src/corelib/statemachine/qstatemachine.h +++ b/src/corelib/statemachine/qstatemachine.h @@ -67,7 +67,7 @@ class Q_CORE_EXPORT QStateMachine : public QState Q_PROPERTY(RestorePolicy globalRestorePolicy READ globalRestorePolicy WRITE setGlobalRestorePolicy) Q_ENUMS(RestorePolicy) #ifndef QT_NO_ANIMATION - Q_PROPERTY(bool animationsEnabled READ animationsEnabled WRITE setAnimationsEnabled) + Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated) #endif public: class SignalEvent : public QEvent @@ -133,8 +133,8 @@ public: bool isRunning() const; #ifndef QT_NO_ANIMATION - bool animationsEnabled() const; - void setAnimationsEnabled(bool enabled); + bool isAnimated() const; + void setAnimated(bool enabled); void addDefaultAnimation(QAbstractAnimation *animation); QList defaultAnimations() const; diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index 69b727d..f0d9c7c 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -200,7 +200,7 @@ public: QSet pendingErrorStatesForDefaultEntry; #ifndef QT_NO_ANIMATION - bool animationsEnabled; + bool animated; QPair, QList > initializeAnimation(QAbstractAnimation *abstractAnimation, diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 975b301..0df8d52 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -1340,11 +1340,11 @@ void tst_QStateMachine::assignPropertyWithAnimation() // Single animation { QStateMachine machine; - QVERIFY(machine.animationsEnabled()); - machine.setAnimationsEnabled(false); - QVERIFY(!machine.animationsEnabled()); - machine.setAnimationsEnabled(true); - QVERIFY(machine.animationsEnabled()); + QVERIFY(machine.isAnimated()); + machine.setAnimated(false); + QVERIFY(!machine.isAnimated()); + machine.setAnimated(true); + QVERIFY(machine.isAnimated()); QObject obj; obj.setProperty("foo", 321); obj.setProperty("bar", 654); -- cgit v0.12 From b210026bda1fcd6d38b8a5a556aefe4fb5c4f891 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 3 Nov 2009 12:05:55 +0100 Subject: Change name of DoNotRestoreProperties enum to DontRestoreProperties Using the abbreviated "Dont" is consistent with other negated enum names in Qt. Reviewed-by: Kent Hansen --- src/corelib/statemachine/qstatemachine.cpp | 8 ++++---- src/corelib/statemachine/qstatemachine.h | 2 +- tests/auto/qstatemachine/tst_qstatemachine.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 322e24a..0d07093 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -159,7 +159,7 @@ QT_BEGIN_NAMESPACE \brief the restore policy for states of this state machine. The default value of this property is - QStateMachine::DoNotRestoreProperties. + QStateMachine::DontRestoreProperties. */ #ifndef QT_NO_ANIMATION @@ -185,7 +185,7 @@ QStateMachinePrivate::QStateMachinePrivate() stop = false; stopProcessingReason = EventQueueEmpty; error = QStateMachine::NoError; - globalRestorePolicy = QStateMachine::DoNotRestoreProperties; + globalRestorePolicy = QStateMachine::DontRestoreProperties; signalEventGenerator = 0; #ifndef QT_NO_ANIMATION animated = true; @@ -1696,7 +1696,7 @@ QStateMachine::~QStateMachine() already been saved by the state machine, it will not be overwritten until the property has been successfully restored. - \value DoNotRestoreProperties The state machine should not save the initial values of properties + \value DontRestoreProperties The state machine should not save the initial values of properties and restore them later. \value RestoreProperties The state machine should save the initial values of properties and restore them later. @@ -1746,7 +1746,7 @@ QStateMachine::RestorePolicy QStateMachine::globalRestorePolicy() const /*! Sets the restore policy of the state machine to \a restorePolicy. The default - restore policy is QAbstractState::DoNotRestoreProperties. + restore policy is QAbstractState::DontRestoreProperties. \sa globalRestorePolicy() */ diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h index f7ceba1..ff2b667 100644 --- a/src/corelib/statemachine/qstatemachine.h +++ b/src/corelib/statemachine/qstatemachine.h @@ -109,7 +109,7 @@ public: }; enum RestorePolicy { - DoNotRestoreProperties, + DontRestoreProperties, RestoreProperties }; diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 0df8d52..31ab3af 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -162,7 +162,7 @@ private slots: void defaultGlobalRestorePolicy(); void globalRestorePolicySetToRestore(); - void globalRestorePolicySetToDoNotRestore(); + void globalRestorePolicySetToDontRestore(); void noInitialStateForInitialState(); @@ -984,7 +984,7 @@ void tst_QStateMachine::customErrorStateNotInGraph() void tst_QStateMachine::restoreProperties() { QStateMachine machine; - QCOMPARE(machine.globalRestorePolicy(), QStateMachine::DoNotRestoreProperties); + QCOMPARE(machine.globalRestorePolicy(), QStateMachine::DontRestoreProperties); machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties); QObject *object = new QObject(&machine); @@ -2736,10 +2736,10 @@ void tst_QStateMachine::restorePolicyNotInherited() }*/ -void tst_QStateMachine::globalRestorePolicySetToDoNotRestore() +void tst_QStateMachine::globalRestorePolicySetToDontRestore() { QStateMachine machine; - machine.setGlobalRestorePolicy(QStateMachine::DoNotRestoreProperties); + machine.setGlobalRestorePolicy(QStateMachine::DontRestoreProperties); QObject *propertyHolder = new QObject(&machine); propertyHolder->setProperty("a", 1); -- cgit v0.12 From 569e4b636fc91a9d5c6f6e4d65967327786adb3c Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 3 Nov 2009 13:13:35 +0100 Subject: Remove return type of QState::addTransition(QAbstractTransition*) Returning the input argument in a function can lead to confusion and serves no purpose here. Instead, we'll mirror the API from QMenu::addAction() overloads, where the overload that takes a preconstructed object has a void return type. Reviewed-by: Kent Hansen --- src/corelib/statemachine/qstate.cpp | 15 +++++---- src/corelib/statemachine/qstate.h | 2 +- tests/auto/qstatemachine/tst_qstatemachine.cpp | 42 +++++++++++++++++--------- 3 files changed, 36 insertions(+), 23 deletions(-) diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp index bcd8364..ea20619 100644 --- a/src/corelib/statemachine/qstate.cpp +++ b/src/corelib/statemachine/qstate.cpp @@ -286,15 +286,14 @@ void QState::setErrorState(QAbstractState *state) /*! Adds the given \a transition. The transition has this state as the source. - This state takes ownership of the transition. If the transition is successfully - added, the function will return the \a transition pointer. Otherwise it will return null. + This state takes ownership of the transition. */ -QAbstractTransition *QState::addTransition(QAbstractTransition *transition) +void QState::addTransition(QAbstractTransition *transition) { Q_D(QState); if (!transition) { qWarning("QState::addTransition: cannot add null transition"); - return 0; + return ; } transition->setParent(this); @@ -303,18 +302,17 @@ QAbstractTransition *QState::addTransition(QAbstractTransition *transition) QAbstractState *t = targets.at(i).data(); if (!t) { qWarning("QState::addTransition: cannot add transition to null state"); - return 0; + return ; } if ((QAbstractStatePrivate::get(t)->machine() != d->machine()) && QAbstractStatePrivate::get(t)->machine() && d->machine()) { qWarning("QState::addTransition: cannot add transition " "to a state in a different state machine"); - return 0; + return ; } } if (machine() != 0 && machine()->configuration().contains(this)) QStateMachinePrivate::get(machine())->registerTransitions(this); - return transition; } /*! @@ -379,7 +377,8 @@ QAbstractTransition *QState::addTransition(QAbstractState *target) return 0; } UnconditionalTransition *trans = new UnconditionalTransition(target); - return addTransition(trans); + addTransition(trans); + return trans; } /*! diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h index 7a47447..781382d 100644 --- a/src/corelib/statemachine/qstate.h +++ b/src/corelib/statemachine/qstate.h @@ -76,7 +76,7 @@ public: QAbstractState *errorState() const; void setErrorState(QAbstractState *state); - QAbstractTransition *addTransition(QAbstractTransition *transition); + void addTransition(QAbstractTransition *transition); QSignalTransition *addTransition(QObject *sender, const char *signal, QAbstractState *target); QAbstractTransition *addTransition(QAbstractState *target); void removeTransition(QAbstractTransition *transition); diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 31ab3af..fb6567a 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -286,8 +286,8 @@ void tst_QStateMachine::transitionToRootState() machine.addState(initialState); machine.setInitialState(initialState); - QAbstractTransition *trans = initialState->addTransition(new EventTransition(QEvent::User, &machine)); - QVERIFY(trans != 0); + QAbstractTransition *trans = new EventTransition(QEvent::User, &machine); + initialState->addTransition(trans); QCOMPARE(trans->sourceState(), initialState); QCOMPARE(trans->targetState(), static_cast(&machine)); @@ -310,7 +310,7 @@ void tst_QStateMachine::transitionFromRootState() QState *root = &machine; QState *s1 = new QState(root); EventTransition *trans = new EventTransition(QEvent::User, s1); - QCOMPARE(root->addTransition(trans), static_cast(trans)); + root->addTransition(trans); QCOMPARE(trans->sourceState(), root); QCOMPARE(trans->targetState(), static_cast(s1)); } @@ -1155,7 +1155,7 @@ void tst_QStateMachine::stateEntryAndExit() QCOMPARE(t->targetState(), (QAbstractState*)s2); QCOMPARE(t->targetStates().size(), 1); QCOMPARE(t->targetStates().at(0), (QAbstractState*)s2); - QCOMPARE(s1->addTransition(t), (QAbstractTransition*)t); + s1->addTransition(t); QCOMPARE(t->sourceState(), (QState*)s1); QCOMPARE(t->machine(), &machine); @@ -1173,7 +1173,7 @@ void tst_QStateMachine::stateEntryAndExit() s2->removeTransition(trans); QCOMPARE(trans->sourceState(), (QState*)0); QCOMPARE(trans->targetState(), (QAbstractState*)s3); - QCOMPARE(s2->addTransition(trans), trans); + s2->addTransition(trans); QCOMPARE(trans->sourceState(), (QState*)s2); } @@ -3117,7 +3117,9 @@ void tst_QStateMachine::twoAnimatedTransitions() QState *s2 = new QState(&machine); s2->assignProperty(object, "foo", 5.0); QPropertyAnimation *fooAnimation = new QPropertyAnimation(object, "foo", s2); - s1->addTransition(new EventTransition(QEvent::User, s2))->addAnimation(fooAnimation); + EventTransition *trans = new EventTransition(QEvent::User, s2); + s1->addTransition(trans); + trans->addAnimation(fooAnimation); QState *s3 = new QState(&machine); QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); @@ -3126,7 +3128,9 @@ void tst_QStateMachine::twoAnimatedTransitions() QState *s4 = new QState(&machine); s4->assignProperty(object, "foo", 2.0); QPropertyAnimation *fooAnimation2 = new QPropertyAnimation(object, "foo", s4); - s3->addTransition(new EventTransition(QEvent::User, s4))->addAnimation(fooAnimation2); + trans = new EventTransition(QEvent::User, s4); + s3->addTransition(trans); + trans->addAnimation(fooAnimation2); QState *s5 = new QState(&machine); QObject::connect(s5, SIGNAL(entered()), QApplication::instance(), SLOT(quit())); @@ -3161,7 +3165,9 @@ void tst_QStateMachine::playAnimationTwice() QState *s2 = new QState(&machine); s2->assignProperty(object, "foo", 5.0); QPropertyAnimation *fooAnimation = new QPropertyAnimation(object, "foo", s2); - s1->addTransition(new EventTransition(QEvent::User, s2))->addAnimation(fooAnimation); + EventTransition *trans = new EventTransition(QEvent::User, s2); + s1->addTransition(trans); + trans->addAnimation(fooAnimation); QState *s3 = new QState(&machine); QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); @@ -3169,7 +3175,9 @@ void tst_QStateMachine::playAnimationTwice() QState *s4 = new QState(&machine); s4->assignProperty(object, "foo", 2.0); - s3->addTransition(new EventTransition(QEvent::User, s4))->addAnimation(fooAnimation); + trans = new EventTransition(QEvent::User, s4); + s3->addTransition(trans); + trans->addAnimation(fooAnimation); QState *s5 = new QState(&machine); QObject::connect(s5, SIGNAL(entered()), QApplication::instance(), SLOT(quit())); @@ -3213,14 +3221,16 @@ void tst_QStateMachine::nestedTargetStateForAnimation() QState *s2Child2 = new QState(s2); s2Child2->assignProperty(object, "bar", 11.0); - QAbstractTransition *at = s2Child->addTransition(new EventTransition(QEvent::User, s2Child2)); + QAbstractTransition *at = new EventTransition(QEvent::User, s2Child2); + s2Child->addTransition(at); QPropertyAnimation *animation = new QPropertyAnimation(object, "bar", s2); animation->setDuration(2000); connect(animation, SIGNAL(finished()), &counter, SLOT(slot())); at->addAnimation(animation); - at = s1->addTransition(new EventTransition(QEvent::User, s2)); + at = new EventTransition(QEvent::User, s2); + s1->addTransition(at); animation = new QPropertyAnimation(object, "foo", s2); connect(animation, SIGNAL(finished()), &counter, SLOT(slot())); @@ -3299,7 +3309,8 @@ void tst_QStateMachine::animatedGlobalRestoreProperty() QState *s4 = new QState(&machine); QObject::connect(s4, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); - QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2)); + QAbstractTransition *at = new EventTransition(QEvent::User, s2); + s1->addTransition(at); QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", s2); connect(pa, SIGNAL(finished()), &counter, SLOT(slot())); at->addAnimation(pa); @@ -3341,7 +3352,9 @@ void tst_QStateMachine::specificTargetValueOfAnimation() QPropertyAnimation *anim = new QPropertyAnimation(object, "foo"); anim->setEndValue(10.0); - s1->addTransition(new EventTransition(QEvent::User, s2))->addAnimation(anim); + EventTransition *trans = new EventTransition(QEvent::User, s2); + s1->addTransition(trans); + trans->addAnimation(anim); QState *s3 = new QState(&machine); QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); @@ -3495,7 +3508,8 @@ void tst_QStateMachine::overrideDefaultAnimationWithSpecific() QState *s3 = new QState(&machine); QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); - QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2)); + QAbstractTransition *at = new EventTransition(QEvent::User, s2); + s1->addTransition(at); QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo"); connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot())); -- cgit v0.12 From 2596d721d64ad4d484176888cb166fbc43157ca9 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 3 Nov 2009 13:39:40 +0100 Subject: Change name of modifiersMask property to "modifierMask" "modifierMask" is more correct English. Reviewed-by: Kent Hansen --- src/gui/statemachine/qbasickeyeventtransition.cpp | 24 +++++++++++----------- src/gui/statemachine/qbasickeyeventtransition_p.h | 6 +++--- .../statemachine/qbasicmouseeventtransition.cpp | 16 +++++++-------- .../statemachine/qbasicmouseeventtransition_p.h | 4 ++-- src/gui/statemachine/qkeyeventtransition.cpp | 18 ++++++++-------- src/gui/statemachine/qkeyeventtransition.h | 6 +++--- src/gui/statemachine/qmouseeventtransition.cpp | 18 ++++++++-------- src/gui/statemachine/qmouseeventtransition.h | 6 +++--- 8 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/gui/statemachine/qbasickeyeventtransition.cpp b/src/gui/statemachine/qbasickeyeventtransition.cpp index 445a253..bf10e3d 100644 --- a/src/gui/statemachine/qbasickeyeventtransition.cpp +++ b/src/gui/statemachine/qbasickeyeventtransition.cpp @@ -68,14 +68,14 @@ public: QEvent::Type eventType; int key; - Qt::KeyboardModifiers modifiersMask; + Qt::KeyboardModifiers modifierMask; }; QBasicKeyEventTransitionPrivate::QBasicKeyEventTransitionPrivate() { eventType = QEvent::None; key = 0; - modifiersMask = Qt::NoModifier; + modifierMask = Qt::NoModifier; } QBasicKeyEventTransitionPrivate *QBasicKeyEventTransitionPrivate::get(QBasicKeyEventTransition *q) @@ -106,17 +106,17 @@ QBasicKeyEventTransition::QBasicKeyEventTransition(QEvent::Type type, int key, /*! Constructs a new event transition for events of the given \a type for the - given \a key, with the given \a modifiersMask and \a sourceState. + given \a key, with the given \a modifierMask and \a sourceState. */ QBasicKeyEventTransition::QBasicKeyEventTransition(QEvent::Type type, int key, - Qt::KeyboardModifiers modifiersMask, + Qt::KeyboardModifiers modifierMask, QState *sourceState) : QAbstractTransition(*new QBasicKeyEventTransitionPrivate, sourceState) { Q_D(QBasicKeyEventTransition); d->eventType = type; d->key = key; - d->modifiersMask = modifiersMask; + d->modifierMask = modifierMask; } /*! @@ -163,23 +163,23 @@ void QBasicKeyEventTransition::setKey(int key) } /*! - Returns the keyboard modifiers mask that this key event transition checks + Returns the keyboard modifier mask that this key event transition checks for. */ -Qt::KeyboardModifiers QBasicKeyEventTransition::modifiersMask() const +Qt::KeyboardModifiers QBasicKeyEventTransition::modifierMask() const { Q_D(const QBasicKeyEventTransition); - return d->modifiersMask; + return d->modifierMask; } /*! - Sets the keyboard modifiers mask that this key event transition will check + Sets the keyboard modifier mask that this key event transition will check for. */ -void QBasicKeyEventTransition::setModifiersMask(Qt::KeyboardModifiers modifiersMask) +void QBasicKeyEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask) { Q_D(QBasicKeyEventTransition); - d->modifiersMask = modifiersMask; + d->modifierMask = modifierMask; } /*! @@ -191,7 +191,7 @@ bool QBasicKeyEventTransition::eventTest(QEvent *event) if (event->type() == d->eventType) { QKeyEvent *ke = static_cast(event); return (ke->key() == d->key) - && ((ke->modifiers() & d->modifiersMask) == d->modifiersMask); + && ((ke->modifiers() & d->modifierMask) == d->modifierMask); } return false; } diff --git a/src/gui/statemachine/qbasickeyeventtransition_p.h b/src/gui/statemachine/qbasickeyeventtransition_p.h index 3c2ec7d..87d3dc7 100644 --- a/src/gui/statemachine/qbasickeyeventtransition_p.h +++ b/src/gui/statemachine/qbasickeyeventtransition_p.h @@ -69,7 +69,7 @@ public: QBasicKeyEventTransition(QState *sourceState = 0); QBasicKeyEventTransition(QEvent::Type type, int key, QState *sourceState = 0); QBasicKeyEventTransition(QEvent::Type type, int key, - Qt::KeyboardModifiers modifiersMask, + Qt::KeyboardModifiers modifierMask, QState *sourceState = 0); ~QBasicKeyEventTransition(); @@ -79,8 +79,8 @@ public: int key() const; void setKey(int key); - Qt::KeyboardModifiers modifiersMask() const; - void setModifiersMask(Qt::KeyboardModifiers modifiers); + Qt::KeyboardModifiers modifierMask() const; + void setModifierMask(Qt::KeyboardModifiers modifiers); protected: bool eventTest(QEvent *event); diff --git a/src/gui/statemachine/qbasicmouseeventtransition.cpp b/src/gui/statemachine/qbasicmouseeventtransition.cpp index 694c319..4a977ba 100644 --- a/src/gui/statemachine/qbasicmouseeventtransition.cpp +++ b/src/gui/statemachine/qbasicmouseeventtransition.cpp @@ -69,7 +69,7 @@ public: QEvent::Type eventType; Qt::MouseButton button; - Qt::KeyboardModifiers modifiersMask; + Qt::KeyboardModifiers modifierMask; QPainterPath path; }; @@ -149,23 +149,23 @@ void QBasicMouseEventTransition::setButton(Qt::MouseButton button) } /*! - Returns the keyboard modifiers mask that this mouse event transition checks + Returns the keyboard modifier mask that this mouse event transition checks for. */ -Qt::KeyboardModifiers QBasicMouseEventTransition::modifiersMask() const +Qt::KeyboardModifiers QBasicMouseEventTransition::modifierMask() const { Q_D(const QBasicMouseEventTransition); - return d->modifiersMask; + return d->modifierMask; } /*! - Sets the keyboard modifiers mask that this mouse event transition will check + Sets the keyboard modifier mask that this mouse event transition will check for. */ -void QBasicMouseEventTransition::setModifiersMask(Qt::KeyboardModifiers modifiersMask) +void QBasicMouseEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask) { Q_D(QBasicMouseEventTransition); - d->modifiersMask = modifiersMask; + d->modifierMask = modifierMask; } /*! @@ -195,7 +195,7 @@ bool QBasicMouseEventTransition::eventTest(QEvent *event) if (event->type() == d->eventType) { QMouseEvent *me = static_cast(event); return (me->button() == d->button) - && ((me->modifiers() & d->modifiersMask) == d->modifiersMask) + && ((me->modifiers() & d->modifierMask) == d->modifierMask) && (d->path.isEmpty() || d->path.contains(me->pos())); } return false; diff --git a/src/gui/statemachine/qbasicmouseeventtransition_p.h b/src/gui/statemachine/qbasicmouseeventtransition_p.h index 512e0f8..8684fa3 100644 --- a/src/gui/statemachine/qbasicmouseeventtransition_p.h +++ b/src/gui/statemachine/qbasicmouseeventtransition_p.h @@ -79,8 +79,8 @@ public: Qt::MouseButton button() const; void setButton(Qt::MouseButton button); - Qt::KeyboardModifiers modifiersMask() const; - void setModifiersMask(Qt::KeyboardModifiers modifiers); + Qt::KeyboardModifiers modifierMask() const; + void setModifierMask(Qt::KeyboardModifiers modifiers); QPainterPath path() const; void setPath(const QPainterPath &path); diff --git a/src/gui/statemachine/qkeyeventtransition.cpp b/src/gui/statemachine/qkeyeventtransition.cpp index dee3168..a15e671 100644 --- a/src/gui/statemachine/qkeyeventtransition.cpp +++ b/src/gui/statemachine/qkeyeventtransition.cpp @@ -69,9 +69,9 @@ QT_BEGIN_NAMESPACE */ /*! - \property QKeyEventTransition::modifiersMask + \property QKeyEventTransition::modifierMask - \brief the keyboard modifiers mask that this key event transition checks for + \brief the keyboard modifier mask that this key event transition checks for */ class QKeyEventTransitionPrivate : public QEventTransitionPrivate @@ -133,23 +133,23 @@ void QKeyEventTransition::setKey(int key) } /*! - Returns the keyboard modifiers mask that this key event transition checks + Returns the keyboard modifier mask that this key event transition checks for. */ -Qt::KeyboardModifiers QKeyEventTransition::modifiersMask() const +Qt::KeyboardModifiers QKeyEventTransition::modifierMask() const { Q_D(const QKeyEventTransition); - return d->transition->modifiersMask(); + return d->transition->modifierMask(); } /*! - Sets the keyboard \a modifiers mask that this key event transition will - check for. + Sets the keyboard modifier mask that this key event transition will + check for to \a modifierMask. */ -void QKeyEventTransition::setModifiersMask(Qt::KeyboardModifiers modifiersMask) +void QKeyEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask) { Q_D(QKeyEventTransition); - d->transition->setModifiersMask(modifiersMask); + d->transition->setModifierMask(modifierMask); } /*! diff --git a/src/gui/statemachine/qkeyeventtransition.h b/src/gui/statemachine/qkeyeventtransition.h index 8df8138..ab1c155 100644 --- a/src/gui/statemachine/qkeyeventtransition.h +++ b/src/gui/statemachine/qkeyeventtransition.h @@ -57,7 +57,7 @@ class Q_GUI_EXPORT QKeyEventTransition : public QEventTransition { Q_OBJECT Q_PROPERTY(int key READ key WRITE setKey) - Q_PROPERTY(Qt::KeyboardModifiers modifiersMask READ modifiersMask WRITE setModifiersMask) + Q_PROPERTY(Qt::KeyboardModifiers modifierMask READ modifierMask WRITE setModifierMask) public: QKeyEventTransition(QState *sourceState = 0); QKeyEventTransition(QObject *object, QEvent::Type type, int key, @@ -67,8 +67,8 @@ public: int key() const; void setKey(int key); - Qt::KeyboardModifiers modifiersMask() const; - void setModifiersMask(Qt::KeyboardModifiers modifiers); + Qt::KeyboardModifiers modifierMask() const; + void setModifierMask(Qt::KeyboardModifiers modifiers); protected: void onTransition(QEvent *event); diff --git a/src/gui/statemachine/qmouseeventtransition.cpp b/src/gui/statemachine/qmouseeventtransition.cpp index 86cacf7..dbf9e19 100644 --- a/src/gui/statemachine/qmouseeventtransition.cpp +++ b/src/gui/statemachine/qmouseeventtransition.cpp @@ -70,9 +70,9 @@ QT_BEGIN_NAMESPACE */ /*! - \property QMouseEventTransition::modifiersMask + \property QMouseEventTransition::modifierMask - \brief the keyboard modifiers mask that this mouse event transition checks for + \brief the keyboard modifier mask that this mouse event transition checks for */ class QMouseEventTransitionPrivate : public QEventTransitionPrivate @@ -139,23 +139,23 @@ void QMouseEventTransition::setButton(Qt::MouseButton button) } /*! - Returns the keyboard modifiers mask that this mouse event transition checks + Returns the keyboard modifier mask that this mouse event transition checks for. */ -Qt::KeyboardModifiers QMouseEventTransition::modifiersMask() const +Qt::KeyboardModifiers QMouseEventTransition::modifierMask() const { Q_D(const QMouseEventTransition); - return d->transition->modifiersMask(); + return d->transition->modifierMask(); } /*! - Sets the keyboard \a modifiers mask that this mouse event transition will - check for. + Sets the keyboard modifier mask that this mouse event transition will + check for to \a modifierMask. */ -void QMouseEventTransition::setModifiersMask(Qt::KeyboardModifiers modifiersMask) +void QMouseEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask) { Q_D(QMouseEventTransition); - d->transition->setModifiersMask(modifiersMask); + d->transition->setModifierMask(modifierMask); } /*! diff --git a/src/gui/statemachine/qmouseeventtransition.h b/src/gui/statemachine/qmouseeventtransition.h index 4e324ec..a6687b6 100644 --- a/src/gui/statemachine/qmouseeventtransition.h +++ b/src/gui/statemachine/qmouseeventtransition.h @@ -58,7 +58,7 @@ class Q_GUI_EXPORT QMouseEventTransition : public QEventTransition { Q_OBJECT Q_PROPERTY(Qt::MouseButton button READ button WRITE setButton) - Q_PROPERTY(Qt::KeyboardModifiers modifiersMask READ modifiersMask WRITE setModifiersMask) + Q_PROPERTY(Qt::KeyboardModifiers modifierMask READ modifierMask WRITE setModifierMask) public: QMouseEventTransition(QState *sourceState = 0); QMouseEventTransition(QObject *object, QEvent::Type type, @@ -68,8 +68,8 @@ public: Qt::MouseButton button() const; void setButton(Qt::MouseButton button); - Qt::KeyboardModifiers modifiersMask() const; - void setModifiersMask(Qt::KeyboardModifiers modifiers); + Qt::KeyboardModifiers modifierMask() const; + void setModifierMask(Qt::KeyboardModifiers modifiers); QPainterPath path() const; void setPath(const QPainterPath &path); -- cgit v0.12 From 19421cc33af4f439f4c7aea2de9f449987fbc420 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 3 Nov 2009 13:53:19 +0100 Subject: Change name of QMouseEventTransition::path() to hitTestPath(). Make it clearer what the property actually does. Reviewed-by: Kent Hansen --- src/gui/statemachine/qbasicmouseeventtransition.cpp | 8 ++++---- src/gui/statemachine/qbasicmouseeventtransition_p.h | 4 ++-- src/gui/statemachine/qmouseeventtransition.cpp | 12 ++++++------ src/gui/statemachine/qmouseeventtransition.h | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/gui/statemachine/qbasicmouseeventtransition.cpp b/src/gui/statemachine/qbasicmouseeventtransition.cpp index 4a977ba..fe0dea9 100644 --- a/src/gui/statemachine/qbasicmouseeventtransition.cpp +++ b/src/gui/statemachine/qbasicmouseeventtransition.cpp @@ -169,18 +169,18 @@ void QBasicMouseEventTransition::setModifierMask(Qt::KeyboardModifiers modifierM } /*! - Returns the path for this mouse event transition. + Returns the hit test path for this mouse event transition. */ -QPainterPath QBasicMouseEventTransition::path() const +QPainterPath QBasicMouseEventTransition::hitTestPath() const { Q_D(const QBasicMouseEventTransition); return d->path; } /*! - Sets the path for this mouse event transition. + Sets the hit test path for this mouse event transition. */ -void QBasicMouseEventTransition::setPath(const QPainterPath &path) +void QBasicMouseEventTransition::setHitTestPath(const QPainterPath &path) { Q_D(QBasicMouseEventTransition); d->path = path; diff --git a/src/gui/statemachine/qbasicmouseeventtransition_p.h b/src/gui/statemachine/qbasicmouseeventtransition_p.h index 8684fa3..6754c55 100644 --- a/src/gui/statemachine/qbasicmouseeventtransition_p.h +++ b/src/gui/statemachine/qbasicmouseeventtransition_p.h @@ -82,8 +82,8 @@ public: Qt::KeyboardModifiers modifierMask() const; void setModifierMask(Qt::KeyboardModifiers modifiers); - QPainterPath path() const; - void setPath(const QPainterPath &path); + QPainterPath hitTestPath() const; + void setHitTestPath(const QPainterPath &path); protected: bool eventTest(QEvent *event); diff --git a/src/gui/statemachine/qmouseeventtransition.cpp b/src/gui/statemachine/qmouseeventtransition.cpp index dbf9e19..f5c0cb1 100644 --- a/src/gui/statemachine/qmouseeventtransition.cpp +++ b/src/gui/statemachine/qmouseeventtransition.cpp @@ -159,25 +159,25 @@ void QMouseEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask) } /*! - Returns the path for this mouse event transition. + Returns the hit test path for this mouse event transition. */ -QPainterPath QMouseEventTransition::path() const +QPainterPath QMouseEventTransition::hitTestPath() const { Q_D(const QMouseEventTransition); - return d->transition->path(); + return d->transition->hitTestPath(); } /*! - Sets the \a path for this mouse event transition. + Sets the hit test path for this mouse event transition to \a path. If a valid path has been set, the transition will only trigger if the mouse event position (QMouseEvent::pos()) is inside the path. \sa QPainterPath::contains() */ -void QMouseEventTransition::setPath(const QPainterPath &path) +void QMouseEventTransition::setHitTestPath(const QPainterPath &path) { Q_D(QMouseEventTransition); - d->transition->setPath(path); + d->transition->setHitTestPath(path); } /*! diff --git a/src/gui/statemachine/qmouseeventtransition.h b/src/gui/statemachine/qmouseeventtransition.h index a6687b6..e7f6a45 100644 --- a/src/gui/statemachine/qmouseeventtransition.h +++ b/src/gui/statemachine/qmouseeventtransition.h @@ -71,8 +71,8 @@ public: Qt::KeyboardModifiers modifierMask() const; void setModifierMask(Qt::KeyboardModifiers modifiers); - QPainterPath path() const; - void setPath(const QPainterPath &path); + QPainterPath hitTestPath() const; + void setHitTestPath(const QPainterPath &path); protected: void onTransition(QEvent *event); -- cgit v0.12 From ddd1c40712a6a50b0574341087118fe4db67c3b2 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 3 Nov 2009 14:19:41 +0100 Subject: Rename QState::polished() signal to "propertiesAssigned" "Polished" was never a very descriptive word, and it already has a meaning attached in the QStyle API. Additionally, "propertiesAssigned" has the benefit of giving the relation to the assignProperty() function as part of the name. Reviewed-by: Kent Hansen --- doc/src/examples/stickman.qdoc | 9 +++--- doc/src/frameworks-technologies/statemachine.qdoc | 10 +++---- doc/src/snippets/statemachine/main5.cpp | 2 +- examples/animation/stickman/lifecycle.cpp | 4 +-- src/corelib/statemachine/qstate.cpp | 16 +++++++---- src/corelib/statemachine/qstate.h | 2 +- src/corelib/statemachine/qstate_p.h | 2 +- src/corelib/statemachine/qstatemachine.cpp | 8 +++--- tests/auto/qstatemachine/tst_qstatemachine.cpp | 34 +++++++++++------------ 9 files changed, 47 insertions(+), 40 deletions(-) diff --git a/doc/src/examples/stickman.qdoc b/doc/src/examples/stickman.qdoc index e70c39b..c9e98d0 100644 --- a/doc/src/examples/stickman.qdoc +++ b/doc/src/examples/stickman.qdoc @@ -55,9 +55,9 @@ Animations are implemented as composite states. Each child state of the animation state represents a frame in the animation by setting the position of each joint in the stickman's skeleton to the positions defined for the particular frame. The frames are then bound together - with animated transitions that trigger on the source state's polished() signal. Thus, the - machine will enter the state representing the next frame in the animation immediately after it - has finished animating into the previous frame. + with animated transitions that trigger on the source state's propertiesAssigned() signal. Thus, + the machine will enter the state representing the next frame in the animation immediately after + it has finished animating into the previous frame. \image stickman-example1.png @@ -67,7 +67,8 @@ \snippet examples/animation/stickman/lifecycle.cpp 1 - The states are then bound together with signal transitions that listen to the polished() signal. + The states are then bound together with signal transitions that listen to the + propertiesAssigned() signal. \snippet examples/animation/stickman/lifecycle.cpp 2 diff --git a/doc/src/frameworks-technologies/statemachine.qdoc b/doc/src/frameworks-technologies/statemachine.qdoc index ac10314..708561d 100644 --- a/doc/src/frameworks-technologies/statemachine.qdoc +++ b/doc/src/frameworks-technologies/statemachine.qdoc @@ -501,9 +501,9 @@ message box will pop up before the geometry of the button has actually been set. To ensure that the message box does not pop up until the geometry actually reaches its final - value, we can use the state's polished() signal. The polished() signal will be emitted when the - the property is assigned its final value, whether this is done immediately or after the animation - has finished playing. + value, we can use the state's propertiesAssigned() signal. The propertiesAssigned() signal will be + emitted when the property is assigned its final value, whether this is done immediately or + after the animation has finished playing. \code \snippet doc/src/snippets/statemachine/main5.cpp 6 \endcode @@ -519,14 +519,14 @@ has been assigned the defined value. If the global restore policy is set to QStateMachine::RestoreProperties, the state will not emit - the polished() signal until these have been executed as well. + the propertiesAssigned() signal until these have been executed as well. \section1 What Happens If A State Is Exited Before The Animation Has Finished If a state has property assignments, and the transition into the state has animations for the properties, the state can potentially be exited before the properties have been assigned to the values defines by the state. This is true in particular when there are transitions out from the - state that do not depend on the state being polished, as described in the previous section. + state that do not depend on the propertiesAssigned signal, as described in the previous section. The State Machine API guarantees that a property assigned by the state machine either: \list diff --git a/doc/src/snippets/statemachine/main5.cpp b/doc/src/snippets/statemachine/main5.cpp index 346cbce..ff25b7b 100644 --- a/doc/src/snippets/statemachine/main5.cpp +++ b/doc/src/snippets/statemachine/main5.cpp @@ -145,7 +145,7 @@ int main(int argv, char **args) connect(s3, SIGNAL(entered()), messageBox, SLOT(exec())); s1->addTransition(button, SIGNAL(clicked()), s2); - s2->addTransition(s2, SIGNAL(polished()), s3); + s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3); //![6] } diff --git a/examples/animation/stickman/lifecycle.cpp b/examples/animation/stickman/lifecycle.cpp index 250fb85..1b6f9cd 100644 --- a/examples/animation/stickman/lifecycle.cpp +++ b/examples/animation/stickman/lifecycle.cpp @@ -194,14 +194,14 @@ QState *LifeCycle::makeState(QState *parentState, const QString &animationFileNa topLevel->setInitialState(frameState); else //! [2] - previousState->addTransition(previousState, SIGNAL(polished()), frameState); + previousState->addTransition(previousState, SIGNAL(propertiesAssigned()), frameState); //! [2] previousState = frameState; } // Loop - previousState->addTransition(previousState, SIGNAL(polished()), topLevel->initialState()); + previousState->addTransition(previousState, SIGNAL(propertiesAssigned()), topLevel->initialState()); return topLevel; diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp index ea20619..6d89248 100644 --- a/src/corelib/statemachine/qstate.cpp +++ b/src/corelib/statemachine/qstate.cpp @@ -139,10 +139,10 @@ void QStatePrivate::emitFinished() emit q->finished(); } -void QStatePrivate::emitPolished() +void QStatePrivate::emitPropertiesAssigned() { Q_Q(QState); - emit q->polished(); + emit q->propertiesAssigned(); } /*! @@ -228,7 +228,7 @@ QList QStatePrivate::transitions() const Instructs this state to set the property with the given \a name of the given \a object to the given \a value when the state is entered. - \sa polished() + \sa propertiesAssigned() */ void QState::assignProperty(QObject *object, const char *name, const QVariant &value) @@ -491,9 +491,15 @@ bool QState::event(QEvent *e) */ /*! - \fn QState::polished() + \fn QState::propertiesAssigned() - This signal is emitted when all properties have been assigned their final value. + This signal is emitted when all properties have been assigned their final value. If the state + assigns a value to one or more properties for which an animation exists (either set on the + transition or as a default animation on the state machine), then the signal will not be emitted + until all such animations have finished playing. + + If there are no relevant animations, or no property assignments defined for the state, then + the signal will be emitted immediately before the state is entered. \sa QState::assignProperty(), QAbstractTransition::addAnimation() */ diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h index 781382d..423f940 100644 --- a/src/corelib/statemachine/qstate.h +++ b/src/corelib/statemachine/qstate.h @@ -94,7 +94,7 @@ public: Q_SIGNALS: void finished(); - void polished(); + void propertiesAssigned(); protected: void onEntry(QEvent *event); diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h index 34c8838..7fe6279 100644 --- a/src/corelib/statemachine/qstate_p.h +++ b/src/corelib/statemachine/qstate_p.h @@ -94,7 +94,7 @@ public: QList transitions() const; void emitFinished(); - void emitPolished(); + void emitPropertiesAssigned(); QAbstractState *errorState; QAbstractState *initialState; diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 0d07093..0648d14 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -807,7 +807,7 @@ void QStateMachinePrivate::applyProperties(const QList &tr if (anim->state() == QAbstractAnimation::Running) { // The animation is still running. This can happen if the // animation is a group, and one of its children just finished, - // and that caused a state to emit its polished() signal, and + // and that caused a state to emit its propertiesAssigned() signal, and // that triggered a transition in the machine. // Just stop the animation so it is correctly restarted again. anim->stop(); @@ -829,7 +829,7 @@ void QStateMachinePrivate::applyProperties(const QList &tr } } - // Emit polished signal for entered states that have no animated properties. + // Emit propertiesAssigned signal for entered states that have no animated properties. for (int i = 0; i < enteredStates.size(); ++i) { QState *s = qobject_cast(enteredStates.at(i)); if (s @@ -837,7 +837,7 @@ void QStateMachinePrivate::applyProperties(const QList &tr && !animationsForState.contains(s) #endif ) - QStatePrivate::get(s)->emitPolished(); + QStatePrivate::get(s)->emitPropertiesAssigned(); } } @@ -1100,7 +1100,7 @@ void QStateMachinePrivate::_q_animationFinished() animations.removeOne(anim); if (animations.isEmpty()) { animationsForState.erase(it); - QStatePrivate::get(qobject_cast(state))->emitPolished(); + QStatePrivate::get(qobject_cast(state))->emitPropertiesAssigned(); } } diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index fb6567a..9a2b2ed 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -184,7 +184,7 @@ private slots: void twoAnimatedTransitions(); void playAnimationTwice(); void nestedTargetStateForAnimation(); - void polishedSignalTransitionsReuseAnimationGroup(); + void propertiesAssignedSignalTransitionsReuseAnimationGroup(); void animatedGlobalRestoreProperty(); void specificTargetValueOfAnimation(); @@ -1319,9 +1319,9 @@ void tst_QStateMachine::assignProperty() QCOMPARE(s1->objectName(), QString::fromLatin1("foo")); { - QSignalSpy polishedSpy(s1, SIGNAL(polished())); + QSignalSpy propertiesAssignedSpy(s1, SIGNAL(propertiesAssigned())); machine.start(); - QTRY_COMPARE(polishedSpy.count(), 1); + QTRY_COMPARE(propertiesAssignedSpy.count(), 1); } // nested states @@ -1371,7 +1371,7 @@ void tst_QStateMachine::assignPropertyWithAnimation() QCOMPARE(trans->animations().size(), 1); QCOMPARE(trans->animations().at(0), (QAbstractAnimation*)&anim); QFinalState *s3 = new QFinalState(&machine); - s2->addTransition(s2, SIGNAL(polished()), s3); + s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3); machine.setInitialState(s1); QSignalSpy finishedSpy(&machine, SIGNAL(finished())); @@ -1399,7 +1399,7 @@ void tst_QStateMachine::assignPropertyWithAnimation() anim2.setDuration(150); trans->addAnimation(&anim2); QFinalState *s3 = new QFinalState(&machine); - s2->addTransition(s2, SIGNAL(polished()), s3); + s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3); machine.setInitialState(s1); QSignalSpy finishedSpy(&machine, SIGNAL(finished())); @@ -1427,7 +1427,7 @@ void tst_QStateMachine::assignPropertyWithAnimation() group.addAnimation(new QPropertyAnimation(&obj, "bar")); trans->addAnimation(&group); QFinalState *s3 = new QFinalState(&machine); - s2->addTransition(s2, SIGNAL(polished()), s3); + s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3); machine.setInitialState(s1); QSignalSpy finishedSpy(&machine, SIGNAL(finished())); @@ -1473,10 +1473,10 @@ void tst_QStateMachine::assignPropertyWithAnimation() anim2.setDuration(250); trans->addAnimation(&anim2); - s21->addTransition(s21, SIGNAL(polished()), s22); + s21->addTransition(s21, SIGNAL(propertiesAssigned()), s22); QFinalState *s3 = new QFinalState(&machine); - s22->addTransition(s2, SIGNAL(polished()), s3); + s22->addTransition(s2, SIGNAL(propertiesAssigned()), s3); machine.setInitialState(s1); QSignalSpy finishedSpy(&machine, SIGNAL(finished())); @@ -1513,13 +1513,13 @@ void tst_QStateMachine::assignPropertyWithAnimation() machine.setInitialState(group); machine.start(); QTRY_COMPARE(machine.configuration().contains(s1), true); - QSignalSpy polishedSpy(s2, SIGNAL(polished())); + QSignalSpy propertiesAssignedSpy(s2, SIGNAL(propertiesAssigned())); emitter.emitSignalWithNoArg(); QTRY_COMPARE(machine.configuration().contains(s2), true); - QVERIFY(polishedSpy.isEmpty()); + QVERIFY(propertiesAssignedSpy.isEmpty()); emitter.emitSignalWithNoArg(); // will cause animations from s1-->s2 to abort QTRY_COMPARE(machine.configuration().contains(s3), true); - QVERIFY(polishedSpy.isEmpty()); + QVERIFY(propertiesAssignedSpy.isEmpty()); QCOMPARE(obj.property("foo").toInt(), 911); QCOMPARE(obj.property("bar").toInt(), 789); } @@ -3089,7 +3089,7 @@ void tst_QStateMachine::twoAnimations() QState *s3 = new QState(&machine); QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); - s2->addTransition(s2, SIGNAL(polished()), s3); + s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3); machine.setInitialState(s1); machine.start(); @@ -3241,7 +3241,7 @@ void tst_QStateMachine::nestedTargetStateForAnimation() at->addAnimation(animation); QState *s3 = new QState(&machine); - s2->addTransition(s2Child, SIGNAL(polished()), s3); + s2->addTransition(s2Child, SIGNAL(propertiesAssigned()), s3); QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); @@ -3258,7 +3258,7 @@ void tst_QStateMachine::nestedTargetStateForAnimation() QCOMPARE(counter.counter, 2); } -void tst_QStateMachine::polishedSignalTransitionsReuseAnimationGroup() +void tst_QStateMachine::propertiesAssignedSignalTransitionsReuseAnimationGroup() { QStateMachine machine; QObject *object = new QObject(&machine); @@ -3275,9 +3275,9 @@ void tst_QStateMachine::polishedSignalTransitionsReuseAnimationGroup() QParallelAnimationGroup animationGroup; animationGroup.addAnimation(new QPropertyAnimation(object, "foo")); QSignalSpy animationFinishedSpy(&animationGroup, SIGNAL(finished())); - s1->addTransition(s1, SIGNAL(polished()), s2)->addAnimation(&animationGroup); - s2->addTransition(s2, SIGNAL(polished()), s3)->addAnimation(&animationGroup); - s3->addTransition(s3, SIGNAL(polished()), s4); + s1->addTransition(s1, SIGNAL(propertiesAssigned()), s2)->addAnimation(&animationGroup); + s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3)->addAnimation(&animationGroup); + s3->addTransition(s3, SIGNAL(propertiesAssigned()), s4); machine.setInitialState(s1); QSignalSpy machineFinishedSpy(&machine, SIGNAL(finished())); -- cgit v0.12 From 66056ead409d4ba79b2b7dd08d12332ba47f5307 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Mon, 2 Nov 2009 17:42:17 +0100 Subject: Make the QDataStream autotest much more robust In the old version, we'd read all the types, then start comparing. If an operator left the stream in a bogus state, funny things would happen (e.g. crashes). Now, we test the value instantly before reading the next one, thus preventing reading bogus. --- tests/auto/qdatastream/tst_qdatastream.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/tests/auto/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp index add0945..bb59809 100644 --- a/tests/auto/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/qdatastream/tst_qdatastream.cpp @@ -3180,28 +3180,31 @@ void tst_QDataStream::streamRealDataTypes() QDataStream stream(&file); stream.setVersion(QDataStream::Qt_4_2); - stream >> a >> b >> c >> d >> e >> f >> point - >> rect >> polygon >> matrix >> p; - if (i == 1) - stream >> pict; - stream >> textLength >> col >> rGrad >> cGrad - >> pen; - - QCOMPARE(stream.status(), QDataStream::Ok); - + stream >> a; QCOMPARE(a, qreal(0)); + stream >> b; QCOMPARE(b, qreal(1.0)); + stream >> c; QCOMPARE(c, qreal(1.1)); + stream >> d; QCOMPARE(d, qreal(3.14)); + stream >> e; QCOMPARE(e, qreal(-3.14)); + stream >> f; QCOMPARE(f, qreal(-1)); + stream >> point; QCOMPARE(point, QPointF(3, 5)); + stream >> rect; QCOMPARE(rect, QRectF(-1, -2, 3, 4)); + stream >> polygon; QCOMPARE((QVector &)polygon, (QPolygonF() << QPointF(0, 0) << QPointF(1, 2))); + stream >> matrix; QCOMPARE(matrix, QMatrix().rotate(90).scale(2, 2)); + stream >> p; QCOMPARE(p, path); + if (i == 1) { + stream >> pict; - if (i == 0) { QByteArray pictA, pictB; QBuffer bufA, bufB; QVERIFY(bufA.open(QIODevice::ReadWrite)); @@ -3212,8 +3215,11 @@ void tst_QDataStream::streamRealDataTypes() QCOMPARE(pictA, pictB); } + stream >> textLength; QCOMPARE(textLength, QTextLength(QTextLength::VariableLength, 1.5)); + stream >> col; QCOMPARE(col, color); + stream >> rGrad; QCOMPARE(rGrad.style(), radialBrush.style()); QCOMPARE(rGrad.matrix(), radialBrush.matrix()); QCOMPARE(rGrad.gradient()->type(), radialBrush.gradient()->type()); @@ -3222,6 +3228,7 @@ void tst_QDataStream::streamRealDataTypes() QCOMPARE(((QRadialGradient *)rGrad.gradient())->center(), ((QRadialGradient *)radialBrush.gradient())->center()); QCOMPARE(((QRadialGradient *)rGrad.gradient())->focalPoint(), ((QRadialGradient *)radialBrush.gradient())->focalPoint()); QCOMPARE(((QRadialGradient *)rGrad.gradient())->radius(), ((QRadialGradient *)radialBrush.gradient())->radius()); + stream >> cGrad; QCOMPARE(cGrad.style(), conicalBrush.style()); QCOMPARE(cGrad.matrix(), conicalBrush.matrix()); QCOMPARE(cGrad.gradient()->type(), conicalBrush.gradient()->type()); @@ -3231,7 +3238,10 @@ void tst_QDataStream::streamRealDataTypes() QCOMPARE(((QConicalGradient *)cGrad.gradient())->angle(), ((QConicalGradient *)conicalBrush.gradient())->angle()); QCOMPARE(cGrad, conicalBrush); + stream >> pen; QCOMPARE(pen.widthF(), qreal(1.5)); + + QCOMPARE(stream.status(), QDataStream::Ok); } #if defined(Q_OS_SYMBIAN) #undef qreal -- cgit v0.12 From 18b072835e3f726a1d2d7604b0dc98cd420d3088 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Mon, 2 Nov 2009 17:57:54 +0100 Subject: fix test for real - if the reference stream contains doubles, we must read doubles, and not qreals --- tests/auto/qdatastream/tst_qdatastream.cpp | 63 +++++++++++++++--------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/tests/auto/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp index bb59809..56fc53a 100644 --- a/tests/auto/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/qdatastream/tst_qdatastream.cpp @@ -3100,22 +3100,6 @@ void tst_QDataStream::streamToAndFromQByteArray() void tst_QDataStream::streamRealDataTypes() { -#if defined(Q_OS_WINCE) - // Note: Probably actually same 'qreal being typedeffed as float instead of double' issue as in Symbian - // instead of what CE skip message says. - QSKIP("Skipped on CE as it demands too much memory and fragments", SkipAll); -#elif defined(Q_OS_SYMBIAN) - // qreal is typedeffed float in symbian instead of double like in most platforms, so reference stream - // gets corrupted. Basically this test is flawed, as one shouldn't use naked typedeffed types in - // streams that are meant to work cross-platform. - // As this test also tests other floating point using classes, we do not simply skip it, but work around - // the qreal issue by redefining qreal as double for the duration of this function. - // Note that streaming classes works because they do explicitly use double instead of qreal when - // writing/reading to/from stream. -# define qreal double - qWarning("Note: streamRealDataTypes test redefines qreal as double in symbian!!!"); -#endif - // Generate QPicture from SVG. QSvgRenderer renderer(svgFile); QVERIFY(renderer.isValid()); @@ -3163,7 +3147,6 @@ void tst_QDataStream::streamRealDataTypes() file.close(); } - qreal a, b, c, d, e, f; QPointF point; QRectF rect; QPolygonF polygon; @@ -3180,18 +3163,37 @@ void tst_QDataStream::streamRealDataTypes() QDataStream stream(&file); stream.setVersion(QDataStream::Qt_4_2); - stream >> a; - QCOMPARE(a, qreal(0)); - stream >> b; - QCOMPARE(b, qreal(1.0)); - stream >> c; - QCOMPARE(c, qreal(1.1)); - stream >> d; - QCOMPARE(d, qreal(3.14)); - stream >> e; - QCOMPARE(e, qreal(-3.14)); - stream >> f; - QCOMPARE(f, qreal(-1)); + if (i == 0) { + // the reference stream for 4.2 contains doubles, + // so we must read them out as doubles! + double a, b, c, d, e, f; + stream >> a; + QCOMPARE(a, 0.0); + stream >> b; + QCOMPARE(b, 1.0); + stream >> c; + QCOMPARE(c, 1.1); + stream >> d; + QCOMPARE(d, 3.14); + stream >> e; + QCOMPARE(e, -3.14); + stream >> f; + QCOMPARE(f, -1.0); + } else { + qreal a, b, c, d, e, f; + stream >> a; + QCOMPARE(a, qreal(0)); + stream >> b; + QCOMPARE(b, qreal(1.0)); + stream >> c; + QCOMPARE(c, qreal(1.1)); + stream >> d; + QCOMPARE(d, qreal(3.14)); + stream >> e; + QCOMPARE(e, qreal(-3.14)); + stream >> f; + QCOMPARE(f, qreal(-1)); + } stream >> point; QCOMPARE(point, QPointF(3, 5)); stream >> rect; @@ -3243,9 +3245,6 @@ void tst_QDataStream::streamRealDataTypes() QCOMPARE(stream.status(), QDataStream::Ok); } -#if defined(Q_OS_SYMBIAN) - #undef qreal -#endif } #ifdef QT3_SUPPORT -- cgit v0.12 From d436493da1e01ac460f42ea0f58be00d8c6fdaea Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 3 Nov 2009 13:44:13 +0000 Subject: Revert "Fixed a crash in the QApplication autotest." This reverts commit f3854db64bcaa0f26faf5ff1414d3b9ccfc00e35. It is replaced by 6a89291d. Reviewed-by: Janne Anttila --- src/gui/kernel/qsoftkeymanager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index 26f0a39..a914220 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -197,8 +197,7 @@ bool QSoftKeyManager::event(QEvent *e) } while (source); QSoftKeyManagerPrivate::softKeySource = source; - if (source) - QSoftKeyManagerPrivate::updateSoftKeys_sys(softKeys); + QSoftKeyManagerPrivate::updateSoftKeys_sys(softKeys); return true; } return false; -- cgit v0.12 From 1a03f7a1163b8aea69b54066f25f6b935352b6d8 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 3 Nov 2009 15:41:08 +0000 Subject: Fixed crash opening audio clip when video clip currently open Task-number: QTBUG-5302 Reviewed-by: trustme --- src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp index d1d2337..fe469cf 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -110,6 +110,9 @@ MMF::VideoPlayer::~VideoPlayer() TRACE_CONTEXT(VideoPlayer::~VideoPlayer, EVideoApi); TRACE_ENTRY_0(); + if (m_videoOutput) + m_videoOutput->setObserver(0); + TRACE_EXIT_0(); } -- cgit v0.12 From 4c1ac09381a259e96a1774a5c931c55e8393813f Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Tue, 3 Nov 2009 17:02:58 +0100 Subject: Update mkdist-webkit script: - Use newest qtwebkit tag - Keep BitmapInfo.h and BitmalInfo.cpp in src/3rdparty Reviewed-by: TrustMe --- util/webkit/mkdist-webkit | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/webkit/mkdist-webkit b/util/webkit/mkdist-webkit index f88f10e..ddf74bb 100755 --- a/util/webkit/mkdist-webkit +++ b/util/webkit/mkdist-webkit @@ -5,7 +5,7 @@ die() { exit 1 } -default_tag="qtwebkit-4.6-snapshot-22102009" +default_tag="qtwebkit-4.6-snapshot-20091003" if [ $# -eq 0 ]; then tag="$default_tag" @@ -155,7 +155,7 @@ excluded_directories="$excluded_directories WebKit/chromium" excluded_directories="$excluded_directories WebKit/English.lproj WebKit/WebKit.xcodeproj" excluded_directories="$excluded_directories WebCore/English.lproj" -exclude_with_exceptions_list="WebCore/platform/win/:WebCore/platform/win/SystemTimeWin.cpp" +exclude_with_exceptions_list="WebCore/platform/win/:WebCore/platform/win/SystemTimeWin.cpp\\|WebCore/platform/win/BitmapInfo.*" excluded_directories="$excluded_directories WebKit/mac/Carbon" excluded_directories="$excluded_directories WebKit/mac/ChangeLog" -- cgit v0.12 From 33eefe549f4570a79d2531bad82698f7109ab687 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Tue, 3 Nov 2009 17:12:30 +0100 Subject: Updated WebKit from /home/jturcott/dev/webkit/ to qtwebkit-4.6-snapshot-20091003 ( 8f810287200d21aded375664cc0a6ac0476dbdea ) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes in WebKit/qt since the last update: ++ b/WebKit/qt/ChangeLog 2009-10-29 Kenneth Rohde Christiansen Reviewed by Tor Arne Vestbø. Remove QWebView::guessUrlFromString() and replace its use with the new QUrl::fromUserInput() if using Qt 4.6 or newer. * Api/qwebview.cpp: * Api/qwebview.h: * QGVLauncher/main.cpp: (urlFromUserInput): (WebPage::applyProxy): (MainWindow::load): * QtLauncher/main.cpp: (urlFromUserInput): (MainWindow::MainWindow): (MainWindow::changeLocation): * tests/qwebview/tst_qwebview.cpp: 2009-10-28 Kenneth Rohde Christiansen Reviewed by Tor Arne Vestbø. Serialize directly to the stream, and not first to an QByteArray, that is later serialized. That is slower and also uses more bytes. * Api/qwebhistory.cpp: (operator<<): (operator>>): 2009-10-28 Shinichiro Hamaji Reviewed by Eric Seidel. [Qt] WebFrame::counterValueForElementById must not be exposed https://bugs.webkit.org/show_bug.cgi?id=30882 * Api/qwebframe.cpp: (qt_drt_counterValueForElementById): * Api/qwebframe.h: 2009-10-27 Shinichiro Hamaji Reviewed by Darin Adler. Provide a way to get counter values with layoutTestContoller https://bugs.webkit.org/show_bug.cgi?id=30555 * Api/qwebframe.cpp: (QWebFrame::counterValueForElementById): (QWebHitTestResult::frame): * Api/qwebframe.h: 2009-10-28 Antonio Gomes Pushing missing WebKit/qt/tests/qwebframe/resources/ dir from bug 29248. [Qt] [API] Make it possible to have 'invisible' loads https://bugs.webkit.org/show_bug.cgi?id=29248 * tests/qwebframe/resources/image2.png: Copied from WebKit/qt/tests/qwebelement/image.png. 2009-10-28 Kenneth Rohde Christiansen Reviewed by Tor Arne Vestbø. [Qt] QWebHistory::saveState() is inconsistent with the Qt API https://bugs.webkit.org/show_bug.cgi?id=30710 Make the versioning internal and enforce it in the WebCore part. Adjust the comments, as well as remove now dead code. * Api/qwebhistory.cpp: (operator<<): (operator>>): * Api/qwebhistory.h: 2009-10-28 Kenneth Rohde Christiansen Reviewed by Holger Freyther. [Qt] QWebHistory::saveState() is inconsistent with the Qt API https://bugs.webkit.org/show_bug.cgi?id=30710 Remove the QWebHistory::saveState() and ::restoreState() as they are inconsistent with the Qt API. Update unittests to reflect the change. * Api/qwebhistory.cpp: (operator<<): (operator>>): * Api/qwebhistory.h: * tests/qwebhistory/tst_qwebhistory.cpp: (saveHistory): (restoreHistory): (tst_QWebHistory::saveAndRestore_crash_1): (tst_QWebHistory::saveAndRestore_crash_2): (tst_QWebHistory::saveAndRestore_crash_3): (tst_QWebHistory::clear): 2009-10-27 Antonio Gomes Reviewed by Holger Freyther. Complementary fix to bug 30779. By mistake I used QWeakPointer's toStrongRef() method which docs explicitly say to not be used in this situation (when the tracked pointer is devired from QObject). Instead QWeakPointer's data() is recommended. * Api/qwebpage.cpp: (QWebPage::view): 2009-10-27 Holger Hans Peter Freyther Reviewed by Simon Fraser. Change HitTestResult methods to use (3d) transformation aware methods https://bugs.webkit.org/show_bug.cgi?id=27347 The HitTestResult::boundingBox method was removed. The RenderObject must be used directly. In contrast to the old HitTestResult::boundingBox method this code must use a (3d) transformation aware method to not run into an assert in SVGRenderBase::mapLocalToContainer. * Api/qwebframe.cpp: (QWebHitTestResultPrivate::QWebHitTestResultPrivate): 2009-10-27 Kenneth Rohde Christiansen Rubberstamped by Oliver Hunt. Change two methods to be internal for DRT use only. Part of [Qt] Review all new API in Qt 4.6 https://bugs.webkit.org/show_bug.cgi?id=29843#c11 * Api/qwebsecurityorigin.cpp: (qt_drt_whiteListAccessFromOrigin): (qt_drt_resetOriginAccessWhiteLists): (QWebSecurityOrigin::localSchemes): * Api/qwebsecurityorigin.h: 2009-10-27 Kenneth Rohde Christiansen Reviewed by Tor Arne Vestbø. Make sure that initiating a rotation while rotating won't make it end up at rotation positions that are not a multiply of 180 degrees. * QGVLauncher/main.cpp: (MainView::animatedFlip): 2009-10-27 Kenneth Rohde Christiansen Unreviewed Qt build fix. Update the tests as well to the new API change. * tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::clear): 2009-10-27 Kenneth Rohde Christiansen Rubberstamped by Tor Arne Vestbø. [Qt] QWebElement::removeChildren() should be QWebElement::removeAllChildren() https://bugs.webkit.org/show_bug.cgi?id=30630 * Api/qwebelement.cpp: (QWebElement::removeAllChildren): * Api/qwebelement.h: 2009-10-27 Antonio Gomes Reviewed by Antti Koivisto and Holger Freyther. Make QWebPagePrivate's (QWidget) view to be a QWeakPointer. https://bugs.webkit.org/show_bug.cgi?id=30779 The fact that it was been set from external objects of qwebpage and not being deleted internally can lead to dangling references. * Api/qgraphicswebview.cpp: (QGraphicsWebView::~QGraphicsWebView): * Api/qwebpage.cpp: (QWebPagePrivate::QWebPagePrivate): (QWebPagePrivate::createContextMenu): (QWebPagePrivate::handleSoftwareInputPanel): (QWebPagePrivate::keyPressEvent): (QWebPage::setView): (QWebPage::view): (QWebPage::javaScriptAlert): (QWebPage::javaScriptConfirm): (QWebPage::javaScriptPrompt): (QWebPage::shouldInterruptJavaScript): (QWebPage::createWindow): (QWebPage::extension): (QWebPage::chooseFile): (QWebPage::userAgentForUrl): * Api/qwebpage_p.h: * Api/qwebview.cpp: (QWebView::~QWebView): 2009-10-26 Kenneth Rohde Christiansen Unreviewed documentation fix from David Boddie (Qt Doc Team) Removes the check around the RenderHints property documentation that was clearly added to synchronize the source and header files when the #if !defined(Q_OS_SYMBIAN) guards was added to the property. The documentation has also been updated to ensure that Symbian users know that there is no actual RenderHints property on their platform. * Api/qwebview.cpp: 2009-10-26 Kenneth Rohde Christiansen Unreviewed documentation fix from David Boddie (Qt Doc Team) Ensure that qdoc will always see the RenderHints property. The property was only defined in the header file if the Q_OS_SYMBIAN symbol was not defined, resulting in the property not showing up in the Qt documentation just because one platform doesn't support it. A follow up commit will improve the documentation for the property and note that it is not supported on the Symbiam platform. * Api/qwebview.h: 2009-10-26 Benjamin Poulain Reviewed by Tor Arne Vestbø. [Qt] Reintroduce QWebElementCollection Revert the patch that has replaced QWebElementCollection with QList. Update the tests accordingly. Remove the constness of the return type of QWebElement operator[]. https://bugs.webkit.org/show_bug.cgi?id=30767 * Api/qwebelement.cpp: (QWebElement::findAll): (QWebElementCollectionPrivate::QWebElementCollectionPrivate): (QWebElementCollectionPrivate::create): (QWebElementCollection::QWebElementCollection): (QWebElementCollection::operator=): (QWebElementCollection::~QWebElementCollection): (QWebElementCollection::operator+): (QWebElementCollection::append): (QWebElementCollection::count): (QWebElementCollection::at): (QWebElementCollection::toList): * Api/qwebelement.h: (const_iterator::begin): (const_iterator::end): (const_iterator::operator[]): * Api/qwebframe.cpp: (QWebFrame::findAllElements): * Api/qwebframe.h: * QtLauncher/main.cpp: (MainWindow::selectElements): * tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::simpleCollection): (tst_QWebElement::iteration): (tst_QWebElement::emptyCollection): (tst_QWebElement::appendCollection): (tst_QWebElement::nullSelect): (tst_QWebElement::hasSetFocus): (tst_QWebElement::render): * tests/qwebpage/tst_qwebpage.cpp: (tst_QWebPage::inputMethods): 2009-10-24 Laszlo Gombos Reviewed by Holger Freyther. [Qt] [Symbian] Set the capability and memory required to run QtWebKit for Symbian https://bugs.webkit.org/show_bug.cgi?id=30476 Assign ReadUserData WriteUserData NetworkServices Symbian capabilities to all QtWebkit executables. * QGVLauncher/QGVLauncher.pro: * QtLauncher/QtLauncher.pro: * tests/benchmarks/loading/tst_loading.pro: * tests/benchmarks/painting/tst_painting.pro: * tests/qgraphicswebview/qgraphicswebview.pro: * tests/qwebelement/qwebelement.pro: * tests/qwebframe/qwebframe.pro: * tests/qwebhistory/qwebhistory.pro: * tests/qwebhistoryinterface/qwebhistoryinterface.pro: * tests/qwebpage/qwebpage.pro: * tests/qwebplugindatabase/qwebplugindatabase.pro: * tests/qwebview/qwebview.pro: 2009-10-22 Gavin Barraclough Reviewed by NOBODY (speculative build fix - qt is currently already broken!) Build fix following bug #30696. * Api/qwebelement.cpp: (setupScriptContext): * Api/qwebframe.cpp: (QWebFrame::evaluateJavaScript): 2009-10-22 Shu Chang Reviewed by Eric Seidel. [Qt] Enable track visited links in QWebPage https://bugs.webkit.org/show_bug.cgi?id=30574 Test: fast/history/clicked-link-is-visited.html * Api/qwebpage.cpp: (QWebPagePrivate::QWebPagePrivate): 2009-10-22 Girish Ramakrishnan Reviewed by Eric Seidel. [Qt] Add Print Shortcut to QtLauncher https://bugs.webkit.org/show_bug.cgi?id=30682 * QtLauncher/main.cpp: (MainWindow::setupUI): 2009-10-22 Antonio Gomes Rubberstamped by Tor Arne Vestbø. Code standarlization for QGVLauncher. 1) Made member initilization lists in constructors to be per line. 2) Made applyProxy method inline as all other methods in WebPage class. * QGVLauncher/main.cpp: (WebPage::WebPage): (WebPage::applyProxy): (MainView::MainView): (MainWindow::MainWindow): (MainWindow::init): 2009-10-22 Antonio Gomes Reviewed by Tor Arne Vestbø. Add a Y-Axis rotation to QGVLauncher. It uses the QStateMachine API from Qt 4.6. * QGVLauncher/main.cpp: (WebView::WebView): (WebView::setYRotation): (WebView::yRotation): (MainView::flip): (MainView::animatedYFlip): (SharedScene::SharedScene): (SharedScene::webView): (MainWindow::init): (MainWindow::animatedYFlip): (MainWindow::buildUI): 2009-10-20 Kenneth Rohde Christiansen Reviewed By Adam Barth. Add some actions to the menu for cursor debugging. GraphicsView based launcher only. * QGVLauncher/main.cpp: (MainView::setWaitCursor): (MainView::resetCursor): (MainView::flip): (MainWindow::setWaitCursor): (MainWindow::resetCursor): (MainWindow::buildUI): 2009-10-20 Kenneth Rohde Christiansen Rubberstamped by Adam Barth. Remove clipRenderToViewport as agreed upon in https://bugs.webkit.org/show_bug.cgi?id=29843 * Api/qwebframe.cpp: * Api/qwebframe.h: * Api/qwebframe_p.h: (QWebFramePrivate::QWebFramePrivate): 2009-10-20 Kenneth Rohde Christiansen Reviewed by Adam Barth. Update the tests to test the new render functionality, and take into consideration that render() clips to the frame itself as well as the viewport. QWebFrame::render() now always clips, so the old tests were bogus. Rendering pure contents (no scrollbars etc) without clipping can now be accomplished using QWebFrame::documentElement()->render(...) * Api/qwebframe.cpp: * Api/qwebframe.h: * Api/qwebframe_p.h: (QWebFramePrivate::QWebFramePrivate): * tests/qwebframe/tst_qwebframe.cpp: 2009-10-20 Kenneth Rohde Christiansen Rubberstamped by Adam Barth. As we do not support rendering a QWebFrame without it being clipped the the frame as well as the viewport, we now set the viewport size to the size of the contents. Rendering pure contents (no scrollbars etc) without clipping can be acomplished using QWebFrame::documentElement()->render(...) * tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::render): 2009-10-20 Kenneth Rohde Christiansen Reviewed by Tor Arne Vestbø. Add menu item to dump the plugin list to the console, which can be handy for debugging. * QtLauncher/main.cpp: (MainWindow::dumpPlugins): (MainWindow::setupUI): 2009-10-19 Kenneth Rohde Christiansen Reviewed by Tor Arne Vestbø. Introduce new render method on QWebFrame, which supports specifying which layers to render (scrollbars, contents, pan-icon). * Api/qwebframe.cpp: (QWebFramePrivate::renderPrivate): (QWebFrame::render): * Api/qwebframe.h: * Api/qwebframe_p.h: 2009-10-19 Antonio Gomes Reviewed by Ariya Hidayat. [Qt] Infinite loop (leading to crash) when setting cursor in QGraphicsWebView https://bugs.webkit.org/show_bug.cgi?id=30549 Patch reimplements QGraphicsItem's itemChange method, and make CursorChange event to be emitted after cursor has already been set. QWidget::setCursor send the event just after it sets the cursor, then patch makes both behaviors compatible. * Api/qgraphicswebview.cpp: (QGraphicsWebView::itemChange): * Api/qgraphicswebview.h: --- src/3rdparty/webkit/ChangeLog | 42 + src/3rdparty/webkit/JavaScriptCore/ChangeLog | 524 +++ .../webkit/JavaScriptCore/JavaScriptCore.gypi | 1 + .../webkit/JavaScriptCore/JavaScriptCore.pri | 2 + .../JavaScriptCore/assembler/ARMv7Assembler.h | 168 +- .../JavaScriptCore/assembler/MacroAssemblerARM.h | 9 +- .../JavaScriptCore/assembler/MacroAssemblerARMv7.h | 8 +- .../webkit/JavaScriptCore/bytecode/CodeBlock.cpp | 21 +- .../webkit/JavaScriptCore/bytecode/Opcode.h | 1 + .../bytecompiler/BytecodeGenerator.cpp | 13 + .../bytecompiler/BytecodeGenerator.h | 19 + .../JavaScriptCore/interpreter/Interpreter.cpp | 27 + .../JavaScriptCore/jit/ExecutableAllocator.h | 16 + src/3rdparty/webkit/JavaScriptCore/jit/JIT.cpp | 2 + src/3rdparty/webkit/JavaScriptCore/jit/JIT.h | 31 +- src/3rdparty/webkit/JavaScriptCore/jit/JITCall.cpp | 2 +- .../webkit/JavaScriptCore/jit/JITInlineMethods.h | 9 +- .../webkit/JavaScriptCore/jit/JITOpcodes.cpp | 7 +- .../JavaScriptCore/jit/JITPropertyAccess.cpp | 148 +- .../webkit/JavaScriptCore/jit/JITStubs.cpp | 78 +- src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.h | 6 +- .../webkit/JavaScriptCore/parser/Nodes.cpp | 9 + .../webkit/JavaScriptCore/runtime/Collector.cpp | 12 +- .../JavaScriptCore/runtime/DateConstructor.cpp | 4 +- .../webkit/JavaScriptCore/runtime/DateInstance.cpp | 84 +- .../webkit/JavaScriptCore/runtime/DateInstance.h | 23 +- .../JavaScriptCore/runtime/DateInstanceCache.h | 89 + .../JavaScriptCore/runtime/DatePrototype.cpp | 235 +- .../webkit/JavaScriptCore/runtime/DatePrototype.h | 2 +- .../webkit/JavaScriptCore/runtime/JSCell.h | 1 + .../webkit/JavaScriptCore/runtime/JSFunction.h | 8 +- .../webkit/JavaScriptCore/runtime/JSGlobalData.h | 4 +- .../webkit/JavaScriptCore/runtime/JSObject.h | 4 +- .../runtime/JSPropertyNameIterator.cpp | 7 +- .../runtime/JSPropertyNameIterator.h | 18 +- .../webkit/JavaScriptCore/runtime/Structure.cpp | 9 + .../webkit/JavaScriptCore/runtime/Structure.h | 11 +- .../webkit/JavaScriptCore/wtf/CurrentTime.cpp | 4 + .../webkit/JavaScriptCore/wtf/DateMath.cpp | 11 +- .../webkit/JavaScriptCore/wtf/FastMalloc.h | 14 +- .../webkit/JavaScriptCore/wtf/MessageQueue.h | 17 +- src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h | 13 +- .../webkit/JavaScriptCore/wtf/StdLibExtras.h | 2 + .../webkit/JavaScriptCore/wtf/Threading.cpp | 2 +- src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h | 4 + .../JavaScriptCore/wtf/ThreadingPthreads.cpp | 4 +- .../JavaScriptCore/yarr/RegexInterpreter.cpp | 8 +- .../webkit/JavaScriptCore/yarr/RegexJIT.cpp | 5 +- src/3rdparty/webkit/VERSION | 4 +- src/3rdparty/webkit/WebCore/ChangeLog | 4258 +++++++++++++++++++- src/3rdparty/webkit/WebCore/DerivedSources.cpp | 1 + .../ForwardingHeaders/wtf/DateInstanceCache.h | 4 + src/3rdparty/webkit/WebCore/LICENSE-APPLE | 33 +- src/3rdparty/webkit/WebCore/WebCore.gypi | 35 +- src/3rdparty/webkit/WebCore/WebCore.pro | 35 +- .../accessibility/AccessibilityAllInOne.cpp | 44 + .../accessibility/AccessibilityListBoxOption.h | 1 + .../WebCore/accessibility/AccessibilityObject.h | 14 + .../accessibility/AccessibilityRenderObject.cpp | 42 +- .../accessibility/AccessibilityRenderObject.h | 1 + .../accessibility/qt/AccessibilityObjectQt.cpp | 5 + .../WebCore/bindings/ScriptControllerBase.cpp | 4 + .../WebCore/bindings/js/JSAbstractWorkerCustom.cpp | 4 +- .../WebCore/bindings/js/JSBindingsAllInOne.cpp | 150 + .../webkit/WebCore/bindings/js/JSCallbackData.cpp | 9 +- .../webkit/WebCore/bindings/js/JSCallbackData.h | 3 + .../bindings/js/JSCustomXPathNSResolver.cpp | 2 +- .../bindings/js/JSDOMApplicationCacheCustom.cpp | 4 +- .../webkit/WebCore/bindings/js/JSDOMBinding.cpp | 356 +- .../webkit/WebCore/bindings/js/JSDOMBinding.h | 110 +- .../WebCore/bindings/js/JSDOMGlobalObject.cpp | 29 +- .../webkit/WebCore/bindings/js/JSDOMGlobalObject.h | 8 +- .../webkit/WebCore/bindings/js/JSDOMWindowBase.cpp | 32 +- .../webkit/WebCore/bindings/js/JSDOMWindowBase.h | 5 +- .../WebCore/bindings/js/JSDOMWindowCustom.cpp | 15 +- .../WebCore/bindings/js/JSDOMWindowShell.cpp | 8 +- .../webkit/WebCore/bindings/js/JSDOMWindowShell.h | 2 +- .../bindings/js/JSDesktopNotificationsCustom.cpp | 4 +- .../webkit/WebCore/bindings/js/JSEventListener.cpp | 20 +- .../webkit/WebCore/bindings/js/JSEventListener.h | 7 +- .../WebCore/bindings/js/JSEventSourceCustom.cpp | 4 +- .../webkit/WebCore/bindings/js/JSEventTarget.cpp | 4 +- .../webkit/WebCore/bindings/js/JSExceptionBase.cpp | 128 +- .../webkit/WebCore/bindings/js/JSExceptionBase.h | 86 +- .../WebCore/bindings/js/JSHTMLAllCollection.cpp | 35 - .../WebCore/bindings/js/JSHTMLAllCollection.h | 58 - .../bindings/js/JSHTMLAllCollectionCustom.cpp | 135 + .../WebCore/bindings/js/JSHTMLCollectionCustom.cpp | 2 +- .../WebCore/bindings/js/JSHTMLDocumentCustom.cpp | 5 +- .../bindings/js/JSHTMLFrameSetElementCustom.cpp | 4 +- .../bindings/js/JSInspectorBackendCustom.cpp | 7 +- .../WebCore/bindings/js/JSLazyEventListener.cpp | 6 +- .../WebCore/bindings/js/JSLazyEventListener.h | 6 +- .../WebCore/bindings/js/JSMessageChannelCustom.cpp | 14 +- .../WebCore/bindings/js/JSMessagePortCustom.cpp | 11 +- .../webkit/WebCore/bindings/js/JSNodeCustom.cpp | 10 +- .../WebCore/bindings/js/JSNodeFilterCondition.cpp | 2 +- .../bindings/js/JSQuarantinedObjectWrapper.cpp | 8 +- .../bindings/js/JSSVGElementInstanceCustom.cpp | 4 +- .../WebCore/bindings/js/JSSharedWorkerCustom.cpp | 7 +- .../WebCore/bindings/js/JSWebSocketCustom.cpp | 4 +- .../WebCore/bindings/js/JSWorkerContextCustom.cpp | 8 +- .../WebCore/bindings/js/JSXMLHttpRequestCustom.cpp | 11 +- .../bindings/js/JSXMLHttpRequestUploadCustom.cpp | 11 +- .../webkit/WebCore/bindings/js/ScheduledAction.cpp | 15 +- .../webkit/WebCore/bindings/js/ScheduledAction.h | 9 +- .../WebCore/bindings/js/ScriptCachedFrameData.cpp | 13 +- .../WebCore/bindings/js/ScriptController.cpp | 193 +- .../webkit/WebCore/bindings/js/ScriptController.h | 43 +- .../WebCore/bindings/js/ScriptControllerMac.mm | 2 +- .../WebCore/bindings/js/ScriptEventListener.cpp | 4 +- .../WebCore/bindings/js/ScriptFunctionCall.cpp | 6 +- .../WebCore/bindings/js/ScriptObjectQuarantine.cpp | 6 +- .../webkit/WebCore/bindings/js/ScriptSourceCode.h | 8 + .../webkit/WebCore/bindings/js/ScriptState.cpp | 5 +- .../webkit/WebCore/bindings/js/ScriptState.h | 1 + .../WebCore/bindings/js/WorkerScriptController.cpp | 3 +- .../WebCore/bindings/js/WorkerScriptController.h | 3 + .../WebCore/bindings/scripts/CodeGeneratorJS.pm | 40 +- .../WebCore/bindings/scripts/CodeGeneratorV8.pm | 67 +- src/3rdparty/webkit/WebCore/bridge/NP_jsobject.cpp | 9 +- .../webkit/WebCore/bridge/jni/jni_jsobject.mm | 5 +- src/3rdparty/webkit/WebCore/bridge/npapi.h | 25 +- .../webkit/WebCore/bridge/qt/qt_runtime.cpp | 6 +- .../WebCore/css/CSSComputedStyleDeclaration.cpp | 49 +- .../WebCore/css/CSSComputedStyleDeclaration.h | 3 + src/3rdparty/webkit/WebCore/css/CSSParser.cpp | 48 +- src/3rdparty/webkit/WebCore/css/CSSParser.h | 2 +- src/3rdparty/webkit/WebCore/css/CSSParserValues.h | 2 +- .../webkit/WebCore/css/CSSPrimitiveValueMappings.h | 5 +- src/3rdparty/webkit/WebCore/css/CSSProperty.h | 2 +- .../webkit/WebCore/css/CSSPropertyNames.in | 4 + .../webkit/WebCore/css/CSSStyleSelector.cpp | 1 + .../WebCore/css/SVGCSSComputedStyleDeclaration.cpp | 2 + src/3rdparty/webkit/WebCore/css/SVGCSSParser.cpp | 5 + .../webkit/WebCore/css/SVGCSSPropertyNames.in | 2 + .../webkit/WebCore/css/SVGCSSStyleSelector.cpp | 30 + src/3rdparty/webkit/WebCore/dom/Document.cpp | 19 +- src/3rdparty/webkit/WebCore/dom/Document.h | 17 +- src/3rdparty/webkit/WebCore/dom/Element.cpp | 2 +- src/3rdparty/webkit/WebCore/dom/EventTarget.cpp | 35 +- src/3rdparty/webkit/WebCore/dom/EventTarget.h | 20 +- .../webkit/WebCore/dom/HTMLAllCollection.idl | 40 - .../webkit/WebCore/dom/ScriptExecutionContext.cpp | 20 + .../webkit/WebCore/dom/ScriptExecutionContext.h | 4 + src/3rdparty/webkit/WebCore/dom/SelectElement.cpp | 22 +- src/3rdparty/webkit/WebCore/dom/XMLTokenizer.cpp | 49 +- src/3rdparty/webkit/WebCore/dom/XMLTokenizer.h | 7 +- .../webkit/WebCore/dom/XMLTokenizerLibxml2.cpp | 26 +- src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp | 25 +- .../webkit/WebCore/editing/ApplyStyleCommand.cpp | 36 +- .../WebCore/editing/CompositeEditCommand.cpp | 177 +- .../webkit/WebCore/editing/CompositeEditCommand.h | 3 + .../webkit/WebCore/editing/EditorCommand.cpp | 4 +- .../WebCore/editing/IndentOutdentCommand.cpp | 63 +- .../webkit/WebCore/editing/IndentOutdentCommand.h | 1 - .../WebCore/editing/ReplaceNodeWithSpanCommand.cpp | 4 +- .../webkit/WebCore/editing/SelectionController.cpp | 2 + .../webkit/WebCore/generated/CSSPropertyNames.cpp | 428 +- .../webkit/WebCore/generated/CSSPropertyNames.h | 256 +- .../webkit/WebCore/generated/JSAbstractWorker.cpp | 4 +- .../webkit/WebCore/generated/JSBarInfo.cpp | 2 +- .../webkit/WebCore/generated/JSCSSRule.cpp | 2 +- .../webkit/WebCore/generated/JSCSSRuleList.cpp | 2 +- .../WebCore/generated/JSCSSStyleDeclaration.cpp | 2 +- .../webkit/WebCore/generated/JSCSSValue.cpp | 2 +- .../generated/JSCSSVariablesDeclaration.cpp | 2 +- .../webkit/WebCore/generated/JSCanvasArray.cpp | 2 +- .../WebCore/generated/JSCanvasArrayBuffer.cpp | 2 +- .../webkit/WebCore/generated/JSCanvasGradient.cpp | 2 +- .../webkit/WebCore/generated/JSCanvasPattern.cpp | 2 +- .../WebCore/generated/JSCanvasRenderingContext.cpp | 2 +- .../webkit/WebCore/generated/JSClientRect.cpp | 2 +- .../webkit/WebCore/generated/JSClientRectList.cpp | 2 +- .../webkit/WebCore/generated/JSClipboard.cpp | 2 +- .../webkit/WebCore/generated/JSConsole.cpp | 2 +- .../webkit/WebCore/generated/JSCoordinates.cpp | 2 +- .../webkit/WebCore/generated/JSCounter.cpp | 2 +- .../WebCore/generated/JSDOMApplicationCache.cpp | 18 +- .../WebCore/generated/JSDOMCoreException.cpp | 2 +- .../WebCore/generated/JSDOMImplementation.cpp | 2 +- .../webkit/WebCore/generated/JSDOMParser.cpp | 2 +- .../webkit/WebCore/generated/JSDOMSelection.cpp | 2 +- .../webkit/WebCore/generated/JSDOMWindow.cpp | 21 +- .../webkit/WebCore/generated/JSDOMWindow.h | 2 + .../webkit/WebCore/generated/JSDataGridColumn.cpp | 2 +- .../WebCore/generated/JSDataGridColumnList.cpp | 2 +- .../webkit/WebCore/generated/JSDatabase.cpp | 2 +- .../webkit/WebCore/generated/JSDocument.cpp | 80 +- .../webkit/WebCore/generated/JSElement.cpp | 78 +- src/3rdparty/webkit/WebCore/generated/JSEvent.cpp | 2 +- .../webkit/WebCore/generated/JSEventException.cpp | 2 +- .../webkit/WebCore/generated/JSEventSource.cpp | 8 +- src/3rdparty/webkit/WebCore/generated/JSFile.cpp | 2 +- .../webkit/WebCore/generated/JSFileList.cpp | 2 +- .../webkit/WebCore/generated/JSGeolocation.cpp | 2 +- .../webkit/WebCore/generated/JSGeoposition.cpp | 2 +- .../WebCore/generated/JSHTMLAllCollection.cpp | 292 ++ .../webkit/WebCore/generated/JSHTMLAllCollection.h | 104 + .../webkit/WebCore/generated/JSHTMLBodyElement.cpp | 16 +- .../webkit/WebCore/generated/JSHTMLCollection.cpp | 24 +- .../webkit/WebCore/generated/JSHTMLCollection.h | 1 - .../WebCore/generated/JSHTMLFrameSetElement.cpp | 16 +- .../webkit/WebCore/generated/JSHistory.cpp | 2 +- .../webkit/WebCore/generated/JSImageData.cpp | 2 +- .../WebCore/generated/JSInspectorBackend.cpp | 2 +- .../WebCore/generated/JSJavaScriptCallFrame.cpp | 2 +- .../webkit/WebCore/generated/JSLocation.cpp | 2 +- src/3rdparty/webkit/WebCore/generated/JSMedia.cpp | 2 +- .../webkit/WebCore/generated/JSMediaError.cpp | 2 +- .../webkit/WebCore/generated/JSMediaList.cpp | 2 +- .../webkit/WebCore/generated/JSMessageChannel.cpp | 2 +- .../webkit/WebCore/generated/JSMessagePort.cpp | 4 +- .../webkit/WebCore/generated/JSMimeType.cpp | 2 +- .../webkit/WebCore/generated/JSMimeTypeArray.cpp | 2 +- .../webkit/WebCore/generated/JSNamedNodeMap.cpp | 2 +- .../webkit/WebCore/generated/JSNavigator.cpp | 2 +- src/3rdparty/webkit/WebCore/generated/JSNode.cpp | 2 +- .../webkit/WebCore/generated/JSNodeFilter.cpp | 2 +- .../webkit/WebCore/generated/JSNodeIterator.cpp | 2 +- .../webkit/WebCore/generated/JSNodeList.cpp | 2 +- src/3rdparty/webkit/WebCore/generated/JSPlugin.cpp | 2 +- .../webkit/WebCore/generated/JSPluginArray.cpp | 2 +- .../webkit/WebCore/generated/JSPositionError.cpp | 2 +- .../webkit/WebCore/generated/JSRGBColor.cpp | 2 +- src/3rdparty/webkit/WebCore/generated/JSRange.cpp | 2 +- .../webkit/WebCore/generated/JSRangeException.cpp | 2 +- src/3rdparty/webkit/WebCore/generated/JSRect.cpp | 2 +- .../webkit/WebCore/generated/JSSQLError.cpp | 2 +- .../webkit/WebCore/generated/JSSQLResultSet.cpp | 2 +- .../WebCore/generated/JSSQLResultSetRowList.cpp | 2 +- .../webkit/WebCore/generated/JSSQLTransaction.cpp | 2 +- .../webkit/WebCore/generated/JSSVGAngle.cpp | 2 +- .../WebCore/generated/JSSVGAnimatedAngle.cpp | 2 +- .../WebCore/generated/JSSVGAnimatedBoolean.cpp | 2 +- .../WebCore/generated/JSSVGAnimatedEnumeration.cpp | 2 +- .../WebCore/generated/JSSVGAnimatedInteger.cpp | 2 +- .../WebCore/generated/JSSVGAnimatedLength.cpp | 2 +- .../WebCore/generated/JSSVGAnimatedLengthList.cpp | 2 +- .../WebCore/generated/JSSVGAnimatedNumber.cpp | 2 +- .../WebCore/generated/JSSVGAnimatedNumberList.cpp | 2 +- .../generated/JSSVGAnimatedPreserveAspectRatio.cpp | 2 +- .../webkit/WebCore/generated/JSSVGAnimatedRect.cpp | 2 +- .../WebCore/generated/JSSVGAnimatedString.cpp | 2 +- .../generated/JSSVGAnimatedTransformList.cpp | 2 +- .../WebCore/generated/JSSVGElementInstance.cpp | 82 +- .../WebCore/generated/JSSVGElementInstanceList.cpp | 2 +- .../webkit/WebCore/generated/JSSVGException.cpp | 2 +- .../webkit/WebCore/generated/JSSVGLength.cpp | 2 +- .../webkit/WebCore/generated/JSSVGLengthList.cpp | 2 +- .../webkit/WebCore/generated/JSSVGMatrix.cpp | 2 +- .../webkit/WebCore/generated/JSSVGNumber.cpp | 2 +- .../webkit/WebCore/generated/JSSVGNumberList.cpp | 2 +- .../webkit/WebCore/generated/JSSVGPathSeg.cpp | 2 +- .../webkit/WebCore/generated/JSSVGPathSegList.cpp | 2 +- .../webkit/WebCore/generated/JSSVGPoint.cpp | 2 +- .../webkit/WebCore/generated/JSSVGPointList.cpp | 2 +- .../WebCore/generated/JSSVGPreserveAspectRatio.cpp | 2 +- .../webkit/WebCore/generated/JSSVGRect.cpp | 2 +- .../WebCore/generated/JSSVGRenderingIntent.cpp | 2 +- .../webkit/WebCore/generated/JSSVGStringList.cpp | 2 +- .../webkit/WebCore/generated/JSSVGTransform.cpp | 2 +- .../WebCore/generated/JSSVGTransformList.cpp | 2 +- .../webkit/WebCore/generated/JSSVGUnitTypes.cpp | 2 +- src/3rdparty/webkit/WebCore/generated/JSScreen.cpp | 2 +- .../webkit/WebCore/generated/JSStorage.cpp | 2 +- .../webkit/WebCore/generated/JSStyleSheet.cpp | 2 +- .../webkit/WebCore/generated/JSStyleSheetList.cpp | 2 +- .../webkit/WebCore/generated/JSTextMetrics.cpp | 2 +- .../webkit/WebCore/generated/JSTimeRanges.cpp | 2 +- .../webkit/WebCore/generated/JSTreeWalker.cpp | 2 +- .../webkit/WebCore/generated/JSValidityState.cpp | 2 +- .../webkit/WebCore/generated/JSVoidCallback.cpp | 2 +- .../webkit/WebCore/generated/JSWebKitCSSMatrix.cpp | 2 +- .../webkit/WebCore/generated/JSWebKitPoint.cpp | 2 +- .../webkit/WebCore/generated/JSWebSocket.cpp | 8 +- src/3rdparty/webkit/WebCore/generated/JSWorker.cpp | 2 +- .../webkit/WebCore/generated/JSWorkerContext.cpp | 1 - .../webkit/WebCore/generated/JSWorkerLocation.cpp | 2 +- .../webkit/WebCore/generated/JSWorkerNavigator.cpp | 2 +- .../webkit/WebCore/generated/JSXMLHttpRequest.cpp | 14 +- .../generated/JSXMLHttpRequestException.cpp | 2 +- .../WebCore/generated/JSXMLHttpRequestUpload.cpp | 12 +- .../webkit/WebCore/generated/JSXMLSerializer.cpp | 2 +- .../webkit/WebCore/generated/JSXPathEvaluator.cpp | 2 +- .../webkit/WebCore/generated/JSXPathException.cpp | 2 +- .../webkit/WebCore/generated/JSXPathExpression.cpp | 2 +- .../webkit/WebCore/generated/JSXPathNSResolver.cpp | 2 +- .../webkit/WebCore/generated/JSXPathResult.cpp | 2 +- .../webkit/WebCore/generated/JSXSLTProcessor.cpp | 2 +- .../webkit/WebCore/generated/WebKitVersion.h | 2 +- .../webkit/WebCore/history/qt/HistoryItemQt.cpp | 17 +- .../webkit/WebCore/html/HTMLAllCollection.cpp | 47 + .../webkit/WebCore/html/HTMLAllCollection.h | 44 + .../webkit/WebCore/html/HTMLAllCollection.idl | 43 + .../webkit/WebCore/html/HTMLCanvasElement.cpp | 9 +- src/3rdparty/webkit/WebCore/html/HTMLCollection.h | 3 +- .../webkit/WebCore/html/HTMLCollection.idl | 3 +- src/3rdparty/webkit/WebCore/html/HTMLDocument.idl | 2 +- .../webkit/WebCore/html/HTMLInputElement.cpp | 26 +- .../webkit/WebCore/html/HTMLInputElement.h | 2 + .../webkit/WebCore/html/HTMLMediaElement.cpp | 11 +- .../webkit/WebCore/html/HTMLMediaElement.h | 1 - .../webkit/WebCore/html/HTMLOptionsCollection.idl | 7 +- src/3rdparty/webkit/WebCore/html/HTMLTokenizer.cpp | 21 +- .../WebCore/html/canvas/CanvasRenderingContext.h | 3 +- .../html/canvas/CanvasRenderingContext2D.cpp | 80 +- .../html/canvas/CanvasRenderingContext3D.cpp | 359 +- .../WebCore/html/canvas/CanvasRenderingContext3D.h | 13 +- .../webkit/WebCore/inspector/ConsoleMessage.cpp | 7 +- .../webkit/WebCore/inspector/ConsoleMessage.h | 1 + .../WebCore/inspector/DOMDispatchTimelineItem.cpp | 58 - .../WebCore/inspector/DOMDispatchTimelineItem.h | 58 - .../WebCore/inspector/InspectorController.cpp | 47 +- .../webkit/WebCore/inspector/InspectorController.h | 3 +- .../webkit/WebCore/inspector/InspectorDOMAgent.h | 5 + .../webkit/WebCore/inspector/InspectorFrontend.cpp | 17 +- .../webkit/WebCore/inspector/InspectorFrontend.h | 5 +- .../webkit/WebCore/inspector/InspectorResource.cpp | 20 +- .../webkit/WebCore/inspector/InspectorResource.h | 2 + .../WebCore/inspector/InspectorTimelineAgent.cpp | 126 +- .../WebCore/inspector/InspectorTimelineAgent.h | 70 +- .../WebCore/inspector/JavaScriptCallFrame.cpp | 3 +- .../webkit/WebCore/inspector/TimelineItem.cpp | 81 - .../webkit/WebCore/inspector/TimelineItem.h | 88 - .../WebCore/inspector/TimelineRecordFactory.cpp | 116 + .../WebCore/inspector/TimelineRecordFactory.h | 63 + .../inspector/front-end/AbstractTimelinePanel.js | 548 +++ .../front-end/BottomUpProfileDataGridTree.js | 214 +- .../webkit/WebCore/inspector/front-end/Color.js | 8 +- .../WebCore/inspector/front-end/ConsoleView.js | 183 +- .../inspector/front-end/DatabaseQueryView.js | 7 +- .../WebCore/inspector/front-end/ElementsPanel.js | 7 +- .../inspector/front-end/ElementsTreeOutline.js | 26 +- .../front-end/EventListenersSidebarPane.js | 11 +- .../inspector/front-end/Images/timelineBarBlue.png | Bin 0 -> 419 bytes .../inspector/front-end/Images/timelineBarGray.png | Bin 0 -> 378 bytes .../front-end/Images/timelineBarGreen.png | Bin 0 -> 414 bytes .../front-end/Images/timelineBarOrange.png | Bin 0 -> 394 bytes .../front-end/Images/timelineBarPurple.png | Bin 0 -> 420 bytes .../inspector/front-end/Images/timelineBarRed.png | Bin 0 -> 408 bytes .../front-end/Images/timelineBarYellow.png | Bin 0 -> 400 bytes .../front-end/Images/timelineCheckmarks.png | Bin 0 -> 3528 bytes .../inspector/front-end/Images/timelineDots.png | Bin 0 -> 2436 bytes .../inspector/front-end/Images/timelineIcon.png | Bin 0 -> 4419 bytes .../WebCore/inspector/front-end/InjectedScript.js | 60 +- .../inspector/front-end/InspectorControllerStub.js | 291 ++ .../webkit/WebCore/inspector/front-end/Panel.js | 99 + .../inspector/front-end/ProfileDataGridTree.js | 36 +- .../WebCore/inspector/front-end/ProfileView.js | 23 +- .../WebCore/inspector/front-end/ProfilesPanel.js | 91 +- .../inspector/front-end/ResourceCategory.js | 11 +- .../WebCore/inspector/front-end/ResourceView.js | 2 +- .../WebCore/inspector/front-end/ResourcesPanel.js | 647 +-- .../WebCore/inspector/front-end/SourceFrame.js | 459 ++- .../WebCore/inspector/front-end/StoragePanel.js | 68 +- .../inspector/front-end/StylesSidebarPane.js | 15 +- .../WebCore/inspector/front-end/SummaryBar.js | 3 +- .../WebCore/inspector/front-end/TestController.js | 10 + .../WebCore/inspector/front-end/TimelineAgent.js | 29 +- .../WebCore/inspector/front-end/TimelinePanel.js | 362 ++ .../front-end/TopDownProfileDataGridTree.js | 9 +- .../webkit/WebCore/inspector/front-end/WebKit.qrc | 2 + .../WebCore/inspector/front-end/inspector.css | 224 +- .../WebCore/inspector/front-end/inspector.html | 7 +- .../WebCore/inspector/front-end/inspector.js | 96 +- .../WebCore/inspector/front-end/utilities.js | 5 + src/3rdparty/webkit/WebCore/loader/Cache.cpp | 6 + .../webkit/WebCore/loader/CachedResource.cpp | 6 + src/3rdparty/webkit/WebCore/loader/FrameLoader.cpp | 52 +- src/3rdparty/webkit/WebCore/loader/FrameLoader.h | 5 + .../webkit/WebCore/loader/RedirectScheduler.cpp | 13 +- .../webkit/WebCore/loader/ResourceLoadNotifier.h | 7 +- .../webkit/WebCore/loader/icon/IconDatabase.cpp | 4 +- .../WebCore/notifications/NotificationCenter.cpp | 14 + .../WebCore/notifications/NotificationCenter.h | 6 +- src/3rdparty/webkit/WebCore/page/Console.cpp | 4 +- src/3rdparty/webkit/WebCore/page/Console.h | 3 +- src/3rdparty/webkit/WebCore/page/DOMTimer.cpp | 27 + src/3rdparty/webkit/WebCore/page/DOMTimer.h | 1 + src/3rdparty/webkit/WebCore/page/DOMWindow.idl | 9 +- src/3rdparty/webkit/WebCore/page/Geolocation.cpp | 128 +- src/3rdparty/webkit/WebCore/page/Geolocation.h | 25 +- src/3rdparty/webkit/WebCore/page/SecurityOrigin.h | 5 +- .../WebCore/page/android/EventHandlerAndroid.cpp | 8 +- .../WebCore/page/animation/AnimationBase.cpp | 2 + src/3rdparty/webkit/WebCore/platform/FileSystem.h | 64 +- .../webkit/WebCore/platform/SSLKeyGenerator.h | 9 +- .../WebCore/platform/android/ClipboardAndroid.h | 44 +- .../WebCore/platform/android/CursorAndroid.cpp | 7 +- .../platform/android/FileChooserAndroid.cpp | 5 +- .../WebCore/platform/android/FileSystemAndroid.cpp | 10 +- .../WebCore/platform/android/KeyEventAndroid.cpp | 288 +- .../WebCore/platform/android/ScreenAndroid.cpp | 32 +- .../platform/android/TemporaryLinkStubs.cpp | 33 +- .../webkit/WebCore/platform/graphics/BitmapImage.h | 4 +- .../WebCore/platform/graphics/GraphicsContext3D.h | 8 +- .../WebCore/platform/graphics/GraphicsLayer.cpp | 6 - .../WebCore/platform/graphics/GraphicsLayer.h | 8 - .../platform/graphics/filters/FEColorMatrix.cpp | 5 +- .../graphics/filters/FEComponentTransfer.cpp | 10 +- .../platform/graphics/filters/FEGaussianBlur.cpp | 9 +- .../WebCore/platform/graphics/qt/ImageQt.cpp | 39 + .../webkit/WebCore/platform/network/Credential.cpp | 3 +- .../webkit/WebCore/platform/network/Credential.h | 2 +- .../WebCore/platform/network/FormDataBuilder.cpp | 38 +- .../platform/network/ResourceRequestBase.cpp | 22 +- .../WebCore/platform/network/ResourceRequestBase.h | 4 +- .../platform/network/qt/QNetworkReplyHandler.cpp | 3 +- .../webkit/WebCore/platform/qt/CursorQt.cpp | 18 +- .../webkit/WebCore/platform/qt/WheelEventQt.cpp | 4 +- .../webkit/WebCore/platform/text/String.cpp | 4 +- .../webkit/WebCore/platform/win/BitmapInfo.cpp | 66 + .../webkit/WebCore/platform/win/BitmapInfo.h | 43 + .../webkit/WebCore/plugins/PluginDatabase.cpp | 4 +- .../webkit/WebCore/plugins/PluginPackage.cpp | 11 +- src/3rdparty/webkit/WebCore/plugins/PluginView.cpp | 2 +- src/3rdparty/webkit/WebCore/plugins/PluginView.h | 8 +- .../webkit/WebCore/plugins/qt/PluginViewQt.cpp | 33 +- .../WebCore/plugins/win/PluginPackageWin.cpp | 11 - .../webkit/WebCore/plugins/win/PluginViewWin.cpp | 128 +- .../webkit/WebCore/rendering/HitTestResult.cpp | 13 +- .../webkit/WebCore/rendering/HitTestResult.h | 1 - .../WebCore/rendering/MediaControlElements.cpp | 9 + .../WebCore/rendering/MediaControlElements.h | 1 + src/3rdparty/webkit/WebCore/rendering/RenderBox.h | 2 +- .../webkit/WebCore/rendering/RenderInline.cpp | 87 + .../webkit/WebCore/rendering/RenderInline.h | 5 + .../webkit/WebCore/rendering/RenderMedia.cpp | 1 + .../rendering/RenderMediaControlsChromium.cpp | 23 +- .../WebCore/rendering/RenderThemeChromiumWin.cpp | 51 +- .../WebCore/rendering/RenderThemeChromiumWin.h | 2 +- .../webkit/WebCore/rendering/RenderTreeAsText.cpp | 28 + .../webkit/WebCore/rendering/RenderTreeAsText.h | 17 +- .../webkit/WebCore/rendering/SVGRenderSupport.cpp | 3 + .../WebCore/rendering/style/SVGRenderStyle.cpp | 5 +- .../WebCore/rendering/style/SVGRenderStyle.h | 4 + .../WebCore/rendering/style/SVGRenderStyleDefs.cpp | 19 + .../WebCore/rendering/style/SVGRenderStyleDefs.h | 28 + src/3rdparty/webkit/WebCore/storage/Database.cpp | 57 +- src/3rdparty/webkit/WebCore/storage/Database.h | 15 +- .../webkit/WebCore/storage/DatabaseThread.cpp | 22 +- .../webkit/WebCore/storage/DatabaseTracker.cpp | 23 +- .../webkit/WebCore/storage/DatabaseTracker.h | 2 + .../webkit/WebCore/storage/OriginQuotaManager.cpp | 3 +- .../webkit/WebCore/storage/SQLTransaction.cpp | 1 - .../WebCore/storage/SQLTransactionClient.cpp | 8 +- .../WebCore/storage/StorageEventDispatcher.cpp | 4 +- .../webkit/WebCore/svg/SVGStyledElement.cpp | 15 +- .../svg/SynchronizablePropertyController.cpp | 128 +- .../WebCore/svg/SynchronizablePropertyController.h | 68 +- .../webkit/WebCore/websockets/WebSocket.cpp | 10 +- .../webkit/WebCore/websockets/WebSocketChannel.cpp | 31 +- .../webkit/WebCore/websockets/WebSocketChannel.h | 4 +- .../webkit/WebCore/workers/WorkerContext.cpp | 1 + .../webkit/WebCore/workers/WorkerContext.idl | 2 +- src/3rdparty/webkit/WebCore/xml/XMLHttpRequest.cpp | 33 +- src/3rdparty/webkit/WebCore/xml/XMLHttpRequest.h | 2 +- src/3rdparty/webkit/WebCore/xml/XPathFunctions.cpp | 9 +- src/3rdparty/webkit/WebKit.pri | 4 + src/3rdparty/webkit/WebKit/ChangeLog | 16 + src/3rdparty/webkit/WebKit/LICENSE | 22 +- .../WebKit/mac/Configurations/Version.xcconfig | 3 +- .../webkit/WebKit/qt/Api/qgraphicswebview.cpp | 122 +- .../webkit/WebKit/qt/Api/qgraphicswebview.h | 1 + src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp | 414 +- src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h | 76 +- src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp | 119 +- src/3rdparty/webkit/WebKit/qt/Api/qwebframe.h | 19 +- src/3rdparty/webkit/WebKit/qt/Api/qwebframe_p.h | 4 +- src/3rdparty/webkit/WebKit/qt/Api/qwebhistory.cpp | 149 +- src/3rdparty/webkit/WebKit/qt/Api/qwebhistory.h | 15 - src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 58 +- src/3rdparty/webkit/WebKit/qt/Api/qwebpage_p.h | 5 + .../webkit/WebKit/qt/Api/qwebsecurityorigin.cpp | 28 +- .../webkit/WebKit/qt/Api/qwebsecurityorigin.h | 2 - src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp | 109 +- src/3rdparty/webkit/WebKit/qt/Api/qwebview.h | 5 +- src/3rdparty/webkit/WebKit/qt/ChangeLog | 481 +++ .../qt/tests/benchmarks/loading/tst_loading.pro | 5 +- .../qt/tests/benchmarks/painting/tst_painting.pro | 5 +- .../qt/tests/qgraphicswebview/qgraphicswebview.pro | 4 + .../WebKit/qt/tests/qwebelement/qwebelement.pro | 5 +- .../qt/tests/qwebelement/tst_qwebelement.cpp | 91 +- .../webkit/WebKit/qt/tests/qwebframe/qwebframe.pro | 5 +- .../WebKit/qt/tests/qwebframe/resources/image2.png | Bin 0 -> 14743 bytes .../WebKit/qt/tests/qwebframe/tst_qwebframe.cpp | 47 +- .../WebKit/qt/tests/qwebhistory/qwebhistory.pro | 5 +- .../qt/tests/qwebhistory/tst_qwebhistory.cpp | 80 +- .../qwebhistoryinterface/qwebhistoryinterface.pro | 5 +- .../webkit/WebKit/qt/tests/qwebpage/qwebpage.pro | 5 +- .../WebKit/qt/tests/qwebpage/tst_qwebpage.cpp | 2 +- .../qwebplugindatabase/qwebplugindatabase.pro | 5 +- .../webkit/WebKit/qt/tests/qwebview/qwebview.pro | 5 +- .../WebKit/qt/tests/qwebview/tst_qwebview.cpp | 64 - 495 files changed, 14556 insertions(+), 4934 deletions(-) create mode 100644 src/3rdparty/webkit/JavaScriptCore/runtime/DateInstanceCache.h create mode 100644 src/3rdparty/webkit/WebCore/ForwardingHeaders/wtf/DateInstanceCache.h create mode 100755 src/3rdparty/webkit/WebCore/accessibility/AccessibilityAllInOne.cpp create mode 100644 src/3rdparty/webkit/WebCore/bindings/js/JSBindingsAllInOne.cpp delete mode 100644 src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollection.cpp delete mode 100644 src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollection.h create mode 100644 src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp delete mode 100644 src/3rdparty/webkit/WebCore/dom/HTMLAllCollection.idl create mode 100644 src/3rdparty/webkit/WebCore/generated/JSHTMLAllCollection.cpp create mode 100644 src/3rdparty/webkit/WebCore/generated/JSHTMLAllCollection.h create mode 100644 src/3rdparty/webkit/WebCore/html/HTMLAllCollection.cpp create mode 100644 src/3rdparty/webkit/WebCore/html/HTMLAllCollection.h create mode 100644 src/3rdparty/webkit/WebCore/html/HTMLAllCollection.idl delete mode 100644 src/3rdparty/webkit/WebCore/inspector/DOMDispatchTimelineItem.cpp delete mode 100644 src/3rdparty/webkit/WebCore/inspector/DOMDispatchTimelineItem.h delete mode 100644 src/3rdparty/webkit/WebCore/inspector/TimelineItem.cpp delete mode 100644 src/3rdparty/webkit/WebCore/inspector/TimelineItem.h create mode 100644 src/3rdparty/webkit/WebCore/inspector/TimelineRecordFactory.cpp create mode 100644 src/3rdparty/webkit/WebCore/inspector/TimelineRecordFactory.h create mode 100644 src/3rdparty/webkit/WebCore/inspector/front-end/AbstractTimelinePanel.js create mode 100644 src/3rdparty/webkit/WebCore/inspector/front-end/Images/timelineBarBlue.png create mode 100644 src/3rdparty/webkit/WebCore/inspector/front-end/Images/timelineBarGray.png create mode 100644 src/3rdparty/webkit/WebCore/inspector/front-end/Images/timelineBarGreen.png create mode 100644 src/3rdparty/webkit/WebCore/inspector/front-end/Images/timelineBarOrange.png create mode 100644 src/3rdparty/webkit/WebCore/inspector/front-end/Images/timelineBarPurple.png create mode 100644 src/3rdparty/webkit/WebCore/inspector/front-end/Images/timelineBarRed.png create mode 100644 src/3rdparty/webkit/WebCore/inspector/front-end/Images/timelineBarYellow.png create mode 100644 src/3rdparty/webkit/WebCore/inspector/front-end/Images/timelineCheckmarks.png create mode 100644 src/3rdparty/webkit/WebCore/inspector/front-end/Images/timelineDots.png create mode 100644 src/3rdparty/webkit/WebCore/inspector/front-end/Images/timelineIcon.png create mode 100644 src/3rdparty/webkit/WebCore/inspector/front-end/InspectorControllerStub.js create mode 100644 src/3rdparty/webkit/WebCore/inspector/front-end/TimelinePanel.js create mode 100644 src/3rdparty/webkit/WebCore/platform/win/BitmapInfo.cpp create mode 100644 src/3rdparty/webkit/WebCore/platform/win/BitmapInfo.h create mode 100644 src/3rdparty/webkit/WebKit/qt/tests/qwebframe/resources/image2.png diff --git a/src/3rdparty/webkit/ChangeLog b/src/3rdparty/webkit/ChangeLog index fb7dddf..dc43e0e 100644 --- a/src/3rdparty/webkit/ChangeLog +++ b/src/3rdparty/webkit/ChangeLog @@ -1,3 +1,45 @@ +2009-10-26 Holger Hans Peter Freyther + + Rubber-stamped by Darin Adler. + + Export fastMalloc, fastCalloc, fastRealloc and fastFree + https://bugs.webkit.org/show_bug.cgi?id=30769 + + Export the FastMalloc functions outside of the libwebkit library + to be able to instrument memory allocations. These are C++ symbols + but do not require the C++ runtime to be useful and should be of + no harm to plain C code. + + * autotools/symbols.filter: + +2009-10-26 Gustavo Noronha Silva + + Reviewed by Jan Alonzo. + + Alternative solution to regression introduced in r48672. + + * GNUmakefile.am: + +2009-10-26 Xan Lopez + + Reviewed by Gustavo Noronha. + + Update for 1.1.16 release. + + * configure.ac: + +2009-10-24 Laszlo Gombos + + Reviewed by Holger Freyther. + + [Qt] [Symbian] Set the capability and memory required to run QtWebKit for Symbian + https://bugs.webkit.org/show_bug.cgi?id=30476 + + Set the stack size to 80 Kb and heap size to the 128kB - 32MB range + to all executables linking against WebKit library. + + * WebKit.pri: + 2009-10-18 Jan Michael Alonzo Reviewed by Holger Freyther. diff --git a/src/3rdparty/webkit/JavaScriptCore/ChangeLog b/src/3rdparty/webkit/JavaScriptCore/ChangeLog index 8d6c2df..e6ab073 100644 --- a/src/3rdparty/webkit/JavaScriptCore/ChangeLog +++ b/src/3rdparty/webkit/JavaScriptCore/ChangeLog @@ -1,3 +1,527 @@ +2009-10-29 Gabor Loki + + Reviewed by Gavin Barraclough. + + Add cacheFlush support for Thumb-2 on Linux + https://bugs.webkit.org/show_bug.cgi?id=30865 + + * jit/ExecutableAllocator.h: + (JSC::ExecutableAllocator::cacheFlush): + +2009-10-28 Gavin Barraclough + + Reviewed by Oliver Hunt. + + JSC JIT on ARMv7 cannot link jumps >16Mb range + https://bugs.webkit.org/show_bug.cgi?id=30891 + + Start planing all relative jumps as move-32-bit-immediate-to-register-BX. + In the cases where the jump would fall within a relative jump range, use a relative jump. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * assembler/ARMv7Assembler.h: + (JSC::ARMv7Assembler::~ARMv7Assembler): + (JSC::ARMv7Assembler::LinkRecord::LinkRecord): + (JSC::ARMv7Assembler::): + (JSC::ARMv7Assembler::executableCopy): + (JSC::ARMv7Assembler::linkJump): + (JSC::ARMv7Assembler::relinkJump): + (JSC::ARMv7Assembler::setInt32): + (JSC::ARMv7Assembler::isB): + (JSC::ARMv7Assembler::isBX): + (JSC::ARMv7Assembler::isMOV_imm_T3): + (JSC::ARMv7Assembler::isMOVT): + (JSC::ARMv7Assembler::isNOP_T1): + (JSC::ARMv7Assembler::isNOP_T2): + (JSC::ARMv7Assembler::linkJumpAbsolute): + (JSC::ARMv7Assembler::twoWordOp5i6Imm4Reg4EncodedImmFirst): + (JSC::ARMv7Assembler::twoWordOp5i6Imm4Reg4EncodedImmSecond): + (JSC::ARMv7Assembler::ARMInstructionFormatter::twoWordOp5i6Imm4Reg4EncodedImm): + * assembler/MacroAssemblerARMv7.h: + (JSC::MacroAssemblerARMv7::makeJump): + (JSC::MacroAssemblerARMv7::makeBranch): + * jit/JIT.h: + * wtf/Platform.h: + +2009-10-28 Oliver Hunt + + Reviewed by Geoff Garen. + + Improve for..in enumeration performance + https://bugs.webkit.org/show_bug.cgi?id=30887 + + Improve indexing of an object with a for..in iterator by + identifying cases where get_by_val is being used with a iterator + as the subscript and replace it with a new get_by_pname + bytecode. get_by_pname then optimizes lookups that directly access + the base object. + + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::dump): + * bytecode/Opcode.h: + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::emitGetByVal): + * bytecompiler/BytecodeGenerator.h: + (JSC::BytecodeGenerator::pushOptimisedForIn): + (JSC::BytecodeGenerator::popOptimisedForIn): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::privateExecute): + * jit/JIT.cpp: + (JSC::JIT::privateCompileMainPass): + (JSC::JIT::privateCompileSlowCases): + * jit/JIT.h: + * jit/JITPropertyAccess.cpp: + (JSC::JIT::compileGetDirectOffset): + (JSC::JIT::emit_op_get_by_pname): + (JSC::JIT::emitSlow_op_get_by_pname): + * parser/Nodes.cpp: + (JSC::ForInNode::emitBytecode): + * runtime/JSObject.h: + * runtime/JSPropertyNameIterator.cpp: + (JSC::JSPropertyNameIterator::create): + * runtime/JSPropertyNameIterator.h: + (JSC::JSPropertyNameIterator::getOffset): + (JSC::JSPropertyNameIterator::JSPropertyNameIterator): + * runtime/JSValue.h: + (JSC::JSValue::): + * runtime/Structure.cpp: + (JSC::Structure::addPropertyTransition): + (JSC::Structure::changePrototypeTransition): + (JSC::Structure::despecifyFunctionTransition): + (JSC::Structure::addAnonymousSlotsTransition): + (JSC::Structure::getterSetterTransition): + (JSC::Structure::toDictionaryTransition): + (JSC::Structure::addPropertyWithoutTransition): + Track the existence (or not) of non-enumerable properties. + * runtime/Structure.h: + (JSC::Structure::propertyStorageCapacity): + (JSC::Structure::propertyStorageSize): + (JSC::Structure::hasNonEnumerableProperties): + (JSC::Structure::hasAnonymousSlots): + +2009-10-28 Dmitry Titov + + Not reviewed, attemp to fix Windows build. + + Touch the cpp file to cause recompile. + + * wtf/Threading.cpp: + (WTF::threadEntryPoint): + +2009-10-28 Dmitry Titov + + Reviewed by David Levin. + + https://bugs.webkit.org/show_bug.cgi?id=30805 + Add MessageQueue::removeIf(Predicate&) to remove certain tasks without pulling them from the queue. + Existing Database tests cover this since Database removes tasks when it is stopped. + + * wtf/MessageQueue.h: + (WTF::::removeIf): + +2009-10-28 Afonso R. Costa Jr. + + Reviewed by Oliver Hunt. + + [Qt] Enable YARR when YARR_JIT is enabled + https://bugs.webkit.org/show_bug.cgi?id=30730 + + When enabling or disabling JIT using JAVASCRIPTCORE_JIT, the ENABLE_YARR should + be toggled also. + + * JavaScriptCore.pri: + +2009-10-24 Martin Robinson + + Reviewed by Oliver Hunt. + + Fix strict aliasing warning by switching reinterpret_cast to bitwise_cast. + + strict-aliasing warnings in JSFunction.h + https://bugs.webkit.org/show_bug.cgi?id=27869 + + * runtime/JSFunction.h: + (JSC::JSFunction::nativeFunction): + (JSC::JSFunction::scopeChain): + (JSC::JSFunction::setScopeChain): + (JSC::JSFunction::setNativeFunction): + +2009-10-28 Jan-Arve Sæther + + Reviewed by Tor Arne Vestbø. + + Build-fix for 64-bit Windows + + * wtf/Platform.h: Make sure to use WTF_USE_JSVALUE64 + +2009-10-28 Gavin Barraclough + + Reviewed by NOBODY (build fix!). + + * jit/JIT.h: + +2009-10-26 Holger Hans Peter Freyther + + Rubber-stamped by Darin Adler. + + Export fastMalloc, fastCalloc, fastRealloc and fastFree on GCC/Unix + https://bugs.webkit.org/show_bug.cgi?id=30769 + + When using -fvisibility=hidden to hide all internal symbols by default + the malloc symbols will be hidden as well. For memory instrumentation + it is needed to provide an instrumented version of these symbols and + override the normal routines and by changing the visibility back to + default this becomes possible. + + The only other solution would be to use system malloc instead of the + TCmalloc implementation but this will not allow to analyze memory + behavior with the default allocator. + + * wtf/FastMalloc.h: Define WTF_FAST_MALLOC_EXPORT for GCC and !darwin + +2009-10-27 Gavin Barraclough + + Rubber Stamped by Samuel Q. Weinig. + + Make the asserts protecting the offsets in the JIT more descriptive. + + * jit/JIT.h: + * jit/JITCall.cpp: + (JSC::JIT::compileOpCall): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emit_op_method_check): + (JSC::JIT::compileGetByIdHotPath): + (JSC::JIT::compileGetByIdSlowCase): + (JSC::JIT::emit_op_put_by_id): + +2009-10-27 Geoffrey Garen + + Reviewed by Sam Weinig. + + A little bit of refactoring in the date code. + + * JavaScriptCore.exp: Don't export this unused symbol. + + * runtime/DateConstructor.cpp: + (JSC::constructDate): + + * runtime/DateInstance.cpp: + (JSC::DateInstance::DateInstance): + * runtime/DateInstance.h: Removed some unused functions. Changed the default + constructor to ensure that a DateInstance is always initialized. + + * runtime/DatePrototype.cpp: + (JSC::DatePrototype::DatePrototype): Pass an initializer to our constructor, + since it now requires one. + + * wtf/DateMath.cpp: + (WTF::msToGregorianDateTime): Only compute our offset from UTC if our + output will require it. Otherwise, our offset is 0. + +2009-10-27 Geoffrey Garen + + Build fix: Mark DateInstaceCache.h private, so other frameworks can see it. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2009-10-27 Geoffrey Garen + + Build fix: re-readded this file. + + * runtime/DateInstanceCache.h: Added. + (JSC::DateInstanceData::create): + (JSC::DateInstanceData::DateInstanceData): + (JSC::DateInstanceCache::DateInstanceCache): + (JSC::DateInstanceCache::add): + (JSC::DateInstanceCache::lookup): + +2009-10-27 Geoffrey Garen + + Reviewed by Darin Adler and Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=30800 + Cache recently computed date data. + + SunSpider reports a ~0.5% speedup, mostly from date-format-tofte.js. + + * GNUmakefile.am: + * JavaScriptCore.gypi: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: Added new file. + + * runtime/DateInstance.cpp: + (JSC::DateInstance::DateInstance): + (JSC::DateInstance::getGregorianDateTime): Use the shared cache. + + * runtime/DateInstance.h: Renamed m_cache to m_data, to avoid the confusion + of a "cache cache". + + * runtime/DatePrototype.cpp: + (JSC::formatLocaleDate): + (JSC::dateProtoFuncToString): + (JSC::dateProtoFuncToUTCString): + (JSC::dateProtoFuncToISOString): + (JSC::dateProtoFuncToDateString): + (JSC::dateProtoFuncToTimeString): + (JSC::dateProtoFuncGetFullYear): + (JSC::dateProtoFuncGetUTCFullYear): + (JSC::dateProtoFuncToGMTString): + (JSC::dateProtoFuncGetMonth): + (JSC::dateProtoFuncGetUTCMonth): + (JSC::dateProtoFuncGetDate): + (JSC::dateProtoFuncGetUTCDate): + (JSC::dateProtoFuncGetDay): + (JSC::dateProtoFuncGetUTCDay): + (JSC::dateProtoFuncGetHours): + (JSC::dateProtoFuncGetUTCHours): + (JSC::dateProtoFuncGetMinutes): + (JSC::dateProtoFuncGetUTCMinutes): + (JSC::dateProtoFuncGetSeconds): + (JSC::dateProtoFuncGetUTCSeconds): + (JSC::dateProtoFuncGetTimezoneOffset): + (JSC::setNewValueFromTimeArgs): + (JSC::setNewValueFromDateArgs): + (JSC::dateProtoFuncSetYear): + (JSC::dateProtoFuncGetYear): Pass an ExecState to these functions, so they + can access the DateInstanceCache. + + * runtime/JSGlobalData.h: Keep a DateInstanceCache. + +2009-10-27 James Robinson + + Reviewed by Darin Fisher. + + Ensures that JavaScriptCore/wtf/CurrentTime.cpp is not built in PLATFORM(CHROMIUM) builds. + + Chromium uses a different method to calculate the current time than is used in + JavaScriptCore/wtf/CurrentTime.cpp. This can lead to time skew when calls to currentTime() and Chromium's time + function are mixed. In particular, timers can get scheduled in the past which leads to 100% CPU use. + See http://code.google.com/p/chromium/issues/detail?id=25892 for an example. + + https://bugs.webkit.org/show_bug.cgi?id=30833 + + * JavaScriptCore.gyp/JavaScriptCore.gyp: + * wtf/CurrentTime.cpp: + +2009-10-27 Peter Varga + + Rubber-stamped by Tor Arne Vestbø. + + Fix typo in RegexInterpreter.cpp and RegexJIT.cpp alterantive to + alternative. + + * yarr/RegexInterpreter.cpp: + (JSC::Yarr::ByteCompiler::alternativeBodyDisjunction): + (JSC::Yarr::ByteCompiler::alternativeDisjunction): + (JSC::Yarr::ByteCompiler::emitDisjunction): + * yarr/RegexJIT.cpp: + (JSC::Yarr::RegexGenerator::generateDisjunction): + +2009-10-26 Laszlo Gombos + + Reviewed by Darin Adler. + + Make .rc files compile on Windows without depending on MFC headers + https://bugs.webkit.org/show_bug.cgi?id=30750 + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.rc: Use + winresrc.h because it exists even when MFC is not installed, and is + all that's needed here. + +2009-10-26 Gabor Loki + + Reviewed by Gavin Barraclough. + + The thunkReturnAddress is on JITStackFrame on ARM JIT as well + https://bugs.webkit.org/show_bug.cgi?id=30782 + + Move the thunkReturnAddress from top of the stack into the JITStackFrame + structure. This is a requirement for JSValue32_64 support on ARM. + + * assembler/MacroAssemblerARM.h: + (JSC::MacroAssemblerARM::ret): Return with link register + (JSC::MacroAssemblerARM::prepareCall): Store the return address in link register + * jit/JIT.h: Remove unused ctiReturnRegister + * jit/JITInlineMethods.h: Same as ARMv7 + (JSC::JIT::restoreArgumentReference): Ditto. + (JSC::JIT::restoreArgumentReferenceForTrampoline): Ditto. + * jit/JITOpcodes.cpp: Remove ctiReturnRegister related instruction + * jit/JITStubs.cpp: Store thunkReturnAddress on JITStackFrame. Use + small trampoline functions which handle return addresses for each + CTI_STUB_FUNCTION. + * jit/JITStubs.h: Store thunkReturnAddress on JITStackFrame + (JSC::JITStackFrame::returnAddressSlot): Return with the address of thunkReturnAddress + * yarr/RegexJIT.cpp: + (JSC::Yarr::RegexGenerator::generateEnter): Remove the unnecessary instruction + +2009-10-26 Steve Block + + Reviewed by Darin Adler. + + Adds ability to disable ReadWriteLock on platforms (eg Android) that use pthreads but do not support pthread_rwlock. + https://bugs.webkit.org/show_bug.cgi?id=30713 + + * wtf/Platform.h: Modified. Defines HAVE_PTHREAD_RWLOCK for all platforms currently using pthreads. + * wtf/Threading.h: Modified. Use pthread_rwlock_t only when HAVE_PTHREAD_RWLOCK is defined. + * wtf/ThreadingPthreads.cpp: Modified. Build ReadWriteLock methods only when HAVE_PTHREAD_RWLOCK is defined. + +2009-10-24 Laszlo Gombos + + Reviewed by Holger Freyther. + + [Qt] [Symbian] Set the capability and memory required to run QtWebKit for Symbian + https://bugs.webkit.org/show_bug.cgi?id=30476 + + Assign ReadUserData WriteUserData NetworkServices Symbian capabilities + to jsc.exe. + + * jsc.pro: + +2009-10-23 Steve Block + + Reviewed by Dmitry Titov. + + Fixes a leak in createThreadInternal on Android. + https://bugs.webkit.org/show_bug.cgi?id=30698 + + * wtf/ThreadingPthreads.cpp: Modified. + (WTF::createThreadInternal): Avoid leaking a ThreadData object on failure. + +2009-10-22 Geoffrey Garen + + Reviewed by Alexey Proskuryakov. + + Fixed ASSERT when opening Safari's Caches window while the Web Inspector + is open. + + * runtime/Collector.cpp: + (JSC::typeName): Added two new types to the type name list in the Collector. + These types have been around for a while, but nobody remembered to consider them here. + + * runtime/JSCell.h: + (JSC::JSCell::isPropertyNameIterator): + * runtime/JSPropertyNameIterator.h: + (JSC::JSPropertyNameIterator::isPropertyNameIterator): Give the Collector + a way to tell if a cell is a JSPropertyNameIterator. + +2009-10-22 Steve Falkenburg + + Reviewed by Jon Honeycutt. + + https://bugs.webkit.org/show_bug.cgi?id=30686 + Remove debug-specific def file. + Only Debug_All target uses JavaScriptCore_debug.dll naming, and since + that target is only used internally, maintaining two files just to + suppress a single link warning isn't worthwhile. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreCommon.vsprops: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: Removed. + +2009-10-21 Jon Honeycutt + + Screenshots of off-screen plug-ins are blank + After halting a transparent PluginView on + Windows, the transparency is applied twice + + Reviewed by Dan Bernstein. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + Export WTF::deleteOwnedPtr(HDC). + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + Ditto. + +2009-10-20 Geoffrey Garen + + Windows build fix: updated variable name. + + * runtime/DatePrototype.cpp: + (JSC::formatLocaleDate): + +2009-10-20 Geoffrey Garen + + Reviewed by Mark Rowe. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_next_pname): Slightly tweaked this #ifdef to match the + size of a JSValue because m_jsStrings is an array of JSValues. + +2009-10-20 Geoffrey Garen + + Reviewed by Mark Rowe. + + Fixed a 64-bit regression caused by the fix for + https://bugs.webkit.org/show_bug.cgi?id=30570. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_next_pname): Use TimesEight stepping on 64-bit, since + 64-bit pointers are eight bytes long. + +2009-10-20 Geoffrey Garen + + Reviewed by Sam Weinig. + + Refactored DateInstance::msToGregorianDateTime so that a DateInstance's + caller doesn't need to supply the DateInstance's own internal value to + the DateInstance. + + * runtime/DateInstance.cpp: + (JSC::DateInstance::getGregorianDateTime): Renamed from "msToGregorianDateTime". + + * runtime/DateInstance.h: + * runtime/DatePrototype.cpp: + (JSC::formatLocaleDate): + (JSC::dateProtoFuncToString): + (JSC::dateProtoFuncToUTCString): + (JSC::dateProtoFuncToISOString): + (JSC::dateProtoFuncToDateString): + (JSC::dateProtoFuncToTimeString): + (JSC::dateProtoFuncToLocaleString): + (JSC::dateProtoFuncToLocaleDateString): + (JSC::dateProtoFuncToLocaleTimeString): + (JSC::dateProtoFuncGetTime): + (JSC::dateProtoFuncGetFullYear): + (JSC::dateProtoFuncGetUTCFullYear): + (JSC::dateProtoFuncToGMTString): + (JSC::dateProtoFuncGetMonth): + (JSC::dateProtoFuncGetUTCMonth): + (JSC::dateProtoFuncGetDate): + (JSC::dateProtoFuncGetUTCDate): + (JSC::dateProtoFuncGetDay): + (JSC::dateProtoFuncGetUTCDay): + (JSC::dateProtoFuncGetHours): + (JSC::dateProtoFuncGetUTCHours): + (JSC::dateProtoFuncGetMinutes): + (JSC::dateProtoFuncGetUTCMinutes): + (JSC::dateProtoFuncGetSeconds): + (JSC::dateProtoFuncGetUTCSeconds): + (JSC::dateProtoFuncGetTimezoneOffset): + (JSC::setNewValueFromTimeArgs): + (JSC::setNewValueFromDateArgs): + (JSC::dateProtoFuncSetYear): + (JSC::dateProtoFuncGetYear): Also renamed "utc" to "outputIsUTC", for clarity. + +2009-10-20 Gabor Loki + + Reviewed by Geoffrey Garen. + + The op_next_pname should use 4 bytes addressing mode in case of JSValue32 + https://bugs.webkit.org/show_bug.cgi?id=30570 + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_next_pname): + +2009-10-20 Gabor Loki + + Reviewed by Oliver Hunt. + + Move OverridesMarkChildren flag from DatePrototype to its parent class + https://bugs.webkit.org/show_bug.cgi?id=30372 + + * runtime/DateInstance.h: + (JSC::DateInstance::createStructure): + * runtime/DatePrototype.h: + 2009-10-19 Geoffrey Garen Reviewed by Oliver Hunt. diff --git a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi index 4b316c8..03c23c3 100644 --- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi +++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi @@ -194,6 +194,7 @@ 'runtime/DateConversion.h', 'runtime/DateInstance.cpp', 'runtime/DateInstance.h', + 'runtime/DateInstanceCache.h', 'runtime/DatePrototype.cpp', 'runtime/DatePrototype.h', 'runtime/Error.cpp', diff --git a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri index 89c483e..eb26664 100644 --- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri +++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri @@ -39,10 +39,12 @@ win32-* { contains(JAVASCRIPTCORE_JIT,yes) { DEFINES+=ENABLE_JIT=1 DEFINES+=ENABLE_YARR_JIT=1 + DEFINES+=ENABLE_YARR=1 } contains(JAVASCRIPTCORE_JIT,no) { DEFINES+=ENABLE_JIT=0 DEFINES+=ENABLE_YARR_JIT=0 + DEFINES+=ENABLE_YARR=0 } # In debug mode JIT disabled until crash fixed diff --git a/src/3rdparty/webkit/JavaScriptCore/assembler/ARMv7Assembler.h b/src/3rdparty/webkit/JavaScriptCore/assembler/ARMv7Assembler.h index 078de44..02ce2e9 100644 --- a/src/3rdparty/webkit/JavaScriptCore/assembler/ARMv7Assembler.h +++ b/src/3rdparty/webkit/JavaScriptCore/assembler/ARMv7Assembler.h @@ -407,6 +407,11 @@ register writeback class ARMv7Assembler { public: + ~ARMv7Assembler() + { + ASSERT(m_jumpsToLink.isEmpty()); + } + typedef ARMRegisters::RegisterID RegisterID; typedef ARMRegisters::FPRegisterID FPRegisterID; @@ -477,6 +482,17 @@ public: private: + struct LinkRecord { + LinkRecord(intptr_t from, intptr_t to) + : from(from) + , to(to) + { + } + + intptr_t from; + intptr_t to; + }; + // ARMv7, Appx-A.6.3 bool BadReg(RegisterID reg) { @@ -574,6 +590,7 @@ private: OP_SUB_SP_imm_T1 = 0xB080, OP_BKPT = 0xBE00, OP_IT = 0xBF00, + OP_NOP_T1 = 0xBF00, } OpcodeID; typedef enum { @@ -608,6 +625,7 @@ private: OP_MOV_imm_T3 = 0xF240, OP_SUB_imm_T4 = 0xF2A0, OP_MOVT = 0xF2C0, + OP_NOP_T2a = 0xF3AF, OP_LDRH_reg_T2 = 0xF830, OP_LDRH_imm_T3 = 0xF830, OP_STR_imm_T4 = 0xF840, @@ -626,6 +644,7 @@ private: typedef enum { OP_B_T4b = 0x9000, + OP_NOP_T2b = 0x8000, } OpcodeID2; struct FourFours { @@ -1481,6 +1500,15 @@ public: void* executableCopy(ExecutablePool* allocator) { void* copy = m_formatter.executableCopy(allocator); + + unsigned jumpCount = m_jumpsToLink.size(); + for (unsigned i = 0; i < jumpCount; ++i) { + uint16_t* location = reinterpret_cast(reinterpret_cast(copy) + m_jumpsToLink[i].from); + uint16_t* target = reinterpret_cast(reinterpret_cast(copy) + m_jumpsToLink[i].to); + linkJumpAbsolute(location, target); + } + m_jumpsToLink.clear(); + ASSERT(copy); return copy; } @@ -1503,11 +1531,7 @@ public: { ASSERT(to.m_offset != -1); ASSERT(from.m_offset != -1); - - uint16_t* location = reinterpret_cast(reinterpret_cast(m_formatter.data()) + from.m_offset); - intptr_t relative = to.m_offset - from.m_offset; - - linkWithOffset(location, relative); + m_jumpsToLink.append(LinkRecord(from.m_offset, to.m_offset)); } static void linkJump(void* code, JmpSrc from, void* to) @@ -1515,9 +1539,7 @@ public: ASSERT(from.m_offset != -1); uint16_t* location = reinterpret_cast(reinterpret_cast(code) + from.m_offset); - intptr_t relative = reinterpret_cast(to) - reinterpret_cast(location); - - linkWithOffset(location, relative); + linkJumpAbsolute(location, to); } // bah, this mathod should really be static, since it is used by the LinkBuffer. @@ -1541,10 +1563,9 @@ public: ASSERT(!(reinterpret_cast(from) & 1)); ASSERT(!(reinterpret_cast(to) & 1)); - intptr_t relative = reinterpret_cast(to) - reinterpret_cast(from); - linkWithOffset(reinterpret_cast(from), relative); + linkJumpAbsolute(reinterpret_cast(from), to); - ExecutableAllocator::cacheFlush(reinterpret_cast(from) - 2, 2 * sizeof(uint16_t)); + ExecutableAllocator::cacheFlush(reinterpret_cast(from) - 5, 5 * sizeof(uint16_t)); } static void relinkCall(void* from, void* to) @@ -1613,14 +1634,14 @@ private: static void setInt32(void* code, uint32_t value) { uint16_t* location = reinterpret_cast(code); + ASSERT(isMOV_imm_T3(location - 4) && isMOVT(location - 2)); - uint16_t lo16 = value; - uint16_t hi16 = value >> 16; - - spliceHi5(location - 4, lo16); - spliceLo11(location - 3, lo16); - spliceHi5(location - 2, hi16); - spliceLo11(location - 1, hi16); + ARMThumbImmediate lo16 = ARMThumbImmediate::makeUInt16(static_cast(value)); + ARMThumbImmediate hi16 = ARMThumbImmediate::makeUInt16(static_cast(value >> 16)); + location[-4] = twoWordOp5i6Imm4Reg4EncodedImmFirst(OP_MOV_imm_T3, lo16); + location[-3] = twoWordOp5i6Imm4Reg4EncodedImmSecond((location[-3] >> 8) & 0xf, lo16); + location[-2] = twoWordOp5i6Imm4Reg4EncodedImmFirst(OP_MOVT, hi16); + location[-1] = twoWordOp5i6Imm4Reg4EncodedImmSecond((location[-1] >> 8) & 0xf, hi16); ExecutableAllocator::cacheFlush(location - 4, 4 * sizeof(uint16_t)); } @@ -1630,41 +1651,89 @@ private: setInt32(code, reinterpret_cast(value)); } - // Linking & patching: - // This method assumes that the JmpSrc being linked is a T4 b instruction. - static void linkWithOffset(uint16_t* instruction, intptr_t relative) - { - // Currently branches > 16m = mostly deathy. - if (((relative << 7) >> 7) != relative) { - // FIXME: This CRASH means we cannot turn the JIT on by default on arm-v7. - fprintf(stderr, "Error: Cannot link T4b.\n"); - CRASH(); - } - - // ARM encoding for the top two bits below the sign bit is 'peculiar'. - if (relative >= 0) - relative ^= 0xC00000; + static bool isB(void* address) + { + uint16_t* instruction = static_cast(address); + return ((instruction[0] & 0xf800) == OP_B_T4a) && ((instruction[1] & 0xd000) == OP_B_T4b); + } + + static bool isBX(void* address) + { + uint16_t* instruction = static_cast(address); + return (instruction[0] & 0xff87) == OP_BX; + } - // All branch offsets should be an even distance. - ASSERT(!(relative & 1)); + static bool isMOV_imm_T3(void* address) + { + uint16_t* instruction = static_cast(address); + return ((instruction[0] & 0xFBF0) == OP_MOV_imm_T3) && ((instruction[1] & 0x8000) == 0); + } - int word1 = ((relative & 0x1000000) >> 14) | ((relative & 0x3ff000) >> 12); - int word2 = ((relative & 0x800000) >> 10) | ((relative & 0x400000) >> 11) | ((relative & 0xffe) >> 1); + static bool isMOVT(void* address) + { + uint16_t* instruction = static_cast(address); + return ((instruction[0] & 0xFBF0) == OP_MOVT) && ((instruction[1] & 0x8000) == 0); + } - instruction[-2] = OP_B_T4a | word1; - instruction[-1] = OP_B_T4b | word2; + static bool isNOP_T1(void* address) + { + uint16_t* instruction = static_cast(address); + return instruction[0] == OP_NOP_T1; } - // These functions can be used to splice 16-bit immediates back into previously generated instructions. - static void spliceHi5(uint16_t* where, uint16_t what) + static bool isNOP_T2(void* address) { - uint16_t pattern = (what >> 12) | ((what & 0x0800) >> 1); - *where = (*where & 0xFBF0) | pattern; + uint16_t* instruction = static_cast(address); + return (instruction[0] == OP_NOP_T2a) && (instruction[1] == OP_NOP_T2b); } - static void spliceLo11(uint16_t* where, uint16_t what) + + static void linkJumpAbsolute(uint16_t* instruction, void* target) { - uint16_t pattern = ((what & 0x0700) << 4) | (what & 0x00FF); - *where = (*where & 0x8F00) | pattern; + // FIMXE: this should be up in the MacroAssembler layer. :-( + const uint16_t JUMP_TEMPORARY_REGISTER = ARMRegisters::ip; + + ASSERT(!(reinterpret_cast(instruction) & 1)); + ASSERT(!(reinterpret_cast(target) & 1)); + + ASSERT( (isMOV_imm_T3(instruction - 5) && isMOVT(instruction - 3) && isBX(instruction - 1)) + || (isNOP_T1(instruction - 5) && isNOP_T2(instruction - 4) && isB(instruction - 2)) ); + + intptr_t relative = reinterpret_cast(target) - (reinterpret_cast(instruction)); + if (((relative << 7) >> 7) == relative) { + // ARM encoding for the top two bits below the sign bit is 'peculiar'. + if (relative >= 0) + relative ^= 0xC00000; + + // All branch offsets should be an even distance. + ASSERT(!(relative & 1)); + // There may be a better way to fix this, but right now put the NOPs first, since in the + // case of an conditional branch this will be coming after an ITTT predicating *three* + // instructions! Looking backwards to modify the ITTT to an IT is not easy, due to + // variable wdith encoding - the previous instruction might *look* like an ITTT but + // actually be the second half of a 2-word op. + instruction[-5] = OP_NOP_T1; + instruction[-4] = OP_NOP_T2a; + instruction[-3] = OP_NOP_T2b; + instruction[-2] = OP_B_T4a | ((relative & 0x1000000) >> 14) | ((relative & 0x3ff000) >> 12); + instruction[-1] = OP_B_T4b | ((relative & 0x800000) >> 10) | ((relative & 0x400000) >> 11) | ((relative & 0xffe) >> 1); + } else { + ARMThumbImmediate lo16 = ARMThumbImmediate::makeUInt16(static_cast(reinterpret_cast(target) + 1)); + ARMThumbImmediate hi16 = ARMThumbImmediate::makeUInt16(static_cast(reinterpret_cast(target) >> 16)); + instruction[-5] = twoWordOp5i6Imm4Reg4EncodedImmFirst(OP_MOV_imm_T3, lo16); + instruction[-4] = twoWordOp5i6Imm4Reg4EncodedImmSecond(JUMP_TEMPORARY_REGISTER, lo16); + instruction[-3] = twoWordOp5i6Imm4Reg4EncodedImmFirst(OP_MOVT, hi16); + instruction[-2] = twoWordOp5i6Imm4Reg4EncodedImmSecond(JUMP_TEMPORARY_REGISTER, hi16); + instruction[-1] = OP_BX | (JUMP_TEMPORARY_REGISTER << 3); + } + } + + static uint16_t twoWordOp5i6Imm4Reg4EncodedImmFirst(uint16_t op, ARMThumbImmediate imm) + { + return op | (imm.m_value.i << 10) | imm.m_value.imm4; + } + static uint16_t twoWordOp5i6Imm4Reg4EncodedImmSecond(uint16_t rd, ARMThumbImmediate imm) + { + return (imm.m_value.imm3 << 12) | (rd << 8) | imm.m_value.imm8; } class ARMInstructionFormatter { @@ -1723,8 +1792,11 @@ private: void twoWordOp5i6Imm4Reg4EncodedImm(OpcodeID1 op, int imm4, RegisterID rd, ARMThumbImmediate imm) { - m_buffer.putShort(op | (imm.m_value.i << 10) | imm4); - m_buffer.putShort((imm.m_value.imm3 << 12) | (rd << 8) | imm.m_value.imm8); + ARMThumbImmediate newImm = imm; + newImm.m_value.imm4 = imm4; + + m_buffer.putShort(ARMv7Assembler::twoWordOp5i6Imm4Reg4EncodedImmFirst(op, newImm)); + m_buffer.putShort(ARMv7Assembler::twoWordOp5i6Imm4Reg4EncodedImmSecond(rd, newImm)); } void twoWordOp12Reg4Reg4Imm12(OpcodeID1 op, RegisterID reg1, RegisterID reg2, uint16_t imm) @@ -1749,6 +1821,8 @@ private: private: AssemblerBuffer m_buffer; } m_formatter; + + Vector m_jumpsToLink; }; } // namespace JSC diff --git a/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARM.h b/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARM.h index aa8cbb0..7a72b06 100644 --- a/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARM.h +++ b/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARM.h @@ -65,6 +65,7 @@ public: }; static const RegisterID stackPointerRegister = ARMRegisters::sp; + static const RegisterID linkRegister = ARMRegisters::lr; static const Scale ScalePtr = TimesFour; @@ -530,7 +531,7 @@ public: void ret() { - pop(ARMRegisters::pc); + m_assembler.mov_r(ARMRegisters::pc, linkRegister); } void set32(Condition cond, RegisterID left, RegisterID right, RegisterID dest) @@ -746,11 +747,9 @@ protected: void prepareCall() { - ensureSpace(3 * sizeof(ARMWord), sizeof(ARMWord)); + ensureSpace(2 * sizeof(ARMWord), sizeof(ARMWord)); - // S0 might be used for parameter passing - m_assembler.add_r(ARMRegisters::S1, ARMRegisters::pc, ARMAssembler::OP2_IMM | 0x4); - m_assembler.push_r(ARMRegisters::S1); + m_assembler.mov_r(linkRegister, ARMRegisters::pc); } void call32(RegisterID base, int32_t offset) diff --git a/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARMv7.h b/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARMv7.h index a549604..c479517 100644 --- a/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARMv7.h +++ b/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARMv7.h @@ -990,13 +990,15 @@ public: protected: ARMv7Assembler::JmpSrc makeJump() { - return m_assembler.b(); + moveFixedWidthEncoding(Imm32(0), dataTempRegister); + return m_assembler.bx(dataTempRegister); } ARMv7Assembler::JmpSrc makeBranch(ARMv7Assembler::Condition cond) { - m_assembler.it(cond); - return m_assembler.b(); + m_assembler.it(cond, true, true); + moveFixedWidthEncoding(Imm32(0), dataTempRegister); + return m_assembler.bx(dataTempRegister); } ARMv7Assembler::JmpSrc makeBranch(Condition cond) { return makeBranch(armV7Condition(cond)); } ARMv7Assembler::JmpSrc makeBranch(DoubleCondition cond) { return makeBranch(armV7Condition(cond)); } diff --git a/src/3rdparty/webkit/JavaScriptCore/bytecode/CodeBlock.cpp b/src/3rdparty/webkit/JavaScriptCore/bytecode/CodeBlock.cpp index 18ca2ae..c915934 100644 --- a/src/3rdparty/webkit/JavaScriptCore/bytecode/CodeBlock.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/bytecode/CodeBlock.cpp @@ -824,6 +824,16 @@ void CodeBlock::dump(ExecState* exec, const Vector::const_iterator& printf("[%4d] get_by_val\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str()); break; } + case op_get_by_pname: { + int r0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + int r2 = (++it)->u.operand; + int r3 = (++it)->u.operand; + int r4 = (++it)->u.operand; + int r5 = (++it)->u.operand; + printf("[%4d] get_by_pname\t %s, %s, %s, %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str(), registerName(r3).c_str(), registerName(r4).c_str(), registerName(r5).c_str()); + break; + } case op_put_by_val: { int r0 = (++it)->u.operand; int r1 = (++it)->u.operand; @@ -1015,14 +1025,17 @@ void CodeBlock::dump(ExecState* exec, const Vector::const_iterator& break; } case op_get_pnames: { - int r0 = it[0].u.operand; - int r1 = it[1].u.operand; - printf("[%4d] get_pnames\t %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str()); + int r0 = it[1].u.operand; + int r1 = it[2].u.operand; + int r2 = it[3].u.operand; + int r3 = it[4].u.operand; + int offset = it[5].u.operand; + printf("[%4d] get_pnames\t %s, %s, %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str(), registerName(r3).c_str(), offset, location + offset); it += OPCODE_LENGTH(op_get_pnames) - 1; break; } case op_next_pname: { - int dest = it[0].u.operand; + int dest = it[1].u.operand; int iter = it[4].u.operand; int offset = it[5].u.operand; printf("[%4d] next_pname\t %s, %s, %d(->%d)\n", location, registerName(dest).c_str(), registerName(iter).c_str(), offset, location + offset); diff --git a/src/3rdparty/webkit/JavaScriptCore/bytecode/Opcode.h b/src/3rdparty/webkit/JavaScriptCore/bytecode/Opcode.h index 8968252..4facbef 100644 --- a/src/3rdparty/webkit/JavaScriptCore/bytecode/Opcode.h +++ b/src/3rdparty/webkit/JavaScriptCore/bytecode/Opcode.h @@ -113,6 +113,7 @@ namespace JSC { macro(op_put_by_id_generic, 8) \ macro(op_del_by_id, 4) \ macro(op_get_by_val, 4) \ + macro(op_get_by_pname, 7) \ macro(op_put_by_val, 4) \ macro(op_del_by_val, 4) \ macro(op_put_by_index, 4) \ diff --git a/src/3rdparty/webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp b/src/3rdparty/webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp index 41b5c39..04dae15 100644 --- a/src/3rdparty/webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp @@ -1281,6 +1281,19 @@ RegisterID* BytecodeGenerator::emitDeleteById(RegisterID* dst, RegisterID* base, RegisterID* BytecodeGenerator::emitGetByVal(RegisterID* dst, RegisterID* base, RegisterID* property) { + for (size_t i = m_forInContextStack.size(); i > 0; i--) { + ForInContext& context = m_forInContextStack[i - 1]; + if (context.propertyRegister == property) { + emitOpcode(op_get_by_pname); + instructions().append(dst->index()); + instructions().append(base->index()); + instructions().append(property->index()); + instructions().append(context.expectedSubscriptRegister->index()); + instructions().append(context.iterRegister->index()); + instructions().append(context.indexRegister->index()); + return dst; + } + } emitOpcode(op_get_by_val); instructions().append(dst->index()); instructions().append(base->index()); diff --git a/src/3rdparty/webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.h b/src/3rdparty/webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.h index 61de173..4648fb5 100644 --- a/src/3rdparty/webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.h +++ b/src/3rdparty/webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.h @@ -61,6 +61,13 @@ namespace JSC { FinallyContext finallyContext; }; + struct ForInContext { + RefPtr expectedSubscriptRegister; + RefPtr iterRegister; + RefPtr indexRegister; + RefPtr propertyRegister; + }; + class BytecodeGenerator : public FastAllocBase { public: typedef DeclarationStacks::VarStack VarStack; @@ -331,6 +338,17 @@ namespace JSC { void pushFinallyContext(Label* target, RegisterID* returnAddrDst); void popFinallyContext(); + void pushOptimisedForIn(RegisterID* expectedBase, RegisterID* iter, RegisterID* index, RegisterID* propertyRegister) + { + ForInContext context = { expectedBase, iter, index, propertyRegister }; + m_forInContextStack.append(context); + } + + void popOptimisedForIn() + { + m_forInContextStack.removeLast(); + } + LabelScope* breakTarget(const Identifier&); LabelScope* continueTarget(const Identifier&); @@ -467,6 +485,7 @@ namespace JSC { Vector m_scopeContextStack; Vector m_switchContextStack; + Vector m_forInContextStack; int m_nextGlobalIndex; int m_nextParameterIndex; diff --git a/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp b/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp index 53964ad..c77a0f1 100644 --- a/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp @@ -2417,6 +2417,33 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi vPC += OPCODE_LENGTH(op_del_by_id); NEXT_INSTRUCTION(); } + DEFINE_OPCODE(op_get_by_pname) { + int dst = vPC[1].u.operand; + int base = vPC[2].u.operand; + int property = vPC[3].u.operand; + int expected = vPC[4].u.operand; + int iter = vPC[5].u.operand; + int i = vPC[6].u.operand; + + JSValue baseValue = callFrame->r(base).jsValue(); + JSPropertyNameIterator* it = callFrame->r(iter).propertyNameIterator(); + JSValue subscript = callFrame->r(property).jsValue(); + JSValue expectedSubscript = callFrame->r(expected).jsValue(); + int index = callFrame->r(i).i() - 1; + JSValue result; + int offset = 0; + if (subscript == expectedSubscript && baseValue.isCell() && (baseValue.asCell()->structure() == it->cachedStructure()) && it->getOffset(index, offset)) { + callFrame->r(dst) = asObject(baseValue)->getDirectOffset(offset); + vPC += OPCODE_LENGTH(op_get_by_pname); + NEXT_INSTRUCTION(); + } + Identifier propertyName(callFrame, subscript.toString(callFrame)); + result = baseValue.get(callFrame, propertyName); + CHECK_FOR_EXCEPTION(); + callFrame->r(dst) = result; + vPC += OPCODE_LENGTH(op_get_by_pname); + NEXT_INSTRUCTION(); + } DEFINE_OPCODE(op_get_by_val) { /* get_by_val dst(r) base(r) property(r) diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/ExecutableAllocator.h b/src/3rdparty/webkit/JavaScriptCore/jit/ExecutableAllocator.h index 1d15ef0..5c43eeb 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/ExecutableAllocator.h +++ b/src/3rdparty/webkit/JavaScriptCore/jit/ExecutableAllocator.h @@ -189,6 +189,22 @@ public: sys_dcache_flush(code, size); sys_icache_invalidate(code, size); } +#elif PLATFORM(ARM_THUMB2) && PLATFORM(LINUX) + static void cacheFlush(void* code, size_t size) + { + asm volatile ( + "push {r7}\n" + "mov r0, %0\n" + "mov r1, %1\n" + "movw r7, #0x2\n" + "movt r7, #0xf\n" + "movs r2, #0x0\n" + "svc 0x0\n" + "pop {r7}\n" + : + : "r" (code), "r" (reinterpret_cast(code) + size) + : "r0", "r1"); + } #elif PLATFORM(SYMBIAN) static void cacheFlush(void* code, size_t size) { diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JIT.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JIT.cpp index fa0ac2e..000e4b8 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JIT.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JIT.cpp @@ -239,6 +239,7 @@ void JIT::privateCompileMainPass() DEFINE_OP(op_eq_null) DEFINE_OP(op_get_by_id) DEFINE_OP(op_get_by_val) + DEFINE_OP(op_get_by_pname) DEFINE_OP(op_get_global_var) DEFINE_OP(op_get_pnames) DEFINE_OP(op_get_scoped_var) @@ -385,6 +386,7 @@ void JIT::privateCompileSlowCases() DEFINE_SLOWCASE_OP(op_eq) DEFINE_SLOWCASE_OP(op_get_by_id) DEFINE_SLOWCASE_OP(op_get_by_val) + DEFINE_SLOWCASE_OP(op_get_by_pname) DEFINE_SLOWCASE_OP(op_instanceof) DEFINE_SLOWCASE_OP(op_jfalse) DEFINE_SLOWCASE_OP(op_jnless) diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JIT.h b/src/3rdparty/webkit/JavaScriptCore/jit/JIT.h index 9406d1f..e19ea17 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JIT.h +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JIT.h @@ -38,6 +38,8 @@ #define JIT_CLASS_ALIGNMENT #endif +#define ASSERT_JIT_OFFSET(actual, expected) ASSERT_WITH_MESSAGE(actual == expected, "JIT Offset \"%s\" should be %d, not %d.\n", #expected, static_cast(actual), static_cast(expected)); + #include "CodeBlock.h" #include "Interpreter.h" #include "JITCode.h" @@ -249,7 +251,6 @@ namespace JSC { static const RegisterID timeoutCheckRegister = ARMRegisters::r5; static const RegisterID callFrameRegister = ARMRegisters::r4; - static const RegisterID ctiReturnRegister = ARMRegisters::r6; static const RegisterID regT0 = ARMRegisters::r0; static const RegisterID regT1 = ARMRegisters::r1; @@ -427,6 +428,7 @@ namespace JSC { #endif void compileGetDirectOffset(RegisterID base, RegisterID resultTag, RegisterID resultPayload, Structure* structure, size_t cachedOffset); void compileGetDirectOffset(JSObject* base, RegisterID temp, RegisterID resultTag, RegisterID resultPayload, size_t cachedOffset); + void compileGetDirectOffset(RegisterID base, RegisterID resultTag, RegisterID resultPayload, RegisterID structure, RegisterID offset); void compilePutDirectOffset(RegisterID base, RegisterID valueTag, RegisterID valuePayload, Structure* structure, size_t cachedOffset); // Arithmetic opcode helpers @@ -528,6 +530,7 @@ namespace JSC { #endif void compileGetDirectOffset(RegisterID base, RegisterID result, Structure* structure, size_t cachedOffset); void compileGetDirectOffset(JSObject* base, RegisterID temp, RegisterID result, size_t cachedOffset); + void compileGetDirectOffset(RegisterID base, RegisterID result, RegisterID structure, RegisterID offset, RegisterID scratch); void compilePutDirectOffset(RegisterID base, RegisterID value, Structure* structure, size_t cachedOffset); #if PLATFORM(X86_64) @@ -583,26 +586,26 @@ namespace JSC { #elif PLATFORM(ARM_THUMB2) // These architecture specific value are used to enable patching - see comment on op_put_by_id. static const int patchOffsetPutByIdStructure = 10; - static const int patchOffsetPutByIdExternalLoad = 20; + static const int patchOffsetPutByIdExternalLoad = 26; static const int patchLengthPutByIdExternalLoad = 12; - static const int patchOffsetPutByIdPropertyMapOffset = 40; + static const int patchOffsetPutByIdPropertyMapOffset = 46; // These architecture specific value are used to enable patching - see comment on op_get_by_id. static const int patchOffsetGetByIdStructure = 10; - static const int patchOffsetGetByIdBranchToSlowCase = 20; - static const int patchOffsetGetByIdExternalLoad = 20; + static const int patchOffsetGetByIdBranchToSlowCase = 26; + static const int patchOffsetGetByIdExternalLoad = 26; static const int patchLengthGetByIdExternalLoad = 12; - static const int patchOffsetGetByIdPropertyMapOffset = 40; - static const int patchOffsetGetByIdPutResult = 44; + static const int patchOffsetGetByIdPropertyMapOffset = 46; + static const int patchOffsetGetByIdPutResult = 50; #if ENABLE(OPCODE_SAMPLING) static const int patchOffsetGetByIdSlowCaseCall = 0; // FIMXE #else static const int patchOffsetGetByIdSlowCaseCall = 28; #endif - static const int patchOffsetOpCallCompareToJump = 10; + static const int patchOffsetOpCallCompareToJump = 16; - static const int patchOffsetMethodCheckProtoObj = 18; - static const int patchOffsetMethodCheckProtoStruct = 28; - static const int patchOffsetMethodCheckPutFunction = 46; + static const int patchOffsetMethodCheckProtoObj = 24; + static const int patchOffsetMethodCheckProtoStruct = 34; + static const int patchOffsetMethodCheckPutFunction = 58; #elif PLATFORM(ARM_TRADITIONAL) // These architecture specific value are used to enable patching - see comment on op_put_by_id. static const int patchOffsetPutByIdStructure = 4; @@ -619,7 +622,7 @@ namespace JSC { #if ENABLE(OPCODE_SAMPLING) #error "OPCODE_SAMPLING is not yet supported" #else - static const int patchOffsetGetByIdSlowCaseCall = 36; + static const int patchOffsetGetByIdSlowCaseCall = 28; #endif static const int patchOffsetOpCallCompareToJump = 12; @@ -640,7 +643,7 @@ namespace JSC { static const int sequenceGetByIdHotPathInstructionSpace = 28; static const int sequenceGetByIdHotPathConstantSpace = 3; // sequenceGetByIdSlowCase - static const int sequenceGetByIdSlowCaseInstructionSpace = 40; + static const int sequenceGetByIdSlowCaseInstructionSpace = 32; static const int sequenceGetByIdSlowCaseConstantSpace = 2; // sequencePutById static const int sequencePutByIdInstructionSpace = 28; @@ -682,6 +685,7 @@ namespace JSC { void emit_op_eq_null(Instruction*); void emit_op_get_by_id(Instruction*); void emit_op_get_by_val(Instruction*); + void emit_op_get_by_pname(Instruction*); void emit_op_get_global_var(Instruction*); void emit_op_get_scoped_var(Instruction*); void emit_op_init_arguments(Instruction*); @@ -771,6 +775,7 @@ namespace JSC { void emitSlow_op_eq(Instruction*, Vector::iterator&); void emitSlow_op_get_by_id(Instruction*, Vector::iterator&); void emitSlow_op_get_by_val(Instruction*, Vector::iterator&); + void emitSlow_op_get_by_pname(Instruction*, Vector::iterator&); void emitSlow_op_instanceof(Instruction*, Vector::iterator&); void emitSlow_op_jfalse(Instruction*, Vector::iterator&); void emitSlow_op_jnless(Instruction*, Vector::iterator&); diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITCall.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JITCall.cpp index cfaa69f..f7fcc0a 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITCall.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITCall.cpp @@ -614,7 +614,7 @@ void JIT::compileOpCall(OpcodeID opcodeID, Instruction* instruction, unsigned ca END_UNINTERRUPTED_SEQUENCE(sequenceOpCall); addSlowCase(jumpToSlow); - ASSERT(differenceBetween(addressOfLinkedFunctionCheck, jumpToSlow) == patchOffsetOpCallCompareToJump); + ASSERT_JIT_OFFSET(differenceBetween(addressOfLinkedFunctionCheck, jumpToSlow), patchOffsetOpCallCompareToJump); m_callStructureStubCompilationInfo[callLinkInfoIndex].hotPathBegin = addressOfLinkedFunctionCheck; // The following is the fast case, only used whan a callee can be linked. diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITInlineMethods.h b/src/3rdparty/webkit/JavaScriptCore/jit/JITInlineMethods.h index f26457a..93d6ce7 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITInlineMethods.h +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITInlineMethods.h @@ -144,7 +144,7 @@ ALWAYS_INLINE void JIT::endUninterruptedSequence(int insnSpace, int constSpace) #endif -#if PLATFORM(ARM_THUMB2) +#if PLATFORM(ARM) ALWAYS_INLINE void JIT::preserveReturnAddressAfterCall(RegisterID reg) { @@ -161,7 +161,7 @@ ALWAYS_INLINE void JIT::restoreReturnAddressBeforeReturn(Address address) loadPtr(address, linkRegister); } -#else // PLATFORM(X86) || PLATFORM(X86_64) || PLATFORM(ARM_TRADITIONAL) +#else // PLATFORM(X86) || PLATFORM(X86_64) ALWAYS_INLINE void JIT::preserveReturnAddressAfterCall(RegisterID reg) { @@ -191,16 +191,13 @@ ALWAYS_INLINE void JIT::restoreArgumentReference() { move(stackPointerRegister, firstArgumentRegister); poke(callFrameRegister, OBJECT_OFFSETOF(struct JITStackFrame, callFrame) / sizeof (void*)); -#if PLATFORM(ARM_TRADITIONAL) - move(ctiReturnRegister, ARMRegisters::lr); -#endif } ALWAYS_INLINE void JIT::restoreArgumentReferenceForTrampoline() { #if PLATFORM(X86) // Within a trampoline the return address will be on the stack at this point. addPtr(Imm32(sizeof(void*)), stackPointerRegister, firstArgumentRegister); -#elif PLATFORM(ARM_THUMB2) +#elif PLATFORM(ARM) move(stackPointerRegister, firstArgumentRegister); #endif // In the trampoline on x86-64, the first argument register is not overwritten. diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITOpcodes.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JITOpcodes.cpp index e10d105..14736cf 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITOpcodes.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITOpcodes.cpp @@ -1792,7 +1792,6 @@ void JIT::privateCompileCTIMachineTrampolines(RefPtr* executable // Setup arg4: This is a plain hack move(stackPointerRegister, ARMRegisters::S0); - move(ctiReturnRegister, ARMRegisters::lr); call(Address(regT1, OBJECT_OFFSETOF(JSFunction, m_data))); addPtr(Imm32(sizeof(ArgList)), stackPointerRegister); @@ -2500,7 +2499,13 @@ void JIT::emit_op_next_pname(Instruction* currentInstruction) // Grab key @ i loadPtr(addressFor(it), regT1); loadPtr(Address(regT1, OBJECT_OFFSETOF(JSPropertyNameIterator, m_jsStrings)), regT2); + +#if USE(JSVALUE64) loadPtr(BaseIndex(regT2, regT0, TimesEight), regT2); +#else + loadPtr(BaseIndex(regT2, regT0, TimesFour), regT2); +#endif + emitPutVirtualRegister(dst, regT2); // Increment i diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITPropertyAccess.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JITPropertyAccess.cpp index 4241111..bf367a6 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITPropertyAccess.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITPropertyAccess.cpp @@ -33,6 +33,7 @@ #include "JITStubCall.h" #include "JSArray.h" #include "JSFunction.h" +#include "JSPropertyNameIterator.h" #include "Interpreter.h" #include "LinkBuffer.h" #include "RepatchBuffer.h" @@ -934,6 +935,69 @@ void JIT::privateCompileGetByIdChain(StructureStubInfo* stubInfo, Structure* str #endif // !ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS) +void JIT::compileGetDirectOffset(RegisterID base, RegisterID resultTag, RegisterID resultPayload, RegisterID structure, RegisterID offset) +{ + ASSERT(sizeof(((Structure*)0)->m_propertyStorageCapacity) == sizeof(int32_t)); + ASSERT(sizeof(JSObject::inlineStorageCapacity) == sizeof(int32_t)); + ASSERT(sizeof(JSValue) == 8); + + Jump notUsingInlineStorage = branch32(NotEqual, Address(structure, OBJECT_OFFSETOF(Structure, m_propertyStorageCapacity)), Imm32(JSObject::inlineStorageCapacity)); + loadPtr(BaseIndex(base, offset, TimesEight, OBJECT_OFFSETOF(JSObject, m_inlineStorage)+OBJECT_OFFSETOF(JSValue, u.asBits.payload)), resultPayload); + loadPtr(BaseIndex(base, offset, TimesEight, OBJECT_OFFSETOF(JSObject, m_inlineStorage)+OBJECT_OFFSETOF(JSValue, u.asBits.tag)), resultTag); + Jump finishedLoad = jump(); + notUsingInlineStorage.link(this); + loadPtr(Address(base, OBJECT_OFFSETOF(JSObject, m_externalStorage)), base); + loadPtr(BaseIndex(base, offset, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.payload)), resultPayload); + loadPtr(BaseIndex(base, offset, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.tag)), resultTag); + finishedLoad.link(this); +} + +void JIT::emit_op_get_by_pname(Instruction* currentInstruction) +{ + unsigned dst = currentInstruction[1].u.operand; + unsigned base = currentInstruction[2].u.operand; + unsigned property = currentInstruction[3].u.operand; + unsigned expected = currentInstruction[4].u.operand; + unsigned iter = currentInstruction[5].u.operand; + unsigned i = currentInstruction[6].u.operand; + + emitLoad2(property, regT1, regT0, base, regT3, regT2); + emitJumpSlowCaseIfNotJSCell(property, regT1); + addSlowCase(branchPtr(NotEqual, regT0, payloadFor(expected))); + // Property registers are now available as the property is known + emitJumpSlowCaseIfNotJSCell(base, regT3); + emitLoadPayload(iter, regT1); + + // Test base's structure + loadPtr(Address(regT2, OBJECT_OFFSETOF(JSCell, m_structure)), regT0); + addSlowCase(branchPtr(NotEqual, regT0, Address(regT1, OBJECT_OFFSETOF(JSPropertyNameIterator, m_cachedStructure)))); + load32(addressFor(i), regT3); + sub32(Imm32(1), regT3); + addSlowCase(branch32(AboveOrEqual, regT3, Address(regT1, OBJECT_OFFSETOF(JSPropertyNameIterator, m_numCacheableSlots)))); + compileGetDirectOffset(regT2, regT1, regT0, regT0, regT3); + + emitStore(dst, regT1, regT0); + map(m_bytecodeIndex + OPCODE_LENGTH(op_get_by_pname), dst, regT1, regT0); +} + +void JIT::emitSlow_op_get_by_pname(Instruction* currentInstruction, Vector::iterator& iter) +{ + unsigned dst = currentInstruction[1].u.operand; + unsigned base = currentInstruction[2].u.operand; + unsigned property = currentInstruction[3].u.operand; + + linkSlowCaseIfNotJSCell(iter, property); + linkSlowCase(iter); + linkSlowCaseIfNotJSCell(iter, base); + linkSlowCase(iter); + linkSlowCase(iter); + + JITStubCall stubCall(this, cti_op_get_by_val); + stubCall.addArgument(base); + stubCall.addArgument(property); + stubCall.call(dst); +} + #else // USE(JSVALUE32_64) void JIT::emit_op_get_by_val(Instruction* currentInstruction) @@ -967,6 +1031,48 @@ void JIT::emit_op_get_by_val(Instruction* currentInstruction) emitPutVirtualRegister(dst); } +void JIT::emit_op_get_by_pname(Instruction* currentInstruction) +{ + unsigned dst = currentInstruction[1].u.operand; + unsigned base = currentInstruction[2].u.operand; + unsigned property = currentInstruction[3].u.operand; + unsigned expected = currentInstruction[4].u.operand; + unsigned iter = currentInstruction[5].u.operand; + unsigned i = currentInstruction[6].u.operand; + + emitGetVirtualRegister(property, regT0); + addSlowCase(branchPtr(NotEqual, regT0, addressFor(expected))); + emitGetVirtualRegisters(base, regT0, iter, regT1); + emitJumpSlowCaseIfNotJSCell(regT0, base); + + // Test base's structure + loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT2); + addSlowCase(branchPtr(NotEqual, regT2, Address(regT1, OBJECT_OFFSETOF(JSPropertyNameIterator, m_cachedStructure)))); + load32(addressFor(i), regT3); + sub32(Imm32(1), regT3); + addSlowCase(branch32(AboveOrEqual, regT3, Address(regT1, OBJECT_OFFSETOF(JSPropertyNameIterator, m_numCacheableSlots)))); + compileGetDirectOffset(regT0, regT0, regT2, regT3, regT1); + + emitPutVirtualRegister(dst, regT0); +} + +void JIT::emitSlow_op_get_by_pname(Instruction* currentInstruction, Vector::iterator& iter) +{ + unsigned dst = currentInstruction[1].u.operand; + unsigned base = currentInstruction[2].u.operand; + unsigned property = currentInstruction[3].u.operand; + + linkSlowCase(iter); + linkSlowCaseIfNotJSCell(iter, base); + linkSlowCase(iter); + linkSlowCase(iter); + + JITStubCall stubCall(this, cti_op_get_by_val); + stubCall.addArgument(base, regT2); + stubCall.addArgument(property, regT2); + stubCall.call(dst); +} + void JIT::emit_op_put_by_val(Instruction* currentInstruction) { unsigned base = currentInstruction[1].u.operand; @@ -1132,9 +1238,9 @@ void JIT::emit_op_method_check(Instruction* currentInstruction) Jump match = jump(); - ASSERT(differenceBetween(info.structureToCompare, protoObj) == patchOffsetMethodCheckProtoObj); - ASSERT(differenceBetween(info.structureToCompare, protoStructureToCompare) == patchOffsetMethodCheckProtoStruct); - ASSERT(differenceBetween(info.structureToCompare, putFunction) == patchOffsetMethodCheckPutFunction); + ASSERT_JIT_OFFSET(differenceBetween(info.structureToCompare, protoObj), patchOffsetMethodCheckProtoObj); + ASSERT_JIT_OFFSET(differenceBetween(info.structureToCompare, protoStructureToCompare), patchOffsetMethodCheckProtoStruct); + ASSERT_JIT_OFFSET(differenceBetween(info.structureToCompare, putFunction), patchOffsetMethodCheckPutFunction); // Link the failure cases here. notCell.link(this); @@ -1201,22 +1307,22 @@ void JIT::compileGetByIdHotPath(int, int baseVReg, Identifier*, unsigned propert DataLabelPtr structureToCompare; Jump structureCheck = branchPtrWithPatch(NotEqual, Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), structureToCompare, ImmPtr(reinterpret_cast(patchGetByIdDefaultStructure))); addSlowCase(structureCheck); - ASSERT(differenceBetween(hotPathBegin, structureToCompare) == patchOffsetGetByIdStructure); - ASSERT(differenceBetween(hotPathBegin, structureCheck) == patchOffsetGetByIdBranchToSlowCase); + ASSERT_JIT_OFFSET(differenceBetween(hotPathBegin, structureToCompare), patchOffsetGetByIdStructure); + ASSERT_JIT_OFFSET(differenceBetween(hotPathBegin, structureCheck), patchOffsetGetByIdBranchToSlowCase) Label externalLoad = loadPtrWithPatchToLEA(Address(regT0, OBJECT_OFFSETOF(JSObject, m_externalStorage)), regT0); Label externalLoadComplete(this); - ASSERT(differenceBetween(hotPathBegin, externalLoad) == patchOffsetGetByIdExternalLoad); - ASSERT(differenceBetween(externalLoad, externalLoadComplete) == patchLengthGetByIdExternalLoad); + ASSERT_JIT_OFFSET(differenceBetween(hotPathBegin, externalLoad), patchOffsetGetByIdExternalLoad); + ASSERT_JIT_OFFSET(differenceBetween(externalLoad, externalLoadComplete), patchLengthGetByIdExternalLoad); DataLabel32 displacementLabel = loadPtrWithAddressOffsetPatch(Address(regT0, patchGetByIdDefaultOffset), regT0); - ASSERT(differenceBetween(hotPathBegin, displacementLabel) == patchOffsetGetByIdPropertyMapOffset); + ASSERT_JIT_OFFSET(differenceBetween(hotPathBegin, displacementLabel), patchOffsetGetByIdPropertyMapOffset); Label putResult(this); END_UNINTERRUPTED_SEQUENCE(sequenceGetByIdHotPath); - ASSERT(differenceBetween(hotPathBegin, putResult) == patchOffsetGetByIdPutResult); + ASSERT_JIT_OFFSET(differenceBetween(hotPathBegin, putResult), patchOffsetGetByIdPutResult); } void JIT::emitSlow_op_get_by_id(Instruction* currentInstruction, Vector::iterator& iter) @@ -1251,7 +1357,7 @@ void JIT::compileGetByIdSlowCase(int resultVReg, int baseVReg, Identifier* ident END_UNINTERRUPTED_SEQUENCE(sequenceGetByIdSlowCase); - ASSERT(differenceBetween(coldPathBegin, call) == patchOffsetGetByIdSlowCaseCall); + ASSERT_JIT_OFFSET(differenceBetween(coldPathBegin, call), patchOffsetGetByIdSlowCaseCall); // Track the location of the call; this will be used to recover patch information. m_propertyAccessCompilationInfo[m_propertyAccessInstructionIndex].callReturnLocation = call; @@ -1282,19 +1388,19 @@ void JIT::emit_op_put_by_id(Instruction* currentInstruction) // It is important that the following instruction plants a 32bit immediate, in order that it can be patched over. DataLabelPtr structureToCompare; addSlowCase(branchPtrWithPatch(NotEqual, Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), structureToCompare, ImmPtr(reinterpret_cast(patchGetByIdDefaultStructure)))); - ASSERT(differenceBetween(hotPathBegin, structureToCompare) == patchOffsetPutByIdStructure); + ASSERT_JIT_OFFSET(differenceBetween(hotPathBegin, structureToCompare), patchOffsetPutByIdStructure); // Plant a load from a bogus ofset in the object's property map; we will patch this later, if it is to be used. Label externalLoad = loadPtrWithPatchToLEA(Address(regT0, OBJECT_OFFSETOF(JSObject, m_externalStorage)), regT0); Label externalLoadComplete(this); - ASSERT(differenceBetween(hotPathBegin, externalLoad) == patchOffsetPutByIdExternalLoad); - ASSERT(differenceBetween(externalLoad, externalLoadComplete) == patchLengthPutByIdExternalLoad); + ASSERT_JIT_OFFSET(differenceBetween(hotPathBegin, externalLoad), patchOffsetPutByIdExternalLoad); + ASSERT_JIT_OFFSET(differenceBetween(externalLoad, externalLoadComplete), patchLengthPutByIdExternalLoad); DataLabel32 displacementLabel = storePtrWithAddressOffsetPatch(regT1, Address(regT0, patchGetByIdDefaultOffset)); END_UNINTERRUPTED_SEQUENCE(sequencePutById); - ASSERT(differenceBetween(hotPathBegin, displacementLabel) == patchOffsetPutByIdPropertyMapOffset); + ASSERT_JIT_OFFSET(differenceBetween(hotPathBegin, displacementLabel), patchOffsetPutByIdPropertyMapOffset); } void JIT::emitSlow_op_put_by_id(Instruction* currentInstruction, Vector::iterator& iter) @@ -1351,6 +1457,20 @@ void JIT::compileGetDirectOffset(JSObject* base, RegisterID temp, RegisterID res } } +void JIT::compileGetDirectOffset(RegisterID base, RegisterID result, RegisterID structure, RegisterID offset, RegisterID scratch) +{ + ASSERT(sizeof(((Structure*)0)->m_propertyStorageCapacity) == sizeof(int32_t)); + ASSERT(sizeof(JSObject::inlineStorageCapacity) == sizeof(int32_t)); + + Jump notUsingInlineStorage = branch32(NotEqual, Address(structure, OBJECT_OFFSETOF(Structure, m_propertyStorageCapacity)), Imm32(JSObject::inlineStorageCapacity)); + loadPtr(BaseIndex(base, offset, ScalePtr, OBJECT_OFFSETOF(JSObject, m_inlineStorage)), result); + Jump finishedLoad = jump(); + notUsingInlineStorage.link(this); + loadPtr(Address(base, OBJECT_OFFSETOF(JSObject, m_externalStorage)), scratch); + loadPtr(BaseIndex(scratch, offset, ScalePtr, 0), result); + finishedLoad.link(this); +} + void JIT::testPrototype(Structure* structure, JumpList& failureCases) { if (structure->m_prototype.isNull()) diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp index 457518c..c999618 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp @@ -75,25 +75,12 @@ namespace JSC { #define THUMB_FUNC_PARAM(name) #endif -#if PLATFORM(LINUX) && (PLATFORM(X86_64) || PLATFORM(X86)) +#if PLATFORM(LINUX) && PLATFORM(X86_64) #define SYMBOL_STRING_RELOCATION(name) #name "@plt" #else #define SYMBOL_STRING_RELOCATION(name) SYMBOL_STRING(name) #endif -#if PLATFORM(DARWIN) - // Mach-O platform -#define HIDE_SYMBOL(name) ".private_extern _" #name -#elif PLATFORM(AIX) - // IBM's own file format -#define HIDE_SYMBOL(name) ".lglobl " #name -#elif PLATFORM(LINUX) || PLATFORM(FREEBSD) || PLATFORM(OPENBSD) || PLATFORM(SOLARIS) || (PLATFORM(HPUX) && PLATFORM(IA64)) || PLATFORM(SYMBIAN) || PLATFORM(NETBSD) - // ELF platform -#define HIDE_SYMBOL(name) ".hidden " #name -#else -#define HIDE_SYMBOL(name) -#endif - #if USE(JSVALUE32_64) #if COMPILER(GCC) && PLATFORM(X86) @@ -106,9 +93,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x58, JITStackFrame_ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x50, JITStackFrame_code_offset_matches_ctiTrampoline); asm volatile ( -".text\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" -HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "pushl %ebp" "\n" "movl %esp, %ebp" "\n" @@ -129,7 +114,6 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" -HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" #if !USE(JIT_STUB_ARGUMENT_VA_LIST) "movl %esp, %ecx" "\n" @@ -145,7 +129,6 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" -HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "addl $0x3c, %esp" "\n" "popl %ebx" "\n" @@ -170,7 +153,6 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x80, JITStackFrame_code_ asm volatile ( ".globl " SYMBOL_STRING(ctiTrampoline) "\n" -HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "pushq %rbp" "\n" "movq %rsp, %rbp" "\n" @@ -197,7 +179,6 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" -HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" "movq %rsp, %rdi" "\n" "call " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n" @@ -213,7 +194,6 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" -HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "addq $0x48, %rsp" "\n" "popq %rbx" "\n" @@ -235,7 +215,6 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" -HIDE_SYMBOL(ctiTrampoline) "\n" ".thumb" "\n" ".thumb_func " THUMB_FUNC_PARAM(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" @@ -262,7 +241,6 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" -HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" ".thumb" "\n" ".thumb_func " THUMB_FUNC_PARAM(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" @@ -368,9 +346,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x30, JITStackFrame_code_ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x1c, JITStackFrame_stub_argument_space_matches_ctiTrampoline); asm volatile ( -".text\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" -HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "pushl %ebp" "\n" "movl %esp, %ebp" "\n" @@ -391,7 +367,6 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" -HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" #if !USE(JIT_STUB_ARGUMENT_VA_LIST) "movl %esp, %ecx" "\n" @@ -407,7 +382,6 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" -HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "addl $0x1c, %esp" "\n" "popl %ebx" "\n" @@ -430,9 +404,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x48, JITStackFrame_code_ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x78, JITStackFrame_stub_argument_space_matches_ctiTrampoline); asm volatile ( -".text\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" -HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "pushq %rbp" "\n" "movq %rsp, %rbp" "\n" @@ -466,7 +438,6 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" -HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" "movq %rsp, %rdi" "\n" "call " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n" @@ -482,7 +453,6 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" -HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "addq $0x78, %rsp" "\n" "popq %rbx" "\n" @@ -504,7 +474,6 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" -HIDE_SYMBOL(ctiTrampoline) "\n" ".thumb" "\n" ".thumb_func " THUMB_FUNC_PARAM(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" @@ -531,7 +500,6 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" -HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" ".thumb" "\n" ".thumb_func " THUMB_FUNC_PARAM(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" @@ -549,7 +517,6 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" -HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" ".thumb" "\n" ".thumb_func " THUMB_FUNC_PARAM(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" @@ -564,45 +531,31 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" #elif COMPILER(GCC) && PLATFORM(ARM_TRADITIONAL) asm volatile ( -".text\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" -HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "stmdb sp!, {r1-r3}" "\n" "stmdb sp!, {r4-r8, lr}" "\n" - "mov r6, pc" "\n" - "add r6, r6, #40" "\n" - "sub sp, sp, #32" "\n" - "ldr r4, [sp, #60]" "\n" + "sub sp, sp, #36" "\n" + "mov r4, r2" "\n" "mov r5, #512" "\n" - // r0 contains the code - "add r8, pc, #4" "\n" - "str r8, [sp, #-4]!" "\n" + "mov lr, pc" "\n" "mov pc, r0" "\n" - "add sp, sp, #32" "\n" + "add sp, sp, #36" "\n" "ldmia sp!, {r4-r8, lr}" "\n" "add sp, sp, #12" "\n" "mov pc, lr" "\n" - - // the return instruction - "ldr pc, [sp], #4" "\n" ); asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" -HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" "mov r0, sp" "\n" - "mov lr, r6" "\n" - "add r8, pc, #4" "\n" - "str r8, [sp, #-4]!" "\n" - "b " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n" + "bl " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n" // Both has the same return sequence ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" -HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" - "add sp, sp, #32" "\n" + "add sp, sp, #36" "\n" "ldmia sp!, {r4-r8, lr}" "\n" "add sp, sp, #12" "\n" "mov pc, lr" "\n" @@ -935,7 +888,6 @@ static NEVER_INLINE void throwStackOverflowError(CallFrame* callFrame, JSGlobalD ".text" "\n" \ ".align 2" "\n" \ ".globl " SYMBOL_STRING(cti_##op) "\n" \ - HIDE_SYMBOL(cti_##op) "\n" \ ".thumb" "\n" \ ".thumb_func " THUMB_FUNC_PARAM(cti_##op) "\n" \ SYMBOL_STRING(cti_##op) ":" "\n" \ @@ -946,6 +898,22 @@ static NEVER_INLINE void throwStackOverflowError(CallFrame* callFrame, JSGlobalD ); \ rtype JITStubThunked_##op(STUB_ARGS_DECLARATION) \ +#elif PLATFORM(ARM_TRADITIONAL) && COMPILER(GCC) + +#define DEFINE_STUB_FUNCTION(rtype, op) \ + extern "C" { \ + rtype JITStubThunked_##op(STUB_ARGS_DECLARATION); \ + }; \ + asm volatile ( \ + ".globl " SYMBOL_STRING(cti_##op) "\n" \ + SYMBOL_STRING(cti_##op) ":" "\n" \ + "str lr, [sp, #32]" "\n" \ + "bl " SYMBOL_STRING(JITStubThunked_##op) "\n" \ + "ldr lr, [sp, #32]" "\n" \ + "mov pc, lr" "\n" \ + ); \ + rtype JITStubThunked_##op(STUB_ARGS_DECLARATION) + #else #define DEFINE_STUB_FUNCTION(rtype, op) rtype JIT_STUB cti_##op(STUB_ARGS_DECLARATION) #endif diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.h b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.h index ccbcd2a..69776cb 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.h +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.h @@ -163,6 +163,8 @@ namespace JSC { JITStubArg padding; // Unused JITStubArg args[7]; + ReturnAddressPtr thunkReturnAddress; + void* preservedR4; void* preservedR5; void* preservedR6; @@ -173,11 +175,13 @@ namespace JSC { RegisterFile* registerFile; CallFrame* callFrame; JSValue* exception; + + // These arguments passed on the stack. Profiler** enabledProfilerReference; JSGlobalData* globalData; // When JIT code makes a call, it pushes its return address just below the rest of the stack. - ReturnAddressPtr* returnAddressSlot() { return reinterpret_cast(this) - 1; } + ReturnAddressPtr* returnAddressSlot() { return &thunkReturnAddress; } }; #else #error "JITStackFrame not defined for this platform." diff --git a/src/3rdparty/webkit/JavaScriptCore/parser/Nodes.cpp b/src/3rdparty/webkit/JavaScriptCore/parser/Nodes.cpp index b1e317e..45009dc 100644 --- a/src/3rdparty/webkit/JavaScriptCore/parser/Nodes.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/parser/Nodes.cpp @@ -1477,6 +1477,7 @@ RegisterID* ForInNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds generator.emitNode(base.get(), m_expr); RefPtr i = generator.newTemporary(); RefPtr size = generator.newTemporary(); + RefPtr expectedSubscript; RefPtr iter = generator.emitGetPropertyNames(generator.newTemporary(), base.get(), i.get(), size.get(), scope->breakTarget()); generator.emitJump(scope->continueTarget()); @@ -1484,6 +1485,7 @@ RegisterID* ForInNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds generator.emitLabel(loopStart.get()); RegisterID* propertyName; + bool optimizedForinAccess = false; if (m_lexpr->isResolveNode()) { const Identifier& ident = static_cast(m_lexpr)->identifier(); propertyName = generator.registerFor(ident); @@ -1494,6 +1496,10 @@ RegisterID* ForInNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds generator.emitExpressionInfo(divot(), startOffset(), endOffset()); generator.emitPutById(base, ident, propertyName); + } else { + expectedSubscript = generator.emitMove(generator.newTemporary(), propertyName); + generator.pushOptimisedForIn(expectedSubscript.get(), iter.get(), i.get(), propertyName); + optimizedForinAccess = true; } } else if (m_lexpr->isDotAccessorNode()) { DotAccessorNode* assignNode = static_cast(m_lexpr); @@ -1518,6 +1524,9 @@ RegisterID* ForInNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds generator.emitNode(dst, m_statement); + if (optimizedForinAccess) + generator.popOptimisedForIn(); + generator.emitLabel(scope->continueTarget()); generator.emitNextPropertyName(propertyName, base.get(), i.get(), size.get(), iter.get(), loopStart.get()); generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine()); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp index a69115c..b885049 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp @@ -240,9 +240,7 @@ void Heap::destroy() template NEVER_INLINE CollectorBlock* Heap::allocateBlock() { - // Disable the use of vm_map for the Qt build on Darwin, because when compiled on 10.4 - // it crashes on 10.5 -#if PLATFORM(DARWIN) && !PLATFORM(QT) +#if PLATFORM(DARWIN) vm_address_t address = 0; // FIXME: tag the region as a JavaScriptCore heap when we get a registered VM tag: . vm_map(current_task(), &address, BLOCK_SIZE, BLOCK_OFFSET_MASK, VM_FLAGS_ANYWHERE | VM_TAG_FOR_COLLECTOR_MEMORY, MEMORY_OBJECT_NULL, 0, FALSE, VM_PROT_DEFAULT, VM_PROT_DEFAULT, VM_INHERIT_DEFAULT); @@ -334,9 +332,7 @@ NEVER_INLINE void Heap::freeBlock(size_t block) NEVER_INLINE void Heap::freeBlock(CollectorBlock* block) { - // Disable the use of vm_deallocate for the Qt build on Darwin, because when compiled on 10.4 - // it crashes on 10.5 -#if PLATFORM(DARWIN) && !PLATFORM(QT) +#if PLATFORM(DARWIN) vm_deallocate(current_task(), reinterpret_cast(block), BLOCK_SIZE); #elif PLATFORM(SYMBIAN) userChunk->Free(reinterpret_cast(block)); @@ -1291,6 +1287,10 @@ static const char* typeName(JSCell* cell) #endif if (cell->isGetterSetter()) return "gettersetter"; + if (cell->isAPIValueWrapper()) + return "value wrapper"; + if (cell->isPropertyNameIterator()) + return "for-in iterator"; ASSERT(cell->isObject()); const ClassInfo* info = cell->classInfo(); return info ? info->className : "Object"; diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/DateConstructor.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/DateConstructor.cpp index f9b7d84..9908fef 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/DateConstructor.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/DateConstructor.cpp @@ -112,9 +112,7 @@ JSObject* constructDate(ExecState* exec, const ArgList& args) } } - DateInstance* result = new (exec) DateInstance(exec->lexicalGlobalObject()->dateStructure()); - result->setInternalValue(jsNumber(exec, timeClip(value))); - return result; + return new (exec) DateInstance(exec, value); } static JSObject* constructWithDateConstructor(ExecState* exec, JSObject*, const ArgList& args) diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/DateInstance.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/DateInstance.cpp index 4cd58f5..d4c9ef7 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/DateInstance.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/DateInstance.cpp @@ -32,95 +32,43 @@ using namespace WTF; namespace JSC { -struct DateInstance::Cache { - double m_gregorianDateTimeCachedForMS; - GregorianDateTime m_cachedGregorianDateTime; - double m_gregorianDateTimeUTCCachedForMS; - GregorianDateTime m_cachedGregorianDateTimeUTC; -}; - const ClassInfo DateInstance::info = {"Date", 0, 0, 0}; -DateInstance::DateInstance(NonNullPassRefPtr structure) +DateInstance::DateInstance(ExecState* exec, NonNullPassRefPtr structure) : JSWrapperObject(structure) - , m_cache(0) { + setInternalValue(jsNaN(exec)); } DateInstance::DateInstance(ExecState* exec, double time) : JSWrapperObject(exec->lexicalGlobalObject()->dateStructure()) - , m_cache(0) { setInternalValue(jsNumber(exec, timeClip(time))); } -DateInstance::~DateInstance() +bool DateInstance::getGregorianDateTime(ExecState* exec, bool outputIsUTC, GregorianDateTime& t) const { - delete m_cache; -} + double milli = internalNumber(); + if (isnan(milli)) + return false; -void DateInstance::msToGregorianDateTime(double milli, bool outputIsUTC, GregorianDateTime& t) const -{ - if (!m_cache) { - m_cache = new Cache; - m_cache->m_gregorianDateTimeCachedForMS = NaN; - m_cache->m_gregorianDateTimeUTCCachedForMS = NaN; - } + if (!m_data) + m_data = exec->globalData().dateInstanceCache.add(milli); if (outputIsUTC) { - if (m_cache->m_gregorianDateTimeUTCCachedForMS != milli) { - WTF::msToGregorianDateTime(milli, true, m_cache->m_cachedGregorianDateTimeUTC); - m_cache->m_gregorianDateTimeUTCCachedForMS = milli; + if (m_data->m_gregorianDateTimeUTCCachedForMS != milli) { + WTF::msToGregorianDateTime(internalNumber(), true, m_data->m_cachedGregorianDateTimeUTC); + m_data->m_gregorianDateTimeUTCCachedForMS = milli; } - t.copyFrom(m_cache->m_cachedGregorianDateTimeUTC); + t.copyFrom(m_data->m_cachedGregorianDateTimeUTC); } else { - if (m_cache->m_gregorianDateTimeCachedForMS != milli) { - WTF::msToGregorianDateTime(milli, false, m_cache->m_cachedGregorianDateTime); - m_cache->m_gregorianDateTimeCachedForMS = milli; + if (m_data->m_gregorianDateTimeCachedForMS != milli) { + WTF::msToGregorianDateTime(internalNumber(), false, m_data->m_cachedGregorianDateTime); + m_data->m_gregorianDateTimeCachedForMS = milli; } - t.copyFrom(m_cache->m_cachedGregorianDateTime); + t.copyFrom(m_data->m_cachedGregorianDateTime); } -} -bool DateInstance::getTime(GregorianDateTime& t, int& offset) const -{ - double milli = internalNumber(); - if (isnan(milli)) - return false; - - msToGregorianDateTime(milli, false, t); - offset = gmtoffset(t); - return true; -} - -bool DateInstance::getUTCTime(GregorianDateTime& t) const -{ - double milli = internalNumber(); - if (isnan(milli)) - return false; - - msToGregorianDateTime(milli, true, t); - return true; -} - -bool DateInstance::getTime(double& milli, int& offset) const -{ - milli = internalNumber(); - if (isnan(milli)) - return false; - - GregorianDateTime t; - msToGregorianDateTime(milli, false, t); - offset = gmtoffset(t); - return true; -} - -bool DateInstance::getUTCTime(double& milli) const -{ - milli = internalNumber(); - if (isnan(milli)) - return false; - return true; } diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/DateInstance.h b/src/3rdparty/webkit/JavaScriptCore/runtime/DateInstance.h index 36d90b1..38b321c 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/DateInstance.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/DateInstance.h @@ -32,27 +32,26 @@ namespace JSC { class DateInstance : public JSWrapperObject { public: DateInstance(ExecState*, double); - explicit DateInstance(NonNullPassRefPtr); - virtual ~DateInstance(); + explicit DateInstance(ExecState*, NonNullPassRefPtr); double internalNumber() const { return internalValue().uncheckedGetNumber(); } - bool getTime(WTF::GregorianDateTime&, int& offset) const; - bool getUTCTime(WTF::GregorianDateTime&) const; - bool getTime(double& milliseconds, int& offset) const; - bool getUTCTime(double& milliseconds) const; - static JS_EXPORTDATA const ClassInfo info; - void msToGregorianDateTime(double, bool outputIsUTC, WTF::GregorianDateTime&) const; + bool getGregorianDateTime(ExecState*, bool outputIsUTC, WTF::GregorianDateTime&) const; + + static PassRefPtr createStructure(JSValue prototype) + { + return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags)); + } + + protected: + static const unsigned StructureFlags = OverridesMarkChildren | JSWrapperObject::StructureFlags; private: virtual const ClassInfo* classInfo() const { return &info; } - using JSWrapperObject::internalValue; - - struct Cache; - mutable Cache* m_cache; + mutable RefPtr m_data; }; DateInstance* asDateInstance(JSValue); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/DateInstanceCache.h b/src/3rdparty/webkit/JavaScriptCore/runtime/DateInstanceCache.h new file mode 100644 index 0000000..b626c1d --- /dev/null +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/DateInstanceCache.h @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DateInstanceCache_h +#define DateInstanceCache_h + +#include +#include +#include +#include + +namespace JSC { + + extern const double NaN; + + class DateInstanceData : public RefCounted { + public: + static PassRefPtr create() { return adoptRef(new DateInstanceData); } + + double m_gregorianDateTimeCachedForMS; + WTF::GregorianDateTime m_cachedGregorianDateTime; + double m_gregorianDateTimeUTCCachedForMS; + WTF::GregorianDateTime m_cachedGregorianDateTimeUTC; + + private: + DateInstanceData() + : m_gregorianDateTimeCachedForMS(NaN) + , m_gregorianDateTimeUTCCachedForMS(NaN) + { + } + }; + + class DateInstanceCache { + public: + DateInstanceCache() + { + for (size_t i = 0; i < cacheSize; ++i) + m_cache[i].key = NaN; + } + + DateInstanceData* add(double d) + { + CacheEntry& entry = lookup(d); + if (d == entry.key) + return entry.value.get(); + + entry.key = d; + entry.value = DateInstanceData::create(); + return entry.value.get(); + } + + private: + static const size_t cacheSize = 64; + + struct CacheEntry { + double key; + RefPtr value; + }; + + CacheEntry& lookup(double d) { return m_cache[WTF::FloatHash::hash(d) & (cacheSize - 1)]; } + + CacheEntry m_cache[cacheSize]; + }; + +} // namespace JSC + +#endif // DateInstanceCache_h diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/DatePrototype.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/DatePrototype.cpp index e46ab67..3f3e1f9 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/DatePrototype.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/DatePrototype.cpp @@ -251,11 +251,12 @@ static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, L return jsNontrivialString(exec, timebuffer); } -static JSCell* formatLocaleDate(ExecState* exec, DateInstance* dateObject, double timeInMilliseconds, LocaleDateTimeFormat format, const ArgList&) +static JSCell* formatLocaleDate(ExecState* exec, DateInstance* dateObject, double, LocaleDateTimeFormat format, const ArgList&) { GregorianDateTime gregorianDateTime; - const bool notUTC = false; - dateObject->msToGregorianDateTime(timeInMilliseconds, notUTC, gregorianDateTime); + const bool outputIsUTC = false; + if (!dateObject->getGregorianDateTime(exec, outputIsUTC, gregorianDateTime)) + return jsNontrivialString(exec, "Invalid Date"); return formatLocaleDate(exec, gregorianDateTime, format); } @@ -396,9 +397,8 @@ const ClassInfo DatePrototype::info = {"Date", &DateInstance::info, 0, ExecState // ECMA 15.9.4 DatePrototype::DatePrototype(ExecState* exec, NonNullPassRefPtr structure) - : DateInstance(structure) + : DateInstance(exec, structure) { - setInternalValue(jsNaN(exec)); // The constructor will be added later, after DateConstructor has been built. } @@ -420,16 +420,14 @@ JSValue JSC_HOST_CALL dateProtoFuncToString(ExecState* exec, JSObject*, JSValue if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = false; + const bool outputIsUTC = false; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNontrivialString(exec, "Invalid Date"); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); - return jsNontrivialString(exec, formatDate(t) + " " + formatTime(t, utc)); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNontrivialString(exec, "Invalid Date"); + return jsNontrivialString(exec, formatDate(t) + " " + formatTime(t, outputIsUTC)); } JSValue JSC_HOST_CALL dateProtoFuncToUTCString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) @@ -437,16 +435,14 @@ JSValue JSC_HOST_CALL dateProtoFuncToUTCString(ExecState* exec, JSObject*, JSVal if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = true; + const bool outputIsUTC = true; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNontrivialString(exec, "Invalid Date"); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); - return jsNontrivialString(exec, formatDateUTCVariant(t) + " " + formatTime(t, utc)); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNontrivialString(exec, "Invalid Date"); + return jsNontrivialString(exec, formatDateUTCVariant(t) + " " + formatTime(t, outputIsUTC)); } JSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) @@ -454,19 +450,17 @@ JSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState* exec, JSObject*, JSVal if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = true; + const bool outputIsUTC = true; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (!isfinite(milli)) - return jsNontrivialString(exec, "Invalid Date"); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNontrivialString(exec, "Invalid Date"); // Maximum amount of space we need in buffer: 6 (max. digits in year) + 2 * 5 (2 characters each for month, day, hour, minute, second) + 4 (. + 3 digits for milliseconds) // 6 for formatting and one for null termination = 27. We add one extra character to allow us to force null termination. char buffer[28]; - snprintf(buffer, sizeof(buffer) - 1, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", 1900 + t.year, t.month + 1, t.monthDay, t.hour, t.minute, t.second, static_cast(fmod(milli, 1000))); + snprintf(buffer, sizeof(buffer) - 1, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", 1900 + t.year, t.month + 1, t.monthDay, t.hour, t.minute, t.second, static_cast(fmod(thisDateObj->internalNumber(), 1000))); buffer[sizeof(buffer) - 1] = 0; return jsNontrivialString(exec, buffer); } @@ -476,15 +470,13 @@ JSValue JSC_HOST_CALL dateProtoFuncToDateString(ExecState* exec, JSObject*, JSVa if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = false; + const bool outputIsUTC = false; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNontrivialString(exec, "Invalid Date"); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNontrivialString(exec, "Invalid Date"); return jsNontrivialString(exec, formatDate(t)); } @@ -493,16 +485,14 @@ JSValue JSC_HOST_CALL dateProtoFuncToTimeString(ExecState* exec, JSObject*, JSVa if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = false; + const bool outputIsUTC = false; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNontrivialString(exec, "Invalid Date"); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); - return jsNontrivialString(exec, formatTime(t, utc)); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNontrivialString(exec, "Invalid Date"); + return jsNontrivialString(exec, formatTime(t, outputIsUTC)); } JSValue JSC_HOST_CALL dateProtoFuncToLocaleString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) @@ -511,11 +501,7 @@ JSValue JSC_HOST_CALL dateProtoFuncToLocaleString(ExecState* exec, JSObject*, JS return throwError(exec, TypeError); DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNontrivialString(exec, "Invalid Date"); - - return formatLocaleDate(exec, thisDateObj, milli, LocaleDateAndTime, args); + return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDateAndTime, args); } JSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) @@ -524,11 +510,7 @@ JSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState* exec, JSObject* return throwError(exec, TypeError); DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNontrivialString(exec, "Invalid Date"); - - return formatLocaleDate(exec, thisDateObj, milli, LocaleDate, args); + return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDate, args); } JSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) @@ -537,11 +519,7 @@ JSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState* exec, JSObject* return throwError(exec, TypeError); DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNontrivialString(exec, "Invalid Date"); - - return formatLocaleDate(exec, thisDateObj, milli, LocaleTime, args); + return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleTime, args); } JSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) @@ -549,12 +527,7 @@ JSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState* exec, JSObject*, JSValue t if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNaN(exec); - - return jsNumber(exec, milli); + return asDateInstance(thisValue)->internalValue(); } JSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) @@ -562,15 +535,13 @@ JSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState* exec, JSObject*, JSVal if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = false; + const bool outputIsUTC = false; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNaN(exec); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNaN(exec); return jsNumber(exec, 1900 + t.year); } @@ -579,15 +550,13 @@ JSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState* exec, JSObject*, JS if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = true; + const bool outputIsUTC = true; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNaN(exec); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNaN(exec); return jsNumber(exec, 1900 + t.year); } @@ -596,16 +565,14 @@ JSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState* exec, JSObject*, JSVal if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = true; + const bool outputIsUTC = true; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNontrivialString(exec, "Invalid Date"); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); - return jsNontrivialString(exec, formatDateUTCVariant(t) + " " + formatTime(t, utc)); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNontrivialString(exec, "Invalid Date"); + return jsNontrivialString(exec, formatDateUTCVariant(t) + " " + formatTime(t, outputIsUTC)); } JSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) @@ -613,15 +580,13 @@ JSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState* exec, JSObject*, JSValue if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = false; + const bool outputIsUTC = false; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNaN(exec); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNaN(exec); return jsNumber(exec, t.month); } @@ -630,15 +595,13 @@ JSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState* exec, JSObject*, JSVal if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = true; + const bool outputIsUTC = true; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNaN(exec); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNaN(exec); return jsNumber(exec, t.month); } @@ -647,15 +610,13 @@ JSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState* exec, JSObject*, JSValue t if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = false; + const bool outputIsUTC = false; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNaN(exec); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNaN(exec); return jsNumber(exec, t.monthDay); } @@ -664,15 +625,13 @@ JSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState* exec, JSObject*, JSValu if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = true; + const bool outputIsUTC = true; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNaN(exec); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNaN(exec); return jsNumber(exec, t.monthDay); } @@ -681,15 +640,13 @@ JSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState* exec, JSObject*, JSValue th if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = false; + const bool outputIsUTC = false; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNaN(exec); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNaN(exec); return jsNumber(exec, t.weekDay); } @@ -698,15 +655,13 @@ JSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState* exec, JSObject*, JSValue if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = true; + const bool outputIsUTC = true; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNaN(exec); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNaN(exec); return jsNumber(exec, t.weekDay); } @@ -715,15 +670,13 @@ JSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState* exec, JSObject*, JSValue if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = false; + const bool outputIsUTC = false; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNaN(exec); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNaN(exec); return jsNumber(exec, t.hour); } @@ -732,15 +685,13 @@ JSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState* exec, JSObject*, JSVal if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = true; + const bool outputIsUTC = true; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNaN(exec); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNaN(exec); return jsNumber(exec, t.hour); } @@ -749,15 +700,13 @@ JSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState* exec, JSObject*, JSValu if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = false; + const bool outputIsUTC = false; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNaN(exec); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNaN(exec); return jsNumber(exec, t.minute); } @@ -766,15 +715,13 @@ JSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState* exec, JSObject*, JSV if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = true; + const bool outputIsUTC = true; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNaN(exec); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNaN(exec); return jsNumber(exec, t.minute); } @@ -783,15 +730,13 @@ JSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState* exec, JSObject*, JSValu if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = false; + const bool outputIsUTC = false; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNaN(exec); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNaN(exec); return jsNumber(exec, t.second); } @@ -800,15 +745,13 @@ JSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState* exec, JSObject*, JSV if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = true; + const bool outputIsUTC = true; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNaN(exec); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNaN(exec); return jsNumber(exec, t.second); } @@ -847,15 +790,13 @@ JSValue JSC_HOST_CALL dateProtoFuncGetTimezoneOffset(ExecState* exec, JSObject*, if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = false; + const bool outputIsUTC = false; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNaN(exec); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNaN(exec); return jsNumber(exec, -gmtoffset(t) / minutesPerHour); } @@ -890,7 +831,7 @@ static JSValue setNewValueFromTimeArgs(ExecState* exec, JSValue thisValue, const double ms = milli - secs * msPerSecond; GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, inputIsUTC, t); + thisDateObj->getGregorianDateTime(exec, inputIsUTC, t); if (!fillStructuresUsingTimeArgs(exec, args, numArgsToUse, &ms, &t)) { JSValue result = jsNaN(exec); @@ -922,11 +863,11 @@ static JSValue setNewValueFromDateArgs(ExecState* exec, JSValue thisValue, const if (numArgsToUse == 3 && isnan(milli)) // Based on ECMA 262 15.9.5.40 - .41 (set[UTC]FullYear) // the time must be reset to +0 if it is NaN. - thisDateObj->msToGregorianDateTime(0, true, t); + WTF::msToGregorianDateTime(0, true, t); else { double secs = floor(milli / msPerSecond); ms = milli - secs * msPerSecond; - thisDateObj->msToGregorianDateTime(milli, inputIsUTC, t); + thisDateObj->getGregorianDateTime(exec, inputIsUTC, t); } if (!fillStructuresUsingDateArgs(exec, args, numArgsToUse, &ms, &t)) { @@ -1029,7 +970,7 @@ JSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState* exec, JSObject*, JSValue t if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = false; + const bool outputIsUTC = false; DateInstance* thisDateObj = asDateInstance(thisValue); if (args.isEmpty()) { @@ -1045,11 +986,11 @@ JSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState* exec, JSObject*, JSValue t if (isnan(milli)) // Based on ECMA 262 B.2.5 (setYear) // the time must be reset to +0 if it is NaN. - thisDateObj->msToGregorianDateTime(0, true, t); + WTF::msToGregorianDateTime(0, true, t); else { double secs = floor(milli / msPerSecond); ms = milli - secs * msPerSecond; - thisDateObj->msToGregorianDateTime(milli, utc, t); + thisDateObj->getGregorianDateTime(exec, outputIsUTC, t); } bool ok = true; @@ -1061,7 +1002,7 @@ JSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState* exec, JSObject*, JSValue t } t.year = (year > 99 || year < 0) ? year - 1900 : year; - JSValue result = jsNumber(exec, gregorianDateTimeToMS(t, ms, utc)); + JSValue result = jsNumber(exec, gregorianDateTimeToMS(t, ms, outputIsUTC)); thisDateObj->setInternalValue(result); return result; } @@ -1071,15 +1012,13 @@ JSValue JSC_HOST_CALL dateProtoFuncGetYear(ExecState* exec, JSObject*, JSValue t if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); - const bool utc = false; + const bool outputIsUTC = false; DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = thisDateObj->internalNumber(); - if (isnan(milli)) - return jsNaN(exec); GregorianDateTime t; - thisDateObj->msToGregorianDateTime(milli, utc, t); + if (!thisDateObj->getGregorianDateTime(exec, outputIsUTC, t)) + return jsNaN(exec); // NOTE: IE returns the full year even in getYear. return jsNumber(exec, t.year); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/DatePrototype.h b/src/3rdparty/webkit/JavaScriptCore/runtime/DatePrototype.h index 5fe4f47..f565775 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/DatePrototype.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/DatePrototype.h @@ -43,7 +43,7 @@ namespace JSC { } protected: - static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesMarkChildren | DateInstance::StructureFlags; + static const unsigned StructureFlags = OverridesGetOwnPropertySlot | DateInstance::StructureFlags; }; diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSCell.h b/src/3rdparty/webkit/JavaScriptCore/runtime/JSCell.h index 16a5131..722ae33 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSCell.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSCell.h @@ -59,6 +59,7 @@ namespace JSC { virtual bool isGetterSetter() const; bool inherits(const ClassInfo*) const; virtual bool isAPIValueWrapper() const { return false; } + virtual bool isPropertyNameIterator() const { return false; } Structure* structure() const; diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSFunction.h b/src/3rdparty/webkit/JavaScriptCore/runtime/JSFunction.h index b4356c4..fcac9aa 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSFunction.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSFunction.h @@ -66,7 +66,7 @@ namespace JSC { NativeFunction nativeFunction() { - return *reinterpret_cast(m_data); + return *WTF::bitwise_cast(m_data); } virtual ConstructType getConstructData(ConstructData&); @@ -97,7 +97,7 @@ namespace JSC { ScopeChain& scopeChain() { ASSERT(!isHostFunctionNonInline()); - return *reinterpret_cast(m_data); + return *WTF::bitwise_cast(m_data); } void clearScopeChain() { @@ -112,11 +112,11 @@ namespace JSC { void setScopeChain(const ScopeChain& sc) { ASSERT(!isHostFunctionNonInline()); - *reinterpret_cast(m_data) = sc; + *WTF::bitwise_cast(m_data) = sc; } void setNativeFunction(NativeFunction func) { - *reinterpret_cast(m_data) = func; + *WTF::bitwise_cast(m_data) = func; } unsigned char m_data[sizeof(void*)]; }; diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalData.h b/src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalData.h index 3ad90ad..d2aa2da 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalData.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalData.h @@ -30,6 +30,7 @@ #define JSGlobalData_h #include "Collector.h" +#include "DateInstanceCache.h" #include "ExecutableAllocator.h" #include "JITStubs.h" #include "JSValue.h" @@ -116,7 +117,8 @@ namespace JSC { const MarkedArgumentBuffer* emptyList; // Lists are supposed to be allocated on the stack to have their elements properly marked, which is not the case here - but this list has nothing to mark. SmallStrings smallStrings; NumericStrings numericStrings; - + DateInstanceCache dateInstanceCache; + #if ENABLE(ASSEMBLER) ExecutableAllocator executableAllocator; #endif diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.h b/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.h index 1dbab94..5a89c40 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.h @@ -202,8 +202,8 @@ namespace JSC { void allocatePropertyStorageInline(size_t oldSize, size_t newSize); bool isUsingInlineStorage() const { return m_structure->isUsingInlineStorage(); } - static const size_t inlineStorageCapacity = sizeof(EncodedJSValue) == 2 * sizeof(void*) ? 4 : 3; - static const size_t nonInlineBaseStorageCapacity = 16; + static const unsigned inlineStorageCapacity = sizeof(EncodedJSValue) == 2 * sizeof(void*) ? 4 : 3; + static const unsigned nonInlineBaseStorageCapacity = 16; static PassRefPtr createStructure(JSValue prototype) { diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSPropertyNameIterator.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/JSPropertyNameIterator.cpp index 2cd9f75..6fd0344 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSPropertyNameIterator.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSPropertyNameIterator.cpp @@ -43,7 +43,12 @@ JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, JSObject PropertyNameArray propertyNames(exec); o->getPropertyNames(exec, propertyNames); - JSPropertyNameIterator* jsPropertyNameIterator = new (exec) JSPropertyNameIterator(exec, propertyNames.data()); + size_t numCacheableSlots = 0; + if (!o->structure()->hasNonEnumerableProperties() && !o->structure()->hasAnonymousSlots() && + !o->structure()->isUncacheableDictionary() && !o->structure()->typeInfo().overridesGetPropertyNames()) + numCacheableSlots = o->structure()->propertyStorageSize(); + + JSPropertyNameIterator* jsPropertyNameIterator = new (exec) JSPropertyNameIterator(exec, propertyNames.data(), numCacheableSlots); if (o->structure()->isDictionary()) return jsPropertyNameIterator; diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSPropertyNameIterator.h b/src/3rdparty/webkit/JavaScriptCore/runtime/JSPropertyNameIterator.h index 0559e0b..529ae8b 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSPropertyNameIterator.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSPropertyNameIterator.h @@ -50,8 +50,18 @@ namespace JSC { return Structure::create(prototype, TypeInfo(CompoundType, OverridesMarkChildren)); } + virtual bool isPropertyNameIterator() const { return true; } + virtual void markChildren(MarkStack&); + bool getOffset(size_t i, int& offset) + { + if (i >= m_numCacheableSlots) + return false; + offset = i; + return true; + } + JSValue get(ExecState*, JSObject*, size_t i); size_t size() { return m_jsStringsSize; } @@ -62,17 +72,19 @@ namespace JSC { StructureChain* cachedPrototypeChain() { return m_cachedPrototypeChain.get(); } private: - JSPropertyNameIterator(ExecState*, PropertyNameArrayData* propertyNameArrayData); + JSPropertyNameIterator(ExecState*, PropertyNameArrayData* propertyNameArrayData, size_t numCacheableSlot); Structure* m_cachedStructure; RefPtr m_cachedPrototypeChain; - size_t m_jsStringsSize; + uint32_t m_numCacheableSlots; + uint32_t m_jsStringsSize; OwnArrayPtr m_jsStrings; }; -inline JSPropertyNameIterator::JSPropertyNameIterator(ExecState* exec, PropertyNameArrayData* propertyNameArrayData) +inline JSPropertyNameIterator::JSPropertyNameIterator(ExecState* exec, PropertyNameArrayData* propertyNameArrayData, size_t numCacheableSlots) : JSCell(exec->globalData().propertyNameIteratorStructure.get()) , m_cachedStructure(0) + , m_numCacheableSlots(numCacheableSlots) , m_jsStringsSize(propertyNameArrayData->propertyNameVector().size()) , m_jsStrings(new JSValue[m_jsStringsSize]) { diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.cpp index a11050f..65b62f9 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.cpp @@ -375,6 +375,7 @@ PassRefPtr Structure::addPropertyTransition(Structure* structure, con transition->m_specificValueInPrevious = specificValue; transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties; + transition->m_hasNonEnumerableProperties = structure->m_hasNonEnumerableProperties; if (structure->m_propertyTable) { if (structure->m_isPinnedPropertyTable) @@ -417,6 +418,7 @@ PassRefPtr Structure::changePrototypeTransition(Structure* structure, transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties; + transition->m_hasNonEnumerableProperties = structure->m_hasNonEnumerableProperties; // Don't set m_offset, as one can not transition to this. @@ -433,6 +435,7 @@ PassRefPtr Structure::despecifyFunctionTransition(Structure* structur transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties; + transition->m_hasNonEnumerableProperties = structure->m_hasNonEnumerableProperties; // Don't set m_offset, as one can not transition to this. @@ -464,6 +467,7 @@ PassRefPtr Structure::addAnonymousSlotsTransition(Structure* structur transition->m_specificValueInPrevious = 0; transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties; + transition->m_hasNonEnumerableProperties = structure->m_hasNonEnumerableProperties; if (structure->m_propertyTable) { if (structure->m_isPinnedPropertyTable) @@ -492,6 +496,7 @@ PassRefPtr Structure::getterSetterTransition(Structure* structure) RefPtr transition = create(structure->storedPrototype(), structure->typeInfo()); transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; transition->m_hasGetterSetterProperties = transition->m_hasGetterSetterProperties; + transition->m_hasNonEnumerableProperties = structure->m_hasNonEnumerableProperties; // Don't set m_offset, as one can not transition to this. @@ -510,6 +515,7 @@ PassRefPtr Structure::toDictionaryTransition(Structure* structure, Di transition->m_dictionaryKind = kind; transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties; + transition->m_hasNonEnumerableProperties = structure->m_hasNonEnumerableProperties; structure->materializePropertyMapIfNecessary(); transition->m_propertyTable = structure->copyPropertyTable(); @@ -550,6 +556,9 @@ size_t Structure::addPropertyWithoutTransition(const Identifier& propertyName, u materializePropertyMapIfNecessary(); m_isPinnedPropertyTable = true; + if (attributes & DontEnum) + m_hasNonEnumerableProperties = true; + size_t offset = put(propertyName, attributes, specificValue); if (propertyStorageSize() > propertyStorageCapacity()) growPropertyStorageCapacity(); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h index 2496c1b..f355c53 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h @@ -95,8 +95,8 @@ namespace JSC { Structure* previousID() const { return m_previous.get(); } void growPropertyStorageCapacity(); - size_t propertyStorageCapacity() const { return m_propertyStorageCapacity; } - size_t propertyStorageSize() const { return m_propertyTable ? m_propertyTable->keyCount + m_propertyTable->anonymousSlotCount + (m_propertyTable->deletedOffsets ? m_propertyTable->deletedOffsets->size() : 0) : m_offset + 1; } + unsigned propertyStorageCapacity() const { return m_propertyStorageCapacity; } + unsigned propertyStorageSize() const { return m_propertyTable ? m_propertyTable->keyCount + m_propertyTable->anonymousSlotCount + (m_propertyTable->deletedOffsets ? m_propertyTable->deletedOffsets->size() : 0) : m_offset + 1; } bool isUsingInlineStorage() const; size_t get(const Identifier& propertyName); @@ -119,6 +119,10 @@ namespace JSC { bool hasGetterSetterProperties() const { return m_hasGetterSetterProperties; } void setHasGetterSetterProperties(bool hasGetterSetterProperties) { m_hasGetterSetterProperties = hasGetterSetterProperties; } + bool hasNonEnumerableProperties() const { return m_hasNonEnumerableProperties; } + + bool hasAnonymousSlots() const { return m_propertyTable && m_propertyTable->anonymousSlotCount; } + bool isEmpty() const { return m_propertyTable ? !m_propertyTable->keyCount : m_offset == noOffset; } JSCell* specificValue() { return m_specificValueInPrevious; } @@ -190,12 +194,13 @@ namespace JSC { PropertyMapHashTable* m_propertyTable; - size_t m_propertyStorageCapacity; + uint32_t m_propertyStorageCapacity; signed char m_offset; unsigned m_dictionaryKind : 2; bool m_isPinnedPropertyTable : 1; bool m_hasGetterSetterProperties : 1; + bool m_hasNonEnumerableProperties : 1; #if COMPILER(WINSCW) // Workaround for Symbian WINSCW compiler that cannot resolve unsigned type of the declared // bitfield, when used as argument in make_pair() function calls in structure.ccp. diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/CurrentTime.cpp b/src/3rdparty/webkit/JavaScriptCore/wtf/CurrentTime.cpp index a3d5290..b36cae5 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/CurrentTime.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/CurrentTime.cpp @@ -63,6 +63,10 @@ extern "C" time_t mktime(struct tm *t); #include #endif +#if PLATFORM(CHROMIUM) +#error Chromium uses a different timer implementation +#endif + namespace WTF { const double msPerSecond = 1000.0; diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/DateMath.cpp b/src/3rdparty/webkit/JavaScriptCore/wtf/DateMath.cpp index 0386494..2110432 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/DateMath.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/DateMath.cpp @@ -501,13 +501,13 @@ double gregorianDateTimeToMS(const GregorianDateTime& t, double milliSeconds, bo return result; } +// input is UTC void msToGregorianDateTime(double ms, bool outputIsUTC, GregorianDateTime& tm) { - // input is UTC double dstOff = 0.0; - const double utcOff = getUTCOffset(); - - if (!outputIsUTC) { // convert to local time + double utcOff = 0.0; + if (!outputIsUTC) { + utcOff = getUTCOffset(); dstOff = getDSTOffset(ms, utcOff); ms += dstOff + utcOff; } @@ -522,8 +522,7 @@ void msToGregorianDateTime(double ms, bool outputIsUTC, GregorianDateTime& tm) tm.month = monthFromDayInYear(tm.yearDay, isLeapYear(year)); tm.year = year - 1900; tm.isDST = dstOff != 0.0; - - tm.utcOffset = outputIsUTC ? 0 : static_cast((dstOff + utcOff) / msPerSecond); + tm.utcOffset = static_cast((dstOff + utcOff) / msPerSecond); tm.timeZone = NULL; } diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/FastMalloc.h b/src/3rdparty/webkit/JavaScriptCore/wtf/FastMalloc.h index ca0961c..541b05d 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/FastMalloc.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/FastMalloc.h @@ -26,13 +26,19 @@ #include #include +#if COMPILER(GCC) +#define WTF_FAST_MALLOC_EXPORT __attribute__((visibility("default"))) +#else +#define WTF_FAST_MALLOC_EXPORT +#endif + namespace WTF { // These functions call CRASH() if an allocation fails. - void* fastMalloc(size_t); + void* fastMalloc(size_t) WTF_FAST_MALLOC_EXPORT; void* fastZeroedMalloc(size_t); - void* fastCalloc(size_t numElements, size_t elementSize); - void* fastRealloc(void*, size_t); + void* fastCalloc(size_t numElements, size_t elementSize) WTF_FAST_MALLOC_EXPORT; + void* fastRealloc(void*, size_t) WTF_FAST_MALLOC_EXPORT; struct TryMallocReturnValue { TryMallocReturnValue(void* data) @@ -71,7 +77,7 @@ namespace WTF { TryMallocReturnValue tryFastCalloc(size_t n_elements, size_t element_size); TryMallocReturnValue tryFastRealloc(void* p, size_t n); - void fastFree(void*); + void fastFree(void*) WTF_FAST_MALLOC_EXPORT; #ifndef NDEBUG void fastMallocForbid(); diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/MessageQueue.h b/src/3rdparty/webkit/JavaScriptCore/wtf/MessageQueue.h index 12291cc..9c9a4a7 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/MessageQueue.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/MessageQueue.h @@ -55,9 +55,13 @@ namespace WTF { bool waitForMessage(DataType&); template MessageQueueWaitResult waitForMessageFilteredWithTimeout(DataType&, Predicate&, double absoluteTime); - void kill(); + + template + void removeIf(Predicate&); bool tryGetMessage(DataType&); + + void kill(); bool killed() const; // The result of isEmpty() is only valid if no other thread is manipulating the queue at the same time. @@ -149,6 +153,17 @@ namespace WTF { } template + template + inline void MessageQueue::removeIf(Predicate& predicate) + { + MutexLocker lock(m_mutex); + DequeConstIterator found = m_queue.end(); + while ((found = m_queue.findIf(predicate)) != m_queue.end()) { + m_queue.remove(found); + } + } + + template inline bool MessageQueue::isEmpty() { MutexLocker lock(m_mutex); diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h index 7151b514..7632435 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h @@ -466,6 +466,7 @@ #if PLATFORM(MAC) && !PLATFORM(IPHONE) #define WTF_PLATFORM_CF 1 #define WTF_USE_PTHREADS 1 +#define HAVE_PTHREAD_RWLOCK 1 #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_TIGER) && defined(__x86_64__) #define WTF_USE_PLUGIN_HOST_PROCESS 1 #endif @@ -482,6 +483,7 @@ #if PLATFORM(CHROMIUM) && PLATFORM(DARWIN) #define WTF_PLATFORM_CF 1 #define WTF_USE_PTHREADS 1 +#define HAVE_PTHREAD_RWLOCK 1 #endif #if PLATFORM(IPHONE) @@ -498,6 +500,7 @@ #define HAVE_READLINE 1 #define WTF_PLATFORM_CF 1 #define WTF_USE_PTHREADS 1 +#define HAVE_PTHREAD_RWLOCK 1 #endif #if PLATFORM(WIN) @@ -511,6 +514,7 @@ #if PLATFORM(GTK) #if HAVE(PTHREAD_H) #define WTF_USE_PTHREADS 1 +#define HAVE_PTHREAD_RWLOCK 1 #endif #endif @@ -518,6 +522,7 @@ #define HAVE_POSIX_MEMALIGN 1 #define WTF_USE_CURL 1 #define WTF_USE_PTHREADS 1 +#define HAVE_PTHREAD_RWLOCK 1 #define USE_SYSTEM_MALLOC 1 #define ENABLE_NETSCAPE_PLUGIN_API 0 #endif @@ -698,7 +703,7 @@ #endif #if !defined(WTF_USE_JSVALUE64) && !defined(WTF_USE_JSVALUE32) && !defined(WTF_USE_JSVALUE32_64) -#if PLATFORM(X86_64) && (PLATFORM(DARWIN) || PLATFORM(LINUX)) +#if PLATFORM(X86_64) && (PLATFORM(DARWIN) || PLATFORM(LINUX) || PLATFORM(WIN_OS)) #define WTF_USE_JSVALUE64 1 #elif PLATFORM(ARM) || PLATFORM(PPC64) #define WTF_USE_JSVALUE32 1 @@ -725,8 +730,7 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */ #define ENABLE_JIT 1 #define WTF_USE_JIT_STUB_ARGUMENT_VA_LIST 1 #elif PLATFORM(ARM_THUMB2) && PLATFORM(IPHONE) - /* Under development, temporarily disabled until 16Mb link range limit in assembler is fixed. */ - #define ENABLE_JIT 0 + #define ENABLE_JIT 1 #define ENABLE_JIT_OPTIMIZE_NATIVE_CALL 0 /* The JIT is tested & working on x86 Windows */ #elif PLATFORM(X86) && PLATFORM(WIN) @@ -792,8 +796,7 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */ /* YARR supports x86 & x86-64, and has been tested on Mac and Windows. */ #if (PLATFORM(X86) && PLATFORM(MAC)) \ || (PLATFORM(X86_64) && PLATFORM(MAC)) \ - /* Under development, temporarily disabled until 16Mb link range limit in assembler is fixed. */ \ - || (PLATFORM(ARM_THUMB2) && PLATFORM(IPHONE) && 0) \ + || (PLATFORM(ARM_THUMB2) && PLATFORM(IPHONE)) \ || (PLATFORM(X86) && PLATFORM(WIN)) #define ENABLE_YARR 1 #define ENABLE_YARR_JIT 1 diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/StdLibExtras.h b/src/3rdparty/webkit/JavaScriptCore/wtf/StdLibExtras.h index d21d1ff..c9b5742 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/StdLibExtras.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/StdLibExtras.h @@ -32,6 +32,7 @@ // Use these to declare and define a static local variable (static T;) so that // it is leaked so that its destructors are not called at exit. Using this // macro also allows workarounds a compiler bug present in Apple's version of GCC 4.0.1. +#ifndef DEFINE_STATIC_LOCAL #if COMPILER(GCC) && defined(__APPLE_CC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 1 #define DEFINE_STATIC_LOCAL(type, name, arguments) \ static type* name##Ptr = new type arguments; \ @@ -40,6 +41,7 @@ #define DEFINE_STATIC_LOCAL(type, name, arguments) \ static type& name = *new type arguments #endif +#endif // OBJECT_OFFSETOF: Like the C++ offsetof macro, but you can use it with classes. // The magic number 0x4000 is insignificant. We use it to avoid using NULL, since diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.cpp b/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.cpp index 56bf438..1d4185c 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.cpp @@ -51,7 +51,7 @@ static void* threadEntryPoint(void* contextData) setThreadNameInternal(context->name); - // Block until our creating thread has completed any extra setup work + // Block until our creating thread has completed any extra setup work. { MutexLocker locker(context->creationMutex); } diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h index 5154545..71c9402 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h @@ -128,7 +128,11 @@ void detachThread(ThreadIdentifier); #if USE(PTHREADS) typedef pthread_mutex_t PlatformMutex; +#if HAVE(PTHREAD_RWLOCK) typedef pthread_rwlock_t PlatformReadWriteLock; +#else +typedef void* PlatformReadWriteLock; +#endif typedef pthread_cond_t PlatformCondition; #elif PLATFORM(GTK) typedef GOwnPtr PlatformMutex; diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/ThreadingPthreads.cpp b/src/3rdparty/webkit/JavaScriptCore/wtf/ThreadingPthreads.cpp index e4fb419..6cad5e3 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/ThreadingPthreads.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/ThreadingPthreads.cpp @@ -167,6 +167,7 @@ ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, con if (pthread_create(&threadHandle, 0, runThreadWithRegistration, static_cast(threadData))) { LOG_ERROR("Failed to create pthread at entry point %p with data %p", entryPoint, data); + delete threadData; return 0; } return establishIdentifierForPthreadHandle(threadHandle); @@ -270,7 +271,7 @@ void Mutex::unlock() ASSERT_UNUSED(result, !result); } - +#if HAVE(PTHREAD_RWLOCK) ReadWriteLock::ReadWriteLock() { pthread_rwlock_init(&m_readWriteLock, NULL); @@ -324,6 +325,7 @@ void ReadWriteLock::unlock() int result = pthread_rwlock_unlock(&m_readWriteLock); ASSERT_UNUSED(result, !result); } +#endif // HAVE(PTHREAD_RWLOCK) ThreadCondition::ThreadCondition() { diff --git a/src/3rdparty/webkit/JavaScriptCore/yarr/RegexInterpreter.cpp b/src/3rdparty/webkit/JavaScriptCore/yarr/RegexInterpreter.cpp index aafea3c..d088086 100644 --- a/src/3rdparty/webkit/JavaScriptCore/yarr/RegexInterpreter.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/yarr/RegexInterpreter.cpp @@ -1490,7 +1490,7 @@ public: closeBodyAlternative(); } - void alterantiveBodyDisjunction() + void alternativeBodyDisjunction() { int newAlternativeIndex = m_bodyDisjunction->terms.size(); m_bodyDisjunction->terms[m_currentAlternativeIndex].alternative.next = newAlternativeIndex - m_currentAlternativeIndex; @@ -1499,7 +1499,7 @@ public: m_currentAlternativeIndex = newAlternativeIndex; } - void alterantiveDisjunction() + void alternativeDisjunction() { int newAlternativeIndex = m_bodyDisjunction->terms.size(); m_bodyDisjunction->terms[m_currentAlternativeIndex].alternative.next = newAlternativeIndex - m_currentAlternativeIndex; @@ -1515,9 +1515,9 @@ public: if (alt) { if (disjunction == m_pattern.m_body) - alterantiveBodyDisjunction(); + alternativeBodyDisjunction(); else - alterantiveDisjunction(); + alternativeDisjunction(); } PatternAlternative* alternative = disjunction->m_alternatives[alt]; diff --git a/src/3rdparty/webkit/JavaScriptCore/yarr/RegexJIT.cpp b/src/3rdparty/webkit/JavaScriptCore/yarr/RegexJIT.cpp index b635a45..5ce579a 100644 --- a/src/3rdparty/webkit/JavaScriptCore/yarr/RegexJIT.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/yarr/RegexJIT.cpp @@ -1264,7 +1264,7 @@ class RegexGenerator : private MacroAssembler { // complex here in compilation, and in the common case we should end up coallescing the checks. // // FIXME: a nice improvement here may be to stop trying to match sooner, based on the least - // of the minimum-alterantive-lengths. E.g. if I have two alternatives of length 200 and 150, + // of the minimum-alternative-lengths. E.g. if I have two alternatives of length 200 and 150, // and a string of length 100, we'll end up looping index from 0 to 100, checking whether there // is sufficient input to run either alternative (constantly failing). If there had been only // one alternative, or if the shorter alternative had come first, we would have terminated @@ -1309,9 +1309,6 @@ class RegexGenerator : private MacroAssembler { loadPtr(Address(X86Registers::ebp, 2 * sizeof(void*)), output); #endif #elif PLATFORM(ARM) -#if PLATFORM(ARM_TRADITIONAL) - push(ARMRegisters::lr); -#endif push(ARMRegisters::r4); push(ARMRegisters::r5); push(ARMRegisters::r6); diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 488c6a0..98f007c 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,8 +4,8 @@ This is a snapshot of the Qt port of WebKit from The commit imported was from the - qtwebkit-4.6-snapshot-22102009 branch/tag + qtwebkit-4.6-snapshot-20091003 branch/tag and has the sha1 checksum - 0639bb8e812c8923287cd5523248ca64fa5f7a50 + 8f810287200d21aded375664cc0a6ac0476dbdea diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 4e5dff8..2b36014 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,4260 @@ +2009-11-02 Tor Arne Vestbø + + Rubber-stamped by Antti Koivisto. + + [Qt] Build fix for Windows CE + + * plugins/PluginDatabase.cpp: + +2009-11-02 Jocelyn Turcotte + + Reviewed by Tor Arne Vestbø. + + [Qt] Fix Qt build on Windows. + https://bugs.webkit.org/show_bug.cgi?id=30905 + + * WebCore.pro: + * platform/graphics/BitmapImage.h: + * platform/graphics/qt/ImageQt.cpp: + (WebCore::BitmapImage::BitmapImage): + (WebCore::BitmapImage::create): + +2009-10-28 Adam Barth + + Reviewed by Eric Seidel. + + Don't run JavaScript URLs in view source mode + https://bugs.webkit.org/show_bug.cgi?id=30881 + + Just say no. + + Test: http/tests/security/view-source-no-javascript-url.html + + * bindings/ScriptControllerBase.cpp: + (WebCore::ScriptController::executeIfJavaScriptURL): + +2009-10-29 Gustavo Noronha Silva + + Unreviewed. Fixes style problems pointed out by Evan Martin. + + * platform/gtk/Language.cpp: + (WebCore::defaultLanguage): + +2009-10-29 Dan Bernstein + + Rubber-stamped by Mark Rowe. + + 64-bit Leopard build fix after r50259 + + * platform/graphics/mac/ComplexTextControllerATSUI.cpp: + Declared ATSUTextInserted in 64-bit. + (WebCore::fontHasMirroringInfo): Use %d format and cast to int. + (WebCore::disableLigatures): Ditto. + (WebCore::initializeATSUStyle): Ditto. + (WebCore::ComplexTextController::collectComplexTextRunsForCharacters): Ditto. + +2009-10-29 Dan Bernstein + + Tiger build fix after r50259 + + * platform/graphics/mac/ComplexTextController.h: + * platform/graphics/mac/ComplexTextControllerATSUI.cpp: + +2009-10-29 Dan Bernstein + + Attempted Tiger build fix after r50259 + + * platform/graphics/mac/ComplexTextControllerATSUI.cpp: + +2009-10-28 Steve Falkenburg + + Rubber stamped by Mark Rowe. + + https://bugs.webkit.org/show_bug.cgi?id=30899 + WebKit fails to build release on 32-bit Windows systems + + * WebCore.vcproj/WebCore.vcproj: Excluded files from project. + * bindings/js/JSBindingsAllInOne.cpp: Added. + +2009-10-28 Dan Bernstein + + Reviewed by Jon Honeycutt. + + Fixed typos in color names. + + * inspector/front-end/Color.js: + +2009-10-28 Dan Bernstein + + Reviewed by Sam Weinig. + + Share code between the ATSUI- and Core Text-based Font implementations by doing the + following: + - Generalize CoreTextController as ComplexTextController, keeping the Core Text-specific + parts in ComplexTextControllerCoreText.cpp. + - Generalize FontMacCoreText as FontComplexTextMac using ComplexTextController + - Implement ATSUI-specific parts of ComplexTextController in ComplexTextControllerATSUI. + - Remove FontMacATSUI. + + * WebCore.xcodeproj/project.pbxproj: Removed CoreTextController.{cpp,h}, FontMacATSUI.mm, + and FontMacCoreText.cpp, and added ComplexTextController.{cpp,h}, + ComplexTextControllerATSUI.cpp, ComplexTextControllerCoreText.cpp, and + FontComplexTextMac.cpp. + + * platform/graphics/mac/ComplexTextController.cpp: Copied from CoreTextController.cpp and + kept the non-Core Text-specific bits. + (WebCore::ComplexTextController::ComplexTextController): Updated for renames, including + its own. + (WebCore::ComplexTextController::offsetForPosition): Updated for renames and for + m_complexTextRuns holding references instead of objects. + (WebCore::ComplexTextController::collectComplexTextRuns): Updated for renames, including + its own. + (WebCore::ComplexTextController::advance): Updated for renames. + (WebCore::ComplexTextController::adjustGlyphsAndAdvances): Updated for renames and for + m_complexTextRuns holding references instead of objects, and changed to use the glyphs() + and advances() accessors. + + * platform/graphics/mac/ComplexTextController.h: Copied from CoreTextController.h and + renamed CoreTextController to ComplexTextController and CoreTextRun to ComplexTextRun. Made + the latter RefCounted, added ATSUI-specific members to it, and made some other members + Core Text-specific. Renamed m_coreTextRuns to m_complexTextRuns and made it hold references + rather than objects. + (WebCore::ComplexTextController::ComplexTextRun::create): + (WebCore::ComplexTextController::ComplexTextRun::glyphs): + (WebCore::ComplexTextController::ComplexTextRun::advances): + + * platform/graphics/mac/ComplexTextControllerATSUI.cpp: Added. Includes ATSUI-specific + parts of the ComplexTextController implementation. + (WebCore::ComplexTextController::ComplexTextRun::overrideLayoutOperation): This ATSUI + callback populates the ComplexTextRun’s glyphs, advances and indices vectors. It is invoked + when the ComplexTextRun constructor calls ATSUGetGlyphBounds(). + (WebCore::isArabicLamWithAlefLigature): Helper function, copied from FontMacATSUI.mm. + (WebCore::shapeArabic): Helper function, adapted from FontMacATSUI.mm. + (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): Sets up the + ATSUTextLayout, substituting the text buffer if necessary for things like shaping Arabic, + mirroring glyphs or directionality overrides, then calls ATSUGetGlyphBounds() in order to + get the glyphs, advances and indices vectors populated. + (WebCore::fontHasMirroringInfo): Helper function, copied from FontMacATSUI.mm. + (WebCore::disableLigatures): Ditto. + (WebCore::initializeATSUStyle): Ditto, somewhat cleaned up and simplified. + (WebCore::ComplexTextController::collectComplexTextRunsForCharacters): Constructs + ComplexTextRuns, either missing-glyphs ones or ATSUTextLayout-based ones. + + * platform/graphics/mac/ComplexTextControllerCoreText.cpp: Copied from + CoreTextController.cpp and kept the Core Text-specific bits. + (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): Updated for renames, + including its own, and moved the code to initialize m_glyphs and m_advances here. Previously + this was done in adjustGlyphsAndAdvances(). + (WebCore::ComplexTextController::collectComplexTextRunsForCharacters): Updated for renames, + including its own. + * platform/graphics/mac/CoreTextController.cpp: Removed. + * platform/graphics/mac/CoreTextController.h: Removed. + * platform/graphics/mac/FontComplexTextMac.cpp: Renamed FontMacCoreText.cpp to this. + (WebCore::Font::selectionRectForComplexText): Changed to use ComplexTextController instead + of CoreTextController. + (WebCore::Font::drawComplexText): Ditto. + (WebCore::Font::floatWidthForComplexText): Ditto. + (WebCore::Font::offsetForPositionForComplexText): Ditto. + * platform/graphics/mac/FontMacATSUI.mm: Removed. + * platform/graphics/mac/FontMacCoreText.cpp: Removed. + +2009-10-27 Chris Fleizach + + Reviewed by Darin Adler. + + WAI-ARIA: add support for 'option' role + https://bugs.webkit.org/show_bug.cgi?id=30843 + + Test: accessibility/aria-option-role.html + + * accessibility/AccessibilityListBoxOption.h: + (WebCore::AccessibilityListBoxOption::canHaveChildren): + * accessibility/AccessibilityRenderObject.cpp: + (WebCore::RoleEntry::): + (WebCore::AccessibilityRenderObject::canHaveChildren): + +2009-10-28 Jens Alfke + + Reviewed by Eric Seidel. + + Fix GCC compiler warnings in WebCore, and enable -Wall and -Werror for Chromium build. + https://bugs.webkit.org/show_bug.cgi?id=30716 + + * WebCore.gyp/WebCore.gyp: Enable "chromium_code" flag, just on Mac build for now. + * accessibility/AccessibilityRenderObject.cpp: + (WebCore::createARIARoleMap): Fix struct visibiity warning. + * bindings/v8/ScriptCallStack.h: Fix out-of-order member initialization warning. + * bindings/v8/V8Collection.h: + (WebCore::getV8Object): Function in header should not be 'static' (fixes unused-static warning.) + * bindings/v8/V8DOMWrapper.cpp: + (WebCore::V8DOMWrapper::convertNewNodeToV8Object): Fix signed/unsigned comparison warning. + * bindings/v8/V8GCController.cpp: + (WebCore::ObjectGrouperVisitor::applyGrouping): Fix unused-variable warning. + * css/CSSPrimitiveValueMappings.h: + (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Enable ListButtonPart case to avoid + warning about missing cases in 'switch' statement. + * editing/EditorCommand.cpp: + (WebCore::createCommandMap): Fix struct visibiity warning. + * platform/graphics/skia/PlatformContextSkia.cpp: + (PlatformContextSkia::State::State): Fix out-of-order member initialization warning. + * rendering/RenderMediaControlsChromium.cpp: + (WebCore::RenderMediaControlsChromium::shouldRenderMediaControlPart): Add empty 'default' case in + 'switch' statement to avoid missing-case warning. + (WebCore::RenderMediaControlsChromium::paintMediaControlsPart): Ditto. + * xml/XPathFunctions.cpp: + (WebCore::XPath::createFunctionMap): Fix struct visibiity warning. + +2009-10-29 Adam Barth + + Reviewed by Darin Adler. + + REGRESSION: crashes in WebCore::RedirectScheduler::timerFired(WebCore::Timer*) + https://bugs.webkit.org/show_bug.cgi?id=30839 + + Added null check for the case when the frame is detached from the page. + + * loader/RedirectScheduler.cpp: + (WebCore::RedirectScheduler::timerFired): + +2009-10-28 Joanmarie Diggs + + Reviewed by Xan Lopez. + + https://bugs.webkit.org/show_bug.cgi?id=30817 + Use parentObjectUnignored instead of parentObject in webkit_accessible_get_parent + + Also removes the hack I had originally added to solve bug 25411, because + the fix here is what I should have done in the first place. + + * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp: + (webkit_accessible_get_parent): + +2009-10-28 Dmitry Titov + + Reviewed by David Levin. + + https://bugs.webkit.org/show_bug.cgi?id=30805 + Add MessageQueue::removeIf(Predicate&) to remove certain tasks without pulling them from the queue. + Existing Database tests cover this, no change in functionality. + + * storage/DatabaseThread.cpp: + (WebCore::SameDatabasePredicate::SameDatabasePredicate): Added predicate that flags the tasks belonging to a specified database. + (WebCore::SameDatabasePredicate::operator()): + (WebCore::DatabaseThread::unscheduleDatabaseTasks): changed to use the new removeIf method. + +2009-10-28 Pavel Feldman + + Reviewed by Timothy Hatcher. + + Web Inspector: Glue subsequent timeline records with same category + and title together. + + https://bugs.webkit.org/show_bug.cgi?id=30885 + + * English.lproj/localizedStrings.js: + * inspector/front-end/TimelinePanel.js: + (WebInspector.TimelinePanel.prototype.addRecordToTimeline): + (WebInspector.TimelinePanel.prototype._formatRecord): + (WebInspector.TimelineRecordTreeElement.prototype.onattach): + (WebInspector.TimelineRecordTreeElement.prototype.refresh): + +2009-10-28 Gustavo Noronha Silva + + Reviewed by Xan Lopez. + + [GTK] Fails new test fast/js/navigator-language.html + https://bugs.webkit.org/show_bug.cgi?id=30440 + + Reimplement WebCore::defaultLanguage to account for changes in + locale done by setLocale. + + Already existing test: fast/js/navigator-language.html + + * platform/gtk/Language.cpp: + (WebCore::defaultLanguage): + +2009-10-28 Eric Carlson + + Reviewed by Simon Fraser. + + + Can't exit full screen mode or restart movie after pressing command -R. + + * html/HTMLMediaElement.cpp: + (WebCore::HTMLMediaElement::removedFromDocument): + (WebCore::HTMLMediaElement::documentWillBecomeInactive): + Exit from fullscreen if necessary. + * html/HTMLMediaElement.h: + +2009-10-28 Alexey Proskuryakov + + Unreviewed - a trivial fix to get Windows bots running. + + https://bugs.webkit.org/show_bug.cgi?id=30841 + WebKit should not pass Referer header through a redirect to a non-secure site + + * platform/network/cf/ResourceRequestCFNet.cpp: (WebCore::setHeaderFields): Don't try to + access empty vector's data. + +2009-10-28 Joanmarie Diggs + + Reviewed by Xan Lopez. + + https://bugs.webkit.org/show_bug.cgi?id=25897 + [Gtk] Extraneous object of ROLE_PANEL in hierarchy for entries + + Remove the extraneous object of ROLE_PANEL. + + * accessibility/gtk/AccessibilityObjectAtk.cpp: + (AccessibilityObject::accessibilityPlatformIncludesObject): + +2009-10-28 Jonathan Dixon + + Reviewed by Eric Seidel. + + Bug 30547: (Chromium) searchbox not rendered properly due to the css property -webkit-border-radius + https://bugs.webkit.org/show_bug.cgi?id=30547 + + Test: fast/css/text-input-with-webkit-border-radius.html + + * rendering/RenderThemeChromiumWin.cpp: + (WebCore::RenderThemeChromiumWin::paintTextFieldInternal): + Implemented rounded border rendering in Chromium Windows theme renderer. + +2009-10-28 Pavel Feldman + + Reviewed by Timothy Hatcher. + + Web Inspector: Pull items collections from resources panel and + timeline panel into AbstractTimelinePanel. + + https://bugs.webkit.org/show_bug.cgi?id=30875 + + * inspector/front-end/AbstractTimelinePanel.js: + (WebInspector.AbstractTimelinePanel): + (WebInspector.AbstractTimelinePanel.prototype.populateSidebar): + (WebInspector.AbstractTimelinePanel.prototype.createItemTreeElement): + (WebInspector.AbstractTimelinePanel.prototype.createItemGraph): + (WebInspector.AbstractTimelinePanel.prototype._showCategory): + (WebInspector.AbstractTimelinePanel.prototype._hideCategory): + (WebInspector.AbstractTimelinePanel.prototype.filter): + (WebInspector.AbstractTimelinePanel.prototype._createGraph): + (WebInspector.AbstractTimelinePanel.prototype.updateMainViewWidth): + (WebInspector.AbstractTimelinePanel.prototype.refresh): + (WebInspector.AbstractTimelinePanel.prototype.reset): + (WebInspector.AbstractTimelinePanel.prototype.get calculator): + (WebInspector.AbstractTimelinePanel.prototype.set calculator): + (WebInspector.AbstractTimelinePanel.prototype.addItem): + (WebInspector.AbstractTimelinePanel.prototype.removeItem): + (WebInspector.AbstractTimelinePanel.prototype.refreshItem): + (WebInspector.AbstractTimelinePanel.prototype.revealAndSelectItem): + (WebInspector.AbstractTimelinePanel.prototype.sortItems): + (WebInspector.AbstractTimelinePanel.prototype.adjustScrollPosition): + (WebInspector.AbstractTimelineCategory): + (WebInspector.AbstractTimelineCategory.prototype.toString): + * inspector/front-end/ResourceCategory.js: + (WebInspector.ResourceCategory): + * inspector/front-end/ResourcesPanel.js: + (WebInspector.ResourcesPanel): + (WebInspector.ResourcesPanel.prototype.createItemTreeElement): + (WebInspector.ResourcesPanel.prototype.createItemGraph): + (WebInspector.ResourcesPanel.prototype.isCategoryVisible): + (WebInspector.ResourcesPanel.prototype.populateSidebar): + (WebInspector.ResourcesPanel.prototype.get searchableViews): + (WebInspector.ResourcesPanel.prototype.get searchResultsSortFunction.sortFuction): + (WebInspector.ResourcesPanel.prototype.get searchResultsSortFunction): + (WebInspector.ResourcesPanel.prototype.searchMatchFound): + (WebInspector.ResourcesPanel.prototype.searchCanceled): + (WebInspector.ResourcesPanel.prototype.performSearch): + (WebInspector.ResourcesPanel.prototype.refresh): + (WebInspector.ResourcesPanel.prototype.reset): + (WebInspector.ResourcesPanel.prototype.removeResource): + (WebInspector.ResourcesPanel.prototype.addMessageToResource): + (WebInspector.ResourcesPanel.prototype.clearMessages): + (WebInspector.ResourcesPanel.prototype.refreshResource): + (WebInspector.ResourcesPanel.prototype.recreateViewForResourceIfNeeded): + (WebInspector.ResourcesPanel.prototype.showResource): + (WebInspector.ResourcesPanel.prototype._sortResourcesIfNeeded): + (WebInspector.ResourcesPanel.prototype._toggleLargerResources): + (WebInspector.ResourcesPanel.prototype._toggleResourceTracking): + (WebInspector.ResourcesPanel.prototype.get _resources): + (WebInspector.ResourceTimeCalculator.prototype._upperBound): + * inspector/front-end/TimelinePanel.js: + (WebInspector.TimelinePanel): + (WebInspector.TimelinePanel.prototype.get categories): + (WebInspector.TimelinePanel.prototype.populateSidebar): + (WebInspector.TimelinePanel.prototype.addRecordToTimeline): + (WebInspector.TimelinePanel.prototype.createItemTreeElement): + (WebInspector.TimelinePanel.prototype.createItemGraph): + (WebInspector.TimelinePanel.prototype._formatRecord): + (WebInspector.TimelineCategory): + * inspector/front-end/inspector.css: + * inspector/front-end/inspector.html: + +2009-10-28 Kelly Norton + + Reviewed by Pavel Feldman. + + Resets InspectorFrontend in InspectorTimelineAgent instead of removing it so + that it remains active on refreshs and page transitions. + https://bugs.webkit.org/show_bug.cgi?id=30874 + + * inspector/InspectorController.cpp: + (WebCore::InspectorController::setFrontendProxyObject): + * inspector/InspectorTimelineAgent.cpp: + (WebCore::InspectorTimelineAgent::resetFrontendProxyObject): + * inspector/InspectorTimelineAgent.h: + +2009-10-27 Shinichiro Hamaji + + Reviewed by Darin Adler. + + Provide a way to get counter values with layoutTestContoller + https://bugs.webkit.org/show_bug.cgi?id=30555 + + Expose WebCore::counterValueForElement as a WebCore API. + + * WebCore.base.exp: + * rendering/RenderTreeAsText.cpp: + (WebCore::writeCounterValuesFromChildren): + (WebCore::counterValueForElement): + * rendering/RenderTreeAsText.h: + +2009-10-28 Nate Chapin + + Unreviewed, Chromium build fix for r50225. + + * loader/FrameLoader.cpp: + (WebCore::FrameLoader::defaultObjectContentType): + +2009-10-28 Eric Z. Ayers + + Reviewed by Pavel Feldman. + + Adds InspectorTimelineAgent instrumentation for encountering a + . Check if it has the // expected value in all cases. // See smart window.open policy for where this is used. - ExecState* exec = m_windowShell->window()->globalExec(); + JSDOMWindowShell* shell = windowShell(world); + ExecState* exec = shell->window()->globalExec(); const String* savedSourceURL = m_sourceURL; m_sourceURL = &sourceURL; @@ -107,9 +117,9 @@ ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode) RefPtr protect = m_frame; - m_windowShell->window()->globalData()->timeoutChecker.start(); - Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), jsSourceCode, m_windowShell); - m_windowShell->window()->globalData()->timeoutChecker.stop(); + exec->globalData().timeoutChecker.start(); + Completion comp = WebCore::evaluateInWorld(exec, exec->dynamicGlobalObject()->globalScopeChain(), jsSourceCode, shell, world); + exec->globalData().timeoutChecker.stop(); // Evaluating the JavaScript could cause the frame to be deallocated // so we start the keep alive timer here. @@ -127,52 +137,114 @@ ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode) return JSValue(); } -void ScriptController::evaluateInIsolatedWorld(unsigned /* worldID */, const Vector& sourceCode) +ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode) +{ + return evaluateInWorld(sourceCode, mainThreadNormalWorld()); +} + +// An DOMWrapperWorld other than the thread's normal world. +class IsolatedWorld : public DOMWrapperWorld { +public: + IsolatedWorld(JSGlobalData* globalData) + : DOMWrapperWorld(globalData) + { + JSGlobalData::ClientData* clientData = globalData->clientData; + ASSERT(clientData); + static_cast(clientData)->rememberWorld(this); + } + + static PassRefPtr create(JSGlobalData* globalData) { return adoptRef(new IsolatedWorld(globalData)); } +}; + +static PassRefPtr findWorld(unsigned worldID) +{ + if (!worldID) + return IsolatedWorld::create(JSDOMWindow::commonJSGlobalData()); + + typedef HashMap > WorldMap; + DEFINE_STATIC_LOCAL(WorldMap, isolatedWorlds, ()); + + WorldMap::iterator iter = isolatedWorlds.find(worldID); + if (iter != isolatedWorlds.end()) + return iter->second; + + RefPtr newWorld = IsolatedWorld::create(JSDOMWindow::commonJSGlobalData()); + isolatedWorlds.add(worldID, newWorld); + return newWorld; +} + +JSDOMWindow* ScriptController::globalObject(unsigned worldID) +{ + RefPtr world = findWorld(worldID); + return windowShell(world.get())->window(); +} + +ScriptValue ScriptController::evaluateInIsolatedWorld(unsigned worldID, const ScriptSourceCode& sourceCode) +{ + RefPtr world = findWorld(worldID); + return evaluateInWorld(sourceCode, world.get()); +} + +void ScriptController::evaluateInIsolatedWorld(unsigned worldID, const Vector& sourceCode) { - // FIXME: Actually support isolated worlds! + RefPtr world = findWorld(worldID); + unsigned size = sourceCode.size(); for (unsigned i = 0; i < size; ++i) - evaluate(sourceCode[i]); + evaluateInWorld(sourceCode[i], world.get()); } void ScriptController::clearWindowShell() { - if (!m_windowShell) + if (m_windowShells.isEmpty()) return; JSLock lock(SilenceAssertionsOnly); // Clear the debugger from the current window before setting the new window. + DOMWrapperWorld* debugWorld = debuggerWorld(); attachDebugger(0); - m_windowShell->window()->willRemoveFromWindowShell(); - m_windowShell->setWindow(m_frame->domWindow()); + for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter) { + DOMWrapperWorld* world = iter->first; + JSDOMWindowShell* windowShell = iter->second; + windowShell->window()->willRemoveFromWindowShell(); + windowShell->setWindow(m_frame->domWindow()); - if (Page* page = m_frame->page()) { - attachDebugger(page->debugger()); - m_windowShell->window()->setProfileGroup(page->group().identifier()); + if (Page* page = m_frame->page()) { + if (world == debugWorld) + attachDebugger(page->debugger()); + windowShell->window()->setProfileGroup(page->group().identifier()); + } } // There is likely to be a lot of garbage now. gcController().garbageCollectSoon(); } -void ScriptController::initScript() +JSDOMWindowShell* ScriptController::initScript(DOMWrapperWorld* world) { - if (m_windowShell) - return; + ASSERT(!m_windowShells.contains(world)); JSLock lock(SilenceAssertionsOnly); - m_windowShell = new JSDOMWindowShell(m_frame->domWindow()); - m_windowShell->window()->updateDocument(); + JSDOMWindowShell* windowShell = new JSDOMWindowShell(m_frame->domWindow()); + m_windowShells.add(world, windowShell); + world->rememberScriptController(this); + windowShell->window()->updateDocument(world); if (Page* page = m_frame->page()) { - attachDebugger(page->debugger()); - m_windowShell->window()->setProfileGroup(page->group().identifier()); + if (world == debuggerWorld()) + attachDebugger(page->debugger()); + windowShell->window()->setProfileGroup(page->group().identifier()); + } + + { + EnterDOMWrapperWorld worldEntry(*JSDOMWindow::commonJSGlobalData(), world); + m_frame->loader()->dispatchWindowObjectAvailable(); } - m_frame->loader()->dispatchWindowObjectAvailable(); + return windowShell; } bool ScriptController::processingUserGesture() const @@ -182,10 +254,11 @@ bool ScriptController::processingUserGesture() const bool ScriptController::processingUserGestureEvent() const { - if (!m_windowShell) + JSDOMWindowShell* shell = existingWindowShell(mainThreadNormalWorld()); + if (!shell) return false; - if (Event* event = m_windowShell->window()->currentEvent()) { + if (Event* event = shell->window()->currentEvent()) { if (event->createdByDOM()) return false; @@ -243,13 +316,16 @@ bool ScriptController::isEnabled() void ScriptController::attachDebugger(JSC::Debugger* debugger) { - if (!m_windowShell) + // FIXME: Should be able to debug isolated worlds. + JSDOMWindowShell* shell = existingWindowShell(debuggerWorld()); + if (!shell) return; + JSDOMWindow* globalObject = shell->window(); if (debugger) - debugger->attach(m_windowShell->window()); - else if (JSC::Debugger* currentDebugger = m_windowShell->window()->debugger()) - currentDebugger->detach(m_windowShell->window()); + debugger->attach(globalObject); + else if (JSC::Debugger* currentDebugger = globalObject->debugger()) + currentDebugger->detach(globalObject); } void ScriptController::updateDocument() @@ -258,8 +334,8 @@ void ScriptController::updateDocument() return; JSLock lock(SilenceAssertionsOnly); - if (m_windowShell) - m_windowShell->window()->updateDocument(); + for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter) + iter->second->window()->updateDocument(iter->first); } void ScriptController::updateSecurityOrigin() @@ -274,7 +350,7 @@ Bindings::RootObject* ScriptController::bindingRootObject() if (!m_bindingRootObject) { JSLock lock(SilenceAssertionsOnly); - m_bindingRootObject = Bindings::RootObject::create(0, globalObject()); + m_bindingRootObject = Bindings::RootObject::create(0, globalObject(pluginWorld())); } return m_bindingRootObject.get(); } @@ -285,7 +361,7 @@ PassRefPtr ScriptController::createRootObject(void* native if (it != m_rootObjects.end()) return it->second; - RefPtr rootObject = Bindings::RootObject::create(nativeHandle, globalObject()); + RefPtr rootObject = Bindings::RootObject::create(nativeHandle, globalObject(pluginWorld())); m_rootObjects.set(nativeHandle, rootObject); return rootObject.release(); @@ -300,7 +376,7 @@ NPObject* ScriptController::windowScriptNPObject() // JavaScript is enabled, so there is a JavaScript window object. // Return an NPObject bound to the window object. JSC::JSLock lock(SilenceAssertionsOnly); - JSObject* win = windowShell()->window(); + JSObject* win = windowShell(pluginWorld())->window(); ASSERT(win); Bindings::RootObject* root = bindingRootObject(); m_windowScriptNPObject = _NPN_CreateScriptObject(0, win, root); @@ -334,8 +410,9 @@ JSObject* ScriptController::jsObjectForPluginElement(HTMLPlugInElement* plugin) // Create a JSObject bound to this element JSLock lock(SilenceAssertionsOnly); - ExecState* exec = globalObject()->globalExec(); - JSValue jsElementValue = toJS(exec, globalObject(), plugin); + JSDOMWindow* globalObj = globalObject(pluginWorld()); + // FIXME: is normal okay? - used for NP plugins? + JSValue jsElementValue = toJS(globalObj->globalExec(), globalObj, plugin); if (!jsElementValue || !jsElementValue.isObject()) return 0; @@ -391,4 +468,44 @@ void ScriptController::clearScriptObjects() #endif } +ScriptValue ScriptController::executeScriptInIsolatedWorld(unsigned worldID, const String& script, bool forceUserGesture) +{ + ScriptSourceCode sourceCode(script, forceUserGesture ? KURL() : m_frame->loader()->url()); + + if (!isEnabled() || isPaused()) + return ScriptValue(); + + bool wasInExecuteScript = m_inExecuteScript; + m_inExecuteScript = true; + + ScriptValue result = evaluateInIsolatedWorld(worldID, sourceCode); + + if (!wasInExecuteScript) { + m_inExecuteScript = false; + Document::updateStyleForAllDocuments(); + } + + return result; +} + +ScriptValue ScriptController::executeScriptInIsolatedWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture) +{ + ScriptSourceCode sourceCode(script, forceUserGesture ? KURL() : m_frame->loader()->url()); + + if (!isEnabled() || isPaused()) + return ScriptValue(); + + bool wasInExecuteScript = m_inExecuteScript; + m_inExecuteScript = true; + + ScriptValue result = evaluateInWorld(sourceCode, world); + + if (!wasInExecuteScript) { + m_inExecuteScript = false; + Document::updateStyleForAllDocuments(); + } + + return result; +} + } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptController.h b/src/3rdparty/webkit/WebCore/bindings/js/ScriptController.h index bd4b65e..f2a497d 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptController.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptController.h @@ -63,31 +63,49 @@ class XSSAuditor; typedef HashMap > RootObjectMap; class ScriptController { + typedef WTF::HashMap > ShellMap; + public: ScriptController(Frame*); ~ScriptController(); - bool haveWindowShell() const { return m_windowShell; } - JSDOMWindowShell* windowShell() + JSDOMWindowShell* windowShell(DOMWrapperWorld* world) + { + ShellMap::iterator iter = m_windowShells.find(world); + return (iter != m_windowShells.end()) ? iter->second.get() : initScript(world); + } + JSDOMWindowShell* existingWindowShell(DOMWrapperWorld* world) const + { + ShellMap::const_iterator iter = m_windowShells.find(world); + return (iter != m_windowShells.end()) ? iter->second.get() : 0; + } + JSDOMWindow* globalObject(DOMWrapperWorld* world) { - initScriptIfNeeded(); - return m_windowShell; + return windowShell(world)->window(); } + JSDOMWindow* globalObject(unsigned worldID); - JSDOMWindow* globalObject() + void forgetWorld(DOMWrapperWorld* world) { - initScriptIfNeeded(); - return m_windowShell->window(); + m_windowShells.remove(world); } ScriptValue executeScript(const ScriptSourceCode&); ScriptValue executeScript(const String& script, bool forceUserGesture = false); + ScriptValue executeScriptInIsolatedWorld(unsigned worldID, const String& script, bool forceUserGesture = false); + ScriptValue executeScriptInIsolatedWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture = false); // Returns true if argument is a JavaScript URL. bool executeIfJavaScriptURL(const KURL&, bool userGesture = false, bool replaceDocument = true); + // This function must be called from the main thread. It is safe to call it repeatedly. + // Darwin is an exception to this rule: it is OK to call this function from any thread, even reentrantly. + static void initializeThreading(); + ScriptValue evaluate(const ScriptSourceCode&); - void evaluateInIsolatedWorld(unsigned worldID, const Vector&); + ScriptValue evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*); + ScriptValue evaluateInIsolatedWorld(unsigned /*worldID*/, const ScriptSourceCode&); + void evaluateInIsolatedWorld(unsigned /*worldID*/, const Vector&); void setEventHandlerLineNumber(int lineno) { m_handlerLineNumber = lineno; } int eventHandlerLineNumber() { return m_handlerLineNumber; } @@ -144,19 +162,14 @@ public: XSSAuditor* xssAuditor() { return m_XSSAuditor.get(); } private: - void initScriptIfNeeded() - { - if (!m_windowShell) - initScript(); - } - void initScript(); + JSDOMWindowShell* initScript(DOMWrapperWorld* world); void disconnectPlatformScriptObjects(); bool processingUserGestureEvent() const; bool isJavaScriptAnchorNavigation() const; - JSC::ProtectedPtr m_windowShell; + ShellMap m_windowShells; Frame* m_frame; int m_handlerLineNumber; const String* m_sourceURL; diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptControllerMac.mm b/src/3rdparty/webkit/WebCore/bindings/js/ScriptControllerMac.mm index e6a654f..21ec0f2 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptControllerMac.mm +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptControllerMac.mm @@ -114,7 +114,7 @@ WebScriptObject* ScriptController::windowScriptObject() if (!m_windowScriptObject) { JSC::JSLock lock(JSC::SilenceAssertionsOnly); JSC::Bindings::RootObject* root = bindingRootObject(); - m_windowScriptObject = [WebScriptObject scriptObjectForJSObject:toRef(windowShell()) originRootObject:root rootObject:root]; + m_windowScriptObject = [WebScriptObject scriptObjectForJSObject:toRef(windowShell(pluginWorld())) originRootObject:root rootObject:root]; } ASSERT([m_windowScriptObject.get() isKindOfClass:[DOMAbstractView class]]); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptEventListener.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptEventListener.cpp index 0b0047b..8399c7a 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptEventListener.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptEventListener.cpp @@ -71,7 +71,7 @@ PassRefPtr createAttributeEventListener(Node* node, Attribu sourceURL = node->document()->url().string(); } - return JSLazyEventListener::create(attr->localName().string(), eventParameterName(node->isSVGElement()), attr->value(), node, sourceURL, lineNumber); + return JSLazyEventListener::create(attr->localName().string(), eventParameterName(node->isSVGElement()), attr->value(), node, sourceURL, lineNumber, mainThreadNormalWorld()); } PassRefPtr createAttributeEventListener(Frame* frame, Attribute* attr) @@ -93,7 +93,7 @@ PassRefPtr createAttributeEventListener(Frame* frame, Attri lineNumber = scriptController->eventHandlerLineNumber(); sourceURL = frame->document()->url().string(); - return JSLazyEventListener::create(attr->localName().string(), eventParameterName(frame->document()->isSVGDocument()), attr->value(), 0, sourceURL, lineNumber); + return JSLazyEventListener::create(attr->localName().string(), eventParameterName(frame->document()->isSVGDocument()), attr->value(), 0, sourceURL, lineNumber, mainThreadNormalWorld()); } String getEventListenerHandlerBody(ScriptExecutionContext* context, ScriptState* scriptState, EventListener* eventListener) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptFunctionCall.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptFunctionCall.cpp index 46e80ac..91b2a57 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptFunctionCall.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptFunctionCall.cpp @@ -123,7 +123,8 @@ ScriptValue ScriptFunctionCall::call(bool& hadException, bool reportExceptions) if (callType == CallTypeNone) return ScriptValue(); - JSValue result = JSC::call(m_exec, function, callType, callData, thisObject, m_arguments); + // FIXME: Should this function take a worldID? - only used by inspector? + JSValue result = callInWorld(m_exec, function, callType, callData, thisObject, m_arguments, debuggerWorld()); if (m_exec->hadException()) { if (reportExceptions) reportException(m_exec, m_exec->exception()); @@ -161,7 +162,8 @@ ScriptObject ScriptFunctionCall::construct(bool& hadException, bool reportExcept if (constructType == ConstructTypeNone) return ScriptObject(); - JSValue result = JSC::construct(m_exec, constructor, constructType, constructData, m_arguments); + // FIXME: Currently this method constructs objects in debuggerWorld(). We could use the current world, or pass a worldID to this function? + JSValue result = constructInWorld(m_exec, constructor, constructType, constructData, m_arguments, debuggerWorld()); if (m_exec->hadException()) { if (reportExceptions) reportException(m_exec, m_exec->exception()); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptObjectQuarantine.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptObjectQuarantine.cpp index b48556e..313530f 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptObjectQuarantine.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptObjectQuarantine.cpp @@ -72,7 +72,7 @@ bool getQuarantinedScriptObject(Database* database, ScriptObject& quarantinedObj if (!frame) return false; - JSDOMGlobalObject* globalObject = toJSDOMWindow(frame); + JSDOMGlobalObject* globalObject = toJSDOMWindow(frame, debuggerWorld()); ExecState* exec = globalObject->globalExec(); JSLock lock(SilenceAssertionsOnly); @@ -89,7 +89,7 @@ bool getQuarantinedScriptObject(Storage* storage, ScriptObject& quarantinedObjec Frame* frame = storage->frame(); ASSERT(frame); - JSDOMGlobalObject* globalObject = toJSDOMWindow(frame); + JSDOMGlobalObject* globalObject = toJSDOMWindow(frame, debuggerWorld()); ExecState* exec = globalObject->globalExec(); JSLock lock(SilenceAssertionsOnly); @@ -116,7 +116,7 @@ bool getQuarantinedScriptObject(DOMWindow* domWindow, ScriptObject& quarantinedO { ASSERT(domWindow); - JSDOMWindow* window = toJSDOMWindow(domWindow->frame()); + JSDOMWindow* window = toJSDOMWindow(domWindow->frame(), debuggerWorld()); ExecState* exec = window->globalExec(); JSLock lock(SilenceAssertionsOnly); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptSourceCode.h b/src/3rdparty/webkit/WebCore/bindings/js/ScriptSourceCode.h index 1b05ded..32d6298 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptSourceCode.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptSourceCode.h @@ -44,6 +44,7 @@ public: ScriptSourceCode(const String& source, const KURL& url = KURL(), int startLine = 1) : m_provider(StringSourceProvider::create(source, url.isNull() ? String() : url.string())) , m_code(m_provider, startLine) + , m_url(url) { } @@ -59,10 +60,17 @@ public: const String& source() const { return m_provider->source(); } + int startLine() const { return m_code.firstLine(); } + + const KURL& url() const { return m_url; } + private: RefPtr m_provider; JSC::SourceCode m_code; + + KURL m_url; + }; } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptState.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptState.cpp index 8bfa33d..60ba2a0 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptState.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptState.cpp @@ -32,6 +32,7 @@ #include "ScriptState.h" #include "Frame.h" +#include "JSDOMWindowBase.h" #include "Node.h" #include "Page.h" @@ -49,12 +50,12 @@ ScriptState* scriptStateFromNode(Node* node) return 0; if (!frame->script()->isEnabled()) return 0; - return frame->script()->globalObject()->globalExec(); + return frame->script()->globalObject(mainThreadCurrentWorld())->globalExec(); } ScriptState* scriptStateFromPage(Page* page) { - return page->mainFrame()->script()->globalObject()->globalExec(); + return page->mainFrame()->script()->globalObject(mainThreadCurrentWorld())->globalExec(); } } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptState.h b/src/3rdparty/webkit/WebCore/bindings/js/ScriptState.h index fa5c4a8..279234e 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptState.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptState.h @@ -35,6 +35,7 @@ #include "JSDOMBinding.h" namespace WebCore { + class DOMWrapperWorld; class Node; class Page; diff --git a/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.cpp b/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.cpp index 3590dad..b66b0e8 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.cpp @@ -52,6 +52,7 @@ WorkerScriptController::WorkerScriptController(WorkerContext* workerContext) , m_workerContext(workerContext) , m_executionForbidden(false) { + m_globalData->clientData = new WebCoreJSClientData(m_globalData.get()); } WorkerScriptController::~WorkerScriptController() @@ -122,7 +123,7 @@ ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, ExecState* exec = m_workerContextWrapper->globalExec(); m_workerContextWrapper->globalData()->timeoutChecker.start(); - Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper); + Completion comp = evaluateInWorld(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper, currentWorld(exec)); m_workerContextWrapper->globalData()->timeoutChecker.stop(); if (comp.complType() == Normal || comp.complType() == ReturnValue) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.h b/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.h index bb33f60..c820cd9 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.h @@ -62,6 +62,9 @@ namespace WebCore { void setException(ScriptValue); void forbidExecution(); + + JSC::JSGlobalData* globalData() { return m_globalData.get(); } + private: void initScriptIfNeeded() { diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm index ff7b52f..d8367ac 100644 --- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -292,7 +292,7 @@ sub GenerateGetOwnPropertySlotBody my @getOwnPropertySlotImpl = (); - if ($interfaceName eq "NamedNodeMap" or $interfaceName eq "HTMLCollection") { + if ($interfaceName eq "NamedNodeMap" or $interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") { push(@getOwnPropertySlotImpl, " ${namespaceMaybe}JSValue proto = prototype();\n"); push(@getOwnPropertySlotImpl, " if (proto.isObject() && static_cast<${namespaceMaybe}JSObject*>(asObject(proto))->hasProperty(exec, propertyName))\n"); push(@getOwnPropertySlotImpl, " return false;\n\n"); @@ -369,7 +369,7 @@ sub GenerateGetOwnPropertyDescriptorBody my @getOwnPropertyDescriptorImpl = (); - if ($interfaceName eq "NamedNodeMap" or $interfaceName eq "HTMLCollection") { + if ($interfaceName eq "NamedNodeMap" or $interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") { push(@getOwnPropertyDescriptorImpl, " ${namespaceMaybe}JSValue proto = prototype();\n"); push(@getOwnPropertyDescriptorImpl, " if (proto.isObject() && static_cast<${namespaceMaybe}JSObject*>(asObject(proto))->hasProperty(exec, propertyName))\n"); push(@getOwnPropertyDescriptorImpl, " return false;\n\n"); @@ -658,6 +658,12 @@ sub GenerateHeader # Custom lookupSetter function push(@headerContent, " virtual JSC::JSValue lookupSetter(JSC::ExecState*, const JSC::Identifier& propertyName);\n") if $dataNode->extendedAttributes->{"CustomLookupSetter"}; + # Override toBoolean to return false for objects that want to 'MasqueradesAsUndefined'. + if ($dataNode->extendedAttributes->{"MasqueradesAsUndefined"}) { + push(@headerContent, " virtual bool toBoolean(JSC::ExecState*) const { return false; };\n"); + $structureFlags{"JSC::MasqueradesAsUndefined"} = 1; + } + # Constructor object getter push(@headerContent, " static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*);\n") if $dataNode->extendedAttributes->{"GenerateConstructor"}; @@ -1188,19 +1194,21 @@ sub GenerateImplementation push(@implContent, " impl()->invalidateEventListeners();\n"); } - if ($interfaceName eq "Node") { - push(@implContent, " forgetDOMNode(impl()->document(), impl());\n"); - } else { - if ($podType) { - my $animatedType = $implClassName; - $animatedType =~ s/SVG/SVGAnimated/; + if (!$dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"}) { + if ($interfaceName eq "Node") { + push(@implContent, " forgetDOMNode(this, impl(), impl()->document());\n"); + } else { + if ($podType) { + my $animatedType = $implClassName; + $animatedType =~ s/SVG/SVGAnimated/; - # Special case for JSSVGNumber - if ($codeGenerator->IsSVGAnimatedType($animatedType) and $podType ne "float") { - push(@implContent, " JSSVGDynamicPODTypeWrapperCache<$podType, $animatedType>::forgetWrapper(m_impl.get());\n"); + # Special case for JSSVGNumber + if ($codeGenerator->IsSVGAnimatedType($animatedType) and $podType ne "float") { + push(@implContent, " JSSVGDynamicPODTypeWrapperCache<$podType, $animatedType>::forgetWrapper(m_impl.get());\n"); + } } + push(@implContent, " forgetDOMObject(this, impl());\n"); } - push(@implContent, " forgetDOMObject(*Heap::heap(this)->globalData(), impl());\n"); } push(@implContent, "}\n\n"); @@ -1210,7 +1218,7 @@ sub GenerateImplementation # its own special handling rather than relying on the caching that Node normally does. if ($interfaceName eq "Document") { push(@implContent, "${className}::~$className()\n"); - push(@implContent, "{\n forgetDOMObject(*Heap::heap(this)->globalData(), static_cast<${implClassName}*>(impl()));\n}\n\n"); + push(@implContent, "{\n forgetDOMObject(this, static_cast<${implClassName}*>(impl()));\n}\n\n"); } if ($needsMarkChildren && !$dataNode->extendedAttributes->{"CustomMarkFunction"}) { @@ -1476,7 +1484,7 @@ sub GenerateImplementation } else { $implIncludes{"Frame.h"} = 1; $implIncludes{"JSDOMGlobalObject.h"} = 1; - push(@implContent, " JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext());\n"); + push(@implContent, " JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec);\n"); push(@implContent, " if (!globalObject)\n"); push(@implContent, " return;\n"); } @@ -1700,7 +1708,7 @@ sub GenerateImplementation push(@implContent, " return toJS(exec, thisObj->globalObject(), static_cast<$implClassName*>(thisObj->impl())->item(slot.index()));\n"); } push(@implContent, "}\n"); - if ($interfaceName eq "HTMLCollection") { + if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") { $implIncludes{"JSNode.h"} = 1; $implIncludes{"Node.h"} = 1; } @@ -1711,7 +1719,7 @@ sub GenerateImplementation push(@implContent, "{\n"); push(@implContent, " return jsNumber(exec, static_cast<$implClassName*>(impl())->item(index));\n"); push(@implContent, "}\n"); - if ($interfaceName eq "HTMLCollection") { + if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") { $implIncludes{"JSNode.h"} = 1; $implIncludes{"Node.h"} = 1; } diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm index 28562f1..95b2aa2 100644 --- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -215,7 +215,6 @@ sub AddClassForwardIfNeeded sub GetImplementationFileName { my $iface = shift; - return "HTMLCollection.h" if $iface eq "HTMLAllCollection"; return "Event.h" if $iface eq "DOMTimeStamp"; return "NamedAttrMap.h" if $iface eq "NamedNodeMap"; return "NameNodeList.h" if $iface eq "NodeList"; @@ -307,7 +306,7 @@ sub GenerateSetDOMException my $indent = shift; my $result = ""; - $result .= $indent . "if (ec) {\n"; + $result .= $indent . "if (UNLIKELY(ec)) {\n"; $result .= $indent . " V8Proxy::setDOMException(ec);\n"; $result .= $indent . " return v8::Handle();\n"; $result .= $indent . "}\n"; @@ -622,15 +621,17 @@ END push(@implContentDecls, " if (!imp->document())\n"); push(@implContentDecls, " return v8::Undefined();\n"); } - push(@implContentDecls, " $nativeType v = "); - - push(@implContentDecls, "$getterString;\n"); if ($useExceptions) { + push(@implContentDecls, " $nativeType v = "); + push(@implContentDecls, "$getterString;\n"); push(@implContentDecls, GenerateSetDOMException(" ")); + $result = "v"; + $result .= ".release()" if (IsRefPtrType($returnType)); + } else { + # Can inline the function call into the return statement to avoid overhead of using a Ref<> temporary + $result = $getterString; } - - $result = "v"; } if (IsSVGTypeNeedingContextParameter($attrType) && !$skipContext) { @@ -646,7 +647,6 @@ END my $classIndex = uc($attrType); push(@implContentDecls, " return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper.release());\n"); } else { - $result .= ".release()" if (IsRefPtrType($attrType)); push(@implContentDecls, " " . ReturnNativeToJSValue($attribute->signature, $result, " ").";\n"); } @@ -784,7 +784,8 @@ END } if ($useExceptions) { - push(@implContentDecls, " V8Proxy::setDOMException(ec);\n"); + push(@implContentDecls, " if (UNLIKELY(ec))\n"); + push(@implContentDecls, " V8Proxy::setDOMException(ec);\n"); } if ($isPodType) { @@ -917,7 +918,7 @@ END if (TypeCanFailConversion($parameter)) { $implIncludes{"ExceptionCode.h"} = 1; push(@implContentDecls, -" if (!$parameterName" . (BasicTypeCanFailConversion($parameter) ? "Ok" : "") . ") {\n" . +" if (UNLIKELY(!$parameterName" . (BasicTypeCanFailConversion($parameter) ? "Ok" : "") . ")) {\n" . " V8Proxy::setDOMException(TYPE_MISMATCH_ERR);\n" . " return v8::Handle();\n" . " }\n"); @@ -926,7 +927,7 @@ END if ($parameter->extendedAttributes->{"IsIndex"}) { $implIncludes{"ExceptionCode.h"} = 1; push(@implContentDecls, -" if ($parameterName < 0) {\n" . +" if (UNLIKELY($parameterName < 0)) {\n" . " V8Proxy::setDOMException(INDEX_SIZE_ERR);\n" . " return v8::Handle();\n" . " }\n"); @@ -1322,6 +1323,13 @@ END $template = "instance"; } + my $conditional = ""; + if ($attrExt->{"EnabledAtRuntime"}) { + # Only call Set()/SetAccessor() if this method should be enabled + $enable_function = $interfaceName . $codeGenerator->WK_ucfirst($function->signature->name); + $conditional = "if (V8Custom::v8${enable_function}Enabled())\n"; + } + if ($attrExt->{"DoNotCheckDomainSecurity"} && ($dataNode->extendedAttributes->{"CheckDomainSecurity"} || $interfaceName eq "DOMWindow")) { # Mark the accessor as ReadOnly and set it on the proto object so @@ -1342,7 +1350,7 @@ END push(@implContent, <SetAccessor( + $conditional $template->SetAccessor( v8::String::New("$name"), ${interfaceName}Internal::${name}AttrGetter, 0, @@ -1370,7 +1378,7 @@ END push(@implContent, <Set( + $conditional ${template}->Set( v8::String::New("$name"), $templateFunction, static_cast($property_attributes)); @@ -1388,7 +1396,7 @@ END } # Set the class name. This is used when printing objects. - push(@implContent, " desc->SetClassName(v8::String::New(\"" . GetClassName(${interfaceName}) . "\"));\n"); + push(@implContent, " desc->SetClassName(v8::String::New(\"${interfaceName}\"));\n"); if ($has_constants) { push(@implContent, < > result = $functionString;\n"; - } else { + } elsif (@{$function->raisesExceptions} or $returnsPodType or $isPodType or IsSVGTypeNeedingContextParameter($returnType)) { $result .= $indent . $nativeReturnType . " result = $functionString;\n"; + } else { + # Can inline the function call into the return statement to avoid overhead of using a Ref<> temporary + $return = $functionString; + $returnIsRef = 0; } if (@{$function->raisesExceptions}) { $result .= GenerateSetDOMException($indent); } - my $return = "result"; - # If the return type is a POD type, separate out the wrapper generation if ($returnsListItemPodType) { $result .= $indent . "RefPtr > wrapper = "; @@ -1602,7 +1615,7 @@ sub GenerateFunctionCallString() my $classIndex = uc($returnType); $result .= $indent . "return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper.release());\n"; } else { - $return .= ".release()" if (IsRefPtrType($returnType)); + $return .= ".release()" if ($returnIsRef); $result .= $indent . ReturnNativeToJSValue($function->signature, $return, $indent) . ";\n"; } @@ -1610,15 +1623,6 @@ sub GenerateFunctionCallString() } -# Get the class name used for printing javascript DOM-object wrappers. -sub GetClassName -{ - my $type = shift; - return "HTMLCollection" if $type eq "HTMLAllCollection"; - return $type; -} - - sub GetTypeFromSignature { my $signature = shift; @@ -1696,6 +1700,7 @@ sub IsRefPtrType return 1 if $type eq "EventListener"; return 1 if $type eq "FileList"; return 1 if $type eq "HTMLCollection"; + return 1 if $type eq "HTMLAllCollection"; return 1 if $type eq "HTMLDocument"; return 1 if $type eq "HTMLElement"; return 1 if $type eq "HTMLOptionsCollection"; @@ -2147,7 +2152,11 @@ sub ReturnNativeToJSValue # special case for non-DOM node interfaces if (IsDOMNodeType($type)) { - return "return V8DOMWrapper::convertNodeToV8Object($value)"; + if ($signature->extendedAttributes->{"ReturnsNew"}) { + return "return V8DOMWrapper::convertNewNodeToV8Object($value)"; + } else { + return "return V8DOMWrapper::convertNodeToV8Object($value)"; + } } if ($type eq "EventTarget" or $type eq "SVGElementInstance") { @@ -2159,7 +2168,7 @@ sub ReturnNativeToJSValue } if ($type eq "EventListener") { - return "return V8DOMWrapper::convertEventListenerToV8Object($value)"; + return "return V8DOMWrapper::convertEventListenerToV8Object(imp->scriptExecutionContext(), $value)"; } if ($type eq "SerializedScriptValue") { diff --git a/src/3rdparty/webkit/WebCore/bridge/NP_jsobject.cpp b/src/3rdparty/webkit/WebCore/bridge/NP_jsobject.cpp index 006f17f..6a89652 100644 --- a/src/3rdparty/webkit/WebCore/bridge/NP_jsobject.cpp +++ b/src/3rdparty/webkit/WebCore/bridge/NP_jsobject.cpp @@ -34,6 +34,7 @@ #include "c_utility.h" #include "c_instance.h" #include "IdentifierRep.h" +#include "JSDOMBinding.h" #include "npruntime_impl.h" #include "npruntime_priv.h" #include "runtime_root.h" @@ -123,7 +124,7 @@ bool _NPN_InvokeDefault(NPP, NPObject* o, const NPVariant* args, uint32_t argCou getListFromVariantArgs(exec, args, argCount, rootObject, argList); ProtectedPtr globalObject = rootObject->globalObject(); globalObject->globalData()->timeoutChecker.start(); - JSValue resultV = call(exec, function, callType, callData, function, argList); + JSValue resultV = callInWorld(exec, function, callType, callData, function, argList, pluginWorld()); globalObject->globalData()->timeoutChecker.stop(); // Convert and return the result of the function call. @@ -173,7 +174,7 @@ bool _NPN_Invoke(NPP npp, NPObject* o, NPIdentifier methodName, const NPVariant* getListFromVariantArgs(exec, args, argCount, rootObject, argList); ProtectedPtr globalObject = rootObject->globalObject(); globalObject->globalData()->timeoutChecker.start(); - JSValue resultV = call(exec, function, callType, callData, obj->imp, argList); + JSValue resultV = callInWorld(exec, function, callType, callData, obj->imp, argList, pluginWorld()); globalObject->globalData()->timeoutChecker.stop(); // Convert and return the result of the function call. @@ -203,7 +204,7 @@ bool _NPN_Evaluate(NPP, NPObject* o, NPString* s, NPVariant* variant) String scriptString = convertNPStringToUTF16(s); ProtectedPtr globalObject = rootObject->globalObject(); globalObject->globalData()->timeoutChecker.start(); - Completion completion = JSC::evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(scriptString)); + Completion completion = evaluateInWorld(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(scriptString), JSC::JSValue(), pluginWorld()); globalObject->globalData()->timeoutChecker.stop(); ComplType type = completion.complType(); @@ -443,7 +444,7 @@ bool _NPN_Construct(NPP, NPObject* o, const NPVariant* args, uint32_t argCount, getListFromVariantArgs(exec, args, argCount, rootObject, argList); ProtectedPtr globalObject = rootObject->globalObject(); globalObject->globalData()->timeoutChecker.start(); - JSValue resultV = construct(exec, constructor, constructType, constructData, argList); + JSValue resultV = constructInWorld(exec, constructor, constructType, constructData, argList, pluginWorld()); globalObject->globalData()->timeoutChecker.stop(); // Convert and return the result. diff --git a/src/3rdparty/webkit/WebCore/bridge/jni/jni_jsobject.mm b/src/3rdparty/webkit/WebCore/bridge/jni/jni_jsobject.mm index eb4a6bd..cc28a75 100644 --- a/src/3rdparty/webkit/WebCore/bridge/jni/jni_jsobject.mm +++ b/src/3rdparty/webkit/WebCore/bridge/jni/jni_jsobject.mm @@ -29,6 +29,7 @@ #if ENABLE(MAC_JAVA_BRIDGE) #include "Frame.h" +#include "JSDOMBinding.h" #include "ScriptController.h" #include "StringSourceProvider.h" #include "WebCoreFrameView.h" @@ -302,7 +303,7 @@ jobject JavaJSObject::call(jstring methodName, jobjectArray args) const MarkedArgumentBuffer argList; getListFromJArray(exec, args, argList); rootObject->globalObject()->globalData()->timeoutChecker.start(); - JSValue result = JSC::call(exec, function, callType, callData, _imp, argList); + JSValue result = WebCore::callInWorld(exec, function, callType, callData, _imp, argList, WebCore::pluginWorld()); rootObject->globalObject()->globalData()->timeoutChecker.stop(); return convertValueToJObject(result); @@ -321,7 +322,7 @@ jobject JavaJSObject::eval(jstring script) const return 0; rootObject->globalObject()->globalData()->timeoutChecker.start(); - Completion completion = JSC::evaluate(rootObject->globalObject()->globalExec(), rootObject->globalObject()->globalScopeChain(), makeSource(JavaString(script))); + Completion completion = WebCore::evaluateInWorld(rootObject->globalObject()->globalExec(), rootObject->globalObject()->globalScopeChain(), makeSource(JavaString(script)), JSC::JSValue(), WebCore::pluginWorld()); rootObject->globalObject()->globalData()->timeoutChecker.stop(); ComplType type = completion.complType(); diff --git a/src/3rdparty/webkit/WebCore/bridge/npapi.h b/src/3rdparty/webkit/WebCore/bridge/npapi.h index 5d48b0d..c6cd557 100644 --- a/src/3rdparty/webkit/WebCore/bridge/npapi.h +++ b/src/3rdparty/webkit/WebCore/bridge/npapi.h @@ -56,6 +56,12 @@ # endif /* XP_WIN */ #endif /* _WIN32 */ +#ifdef __SYMBIAN32__ +# ifndef XP_SYMBIAN +# define XP_SYMBIAN 1 +# endif +#endif /* __SYMBIAN32__ */ + #ifdef __MWERKS__ # define _declspec __declspec # ifdef macintosh @@ -64,22 +70,15 @@ # endif /* XP_MAC */ # endif /* macintosh */ # ifdef __INTEL__ -# ifndef __SYMBIAN32__ +# ifndef XP_SYMBIAN # undef NULL -# endif -# ifndef XP_WIN -# define XP_WIN 1 -# endif /* __INTEL__ */ -# endif /* XP_PC */ +# ifndef XP_WIN +# define XP_WIN 1 +# endif /* XP_WIN */ +# endif /* XP_SYMBIAN */ +# endif /* __INTEL__ */ #endif /* __MWERKS__ */ -#ifdef __SYMBIAN32__ -# ifndef XP_SYMBIAN -# define XP_SYMBIAN 1 -# undef XP_WIN -# endif -#endif /* __SYMBIAN32__ */ - #if defined(__APPLE_CC__) && !defined(__MACOS_CLASSIC__) && !defined(XP_UNIX) # define XP_MACOSX #endif diff --git a/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.cpp b/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.cpp index 3cb2156..6887325 100644 --- a/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.cpp +++ b/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.cpp @@ -458,7 +458,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type if (type == Date) { DateInstance* date = static_cast(object); WTF::GregorianDateTime gdt; - date->getUTCTime(gdt); + WTF::msToGregorianDateTime(date->internalNumber(), true, gdt); if (hint == QMetaType::QDateTime) { ret = QDateTime(QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay), QTime(gdt.hour, gdt.minute, gdt.second), Qt::UTC); dist = 0; @@ -834,9 +834,7 @@ JSValue convertQVariantToValue(ExecState* exec, PassRefPtr root, con dt.isDST = -1; double ms = WTF::gregorianDateTimeToMS(dt, time.msec(), /*inputIsUTC*/ false); - DateInstance* instance = new (exec) DateInstance(exec->lexicalGlobalObject()->dateStructure()); - instance->setInternalValue(jsNumber(exec, trunc(ms))); - return instance; + return new (exec) DateInstance(exec, trunc(ms)); } if (type == QMetaType::QByteArray) { diff --git a/src/3rdparty/webkit/WebCore/css/CSSComputedStyleDeclaration.cpp b/src/3rdparty/webkit/WebCore/css/CSSComputedStyleDeclaration.cpp index 4e067ce..b8769f9 100644 --- a/src/3rdparty/webkit/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/src/3rdparty/webkit/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -157,6 +157,7 @@ static const int computedProperties[] = { CSSPropertyWebkitBackgroundClip, CSSPropertyWebkitBackgroundComposite, CSSPropertyWebkitBackgroundOrigin, + CSSPropertyWebkitBackgroundSize, CSSPropertyWebkitBorderFit, CSSPropertyWebkitBorderHorizontalSpacing, CSSPropertyWebkitBorderImage, @@ -260,30 +261,13 @@ static const int computedProperties[] = { CSSPropertyTextAnchor, CSSPropertyWritingMode, CSSPropertyGlyphOrientationHorizontal, - CSSPropertyGlyphOrientationVertical + CSSPropertyGlyphOrientationVertical, + CSSPropertyWebkitShadow #endif }; const unsigned numComputedProperties = sizeof(computedProperties) / sizeof(computedProperties[0]); -static PassRefPtr valueForShadow(const ShadowData* shadow, CSSPropertyID propertyID) -{ - if (!shadow) - return CSSPrimitiveValue::createIdentifier(CSSValueNone); - - RefPtr list = CSSValueList::createCommaSeparated(); - for (const ShadowData* s = shadow; s; s = s->next) { - RefPtr x = CSSPrimitiveValue::create(s->x, CSSPrimitiveValue::CSS_PX); - RefPtr y = CSSPrimitiveValue::create(s->y, CSSPrimitiveValue::CSS_PX); - RefPtr blur = CSSPrimitiveValue::create(s->blur, CSSPrimitiveValue::CSS_PX); - RefPtr spread = propertyID == CSSPropertyTextShadow ? 0 : CSSPrimitiveValue::create(s->spread, CSSPrimitiveValue::CSS_PX); - RefPtr style = propertyID == CSSPropertyTextShadow || s->style == Normal ? 0 : CSSPrimitiveValue::createIdentifier(CSSValueInset); - RefPtr color = CSSPrimitiveValue::createColor(s->color.rgb()); - list->prepend(ShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release())); - } - return list.release(); -} - static int valueForRepeatRule(int rule) { switch (rule) { @@ -571,6 +555,26 @@ PassRefPtr CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringK return CSSPrimitiveValue::create(style->fontDescription().computedPixelSize(), CSSPrimitiveValue::CSS_PX); } +PassRefPtr CSSComputedStyleDeclaration::valueForShadow(const ShadowData* shadow, int id) const +{ + if (!shadow) + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + + CSSPropertyID propertyID = static_cast(id); + + RefPtr list = CSSValueList::createCommaSeparated(); + for (const ShadowData* s = shadow; s; s = s->next) { + RefPtr x = CSSPrimitiveValue::create(s->x, CSSPrimitiveValue::CSS_PX); + RefPtr y = CSSPrimitiveValue::create(s->y, CSSPrimitiveValue::CSS_PX); + RefPtr blur = CSSPrimitiveValue::create(s->blur, CSSPrimitiveValue::CSS_PX); + RefPtr spread = propertyID == CSSPropertyTextShadow ? 0 : CSSPrimitiveValue::create(s->spread, CSSPrimitiveValue::CSS_PX); + RefPtr style = propertyID == CSSPropertyTextShadow || s->style == Normal ? 0 : CSSPrimitiveValue::createIdentifier(CSSValueInset); + RefPtr color = CSSPrimitiveValue::createColor(s->color.rgb()); + list->prepend(ShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release())); + } + return list.release(); +} + PassRefPtr CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID) const { return getPropertyCSSValue(propertyID, UpdateLayout); @@ -676,7 +680,8 @@ PassRefPtr CSSComputedStyleDeclaration::getPropertyCSSValue(int proper if (style->backgroundImage()) return style->backgroundImage()->cssValue(); return CSSPrimitiveValue::createIdentifier(CSSValueNone); - case CSSPropertyBackgroundSize: { + case CSSPropertyBackgroundSize: + case CSSPropertyWebkitBackgroundSize: { EFillSizeType size = style->backgroundSizeType(); if (size == Contain) return CSSPrimitiveValue::createIdentifier(CSSValueContain); @@ -777,7 +782,7 @@ PassRefPtr CSSComputedStyleDeclaration::getPropertyCSSValue(int proper case CSSPropertyWebkitBoxReflect: return valueForReflection(style->boxReflect()); case CSSPropertyWebkitBoxShadow: - return valueForShadow(style->boxShadow(), static_cast(propertyID)); + return valueForShadow(style->boxShadow(), propertyID); case CSSPropertyCaptionSide: return CSSPrimitiveValue::create(style->captionSide()); case CSSPropertyClear: @@ -1061,7 +1066,7 @@ PassRefPtr CSSComputedStyleDeclaration::getPropertyCSSValue(int proper case CSSPropertyTextIndent: return CSSPrimitiveValue::create(style->textIndent()); case CSSPropertyTextShadow: - return valueForShadow(style->textShadow(), static_cast(propertyID)); + return valueForShadow(style->textShadow(), propertyID); case CSSPropertyTextRendering: return CSSPrimitiveValue::create(style->fontDescription().textRenderingMode()); case CSSPropertyTextOverflow: diff --git a/src/3rdparty/webkit/WebCore/css/CSSComputedStyleDeclaration.h b/src/3rdparty/webkit/WebCore/css/CSSComputedStyleDeclaration.h index c1f34c3..842a995 100644 --- a/src/3rdparty/webkit/WebCore/css/CSSComputedStyleDeclaration.h +++ b/src/3rdparty/webkit/WebCore/css/CSSComputedStyleDeclaration.h @@ -27,6 +27,7 @@ namespace WebCore { class CSSMutableStyleDeclaration; +class ShadowData; enum EUpdateLayout { DoNotUpdateLayout = false, UpdateLayout = true }; @@ -66,6 +67,8 @@ private: virtual String removeProperty(int propertyID, ExceptionCode&); virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&); + PassRefPtr valueForShadow(const ShadowData*, int) const; + RefPtr m_node; }; diff --git a/src/3rdparty/webkit/WebCore/css/CSSParser.cpp b/src/3rdparty/webkit/WebCore/css/CSSParser.cpp index 10949dd..6024a5b 100644 --- a/src/3rdparty/webkit/WebCore/css/CSSParser.cpp +++ b/src/3rdparty/webkit/WebCore/css/CSSParser.cpp @@ -873,6 +873,7 @@ bool CSSParser::parseValue(int propId, bool important) case CSSPropertyBackgroundPositionX: case CSSPropertyBackgroundPositionY: case CSSPropertyBackgroundSize: + case CSSPropertyWebkitBackgroundSize: case CSSPropertyBackgroundRepeat: case CSSPropertyBackgroundRepeatX: case CSSPropertyBackgroundRepeatY: @@ -1726,6 +1727,15 @@ void CSSParser::addFillValue(RefPtr& lval, PassRefPtr rval) lval = rval; } +static bool parseBackgroundClip(CSSParserValue* parserValue, RefPtr& cssValue) +{ + if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddingBox || parserValue->id == CSSValueWebkitText) { + cssValue = CSSPrimitiveValue::createIdentifier(parserValue->id); + return true; + } + return false; +} + const int cMaxFillProperties = 9; bool CSSParser::parseFillShorthand(int propId, const int* properties, int numProperties, bool important) @@ -1777,6 +1787,7 @@ bool CSSParser::parseFillShorthand(int propId, const int* properties, int numPro RefPtr val1; RefPtr val2; int propId1, propId2; + CSSParserValue* parserValue = m_valueList->current(); if (parseFillProperty(properties[i], propId1, propId2, val1, val2)) { parsedProperty[i] = found = true; addFillValue(values[i], val1.release()); @@ -1786,7 +1797,7 @@ bool CSSParser::parseFillShorthand(int propId, const int* properties, int numPro addFillValue(repeatYValue, val2.release()); if (properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) { // Reparse the value as a clip, and see if we succeed. - if (parseFillProperty(CSSPropertyBackgroundClip, propId1, propId2, val1, val2)) + if (parseBackgroundClip(parserValue, val1)) addFillValue(clipValue, val1.release()); // The property parsed successfully. else addFillValue(clipValue, CSSInitialValue::createImplicit()); // Some value was used for origin that is not supported by clip. Just reset clip instead. @@ -2319,7 +2330,7 @@ void CSSParser::parseFillRepeat(RefPtr& value1, RefPtr& valu } } -PassRefPtr CSSParser::parseFillSize(bool& allowComma) +PassRefPtr CSSParser::parseFillSize(int propId, bool& allowComma) { allowComma = true; CSSParserValue* value = m_valueList->current(); @@ -2328,7 +2339,7 @@ PassRefPtr CSSParser::parseFillSize(bool& allowComma) return CSSPrimitiveValue::createIdentifier(value->id); RefPtr parsedValue1; - + if (value->id == CSSValueAuto) parsedValue1 = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_UNKNOWN); else { @@ -2336,8 +2347,9 @@ PassRefPtr CSSParser::parseFillSize(bool& allowComma) return 0; parsedValue1 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit); } - - RefPtr parsedValue2 = parsedValue1; + + CSSPropertyID property = static_cast(propId); + RefPtr parsedValue2; if ((value = m_valueList->next())) { if (value->id == CSSValueAuto) parsedValue2 = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_UNKNOWN); @@ -2349,7 +2361,13 @@ PassRefPtr CSSParser::parseFillSize(bool& allowComma) parsedValue2 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit); } } - + if (!parsedValue2) { + if (property == CSSPropertyWebkitBackgroundSize || property == CSSPropertyWebkitMaskSize) + parsedValue2 = parsedValue1; + else + parsedValue2 = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_UNKNOWN); + } + return CSSPrimitiveValue::create(Pair::create(parsedValue1.release(), parsedValue2.release())); } @@ -2425,10 +2443,8 @@ bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2, } break; case CSSPropertyBackgroundClip: - if (val->id == CSSValueBorderBox || val->id == CSSValuePaddingBox || val->id == CSSValueWebkitText) { - currValue = CSSPrimitiveValue::createIdentifier(val->id); + if (parseBackgroundClip(val, currValue)) m_valueList->next(); - } break; case CSSPropertyBackgroundOrigin: if (val->id == CSSValueBorderBox || val->id == CSSValuePaddingBox || val->id == CSSValueContentBox) { @@ -2470,8 +2486,9 @@ bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2, // parseFillRepeat advances the m_valueList pointer break; case CSSPropertyBackgroundSize: + case CSSPropertyWebkitBackgroundSize: case CSSPropertyWebkitMaskSize: { - currValue = parseFillSize(allowComma); + currValue = parseFillSize(propId, allowComma); if (currValue) m_valueList->next(); break; @@ -3736,7 +3753,11 @@ bool CSSParser::parseShadow(int propId, bool important) // Other operators aren't legal or we aren't done with the current shadow // value. Treat as invalid. return false; - +#if ENABLE(SVG) + // -webkit-shadow does not support multiple values. + if (static_cast(propId) == CSSPropertyWebkitShadow) + return false; +#endif // The value is good. Commit it. context.commitValue(); } else if (validUnit(val, FLength, true)) { @@ -5182,11 +5203,6 @@ static int cssPropertyID(const UChar* propertyName, unsigned length) const char* const opacity = "opacity"; name = opacity; length = strlen(opacity); - } else if (strcmp(buffer, "-webkit-background-size") == 0) { - // CSS Backgrounds/Borders. -webkit-background-size worked in Safari 4 and earlier. - const char* const backgroundSize = "background-size"; - name = backgroundSize; - length = strlen(backgroundSize); } else if (hasPrefix(buffer + 7, length - 7, "-border-")) { // -webkit-border-*-*-radius worked in Safari 4 and earlier. -webkit-border-radius syntax // differs from border-radius, so it is remains as a distinct property. diff --git a/src/3rdparty/webkit/WebCore/css/CSSParser.h b/src/3rdparty/webkit/WebCore/css/CSSParser.h index 1a156da..6d1bb32 100644 --- a/src/3rdparty/webkit/WebCore/css/CSSParser.h +++ b/src/3rdparty/webkit/WebCore/css/CSSParser.h @@ -83,7 +83,7 @@ namespace WebCore { PassRefPtr parseFillPositionXY(bool& xFound, bool& yFound); void parseFillPosition(RefPtr&, RefPtr&); void parseFillRepeat(RefPtr&, RefPtr&); - PassRefPtr parseFillSize(bool &allowComma); + PassRefPtr parseFillSize(int propId, bool &allowComma); bool parseFillProperty(int propId, int& propId1, int& propId2, RefPtr&, RefPtr&); bool parseFillShorthand(int propId, const int* properties, int numProperties, bool important); diff --git a/src/3rdparty/webkit/WebCore/css/CSSParserValues.h b/src/3rdparty/webkit/WebCore/css/CSSParserValues.h index 242cda8..1e9767a 100644 --- a/src/3rdparty/webkit/WebCore/css/CSSParserValues.h +++ b/src/3rdparty/webkit/WebCore/css/CSSParserValues.h @@ -88,7 +88,7 @@ private: unsigned m_variablesCount; }; -struct CSSParserFunction { +struct CSSParserFunction : FastAllocBase { CSSParserString name; CSSParserValueList* args; diff --git a/src/3rdparty/webkit/WebCore/css/CSSPrimitiveValueMappings.h b/src/3rdparty/webkit/WebCore/css/CSSPrimitiveValueMappings.h index 3616aa5..6f89df9 100644 --- a/src/3rdparty/webkit/WebCore/css/CSSPrimitiveValueMappings.h +++ b/src/3rdparty/webkit/WebCore/css/CSSPrimitiveValueMappings.h @@ -200,11 +200,11 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e) case ListboxPart: m_value.ident = CSSValueListbox; break; -#if ENABLE(DATALIST) case ListButtonPart: +#if ENABLE(DATALIST) m_value.ident = CSSValueListButton; - break; #endif + break; case ListItemPart: m_value.ident = CSSValueListitem; break; @@ -378,6 +378,7 @@ template<> inline CSSPrimitiveValue::operator EFillBox() const case CSSValueContentBox: return ContentFillBox; case CSSValueText: + case CSSValueWebkitText: return TextFillBox; default: ASSERT_NOT_REACHED(); diff --git a/src/3rdparty/webkit/WebCore/css/CSSProperty.h b/src/3rdparty/webkit/WebCore/css/CSSProperty.h index 7af8348..b5635d0 100644 --- a/src/3rdparty/webkit/WebCore/css/CSSProperty.h +++ b/src/3rdparty/webkit/WebCore/css/CSSProperty.h @@ -29,7 +29,7 @@ namespace WebCore { -class CSSProperty { +class CSSProperty : public FastAllocBase { public: CSSProperty(int propID, PassRefPtr value, bool important = false, int shorthandID = 0, bool implicit = false) : m_id(propID) diff --git a/src/3rdparty/webkit/WebCore/css/CSSPropertyNames.in b/src/3rdparty/webkit/WebCore/css/CSSPropertyNames.in index 5ef6605..48a18e7 100644 --- a/src/3rdparty/webkit/WebCore/css/CSSPropertyNames.in +++ b/src/3rdparty/webkit/WebCore/css/CSSPropertyNames.in @@ -160,6 +160,10 @@ zoom -webkit-background-clip -webkit-background-composite -webkit-background-origin +# -webkit-background-size differs from background-size only in the interpretation of +# a single value: -webkit-background-size: l; is equivalent to background-size: l l; +# whereas background-size: l; is equivalent to background-size: l auto; +-webkit-background-size -webkit-binding -webkit-border-fit -webkit-border-horizontal-spacing diff --git a/src/3rdparty/webkit/WebCore/css/CSSStyleSelector.cpp b/src/3rdparty/webkit/WebCore/css/CSSStyleSelector.cpp index 181e480..40627cf 100644 --- a/src/3rdparty/webkit/WebCore/css/CSSStyleSelector.cpp +++ b/src/3rdparty/webkit/WebCore/css/CSSStyleSelector.cpp @@ -2961,6 +2961,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) HANDLE_BACKGROUND_VALUE(origin, Origin, value) return; case CSSPropertyBackgroundSize: + case CSSPropertyWebkitBackgroundSize: HANDLE_BACKGROUND_VALUE(size, Size, value) return; case CSSPropertyWebkitMaskAttachment: diff --git a/src/3rdparty/webkit/WebCore/css/SVGCSSComputedStyleDeclaration.cpp b/src/3rdparty/webkit/WebCore/css/SVGCSSComputedStyleDeclaration.cpp index e8492d4..1f19983 100644 --- a/src/3rdparty/webkit/WebCore/css/SVGCSSComputedStyleDeclaration.cpp +++ b/src/3rdparty/webkit/WebCore/css/SVGCSSComputedStyleDeclaration.cpp @@ -166,6 +166,8 @@ PassRefPtr CSSComputedStyleDeclaration::getSVGPropertyCSSValue(int pro return 0; } + case CSSPropertyWebkitShadow: + return valueForShadow(svgStyle->shadow(), propertyID); case CSSPropertyMarker: case CSSPropertyEnableBackground: case CSSPropertyColorProfile: diff --git a/src/3rdparty/webkit/WebCore/css/SVGCSSParser.cpp b/src/3rdparty/webkit/WebCore/css/SVGCSSParser.cpp index 0ae9fbc..8730e49 100644 --- a/src/3rdparty/webkit/WebCore/css/SVGCSSParser.cpp +++ b/src/3rdparty/webkit/WebCore/css/SVGCSSParser.cpp @@ -257,6 +257,11 @@ bool CSSParser::parseSVGValue(int propId, bool important) m_valueList->next(); } break; + case CSSPropertyWebkitShadow: + if (id == CSSValueNone) + valid_primitive = true; + else + return parseShadow(propId, important); /* shorthand properties */ case CSSPropertyMarker: diff --git a/src/3rdparty/webkit/WebCore/css/SVGCSSPropertyNames.in b/src/3rdparty/webkit/WebCore/css/SVGCSSPropertyNames.in index e400ffe..809eabe 100644 --- a/src/3rdparty/webkit/WebCore/css/SVGCSSPropertyNames.in +++ b/src/3rdparty/webkit/WebCore/css/SVGCSSPropertyNames.in @@ -46,3 +46,5 @@ glyph-orientation-vertical kerning text-anchor writing-mode + +-webkit-shadow diff --git a/src/3rdparty/webkit/WebCore/css/SVGCSSStyleSelector.cpp b/src/3rdparty/webkit/WebCore/css/SVGCSSStyleSelector.cpp index b81b4f2..7e4483f 100644 --- a/src/3rdparty/webkit/WebCore/css/SVGCSSStyleSelector.cpp +++ b/src/3rdparty/webkit/WebCore/css/SVGCSSStyleSelector.cpp @@ -37,6 +37,7 @@ #include "CSSPropertyNames.h" #include "CSSValueList.h" #include "Document.h" +#include "ShadowValue.h" #include "SVGColor.h" #include "SVGNames.h" #include "SVGPaint.h" @@ -526,6 +527,35 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue* value) // Silently ignoring this property for now // http://bugs.webkit.org/show_bug.cgi?id=6022 break; + case CSSPropertyWebkitShadow: { + if (isInherit) + return svgstyle->setShadow(m_parentStyle->svgStyle()->shadow() ? new ShadowData(*m_parentStyle->svgStyle()->shadow()) : 0); + if (isInitial || primitiveValue) // initial | none + return svgstyle->setShadow(0); + + if (!value->isValueList()) + return; + + float zoomFactor = m_style->effectiveZoom(); + + CSSValueList *list = static_cast(value); + ASSERT(list->length() == 1); + ShadowValue* item = static_cast(list->itemWithoutBoundsCheck(0)); + int x = item->x->computeLengthInt(style(), m_rootElementStyle, zoomFactor); + int y = item->y->computeLengthInt(style(), m_rootElementStyle, zoomFactor); + int blur = item->blur ? item->blur->computeLengthInt(style(), m_rootElementStyle, zoomFactor) : 0; + Color color; + if (item->color) + color = getColorFromPrimitiveValue(item->color.get()); + + // -webkit-shadow does should not have a spread or style + ASSERT(!item->spread); + ASSERT(!item->style); + + ShadowData* shadowData = new ShadowData(x, y, blur, 0, Normal, color.isValid() ? color : Color::transparent); + svgstyle->setShadow(shadowData); + return; + } default: // If you crash here, it's because you added a css property and are not handling it // in either this switch statement or the one in CSSStyleSelector::applyProperty diff --git a/src/3rdparty/webkit/WebCore/dom/Document.cpp b/src/3rdparty/webkit/WebCore/dom/Document.cpp index 475a8c1..4eb44f7 100644 --- a/src/3rdparty/webkit/WebCore/dom/Document.cpp +++ b/src/3rdparty/webkit/WebCore/dom/Document.cpp @@ -58,6 +58,7 @@ #include "FrameLoader.h" #include "FrameTree.h" #include "FrameView.h" +#include "HTMLAllCollection.h" #include "HTMLAnchorElement.h" #include "HTMLBodyElement.h" #include "HTMLCanvasElement.h" @@ -511,6 +512,16 @@ Document::~Document() m_styleSheets->documentDestroyed(); } +Document::JSWrapperCache* Document::createWrapperCache(DOMWrapperWorld* world) +{ + JSWrapperCache* wrapperCache = new JSWrapperCache(); + m_wrapperCacheMap.set(world, wrapperCache); +#if USE(JSC) + world->rememberDocument(this); +#endif + return wrapperCache; +} + void Document::resetLinkColor() { m_linkColor = Color(0, 0, 238); @@ -943,7 +954,7 @@ Element* Document::elementFromPoint(int x, int y) const return 0; float zoomFactor = frame->pageZoomFactor(); - IntPoint point = roundedIntPoint(FloatPoint((x + view()->scrollX()) * zoomFactor, (y + view()->scrollY()) * zoomFactor)); + IntPoint point = roundedIntPoint(FloatPoint(x * zoomFactor + view()->scrollX(), y * zoomFactor + view()->scrollY())); if (!frameView->visibleContentRect().contains(point)) return 0; @@ -973,7 +984,7 @@ PassRefPtr Document::caretRangeFromPoint(int x, int y) return 0; float zoomFactor = frame->pageZoomFactor(); - IntPoint point = roundedIntPoint(FloatPoint((x + view()->scrollX()) * zoomFactor, (y + view()->scrollY()) * zoomFactor)); + IntPoint point = roundedIntPoint(FloatPoint(x * zoomFactor + view()->scrollX(), y * zoomFactor + view()->scrollY())); if (!frameView->visibleContentRect().contains(point)) return 0; @@ -3988,9 +3999,9 @@ PassRefPtr Document::anchors() return HTMLCollection::create(this, DocAnchors); } -PassRefPtr Document::all() +PassRefPtr Document::all() { - return HTMLCollection::create(this, DocAll); + return HTMLAllCollection::create(this); } PassRefPtr Document::windowNamedItems(const String &name) diff --git a/src/3rdparty/webkit/WebCore/dom/Document.h b/src/3rdparty/webkit/WebCore/dom/Document.h index 09bba58..0632be1 100644 --- a/src/3rdparty/webkit/WebCore/dom/Document.h +++ b/src/3rdparty/webkit/WebCore/dom/Document.h @@ -71,6 +71,7 @@ namespace WebCore { class HitTestRequest; class HTMLCanvasElement; class HTMLCollection; + class HTMLAllCollection; class HTMLDocument; class HTMLElement; class HTMLFormElement; @@ -79,6 +80,7 @@ namespace WebCore { class HTMLMapElement; class InspectorTimelineAgent; class IntPoint; + class DOMWrapperWorld; class JSNode; class MouseEventWithHitTestResults; class NodeFilter; @@ -315,12 +317,13 @@ public: PassRefPtr links(); PassRefPtr forms(); PassRefPtr anchors(); - PassRefPtr all(); PassRefPtr objects(); PassRefPtr scripts(); PassRefPtr windowNamedItems(const String& name); PassRefPtr documentNamedItems(const String& name); + PassRefPtr all(); + // Find first anchor with the given name. // First searches for an element with the given ID, but if that fails, then looks // for an anchor with the given name. ID matching is always case sensitive, but @@ -819,7 +822,15 @@ public: virtual void postTask(PassRefPtr); // Executes the task on context's thread asynchronously. typedef HashMap JSWrapperCache; - JSWrapperCache& wrapperCache() { return m_wrapperCache; } + typedef HashMap JSWrapperCacheMap; + JSWrapperCacheMap& wrapperCacheMap() { return m_wrapperCacheMap; } + JSWrapperCache* getWrapperCache(DOMWrapperWorld* world) + { + if (JSWrapperCache* wrapperCache = m_wrapperCacheMap.get(world)) + return wrapperCache; + return createWrapperCache(world); + } + JSWrapperCache* createWrapperCache(DOMWrapperWorld*); virtual void finishedParsing(); @@ -1137,7 +1148,7 @@ private: unsigned m_numNodeListCaches; - JSWrapperCache m_wrapperCache; + JSWrapperCacheMap m_wrapperCacheMap; #if ENABLE(DATABASE) RefPtr m_databaseThread; diff --git a/src/3rdparty/webkit/WebCore/dom/Element.cpp b/src/3rdparty/webkit/WebCore/dom/Element.cpp index 621c63a..9edde25 100644 --- a/src/3rdparty/webkit/WebCore/dom/Element.cpp +++ b/src/3rdparty/webkit/WebCore/dom/Element.cpp @@ -1414,7 +1414,7 @@ KURL Element::getURLAttribute(const QualifiedName& name) const ASSERT(isURLAttribute(attribute)); } #endif - return document()->completeURL(getAttribute(name)); + return document()->completeURL(deprecatedParseURL(getAttribute(name))); } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/dom/EventTarget.cpp b/src/3rdparty/webkit/WebCore/dom/EventTarget.cpp index ceb5221..694e78a 100644 --- a/src/3rdparty/webkit/WebCore/dom/EventTarget.cpp +++ b/src/3rdparty/webkit/WebCore/dom/EventTarget.cpp @@ -192,9 +192,16 @@ bool EventTarget::removeEventListener(const AtomicString& eventType, EventListen // Notify firing events planning to invoke the listener at 'index' that // they have one less listener to invoke. - for (size_t i = 0; i < d->firingEventEndIterators.size(); ++i) { - if (eventType == *d->firingEventEndIterators[i].eventType && index < *d->firingEventEndIterators[i].value) - --*d->firingEventEndIterators[i].value; + for (size_t i = 0; i < d->firingEventIterators.size(); ++i) { + if (eventType != d->firingEventIterators[i].eventType) + continue; + + if (index >= d->firingEventIterators[i].end) + continue; + + --d->firingEventIterators[i].end; + if (index <= d->firingEventIterators[i].iterator) + --d->firingEventIterators[i].iterator; } return true; @@ -232,6 +239,10 @@ bool EventTarget::dispatchEvent(PassRefPtr event, ExceptionCode& ec) ec = EventException::UNSPECIFIED_EVENT_TYPE_ERR; return false; } + + if (!scriptExecutionContext()) + return false; + return dispatchEvent(event); } @@ -259,9 +270,15 @@ bool EventTarget::fireEventListeners(Event* event) RefPtr protect = this; + // Fire all listeners registered for this event. Don't fire listeners removed + // during event dispatch. Also, don't fire event listeners added during event + // dispatch. Conveniently, all new event listeners will be added after 'end', + // so iterating to 'end' naturally excludes new event listeners. + + size_t i = 0; size_t end = entry.size(); - d->firingEventEndIterators.append(FiringEventEndIterator(&event->type(), &end)); - for (size_t i = 0; i < end; ++i) { + d->firingEventIterators.append(FiringEventIterator(event->type(), i, end)); + for ( ; i < end; ++i) { RegisteredEventListener& registeredListener = entry[i]; if (event->eventPhase() == Event::CAPTURING_PHASE && !registeredListener.useCapture) continue; @@ -271,7 +288,7 @@ bool EventTarget::fireEventListeners(Event* event) // event listeners, even though that violates some versions of the DOM spec. registeredListener.listener->handleEvent(scriptExecutionContext(), event); } - d->firingEventEndIterators.removeLast(); + d->firingEventIterators.removeLast(); return !event->defaultPrevented(); } @@ -298,8 +315,10 @@ void EventTarget::removeAllEventListeners() // Notify firing events planning to invoke the listener at 'index' that // they have one less listener to invoke. - for (size_t i = 0; i < d->firingEventEndIterators.size(); ++i) - *d->firingEventEndIterators[i].value = 0; + for (size_t i = 0; i < d->firingEventIterators.size(); ++i) { + d->firingEventIterators[i].iterator = 0; + d->firingEventIterators[i].end = 0; + } } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/dom/EventTarget.h b/src/3rdparty/webkit/WebCore/dom/EventTarget.h index 2d612e1..9a1975c 100644 --- a/src/3rdparty/webkit/WebCore/dom/EventTarget.h +++ b/src/3rdparty/webkit/WebCore/dom/EventTarget.h @@ -61,24 +61,26 @@ namespace WebCore { typedef int ExceptionCode; - struct FiringEventEndIterator { - FiringEventEndIterator(const AtomicString* eventType, size_t* value) + struct FiringEventIterator { + FiringEventIterator(const AtomicString& eventType, size_t& iterator, size_t& end) : eventType(eventType) - , value(value) + , iterator(iterator) + , end(end) { } - - const AtomicString* eventType; - size_t* value; + + const AtomicString& eventType; + size_t& iterator; + size_t& end; }; - typedef Vector FiringEventEndIteratorVector; + typedef Vector FiringEventIteratorVector; typedef Vector EventListenerVector; typedef HashMap EventListenerMap; struct EventTargetData { EventListenerMap eventListenerMap; - FiringEventEndIteratorVector firingEventEndIterators; + FiringEventIteratorVector firingEventIterators; }; class EventTarget { @@ -209,7 +211,7 @@ namespace WebCore { EventTargetData* d = eventTargetData(); if (!d) return false; - return d->firingEventEndIterators.size() != 0; + return d->firingEventIterators.size() != 0; } inline bool EventTarget::hasEventListeners() diff --git a/src/3rdparty/webkit/WebCore/dom/HTMLAllCollection.idl b/src/3rdparty/webkit/WebCore/dom/HTMLAllCollection.idl deleted file mode 100644 index dee365f..0000000 --- a/src/3rdparty/webkit/WebCore/dom/HTMLAllCollection.idl +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2008, 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -module html { - - // This interface is used for undetectable HTMLCollections. - // An undetectable HTMLCollection behaves like an HTMLCollection - // when used, but the 'typeof' operator returns undefined and - // ToBoolean returns false. - interface HTMLAllCollection : HTMLCollection { - }; - -} diff --git a/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.cpp b/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.cpp index 45d4e23..f7046e3 100644 --- a/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.cpp +++ b/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.cpp @@ -36,6 +36,10 @@ #include #include +#if USE(JSC) +#include "JSDOMWindow.h" +#endif + namespace WebCore { class ProcessMessagesSoonTask : public ScriptExecutionContext::Task { @@ -195,4 +199,20 @@ ScriptExecutionContext::Task::~Task() { } +#if USE(JSC) +JSC::JSGlobalData* ScriptExecutionContext::globalData() +{ + if (isDocument()) + return JSDOMWindow::commonJSGlobalData(); + +#if ENABLE(WORKERS) + if (isWorkerContext()) + return static_cast(this)->script()->globalData(); +#endif + + ASSERT_NOT_REACHED(); + return 0; +} +#endif + } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.h b/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.h index bb78b6f..398afec 100644 --- a/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.h +++ b/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.h @@ -104,6 +104,10 @@ namespace WebCore { void removeTimeout(int timeoutId); DOMTimer* findTimeout(int timeoutId); +#if USE(JSC) + JSC::JSGlobalData* globalData(); +#endif + protected: // Explicitly override the security origin for this script context. // Note: It is dangerous to change the security origin of a script context diff --git a/src/3rdparty/webkit/WebCore/dom/SelectElement.cpp b/src/3rdparty/webkit/WebCore/dom/SelectElement.cpp index 49713ba..3d2a549 100644 --- a/src/3rdparty/webkit/WebCore/dom/SelectElement.cpp +++ b/src/3rdparty/webkit/WebCore/dom/SelectElement.cpp @@ -479,12 +479,14 @@ bool SelectElement::appendFormData(SelectElementData& data, Element* element, Fo // We return the first one if it was a combobox select if (!successful && !data.multiple() && data.size() <= 1 && items.size()) { OptionElement* optionElement = toOptionElement(items[0]); - const AtomicString& value = optionElement->value(); - if (value.isNull()) - list.appendData(name, optionElement->text().stripWhiteSpace()); - else - list.appendData(name, value); - successful = true; + if (optionElement) { + const AtomicString& value = optionElement->value(); + if (value.isNull()) + list.appendData(name, optionElement->text().stripWhiteSpace()); + else + list.appendData(name, value); + successful = true; + } } return successful; @@ -874,13 +876,19 @@ void SelectElement::typeAheadFind(SelectElementData& data, Element* element, Key int index = (optionToListIndex(data, element, selected >= 0 ? selected : 0) + searchStartOffset) % itemCount; ASSERT(index >= 0); + // Compute a case-folded copy of the prefix string before beginning the search for + // a matching element. This code uses foldCase to work around the fact that + // String::startWith does not fold non-ASCII characters. This code can be changed + // to use startWith once that is fixed. + String prefixWithCaseFolded(prefix.foldCase()); for (int i = 0; i < itemCount; ++i, index = (index + 1) % itemCount) { OptionElement* optionElement = toOptionElement(items[index]); if (!optionElement || items[index]->disabled()) continue; + // Fold the option string and check if its prefix is equal to the folded prefix. String text = optionElement->textIndentedToRespectGroupLabel(); - if (stripLeadingWhiteSpace(text).startsWith(prefix, false)) { + if (stripLeadingWhiteSpace(text).foldCase().startsWith(prefixWithCaseFolded)) { setSelectedIndex(data, element, listToOptionIndex(data, element, index)); if (!data.usesMenuList()) listBoxOnChange(data, element); diff --git a/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.cpp b/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.cpp index 543927d..30d39e0 100644 --- a/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.cpp +++ b/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.cpp @@ -79,15 +79,41 @@ bool XMLTokenizer::isWMLDocument() const } #endif -void XMLTokenizer::setCurrentNode(Node* n) +void XMLTokenizer::pushCurrentNode(Node* n) { - bool nodeNeedsReference = n && n != m_doc; - if (nodeNeedsReference) - n->ref(); - if (m_currentNodeIsReferenced) - m_currentNode->deref(); + ASSERT(n); + ASSERT(m_currentNode); + if (n != m_doc) + n->ref(); + m_currentNodeStack.append(m_currentNode); m_currentNode = n; - m_currentNodeIsReferenced = nodeNeedsReference; +} + +void XMLTokenizer::popCurrentNode() +{ + ASSERT(m_currentNode); + ASSERT(m_currentNodeStack.size()); + + if (m_currentNode != m_doc) + m_currentNode->deref(); + + m_currentNode = m_currentNodeStack.last(); + m_currentNodeStack.removeLast(); +} + +void XMLTokenizer::clearCurrentNodeStack() +{ + if (m_currentNode && m_currentNode != m_doc) + m_currentNode->deref(); + m_currentNode = 0; + + if (m_currentNodeStack.size()) { // Aborted parsing. + for (size_t i = m_currentNodeStack.size() - 1; i != 0; --i) + m_currentNodeStack[i]->deref(); + if (m_currentNodeStack[0] && m_currentNodeStack[0] != m_doc) + m_currentNodeStack[0]->deref(); + m_currentNodeStack.clear(); + } } void XMLTokenizer::write(const SegmentedString& s, bool /*appendData*/) @@ -143,7 +169,7 @@ bool XMLTokenizer::enterText() RefPtr newNode = Text::create(m_doc, ""); if (!m_currentNode->addChild(newNode.get())) return false; - setCurrentNode(newNode.get()); + pushCurrentNode(newNode.get()); return true; } @@ -173,10 +199,7 @@ void XMLTokenizer::exitText() if (m_view && m_currentNode && !m_currentNode->attached()) m_currentNode->attach(); - // FIXME: What's the right thing to do if the parent is really 0? - // Just leaving the current node set to the text node doesn't make much sense. - if (Node* par = m_currentNode->parentNode()) - setCurrentNode(par); + popCurrentNode(); } void XMLTokenizer::end() @@ -190,7 +213,7 @@ void XMLTokenizer::end() m_doc->updateStyleSelector(); } - setCurrentNode(0); + clearCurrentNodeStack(); if (!m_parsingFragment) m_doc->finishedParsing(); } diff --git a/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.h b/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.h index 019a831..e1ee09f 100644 --- a/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.h +++ b/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.h @@ -124,7 +124,10 @@ public: friend bool parseXMLDocumentFragment(const String& chunk, DocumentFragment* fragment, Element* parent); void initializeParserContext(const char* chunk = 0); - void setCurrentNode(Node*); + + void pushCurrentNode(Node*); + void popCurrentNode(); + void clearCurrentNodeStack(); void insertErrorMessageBlock(); @@ -148,7 +151,7 @@ public: Vector m_bufferedText; #endif Node* m_currentNode; - bool m_currentNodeIsReferenced; + Vector m_currentNodeStack; bool m_sawError; bool m_sawXSLTransform; diff --git a/src/3rdparty/webkit/WebCore/dom/XMLTokenizerLibxml2.cpp b/src/3rdparty/webkit/WebCore/dom/XMLTokenizerLibxml2.cpp index 6cc0a0c..9aa0961 100644 --- a/src/3rdparty/webkit/WebCore/dom/XMLTokenizerLibxml2.cpp +++ b/src/3rdparty/webkit/WebCore/dom/XMLTokenizerLibxml2.cpp @@ -530,7 +530,6 @@ XMLTokenizer::XMLTokenizer(Document* _doc, FrameView* _view) , m_context(0) , m_pendingCallbacks(new PendingCallbacks) , m_currentNode(_doc) - , m_currentNodeIsReferenced(false) , m_sawError(false) , m_sawXSLTransform(false) , m_sawFirstElement(false) @@ -557,7 +556,6 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) , m_context(0) , m_pendingCallbacks(new PendingCallbacks) , m_currentNode(fragment) - , m_currentNodeIsReferenced(fragment) , m_sawError(false) , m_sawXSLTransform(false) , m_sawFirstElement(false) @@ -576,8 +574,7 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) , m_scriptStartLine(0) , m_parsingFragment(true) { - if (fragment) - fragment->ref(); + fragment->ref(); if (m_doc) m_doc->ref(); @@ -614,7 +611,7 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) XMLTokenizer::~XMLTokenizer() { - setCurrentNode(0); + clearCurrentNodeStack(); if (m_parsingFragment && m_doc) m_doc->deref(); if (m_pendingScript) @@ -801,7 +798,7 @@ void XMLTokenizer::startElementNs(const xmlChar* xmlLocalName, const xmlChar* xm return; } - setCurrentNode(newElement.get()); + pushCurrentNode(newElement.get()); if (m_view && !newElement->attached()) newElement->attach(); @@ -822,22 +819,29 @@ void XMLTokenizer::endElementNs() exitText(); Node* n = m_currentNode; - RefPtr parent = n->parentNode(); n->finishParsingChildren(); if (!n->isElementNode() || !m_view) { - setCurrentNode(parent.get()); + popCurrentNode(); return; } Element* element = static_cast(n); + + // The element's parent may have already been removed from document. + // Parsing continues in this case, but scripts aren't executed. + if (!element->inDocument()) { + popCurrentNode(); + return; + } + ScriptElement* scriptElement = toScriptElement(element); if (!scriptElement) { - setCurrentNode(parent.get()); + popCurrentNode(); return; } - // don't load external scripts for standalone documents (for now) + // Don't load external scripts for standalone documents (for now). ASSERT(!m_pendingScript); m_requestingScript = true; @@ -865,7 +869,7 @@ void XMLTokenizer::endElementNs() m_view->frame()->script()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), m_doc->url(), m_scriptStartLine)); } m_requestingScript = false; - setCurrentNode(parent.get()); + popCurrentNode(); } void XMLTokenizer::characters(const xmlChar* s, int len) diff --git a/src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp b/src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp index 65cbc21..c6e73ba 100644 --- a/src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp +++ b/src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp @@ -85,7 +85,6 @@ XMLTokenizer::XMLTokenizer(Document* _doc, FrameView* _view) , m_view(_view) , m_wroteText(false) , m_currentNode(_doc) - , m_currentNodeIsReferenced(false) , m_sawError(false) , m_sawXSLTransform(false) , m_sawFirstElement(false) @@ -114,7 +113,6 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) , m_view(0) , m_wroteText(false) , m_currentNode(fragment) - , m_currentNodeIsReferenced(fragment) , m_sawError(false) , m_sawXSLTransform(false) , m_sawFirstElement(false) @@ -133,8 +131,7 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) , m_scriptStartLine(0) , m_parsingFragment(true) { - if (fragment) - fragment->ref(); + fragment->ref(); if (m_doc) m_doc->ref(); @@ -188,7 +185,7 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) XMLTokenizer::~XMLTokenizer() { - setCurrentNode(0); + clearCurrentNodeStack(); if (m_parsingFragment && m_doc) m_doc->deref(); if (m_pendingScript) @@ -569,7 +566,7 @@ void XMLTokenizer::parseStartElement() return; } - setCurrentNode(newElement.get()); + pushCurrentNode(newElement.get()); if (m_view && !newElement->attached()) newElement->attach(); @@ -582,18 +579,26 @@ void XMLTokenizer::parseEndElement() exitText(); Node* n = m_currentNode; - RefPtr parent = n->parentNode(); n->finishParsingChildren(); if (!n->isElementNode() || !m_view) { - setCurrentNode(parent.get()); + if (!m_currentNodeStack.isEmpty()) + popCurrentNode(); return; } Element* element = static_cast(n); + + // The element's parent may have already been removed from document. + // Parsing continues in this case, but scripts aren't executed. + if (!element->inDocument()) { + popCurrentNode(); + return; + } + ScriptElement* scriptElement = toScriptElement(element); if (!scriptElement) { - setCurrentNode(parent.get()); + popCurrentNode(); return; } @@ -625,7 +630,7 @@ void XMLTokenizer::parseEndElement() m_view->frame()->script()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), m_doc->url(), m_scriptStartLine)); } m_requestingScript = false; - setCurrentNode(parent.get()); + popCurrentNode(); } void XMLTokenizer::parseCharacters() diff --git a/src/3rdparty/webkit/WebCore/editing/ApplyStyleCommand.cpp b/src/3rdparty/webkit/WebCore/editing/ApplyStyleCommand.cpp index 89d862f..7a8f025 100644 --- a/src/3rdparty/webkit/WebCore/editing/ApplyStyleCommand.cpp +++ b/src/3rdparty/webkit/WebCore/editing/ApplyStyleCommand.cpp @@ -334,6 +334,38 @@ static void diffTextDecorations(CSSMutableStyleDeclaration* style, int propertID setTextDecorationProperty(style, newTextDecoration.get(), propertID); } +static bool fontWeightIsBold(CSSStyleDeclaration* style) +{ + ASSERT(style); + RefPtr fontWeight = style->getPropertyCSSValue(CSSPropertyFontWeight); + + if (!fontWeight) + return false; + if (!fontWeight->isPrimitiveValue()) + return false; + + // Because b tag can only bold text, there are only two states in plain html: bold and not bold. + // Collapse all other values to either one of these two states for editing purposes. + switch (static_cast(fontWeight.get())->getIdent()) { + case CSSValue100: + case CSSValue200: + case CSSValue300: + case CSSValue400: + case CSSValue500: + case CSSValueNormal: + return false; + case CSSValueBold: + case CSSValue600: + case CSSValue700: + case CSSValue800: + case CSSValue900: + return true; + } + + ASSERT_NOT_REACHED(); // For CSSValueBolder and CSSValueLighter + return false; // Make compiler happy +} + RefPtr getPropertiesNotInComputedStyle(CSSStyleDeclaration* style, CSSComputedStyleDeclaration* computedStyle) { ASSERT(style); @@ -345,6 +377,9 @@ RefPtr getPropertiesNotInComputedStyle(CSSStyleDecla diffTextDecorations(result.get(), CSSPropertyTextDecoration, computedTextDecorationsInEffect.get()); diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, computedTextDecorationsInEffect.get()); + if (fontWeightIsBold(result.get()) == fontWeightIsBold(computedStyle)) + result->removeProperty(CSSPropertyFontWeight); + return result; } @@ -352,7 +387,6 @@ RefPtr getPropertiesNotInComputedStyle(CSSStyleDecla // e.g. when a user inserts a new paragraph, all properties listed here must be copied to the new paragraph. // FIXME: The current editingStyleProperties contains all inheritableProperties but we may not need to preserve all inheritable properties static const int editingStyleProperties[] = { - CSSPropertyBackgroundColor, // CSS inheritable properties CSSPropertyBorderCollapse, CSSPropertyColor, diff --git a/src/3rdparty/webkit/WebCore/editing/CompositeEditCommand.cpp b/src/3rdparty/webkit/WebCore/editing/CompositeEditCommand.cpp index 0496a8f..1617be8 100644 --- a/src/3rdparty/webkit/WebCore/editing/CompositeEditCommand.cpp +++ b/src/3rdparty/webkit/WebCore/editing/CompositeEditCommand.cpp @@ -20,7 +20,7 @@ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" @@ -71,7 +71,7 @@ namespace WebCore { using namespace HTMLNames; -CompositeEditCommand::CompositeEditCommand(Document *document) +CompositeEditCommand::CompositeEditCommand(Document *document) : EditCommand(document) { } @@ -396,7 +396,7 @@ void CompositeEditCommand::rebalanceWhitespaceAt(const Position& position) Node* node = position.node(); if (!node || !node->isTextNode()) return; - Text* textNode = static_cast(node); + Text* textNode = static_cast(node); if (textNode->length() == 0) return; @@ -739,6 +739,129 @@ void CompositeEditCommand::pushPartiallySelectedAnchorElementsDown() setEndingSelection(originalSelection); } +// Clone the paragraph between start and end under blockElement, +// preserving the hierarchy up to outerNode. + +void CompositeEditCommand::cloneParagraphUnderNewElement(Position& start, Position& end, Node* outerNode, Element* blockElement) +{ + // First we clone the outerNode + + RefPtr lastNode = outerNode->cloneNode(isTableElement(outerNode)); + appendNode(lastNode, blockElement); + + if (start.node() != outerNode) { + Vector > ancestors; + + // Insert each node from innerNode to outerNode (excluded) in a list. + for (Node* n = start.node(); n && n != outerNode; n = n->parentNode()) + ancestors.append(n); + + // Clone every node between start.node() and outerBlock. + + for (size_t i = ancestors.size(); i != 0; --i) { + Node* item = ancestors[i - 1].get(); + RefPtr child = item->cloneNode(isTableElement(item)); + appendNode(child, static_cast(lastNode.get())); + lastNode = child.release(); + } + } + + // Handle the case of paragraphs with more than one node, + // cloning all the siblings until end.node() is reached. + + if (start.node() != end.node()) { + for (Node* n = start.node()->nextSibling(); n != NULL; n = n->nextSibling()) { + RefPtr clonedNode = n->cloneNode(true); + insertNodeAfter(clonedNode, lastNode); + lastNode = clonedNode.release(); + if (n == end.node()) + break; + } + } +} + + +// There are bugs in deletion when it removes a fully selected table/list. +// It expands and removes the entire table/list, but will let content +// before and after the table/list collapse onto one line. +// Deleting a paragraph will leave a placeholder. Remove it (and prune +// empty or unrendered parents). + +void CompositeEditCommand::cleanupAfterDeletion() +{ + VisiblePosition caretAfterDelete = endingSelection().visibleStart(); + if (isStartOfParagraph(caretAfterDelete) && isEndOfParagraph(caretAfterDelete)) { + // Note: We want the rightmost candidate. + Position position = caretAfterDelete.deepEquivalent().downstream(); + Node* node = position.node(); + // Normally deletion will leave a br as a placeholder. + if (node->hasTagName(brTag)) + removeNodeAndPruneAncestors(node); + // If the selection to move was empty and in an empty block that + // doesn't require a placeholder to prop itself open (like a bordered + // div or an li), remove it during the move (the list removal code + // expects this behavior). + else if (isBlock(node)) + removeNodeAndPruneAncestors(node); + else if (lineBreakExistsAtPosition(position)) { + // There is a preserved '\n' at caretAfterDelete. + // We can safely assume this is a text node. + Text* textNode = static_cast(node); + if (textNode->length() == 1) + removeNodeAndPruneAncestors(node); + else + deleteTextFromNode(textNode, position.deprecatedEditingOffset(), 1); + } + } +} + +// This is a version of moveParagraph that preserves style by keeping the original markup +// It is currently used only by IndentOutdentCommand but it is meant to be used in the +// future by several other commands such as InsertList and the align commands. +// The blockElement parameter is the element to move the paragraph to, +// outerNode is the top element of the paragraph hierarchy. + +void CompositeEditCommand::moveParagraphWithClones(const VisiblePosition& startOfParagraphToMove, const VisiblePosition& endOfParagraphToMove, Element* blockElement, Node* outerNode) +{ + ASSERT(outerNode); + ASSERT(blockElement); + + VisiblePosition beforeParagraph = startOfParagraphToMove.previous(); + VisiblePosition afterParagraph(endOfParagraphToMove.next()); + + // We upstream() the end and downstream() the start so that we don't include collapsed whitespace in the move. + // When we paste a fragment, spaces after the end and before the start are treated as though they were rendered. + Position start = startOfParagraphToMove.deepEquivalent().downstream(); + Position end = endOfParagraphToMove.deepEquivalent().upstream(); + + cloneParagraphUnderNewElement(start, end, outerNode, blockElement); + + setEndingSelection(VisibleSelection(start, end, DOWNSTREAM)); + deleteSelection(false, false, false, false); + + // There are bugs in deletion when it removes a fully selected table/list. + // It expands and removes the entire table/list, but will let content + // before and after the table/list collapse onto one line. + + cleanupAfterDeletion(); + + // Add a br if pruning an empty block level element caused a collapse. For example: + // foo^ + //
bar
+ // baz + // Imagine moving 'bar' to ^. 'bar' will be deleted and its div pruned. That would + // cause 'baz' to collapse onto the line with 'foobar' unless we insert a br. + // Must recononicalize these two VisiblePositions after the pruning above. + beforeParagraph = VisiblePosition(beforeParagraph.deepEquivalent()); + afterParagraph = VisiblePosition(afterParagraph.deepEquivalent()); + + if (beforeParagraph.isNotNull() && !isTableElement(beforeParagraph.deepEquivalent().node()) && (!isEndOfParagraph(beforeParagraph) || beforeParagraph == afterParagraph)) { + // FIXME: Trim text between beforeParagraph and afterParagraph if they aren't equal. + insertNodeAt(createBreakElement(document()), beforeParagraph.deepEquivalent()); + } +} + + // This moves a paragraph preserving its style. void CompositeEditCommand::moveParagraph(const VisiblePosition& startOfParagraphToMove, const VisiblePosition& endOfParagraphToMove, const VisiblePosition& destination, bool preserveSelection, bool preserveStyle) { @@ -784,7 +907,7 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap VisiblePosition afterParagraph(endOfParagraphToMove.next()); // We upstream() the end and downstream() the start so that we don't include collapsed whitespace in the move. - // When we paste a fragment, spaces after the end and before the start are treated as though they were rendered. + // When we paste a fragment, spaces after the end and before the start are treated as though they were rendered. Position start = startOfParagraphToMove.deepEquivalent().downstream(); Position end = endOfParagraphToMove.deepEquivalent().upstream(); @@ -793,7 +916,7 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap Position endRangeCompliant = rangeCompliantEquivalent(end); RefPtr range = Range::create(document(), startRangeCompliant.node(), startRangeCompliant.deprecatedEditingOffset(), endRangeCompliant.node(), endRangeCompliant.deprecatedEditingOffset()); - // FIXME: This is an inefficient way to preserve style on nodes in the paragraph to move. It + // FIXME: This is an inefficient way to preserve style on nodes in the paragraph to move. It // shouldn't matter though, since moved paragraphs will usually be quite small. RefPtr fragment = startOfParagraphToMove != endOfParagraphToMove ? createFragmentFromMarkup(document(), createMarkup(range.get(), 0, DoNotAnnotateForInterchange, true), "") : 0; @@ -813,42 +936,14 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap deleteSelection(false, false, false, false); ASSERT(destination.deepEquivalent().node()->inDocument()); - - // There are bugs in deletion when it removes a fully selected table/list. - // It expands and removes the entire table/list, but will let content - // before and after the table/list collapse onto one line. - - // Deleting a paragraph will leave a placeholder. Remove it (and prune - // empty or unrendered parents). - VisiblePosition caretAfterDelete = endingSelection().visibleStart(); - if (isStartOfParagraph(caretAfterDelete) && isEndOfParagraph(caretAfterDelete)) { - // Note: We want the rightmost candidate. - Position position = caretAfterDelete.deepEquivalent().downstream(); - Node* node = position.node(); - // Normally deletion will leave a br as a placeholder. - if (node->hasTagName(brTag)) - removeNodeAndPruneAncestors(node); - // If the selection to move was empty and in an empty block that - // doesn't require a placeholder to prop itself open (like a bordered - // div or an li), remove it during the move (the list removal code - // expects this behavior). - else if (isBlock(node)) - removeNodeAndPruneAncestors(node); - else if (lineBreakExistsAtVisiblePosition(caretAfterDelete)) { - // There is a preserved '\n' at caretAfterDelete. - Text* textNode = static_cast(node); - if (textNode->length() == 1) - removeNodeAndPruneAncestors(node); - else - deleteTextFromNode(textNode, position.deprecatedEditingOffset(), 1); - } - } - // Add a br if pruning an empty block level element caused a collapse. For example: + cleanupAfterDeletion(); + + // Add a br if pruning an empty block level element caused a collapse. For example: // foo^ //
bar
// baz - // Imagine moving 'bar' to ^. 'bar' will be deleted and its div pruned. That would + // Imagine moving 'bar' to ^. 'bar' will be deleted and its div pruned. That would // cause 'baz' to collapse onto the line with 'foobar' unless we insert a br. // Must recononicalize these two VisiblePositions after the pruning above. beforeParagraph = VisiblePosition(beforeParagraph.deepEquivalent()); @@ -912,7 +1007,7 @@ bool CompositeEditCommand::breakOutOfEmptyListItem() removeNodePreservingChildren(listNode->parentNode()); newBlock = createListItemElement(document()); } - // If listNode does NOT appear at the end of the outer list item, then behave as if in a regular paragraph. + // If listNode does NOT appear at the end of the outer list item, then behave as if in a regular paragraph. } else if (blockEnclosingList->hasTagName(olTag) || blockEnclosingList->hasTagName(ulTag)) newBlock = createListItemElement(document()); } @@ -971,7 +1066,7 @@ bool CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph() // to hold the caret before the highest blockquote. insertNodeBefore(br, highestBlockquote); VisiblePosition atBR(Position(br.get(), 0)); - // If the br we inserted collapsed, for example foo
...
, insert + // If the br we inserted collapsed, for example foo
...
, insert // a second one. if (!isStartOfParagraph(atBR)) insertNodeBefore(createBreakElement(document()), br); @@ -1002,7 +1097,7 @@ bool CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph() return true; } -// Operations use this function to avoid inserting content into an anchor when at the start or the end of +// Operations use this function to avoid inserting content into an anchor when at the start or the end of // that anchor, as in NSTextView. // FIXME: This is only an approximation of NSTextViews insertion behavior, which varies depending on how // the caret was made. @@ -1022,7 +1117,7 @@ Position CompositeEditCommand::positionAvoidingSpecialElementBoundary(const Posi if (enclosingAnchor && !isBlock(enclosingAnchor)) { VisiblePosition firstInAnchor(firstDeepEditingPositionForNode(enclosingAnchor)); VisiblePosition lastInAnchor(lastDeepEditingPositionForNode(enclosingAnchor)); - // If visually just after the anchor, insert *inside* the anchor unless it's the last + // If visually just after the anchor, insert *inside* the anchor unless it's the last // VisiblePosition in the document, to match NSTextView. if (visiblePos == lastInAnchor) { // Make sure anchors are pushed down before avoiding them so that we don't diff --git a/src/3rdparty/webkit/WebCore/editing/CompositeEditCommand.h b/src/3rdparty/webkit/WebCore/editing/CompositeEditCommand.h index 2c6403e..0cceaaa 100644 --- a/src/3rdparty/webkit/WebCore/editing/CompositeEditCommand.h +++ b/src/3rdparty/webkit/WebCore/editing/CompositeEditCommand.h @@ -102,6 +102,9 @@ protected: void moveParagraph(const VisiblePosition&, const VisiblePosition&, const VisiblePosition&, bool preserveSelection = false, bool preserveStyle = true); void moveParagraphs(const VisiblePosition&, const VisiblePosition&, const VisiblePosition&, bool preserveSelection = false, bool preserveStyle = true); + void moveParagraphWithClones(const VisiblePosition& startOfParagraphToMove, const VisiblePosition& endOfParagraphToMove, Element* blockElement, Node* outerNode); + void cloneParagraphUnderNewElement(Position& start, Position& end, Node* outerNode, Element* blockElement); + void cleanupAfterDeletion(); bool breakOutOfEmptyListItem(); bool breakOutOfEmptyMailBlockquotedParagraph(); diff --git a/src/3rdparty/webkit/WebCore/editing/EditorCommand.cpp b/src/3rdparty/webkit/WebCore/editing/EditorCommand.cpp index abd0174..3379b3c 100644 --- a/src/3rdparty/webkit/WebCore/editing/EditorCommand.cpp +++ b/src/3rdparty/webkit/WebCore/editing/EditorCommand.cpp @@ -1291,10 +1291,10 @@ static String valueForeColor(Frame* frame, Event*) // Map of functions +struct CommandEntry { const char* name; EditorInternalCommand command; }; + static const CommandMap& createCommandMap() { - struct CommandEntry { const char* name; EditorInternalCommand command; }; - static const CommandEntry commands[] = { { "AlignCenter", { executeJustifyCenter, supportedFromMenuOrKeyBinding, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, { "AlignJustified", { executeJustifyFull, supportedFromMenuOrKeyBinding, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, diff --git a/src/3rdparty/webkit/WebCore/editing/IndentOutdentCommand.cpp b/src/3rdparty/webkit/WebCore/editing/IndentOutdentCommand.cpp index 84fa147..808a2f8 100644 --- a/src/3rdparty/webkit/WebCore/editing/IndentOutdentCommand.cpp +++ b/src/3rdparty/webkit/WebCore/editing/IndentOutdentCommand.cpp @@ -67,37 +67,6 @@ IndentOutdentCommand::IndentOutdentCommand(Document* document, EIndentType typeO { } -// This function is a workaround for moveParagraph's tendency to strip blockquotes. It updates lastBlockquote to point to the -// correct level for the current paragraph, and returns a pointer to a placeholder br where the insertion should be performed. -PassRefPtr IndentOutdentCommand::prepareBlockquoteLevelForInsertion(const VisiblePosition& currentParagraph, RefPtr& lastBlockquote) -{ - int currentBlockquoteLevel = 0; - int lastBlockquoteLevel = 0; - Node* node = currentParagraph.deepEquivalent().node(); - while ((node = enclosingNodeWithTag(Position(node->parentNode(), 0), blockquoteTag))) - currentBlockquoteLevel++; - node = lastBlockquote.get(); - while ((node = enclosingNodeWithTag(Position(node->parentNode(), 0), blockquoteTag))) - lastBlockquoteLevel++; - while (currentBlockquoteLevel > lastBlockquoteLevel) { - RefPtr newBlockquote = createIndentBlockquoteElement(document()); - appendNode(newBlockquote, lastBlockquote); - lastBlockquote = newBlockquote; - lastBlockquoteLevel++; - } - while (currentBlockquoteLevel < lastBlockquoteLevel) { - lastBlockquote = static_cast(enclosingNodeWithTag(Position(lastBlockquote->parentNode(), 0), blockquoteTag)); - lastBlockquoteLevel--; - } - RefPtr placeholder = createBreakElement(document()); - appendNode(placeholder, lastBlockquote); - // Add another br before the placeholder if it collapsed. - VisiblePosition visiblePos(Position(placeholder.get(), 0)); - if (!isStartOfParagraph(visiblePos)) - insertNodeBefore(createBreakElement(document()), placeholder); - return placeholder.release(); -} - bool IndentOutdentCommand::tryIndentingAsListItem(const VisiblePosition& endOfCurrentParagraph) { // If our selection is not inside a list, bail out. @@ -117,13 +86,9 @@ bool IndentOutdentCommand::tryIndentingAsListItem(const VisiblePosition& endOfCu Element* nextList = selectedListItem->nextElementSibling(); RefPtr newList = document()->createElement(listNode->tagQName(), false); - RefPtr newListItem = selectedListItem->cloneElementWithoutChildren(); - RefPtr placeholder = createBreakElement(document()); insertNodeBefore(newList, selectedListItem); - appendNode(newListItem, newList); - appendNode(placeholder, newListItem); - moveParagraph(startOfParagraph(endOfCurrentParagraph), endOfCurrentParagraph, VisiblePosition(Position(placeholder, 0)), true); + moveParagraphWithClones(startOfParagraph(endOfCurrentParagraph), endOfCurrentParagraph, newList.get(), selectedListItem); if (canMergeLists(previousList, newList.get())) mergeIdenticalElements(previousList, newList); @@ -137,25 +102,31 @@ void IndentOutdentCommand::indentIntoBlockquote(const VisiblePosition& endOfCurr { Node* enclosingCell = 0; + Position start = startOfParagraph(endOfCurrentParagraph).deepEquivalent(); + enclosingCell = enclosingNodeOfType(start, &isTableCell); + Node* nodeToSplitTo; + if (enclosingCell) + nodeToSplitTo = enclosingCell; + else if (enclosingList(start.node())) + nodeToSplitTo = enclosingBlock(start.node()); + else + nodeToSplitTo = editableRootForPosition(start); + + RefPtr outerBlock = splitTreeToNode(start.node(), nodeToSplitTo); + if (!targetBlockquote) { // Create a new blockquote and insert it as a child of the root editable element. We accomplish // this by splitting all parents of the current paragraph up to that point. targetBlockquote = createIndentBlockquoteElement(document()); - Position start = startOfParagraph(endOfCurrentParagraph).deepEquivalent(); - enclosingCell = enclosingNodeOfType(start, &isTableCell); - Node* nodeToSplitTo = enclosingCell ? enclosingCell : editableRootForPosition(start); - RefPtr startOfNewBlock = splitTreeToNode(start.node(), nodeToSplitTo); - insertNodeBefore(targetBlockquote, startOfNewBlock); + insertNodeBefore(targetBlockquote, outerBlock); } - RefPtr insertionPoint = prepareBlockquoteLevelForInsertion(endOfCurrentParagraph, targetBlockquote); - + moveParagraphWithClones(startOfParagraph(endOfCurrentParagraph), endOfCurrentParagraph, targetBlockquote.get(), outerBlock.get()); + // Don't put the next paragraph in the blockquote we just created for this paragraph unless // the next paragraph is in the same cell. if (enclosingCell && enclosingCell != enclosingNodeOfType(endOfNextParagraph.deepEquivalent(), &isTableCell)) targetBlockquote = 0; - - moveParagraph(startOfParagraph(endOfCurrentParagraph), endOfCurrentParagraph, VisiblePosition(Position(insertionPoint, 0)), true); } void IndentOutdentCommand::indentRegion() @@ -191,8 +162,6 @@ void IndentOutdentCommand::indentRegion() blockquoteForNextIndent = 0; else indentIntoBlockquote(endOfCurrentParagraph, endOfNextParagraph, blockquoteForNextIndent); - // blockquoteForNextIndent maybe updated - // this is due to the way prepareBlockquoteLevelForInsertion was designed. // Sanity check: Make sure our moveParagraph calls didn't remove endOfNextParagraph.deepEquivalent().node() // If somehow we did, return to prevent crashes. if (endOfNextParagraph.isNotNull() && !endOfNextParagraph.deepEquivalent().node()->inDocument()) { diff --git a/src/3rdparty/webkit/WebCore/editing/IndentOutdentCommand.h b/src/3rdparty/webkit/WebCore/editing/IndentOutdentCommand.h index 419f832f..817b4c8 100644 --- a/src/3rdparty/webkit/WebCore/editing/IndentOutdentCommand.h +++ b/src/3rdparty/webkit/WebCore/editing/IndentOutdentCommand.h @@ -49,7 +49,6 @@ private: void indentRegion(); void outdentRegion(); void outdentParagraph(); - PassRefPtr prepareBlockquoteLevelForInsertion(const VisiblePosition&, RefPtr&); bool tryIndentingAsListItem(const VisiblePosition&); void indentIntoBlockquote(const VisiblePosition&, const VisiblePosition&, RefPtr&); diff --git a/src/3rdparty/webkit/WebCore/editing/ReplaceNodeWithSpanCommand.cpp b/src/3rdparty/webkit/WebCore/editing/ReplaceNodeWithSpanCommand.cpp index 21ca924..0874201 100644 --- a/src/3rdparty/webkit/WebCore/editing/ReplaceNodeWithSpanCommand.cpp +++ b/src/3rdparty/webkit/WebCore/editing/ReplaceNodeWithSpanCommand.cpp @@ -57,7 +57,9 @@ static void swapInNodePreservingAttributesAndChildren(Node* newNode, Node* nodeT parentNode->insertBefore(newNode, nodeToReplace, ec); ASSERT(!ec); - for (Node* child = nodeToReplace->firstChild(); child; child = child->nextSibling()) { + Node* nextChild; + for (Node* child = nodeToReplace->firstChild(); child; child = nextChild) { + nextChild = child->nextSibling(); newNode->appendChild(child, ec); ASSERT(!ec); } diff --git a/src/3rdparty/webkit/WebCore/editing/SelectionController.cpp b/src/3rdparty/webkit/WebCore/editing/SelectionController.cpp index 7d99916..00672f2 100644 --- a/src/3rdparty/webkit/WebCore/editing/SelectionController.cpp +++ b/src/3rdparty/webkit/WebCore/editing/SelectionController.cpp @@ -725,6 +725,8 @@ bool SelectionController::modify(EAlteration alter, int verticalDistance, bool u if (userTriggered) m_frame->setSelectionGranularity(CharacterGranularity); + m_lastChangeWasHorizontalExtension = alter == EXTEND; + return true; } diff --git a/src/3rdparty/webkit/WebCore/generated/CSSPropertyNames.cpp b/src/3rdparty/webkit/WebCore/generated/CSSPropertyNames.cpp index 8780c36..919eb24 100644 --- a/src/3rdparty/webkit/WebCore/generated/CSSPropertyNames.cpp +++ b/src/3rdparty/webkit/WebCore/generated/CSSPropertyNames.cpp @@ -226,7 +226,7 @@ findProp (register const char *str, register unsigned int len) { enum { - TOTAL_KEYWORDS = 278, + TOTAL_KEYWORDS = 280, MIN_WORD_LENGTH = 3, MAX_WORD_LENGTH = 43, MIN_HASH_VALUE = 6, @@ -241,67 +241,67 @@ findProp (register const char *str, register unsigned int len) {"zoom", CSSPropertyZoom}, #line 23 "CSSPropertyNames.gperf" {"border", CSSPropertyBorder}, -#line 267 "CSSPropertyNames.gperf" +#line 268 "CSSPropertyNames.gperf" {"marker", CSSPropertyMarker}, #line 24 "CSSPropertyNames.gperf" {"border-bottom", CSSPropertyBorderBottom}, -#line 269 "CSSPropertyNames.gperf" +#line 270 "CSSPropertyNames.gperf" {"marker-mid", CSSPropertyMarkerMid}, #line 78 "CSSPropertyNames.gperf" {"margin", CSSPropertyMargin}, -#line 285 "CSSPropertyNames.gperf" +#line 286 "CSSPropertyNames.gperf" {"kerning", CSSPropertyKerning}, -#line 268 "CSSPropertyNames.gperf" +#line 269 "CSSPropertyNames.gperf" {"marker-end", CSSPropertyMarkerEnd}, #line 79 "CSSPropertyNames.gperf" {"margin-bottom", CSSPropertyMarginBottom}, -#line 251 "CSSPropertyNames.gperf" +#line 252 "CSSPropertyNames.gperf" {"mask", CSSPropertyMask}, -#line 272 "CSSPropertyNames.gperf" +#line 273 "CSSPropertyNames.gperf" {"stroke", CSSPropertyStroke}, #line 111 "CSSPropertyNames.gperf" {"size", CSSPropertySize}, #line 144 "CSSPropertyNames.gperf" {"word-break", CSSPropertyWordBreak}, -#line 287 "CSSPropertyNames.gperf" +#line 288 "CSSPropertyNames.gperf" {"writing-mode", CSSPropertyWritingMode}, -#line 162 "CSSPropertyNames.gperf" +#line 163 "CSSPropertyNames.gperf" {"-webkit-binding", CSSPropertyWebkitBinding}, #line 109 "CSSPropertyNames.gperf" {"resize", CSSPropertyResize}, -#line 266 "CSSPropertyNames.gperf" +#line 267 "CSSPropertyNames.gperf" {"image-rendering", CSSPropertyImageRendering}, #line 149 "CSSPropertyNames.gperf" {"-webkit-animation", CSSPropertyWebkitAnimation}, -#line 165 "CSSPropertyNames.gperf" +#line 166 "CSSPropertyNames.gperf" {"-webkit-border-image", CSSPropertyWebkitBorderImage}, -#line 205 "CSSPropertyNames.gperf" +#line 206 "CSSPropertyNames.gperf" {"-webkit-mask", CSSPropertyWebkitMask}, #line 136 "CSSPropertyNames.gperf" {"top", CSSPropertyTop}, #line 142 "CSSPropertyNames.gperf" {"widows", CSSPropertyWidows}, -#line 270 "CSSPropertyNames.gperf" +#line 271 "CSSPropertyNames.gperf" {"marker-start", CSSPropertyMarkerStart}, #line 154 "CSSPropertyNames.gperf" {"-webkit-animation-name", CSSPropertyWebkitAnimationName}, #line 102 "CSSPropertyNames.gperf" {"page", CSSPropertyPage}, -#line 210 "CSSPropertyNames.gperf" +#line 211 "CSSPropertyNames.gperf" {"-webkit-mask-image", CSSPropertyWebkitMaskImage}, #line 43 "CSSPropertyNames.gperf" {"border-top", CSSPropertyBorderTop}, #line 97 "CSSPropertyNames.gperf" {"padding", CSSPropertyPadding}, -#line 240 "CSSPropertyNames.gperf" +#line 241 "CSSPropertyNames.gperf" {"-webkit-transition", CSSPropertyWebkitTransition}, -#line 211 "CSSPropertyNames.gperf" +#line 212 "CSSPropertyNames.gperf" {"-webkit-mask-origin", CSSPropertyWebkitMaskOrigin}, #line 98 "CSSPropertyNames.gperf" {"padding-bottom", CSSPropertyPaddingBottom}, #line 82 "CSSPropertyNames.gperf" {"margin-top", CSSPropertyMarginTop}, -#line 197 "CSSPropertyNames.gperf" +#line 198 "CSSPropertyNames.gperf" {"-webkit-margin-start", CSSPropertyWebkitMarginStart}, #line 55 "CSSPropertyNames.gperf" {"content", CSSPropertyContent}, @@ -309,35 +309,35 @@ findProp (register const char *str, register unsigned int len) {"position", CSSPropertyPosition}, #line 59 "CSSPropertyNames.gperf" {"direction", CSSPropertyDirection}, -#line 218 "CSSPropertyNames.gperf" +#line 219 "CSSPropertyNames.gperf" {"-webkit-mask-size", CSSPropertyWebkitMaskSize}, #line 112 "CSSPropertyNames.gperf" {"src", CSSPropertySrc}, #line 146 "CSSPropertyNames.gperf" {"word-wrap", CSSPropertyWordWrap}, -#line 220 "CSSPropertyNames.gperf" +#line 221 "CSSPropertyNames.gperf" {"-webkit-nbsp-mode", CSSPropertyWebkitNbspMode}, #line 105 "CSSPropertyNames.gperf" {"page-break-inside", CSSPropertyPageBreakInside}, -#line 215 "CSSPropertyNames.gperf" +#line 216 "CSSPropertyNames.gperf" {"-webkit-mask-repeat", CSSPropertyWebkitMaskRepeat}, #line 101 "CSSPropertyNames.gperf" {"padding-top", CSSPropertyPaddingTop}, -#line 221 "CSSPropertyNames.gperf" +#line 222 "CSSPropertyNames.gperf" {"-webkit-padding-start", CSSPropertyWebkitPaddingStart}, #line 151 "CSSPropertyNames.gperf" {"-webkit-animation-direction", CSSPropertyWebkitAnimationDirection}, -#line 212 "CSSPropertyNames.gperf" +#line 213 "CSSPropertyNames.gperf" {"-webkit-mask-position", CSSPropertyWebkitMaskPosition}, -#line 193 "CSSPropertyNames.gperf" +#line 194 "CSSPropertyNames.gperf" {"-webkit-line-break", CSSPropertyWebkitLineBreak}, -#line 277 "CSSPropertyNames.gperf" +#line 278 "CSSPropertyNames.gperf" {"stroke-miterlimit", CSSPropertyStrokeMiterlimit}, -#line 226 "CSSPropertyNames.gperf" +#line 227 "CSSPropertyNames.gperf" {"-webkit-rtl-ordering", CSSPropertyWebkitRtlOrdering}, -#line 276 "CSSPropertyNames.gperf" +#line 277 "CSSPropertyNames.gperf" {"stroke-linejoin", CSSPropertyStrokeLinejoin}, -#line 282 "CSSPropertyNames.gperf" +#line 283 "CSSPropertyNames.gperf" {"dominant-baseline", CSSPropertyDominantBaseline}, #line 51 "CSSPropertyNames.gperf" {"caption-side", CSSPropertyCaptionSide}, @@ -357,25 +357,25 @@ findProp (register const char *str, register unsigned int len) {"word-spacing", CSSPropertyWordSpacing}, #line 31 "CSSPropertyNames.gperf" {"border-color", CSSPropertyBorderColor}, -#line 199 "CSSPropertyNames.gperf" +#line 200 "CSSPropertyNames.gperf" {"-webkit-marquee", CSSPropertyWebkitMarquee}, #line 25 "CSSPropertyNames.gperf" {"border-bottom-color", CSSPropertyBorderBottomColor}, #line 152 "CSSPropertyNames.gperf" {"-webkit-animation-duration", CSSPropertyWebkitAnimationDuration}, -#line 245 "CSSPropertyNames.gperf" +#line 246 "CSSPropertyNames.gperf" {"-webkit-user-drag", CSSPropertyWebkitUserDrag}, -#line 166 "CSSPropertyNames.gperf" +#line 167 "CSSPropertyNames.gperf" {"-webkit-border-radius", CSSPropertyWebkitBorderRadius}, -#line 209 "CSSPropertyNames.gperf" +#line 210 "CSSPropertyNames.gperf" {"-webkit-mask-composite", CSSPropertyWebkitMaskComposite}, -#line 262 "CSSPropertyNames.gperf" +#line 263 "CSSPropertyNames.gperf" {"color-rendering", CSSPropertyColorRendering}, #line 137 "CSSPropertyNames.gperf" {"unicode-bidi", CSSPropertyUnicodeBidi}, #line 53 "CSSPropertyNames.gperf" {"clip", CSSPropertyClip}, -#line 242 "CSSPropertyNames.gperf" +#line 243 "CSSPropertyNames.gperf" {"-webkit-transition-duration", CSSPropertyWebkitTransitionDuration}, #line 157 "CSSPropertyNames.gperf" {"-webkit-appearance", CSSPropertyWebkitAppearance}, @@ -395,33 +395,35 @@ findProp (register const char *str, register unsigned int len) {"background-origin", CSSPropertyBackgroundOrigin}, #line 57 "CSSPropertyNames.gperf" {"counter-reset", CSSPropertyCounterReset}, -#line 257 "CSSPropertyNames.gperf" +#line 258 "CSSPropertyNames.gperf" {"stop-color", CSSPropertyStopColor}, -#line 280 "CSSPropertyNames.gperf" +#line 281 "CSSPropertyNames.gperf" {"alignment-baseline", CSSPropertyAlignmentBaseline}, #line 22 "CSSPropertyNames.gperf" {"background-size", CSSPropertyBackgroundSize}, -#line 202 "CSSPropertyNames.gperf" +#line 203 "CSSPropertyNames.gperf" {"-webkit-marquee-repetition", CSSPropertyWebkitMarqueeRepetition}, -#line 275 "CSSPropertyNames.gperf" +#line 276 "CSSPropertyNames.gperf" {"stroke-linecap", CSSPropertyStrokeLinecap}, #line 161 "CSSPropertyNames.gperf" {"-webkit-background-origin", CSSPropertyWebkitBackgroundOrigin}, #line 72 "CSSPropertyNames.gperf" {"letter-spacing", CSSPropertyLetterSpacing}, -#line 203 "CSSPropertyNames.gperf" +#line 204 "CSSPropertyNames.gperf" {"-webkit-marquee-speed", CSSPropertyWebkitMarqueeSpeed}, -#line 208 "CSSPropertyNames.gperf" +#line 209 "CSSPropertyNames.gperf" {"-webkit-mask-clip", CSSPropertyWebkitMaskClip}, #line 153 "CSSPropertyNames.gperf" {"-webkit-animation-iteration-count", CSSPropertyWebkitAnimationIterationCount}, -#line 200 "CSSPropertyNames.gperf" - {"-webkit-marquee-direction", CSSPropertyWebkitMarqueeDirection}, #line 201 "CSSPropertyNames.gperf" + {"-webkit-marquee-direction", CSSPropertyWebkitMarqueeDirection}, +#line 162 "CSSPropertyNames.gperf" + {"-webkit-background-size", CSSPropertyWebkitBackgroundSize}, +#line 202 "CSSPropertyNames.gperf" {"-webkit-marquee-increment", CSSPropertyWebkitMarqueeIncrement}, #line 19 "CSSPropertyNames.gperf" {"background-repeat", CSSPropertyBackgroundRepeat}, -#line 222 "CSSPropertyNames.gperf" +#line 223 "CSSPropertyNames.gperf" {"-webkit-perspective", CSSPropertyWebkitPerspective}, #line 110 "CSSPropertyNames.gperf" {"right", CSSPropertyRight}, @@ -433,7 +435,7 @@ findProp (register const char *str, register unsigned int len) {"background-position", CSSPropertyBackgroundPosition}, #line 86 "CSSPropertyNames.gperf" {"min-width", CSSPropertyMinWidth}, -#line 223 "CSSPropertyNames.gperf" +#line 224 "CSSPropertyNames.gperf" {"-webkit-perspective-origin", CSSPropertyWebkitPerspectiveOrigin}, #line 37 "CSSPropertyNames.gperf" {"border-right", CSSPropertyBorderRight}, @@ -445,18 +447,20 @@ findProp (register const char *str, register unsigned int len) {"margin-right", CSSPropertyMarginRight}, #line 29 "CSSPropertyNames.gperf" {"border-bottom-width", CSSPropertyBorderBottomWidth}, -#line 252 "CSSPropertyNames.gperf" +#line 253 "CSSPropertyNames.gperf" {"enable-background", CSSPropertyEnableBackground}, -#line 279 "CSSPropertyNames.gperf" +#line 280 "CSSPropertyNames.gperf" {"stroke-width", CSSPropertyStrokeWidth}, -#line 189 "CSSPropertyNames.gperf" +#line 190 "CSSPropertyNames.gperf" {"-webkit-columns", CSSPropertyWebkitColumns}, -#line 194 "CSSPropertyNames.gperf" +#line 195 "CSSPropertyNames.gperf" {"-webkit-line-clamp", CSSPropertyWebkitLineClamp}, -#line 259 "CSSPropertyNames.gperf" +#line 260 "CSSPropertyNames.gperf" {"color-interpolation", CSSPropertyColorInterpolation}, -#line 163 "CSSPropertyNames.gperf" +#line 164 "CSSPropertyNames.gperf" {"-webkit-border-fit", CSSPropertyWebkitBorderFit}, +#line 289 "CSSPropertyNames.gperf" + {"-webkit-shadow", CSSPropertyWebkitShadow}, #line 65 "CSSPropertyNames.gperf" {"font-size", CSSPropertyFontSize}, #line 30 "CSSPropertyNames.gperf" @@ -467,11 +471,11 @@ findProp (register const char *str, register unsigned int len) {"z-index", CSSPropertyZIndex}, #line 139 "CSSPropertyNames.gperf" {"vertical-align", CSSPropertyVerticalAlign}, -#line 181 "CSSPropertyNames.gperf" +#line 182 "CSSPropertyNames.gperf" {"-webkit-column-break-inside", CSSPropertyWebkitColumnBreakInside}, #line 100 "CSSPropertyNames.gperf" {"padding-right", CSSPropertyPaddingRight}, -#line 247 "CSSPropertyNames.gperf" +#line 248 "CSSPropertyNames.gperf" {"-webkit-user-select", CSSPropertyWebkitUserSelect}, #line 48 "CSSPropertyNames.gperf" {"border-top-width", CSSPropertyBorderTopWidth}, @@ -479,49 +483,49 @@ findProp (register const char *str, register unsigned int len) {"text-rendering", CSSPropertyTextRendering}, #line 88 "CSSPropertyNames.gperf" {"orphans", CSSPropertyOrphans}, -#line 174 "CSSPropertyNames.gperf" +#line 175 "CSSPropertyNames.gperf" {"-webkit-box-orient", CSSPropertyWebkitBoxOrient}, -#line 234 "CSSPropertyNames.gperf" +#line 235 "CSSPropertyNames.gperf" {"-webkit-transform", CSSPropertyWebkitTransform}, -#line 183 "CSSPropertyNames.gperf" +#line 184 "CSSPropertyNames.gperf" {"-webkit-column-gap", CSSPropertyWebkitColumnGap}, -#line 196 "CSSPropertyNames.gperf" +#line 197 "CSSPropertyNames.gperf" {"-webkit-margin-collapse", CSSPropertyWebkitMarginCollapse}, #line 160 "CSSPropertyNames.gperf" {"-webkit-background-composite", CSSPropertyWebkitBackgroundComposite}, -#line 195 "CSSPropertyNames.gperf" +#line 196 "CSSPropertyNames.gperf" {"-webkit-margin-bottom-collapse", CSSPropertyWebkitMarginBottomCollapse}, #line 13 "CSSPropertyNames.gperf" {"background-color", CSSPropertyBackgroundColor}, -#line 231 "CSSPropertyNames.gperf" +#line 232 "CSSPropertyNames.gperf" {"-webkit-text-stroke", CSSPropertyWebkitTextStroke}, -#line 271 "CSSPropertyNames.gperf" +#line 272 "CSSPropertyNames.gperf" {"shape-rendering", CSSPropertyShapeRendering}, #line 104 "CSSPropertyNames.gperf" {"page-break-before", CSSPropertyPageBreakBefore}, -#line 235 "CSSPropertyNames.gperf" +#line 236 "CSSPropertyNames.gperf" {"-webkit-transform-origin", CSSPropertyWebkitTransformOrigin}, #line 103 "CSSPropertyNames.gperf" {"page-break-after", CSSPropertyPageBreakAfter}, #line 90 "CSSPropertyNames.gperf" {"outline-color", CSSPropertyOutlineColor}, -#line 207 "CSSPropertyNames.gperf" +#line 208 "CSSPropertyNames.gperf" {"-webkit-mask-box-image", CSSPropertyWebkitMaskBoxImage}, -#line 178 "CSSPropertyNames.gperf" +#line 179 "CSSPropertyNames.gperf" {"-webkit-box-sizing", CSSPropertyWebkitBoxSizing}, #line 71 "CSSPropertyNames.gperf" {"left", CSSPropertyLeft}, -#line 238 "CSSPropertyNames.gperf" +#line 239 "CSSPropertyNames.gperf" {"-webkit-transform-origin-z", CSSPropertyWebkitTransformOriginZ}, #line 68 "CSSPropertyNames.gperf" {"font-variant", CSSPropertyFontVariant}, #line 62 "CSSPropertyNames.gperf" {"float", CSSPropertyFloat}, -#line 253 "CSSPropertyNames.gperf" +#line 254 "CSSPropertyNames.gperf" {"filter", CSSPropertyFilter}, #line 32 "CSSPropertyNames.gperf" {"border-left", CSSPropertyBorderLeft}, -#line 206 "CSSPropertyNames.gperf" +#line 207 "CSSPropertyNames.gperf" {"-webkit-mask-attachment", CSSPropertyWebkitMaskAttachment}, #line 115 "CSSPropertyNames.gperf" {"text-decoration", CSSPropertyTextDecoration}, @@ -529,31 +533,31 @@ findProp (register const char *str, register unsigned int len) {"margin-left", CSSPropertyMarginLeft}, #line 12 "CSSPropertyNames.gperf" {"background-clip", CSSPropertyBackgroundClip}, -#line 198 "CSSPropertyNames.gperf" +#line 199 "CSSPropertyNames.gperf" {"-webkit-margin-top-collapse", CSSPropertyWebkitMarginTopCollapse}, -#line 167 "CSSPropertyNames.gperf" +#line 168 "CSSPropertyNames.gperf" {"-webkit-border-vertical-spacing", CSSPropertyWebkitBorderVerticalSpacing}, -#line 250 "CSSPropertyNames.gperf" +#line 251 "CSSPropertyNames.gperf" {"clip-rule", CSSPropertyClipRule}, -#line 169 "CSSPropertyNames.gperf" +#line 170 "CSSPropertyNames.gperf" {"-webkit-box-direction", CSSPropertyWebkitBoxDirection}, #line 141 "CSSPropertyNames.gperf" {"white-space", CSSPropertyWhiteSpace}, #line 114 "CSSPropertyNames.gperf" {"text-align", CSSPropertyTextAlign}, -#line 216 "CSSPropertyNames.gperf" +#line 217 "CSSPropertyNames.gperf" {"-webkit-mask-repeat-x", CSSPropertyWebkitMaskRepeatX}, #line 159 "CSSPropertyNames.gperf" {"-webkit-background-clip", CSSPropertyWebkitBackgroundClip}, -#line 217 "CSSPropertyNames.gperf" +#line 218 "CSSPropertyNames.gperf" {"-webkit-mask-repeat-y", CSSPropertyWebkitMaskRepeatY}, -#line 168 "CSSPropertyNames.gperf" +#line 169 "CSSPropertyNames.gperf" {"-webkit-box-align", CSSPropertyWebkitBoxAlign}, -#line 213 "CSSPropertyNames.gperf" +#line 214 "CSSPropertyNames.gperf" {"-webkit-mask-position-x", CSSPropertyWebkitMaskPositionX}, #line 99 "CSSPropertyNames.gperf" {"padding-left", CSSPropertyPaddingLeft}, -#line 190 "CSSPropertyNames.gperf" +#line 191 "CSSPropertyNames.gperf" {"-webkit-font-size-delta", CSSPropertyWebkitFontSizeDelta}, #line 27 "CSSPropertyNames.gperf" {"border-bottom-right-radius", CSSPropertyBorderBottomRightRadius}, @@ -561,61 +565,61 @@ findProp (register const char *str, register unsigned int len) {"opacity", CSSPropertyOpacity}, #line 38 "CSSPropertyNames.gperf" {"border-right-color", CSSPropertyBorderRightColor}, -#line 175 "CSSPropertyNames.gperf" +#line 176 "CSSPropertyNames.gperf" {"-webkit-box-pack", CSSPropertyWebkitBoxPack}, -#line 172 "CSSPropertyNames.gperf" +#line 173 "CSSPropertyNames.gperf" {"-webkit-box-lines", CSSPropertyWebkitBoxLines}, #line 42 "CSSPropertyNames.gperf" {"border-style", CSSPropertyBorderStyle}, -#line 214 "CSSPropertyNames.gperf" +#line 215 "CSSPropertyNames.gperf" {"-webkit-mask-position-y", CSSPropertyWebkitMaskPositionY}, #line 94 "CSSPropertyNames.gperf" {"overflow", CSSPropertyOverflow}, #line 28 "CSSPropertyNames.gperf" {"border-bottom-style", CSSPropertyBorderBottomStyle}, -#line 263 "CSSPropertyNames.gperf" +#line 264 "CSSPropertyNames.gperf" {"fill", CSSPropertyFill}, #line 150 "CSSPropertyNames.gperf" {"-webkit-animation-delay", CSSPropertyWebkitAnimationDelay}, -#line 278 "CSSPropertyNames.gperf" +#line 279 "CSSPropertyNames.gperf" {"stroke-opacity", CSSPropertyStrokeOpacity}, #line 123 "CSSPropertyNames.gperf" {"text-overline", CSSPropertyTextOverline}, -#line 182 "CSSPropertyNames.gperf" +#line 183 "CSSPropertyNames.gperf" {"-webkit-column-count", CSSPropertyWebkitColumnCount}, #line 125 "CSSPropertyNames.gperf" {"text-overline-mode", CSSPropertyTextOverlineMode}, #line 46 "CSSPropertyNames.gperf" {"border-top-right-radius", CSSPropertyBorderTopRightRadius}, -#line 241 "CSSPropertyNames.gperf" +#line 242 "CSSPropertyNames.gperf" {"-webkit-transition-delay", CSSPropertyWebkitTransitionDelay}, #line 60 "CSSPropertyNames.gperf" {"display", CSSPropertyDisplay}, #line 93 "CSSPropertyNames.gperf" {"outline-width", CSSPropertyOutlineWidth}, -#line 243 "CSSPropertyNames.gperf" +#line 244 "CSSPropertyNames.gperf" {"-webkit-transition-property", CSSPropertyWebkitTransitionProperty}, #line 47 "CSSPropertyNames.gperf" {"border-top-style", CSSPropertyBorderTopStyle}, -#line 184 "CSSPropertyNames.gperf" +#line 185 "CSSPropertyNames.gperf" {"-webkit-column-rule", CSSPropertyWebkitColumnRule}, #line 140 "CSSPropertyNames.gperf" {"visibility", CSSPropertyVisibility}, -#line 249 "CSSPropertyNames.gperf" +#line 250 "CSSPropertyNames.gperf" {"clip-path", CSSPropertyClipPath}, -#line 258 "CSSPropertyNames.gperf" +#line 259 "CSSPropertyNames.gperf" {"stop-opacity", CSSPropertyStopOpacity}, -#line 248 "CSSPropertyNames.gperf" +#line 249 "CSSPropertyNames.gperf" {"-webkit-variable-declaration-block", CSSPropertyWebkitVariableDeclarationBlock}, -#line 230 "CSSPropertyNames.gperf" +#line 231 "CSSPropertyNames.gperf" {"-webkit-text-size-adjust", CSSPropertyWebkitTextSizeAdjust}, -#line 232 "CSSPropertyNames.gperf" +#line 233 "CSSPropertyNames.gperf" {"-webkit-text-stroke-color", CSSPropertyWebkitTextStrokeColor}, -#line 256 "CSSPropertyNames.gperf" +#line 257 "CSSPropertyNames.gperf" {"lighting-color", CSSPropertyLightingColor}, #line 70 "CSSPropertyNames.gperf" {"height", CSSPropertyHeight}, -#line 254 "CSSPropertyNames.gperf" +#line 255 "CSSPropertyNames.gperf" {"flood-color", CSSPropertyFloodColor}, #line 156 "CSSPropertyNames.gperf" {"-webkit-animation-timing-function", CSSPropertyWebkitAnimationTimingFunction}, @@ -635,21 +639,21 @@ findProp (register const char *str, register unsigned int len) {"border-left-color", CSSPropertyBorderLeftColor}, #line 74 "CSSPropertyNames.gperf" {"list-style", CSSPropertyListStyle}, -#line 164 "CSSPropertyNames.gperf" +#line 165 "CSSPropertyNames.gperf" {"-webkit-border-horizontal-spacing", CSSPropertyWebkitBorderHorizontalSpacing}, -#line 244 "CSSPropertyNames.gperf" +#line 245 "CSSPropertyNames.gperf" {"-webkit-transition-timing-function", CSSPropertyWebkitTransitionTimingFunction}, #line 75 "CSSPropertyNames.gperf" {"list-style-image", CSSPropertyListStyleImage}, #line 40 "CSSPropertyNames.gperf" {"border-right-width", CSSPropertyBorderRightWidth}, -#line 188 "CSSPropertyNames.gperf" +#line 189 "CSSPropertyNames.gperf" {"-webkit-column-width", CSSPropertyWebkitColumnWidth}, #line 20 "CSSPropertyNames.gperf" {"background-repeat-x", CSSPropertyBackgroundRepeatX}, #line 69 "CSSPropertyNames.gperf" {"font-weight", CSSPropertyFontWeight}, -#line 261 "CSSPropertyNames.gperf" +#line 262 "CSSPropertyNames.gperf" {"color-profile", CSSPropertyColorProfile}, #line 45 "CSSPropertyNames.gperf" {"border-top-left-radius", CSSPropertyBorderTopLeftRadius}, @@ -659,21 +663,21 @@ findProp (register const char *str, register unsigned int len) {"background-position-x", CSSPropertyBackgroundPositionX}, #line 84 "CSSPropertyNames.gperf" {"max-width", CSSPropertyMaxWidth}, -#line 224 "CSSPropertyNames.gperf" +#line 225 "CSSPropertyNames.gperf" {"-webkit-perspective-origin-x", CSSPropertyWebkitPerspectiveOriginX}, -#line 180 "CSSPropertyNames.gperf" +#line 181 "CSSPropertyNames.gperf" {"-webkit-column-break-before", CSSPropertyWebkitColumnBreakBefore}, -#line 179 "CSSPropertyNames.gperf" +#line 180 "CSSPropertyNames.gperf" {"-webkit-column-break-after", CSSPropertyWebkitColumnBreakAfter}, #line 18 "CSSPropertyNames.gperf" {"background-position-y", CSSPropertyBackgroundPositionY}, -#line 191 "CSSPropertyNames.gperf" +#line 192 "CSSPropertyNames.gperf" {"-webkit-font-smoothing", CSSPropertyWebkitFontSmoothing}, -#line 173 "CSSPropertyNames.gperf" +#line 174 "CSSPropertyNames.gperf" {"-webkit-box-ordinal-group", CSSPropertyWebkitBoxOrdinalGroup}, -#line 204 "CSSPropertyNames.gperf" +#line 205 "CSSPropertyNames.gperf" {"-webkit-marquee-style", CSSPropertyWebkitMarqueeStyle}, -#line 225 "CSSPropertyNames.gperf" +#line 226 "CSSPropertyNames.gperf" {"-webkit-perspective-origin-y", CSSPropertyWebkitPerspectiveOriginY}, #line 129 "CSSPropertyNames.gperf" {"text-shadow", CSSPropertyTextShadow}, @@ -683,13 +687,13 @@ findProp (register const char *str, register unsigned int len) {"list-style-position", CSSPropertyListStylePosition}, #line 113 "CSSPropertyNames.gperf" {"table-layout", CSSPropertyTableLayout}, -#line 177 "CSSPropertyNames.gperf" +#line 178 "CSSPropertyNames.gperf" {"-webkit-box-shadow", CSSPropertyWebkitBoxShadow}, #line 124 "CSSPropertyNames.gperf" {"text-overline-color", CSSPropertyTextOverlineColor}, #line 61 "CSSPropertyNames.gperf" {"empty-cells", CSSPropertyEmptyCells}, -#line 233 "CSSPropertyNames.gperf" +#line 234 "CSSPropertyNames.gperf" {"-webkit-text-stroke-width", CSSPropertyWebkitTextStrokeWidth}, #line 130 "CSSPropertyNames.gperf" {"text-transform", CSSPropertyTextTransform}, @@ -697,25 +701,25 @@ findProp (register const char *str, register unsigned int len) {"font-stretch", CSSPropertyFontStretch}, #line 92 "CSSPropertyNames.gperf" {"outline-style", CSSPropertyOutlineStyle}, -#line 286 "CSSPropertyNames.gperf" +#line 287 "CSSPropertyNames.gperf" {"text-anchor", CSSPropertyTextAnchor}, -#line 185 "CSSPropertyNames.gperf" +#line 186 "CSSPropertyNames.gperf" {"-webkit-column-rule-color", CSSPropertyWebkitColumnRuleColor}, -#line 273 "CSSPropertyNames.gperf" +#line 274 "CSSPropertyNames.gperf" {"stroke-dasharray", CSSPropertyStrokeDasharray}, #line 35 "CSSPropertyNames.gperf" {"border-left-width", CSSPropertyBorderLeftWidth}, -#line 265 "CSSPropertyNames.gperf" +#line 266 "CSSPropertyNames.gperf" {"fill-rule", CSSPropertyFillRule}, -#line 236 "CSSPropertyNames.gperf" +#line 237 "CSSPropertyNames.gperf" {"-webkit-transform-origin-x", CSSPropertyWebkitTransformOriginX}, -#line 281 "CSSPropertyNames.gperf" +#line 282 "CSSPropertyNames.gperf" {"baseline-shift", CSSPropertyBaselineShift}, #line 132 "CSSPropertyNames.gperf" {"text-underline-color", CSSPropertyTextUnderlineColor}, -#line 237 "CSSPropertyNames.gperf" +#line 238 "CSSPropertyNames.gperf" {"-webkit-transform-origin-y", CSSPropertyWebkitTransformOriginY}, -#line 260 "CSSPropertyNames.gperf" +#line 261 "CSSPropertyNames.gperf" {"color-interpolation-filters", CSSPropertyColorInterpolationFilters}, #line 39 "CSSPropertyNames.gperf" {"border-right-style", CSSPropertyBorderRightStyle}, @@ -727,63 +731,63 @@ findProp (register const char *str, register unsigned int len) {"overflow-x", CSSPropertyOverflowX}, #line 122 "CSSPropertyNames.gperf" {"text-overflow", CSSPropertyTextOverflow}, -#line 176 "CSSPropertyNames.gperf" +#line 177 "CSSPropertyNames.gperf" {"-webkit-box-reflect", CSSPropertyWebkitBoxReflect}, -#line 246 "CSSPropertyNames.gperf" +#line 247 "CSSPropertyNames.gperf" {"-webkit-user-modify", CSSPropertyWebkitUserModify}, -#line 187 "CSSPropertyNames.gperf" +#line 188 "CSSPropertyNames.gperf" {"-webkit-column-rule-width", CSSPropertyWebkitColumnRuleWidth}, #line 96 "CSSPropertyNames.gperf" {"overflow-y", CSSPropertyOverflowY}, -#line 239 "CSSPropertyNames.gperf" +#line 240 "CSSPropertyNames.gperf" {"-webkit-transform-style", CSSPropertyWebkitTransformStyle}, #line 91 "CSSPropertyNames.gperf" {"outline-offset", CSSPropertyOutlineOffset}, #line 135 "CSSPropertyNames.gperf" {"text-underline-width", CSSPropertyTextUnderlineWidth}, -#line 255 "CSSPropertyNames.gperf" +#line 256 "CSSPropertyNames.gperf" {"flood-opacity", CSSPropertyFloodOpacity}, #line 34 "CSSPropertyNames.gperf" {"border-left-style", CSSPropertyBorderLeftStyle}, #line 83 "CSSPropertyNames.gperf" {"max-height", CSSPropertyMaxHeight}, -#line 229 "CSSPropertyNames.gperf" +#line 230 "CSSPropertyNames.gperf" {"-webkit-text-security", CSSPropertyWebkitTextSecurity}, -#line 192 "CSSPropertyNames.gperf" +#line 193 "CSSPropertyNames.gperf" {"-webkit-highlight", CSSPropertyWebkitHighlight}, -#line 264 "CSSPropertyNames.gperf" +#line 265 "CSSPropertyNames.gperf" {"fill-opacity", CSSPropertyFillOpacity}, -#line 274 "CSSPropertyNames.gperf" +#line 275 "CSSPropertyNames.gperf" {"stroke-dashoffset", CSSPropertyStrokeDashoffset}, #line 126 "CSSPropertyNames.gperf" {"text-overline-style", CSSPropertyTextOverlineStyle}, #line 77 "CSSPropertyNames.gperf" {"list-style-type", CSSPropertyListStyleType}, -#line 219 "CSSPropertyNames.gperf" +#line 220 "CSSPropertyNames.gperf" {"-webkit-match-nearest-mail-blockquote-color", CSSPropertyWebkitMatchNearestMailBlockquoteColor}, -#line 186 "CSSPropertyNames.gperf" +#line 187 "CSSPropertyNames.gperf" {"-webkit-column-rule-style", CSSPropertyWebkitColumnRuleStyle}, #line 158 "CSSPropertyNames.gperf" {"-webkit-backface-visibility", CSSPropertyWebkitBackfaceVisibility}, -#line 228 "CSSPropertyNames.gperf" +#line 229 "CSSPropertyNames.gperf" {"-webkit-text-fill-color", CSSPropertyWebkitTextFillColor}, #line 134 "CSSPropertyNames.gperf" {"text-underline-style", CSSPropertyTextUnderlineStyle}, -#line 284 "CSSPropertyNames.gperf" +#line 285 "CSSPropertyNames.gperf" {"glyph-orientation-vertical", CSSPropertyGlyphOrientationVertical}, #line 64 "CSSPropertyNames.gperf" {"font-family", CSSPropertyFontFamily}, -#line 170 "CSSPropertyNames.gperf" +#line 171 "CSSPropertyNames.gperf" {"-webkit-box-flex", CSSPropertyWebkitBoxFlex}, #line 117 "CSSPropertyNames.gperf" {"text-line-through", CSSPropertyTextLineThrough}, #line 119 "CSSPropertyNames.gperf" {"text-line-through-mode", CSSPropertyTextLineThroughMode}, -#line 227 "CSSPropertyNames.gperf" +#line 228 "CSSPropertyNames.gperf" {"-webkit-text-decorations-in-effect", CSSPropertyWebkitTextDecorationsInEffect}, -#line 283 "CSSPropertyNames.gperf" +#line 284 "CSSPropertyNames.gperf" {"glyph-orientation-horizontal", CSSPropertyGlyphOrientationHorizontal}, -#line 171 "CSSPropertyNames.gperf" +#line 172 "CSSPropertyNames.gperf" {"-webkit-box-flex-group", CSSPropertyWebkitBoxFlexGroup}, #line 118 "CSSPropertyNames.gperf" {"text-line-through-color", CSSPropertyTextLineThroughColor}, @@ -825,113 +829,113 @@ findProp (register const char *str, register unsigned int len) -1, -1, -1, -1, -1, 80, -1, -1, -1, -1, -1, -1, -1, 81, -1, 82, 83, -1, -1, 84, 85, -1, -1, -1, 86, -1, 87, 88, -1, -1, - -1, -1, -1, 89, -1, 90, -1, -1, -1, -1, - 91, -1, -1, -1, -1, -1, -1, 92, -1, -1, - -1, -1, -1, -1, 93, -1, -1, -1, -1, -1, - 94, -1, 95, -1, -1, 96, -1, -1, -1, 97, - -1, -1, -1, -1, 98, -1, 99, 100, -1, -1, - -1, -1, 101, -1, 102, -1, -1, 103, -1, 104, - -1, -1, -1, -1, -1, -1, -1, 105, -1, -1, - -1, -1, 106, -1, -1, -1, -1, -1, -1, -1, - 107, -1, -1, 108, 109, -1, -1, -1, 110, -1, - -1, -1, -1, -1, 111, 112, 113, 114, -1, 115, - -1, -1, -1, -1, -1, -1, -1, 116, 117, 118, - -1, 119, -1, -1, 120, -1, -1, 121, 122, -1, - -1, -1, 123, 124, -1, -1, -1, -1, 125, -1, - -1, -1, -1, 126, -1, 127, 128, -1, -1, 129, - 130, -1, 131, -1, 132, -1, 133, -1, 134, -1, - -1, -1, 135, 136, 137, -1, 138, 139, -1, -1, - 140, 141, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 142, -1, 143, -1, -1, -1, -1, -1, -1, - 144, 145, -1, -1, -1, 146, -1, 147, -1, -1, - -1, 148, -1, -1, 149, -1, 150, -1, -1, -1, - -1, 151, -1, -1, -1, 152, 153, -1, 154, -1, + -1, -1, -1, 89, -1, 90, -1, -1, 91, -1, + 92, -1, -1, -1, -1, -1, -1, 93, -1, -1, + -1, -1, -1, -1, 94, -1, -1, -1, -1, -1, + 95, -1, 96, -1, -1, 97, -1, -1, -1, 98, + -1, -1, -1, -1, 99, -1, 100, 101, -1, -1, + -1, -1, 102, -1, 103, -1, -1, 104, -1, 105, + -1, -1, -1, -1, -1, -1, -1, 106, -1, -1, + -1, -1, 107, -1, -1, -1, -1, -1, -1, -1, + 108, -1, -1, 109, 110, -1, -1, -1, 111, 112, + -1, -1, -1, -1, 113, 114, 115, 116, -1, 117, + -1, -1, -1, -1, -1, -1, -1, 118, 119, 120, + -1, 121, -1, -1, 122, -1, -1, 123, 124, -1, + -1, -1, 125, 126, -1, -1, -1, -1, 127, -1, + -1, -1, -1, 128, -1, 129, 130, -1, -1, 131, + 132, -1, 133, -1, 134, -1, 135, -1, 136, -1, + -1, -1, 137, 138, 139, -1, 140, 141, -1, -1, + 142, 143, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 144, -1, 145, -1, -1, -1, -1, -1, -1, + 146, 147, -1, -1, -1, 148, -1, 149, -1, -1, + -1, 150, -1, -1, 151, -1, 152, -1, -1, -1, + -1, 153, -1, -1, -1, 154, 155, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 155, 156, 157, -1, - -1, -1, 158, 159, -1, -1, 160, 161, 162, -1, - -1, 163, 164, -1, -1, -1, -1, 165, 166, -1, - -1, -1, -1, 167, 168, -1, -1, -1, -1, 169, - -1, -1, -1, 170, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 171, -1, -1, -1, 172, -1, - 173, -1, -1, 174, -1, -1, -1, -1, 175, 176, - -1, -1, 177, 178, -1, -1, -1, -1, -1, -1, - -1, -1, 179, -1, -1, -1, 180, -1, -1, 181, - 182, -1, -1, -1, -1, -1, -1, -1, -1, 183, - -1, -1, 184, -1, 185, -1, -1, -1, -1, 186, - 187, -1, -1, -1, 188, -1, -1, -1, -1, -1, - -1, 189, -1, -1, -1, -1, 190, -1, 191, 192, - 193, -1, -1, 194, 195, -1, -1, -1, -1, -1, - 196, 197, 198, -1, -1, 199, -1, -1, -1, -1, - -1, -1, -1, 200, 201, -1, -1, -1, -1, -1, - -1, 202, -1, 203, -1, -1, -1, -1, -1, -1, - 204, -1, -1, -1, 205, -1, 206, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 207, -1, - -1, -1, 208, -1, 209, -1, 210, -1, -1, 211, - -1, -1, -1, 212, -1, -1, -1, 213, -1, -1, - -1, 214, -1, -1, -1, -1, 215, 216, -1, -1, - 217, 218, -1, 219, -1, -1, 220, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 221, -1, -1, 222, - -1, -1, -1, -1, -1, -1, -1, 223, 224, 225, - -1, 226, -1, -1, -1, 227, -1, -1, -1, 228, - -1, -1, 229, -1, -1, -1, -1, -1, 230, -1, - -1, 231, -1, -1, -1, -1, -1, -1, -1, -1, - 232, -1, -1, -1, -1, -1, 233, 234, -1, -1, - -1, -1, -1, -1, 235, -1, -1, -1, -1, -1, - -1, 236, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 237, - 238, 239, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 157, 158, 159, -1, + -1, -1, 160, 161, -1, -1, 162, 163, 164, -1, + -1, 165, 166, -1, -1, -1, -1, 167, 168, -1, + -1, -1, -1, 169, 170, -1, -1, -1, -1, 171, + -1, -1, -1, 172, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 173, -1, -1, -1, 174, -1, + 175, -1, -1, 176, -1, -1, -1, -1, 177, 178, + -1, -1, 179, 180, -1, -1, -1, -1, -1, -1, + -1, -1, 181, -1, -1, -1, 182, -1, -1, 183, + 184, -1, -1, -1, -1, -1, -1, -1, -1, 185, + -1, -1, 186, -1, 187, -1, -1, -1, -1, 188, + 189, -1, -1, -1, 190, -1, -1, -1, -1, -1, + -1, 191, -1, -1, -1, -1, 192, -1, 193, 194, + 195, -1, -1, 196, 197, -1, -1, -1, -1, -1, + 198, 199, 200, -1, -1, 201, -1, -1, -1, -1, + -1, -1, -1, 202, 203, -1, -1, -1, -1, -1, + -1, 204, -1, 205, -1, -1, -1, -1, -1, -1, + 206, -1, -1, -1, 207, -1, 208, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 209, -1, + -1, -1, 210, -1, 211, -1, 212, -1, -1, 213, + -1, -1, -1, 214, -1, -1, -1, 215, -1, -1, + -1, 216, -1, -1, -1, -1, 217, 218, -1, -1, + 219, 220, -1, 221, -1, -1, 222, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 223, -1, -1, 224, + -1, -1, -1, -1, -1, -1, -1, 225, 226, 227, + -1, 228, -1, -1, -1, 229, -1, -1, -1, 230, + -1, -1, 231, -1, -1, -1, -1, -1, 232, -1, + -1, 233, -1, -1, -1, -1, -1, -1, -1, -1, + 234, -1, -1, -1, -1, -1, 235, 236, -1, -1, + -1, -1, -1, -1, 237, -1, -1, -1, -1, -1, + -1, 238, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 239, + 240, 241, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 240, -1, -1, -1, -1, -1, 241, -1, - -1, -1, -1, -1, -1, 242, -1, -1, -1, -1, + -1, -1, 242, -1, -1, -1, -1, -1, 243, -1, + -1, -1, -1, -1, -1, 244, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 243, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 245, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 244, -1, -1, 245, -1, -1, -1, -1, -1, 246, - -1, -1, -1, -1, 247, 248, -1, -1, -1, -1, - 249, -1, -1, 250, -1, -1, -1, -1, -1, -1, + 246, -1, -1, 247, -1, -1, -1, -1, -1, 248, + -1, -1, -1, -1, 249, 250, -1, -1, -1, -1, + 251, -1, -1, 252, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 251, - -1, -1, -1, -1, -1, 252, -1, -1, -1, -1, - -1, -1, -1, 253, -1, -1, -1, -1, -1, -1, - -1, -1, 254, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 253, + -1, -1, -1, -1, -1, 254, -1, -1, -1, -1, + -1, -1, -1, 255, -1, -1, -1, -1, -1, -1, + -1, -1, 256, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 255, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 257, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 256, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 258, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 257, -1, -1, -1, -1, 258, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 259, -1, 260, + -1, -1, 259, -1, -1, -1, -1, 260, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 261, -1, 262, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 261, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 262, -1, - 263, -1, -1, -1, -1, -1, -1, 264, -1, -1, - -1, -1, -1, 265, -1, -1, -1, -1, -1, -1, + 263, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 264, -1, + 265, -1, -1, -1, -1, -1, -1, 266, -1, -1, + -1, -1, -1, 267, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 266, -1, -1, -1, -1, -1, 267, -1, -1, -1, + 268, -1, -1, -1, -1, -1, 269, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 268, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 270, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 269, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 271, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 270, -1, -1, -1, -1, 271, -1, -1, + -1, -1, 272, -1, -1, -1, -1, 273, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 272, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 274, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 273, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 275, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -939,10 +943,10 @@ findProp (register const char *str, register unsigned int len) -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 274, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 276, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 275, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 277, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -956,7 +960,7 @@ findProp (register const char *str, register unsigned int len) -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 276, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 278, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -976,7 +980,7 @@ findProp (register const char *str, register unsigned int len) -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 277 + -1, -1, -1, 279 }; if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) @@ -998,9 +1002,9 @@ findProp (register const char *str, register unsigned int len) } return 0; } -#line 288 "CSSPropertyNames.gperf" +#line 290 "CSSPropertyNames.gperf" -static const char * const propertyNameStrings[278] = { +static const char * const propertyNameStrings[280] = { "background", "background-attachment", "background-clip", @@ -1153,6 +1157,7 @@ static const char * const propertyNameStrings[278] = { "-webkit-background-clip", "-webkit-background-composite", "-webkit-background-origin", +"-webkit-background-size", "-webkit-binding", "-webkit-border-fit", "-webkit-border-horizontal-spacing", @@ -1279,6 +1284,7 @@ static const char * const propertyNameStrings[278] = { "kerning", "text-anchor", "writing-mode", +"-webkit-shadow", }; const char* getPropertyName(CSSPropertyID id) { diff --git a/src/3rdparty/webkit/WebCore/generated/CSSPropertyNames.h b/src/3rdparty/webkit/WebCore/generated/CSSPropertyNames.h index f1332e3..8957af8 100644 --- a/src/3rdparty/webkit/WebCore/generated/CSSPropertyNames.h +++ b/src/3rdparty/webkit/WebCore/generated/CSSPropertyNames.h @@ -157,136 +157,138 @@ enum CSSPropertyID { CSSPropertyWebkitBackgroundClip = 1150, CSSPropertyWebkitBackgroundComposite = 1151, CSSPropertyWebkitBackgroundOrigin = 1152, - CSSPropertyWebkitBinding = 1153, - CSSPropertyWebkitBorderFit = 1154, - CSSPropertyWebkitBorderHorizontalSpacing = 1155, - CSSPropertyWebkitBorderImage = 1156, - CSSPropertyWebkitBorderRadius = 1157, - CSSPropertyWebkitBorderVerticalSpacing = 1158, - CSSPropertyWebkitBoxAlign = 1159, - CSSPropertyWebkitBoxDirection = 1160, - CSSPropertyWebkitBoxFlex = 1161, - CSSPropertyWebkitBoxFlexGroup = 1162, - CSSPropertyWebkitBoxLines = 1163, - CSSPropertyWebkitBoxOrdinalGroup = 1164, - CSSPropertyWebkitBoxOrient = 1165, - CSSPropertyWebkitBoxPack = 1166, - CSSPropertyWebkitBoxReflect = 1167, - CSSPropertyWebkitBoxShadow = 1168, - CSSPropertyWebkitBoxSizing = 1169, - CSSPropertyWebkitColumnBreakAfter = 1170, - CSSPropertyWebkitColumnBreakBefore = 1171, - CSSPropertyWebkitColumnBreakInside = 1172, - CSSPropertyWebkitColumnCount = 1173, - CSSPropertyWebkitColumnGap = 1174, - CSSPropertyWebkitColumnRule = 1175, - CSSPropertyWebkitColumnRuleColor = 1176, - CSSPropertyWebkitColumnRuleStyle = 1177, - CSSPropertyWebkitColumnRuleWidth = 1178, - CSSPropertyWebkitColumnWidth = 1179, - CSSPropertyWebkitColumns = 1180, - CSSPropertyWebkitFontSizeDelta = 1181, - CSSPropertyWebkitFontSmoothing = 1182, - CSSPropertyWebkitHighlight = 1183, - CSSPropertyWebkitLineBreak = 1184, - CSSPropertyWebkitLineClamp = 1185, - CSSPropertyWebkitMarginBottomCollapse = 1186, - CSSPropertyWebkitMarginCollapse = 1187, - CSSPropertyWebkitMarginStart = 1188, - CSSPropertyWebkitMarginTopCollapse = 1189, - CSSPropertyWebkitMarquee = 1190, - CSSPropertyWebkitMarqueeDirection = 1191, - CSSPropertyWebkitMarqueeIncrement = 1192, - CSSPropertyWebkitMarqueeRepetition = 1193, - CSSPropertyWebkitMarqueeSpeed = 1194, - CSSPropertyWebkitMarqueeStyle = 1195, - CSSPropertyWebkitMask = 1196, - CSSPropertyWebkitMaskAttachment = 1197, - CSSPropertyWebkitMaskBoxImage = 1198, - CSSPropertyWebkitMaskClip = 1199, - CSSPropertyWebkitMaskComposite = 1200, - CSSPropertyWebkitMaskImage = 1201, - CSSPropertyWebkitMaskOrigin = 1202, - CSSPropertyWebkitMaskPosition = 1203, - CSSPropertyWebkitMaskPositionX = 1204, - CSSPropertyWebkitMaskPositionY = 1205, - CSSPropertyWebkitMaskRepeat = 1206, - CSSPropertyWebkitMaskRepeatX = 1207, - CSSPropertyWebkitMaskRepeatY = 1208, - CSSPropertyWebkitMaskSize = 1209, - CSSPropertyWebkitMatchNearestMailBlockquoteColor = 1210, - CSSPropertyWebkitNbspMode = 1211, - CSSPropertyWebkitPaddingStart = 1212, - CSSPropertyWebkitPerspective = 1213, - CSSPropertyWebkitPerspectiveOrigin = 1214, - CSSPropertyWebkitPerspectiveOriginX = 1215, - CSSPropertyWebkitPerspectiveOriginY = 1216, - CSSPropertyWebkitRtlOrdering = 1217, - CSSPropertyWebkitTextDecorationsInEffect = 1218, - CSSPropertyWebkitTextFillColor = 1219, - CSSPropertyWebkitTextSecurity = 1220, - CSSPropertyWebkitTextSizeAdjust = 1221, - CSSPropertyWebkitTextStroke = 1222, - CSSPropertyWebkitTextStrokeColor = 1223, - CSSPropertyWebkitTextStrokeWidth = 1224, - CSSPropertyWebkitTransform = 1225, - CSSPropertyWebkitTransformOrigin = 1226, - CSSPropertyWebkitTransformOriginX = 1227, - CSSPropertyWebkitTransformOriginY = 1228, - CSSPropertyWebkitTransformOriginZ = 1229, - CSSPropertyWebkitTransformStyle = 1230, - CSSPropertyWebkitTransition = 1231, - CSSPropertyWebkitTransitionDelay = 1232, - CSSPropertyWebkitTransitionDuration = 1233, - CSSPropertyWebkitTransitionProperty = 1234, - CSSPropertyWebkitTransitionTimingFunction = 1235, - CSSPropertyWebkitUserDrag = 1236, - CSSPropertyWebkitUserModify = 1237, - CSSPropertyWebkitUserSelect = 1238, - CSSPropertyWebkitVariableDeclarationBlock = 1239, - CSSPropertyClipPath = 1240, - CSSPropertyClipRule = 1241, - CSSPropertyMask = 1242, - CSSPropertyEnableBackground = 1243, - CSSPropertyFilter = 1244, - CSSPropertyFloodColor = 1245, - CSSPropertyFloodOpacity = 1246, - CSSPropertyLightingColor = 1247, - CSSPropertyStopColor = 1248, - CSSPropertyStopOpacity = 1249, - CSSPropertyColorInterpolation = 1250, - CSSPropertyColorInterpolationFilters = 1251, - CSSPropertyColorProfile = 1252, - CSSPropertyColorRendering = 1253, - CSSPropertyFill = 1254, - CSSPropertyFillOpacity = 1255, - CSSPropertyFillRule = 1256, - CSSPropertyImageRendering = 1257, - CSSPropertyMarker = 1258, - CSSPropertyMarkerEnd = 1259, - CSSPropertyMarkerMid = 1260, - CSSPropertyMarkerStart = 1261, - CSSPropertyShapeRendering = 1262, - CSSPropertyStroke = 1263, - CSSPropertyStrokeDasharray = 1264, - CSSPropertyStrokeDashoffset = 1265, - CSSPropertyStrokeLinecap = 1266, - CSSPropertyStrokeLinejoin = 1267, - CSSPropertyStrokeMiterlimit = 1268, - CSSPropertyStrokeOpacity = 1269, - CSSPropertyStrokeWidth = 1270, - CSSPropertyAlignmentBaseline = 1271, - CSSPropertyBaselineShift = 1272, - CSSPropertyDominantBaseline = 1273, - CSSPropertyGlyphOrientationHorizontal = 1274, - CSSPropertyGlyphOrientationVertical = 1275, - CSSPropertyKerning = 1276, - CSSPropertyTextAnchor = 1277, - CSSPropertyWritingMode = 1278, + CSSPropertyWebkitBackgroundSize = 1153, + CSSPropertyWebkitBinding = 1154, + CSSPropertyWebkitBorderFit = 1155, + CSSPropertyWebkitBorderHorizontalSpacing = 1156, + CSSPropertyWebkitBorderImage = 1157, + CSSPropertyWebkitBorderRadius = 1158, + CSSPropertyWebkitBorderVerticalSpacing = 1159, + CSSPropertyWebkitBoxAlign = 1160, + CSSPropertyWebkitBoxDirection = 1161, + CSSPropertyWebkitBoxFlex = 1162, + CSSPropertyWebkitBoxFlexGroup = 1163, + CSSPropertyWebkitBoxLines = 1164, + CSSPropertyWebkitBoxOrdinalGroup = 1165, + CSSPropertyWebkitBoxOrient = 1166, + CSSPropertyWebkitBoxPack = 1167, + CSSPropertyWebkitBoxReflect = 1168, + CSSPropertyWebkitBoxShadow = 1169, + CSSPropertyWebkitBoxSizing = 1170, + CSSPropertyWebkitColumnBreakAfter = 1171, + CSSPropertyWebkitColumnBreakBefore = 1172, + CSSPropertyWebkitColumnBreakInside = 1173, + CSSPropertyWebkitColumnCount = 1174, + CSSPropertyWebkitColumnGap = 1175, + CSSPropertyWebkitColumnRule = 1176, + CSSPropertyWebkitColumnRuleColor = 1177, + CSSPropertyWebkitColumnRuleStyle = 1178, + CSSPropertyWebkitColumnRuleWidth = 1179, + CSSPropertyWebkitColumnWidth = 1180, + CSSPropertyWebkitColumns = 1181, + CSSPropertyWebkitFontSizeDelta = 1182, + CSSPropertyWebkitFontSmoothing = 1183, + CSSPropertyWebkitHighlight = 1184, + CSSPropertyWebkitLineBreak = 1185, + CSSPropertyWebkitLineClamp = 1186, + CSSPropertyWebkitMarginBottomCollapse = 1187, + CSSPropertyWebkitMarginCollapse = 1188, + CSSPropertyWebkitMarginStart = 1189, + CSSPropertyWebkitMarginTopCollapse = 1190, + CSSPropertyWebkitMarquee = 1191, + CSSPropertyWebkitMarqueeDirection = 1192, + CSSPropertyWebkitMarqueeIncrement = 1193, + CSSPropertyWebkitMarqueeRepetition = 1194, + CSSPropertyWebkitMarqueeSpeed = 1195, + CSSPropertyWebkitMarqueeStyle = 1196, + CSSPropertyWebkitMask = 1197, + CSSPropertyWebkitMaskAttachment = 1198, + CSSPropertyWebkitMaskBoxImage = 1199, + CSSPropertyWebkitMaskClip = 1200, + CSSPropertyWebkitMaskComposite = 1201, + CSSPropertyWebkitMaskImage = 1202, + CSSPropertyWebkitMaskOrigin = 1203, + CSSPropertyWebkitMaskPosition = 1204, + CSSPropertyWebkitMaskPositionX = 1205, + CSSPropertyWebkitMaskPositionY = 1206, + CSSPropertyWebkitMaskRepeat = 1207, + CSSPropertyWebkitMaskRepeatX = 1208, + CSSPropertyWebkitMaskRepeatY = 1209, + CSSPropertyWebkitMaskSize = 1210, + CSSPropertyWebkitMatchNearestMailBlockquoteColor = 1211, + CSSPropertyWebkitNbspMode = 1212, + CSSPropertyWebkitPaddingStart = 1213, + CSSPropertyWebkitPerspective = 1214, + CSSPropertyWebkitPerspectiveOrigin = 1215, + CSSPropertyWebkitPerspectiveOriginX = 1216, + CSSPropertyWebkitPerspectiveOriginY = 1217, + CSSPropertyWebkitRtlOrdering = 1218, + CSSPropertyWebkitTextDecorationsInEffect = 1219, + CSSPropertyWebkitTextFillColor = 1220, + CSSPropertyWebkitTextSecurity = 1221, + CSSPropertyWebkitTextSizeAdjust = 1222, + CSSPropertyWebkitTextStroke = 1223, + CSSPropertyWebkitTextStrokeColor = 1224, + CSSPropertyWebkitTextStrokeWidth = 1225, + CSSPropertyWebkitTransform = 1226, + CSSPropertyWebkitTransformOrigin = 1227, + CSSPropertyWebkitTransformOriginX = 1228, + CSSPropertyWebkitTransformOriginY = 1229, + CSSPropertyWebkitTransformOriginZ = 1230, + CSSPropertyWebkitTransformStyle = 1231, + CSSPropertyWebkitTransition = 1232, + CSSPropertyWebkitTransitionDelay = 1233, + CSSPropertyWebkitTransitionDuration = 1234, + CSSPropertyWebkitTransitionProperty = 1235, + CSSPropertyWebkitTransitionTimingFunction = 1236, + CSSPropertyWebkitUserDrag = 1237, + CSSPropertyWebkitUserModify = 1238, + CSSPropertyWebkitUserSelect = 1239, + CSSPropertyWebkitVariableDeclarationBlock = 1240, + CSSPropertyClipPath = 1241, + CSSPropertyClipRule = 1242, + CSSPropertyMask = 1243, + CSSPropertyEnableBackground = 1244, + CSSPropertyFilter = 1245, + CSSPropertyFloodColor = 1246, + CSSPropertyFloodOpacity = 1247, + CSSPropertyLightingColor = 1248, + CSSPropertyStopColor = 1249, + CSSPropertyStopOpacity = 1250, + CSSPropertyColorInterpolation = 1251, + CSSPropertyColorInterpolationFilters = 1252, + CSSPropertyColorProfile = 1253, + CSSPropertyColorRendering = 1254, + CSSPropertyFill = 1255, + CSSPropertyFillOpacity = 1256, + CSSPropertyFillRule = 1257, + CSSPropertyImageRendering = 1258, + CSSPropertyMarker = 1259, + CSSPropertyMarkerEnd = 1260, + CSSPropertyMarkerMid = 1261, + CSSPropertyMarkerStart = 1262, + CSSPropertyShapeRendering = 1263, + CSSPropertyStroke = 1264, + CSSPropertyStrokeDasharray = 1265, + CSSPropertyStrokeDashoffset = 1266, + CSSPropertyStrokeLinecap = 1267, + CSSPropertyStrokeLinejoin = 1268, + CSSPropertyStrokeMiterlimit = 1269, + CSSPropertyStrokeOpacity = 1270, + CSSPropertyStrokeWidth = 1271, + CSSPropertyAlignmentBaseline = 1272, + CSSPropertyBaselineShift = 1273, + CSSPropertyDominantBaseline = 1274, + CSSPropertyGlyphOrientationHorizontal = 1275, + CSSPropertyGlyphOrientationVertical = 1276, + CSSPropertyKerning = 1277, + CSSPropertyTextAnchor = 1278, + CSSPropertyWritingMode = 1279, + CSSPropertyWebkitShadow = 1280, }; const int firstCSSProperty = 1001; -const int numCSSProperties = 278; +const int numCSSProperties = 280; const size_t maxCSSPropertyNameLength = 43; const char* getPropertyName(CSSPropertyID); diff --git a/src/3rdparty/webkit/WebCore/generated/JSAbstractWorker.cpp b/src/3rdparty/webkit/WebCore/generated/JSAbstractWorker.cpp index d472340..bee17ac 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSAbstractWorker.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSAbstractWorker.cpp @@ -149,7 +149,7 @@ JSAbstractWorker::JSAbstractWorker(NonNullPassRefPtr structure, JSDOM JSAbstractWorker::~JSAbstractWorker() { impl()->invalidateEventListeners(); - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } void JSAbstractWorker::markChildren(MarkStack& markStack) @@ -199,7 +199,7 @@ void setJSAbstractWorkerOnerror(ExecState* exec, JSObject* thisObject, JSValue v { UNUSED_PARAM(exec); AbstractWorker* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnerror(globalObject->createJSAttributeEventListener(value)); diff --git a/src/3rdparty/webkit/WebCore/generated/JSBarInfo.cpp b/src/3rdparty/webkit/WebCore/generated/JSBarInfo.cpp index 2f02580..348c086 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSBarInfo.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSBarInfo.cpp @@ -76,7 +76,7 @@ JSBarInfo::JSBarInfo(NonNullPassRefPtr structure, JSDOMGlobalObject* JSBarInfo::~JSBarInfo() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSBarInfo::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSCSSRule.cpp b/src/3rdparty/webkit/WebCore/generated/JSCSSRule.cpp index 307b17a..8d99056 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSCSSRule.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSCSSRule.cpp @@ -162,7 +162,7 @@ JSCSSRule::JSCSSRule(NonNullPassRefPtr structure, JSDOMGlobalObject* JSCSSRule::~JSCSSRule() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSCSSRule::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSCSSRuleList.cpp b/src/3rdparty/webkit/WebCore/generated/JSCSSRuleList.cpp index e02a6ce..0bb58c2 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSCSSRuleList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSCSSRuleList.cpp @@ -140,7 +140,7 @@ JSCSSRuleList::JSCSSRuleList(NonNullPassRefPtr structure, JSDOMGlobal JSCSSRuleList::~JSCSSRuleList() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSCSSRuleList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSCSSStyleDeclaration.cpp b/src/3rdparty/webkit/WebCore/generated/JSCSSStyleDeclaration.cpp index 6292b64..5fbf986 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSCSSStyleDeclaration.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSCSSStyleDeclaration.cpp @@ -154,7 +154,7 @@ JSCSSStyleDeclaration::JSCSSStyleDeclaration(NonNullPassRefPtr struct JSCSSStyleDeclaration::~JSCSSStyleDeclaration() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSCSSStyleDeclaration::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSCSSValue.cpp b/src/3rdparty/webkit/WebCore/generated/JSCSSValue.cpp index 22f6c30..1cb1b75 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSCSSValue.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSCSSValue.cpp @@ -145,7 +145,7 @@ JSCSSValue::JSCSSValue(NonNullPassRefPtr structure, JSDOMGlobalObject JSCSSValue::~JSCSSValue() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSCSSValue::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSCSSVariablesDeclaration.cpp b/src/3rdparty/webkit/WebCore/generated/JSCSSVariablesDeclaration.cpp index ef1d726..975d56d 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSCSSVariablesDeclaration.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSCSSVariablesDeclaration.cpp @@ -147,7 +147,7 @@ JSCSSVariablesDeclaration::JSCSSVariablesDeclaration(NonNullPassRefPtrglobalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSCSSVariablesDeclaration::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSCanvasArray.cpp b/src/3rdparty/webkit/WebCore/generated/JSCanvasArray.cpp index aeeeb4f..05be08c 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSCanvasArray.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSCanvasArray.cpp @@ -93,7 +93,7 @@ JSCanvasArray::JSCanvasArray(NonNullPassRefPtr structure, JSDOMGlobal JSCanvasArray::~JSCanvasArray() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSCanvasArray::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSCanvasArrayBuffer.cpp b/src/3rdparty/webkit/WebCore/generated/JSCanvasArrayBuffer.cpp index cf1c0fe..7099ce9 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSCanvasArrayBuffer.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSCanvasArrayBuffer.cpp @@ -80,7 +80,7 @@ JSCanvasArrayBuffer::JSCanvasArrayBuffer(NonNullPassRefPtr structure, JSCanvasArrayBuffer::~JSCanvasArrayBuffer() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSCanvasArrayBuffer::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSCanvasGradient.cpp b/src/3rdparty/webkit/WebCore/generated/JSCanvasGradient.cpp index 22de482..4d2bfa3 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSCanvasGradient.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSCanvasGradient.cpp @@ -74,7 +74,7 @@ JSCanvasGradient::JSCanvasGradient(NonNullPassRefPtr structure, JSDOM JSCanvasGradient::~JSCanvasGradient() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSCanvasGradient::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSCanvasPattern.cpp b/src/3rdparty/webkit/WebCore/generated/JSCanvasPattern.cpp index 7356770..cfb521b 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSCanvasPattern.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSCanvasPattern.cpp @@ -61,7 +61,7 @@ JSCanvasPattern::JSCanvasPattern(NonNullPassRefPtr structure, JSDOMGl JSCanvasPattern::~JSCanvasPattern() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSCanvasPattern::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSCanvasRenderingContext.cpp b/src/3rdparty/webkit/WebCore/generated/JSCanvasRenderingContext.cpp index 1d06dfe..07710a1 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSCanvasRenderingContext.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSCanvasRenderingContext.cpp @@ -126,7 +126,7 @@ JSCanvasRenderingContext::JSCanvasRenderingContext(NonNullPassRefPtr JSCanvasRenderingContext::~JSCanvasRenderingContext() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSCanvasRenderingContext::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSClientRect.cpp b/src/3rdparty/webkit/WebCore/generated/JSClientRect.cpp index 175d660..48dccd3 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSClientRect.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSClientRect.cpp @@ -130,7 +130,7 @@ JSClientRect::JSClientRect(NonNullPassRefPtr structure, JSDOMGlobalOb JSClientRect::~JSClientRect() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSClientRect::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSClientRectList.cpp b/src/3rdparty/webkit/WebCore/generated/JSClientRectList.cpp index 143ee8c..ff9d963 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSClientRectList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSClientRectList.cpp @@ -141,7 +141,7 @@ JSClientRectList::JSClientRectList(NonNullPassRefPtr structure, JSDOM JSClientRectList::~JSClientRectList() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSClientRectList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSClipboard.cpp b/src/3rdparty/webkit/WebCore/generated/JSClipboard.cpp index f72e341..8f4a7d4 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSClipboard.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSClipboard.cpp @@ -145,7 +145,7 @@ JSClipboard::JSClipboard(NonNullPassRefPtr structure, JSDOMGlobalObje JSClipboard::~JSClipboard() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSClipboard::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSConsole.cpp b/src/3rdparty/webkit/WebCore/generated/JSConsole.cpp index 4bb40c6..0657890 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSConsole.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSConsole.cpp @@ -104,7 +104,7 @@ JSConsole::JSConsole(NonNullPassRefPtr structure, JSDOMGlobalObject* JSConsole::~JSConsole() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSConsole::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSCoordinates.cpp b/src/3rdparty/webkit/WebCore/generated/JSCoordinates.cpp index 6919ad2..348bcc6 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSCoordinates.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSCoordinates.cpp @@ -83,7 +83,7 @@ JSCoordinates::JSCoordinates(NonNullPassRefPtr structure, JSDOMGlobal JSCoordinates::~JSCoordinates() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSCoordinates::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSCounter.cpp b/src/3rdparty/webkit/WebCore/generated/JSCounter.cpp index d17a368..7c22959 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSCounter.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSCounter.cpp @@ -128,7 +128,7 @@ JSCounter::JSCounter(NonNullPassRefPtr structure, JSDOMGlobalObject* JSCounter::~JSCounter() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSCounter::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSDOMApplicationCache.cpp b/src/3rdparty/webkit/WebCore/generated/JSDOMApplicationCache.cpp index 2b65699..17a527e 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSDOMApplicationCache.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSDOMApplicationCache.cpp @@ -118,7 +118,7 @@ JSDOMApplicationCache::JSDOMApplicationCache(NonNullPassRefPtr struct JSDOMApplicationCache::~JSDOMApplicationCache() { impl()->invalidateEventListeners(); - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } void JSDOMApplicationCache::markChildren(MarkStack& markStack) @@ -255,7 +255,7 @@ void setJSDOMApplicationCacheOnchecking(ExecState* exec, JSObject* thisObject, J { UNUSED_PARAM(exec); DOMApplicationCache* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnchecking(globalObject->createJSAttributeEventListener(value)); @@ -265,7 +265,7 @@ void setJSDOMApplicationCacheOnerror(ExecState* exec, JSObject* thisObject, JSVa { UNUSED_PARAM(exec); DOMApplicationCache* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnerror(globalObject->createJSAttributeEventListener(value)); @@ -275,7 +275,7 @@ void setJSDOMApplicationCacheOnnoupdate(ExecState* exec, JSObject* thisObject, J { UNUSED_PARAM(exec); DOMApplicationCache* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnnoupdate(globalObject->createJSAttributeEventListener(value)); @@ -285,7 +285,7 @@ void setJSDOMApplicationCacheOndownloading(ExecState* exec, JSObject* thisObject { UNUSED_PARAM(exec); DOMApplicationCache* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndownloading(globalObject->createJSAttributeEventListener(value)); @@ -295,7 +295,7 @@ void setJSDOMApplicationCacheOnprogress(ExecState* exec, JSObject* thisObject, J { UNUSED_PARAM(exec); DOMApplicationCache* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnprogress(globalObject->createJSAttributeEventListener(value)); @@ -305,7 +305,7 @@ void setJSDOMApplicationCacheOnupdateready(ExecState* exec, JSObject* thisObject { UNUSED_PARAM(exec); DOMApplicationCache* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnupdateready(globalObject->createJSAttributeEventListener(value)); @@ -315,7 +315,7 @@ void setJSDOMApplicationCacheOncached(ExecState* exec, JSObject* thisObject, JSV { UNUSED_PARAM(exec); DOMApplicationCache* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOncached(globalObject->createJSAttributeEventListener(value)); @@ -325,7 +325,7 @@ void setJSDOMApplicationCacheOnobsolete(ExecState* exec, JSObject* thisObject, J { UNUSED_PARAM(exec); DOMApplicationCache* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnobsolete(globalObject->createJSAttributeEventListener(value)); diff --git a/src/3rdparty/webkit/WebCore/generated/JSDOMCoreException.cpp b/src/3rdparty/webkit/WebCore/generated/JSDOMCoreException.cpp index d625e2b..ff88905 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSDOMCoreException.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSDOMCoreException.cpp @@ -185,7 +185,7 @@ JSDOMCoreException::JSDOMCoreException(NonNullPassRefPtr structure, J JSDOMCoreException::~JSDOMCoreException() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSDOMCoreException::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSDOMImplementation.cpp b/src/3rdparty/webkit/WebCore/generated/JSDOMImplementation.cpp index 62eef6c..268647b 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSDOMImplementation.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSDOMImplementation.cpp @@ -148,7 +148,7 @@ JSDOMImplementation::JSDOMImplementation(NonNullPassRefPtr structure, JSDOMImplementation::~JSDOMImplementation() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSDOMImplementation::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSDOMParser.cpp b/src/3rdparty/webkit/WebCore/generated/JSDOMParser.cpp index 4af88cb..ecd336a 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSDOMParser.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSDOMParser.cpp @@ -147,7 +147,7 @@ JSDOMParser::JSDOMParser(NonNullPassRefPtr structure, JSDOMGlobalObje JSDOMParser::~JSDOMParser() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSDOMParser::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSDOMSelection.cpp b/src/3rdparty/webkit/WebCore/generated/JSDOMSelection.cpp index 45ec248..e3a69b0 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSDOMSelection.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSDOMSelection.cpp @@ -119,7 +119,7 @@ JSDOMSelection::JSDOMSelection(NonNullPassRefPtr structure, JSDOMGlob JSDOMSelection::~JSDOMSelection() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSDOMSelection::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.cpp b/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.cpp index dc53217..12edc42 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.cpp @@ -92,6 +92,7 @@ #include "JSEventSource.h" #include "JSFile.h" #include "JSFileList.h" +#include "JSHTMLAllCollection.h" #include "JSHTMLAnchorElement.h" #include "JSHTMLAppletElement.h" #include "JSHTMLAreaElement.h" @@ -246,7 +247,7 @@ ASSERT_CLASS_FITS_IN_CELL(JSDOMWindow); /* Hash table */ -static const HashTableValue JSDOMWindowTableValues[296] = +static const HashTableValue JSDOMWindowTableValues[297] = { { "screen", DontDelete|ReadOnly, (intptr_t)jsDOMWindowScreen, (intptr_t)0 }, { "history", DontDelete|ReadOnly, (intptr_t)jsDOMWindowHistory, (intptr_t)0 }, @@ -468,6 +469,7 @@ static const HashTableValue JSDOMWindowTableValues[296] = { "HTMLTitleElement", DontDelete, (intptr_t)jsDOMWindowHTMLTitleElementConstructor, (intptr_t)setJSDOMWindowHTMLTitleElementConstructor }, { "HTMLUListElement", DontDelete, (intptr_t)jsDOMWindowHTMLUListElementConstructor, (intptr_t)setJSDOMWindowHTMLUListElementConstructor }, { "HTMLCollection", DontDelete, (intptr_t)jsDOMWindowHTMLCollectionConstructor, (intptr_t)setJSDOMWindowHTMLCollectionConstructor }, + { "HTMLAllCollection", DontDelete, (intptr_t)jsDOMWindowHTMLAllCollectionConstructor, (intptr_t)setJSDOMWindowHTMLAllCollectionConstructor }, { "Image", DontDelete, (intptr_t)jsDOMWindowImageConstructor, (intptr_t)setJSDOMWindowImageConstructor }, { "Option", DontDelete, (intptr_t)jsDOMWindowOptionConstructor, (intptr_t)setJSDOMWindowOptionConstructor }, { "CanvasRenderingContext2D", DontDelete, (intptr_t)jsDOMWindowCanvasRenderingContext2DConstructor, (intptr_t)setJSDOMWindowCanvasRenderingContext2DConstructor }, @@ -666,7 +668,6 @@ JSDOMWindow::JSDOMWindow(NonNullPassRefPtr structure, PassRefPtrinvalidateEventListeners(); - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); } JSValue jsDOMWindowScreen(ExecState* exec, const Identifier&, const PropertySlot& slot) @@ -2846,6 +2847,14 @@ JSValue jsDOMWindowHTMLCollectionConstructor(ExecState* exec, const Identifier&, return JSHTMLCollection::getConstructor(exec, castedThis); } +JSValue jsDOMWindowHTMLAllCollectionConstructor(ExecState* exec, const Identifier&, const PropertySlot& slot) +{ + JSDOMWindow* castedThis = static_cast(asObject(slot.slotBase())); + if (!castedThis->allowsAccessFrom(exec)) + return jsUndefined(); + return JSHTMLAllCollection::getConstructor(exec, castedThis); +} + JSValue jsDOMWindowImageConstructor(ExecState* exec, const Identifier&, const PropertySlot& slot) { JSDOMWindow* castedThis = static_cast(asObject(slot.slotBase())); @@ -5261,6 +5270,14 @@ void setJSDOMWindowHTMLCollectionConstructor(ExecState* exec, JSObject* thisObje static_cast(thisObject)->putDirect(Identifier(exec, "HTMLCollection"), value); } +void setJSDOMWindowHTMLAllCollectionConstructor(ExecState* exec, JSObject* thisObject, JSValue value) +{ + if (!static_cast(thisObject)->allowsAccessFrom(exec)) + return; + // Shadowing a built-in constructor + static_cast(thisObject)->putDirect(Identifier(exec, "HTMLAllCollection"), value); +} + void setJSDOMWindowImageConstructor(ExecState* exec, JSObject* thisObject, JSValue value) { if (!static_cast(thisObject)->allowsAccessFrom(exec)) diff --git a/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.h b/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.h index 232c8eb..afc8106 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.h +++ b/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.h @@ -577,6 +577,8 @@ JSC::JSValue jsDOMWindowHTMLUListElementConstructor(JSC::ExecState*, const JSC:: void setJSDOMWindowHTMLUListElementConstructor(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsDOMWindowHTMLCollectionConstructor(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); void setJSDOMWindowHTMLCollectionConstructor(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsDOMWindowHTMLAllCollectionConstructor(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); +void setJSDOMWindowHTMLAllCollectionConstructor(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsDOMWindowImageConstructor(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); void setJSDOMWindowImageConstructor(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsDOMWindowOptionConstructor(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); diff --git a/src/3rdparty/webkit/WebCore/generated/JSDataGridColumn.cpp b/src/3rdparty/webkit/WebCore/generated/JSDataGridColumn.cpp index 586edd1..42b91d1 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSDataGridColumn.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSDataGridColumn.cpp @@ -157,7 +157,7 @@ JSDataGridColumn::JSDataGridColumn(NonNullPassRefPtr structure, JSDOM JSDataGridColumn::~JSDataGridColumn() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSDataGridColumn::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSDataGridColumnList.cpp b/src/3rdparty/webkit/WebCore/generated/JSDataGridColumnList.cpp index 08585fe..945c257 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSDataGridColumnList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSDataGridColumnList.cpp @@ -151,7 +151,7 @@ JSDataGridColumnList::JSDataGridColumnList(NonNullPassRefPtr structur JSDataGridColumnList::~JSDataGridColumnList() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSDataGridColumnList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSDatabase.cpp b/src/3rdparty/webkit/WebCore/generated/JSDatabase.cpp index 5acd5b1..c5ac44d 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSDatabase.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSDatabase.cpp @@ -95,7 +95,7 @@ JSDatabase::JSDatabase(NonNullPassRefPtr structure, JSDOMGlobalObject JSDatabase::~JSDatabase() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSDatabase::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSDocument.cpp b/src/3rdparty/webkit/WebCore/generated/JSDocument.cpp index 47a2936..1fb3b46 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSDocument.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSDocument.cpp @@ -304,7 +304,7 @@ JSDocument::JSDocument(NonNullPassRefPtr structure, JSDOMGlobalObject JSDocument::~JSDocument() { - forgetDOMObject(*Heap::heap(this)->globalData(), static_cast(impl())); + forgetDOMObject(this, static_cast(impl())); } JSObject* JSDocument::createPrototype(ExecState* exec, JSGlobalObject* globalObject) @@ -1099,7 +1099,7 @@ void setJSDocumentOnabort(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnabort(globalObject->createJSAttributeEventListener(value)); @@ -1109,7 +1109,7 @@ void setJSDocumentOnblur(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnblur(globalObject->createJSAttributeEventListener(value)); @@ -1119,7 +1119,7 @@ void setJSDocumentOnchange(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnchange(globalObject->createJSAttributeEventListener(value)); @@ -1129,7 +1129,7 @@ void setJSDocumentOnclick(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnclick(globalObject->createJSAttributeEventListener(value)); @@ -1139,7 +1139,7 @@ void setJSDocumentOncontextmenu(ExecState* exec, JSObject* thisObject, JSValue v { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOncontextmenu(globalObject->createJSAttributeEventListener(value)); @@ -1149,7 +1149,7 @@ void setJSDocumentOndblclick(ExecState* exec, JSObject* thisObject, JSValue valu { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndblclick(globalObject->createJSAttributeEventListener(value)); @@ -1159,7 +1159,7 @@ void setJSDocumentOndrag(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndrag(globalObject->createJSAttributeEventListener(value)); @@ -1169,7 +1169,7 @@ void setJSDocumentOndragend(ExecState* exec, JSObject* thisObject, JSValue value { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndragend(globalObject->createJSAttributeEventListener(value)); @@ -1179,7 +1179,7 @@ void setJSDocumentOndragenter(ExecState* exec, JSObject* thisObject, JSValue val { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndragenter(globalObject->createJSAttributeEventListener(value)); @@ -1189,7 +1189,7 @@ void setJSDocumentOndragleave(ExecState* exec, JSObject* thisObject, JSValue val { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndragleave(globalObject->createJSAttributeEventListener(value)); @@ -1199,7 +1199,7 @@ void setJSDocumentOndragover(ExecState* exec, JSObject* thisObject, JSValue valu { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndragover(globalObject->createJSAttributeEventListener(value)); @@ -1209,7 +1209,7 @@ void setJSDocumentOndragstart(ExecState* exec, JSObject* thisObject, JSValue val { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndragstart(globalObject->createJSAttributeEventListener(value)); @@ -1219,7 +1219,7 @@ void setJSDocumentOndrop(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndrop(globalObject->createJSAttributeEventListener(value)); @@ -1229,7 +1229,7 @@ void setJSDocumentOnerror(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnerror(globalObject->createJSAttributeEventListener(value)); @@ -1239,7 +1239,7 @@ void setJSDocumentOnfocus(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnfocus(globalObject->createJSAttributeEventListener(value)); @@ -1249,7 +1249,7 @@ void setJSDocumentOninput(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOninput(globalObject->createJSAttributeEventListener(value)); @@ -1259,7 +1259,7 @@ void setJSDocumentOninvalid(ExecState* exec, JSObject* thisObject, JSValue value { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOninvalid(globalObject->createJSAttributeEventListener(value)); @@ -1269,7 +1269,7 @@ void setJSDocumentOnkeydown(ExecState* exec, JSObject* thisObject, JSValue value { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnkeydown(globalObject->createJSAttributeEventListener(value)); @@ -1279,7 +1279,7 @@ void setJSDocumentOnkeypress(ExecState* exec, JSObject* thisObject, JSValue valu { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnkeypress(globalObject->createJSAttributeEventListener(value)); @@ -1289,7 +1289,7 @@ void setJSDocumentOnkeyup(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnkeyup(globalObject->createJSAttributeEventListener(value)); @@ -1299,7 +1299,7 @@ void setJSDocumentOnload(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnload(globalObject->createJSAttributeEventListener(value)); @@ -1309,7 +1309,7 @@ void setJSDocumentOnmousedown(ExecState* exec, JSObject* thisObject, JSValue val { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmousedown(globalObject->createJSAttributeEventListener(value)); @@ -1319,7 +1319,7 @@ void setJSDocumentOnmousemove(ExecState* exec, JSObject* thisObject, JSValue val { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmousemove(globalObject->createJSAttributeEventListener(value)); @@ -1329,7 +1329,7 @@ void setJSDocumentOnmouseout(ExecState* exec, JSObject* thisObject, JSValue valu { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmouseout(globalObject->createJSAttributeEventListener(value)); @@ -1339,7 +1339,7 @@ void setJSDocumentOnmouseover(ExecState* exec, JSObject* thisObject, JSValue val { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmouseover(globalObject->createJSAttributeEventListener(value)); @@ -1349,7 +1349,7 @@ void setJSDocumentOnmouseup(ExecState* exec, JSObject* thisObject, JSValue value { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmouseup(globalObject->createJSAttributeEventListener(value)); @@ -1359,7 +1359,7 @@ void setJSDocumentOnmousewheel(ExecState* exec, JSObject* thisObject, JSValue va { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmousewheel(globalObject->createJSAttributeEventListener(value)); @@ -1369,7 +1369,7 @@ void setJSDocumentOnscroll(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnscroll(globalObject->createJSAttributeEventListener(value)); @@ -1379,7 +1379,7 @@ void setJSDocumentOnselect(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnselect(globalObject->createJSAttributeEventListener(value)); @@ -1389,7 +1389,7 @@ void setJSDocumentOnsubmit(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnsubmit(globalObject->createJSAttributeEventListener(value)); @@ -1399,7 +1399,7 @@ void setJSDocumentOnbeforecut(ExecState* exec, JSObject* thisObject, JSValue val { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnbeforecut(globalObject->createJSAttributeEventListener(value)); @@ -1409,7 +1409,7 @@ void setJSDocumentOncut(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOncut(globalObject->createJSAttributeEventListener(value)); @@ -1419,7 +1419,7 @@ void setJSDocumentOnbeforecopy(ExecState* exec, JSObject* thisObject, JSValue va { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnbeforecopy(globalObject->createJSAttributeEventListener(value)); @@ -1429,7 +1429,7 @@ void setJSDocumentOncopy(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOncopy(globalObject->createJSAttributeEventListener(value)); @@ -1439,7 +1439,7 @@ void setJSDocumentOnbeforepaste(ExecState* exec, JSObject* thisObject, JSValue v { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnbeforepaste(globalObject->createJSAttributeEventListener(value)); @@ -1449,7 +1449,7 @@ void setJSDocumentOnpaste(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnpaste(globalObject->createJSAttributeEventListener(value)); @@ -1459,7 +1459,7 @@ void setJSDocumentOnreset(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnreset(globalObject->createJSAttributeEventListener(value)); @@ -1469,7 +1469,7 @@ void setJSDocumentOnsearch(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnsearch(globalObject->createJSAttributeEventListener(value)); @@ -1479,7 +1479,7 @@ void setJSDocumentOnselectstart(ExecState* exec, JSObject* thisObject, JSValue v { UNUSED_PARAM(exec); Document* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnselectstart(globalObject->createJSAttributeEventListener(value)); diff --git a/src/3rdparty/webkit/WebCore/generated/JSElement.cpp b/src/3rdparty/webkit/WebCore/generated/JSElement.cpp index 869c23f..3d3187f 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSElement.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSElement.cpp @@ -897,7 +897,7 @@ void setJSElementOnabort(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnabort(globalObject->createJSAttributeEventListener(value)); @@ -907,7 +907,7 @@ void setJSElementOnblur(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnblur(globalObject->createJSAttributeEventListener(value)); @@ -917,7 +917,7 @@ void setJSElementOnchange(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnchange(globalObject->createJSAttributeEventListener(value)); @@ -927,7 +927,7 @@ void setJSElementOnclick(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnclick(globalObject->createJSAttributeEventListener(value)); @@ -937,7 +937,7 @@ void setJSElementOncontextmenu(ExecState* exec, JSObject* thisObject, JSValue va { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOncontextmenu(globalObject->createJSAttributeEventListener(value)); @@ -947,7 +947,7 @@ void setJSElementOndblclick(ExecState* exec, JSObject* thisObject, JSValue value { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndblclick(globalObject->createJSAttributeEventListener(value)); @@ -957,7 +957,7 @@ void setJSElementOndrag(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndrag(globalObject->createJSAttributeEventListener(value)); @@ -967,7 +967,7 @@ void setJSElementOndragend(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndragend(globalObject->createJSAttributeEventListener(value)); @@ -977,7 +977,7 @@ void setJSElementOndragenter(ExecState* exec, JSObject* thisObject, JSValue valu { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndragenter(globalObject->createJSAttributeEventListener(value)); @@ -987,7 +987,7 @@ void setJSElementOndragleave(ExecState* exec, JSObject* thisObject, JSValue valu { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndragleave(globalObject->createJSAttributeEventListener(value)); @@ -997,7 +997,7 @@ void setJSElementOndragover(ExecState* exec, JSObject* thisObject, JSValue value { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndragover(globalObject->createJSAttributeEventListener(value)); @@ -1007,7 +1007,7 @@ void setJSElementOndragstart(ExecState* exec, JSObject* thisObject, JSValue valu { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndragstart(globalObject->createJSAttributeEventListener(value)); @@ -1017,7 +1017,7 @@ void setJSElementOndrop(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndrop(globalObject->createJSAttributeEventListener(value)); @@ -1027,7 +1027,7 @@ void setJSElementOnerror(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnerror(globalObject->createJSAttributeEventListener(value)); @@ -1037,7 +1037,7 @@ void setJSElementOnfocus(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnfocus(globalObject->createJSAttributeEventListener(value)); @@ -1047,7 +1047,7 @@ void setJSElementOninput(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOninput(globalObject->createJSAttributeEventListener(value)); @@ -1057,7 +1057,7 @@ void setJSElementOninvalid(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOninvalid(globalObject->createJSAttributeEventListener(value)); @@ -1067,7 +1067,7 @@ void setJSElementOnkeydown(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnkeydown(globalObject->createJSAttributeEventListener(value)); @@ -1077,7 +1077,7 @@ void setJSElementOnkeypress(ExecState* exec, JSObject* thisObject, JSValue value { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnkeypress(globalObject->createJSAttributeEventListener(value)); @@ -1087,7 +1087,7 @@ void setJSElementOnkeyup(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnkeyup(globalObject->createJSAttributeEventListener(value)); @@ -1097,7 +1097,7 @@ void setJSElementOnload(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnload(globalObject->createJSAttributeEventListener(value)); @@ -1107,7 +1107,7 @@ void setJSElementOnmousedown(ExecState* exec, JSObject* thisObject, JSValue valu { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmousedown(globalObject->createJSAttributeEventListener(value)); @@ -1117,7 +1117,7 @@ void setJSElementOnmousemove(ExecState* exec, JSObject* thisObject, JSValue valu { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmousemove(globalObject->createJSAttributeEventListener(value)); @@ -1127,7 +1127,7 @@ void setJSElementOnmouseout(ExecState* exec, JSObject* thisObject, JSValue value { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmouseout(globalObject->createJSAttributeEventListener(value)); @@ -1137,7 +1137,7 @@ void setJSElementOnmouseover(ExecState* exec, JSObject* thisObject, JSValue valu { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmouseover(globalObject->createJSAttributeEventListener(value)); @@ -1147,7 +1147,7 @@ void setJSElementOnmouseup(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmouseup(globalObject->createJSAttributeEventListener(value)); @@ -1157,7 +1157,7 @@ void setJSElementOnmousewheel(ExecState* exec, JSObject* thisObject, JSValue val { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmousewheel(globalObject->createJSAttributeEventListener(value)); @@ -1167,7 +1167,7 @@ void setJSElementOnscroll(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnscroll(globalObject->createJSAttributeEventListener(value)); @@ -1177,7 +1177,7 @@ void setJSElementOnselect(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnselect(globalObject->createJSAttributeEventListener(value)); @@ -1187,7 +1187,7 @@ void setJSElementOnsubmit(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnsubmit(globalObject->createJSAttributeEventListener(value)); @@ -1197,7 +1197,7 @@ void setJSElementOnbeforecut(ExecState* exec, JSObject* thisObject, JSValue valu { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnbeforecut(globalObject->createJSAttributeEventListener(value)); @@ -1207,7 +1207,7 @@ void setJSElementOncut(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOncut(globalObject->createJSAttributeEventListener(value)); @@ -1217,7 +1217,7 @@ void setJSElementOnbeforecopy(ExecState* exec, JSObject* thisObject, JSValue val { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnbeforecopy(globalObject->createJSAttributeEventListener(value)); @@ -1227,7 +1227,7 @@ void setJSElementOncopy(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOncopy(globalObject->createJSAttributeEventListener(value)); @@ -1237,7 +1237,7 @@ void setJSElementOnbeforepaste(ExecState* exec, JSObject* thisObject, JSValue va { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnbeforepaste(globalObject->createJSAttributeEventListener(value)); @@ -1247,7 +1247,7 @@ void setJSElementOnpaste(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnpaste(globalObject->createJSAttributeEventListener(value)); @@ -1257,7 +1257,7 @@ void setJSElementOnreset(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnreset(globalObject->createJSAttributeEventListener(value)); @@ -1267,7 +1267,7 @@ void setJSElementOnsearch(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnsearch(globalObject->createJSAttributeEventListener(value)); @@ -1277,7 +1277,7 @@ void setJSElementOnselectstart(ExecState* exec, JSObject* thisObject, JSValue va { UNUSED_PARAM(exec); Element* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnselectstart(globalObject->createJSAttributeEventListener(value)); diff --git a/src/3rdparty/webkit/WebCore/generated/JSEvent.cpp b/src/3rdparty/webkit/WebCore/generated/JSEvent.cpp index acd952f..67eefd0 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSEvent.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSEvent.cpp @@ -199,7 +199,7 @@ JSEvent::JSEvent(NonNullPassRefPtr structure, JSDOMGlobalObject* glob JSEvent::~JSEvent() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSEvent::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSEventException.cpp b/src/3rdparty/webkit/WebCore/generated/JSEventException.cpp index 2246c8f..bd25734 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSEventException.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSEventException.cpp @@ -151,7 +151,7 @@ JSEventException::JSEventException(NonNullPassRefPtr structure, JSDOM JSEventException::~JSEventException() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSEventException::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSEventSource.cpp b/src/3rdparty/webkit/WebCore/generated/JSEventSource.cpp index dcec14e..526d8af 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSEventSource.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSEventSource.cpp @@ -120,7 +120,7 @@ JSEventSource::JSEventSource(NonNullPassRefPtr structure, JSDOMGlobal JSEventSource::~JSEventSource() { impl()->invalidateEventListeners(); - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } void JSEventSource::markChildren(MarkStack& markStack) @@ -205,7 +205,7 @@ void setJSEventSourceOnopen(ExecState* exec, JSObject* thisObject, JSValue value { UNUSED_PARAM(exec); EventSource* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnopen(globalObject->createJSAttributeEventListener(value)); @@ -215,7 +215,7 @@ void setJSEventSourceOnmessage(ExecState* exec, JSObject* thisObject, JSValue va { UNUSED_PARAM(exec); EventSource* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmessage(globalObject->createJSAttributeEventListener(value)); @@ -225,7 +225,7 @@ void setJSEventSourceOnerror(ExecState* exec, JSObject* thisObject, JSValue valu { UNUSED_PARAM(exec); EventSource* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnerror(globalObject->createJSAttributeEventListener(value)); diff --git a/src/3rdparty/webkit/WebCore/generated/JSFile.cpp b/src/3rdparty/webkit/WebCore/generated/JSFile.cpp index 2ee62ae..59192af 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSFile.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSFile.cpp @@ -128,7 +128,7 @@ JSFile::JSFile(NonNullPassRefPtr structure, JSDOMGlobalObject* global JSFile::~JSFile() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSFile::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSFileList.cpp b/src/3rdparty/webkit/WebCore/generated/JSFileList.cpp index 931aae4..50e1f0a 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSFileList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSFileList.cpp @@ -141,7 +141,7 @@ JSFileList::JSFileList(NonNullPassRefPtr structure, JSDOMGlobalObject JSFileList::~JSFileList() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSFileList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSGeolocation.cpp b/src/3rdparty/webkit/WebCore/generated/JSGeolocation.cpp index 17a0509..be50fac 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSGeolocation.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSGeolocation.cpp @@ -92,7 +92,7 @@ JSGeolocation::JSGeolocation(NonNullPassRefPtr structure, JSDOMGlobal JSGeolocation::~JSGeolocation() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSGeolocation::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSGeoposition.cpp b/src/3rdparty/webkit/WebCore/generated/JSGeoposition.cpp index a77413b..ab42d2b 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSGeoposition.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSGeoposition.cpp @@ -80,7 +80,7 @@ JSGeoposition::JSGeoposition(NonNullPassRefPtr structure, JSDOMGlobal JSGeoposition::~JSGeoposition() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSGeoposition::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSHTMLAllCollection.cpp b/src/3rdparty/webkit/WebCore/generated/JSHTMLAllCollection.cpp new file mode 100644 index 0000000..4a8fc83 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/generated/JSHTMLAllCollection.cpp @@ -0,0 +1,292 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" +#include "JSHTMLAllCollection.h" + +#include "AtomicString.h" +#include "HTMLAllCollection.h" +#include "JSNode.h" +#include "JSNodeList.h" +#include "NameNodeList.h" +#include "Node.h" +#include "NodeList.h" +#include +#include +#include +#include + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSHTMLAllCollection); + +/* Hash table */ + +static const HashTableValue JSHTMLAllCollectionTableValues[3] = +{ + { "length", DontDelete|ReadOnly, (intptr_t)jsHTMLAllCollectionLength, (intptr_t)0 }, + { "constructor", DontEnum|ReadOnly, (intptr_t)jsHTMLAllCollectionConstructor, (intptr_t)0 }, + { 0, 0, 0, 0 } +}; + +static JSC_CONST_HASHTABLE HashTable JSHTMLAllCollectionTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 15, JSHTMLAllCollectionTableValues, 0 }; +#else + { 5, 3, JSHTMLAllCollectionTableValues, 0 }; +#endif + +/* Hash table for constructor */ + +static const HashTableValue JSHTMLAllCollectionConstructorTableValues[1] = +{ + { 0, 0, 0, 0 } +}; + +static JSC_CONST_HASHTABLE HashTable JSHTMLAllCollectionConstructorTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 0, JSHTMLAllCollectionConstructorTableValues, 0 }; +#else + { 1, 0, JSHTMLAllCollectionConstructorTableValues, 0 }; +#endif + +class JSHTMLAllCollectionConstructor : public DOMConstructorObject { +public: + JSHTMLAllCollectionConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSHTMLAllCollectionConstructor::createStructure(globalObject->objectPrototype()), globalObject) + { + putDirect(exec->propertyNames().prototype, JSHTMLAllCollectionPrototype::self(exec, globalObject), None); + } + virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&); + virtual const ClassInfo* classInfo() const { return &s_info; } + static const ClassInfo s_info; + + static PassRefPtr createStructure(JSValue proto) + { + return Structure::create(proto, TypeInfo(ObjectType, StructureFlags)); + } + +protected: + static const unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | DOMConstructorObject::StructureFlags; +}; + +const ClassInfo JSHTMLAllCollectionConstructor::s_info = { "HTMLAllCollectionConstructor", 0, &JSHTMLAllCollectionConstructorTable, 0 }; + +bool JSHTMLAllCollectionConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, &JSHTMLAllCollectionConstructorTable, this, propertyName, slot); +} + +bool JSHTMLAllCollectionConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor(exec, &JSHTMLAllCollectionConstructorTable, this, propertyName, descriptor); +} + +/* Hash table for prototype */ + +static const HashTableValue JSHTMLAllCollectionPrototypeTableValues[4] = +{ + { "item", DontDelete|Function, (intptr_t)jsHTMLAllCollectionPrototypeFunctionItem, (intptr_t)1 }, + { "namedItem", DontDelete|Function, (intptr_t)jsHTMLAllCollectionPrototypeFunctionNamedItem, (intptr_t)1 }, + { "tags", DontDelete|Function, (intptr_t)jsHTMLAllCollectionPrototypeFunctionTags, (intptr_t)1 }, + { 0, 0, 0, 0 } +}; + +static JSC_CONST_HASHTABLE HashTable JSHTMLAllCollectionPrototypeTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 7, JSHTMLAllCollectionPrototypeTableValues, 0 }; +#else + { 8, 7, JSHTMLAllCollectionPrototypeTableValues, 0 }; +#endif + +const ClassInfo JSHTMLAllCollectionPrototype::s_info = { "HTMLAllCollectionPrototype", 0, &JSHTMLAllCollectionPrototypeTable, 0 }; + +JSObject* JSHTMLAllCollectionPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype(exec, globalObject); +} + +bool JSHTMLAllCollectionPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticFunctionSlot(exec, &JSHTMLAllCollectionPrototypeTable, this, propertyName, slot); +} + +bool JSHTMLAllCollectionPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticFunctionDescriptor(exec, &JSHTMLAllCollectionPrototypeTable, this, propertyName, descriptor); +} + +const ClassInfo JSHTMLAllCollection::s_info = { "HTMLAllCollection", 0, &JSHTMLAllCollectionTable, 0 }; + +JSHTMLAllCollection::JSHTMLAllCollection(NonNullPassRefPtr structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + : DOMObjectWithGlobalPointer(structure, globalObject) + , m_impl(impl) +{ +} + +JSHTMLAllCollection::~JSHTMLAllCollection() +{ + forgetDOMObject(this, impl()); +} + +JSObject* JSHTMLAllCollection::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return new (exec) JSHTMLAllCollectionPrototype(JSHTMLAllCollectionPrototype::createStructure(globalObject->objectPrototype())); +} + +bool JSHTMLAllCollection::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSValue proto = prototype(); + if (proto.isObject() && static_cast(asObject(proto))->hasProperty(exec, propertyName)) + return false; + + const HashEntry* entry = JSHTMLAllCollectionTable.entry(exec, propertyName); + if (entry) { + slot.setCustom(this, entry->propertyGetter()); + return true; + } + bool ok; + unsigned index = propertyName.toUInt32(&ok, false); + if (ok && index < static_cast(impl())->length()) { + slot.setCustomIndex(this, index, indexGetter); + return true; + } + if (canGetItemsForName(exec, static_cast(impl()), propertyName)) { + slot.setCustom(this, nameGetter); + return true; + } + return getStaticValueSlot(exec, &JSHTMLAllCollectionTable, this, propertyName, slot); +} + +bool JSHTMLAllCollection::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSValue proto = prototype(); + if (proto.isObject() && static_cast(asObject(proto))->hasProperty(exec, propertyName)) + return false; + + const HashEntry* entry = JSHTMLAllCollectionTable.entry(exec, propertyName); + if (entry) { + PropertySlot slot; + slot.setCustom(this, entry->propertyGetter()); + descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes()); + return true; + } + bool ok; + unsigned index = propertyName.toUInt32(&ok, false); + if (ok && index < static_cast(impl())->length()) { + PropertySlot slot; + slot.setCustomIndex(this, index, indexGetter); + descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly); + return true; + } + if (canGetItemsForName(exec, static_cast(impl()), propertyName)) { + PropertySlot slot; + slot.setCustom(this, nameGetter); + descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum); + return true; + } + return getStaticValueDescriptor(exec, &JSHTMLAllCollectionTable, this, propertyName, descriptor); +} + +bool JSHTMLAllCollection::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) +{ + if (propertyName < static_cast(impl())->length()) { + slot.setCustomIndex(this, propertyName, indexGetter); + return true; + } + return getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot); +} + +JSValue jsHTMLAllCollectionLength(ExecState* exec, const Identifier&, const PropertySlot& slot) +{ + JSHTMLAllCollection* castedThis = static_cast(asObject(slot.slotBase())); + UNUSED_PARAM(exec); + HTMLAllCollection* imp = static_cast(castedThis->impl()); + return jsNumber(exec, imp->length()); +} + +JSValue jsHTMLAllCollectionConstructor(ExecState* exec, const Identifier&, const PropertySlot& slot) +{ + JSHTMLAllCollection* domObject = static_cast(asObject(slot.slotBase())); + return JSHTMLAllCollection::getConstructor(exec, domObject->globalObject()); +} +void JSHTMLAllCollection::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) +{ + for (unsigned i = 0; i < static_cast(impl())->length(); ++i) + propertyNames.add(Identifier::from(exec, i)); + Base::getOwnPropertyNames(exec, propertyNames); +} + +JSValue JSHTMLAllCollection::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor(exec, static_cast(globalObject)); +} + +JSValue JSC_HOST_CALL jsHTMLAllCollectionPrototypeFunctionItem(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSHTMLAllCollection::s_info)) + return throwError(exec, TypeError); + JSHTMLAllCollection* castedThisObj = static_cast(asObject(thisValue)); + return castedThisObj->item(exec, args); +} + +JSValue JSC_HOST_CALL jsHTMLAllCollectionPrototypeFunctionNamedItem(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSHTMLAllCollection::s_info)) + return throwError(exec, TypeError); + JSHTMLAllCollection* castedThisObj = static_cast(asObject(thisValue)); + return castedThisObj->namedItem(exec, args); +} + +JSValue JSC_HOST_CALL jsHTMLAllCollectionPrototypeFunctionTags(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSHTMLAllCollection::s_info)) + return throwError(exec, TypeError); + JSHTMLAllCollection* castedThisObj = static_cast(asObject(thisValue)); + HTMLAllCollection* imp = static_cast(castedThisObj->impl()); + const UString& name = args.at(0).toString(exec); + + + JSC::JSValue result = toJS(exec, castedThisObj->globalObject(), WTF::getPtr(imp->tags(name))); + return result; +} + + +JSValue JSHTMLAllCollection::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot) +{ + JSHTMLAllCollection* thisObj = static_cast(asObject(slot.slotBase())); + return toJS(exec, thisObj->globalObject(), static_cast(thisObj->impl())->item(slot.index())); +} +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, HTMLAllCollection* object) +{ + return getDOMObjectWrapper(exec, globalObject, object); +} +HTMLAllCollection* toHTMLAllCollection(JSC::JSValue value) +{ + return value.inherits(&JSHTMLAllCollection::s_info) ? static_cast(asObject(value))->impl() : 0; +} + +} diff --git a/src/3rdparty/webkit/WebCore/generated/JSHTMLAllCollection.h b/src/3rdparty/webkit/WebCore/generated/JSHTMLAllCollection.h new file mode 100644 index 0000000..000986e --- /dev/null +++ b/src/3rdparty/webkit/WebCore/generated/JSHTMLAllCollection.h @@ -0,0 +1,104 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef JSHTMLAllCollection_h +#define JSHTMLAllCollection_h + +#include "DOMObjectWithSVGContext.h" +#include "JSDOMBinding.h" +#include +#include +#include + +namespace WebCore { + +class HTMLAllCollection; + +class JSHTMLAllCollection : public DOMObjectWithGlobalPointer { + typedef DOMObjectWithGlobalPointer Base; +public: + JSHTMLAllCollection(NonNullPassRefPtr, JSDOMGlobalObject*, PassRefPtr); + virtual ~JSHTMLAllCollection(); + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + virtual bool getOwnPropertySlot(JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + + static PassRefPtr createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags)); + } + + virtual JSC::CallType getCallData(JSC::CallData&); + + virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&); + virtual bool toBoolean(JSC::ExecState*) const { return false; }; + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + + // Custom functions + JSC::JSValue item(JSC::ExecState*, const JSC::ArgList&); + JSC::JSValue namedItem(JSC::ExecState*, const JSC::ArgList&); + HTMLAllCollection* impl() const { return m_impl.get(); } + +private: + RefPtr m_impl; +protected: + static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | JSC::MasqueradesAsUndefined | Base::StructureFlags; + static JSC::JSValue indexGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); +private: + static bool canGetItemsForName(JSC::ExecState*, HTMLAllCollection*, const JSC::Identifier&); + static JSC::JSValue nameGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, HTMLAllCollection*); +HTMLAllCollection* toHTMLAllCollection(JSC::JSValue); + +class JSHTMLAllCollectionPrototype : public JSC::JSObject { + typedef JSC::JSObject Base; +public: + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static PassRefPtr createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags)); + } + JSHTMLAllCollectionPrototype(NonNullPassRefPtr structure) : JSC::JSObject(structure) { } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +// Functions + +JSC::JSValue JSC_HOST_CALL jsHTMLAllCollectionPrototypeFunctionItem(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsHTMLAllCollectionPrototypeFunctionNamedItem(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsHTMLAllCollectionPrototypeFunctionTags(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +// Attributes + +JSC::JSValue jsHTMLAllCollectionLength(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); +JSC::JSValue jsHTMLAllCollectionConstructor(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); + +} // namespace WebCore + +#endif diff --git a/src/3rdparty/webkit/WebCore/generated/JSHTMLBodyElement.cpp b/src/3rdparty/webkit/WebCore/generated/JSHTMLBodyElement.cpp index 920f152..5e81799 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSHTMLBodyElement.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSHTMLBodyElement.cpp @@ -350,7 +350,7 @@ void setJSHTMLBodyElementOnbeforeunload(ExecState* exec, JSObject* thisObject, J { UNUSED_PARAM(exec); HTMLBodyElement* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnbeforeunload(globalObject->createJSAttributeEventListener(value)); @@ -360,7 +360,7 @@ void setJSHTMLBodyElementOnhashchange(ExecState* exec, JSObject* thisObject, JSV { UNUSED_PARAM(exec); HTMLBodyElement* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnhashchange(globalObject->createJSAttributeEventListener(value)); @@ -370,7 +370,7 @@ void setJSHTMLBodyElementOnmessage(ExecState* exec, JSObject* thisObject, JSValu { UNUSED_PARAM(exec); HTMLBodyElement* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmessage(globalObject->createJSAttributeEventListener(value)); @@ -380,7 +380,7 @@ void setJSHTMLBodyElementOnoffline(ExecState* exec, JSObject* thisObject, JSValu { UNUSED_PARAM(exec); HTMLBodyElement* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnoffline(globalObject->createJSAttributeEventListener(value)); @@ -390,7 +390,7 @@ void setJSHTMLBodyElementOnonline(ExecState* exec, JSObject* thisObject, JSValue { UNUSED_PARAM(exec); HTMLBodyElement* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnonline(globalObject->createJSAttributeEventListener(value)); @@ -400,7 +400,7 @@ void setJSHTMLBodyElementOnresize(ExecState* exec, JSObject* thisObject, JSValue { UNUSED_PARAM(exec); HTMLBodyElement* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnresize(globalObject->createJSAttributeEventListener(value)); @@ -410,7 +410,7 @@ void setJSHTMLBodyElementOnstorage(ExecState* exec, JSObject* thisObject, JSValu { UNUSED_PARAM(exec); HTMLBodyElement* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnstorage(globalObject->createJSAttributeEventListener(value)); @@ -420,7 +420,7 @@ void setJSHTMLBodyElementOnunload(ExecState* exec, JSObject* thisObject, JSValue { UNUSED_PARAM(exec); HTMLBodyElement* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnunload(globalObject->createJSAttributeEventListener(value)); diff --git a/src/3rdparty/webkit/WebCore/generated/JSHTMLCollection.cpp b/src/3rdparty/webkit/WebCore/generated/JSHTMLCollection.cpp index 63c0d93..213b3c5 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSHTMLCollection.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSHTMLCollection.cpp @@ -24,10 +24,7 @@ #include "AtomicString.h" #include "HTMLCollection.h" #include "JSNode.h" -#include "JSNodeList.h" -#include "NameNodeList.h" #include "Node.h" -#include "NodeList.h" #include #include #include @@ -104,11 +101,10 @@ bool JSHTMLCollectionConstructor::getOwnPropertyDescriptor(ExecState* exec, cons /* Hash table for prototype */ -static const HashTableValue JSHTMLCollectionPrototypeTableValues[4] = +static const HashTableValue JSHTMLCollectionPrototypeTableValues[3] = { { "item", DontDelete|Function, (intptr_t)jsHTMLCollectionPrototypeFunctionItem, (intptr_t)1 }, { "namedItem", DontDelete|Function, (intptr_t)jsHTMLCollectionPrototypeFunctionNamedItem, (intptr_t)1 }, - { "tags", DontDelete|Function, (intptr_t)jsHTMLCollectionPrototypeFunctionTags, (intptr_t)1 }, { 0, 0, 0, 0 } }; @@ -116,7 +112,7 @@ static JSC_CONST_HASHTABLE HashTable JSHTMLCollectionPrototypeTable = #if ENABLE(PERFECT_HASH_SIZE) { 7, JSHTMLCollectionPrototypeTableValues, 0 }; #else - { 8, 7, JSHTMLCollectionPrototypeTableValues, 0 }; + { 5, 3, JSHTMLCollectionPrototypeTableValues, 0 }; #endif const ClassInfo JSHTMLCollectionPrototype::s_info = { "HTMLCollectionPrototype", 0, &JSHTMLCollectionPrototypeTable, 0 }; @@ -146,7 +142,7 @@ JSHTMLCollection::JSHTMLCollection(NonNullPassRefPtr structure, JSDOM JSHTMLCollection::~JSHTMLCollection() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSHTMLCollection::createPrototype(ExecState* exec, JSGlobalObject* globalObject) @@ -260,20 +256,6 @@ JSValue JSC_HOST_CALL jsHTMLCollectionPrototypeFunctionNamedItem(ExecState* exec return castedThisObj->namedItem(exec, args); } -JSValue JSC_HOST_CALL jsHTMLCollectionPrototypeFunctionTags(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) -{ - UNUSED_PARAM(args); - if (!thisValue.inherits(&JSHTMLCollection::s_info)) - return throwError(exec, TypeError); - JSHTMLCollection* castedThisObj = static_cast(asObject(thisValue)); - HTMLCollection* imp = static_cast(castedThisObj->impl()); - const UString& name = args.at(0).toString(exec); - - - JSC::JSValue result = toJS(exec, castedThisObj->globalObject(), WTF::getPtr(imp->tags(name))); - return result; -} - JSValue JSHTMLCollection::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot) { diff --git a/src/3rdparty/webkit/WebCore/generated/JSHTMLCollection.h b/src/3rdparty/webkit/WebCore/generated/JSHTMLCollection.h index 447f620..e14a2c2 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSHTMLCollection.h +++ b/src/3rdparty/webkit/WebCore/generated/JSHTMLCollection.h @@ -92,7 +92,6 @@ protected: JSC::JSValue JSC_HOST_CALL jsHTMLCollectionPrototypeFunctionItem(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsHTMLCollectionPrototypeFunctionNamedItem(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); -JSC::JSValue JSC_HOST_CALL jsHTMLCollectionPrototypeFunctionTags(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); // Attributes JSC::JSValue jsHTMLCollectionLength(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); diff --git a/src/3rdparty/webkit/WebCore/generated/JSHTMLFrameSetElement.cpp b/src/3rdparty/webkit/WebCore/generated/JSHTMLFrameSetElement.cpp index f336c76..9e506a0 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSHTMLFrameSetElement.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSHTMLFrameSetElement.cpp @@ -300,7 +300,7 @@ void setJSHTMLFrameSetElementOnbeforeunload(ExecState* exec, JSObject* thisObjec { UNUSED_PARAM(exec); HTMLFrameSetElement* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnbeforeunload(globalObject->createJSAttributeEventListener(value)); @@ -310,7 +310,7 @@ void setJSHTMLFrameSetElementOnhashchange(ExecState* exec, JSObject* thisObject, { UNUSED_PARAM(exec); HTMLFrameSetElement* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnhashchange(globalObject->createJSAttributeEventListener(value)); @@ -320,7 +320,7 @@ void setJSHTMLFrameSetElementOnmessage(ExecState* exec, JSObject* thisObject, JS { UNUSED_PARAM(exec); HTMLFrameSetElement* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmessage(globalObject->createJSAttributeEventListener(value)); @@ -330,7 +330,7 @@ void setJSHTMLFrameSetElementOnoffline(ExecState* exec, JSObject* thisObject, JS { UNUSED_PARAM(exec); HTMLFrameSetElement* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnoffline(globalObject->createJSAttributeEventListener(value)); @@ -340,7 +340,7 @@ void setJSHTMLFrameSetElementOnonline(ExecState* exec, JSObject* thisObject, JSV { UNUSED_PARAM(exec); HTMLFrameSetElement* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnonline(globalObject->createJSAttributeEventListener(value)); @@ -350,7 +350,7 @@ void setJSHTMLFrameSetElementOnresize(ExecState* exec, JSObject* thisObject, JSV { UNUSED_PARAM(exec); HTMLFrameSetElement* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnresize(globalObject->createJSAttributeEventListener(value)); @@ -360,7 +360,7 @@ void setJSHTMLFrameSetElementOnstorage(ExecState* exec, JSObject* thisObject, JS { UNUSED_PARAM(exec); HTMLFrameSetElement* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnstorage(globalObject->createJSAttributeEventListener(value)); @@ -370,7 +370,7 @@ void setJSHTMLFrameSetElementOnunload(ExecState* exec, JSObject* thisObject, JSV { UNUSED_PARAM(exec); HTMLFrameSetElement* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnunload(globalObject->createJSAttributeEventListener(value)); diff --git a/src/3rdparty/webkit/WebCore/generated/JSHistory.cpp b/src/3rdparty/webkit/WebCore/generated/JSHistory.cpp index 5331441..02be6ba 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSHistory.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSHistory.cpp @@ -92,7 +92,7 @@ JSHistory::JSHistory(NonNullPassRefPtr structure, JSDOMGlobalObject* JSHistory::~JSHistory() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSHistory::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSImageData.cpp b/src/3rdparty/webkit/WebCore/generated/JSImageData.cpp index a21fb87..1de3c43 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSImageData.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSImageData.cpp @@ -126,7 +126,7 @@ JSImageData::JSImageData(NonNullPassRefPtr structure, JSDOMGlobalObje JSImageData::~JSImageData() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSImageData::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSInspectorBackend.cpp b/src/3rdparty/webkit/WebCore/generated/JSInspectorBackend.cpp index 8da82cc..f72baaa 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSInspectorBackend.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSInspectorBackend.cpp @@ -214,7 +214,7 @@ JSInspectorBackend::JSInspectorBackend(NonNullPassRefPtr structure, J JSInspectorBackend::~JSInspectorBackend() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSInspectorBackend::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSJavaScriptCallFrame.cpp b/src/3rdparty/webkit/WebCore/generated/JSJavaScriptCallFrame.cpp index 798d540..2acd1af 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSJavaScriptCallFrame.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSJavaScriptCallFrame.cpp @@ -101,7 +101,7 @@ JSJavaScriptCallFrame::JSJavaScriptCallFrame(NonNullPassRefPtr struct JSJavaScriptCallFrame::~JSJavaScriptCallFrame() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSJavaScriptCallFrame::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSLocation.cpp b/src/3rdparty/webkit/WebCore/generated/JSLocation.cpp index ca21205..bb4d56c 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSLocation.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSLocation.cpp @@ -108,7 +108,7 @@ JSLocation::JSLocation(NonNullPassRefPtr structure, JSDOMGlobalObject JSLocation::~JSLocation() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSLocation::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSMedia.cpp b/src/3rdparty/webkit/WebCore/generated/JSMedia.cpp index b7d4c19..93cde9f 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSMedia.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSMedia.cpp @@ -138,7 +138,7 @@ JSMedia::JSMedia(NonNullPassRefPtr structure, JSDOMGlobalObject* glob JSMedia::~JSMedia() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSMedia::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSMediaError.cpp b/src/3rdparty/webkit/WebCore/generated/JSMediaError.cpp index 97e35e0..534a585 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSMediaError.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSMediaError.cpp @@ -146,7 +146,7 @@ JSMediaError::JSMediaError(NonNullPassRefPtr structure, JSDOMGlobalOb JSMediaError::~JSMediaError() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSMediaError::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSMediaList.cpp b/src/3rdparty/webkit/WebCore/generated/JSMediaList.cpp index 93a17b4..e7b758e 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSMediaList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSMediaList.cpp @@ -142,7 +142,7 @@ JSMediaList::JSMediaList(NonNullPassRefPtr structure, JSDOMGlobalObje JSMediaList::~JSMediaList() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSMediaList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSMessageChannel.cpp b/src/3rdparty/webkit/WebCore/generated/JSMessageChannel.cpp index 4fdac64..8ba6f01 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSMessageChannel.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSMessageChannel.cpp @@ -87,7 +87,7 @@ JSMessageChannel::JSMessageChannel(NonNullPassRefPtr structure, JSDOM JSMessageChannel::~JSMessageChannel() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSMessageChannel::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSMessagePort.cpp b/src/3rdparty/webkit/WebCore/generated/JSMessagePort.cpp index 28e1492..a65091c 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSMessagePort.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSMessagePort.cpp @@ -158,7 +158,7 @@ JSMessagePort::JSMessagePort(NonNullPassRefPtr structure, JSDOMGlobal JSMessagePort::~JSMessagePort() { impl()->invalidateEventListeners(); - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSMessagePort::createPrototype(ExecState* exec, JSGlobalObject* globalObject) @@ -202,7 +202,7 @@ void setJSMessagePortOnmessage(ExecState* exec, JSObject* thisObject, JSValue va { UNUSED_PARAM(exec); MessagePort* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmessage(globalObject->createJSAttributeEventListener(value)); diff --git a/src/3rdparty/webkit/WebCore/generated/JSMimeType.cpp b/src/3rdparty/webkit/WebCore/generated/JSMimeType.cpp index f797df2..c91aaeb 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSMimeType.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSMimeType.cpp @@ -131,7 +131,7 @@ JSMimeType::JSMimeType(NonNullPassRefPtr structure, JSDOMGlobalObject JSMimeType::~JSMimeType() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSMimeType::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSMimeTypeArray.cpp b/src/3rdparty/webkit/WebCore/generated/JSMimeTypeArray.cpp index 0384539..3c7b740 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSMimeTypeArray.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSMimeTypeArray.cpp @@ -142,7 +142,7 @@ JSMimeTypeArray::JSMimeTypeArray(NonNullPassRefPtr structure, JSDOMGl JSMimeTypeArray::~JSMimeTypeArray() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSMimeTypeArray::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSNamedNodeMap.cpp b/src/3rdparty/webkit/WebCore/generated/JSNamedNodeMap.cpp index e3cc8d2..e9c79a1 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSNamedNodeMap.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSNamedNodeMap.cpp @@ -147,7 +147,7 @@ JSNamedNodeMap::JSNamedNodeMap(NonNullPassRefPtr structure, JSDOMGlob JSNamedNodeMap::~JSNamedNodeMap() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSNamedNodeMap::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSNavigator.cpp b/src/3rdparty/webkit/WebCore/generated/JSNavigator.cpp index 6dcda62..1c8e190 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSNavigator.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSNavigator.cpp @@ -108,7 +108,7 @@ JSNavigator::JSNavigator(NonNullPassRefPtr structure, JSDOMGlobalObje JSNavigator::~JSNavigator() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSNavigator::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSNode.cpp b/src/3rdparty/webkit/WebCore/generated/JSNode.cpp index e132829..e3a2006 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSNode.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSNode.cpp @@ -221,7 +221,7 @@ JSNode::JSNode(NonNullPassRefPtr structure, JSDOMGlobalObject* global JSNode::~JSNode() { impl()->invalidateEventListeners(); - forgetDOMNode(impl()->document(), impl()); + forgetDOMNode(this, impl(), impl()->document()); } JSObject* JSNode::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSNodeFilter.cpp b/src/3rdparty/webkit/WebCore/generated/JSNodeFilter.cpp index 141a060..22726f6 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSNodeFilter.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSNodeFilter.cpp @@ -167,7 +167,7 @@ JSNodeFilter::JSNodeFilter(NonNullPassRefPtr structure, JSDOMGlobalOb JSNodeFilter::~JSNodeFilter() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSNodeFilter::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSNodeIterator.cpp b/src/3rdparty/webkit/WebCore/generated/JSNodeIterator.cpp index cf85e40..8570d24 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSNodeIterator.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSNodeIterator.cpp @@ -148,7 +148,7 @@ JSNodeIterator::JSNodeIterator(NonNullPassRefPtr structure, JSDOMGlob JSNodeIterator::~JSNodeIterator() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSNodeIterator::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSNodeList.cpp b/src/3rdparty/webkit/WebCore/generated/JSNodeList.cpp index 01ee9ac..3f3131e 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSNodeList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSNodeList.cpp @@ -142,7 +142,7 @@ JSNodeList::JSNodeList(NonNullPassRefPtr structure, JSDOMGlobalObject JSNodeList::~JSNodeList() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSNodeList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSPlugin.cpp b/src/3rdparty/webkit/WebCore/generated/JSPlugin.cpp index 035a352..1c7b6ec 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSPlugin.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSPlugin.cpp @@ -147,7 +147,7 @@ JSPlugin::JSPlugin(NonNullPassRefPtr structure, JSDOMGlobalObject* gl JSPlugin::~JSPlugin() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSPlugin::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSPluginArray.cpp b/src/3rdparty/webkit/WebCore/generated/JSPluginArray.cpp index bd0b579..38a9346 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSPluginArray.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSPluginArray.cpp @@ -143,7 +143,7 @@ JSPluginArray::JSPluginArray(NonNullPassRefPtr structure, JSDOMGlobal JSPluginArray::~JSPluginArray() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSPluginArray::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSPositionError.cpp b/src/3rdparty/webkit/WebCore/generated/JSPositionError.cpp index e178bd9..fffa0c1 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSPositionError.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSPositionError.cpp @@ -146,7 +146,7 @@ JSPositionError::JSPositionError(NonNullPassRefPtr structure, JSDOMGl JSPositionError::~JSPositionError() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSPositionError::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSRGBColor.cpp b/src/3rdparty/webkit/WebCore/generated/JSRGBColor.cpp index 0dff99a..e45ce66 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSRGBColor.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSRGBColor.cpp @@ -128,7 +128,7 @@ JSRGBColor::JSRGBColor(NonNullPassRefPtr structure, JSDOMGlobalObject JSRGBColor::~JSRGBColor() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSRGBColor::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSRange.cpp b/src/3rdparty/webkit/WebCore/generated/JSRange.cpp index cc59119..bc9979b 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSRange.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSRange.cpp @@ -194,7 +194,7 @@ JSRange::JSRange(NonNullPassRefPtr structure, JSDOMGlobalObject* glob JSRange::~JSRange() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSRange::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSRangeException.cpp b/src/3rdparty/webkit/WebCore/generated/JSRangeException.cpp index 2f8e618..bbb172d 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSRangeException.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSRangeException.cpp @@ -145,7 +145,7 @@ JSRangeException::JSRangeException(NonNullPassRefPtr structure, JSDOM JSRangeException::~JSRangeException() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSRangeException::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSRect.cpp b/src/3rdparty/webkit/WebCore/generated/JSRect.cpp index 37c4669..e57d688 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSRect.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSRect.cpp @@ -129,7 +129,7 @@ JSRect::JSRect(NonNullPassRefPtr structure, JSDOMGlobalObject* global JSRect::~JSRect() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSRect::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSQLError.cpp b/src/3rdparty/webkit/WebCore/generated/JSSQLError.cpp index a318e1d..79fdc89 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSQLError.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSQLError.cpp @@ -83,7 +83,7 @@ JSSQLError::JSSQLError(NonNullPassRefPtr structure, JSDOMGlobalObject JSSQLError::~JSSQLError() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSQLError::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSQLResultSet.cpp b/src/3rdparty/webkit/WebCore/generated/JSSQLResultSet.cpp index 223de95..fa85ad6 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSQLResultSet.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSQLResultSet.cpp @@ -84,7 +84,7 @@ JSSQLResultSet::JSSQLResultSet(NonNullPassRefPtr structure, JSDOMGlob JSSQLResultSet::~JSSQLResultSet() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSQLResultSet::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSQLResultSetRowList.cpp b/src/3rdparty/webkit/WebCore/generated/JSSQLResultSetRowList.cpp index dddf0c4..090e4f7 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSQLResultSetRowList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSQLResultSetRowList.cpp @@ -92,7 +92,7 @@ JSSQLResultSetRowList::JSSQLResultSetRowList(NonNullPassRefPtr struct JSSQLResultSetRowList::~JSSQLResultSetRowList() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSQLResultSetRowList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSQLTransaction.cpp b/src/3rdparty/webkit/WebCore/generated/JSSQLTransaction.cpp index c2c0e54..e165dad 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSQLTransaction.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSQLTransaction.cpp @@ -76,7 +76,7 @@ JSSQLTransaction::JSSQLTransaction(NonNullPassRefPtr structure, JSDOM JSSQLTransaction::~JSSQLTransaction() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSQLTransaction::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGAngle.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGAngle.cpp index 220f4a6..e6d4795 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGAngle.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGAngle.cpp @@ -156,7 +156,7 @@ JSSVGAngle::JSSVGAngle(NonNullPassRefPtr structure, JSDOMGlobalObject JSSVGAngle::~JSSVGAngle() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGAngle::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedAngle.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedAngle.cpp index c09ce1c..599f5ca 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedAngle.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedAngle.cpp @@ -81,7 +81,7 @@ JSSVGAnimatedAngle::JSSVGAnimatedAngle(NonNullPassRefPtr structure, J JSSVGAnimatedAngle::~JSSVGAnimatedAngle() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGAnimatedAngle::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedBoolean.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedBoolean.cpp index fb3f4c8..131b358 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedBoolean.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedBoolean.cpp @@ -79,7 +79,7 @@ JSSVGAnimatedBoolean::JSSVGAnimatedBoolean(NonNullPassRefPtr structur JSSVGAnimatedBoolean::~JSSVGAnimatedBoolean() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGAnimatedBoolean::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedEnumeration.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedEnumeration.cpp index 8fbe43e..6a27988 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedEnumeration.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedEnumeration.cpp @@ -80,7 +80,7 @@ JSSVGAnimatedEnumeration::JSSVGAnimatedEnumeration(NonNullPassRefPtr JSSVGAnimatedEnumeration::~JSSVGAnimatedEnumeration() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGAnimatedEnumeration::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedInteger.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedInteger.cpp index f52a51b..86c388b 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedInteger.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedInteger.cpp @@ -80,7 +80,7 @@ JSSVGAnimatedInteger::JSSVGAnimatedInteger(NonNullPassRefPtr structur JSSVGAnimatedInteger::~JSSVGAnimatedInteger() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGAnimatedInteger::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedLength.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedLength.cpp index 50826a7..f5fff5e 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedLength.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedLength.cpp @@ -80,7 +80,7 @@ JSSVGAnimatedLength::JSSVGAnimatedLength(NonNullPassRefPtr structure, JSSVGAnimatedLength::~JSSVGAnimatedLength() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGAnimatedLength::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedLengthList.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedLengthList.cpp index b0c3743..5525640 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedLengthList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedLengthList.cpp @@ -81,7 +81,7 @@ JSSVGAnimatedLengthList::JSSVGAnimatedLengthList(NonNullPassRefPtr st JSSVGAnimatedLengthList::~JSSVGAnimatedLengthList() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGAnimatedLengthList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedNumber.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedNumber.cpp index ef16117..69f1490 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedNumber.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedNumber.cpp @@ -80,7 +80,7 @@ JSSVGAnimatedNumber::JSSVGAnimatedNumber(NonNullPassRefPtr structure, JSSVGAnimatedNumber::~JSSVGAnimatedNumber() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGAnimatedNumber::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedNumberList.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedNumberList.cpp index af11dbd..0fa8afa 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedNumberList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedNumberList.cpp @@ -81,7 +81,7 @@ JSSVGAnimatedNumberList::JSSVGAnimatedNumberList(NonNullPassRefPtr st JSSVGAnimatedNumberList::~JSSVGAnimatedNumberList() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGAnimatedNumberList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedPreserveAspectRatio.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedPreserveAspectRatio.cpp index 53f0b60..b64ee3a 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedPreserveAspectRatio.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedPreserveAspectRatio.cpp @@ -81,7 +81,7 @@ JSSVGAnimatedPreserveAspectRatio::JSSVGAnimatedPreserveAspectRatio(NonNullPassRe JSSVGAnimatedPreserveAspectRatio::~JSSVGAnimatedPreserveAspectRatio() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGAnimatedPreserveAspectRatio::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedRect.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedRect.cpp index 432a4d5..0db579b 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedRect.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedRect.cpp @@ -81,7 +81,7 @@ JSSVGAnimatedRect::JSSVGAnimatedRect(NonNullPassRefPtr structure, JSD JSSVGAnimatedRect::~JSSVGAnimatedRect() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGAnimatedRect::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedString.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedString.cpp index c3ccd92..a26a070 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedString.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedString.cpp @@ -82,7 +82,7 @@ JSSVGAnimatedString::JSSVGAnimatedString(NonNullPassRefPtr structure, JSSVGAnimatedString::~JSSVGAnimatedString() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGAnimatedString::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedTransformList.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedTransformList.cpp index 52b2395..62c3121 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedTransformList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGAnimatedTransformList.cpp @@ -81,7 +81,7 @@ JSSVGAnimatedTransformList::JSSVGAnimatedTransformList(NonNullPassRefPtrglobalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGAnimatedTransformList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGElementInstance.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGElementInstance.cpp index 10d375d..1bb0736 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGElementInstance.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGElementInstance.cpp @@ -153,7 +153,7 @@ JSSVGElementInstance::JSSVGElementInstance(NonNullPassRefPtr structur JSSVGElementInstance::~JSSVGElementInstance() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGElementInstance::createPrototype(ExecState* exec, JSGlobalObject* globalObject) @@ -724,7 +724,7 @@ void setJSSVGElementInstanceOnabort(ExecState* exec, JSObject* thisObject, JSVal { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnabort(globalObject->createJSAttributeEventListener(value)); @@ -734,7 +734,7 @@ void setJSSVGElementInstanceOnblur(ExecState* exec, JSObject* thisObject, JSValu { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnblur(globalObject->createJSAttributeEventListener(value)); @@ -744,7 +744,7 @@ void setJSSVGElementInstanceOnchange(ExecState* exec, JSObject* thisObject, JSVa { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnchange(globalObject->createJSAttributeEventListener(value)); @@ -754,7 +754,7 @@ void setJSSVGElementInstanceOnclick(ExecState* exec, JSObject* thisObject, JSVal { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnclick(globalObject->createJSAttributeEventListener(value)); @@ -764,7 +764,7 @@ void setJSSVGElementInstanceOncontextmenu(ExecState* exec, JSObject* thisObject, { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOncontextmenu(globalObject->createJSAttributeEventListener(value)); @@ -774,7 +774,7 @@ void setJSSVGElementInstanceOndblclick(ExecState* exec, JSObject* thisObject, JS { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndblclick(globalObject->createJSAttributeEventListener(value)); @@ -784,7 +784,7 @@ void setJSSVGElementInstanceOnerror(ExecState* exec, JSObject* thisObject, JSVal { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnerror(globalObject->createJSAttributeEventListener(value)); @@ -794,7 +794,7 @@ void setJSSVGElementInstanceOnfocus(ExecState* exec, JSObject* thisObject, JSVal { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnfocus(globalObject->createJSAttributeEventListener(value)); @@ -804,7 +804,7 @@ void setJSSVGElementInstanceOninput(ExecState* exec, JSObject* thisObject, JSVal { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOninput(globalObject->createJSAttributeEventListener(value)); @@ -814,7 +814,7 @@ void setJSSVGElementInstanceOnkeydown(ExecState* exec, JSObject* thisObject, JSV { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnkeydown(globalObject->createJSAttributeEventListener(value)); @@ -824,7 +824,7 @@ void setJSSVGElementInstanceOnkeypress(ExecState* exec, JSObject* thisObject, JS { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnkeypress(globalObject->createJSAttributeEventListener(value)); @@ -834,7 +834,7 @@ void setJSSVGElementInstanceOnkeyup(ExecState* exec, JSObject* thisObject, JSVal { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnkeyup(globalObject->createJSAttributeEventListener(value)); @@ -844,7 +844,7 @@ void setJSSVGElementInstanceOnload(ExecState* exec, JSObject* thisObject, JSValu { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnload(globalObject->createJSAttributeEventListener(value)); @@ -854,7 +854,7 @@ void setJSSVGElementInstanceOnmousedown(ExecState* exec, JSObject* thisObject, J { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmousedown(globalObject->createJSAttributeEventListener(value)); @@ -864,7 +864,7 @@ void setJSSVGElementInstanceOnmousemove(ExecState* exec, JSObject* thisObject, J { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmousemove(globalObject->createJSAttributeEventListener(value)); @@ -874,7 +874,7 @@ void setJSSVGElementInstanceOnmouseout(ExecState* exec, JSObject* thisObject, JS { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmouseout(globalObject->createJSAttributeEventListener(value)); @@ -884,7 +884,7 @@ void setJSSVGElementInstanceOnmouseover(ExecState* exec, JSObject* thisObject, J { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmouseover(globalObject->createJSAttributeEventListener(value)); @@ -894,7 +894,7 @@ void setJSSVGElementInstanceOnmouseup(ExecState* exec, JSObject* thisObject, JSV { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmouseup(globalObject->createJSAttributeEventListener(value)); @@ -904,7 +904,7 @@ void setJSSVGElementInstanceOnmousewheel(ExecState* exec, JSObject* thisObject, { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmousewheel(globalObject->createJSAttributeEventListener(value)); @@ -914,7 +914,7 @@ void setJSSVGElementInstanceOnbeforecut(ExecState* exec, JSObject* thisObject, J { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnbeforecut(globalObject->createJSAttributeEventListener(value)); @@ -924,7 +924,7 @@ void setJSSVGElementInstanceOncut(ExecState* exec, JSObject* thisObject, JSValue { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOncut(globalObject->createJSAttributeEventListener(value)); @@ -934,7 +934,7 @@ void setJSSVGElementInstanceOnbeforecopy(ExecState* exec, JSObject* thisObject, { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnbeforecopy(globalObject->createJSAttributeEventListener(value)); @@ -944,7 +944,7 @@ void setJSSVGElementInstanceOncopy(ExecState* exec, JSObject* thisObject, JSValu { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOncopy(globalObject->createJSAttributeEventListener(value)); @@ -954,7 +954,7 @@ void setJSSVGElementInstanceOnbeforepaste(ExecState* exec, JSObject* thisObject, { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnbeforepaste(globalObject->createJSAttributeEventListener(value)); @@ -964,7 +964,7 @@ void setJSSVGElementInstanceOnpaste(ExecState* exec, JSObject* thisObject, JSVal { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnpaste(globalObject->createJSAttributeEventListener(value)); @@ -974,7 +974,7 @@ void setJSSVGElementInstanceOndragenter(ExecState* exec, JSObject* thisObject, J { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndragenter(globalObject->createJSAttributeEventListener(value)); @@ -984,7 +984,7 @@ void setJSSVGElementInstanceOndragover(ExecState* exec, JSObject* thisObject, JS { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndragover(globalObject->createJSAttributeEventListener(value)); @@ -994,7 +994,7 @@ void setJSSVGElementInstanceOndragleave(ExecState* exec, JSObject* thisObject, J { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndragleave(globalObject->createJSAttributeEventListener(value)); @@ -1004,7 +1004,7 @@ void setJSSVGElementInstanceOndrop(ExecState* exec, JSObject* thisObject, JSValu { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndrop(globalObject->createJSAttributeEventListener(value)); @@ -1014,7 +1014,7 @@ void setJSSVGElementInstanceOndragstart(ExecState* exec, JSObject* thisObject, J { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndragstart(globalObject->createJSAttributeEventListener(value)); @@ -1024,7 +1024,7 @@ void setJSSVGElementInstanceOndrag(ExecState* exec, JSObject* thisObject, JSValu { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndrag(globalObject->createJSAttributeEventListener(value)); @@ -1034,7 +1034,7 @@ void setJSSVGElementInstanceOndragend(ExecState* exec, JSObject* thisObject, JSV { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOndragend(globalObject->createJSAttributeEventListener(value)); @@ -1044,7 +1044,7 @@ void setJSSVGElementInstanceOnreset(ExecState* exec, JSObject* thisObject, JSVal { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnreset(globalObject->createJSAttributeEventListener(value)); @@ -1054,7 +1054,7 @@ void setJSSVGElementInstanceOnresize(ExecState* exec, JSObject* thisObject, JSVa { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnresize(globalObject->createJSAttributeEventListener(value)); @@ -1064,7 +1064,7 @@ void setJSSVGElementInstanceOnscroll(ExecState* exec, JSObject* thisObject, JSVa { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnscroll(globalObject->createJSAttributeEventListener(value)); @@ -1074,7 +1074,7 @@ void setJSSVGElementInstanceOnsearch(ExecState* exec, JSObject* thisObject, JSVa { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnsearch(globalObject->createJSAttributeEventListener(value)); @@ -1084,7 +1084,7 @@ void setJSSVGElementInstanceOnselect(ExecState* exec, JSObject* thisObject, JSVa { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnselect(globalObject->createJSAttributeEventListener(value)); @@ -1094,7 +1094,7 @@ void setJSSVGElementInstanceOnselectstart(ExecState* exec, JSObject* thisObject, { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnselectstart(globalObject->createJSAttributeEventListener(value)); @@ -1104,7 +1104,7 @@ void setJSSVGElementInstanceOnsubmit(ExecState* exec, JSObject* thisObject, JSVa { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnsubmit(globalObject->createJSAttributeEventListener(value)); @@ -1114,7 +1114,7 @@ void setJSSVGElementInstanceOnunload(ExecState* exec, JSObject* thisObject, JSVa { UNUSED_PARAM(exec); SVGElementInstance* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnunload(globalObject->createJSAttributeEventListener(value)); diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGElementInstanceList.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGElementInstanceList.cpp index 8bc5bc0..893cc76 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGElementInstanceList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGElementInstanceList.cpp @@ -94,7 +94,7 @@ JSSVGElementInstanceList::JSSVGElementInstanceList(NonNullPassRefPtr JSSVGElementInstanceList::~JSSVGElementInstanceList() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGElementInstanceList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGException.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGException.cpp index 039182f..8906774 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGException.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGException.cpp @@ -150,7 +150,7 @@ JSSVGException::JSSVGException(NonNullPassRefPtr structure, JSDOMGlob JSSVGException::~JSSVGException() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGException::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGLength.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGLength.cpp index f97df89..0bcf836 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGLength.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGLength.cpp @@ -169,7 +169,7 @@ JSSVGLength::JSSVGLength(NonNullPassRefPtr structure, JSDOMGlobalObje JSSVGLength::~JSSVGLength() { JSSVGDynamicPODTypeWrapperCache::forgetWrapper(m_impl.get()); - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGLength::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGLengthList.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGLengthList.cpp index 952a5f0..a984bd1 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGLengthList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGLengthList.cpp @@ -100,7 +100,7 @@ JSSVGLengthList::JSSVGLengthList(NonNullPassRefPtr structure, JSDOMGl JSSVGLengthList::~JSSVGLengthList() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGLengthList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGMatrix.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGMatrix.cpp index ba8dfe8..d46ce6f 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGMatrix.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGMatrix.cpp @@ -107,7 +107,7 @@ JSSVGMatrix::JSSVGMatrix(NonNullPassRefPtr structure, JSDOMGlobalObje JSSVGMatrix::~JSSVGMatrix() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGMatrix::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGNumber.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGNumber.cpp index 2bfe658..8ba2042 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGNumber.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGNumber.cpp @@ -79,7 +79,7 @@ JSSVGNumber::JSSVGNumber(NonNullPassRefPtr structure, JSDOMGlobalObje JSSVGNumber::~JSSVGNumber() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGNumber::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGNumberList.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGNumberList.cpp index dc6f5a4..fa0e3cf 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGNumberList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGNumberList.cpp @@ -99,7 +99,7 @@ JSSVGNumberList::JSSVGNumberList(NonNullPassRefPtr structure, JSDOMGl JSSVGNumberList::~JSSVGNumberList() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGNumberList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGPathSeg.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGPathSeg.cpp index 2f1ecbd..767098b 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGPathSeg.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGPathSeg.cpp @@ -181,7 +181,7 @@ JSSVGPathSeg::JSSVGPathSeg(NonNullPassRefPtr structure, JSDOMGlobalOb JSSVGPathSeg::~JSSVGPathSeg() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGPathSeg::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGPathSegList.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGPathSegList.cpp index 0043533..9a35c1b 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGPathSegList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGPathSegList.cpp @@ -99,7 +99,7 @@ JSSVGPathSegList::JSSVGPathSegList(NonNullPassRefPtr structure, JSDOM JSSVGPathSegList::~JSSVGPathSegList() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGPathSegList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGPoint.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGPoint.cpp index e4c2415..67c35e2 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGPoint.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGPoint.cpp @@ -94,7 +94,7 @@ JSSVGPoint::JSSVGPoint(NonNullPassRefPtr structure, JSDOMGlobalObject JSSVGPoint::~JSSVGPoint() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGPoint::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGPointList.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGPointList.cpp index 4a22ff9..6968c80 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGPointList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGPointList.cpp @@ -98,7 +98,7 @@ JSSVGPointList::JSSVGPointList(NonNullPassRefPtr structure, JSDOMGlob JSSVGPointList::~JSSVGPointList() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGPointList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGPreserveAspectRatio.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGPreserveAspectRatio.cpp index 0f3329c..578cd34 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGPreserveAspectRatio.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGPreserveAspectRatio.cpp @@ -167,7 +167,7 @@ JSSVGPreserveAspectRatio::JSSVGPreserveAspectRatio(NonNullPassRefPtr JSSVGPreserveAspectRatio::~JSSVGPreserveAspectRatio() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGPreserveAspectRatio::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGRect.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGRect.cpp index 8360b4b..e60a309 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGRect.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGRect.cpp @@ -83,7 +83,7 @@ JSSVGRect::JSSVGRect(NonNullPassRefPtr structure, JSDOMGlobalObject* JSSVGRect::~JSSVGRect() { JSSVGDynamicPODTypeWrapperCache::forgetWrapper(m_impl.get()); - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGRect::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGRenderingIntent.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGRenderingIntent.cpp index b484fbf..1793c23 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGRenderingIntent.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGRenderingIntent.cpp @@ -148,7 +148,7 @@ JSSVGRenderingIntent::JSSVGRenderingIntent(NonNullPassRefPtr structur JSSVGRenderingIntent::~JSSVGRenderingIntent() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGRenderingIntent::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGStringList.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGStringList.cpp index d4a6935..591ca64 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGStringList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGStringList.cpp @@ -100,7 +100,7 @@ JSSVGStringList::JSSVGStringList(NonNullPassRefPtr structure, JSDOMGl JSSVGStringList::~JSSVGStringList() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGStringList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGTransform.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGTransform.cpp index 82cddb6..2f51e56 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGTransform.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGTransform.cpp @@ -162,7 +162,7 @@ JSSVGTransform::JSSVGTransform(NonNullPassRefPtr structure, JSDOMGlob JSSVGTransform::~JSSVGTransform() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGTransform::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGTransformList.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGTransformList.cpp index 51c0cca..8ce9342 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGTransformList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGTransformList.cpp @@ -103,7 +103,7 @@ JSSVGTransformList::JSSVGTransformList(NonNullPassRefPtr structure, J JSSVGTransformList::~JSSVGTransformList() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGTransformList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSSVGUnitTypes.cpp b/src/3rdparty/webkit/WebCore/generated/JSSVGUnitTypes.cpp index 452fc9c..fb3321a 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSSVGUnitTypes.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSSVGUnitTypes.cpp @@ -142,7 +142,7 @@ JSSVGUnitTypes::JSSVGUnitTypes(NonNullPassRefPtr structure, JSDOMGlob JSSVGUnitTypes::~JSSVGUnitTypes() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSSVGUnitTypes::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSScreen.cpp b/src/3rdparty/webkit/WebCore/generated/JSScreen.cpp index 574f44c..7ccffa3 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSScreen.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSScreen.cpp @@ -84,7 +84,7 @@ JSScreen::JSScreen(NonNullPassRefPtr structure, JSDOMGlobalObject* gl JSScreen::~JSScreen() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSScreen::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSStorage.cpp b/src/3rdparty/webkit/WebCore/generated/JSStorage.cpp index 998b8cf..e0ae01b 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSStorage.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSStorage.cpp @@ -147,7 +147,7 @@ JSStorage::JSStorage(NonNullPassRefPtr structure, JSDOMGlobalObject* JSStorage::~JSStorage() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSStorage::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSStyleSheet.cpp b/src/3rdparty/webkit/WebCore/generated/JSStyleSheet.cpp index ae7011d..b84ab6b 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSStyleSheet.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSStyleSheet.cpp @@ -136,7 +136,7 @@ JSStyleSheet::JSStyleSheet(NonNullPassRefPtr structure, JSDOMGlobalOb JSStyleSheet::~JSStyleSheet() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSStyleSheet::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSStyleSheetList.cpp b/src/3rdparty/webkit/WebCore/generated/JSStyleSheetList.cpp index 5d07cc1..db3d083 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSStyleSheetList.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSStyleSheetList.cpp @@ -141,7 +141,7 @@ JSStyleSheetList::JSStyleSheetList(NonNullPassRefPtr structure, JSDOM JSStyleSheetList::~JSStyleSheetList() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSStyleSheetList::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSTextMetrics.cpp b/src/3rdparty/webkit/WebCore/generated/JSTextMetrics.cpp index 627ad3b..940498a 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSTextMetrics.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSTextMetrics.cpp @@ -125,7 +125,7 @@ JSTextMetrics::JSTextMetrics(NonNullPassRefPtr structure, JSDOMGlobal JSTextMetrics::~JSTextMetrics() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSTextMetrics::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSTimeRanges.cpp b/src/3rdparty/webkit/WebCore/generated/JSTimeRanges.cpp index 825ca1b..1306ccb 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSTimeRanges.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSTimeRanges.cpp @@ -93,7 +93,7 @@ JSTimeRanges::JSTimeRanges(NonNullPassRefPtr structure, JSDOMGlobalOb JSTimeRanges::~JSTimeRanges() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSTimeRanges::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSTreeWalker.cpp b/src/3rdparty/webkit/WebCore/generated/JSTreeWalker.cpp index a26425e..10645db 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSTreeWalker.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSTreeWalker.cpp @@ -151,7 +151,7 @@ JSTreeWalker::JSTreeWalker(NonNullPassRefPtr structure, JSDOMGlobalOb JSTreeWalker::~JSTreeWalker() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSTreeWalker::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSValidityState.cpp b/src/3rdparty/webkit/WebCore/generated/JSValidityState.cpp index b355874..7616c58 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSValidityState.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSValidityState.cpp @@ -84,7 +84,7 @@ JSValidityState::JSValidityState(NonNullPassRefPtr structure, JSDOMGl JSValidityState::~JSValidityState() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSValidityState::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSVoidCallback.cpp b/src/3rdparty/webkit/WebCore/generated/JSVoidCallback.cpp index a084949..94ad1c5 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSVoidCallback.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSVoidCallback.cpp @@ -73,7 +73,7 @@ JSVoidCallback::JSVoidCallback(NonNullPassRefPtr structure, JSDOMGlob JSVoidCallback::~JSVoidCallback() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSVoidCallback::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSWebKitCSSMatrix.cpp b/src/3rdparty/webkit/WebCore/generated/JSWebKitCSSMatrix.cpp index bcf8286..0bb2267 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSWebKitCSSMatrix.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSWebKitCSSMatrix.cpp @@ -120,7 +120,7 @@ JSWebKitCSSMatrix::JSWebKitCSSMatrix(NonNullPassRefPtr structure, JSD JSWebKitCSSMatrix::~JSWebKitCSSMatrix() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSWebKitCSSMatrix::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSWebKitPoint.cpp b/src/3rdparty/webkit/WebCore/generated/JSWebKitPoint.cpp index 255df0a..ea88682 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSWebKitPoint.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSWebKitPoint.cpp @@ -78,7 +78,7 @@ JSWebKitPoint::JSWebKitPoint(NonNullPassRefPtr structure, JSDOMGlobal JSWebKitPoint::~JSWebKitPoint() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSWebKitPoint::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSWebSocket.cpp b/src/3rdparty/webkit/WebCore/generated/JSWebSocket.cpp index ea8ff3d..7e48815 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSWebSocket.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSWebSocket.cpp @@ -122,7 +122,7 @@ JSWebSocket::JSWebSocket(NonNullPassRefPtr structure, JSDOMGlobalObje JSWebSocket::~JSWebSocket() { impl()->invalidateEventListeners(); - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } void JSWebSocket::markChildren(MarkStack& markStack) @@ -215,7 +215,7 @@ void setJSWebSocketOnopen(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); WebSocket* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnopen(globalObject->createJSAttributeEventListener(value)); @@ -225,7 +225,7 @@ void setJSWebSocketOnmessage(ExecState* exec, JSObject* thisObject, JSValue valu { UNUSED_PARAM(exec); WebSocket* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmessage(globalObject->createJSAttributeEventListener(value)); @@ -235,7 +235,7 @@ void setJSWebSocketOnclose(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); WebSocket* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnclose(globalObject->createJSAttributeEventListener(value)); diff --git a/src/3rdparty/webkit/WebCore/generated/JSWorker.cpp b/src/3rdparty/webkit/WebCore/generated/JSWorker.cpp index 42cc502..14153e2 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSWorker.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSWorker.cpp @@ -129,7 +129,7 @@ void setJSWorkerOnmessage(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); Worker* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnmessage(globalObject->createJSAttributeEventListener(value)); diff --git a/src/3rdparty/webkit/WebCore/generated/JSWorkerContext.cpp b/src/3rdparty/webkit/WebCore/generated/JSWorkerContext.cpp index e29cb32..5b7b105 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSWorkerContext.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSWorkerContext.cpp @@ -129,7 +129,6 @@ JSWorkerContext::JSWorkerContext(NonNullPassRefPtr structure, PassRef JSWorkerContext::~JSWorkerContext() { impl()->invalidateEventListeners(); - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); } bool JSWorkerContext::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) diff --git a/src/3rdparty/webkit/WebCore/generated/JSWorkerLocation.cpp b/src/3rdparty/webkit/WebCore/generated/JSWorkerLocation.cpp index e24d0d6..6046aa6 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSWorkerLocation.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSWorkerLocation.cpp @@ -156,7 +156,7 @@ JSWorkerLocation::JSWorkerLocation(NonNullPassRefPtr structure, JSDOM JSWorkerLocation::~JSWorkerLocation() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSWorkerLocation::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSWorkerNavigator.cpp b/src/3rdparty/webkit/WebCore/generated/JSWorkerNavigator.cpp index 8efab1e..29c2364 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSWorkerNavigator.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSWorkerNavigator.cpp @@ -93,7 +93,7 @@ JSWorkerNavigator::JSWorkerNavigator(NonNullPassRefPtr structure, JSD JSWorkerNavigator::~JSWorkerNavigator() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSWorkerNavigator::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSXMLHttpRequest.cpp b/src/3rdparty/webkit/WebCore/generated/JSXMLHttpRequest.cpp index 9927f5e..d81c689 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSXMLHttpRequest.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSXMLHttpRequest.cpp @@ -137,7 +137,7 @@ JSXMLHttpRequest::JSXMLHttpRequest(NonNullPassRefPtr structure, JSDOM JSXMLHttpRequest::~JSXMLHttpRequest() { impl()->invalidateEventListeners(); - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSXMLHttpRequest::createPrototype(ExecState* exec, JSGlobalObject* globalObject) @@ -294,7 +294,7 @@ void setJSXMLHttpRequestOnabort(ExecState* exec, JSObject* thisObject, JSValue v { UNUSED_PARAM(exec); XMLHttpRequest* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnabort(globalObject->createJSAttributeEventListener(value)); @@ -304,7 +304,7 @@ void setJSXMLHttpRequestOnerror(ExecState* exec, JSObject* thisObject, JSValue v { UNUSED_PARAM(exec); XMLHttpRequest* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnerror(globalObject->createJSAttributeEventListener(value)); @@ -314,7 +314,7 @@ void setJSXMLHttpRequestOnload(ExecState* exec, JSObject* thisObject, JSValue va { UNUSED_PARAM(exec); XMLHttpRequest* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnload(globalObject->createJSAttributeEventListener(value)); @@ -324,7 +324,7 @@ void setJSXMLHttpRequestOnloadstart(ExecState* exec, JSObject* thisObject, JSVal { UNUSED_PARAM(exec); XMLHttpRequest* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnloadstart(globalObject->createJSAttributeEventListener(value)); @@ -334,7 +334,7 @@ void setJSXMLHttpRequestOnprogress(ExecState* exec, JSObject* thisObject, JSValu { UNUSED_PARAM(exec); XMLHttpRequest* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnprogress(globalObject->createJSAttributeEventListener(value)); @@ -344,7 +344,7 @@ void setJSXMLHttpRequestOnreadystatechange(ExecState* exec, JSObject* thisObject { UNUSED_PARAM(exec); XMLHttpRequest* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnreadystatechange(globalObject->createJSAttributeEventListener(value)); diff --git a/src/3rdparty/webkit/WebCore/generated/JSXMLHttpRequestException.cpp b/src/3rdparty/webkit/WebCore/generated/JSXMLHttpRequestException.cpp index 30e0d72..6de17c7 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSXMLHttpRequestException.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSXMLHttpRequestException.cpp @@ -153,7 +153,7 @@ JSXMLHttpRequestException::JSXMLHttpRequestException(NonNullPassRefPtrglobalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSXMLHttpRequestException::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSXMLHttpRequestUpload.cpp b/src/3rdparty/webkit/WebCore/generated/JSXMLHttpRequestUpload.cpp index bc5fff9..9ca7972 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSXMLHttpRequestUpload.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSXMLHttpRequestUpload.cpp @@ -158,7 +158,7 @@ JSXMLHttpRequestUpload::JSXMLHttpRequestUpload(NonNullPassRefPtr stru JSXMLHttpRequestUpload::~JSXMLHttpRequestUpload() { impl()->invalidateEventListeners(); - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSXMLHttpRequestUpload::createPrototype(ExecState* exec, JSGlobalObject* globalObject) @@ -250,7 +250,7 @@ void setJSXMLHttpRequestUploadOnabort(ExecState* exec, JSObject* thisObject, JSV { UNUSED_PARAM(exec); XMLHttpRequestUpload* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnabort(globalObject->createJSAttributeEventListener(value)); @@ -260,7 +260,7 @@ void setJSXMLHttpRequestUploadOnerror(ExecState* exec, JSObject* thisObject, JSV { UNUSED_PARAM(exec); XMLHttpRequestUpload* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnerror(globalObject->createJSAttributeEventListener(value)); @@ -270,7 +270,7 @@ void setJSXMLHttpRequestUploadOnload(ExecState* exec, JSObject* thisObject, JSVa { UNUSED_PARAM(exec); XMLHttpRequestUpload* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnload(globalObject->createJSAttributeEventListener(value)); @@ -280,7 +280,7 @@ void setJSXMLHttpRequestUploadOnloadstart(ExecState* exec, JSObject* thisObject, { UNUSED_PARAM(exec); XMLHttpRequestUpload* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnloadstart(globalObject->createJSAttributeEventListener(value)); @@ -290,7 +290,7 @@ void setJSXMLHttpRequestUploadOnprogress(ExecState* exec, JSObject* thisObject, { UNUSED_PARAM(exec); XMLHttpRequestUpload* imp = static_cast(static_cast(thisObject)->impl()); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext()); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnprogress(globalObject->createJSAttributeEventListener(value)); diff --git a/src/3rdparty/webkit/WebCore/generated/JSXMLSerializer.cpp b/src/3rdparty/webkit/WebCore/generated/JSXMLSerializer.cpp index e6cdd6b..2fd7e29 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSXMLSerializer.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSXMLSerializer.cpp @@ -147,7 +147,7 @@ JSXMLSerializer::JSXMLSerializer(NonNullPassRefPtr structure, JSDOMGl JSXMLSerializer::~JSXMLSerializer() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSXMLSerializer::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSXPathEvaluator.cpp b/src/3rdparty/webkit/WebCore/generated/JSXPathEvaluator.cpp index e25be26..aa8840a 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSXPathEvaluator.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSXPathEvaluator.cpp @@ -158,7 +158,7 @@ JSXPathEvaluator::JSXPathEvaluator(NonNullPassRefPtr structure, JSDOM JSXPathEvaluator::~JSXPathEvaluator() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSXPathEvaluator::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSXPathException.cpp b/src/3rdparty/webkit/WebCore/generated/JSXPathException.cpp index 3894ac2..fb6a00a 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSXPathException.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSXPathException.cpp @@ -148,7 +148,7 @@ JSXPathException::JSXPathException(NonNullPassRefPtr structure, JSDOM JSXPathException::~JSXPathException() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSXPathException::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSXPathExpression.cpp b/src/3rdparty/webkit/WebCore/generated/JSXPathExpression.cpp index 9464146..af059df 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSXPathExpression.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSXPathExpression.cpp @@ -141,7 +141,7 @@ JSXPathExpression::JSXPathExpression(NonNullPassRefPtr structure, JSD JSXPathExpression::~JSXPathExpression() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSXPathExpression::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSXPathNSResolver.cpp b/src/3rdparty/webkit/WebCore/generated/JSXPathNSResolver.cpp index c3bdef1..7ba29c0 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSXPathNSResolver.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSXPathNSResolver.cpp @@ -79,7 +79,7 @@ JSXPathNSResolver::JSXPathNSResolver(NonNullPassRefPtr structure, JSD JSXPathNSResolver::~JSXPathNSResolver() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSXPathNSResolver::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSXPathResult.cpp b/src/3rdparty/webkit/WebCore/generated/JSXPathResult.cpp index 337f473..d70ad29 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSXPathResult.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSXPathResult.cpp @@ -171,7 +171,7 @@ JSXPathResult::JSXPathResult(NonNullPassRefPtr structure, JSDOMGlobal JSXPathResult::~JSXPathResult() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSXPathResult::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/JSXSLTProcessor.cpp b/src/3rdparty/webkit/WebCore/generated/JSXSLTProcessor.cpp index 7dcd9c9..add8a84 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSXSLTProcessor.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSXSLTProcessor.cpp @@ -86,7 +86,7 @@ JSXSLTProcessor::JSXSLTProcessor(NonNullPassRefPtr structure, JSDOMGl JSXSLTProcessor::~JSXSLTProcessor() { - forgetDOMObject(*Heap::heap(this)->globalData(), impl()); + forgetDOMObject(this, impl()); } JSObject* JSXSLTProcessor::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/src/3rdparty/webkit/WebCore/generated/WebKitVersion.h b/src/3rdparty/webkit/WebCore/generated/WebKitVersion.h index 11e6af2..568670b 100644 --- a/src/3rdparty/webkit/WebCore/generated/WebKitVersion.h +++ b/src/3rdparty/webkit/WebCore/generated/WebKitVersion.h @@ -31,6 +31,6 @@ #define WebKitVersion_h #define WEBKIT_MAJOR_VERSION 532 -#define WEBKIT_MINOR_VERSION 3 +#define WEBKIT_MINOR_VERSION 4 #endif //WebKitVersion_h diff --git a/src/3rdparty/webkit/WebCore/history/qt/HistoryItemQt.cpp b/src/3rdparty/webkit/WebCore/history/qt/HistoryItemQt.cpp index 098a786..c5fb069 100644 --- a/src/3rdparty/webkit/WebCore/history/qt/HistoryItemQt.cpp +++ b/src/3rdparty/webkit/WebCore/history/qt/HistoryItemQt.cpp @@ -23,10 +23,13 @@ #include "CString.h" #include "FormData.h" -bool WebCore::HistoryItem::restoreState(QDataStream& in, int /*version*/) +bool WebCore::HistoryItem::restoreState(QDataStream& in, int version) { - // there is no different version right now - // switch (version) { + // we only support version 1 for now + + if (version != 1) + return false; + WebCore::String url; WebCore::String title; WebCore::String altTitle; @@ -87,10 +90,12 @@ bool WebCore::HistoryItem::restoreState(QDataStream& in, int /*version*/) return in.status() == QDataStream::Ok; } -QDataStream& WebCore::HistoryItem::saveState(QDataStream& out, int /*version*/) const +QDataStream& WebCore::HistoryItem::saveState(QDataStream& out, int version) const { - // there is no different version right now - // switch (version) { + // we only support version 1 for now. + if (version != 1) + return out; + out << urlString() << title() << alternateTitle() << lastVisitedTime(); out << originalURLString() << referrer() << target() << parent(); out << lastVisitWasHTTPNonGet() << lastVisitWasFailure() << isTargetItem(); diff --git a/src/3rdparty/webkit/WebCore/html/HTMLAllCollection.cpp b/src/3rdparty/webkit/WebCore/html/HTMLAllCollection.cpp new file mode 100644 index 0000000..dbfed28 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/html/HTMLAllCollection.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "HTMLAllCollection.h" + +#include "Node.h" + +namespace WebCore { + +PassRefPtr HTMLAllCollection::create(PassRefPtr base) +{ + return adoptRef(new HTMLAllCollection(base)); +} + +HTMLAllCollection::HTMLAllCollection(PassRefPtr base) + : HTMLCollection(base, DocAll) +{ +} + +HTMLAllCollection::~HTMLAllCollection() +{ +} + +} // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/html/HTMLAllCollection.h b/src/3rdparty/webkit/WebCore/html/HTMLAllCollection.h new file mode 100644 index 0000000..1dd3ede --- /dev/null +++ b/src/3rdparty/webkit/WebCore/html/HTMLAllCollection.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef HTMLAllCollection_h +#define HTMLAllCollection_h + +#include "HTMLCollection.h" + +namespace WebCore { + +class HTMLAllCollection : public HTMLCollection { +public: + static PassRefPtr create(PassRefPtr); + virtual ~HTMLAllCollection(); + +private: + HTMLAllCollection(PassRefPtr); +}; + +} // namespace WebCore + +#endif // HTMLAllCollection_h diff --git a/src/3rdparty/webkit/WebCore/html/HTMLAllCollection.idl b/src/3rdparty/webkit/WebCore/html/HTMLAllCollection.idl new file mode 100644 index 0000000..d36f41e --- /dev/null +++ b/src/3rdparty/webkit/WebCore/html/HTMLAllCollection.idl @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +module html { + + interface [ + GenerateConstructor, + HasIndexGetter, + HasNameGetter, + CustomCall, + MasqueradesAsUndefined + ] HTMLAllCollection { + readonly attribute unsigned long length; + [Custom] Node item(in unsigned long index); + [Custom] Node namedItem(in DOMString name); + + // FIXME: This should return an HTMLAllCollection. + NodeList tags(in DOMString name); + }; + +} diff --git a/src/3rdparty/webkit/WebCore/html/HTMLCanvasElement.cpp b/src/3rdparty/webkit/WebCore/html/HTMLCanvasElement.cpp index 335b20f..7bae6e3 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLCanvasElement.cpp +++ b/src/3rdparty/webkit/WebCore/html/HTMLCanvasElement.cpp @@ -172,10 +172,11 @@ CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type) if (m_context && !m_context->is3d()) return 0; if (!m_context) { - m_context = new CanvasRenderingContext3D(this); - - // Need to make sure a RenderLayer and compositing layer get created for the Canvas - setNeedsStyleRecalc(SyntheticStyleChange); + m_context = CanvasRenderingContext3D::create(this); + if (m_context) { + // Need to make sure a RenderLayer and compositing layer get created for the Canvas + setNeedsStyleRecalc(SyntheticStyleChange); + } } return m_context.get(); } diff --git a/src/3rdparty/webkit/WebCore/html/HTMLCollection.h b/src/3rdparty/webkit/WebCore/html/HTMLCollection.h index b04bcbc..eea1777 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLCollection.h +++ b/src/3rdparty/webkit/WebCore/html/HTMLCollection.h @@ -64,6 +64,7 @@ public: protected: HTMLCollection(PassRefPtr base, CollectionType, CollectionCache*); + HTMLCollection(PassRefPtr base, CollectionType); CollectionCache* info() const { return m_info; } void resetCollectionInfo() const; @@ -71,8 +72,6 @@ protected: mutable bool m_idsDone; // for nextNamedItem() private: - HTMLCollection(PassRefPtr base, CollectionType); - virtual Element* itemAfter(Element*) const; virtual unsigned calcLength() const; virtual void updateNameCache() const; diff --git a/src/3rdparty/webkit/WebCore/html/HTMLCollection.idl b/src/3rdparty/webkit/WebCore/html/HTMLCollection.idl index 1ba5ec7..45d1127 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLCollection.idl +++ b/src/3rdparty/webkit/WebCore/html/HTMLCollection.idl @@ -34,8 +34,9 @@ module html { [Custom] Node item(in unsigned long index); [Custom] Node namedItem(in DOMString name); - // Extensions +#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C NodeList tags(in DOMString name); +#endif }; } diff --git a/src/3rdparty/webkit/WebCore/html/HTMLDocument.idl b/src/3rdparty/webkit/WebCore/html/HTMLDocument.idl index 3dd7a07..d250741 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLDocument.idl +++ b/src/3rdparty/webkit/WebCore/html/HTMLDocument.idl @@ -39,7 +39,7 @@ module html { #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT // FIXME: This should eventually be available (if they are wanted) for all languages. - attribute [Custom, Deletable] HTMLCollection all; + attribute [Custom, Deletable] HTMLAllCollection all; #endif void clear(); diff --git a/src/3rdparty/webkit/WebCore/html/HTMLInputElement.cpp b/src/3rdparty/webkit/WebCore/html/HTMLInputElement.cpp index ed3405a..f25c908 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLInputElement.cpp +++ b/src/3rdparty/webkit/WebCore/html/HTMLInputElement.cpp @@ -1549,9 +1549,16 @@ void HTMLInputElement::defaultEventHandler(Event* evt) if (r && r->isTextField()) toRenderTextControl(r)->setEdited(false); } - // Form may never have been present, or may have been destroyed by the change event. - if (form()) - form()->submitClick(evt); + + RefPtr formForSubmission = form(); + // If there is no form and the element is an , then create a temporary form just to be used for submission. + if (!formForSubmission && inputType() == ISINDEX) + formForSubmission = createTemporaryFormForIsIndex(); + + // Form may never have been present, or may have been destroyed by code responding to the change event. + if (formForSubmission) + formForSubmission->submitClick(evt); + evt->setDefaultHandled(); return; } @@ -1569,6 +1576,19 @@ void HTMLInputElement::defaultEventHandler(Event* evt) HTMLFormControlElementWithState::defaultEventHandler(evt); } +PassRefPtr HTMLInputElement::createTemporaryFormForIsIndex() +{ + RefPtr form = new HTMLFormElement(formTag, document()); + form->registerFormElement(this); + form->setMethod("GET"); + if (!document()->baseURL().isEmpty()) { + // We treat the href property of the element as the form action, as per section 7.5 + // "Queries and Indexes" of the HTML 2.0 spec. . + form->setAction(document()->baseURL().string()); + } + return form.release(); +} + bool HTMLInputElement::isURLAttribute(Attribute *attr) const { return (attr->name() == srcAttr); diff --git a/src/3rdparty/webkit/WebCore/html/HTMLInputElement.h b/src/3rdparty/webkit/WebCore/html/HTMLInputElement.h index 799d92c..0e2da32 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLInputElement.h +++ b/src/3rdparty/webkit/WebCore/html/HTMLInputElement.h @@ -256,6 +256,8 @@ private: virtual bool isOptionalFormControl() const { return !isRequiredFormControl(); } virtual bool isRequiredFormControl() const; + PassRefPtr createTemporaryFormForIsIndex(); + #if ENABLE(DATALIST) HTMLDataListElement* dataList() const; #endif diff --git a/src/3rdparty/webkit/WebCore/html/HTMLMediaElement.cpp b/src/3rdparty/webkit/WebCore/html/HTMLMediaElement.cpp index 11ca3ba..729aceb 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLMediaElement.cpp +++ b/src/3rdparty/webkit/WebCore/html/HTMLMediaElement.cpp @@ -247,16 +247,12 @@ void HTMLMediaElement::insertedIntoDocument() scheduleLoad(); } -void HTMLMediaElement::willRemove() -{ - if (m_isFullscreen) - exitFullscreen(); - HTMLElement::willRemove(); -} void HTMLMediaElement::removedFromDocument() { if (m_networkState > NETWORK_EMPTY) pause(); + if (m_isFullscreen) + exitFullscreen(); HTMLElement::removedFromDocument(); } @@ -1678,6 +1674,9 @@ void HTMLMediaElement::userCancelledLoad() void HTMLMediaElement::documentWillBecomeInactive() { + if (m_isFullscreen) + exitFullscreen(); + m_inActiveDocument = false; userCancelledLoad(); diff --git a/src/3rdparty/webkit/WebCore/html/HTMLMediaElement.h b/src/3rdparty/webkit/WebCore/html/HTMLMediaElement.h index 0005e07..405f013 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLMediaElement.h +++ b/src/3rdparty/webkit/WebCore/html/HTMLMediaElement.h @@ -57,7 +57,6 @@ public: virtual bool rendererIsNeeded(RenderStyle*); virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); virtual void insertedIntoDocument(); - virtual void willRemove(); virtual void removedFromDocument(); virtual void attach(); virtual void recalcStyle(StyleChange); diff --git a/src/3rdparty/webkit/WebCore/html/HTMLOptionsCollection.idl b/src/3rdparty/webkit/WebCore/html/HTMLOptionsCollection.idl index 5f85fcb..a7e191a 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLOptionsCollection.idl +++ b/src/3rdparty/webkit/WebCore/html/HTMLOptionsCollection.idl @@ -21,7 +21,6 @@ module html { // FIXME: The W3C spec says that HTMLOptionsCollection should not have a parent class. - interface [ GenerateNativeConverter, HasCustomIndexSetter, @@ -36,9 +35,9 @@ module html { raises (DOMException); [Custom] void remove(in unsigned long index); -#if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT - Node item(in unsigned long index); - Node namedItem(in DOMString name); +#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C + Node item(in unsigned long index); + Node namedItem(in DOMString name); #endif }; diff --git a/src/3rdparty/webkit/WebCore/html/HTMLTokenizer.cpp b/src/3rdparty/webkit/WebCore/html/HTMLTokenizer.cpp index 33af997..91285d9 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLTokenizer.cpp +++ b/src/3rdparty/webkit/WebCore/html/HTMLTokenizer.cpp @@ -416,13 +416,13 @@ HTMLTokenizer::State HTMLTokenizer::parseNonHTMLText(SegmentedString& src, State return state; } - + HTMLTokenizer::State HTMLTokenizer::scriptHandler(State state) { // We are inside a + @@ -44,6 +45,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + @@ -69,7 +72,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - @@ -94,6 +96,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + @@ -110,7 +113,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
+
diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.js b/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.js index 17b02a1..c24d589 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.js @@ -143,8 +143,11 @@ var WebInspector = { this.panels.profiles = new WebInspector.ProfilesPanel(); this.panels.profiles.registerProfileType(new WebInspector.CPUProfileType()); } + if (hiddenPanels.indexOf("timeline") === -1 && hiddenPanels.indexOf("timeline") === -1) + this.panels.timeline = new WebInspector.TimelinePanel(); + if (hiddenPanels.indexOf("storage") === -1 && hiddenPanels.indexOf("databases") === -1) - this.panels.storage = new WebInspector.StoragePanel(); + this.panels.storage = new WebInspector.StoragePanel(); }, _loadPreferences: function() @@ -369,6 +372,7 @@ WebInspector.loaded = function() document.body.addStyleClass("platform-" + platform); this._loadPreferences(); + this.pendingDispatches = 0; this.drawer = new WebInspector.Drawer(); this.console = new WebInspector.ConsoleView(this.drawer); @@ -379,13 +383,13 @@ WebInspector.loaded = function() this.domAgent = new WebInspector.DOMAgent(); this.resourceCategories = { - documents: new WebInspector.ResourceCategory(WebInspector.UIString("Documents"), "documents"), - stylesheets: new WebInspector.ResourceCategory(WebInspector.UIString("Stylesheets"), "stylesheets"), - images: new WebInspector.ResourceCategory(WebInspector.UIString("Images"), "images"), - scripts: new WebInspector.ResourceCategory(WebInspector.UIString("Scripts"), "scripts"), - xhr: new WebInspector.ResourceCategory(WebInspector.UIString("XHR"), "xhr"), - fonts: new WebInspector.ResourceCategory(WebInspector.UIString("Fonts"), "fonts"), - other: new WebInspector.ResourceCategory(WebInspector.UIString("Other"), "other") + documents: new WebInspector.ResourceCategory("documents", WebInspector.UIString("Documents"), "rgb(47,102,236)"), + stylesheets: new WebInspector.ResourceCategory("stylesheets", WebInspector.UIString("Stylesheets"), "rgb(157,231,119)"), + images: new WebInspector.ResourceCategory("images", WebInspector.UIString("Images"), "rgb(164,60,255)"), + scripts: new WebInspector.ResourceCategory("scripts", WebInspector.UIString("Scripts"), "rgb(255,121,0)"), + xhr: new WebInspector.ResourceCategory("xhr", WebInspector.UIString("XHR"), "rgb(231,231,10)"), + fonts: new WebInspector.ResourceCategory("fonts", WebInspector.UIString("Fonts"), "rgb(255,82,62)"), + other: new WebInspector.ResourceCategory("other", WebInspector.UIString("Other"), "rgb(186,186,186)") }; this.panels = {}; @@ -456,8 +460,6 @@ WebInspector.loaded = function() // this._updateErrorAndWarningCounts(); var searchField = document.getElementById("search"); - searchField.addEventListener("keydown", this.searchKeyDown.bind(this), false); - searchField.addEventListener("keyup", this.searchKeyUp.bind(this), false); searchField.addEventListener("search", this.performSearch.bind(this), false); // when the search is emptied toolbarElement.addEventListener("mousedown", this.toolbarDragStart, true); @@ -494,7 +496,9 @@ WebInspector.dispatch = function() { function delayDispatch() { WebInspector[methodName].apply(WebInspector, parameters); + WebInspector.pendingDispatches--; } + WebInspector.pendingDispatches++; setTimeout(delayDispatch, 0); } @@ -511,13 +515,19 @@ WebInspector.windowResize = function(event) WebInspector.windowFocused = function(event) { - if (event.target.nodeType === Node.DOCUMENT_NODE) + // Fires after blur, so when focusing on either the main inspector + // or an