From 0d231c32cc7670d356d486b13648cb5bd471ffef Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Mon, 12 Oct 2009 13:44:14 +0200 Subject: Fix a crash in cocoa when a QMessageBox is destroyed from dropEvent() The gobal variable which stores the current mouse event can be updated before dragImage() call(blocking) is finished. So make a local copy of the information required by the QDragManager::drag(). Task-number: QTBUG-4814 Reviewed-by: MortenS --- src/gui/kernel/qcocoaview_mac.mm | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 9eca29d..286eb31 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -1277,29 +1277,29 @@ Qt::DropAction QDragManager::drag(QDrag *o) // convert the image to NSImage. NSImage *image = (NSImage *)qt_mac_create_nsimage(pix); [image retain]; - DnDParams *dndParams = [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]; + DnDParams dndParams = *[QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]; // save supported actions - [dndParams->view setSupportedActions: qt_mac_mapDropActions(dragPrivate()->possible_actions)]; - NSPoint imageLoc = {dndParams->localPoint.x - hotspot.x(), - dndParams->localPoint.y + pix.height() - hotspot.y()}; + [dndParams.view setSupportedActions: qt_mac_mapDropActions(dragPrivate()->possible_actions)]; + NSPoint imageLoc = {dndParams.localPoint.x - hotspot.x(), + dndParams.localPoint.y + pix.height() - hotspot.y()}; NSSize mouseOffset = {0.0, 0.0}; NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; - NSPoint windowPoint = [dndParams->theEvent locationInWindow]; + NSPoint windowPoint = [dndParams.theEvent locationInWindow]; dragPrivate()->executed_action = Qt::ActionMask; // do the drag - [dndParams->view retain]; - [dndParams->view dragImage:image + [dndParams.view retain]; + [dndParams.view dragImage:image at:imageLoc offset:mouseOffset - event:dndParams->theEvent + event:dndParams.theEvent pasteboard:pboard - source:dndParams->view + source:dndParams.view slideBack:YES]; - [dndParams->view release]; + [dndParams.view release]; [image release]; dragPrivate()->executed_action = Qt::IgnoreAction; object = 0; - Qt::DropAction performedAction(qt_mac_mapNSDragOperation(dndParams->performedAction)); + Qt::DropAction performedAction(qt_mac_mapNSDragOperation(dndParams.performedAction)); // do post drag processing, if required. if(performedAction != Qt::IgnoreAction) { // check if the receiver points us to a file location. -- cgit v0.12 From 0baa15e68c7b2e009c1f81f81148939725c216c8 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 13 Oct 2009 10:08:27 +0200 Subject: Fix regression while updating items in itemview. geometry() is in parent coordinate. We want the coordinate in viewport coordinate. There is an offset (the header geometry) between the two. So the first item was not refreshed. (Regression because of e5b32fbe0efc8 and a54c18e27bbb) Reviewed-by: Gabriel Reviewed-by: Alexis Task-number: QTBUG-4849 --- src/gui/itemviews/qabstractitemview.cpp | 2 +- tests/auto/qtreewidget/tst_qtreewidget.cpp | 39 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 6722e3a..a8c7f8b 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -2913,7 +2913,7 @@ void QAbstractItemView::update(const QModelIndex &index) //this test is important for peformance reason //For example in dataChanged we simply update all the cells without checking //it can be a major bottleneck to update rects that aren't even part of the viewport - if (d->viewport->geometry().intersects(rect)) + if (d->viewport->rect().intersects(rect)) d->viewport->update(rect); } } diff --git a/tests/auto/qtreewidget/tst_qtreewidget.cpp b/tests/auto/qtreewidget/tst_qtreewidget.cpp index d4fd1e3..3fcbdd6 100644 --- a/tests/auto/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/qtreewidget/tst_qtreewidget.cpp @@ -49,6 +49,9 @@ #include #include #include +#include + +#include "../../shared/util.h" //TESTED_CLASS= @@ -160,6 +163,7 @@ private slots: void task217309(); void setCurrentItemExpandsParent(); void task239150_editorWidth(); + void setTextUpdate(); public slots: void itemSelectionChanged(); @@ -3023,6 +3027,41 @@ void tst_QTreeWidget::task239150_editorWidth() +void tst_QTreeWidget::setTextUpdate() +{ + QTreeWidget treeWidget; + treeWidget.setColumnCount(2); + + class MyItemDelegate : public QStyledItemDelegate + { + public: + MyItemDelegate() : numPaints(0) { } + void paint(QPainter *painter, + const QStyleOptionViewItem &option, const QModelIndex &index) const + { + numPaints++; + QStyledItemDelegate::paint(painter, option, index); + } + + mutable int numPaints; + } delegate; + + treeWidget.setItemDelegate(&delegate); + treeWidget.show(); + QStringList strList; + strList << "variable1" << "0"; + QTreeWidgetItem *item = new QTreeWidgetItem(strList); + treeWidget.insertTopLevelItem(0, item); + QTest::qWait(50); + QTRY_VERIFY(delegate.numPaints > 0); + delegate.numPaints = 0; + + item->setText(1, "42"); + QApplication::processEvents(); + QTRY_VERIFY(delegate.numPaints > 0); +} + + QTEST_MAIN(tst_QTreeWidget) #include "tst_qtreewidget.moc" -- cgit v0.12 From 252fa3d8fa159791a0762a3e02c1594a34a104af Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Wed, 14 Oct 2009 10:39:05 +0200 Subject: QNAM HTTP Code: Backport a fix related to aborting replies Backport af71faf8cb2c9cbf34c408b81ce7ae1ef6c6403e from 4.6 to 4.5. Task-number: 261999 Reviewed-by: Peter Hartmann --- src/network/access/qhttpnetworkconnection.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index aef1258..d747345 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -954,7 +954,10 @@ void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply) for (int i = 0; i < channelCount; ++i) { if (channels[i].reply == reply) { channels[i].reply = 0; - if (reply->d_func()->connectionCloseEnabled()) + // if HTTP mandates we should close + // or the reply is not finished yet, e.g. it was aborted + // we have to close that connection + if (reply->d_func()->connectionCloseEnabled() || !reply->isFinished()) closeChannel(i); QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); return; -- cgit v0.12 From 93eb7c1378d97978fbe415f532e341de0138f4fe Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 15 Oct 2009 10:44:27 +1000 Subject: Back-port several OpenGL/ES fixes from 4.6 to 4.5 8ee6d090d45198fb2530849236c97f014666b7e4: fix EGL_SAMPLES b125af1b298d694c332f56deebe4755d0c985d5d: memory leak of EGLSurface's ef8d9fa7091b0d45fe15aae43b8f1c47547cb16d: double-destroy of pbuffer 73d9dced8298dfad7bc72607146e81e96fffb6d4: suppress pbuffer warnings Reviewed-by: Donald Carr --- src/opengl/qgl_egl.cpp | 2 +- src/opengl/qgl_qws.cpp | 2 ++ src/opengl/qglpixelbuffer_egl.cpp | 15 +++++++++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp index 7e91c35..348a677 100644 --- a/src/opengl/qgl_egl.cpp +++ b/src/opengl/qgl_egl.cpp @@ -74,7 +74,7 @@ void qt_egl_set_format(QEglProperties& props, int deviceType, const QGLFormat& f props.setValue(EGL_STENCIL_SIZE, f.stencilBufferSize() == -1 ? 1 : f.stencilBufferSize()); if (f.sampleBuffers()) { props.setValue(EGL_SAMPLE_BUFFERS, 1); - props.setValue(EGL_SAMPLES, f.samples()); + props.setValue(EGL_SAMPLES, f.samples() == -1 ? 1 : f.samples()); } else { props.setValue(EGL_SAMPLE_BUFFERS, 0); } diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp index b842426..4058b66 100644 --- a/src/opengl/qgl_qws.cpp +++ b/src/opengl/qgl_qws.cpp @@ -187,6 +187,8 @@ void QGLContext::reset() d->cleanup(); doneCurrent(); if (d->eglContext) { + if (d->eglContext->surface() != EGL_NO_SURFACE) + eglDestroySurface(d->eglContext->display(), d->eglContext->surface()); delete d->eglContext; d->eglContext = 0; } diff --git a/src/opengl/qglpixelbuffer_egl.cpp b/src/opengl/qglpixelbuffer_egl.cpp index b2f16c1..fbe6c36 100644 --- a/src/opengl/qglpixelbuffer_egl.cpp +++ b/src/opengl/qglpixelbuffer_egl.cpp @@ -152,7 +152,7 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge bool QGLPixelBufferPrivate::cleanup() { - eglDestroySurface(QEglContext::defaultDisplay(0), pbuf); + // No need to destroy "pbuf" here - it is done in QGLContext::reset(). return true; } @@ -203,13 +203,20 @@ GLuint QGLPixelBuffer::generateDynamicTexture() const bool QGLPixelBuffer::hasOpenGLPbuffers() { // See if we have at least 1 configuration that matches the default format. - QEglContext ctx; - if (!ctx.openDisplay(0)) + EGLDisplay dpy = QEglContext::defaultDisplay(0); + if (dpy == EGL_NO_DISPLAY) return false; QEglProperties configProps; qt_egl_set_format(configProps, QInternal::Pbuffer, QGLFormat::defaultFormat()); configProps.setRenderableType(QEglContext::OpenGL); - return ctx.chooseConfig(configProps, QEglContext::BestPixelFormat); + do { + EGLConfig cfg = 0; + EGLint matching = 0; + if (eglChooseConfig(dpy, configProps.properties(), + &cfg, 1, &matching) && matching > 0) + return true; + } while (configProps.reduceConfiguration()); + return false; } QT_END_NAMESPACE -- cgit v0.12 From 4f2fecbdb852028bd191fa63aa66527107672dc7 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 15 Oct 2009 10:50:57 +1000 Subject: Remove the surface holder from the PowerVR screen driver The PvrEglSurfaceHolder is a hold-over from Qtopia that isn't needed any more and was never very stable anyway. Reviewed-by: trustme Back port of f613b0170d0fe806378779472315d0bbdc1aada9 --- .../powervr/pvreglscreen/pvreglscreen.cpp | 128 ++------------------- .../gfxdrivers/powervr/pvreglscreen/pvreglscreen.h | 19 --- .../powervr/pvreglscreen/pvreglwindowsurface.cpp | 8 +- .../powervr/pvreglscreen/pvreglwindowsurface.h | 4 +- 4 files changed, 11 insertions(+), 148 deletions(-) diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp index cb453d7..6696672 100644 --- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp +++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp @@ -60,17 +60,20 @@ PvrEglScreen::PvrEglScreen(int displayId) ttyfd = -1; doGraphicsMode = true; oldKdMode = KD_TEXT; - if (QWSServer::instance()) - holder = new PvrEglSurfaceHolder(); - else - holder = 0; + + // Make sure that the EGL layer is initialized and the drivers loaded. + EGLDisplay dpy = eglGetDisplay((EGLNativeDisplayType)EGL_DEFAULT_DISPLAY); + if (!eglInitialize(dpy, 0, 0)) + qWarning("Could not initialize EGL display - are the drivers loaded?"); + + // Make sure that screen 0 is initialized. + pvrQwsScreenWindow(0); } PvrEglScreen::~PvrEglScreen() { if (fd >= 0) ::close(fd); - delete holder; } bool PvrEglScreen::initDevice() @@ -194,7 +197,7 @@ QWSWindowSurface* PvrEglScreen::createSurface(QWidget *widget) const QWSWindowSurface* PvrEglScreen::createSurface(const QString &key) const { if (key == QLatin1String("PvrEgl")) - return new PvrEglWindowSurface(holder); + return new PvrEglWindowSurface(); return QScreen::createSurface(key); } @@ -275,116 +278,3 @@ bool PvrEglScreenSurfaceFunctions::createNativeWindow(QWidget *widget, EGLNative *native = (EGLNativeWindowType)(nsurface->nativeDrawable()); return true; } - -// The PowerVR engine on the device needs to allocate about 2Mb of -// contiguous physical memory to manage drawing into a surface. -// -// The problem is that once Qtopia begins its startup sequence, -// it allocates enough memory to severely fragment the physical -// address space on the device. This leaves the PowerVR engine -// unable to allocate the necessary contiguous physical memory -// when an EGL surface is created. -// -// A solution to this is to pre-allocate a dummy surface early -// in the startup sequence before memory becomes fragmented, -// reserving it for any future EGL applications to use. -// -// However, the PowerVR engine has problems managing multiple -// surfaces concurrently, and so real EGL applications end up -// with unacceptably slow frame rates unless the dummy surface -// is destroyed while the real EGL applications are running. -// -// In summary, we need to try to ensure that there is always at -// least one EGL surface active at any given time to reserve the -// memory but destroy the temporary surface when a real surface -// is using the device. That is the purpose of PvrEglSurfaceHolder. - -PvrEglSurfaceHolder::PvrEglSurfaceHolder(QObject *parent) - : QObject(parent) -{ - numRealSurfaces = 0; - - PvrQwsRect rect; - rect.x = 0; - rect.y = 0; - rect.width = 16; - rect.height = 16; - tempSurface = pvrQwsCreateWindow(0, -1, &rect); - - dpy = EGL_NO_DISPLAY; - config = 0; - surface = EGL_NO_SURFACE; - - dpy = eglGetDisplay((EGLNativeDisplayType)EGL_DEFAULT_DISPLAY); - if (!eglInitialize(dpy, 0, 0)) { - qWarning("Could not initialize EGL display - are the drivers loaded?"); - dpy = EGL_NO_DISPLAY; - return; - } - - EGLint attribList[16]; - int temp = 0; - attribList[temp++] = EGL_LEVEL; // Framebuffer level 0 - attribList[temp++] = 0; - attribList[temp++] = EGL_SURFACE_TYPE; - attribList[temp++] = EGL_WINDOW_BIT; - attribList[temp++] = EGL_NONE; - - EGLint numConfigs = 0; - if (!eglChooseConfig(dpy, attribList, &config, 1, &numConfigs) || numConfigs != 1) { - qWarning("Could not find a matching a EGL configuration"); - eglTerminate(dpy); - dpy = EGL_NO_DISPLAY; - return; - } - - surface = eglCreateWindowSurface - (dpy, config, (EGLNativeWindowType)(-1), NULL); - if (surface == EGL_NO_SURFACE) - qWarning("Could not create the temporary EGL surface"); -} - -PvrEglSurfaceHolder::~PvrEglSurfaceHolder() -{ - if (surface != EGL_NO_SURFACE) - eglDestroySurface(dpy, surface); - if (dpy != EGL_NO_DISPLAY) - eglTerminate(dpy); - if (tempSurface) - pvrQwsDestroyDrawable(tempSurface); -} - -// Add a real EGL surface to the system. -void PvrEglSurfaceHolder::addSurface() -{ - ++numRealSurfaces; - if (numRealSurfaces == 1) { - // Destroy the temporary surface while some other application - // is making use of the EGL sub-system for 3D rendering. - if (surface != EGL_NO_SURFACE) { - eglDestroySurface(dpy, surface); - surface = EGL_NO_SURFACE; - } - } -} - -// Remove an actual EGL surface from the system. -void PvrEglSurfaceHolder::removeSurface() -{ - if (numRealSurfaces > 0) { - --numRealSurfaces; - if (numRealSurfaces == 0) { - // The last real EGL surface has been destroyed, so re-create - // the temporary surface. There is a race condition here in - // that Qtopia could allocate a lot of memory just after - // the real EGL surface is destroyed but before we could - // create the temporary surface again. - if (surface == EGL_NO_SURFACE && dpy != EGL_NO_DISPLAY) { - surface = eglCreateWindowSurface - (dpy, config, (EGLNativeWindowType)(-1), NULL); - if (surface == EGL_NO_SURFACE) - qWarning("Could not re-create the temporary EGL surface"); - } - } - } -} diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h index 1c79f8e..8bf42c7 100644 --- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h +++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h @@ -59,24 +59,6 @@ private: int displayId; }; -class PvrEglSurfaceHolder : public QObject -{ - Q_OBJECT -public: - PvrEglSurfaceHolder(QObject *parent=0); - ~PvrEglSurfaceHolder(); - - void addSurface(); - void removeSurface(); - -private: - int numRealSurfaces; - PvrQwsDrawable *tempSurface; - EGLDisplay dpy; - EGLConfig config; - EGLSurface surface; -}; - class PvrEglScreen : public QGLScreen { public: @@ -105,7 +87,6 @@ private: int fd; int ttyfd, oldKdMode; - PvrEglSurfaceHolder *holder; QString ttyDevice; bool doGraphicsMode; }; diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp index 09c0ace..2c5ac21 100644 --- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp +++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp @@ -53,7 +53,6 @@ PvrEglWindowSurface::PvrEglWindowSurface this->widget = widget; this->screen = screen; - this->holder = 0; this->pdevice = 0; QPoint pos = offset(widget); @@ -78,7 +77,7 @@ PvrEglWindowSurface::PvrEglWindowSurface drawable = pvrQwsCreateWindow(screenNum, (long)widget, &pvrRect); } -PvrEglWindowSurface::PvrEglWindowSurface(PvrEglSurfaceHolder *holder) +PvrEglWindowSurface::PvrEglWindowSurface() : QWSGLWindowSurface() { setSurfaceFlags(QWSWindowSurface::Opaque); @@ -86,9 +85,6 @@ PvrEglWindowSurface::PvrEglWindowSurface(PvrEglSurfaceHolder *holder) widget = 0; screen = 0; pdevice = 0; - - this->holder = holder; - holder->addSurface(); } PvrEglWindowSurface::~PvrEglWindowSurface() @@ -100,8 +96,6 @@ PvrEglWindowSurface::~PvrEglWindowSurface() if (drawable && pvrQwsReleaseWindow(drawable)) pvrQwsDestroyDrawable(drawable); - if (holder) - holder->removeSurface(); delete pdevice; } diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h index 0da3653..58a5fb2 100644 --- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h +++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h @@ -46,13 +46,12 @@ #include "pvrqwsdrawable.h" class QScreen; -class PvrEglSurfaceHolder; class PvrEglWindowSurface : public QWSGLWindowSurface { public: PvrEglWindowSurface(QWidget *widget, QScreen *screen, int screenNum); - PvrEglWindowSurface(PvrEglSurfaceHolder *holder); + PvrEglWindowSurface(); ~PvrEglWindowSurface(); QString key() const { return QLatin1String("PvrEgl"); } @@ -78,7 +77,6 @@ private: QWidget *widget; PvrQwsDrawable *drawable; QScreen *screen; - PvrEglSurfaceHolder *holder; QPaintDevice *pdevice; }; -- cgit v0.12 From 2eb373a68367a6511e12d60034e920345431bcc8 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 15 Oct 2009 14:47:35 +0200 Subject: Some sub menus are disabled in Cocoa The commit faec535829a0e454a6784b0c5c37cb63e7da8f73 introduced this bug. Since we can add a submenu to the same supermenu, we should consider it before disabling the submenu who already have a supermenu. Reviewed-by: MortenS --- src/gui/widgets/qmenu_mac.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 354161d..c3b954f 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -1413,7 +1413,7 @@ QMenuPrivate::QMacMenuPrivate::syncAction(QMacMenuAction *action) SetMenuItemProperty(data.submenuHandle, 0, kMenuCreatorQt, kMenuPropertyCausedQWidget, sizeof(caused), &caused); #else NSMenu *subMenu = static_cast(action->action->menu()->macMenu()); - if ([subMenu supermenu] != nil) { + if ([subMenu supermenu] && [subMenu supermenu] != [item menu]) { // The menu is already a sub-menu of another one. Cocoa will throw an exception, // in such cases. For the time being, a new QMenu with same set of actions is the // only workaround. @@ -1686,7 +1686,7 @@ QMenuBarPrivate::QMacMenuBarPrivate::syncAction(QMacMenuAction *action) GetMenuItemProperty(action->menu, 0, kMenuCreatorQt, kMenuPropertyQWidget, sizeof(caused), 0, &caused); SetMenuItemProperty(submenu, 0, kMenuCreatorQt, kMenuPropertyCausedQWidget, sizeof(caused), &caused); #else - if ([submenu supermenu] != nil) + if ([submenu supermenu] && [submenu supermenu] != [item menu]) return; else [item setSubmenu:submenu]; -- cgit v0.12