src/gui/kernel/qwidget.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
--- a/src/gui/kernel/qwidget.cpp	Fri Sep 17 08:34:18 2010 +0300
+++ b/src/gui/kernel/qwidget.cpp	Mon Oct 04 01:19:32 2010 +0300
@@ -162,41 +162,74 @@
 extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp
 extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp
 
-QRefCountedWidgetBackingStore::QRefCountedWidgetBackingStore()
+/*!
+    \internal
+    \class QWidgetBackingStoreTracker
+    \brief Class which allows tracking of which widgets are using a given backing store
+
+    QWidgetBackingStoreTracker is a thin wrapper around a QWidgetBackingStore pointer,
+    which maintains a list of the QWidgets which are currently using the backing
+    store.  This list is modified via the registerWidget and unregisterWidget functions.
+ */
+
+QWidgetBackingStoreTracker::QWidgetBackingStoreTracker()
     :   m_ptr(0)
 {
 
 }
 
-QRefCountedWidgetBackingStore::~QRefCountedWidgetBackingStore()
+QWidgetBackingStoreTracker::~QWidgetBackingStoreTracker()
 {
     delete m_ptr;
 }
 
-void QRefCountedWidgetBackingStore::create(QWidget *widget)
+/*!
+    \internal
+    Destroy the contained QWidgetBackingStore, if not null, and clear the list of
+    widgets using the backing store, then create a new QWidgetBackingStore, providing
+    the QWidget.
+ */
+void QWidgetBackingStoreTracker::create(QWidget *widget)
 {
     destroy();
     m_ptr = new QWidgetBackingStore(widget);
 }
 
-void QRefCountedWidgetBackingStore::destroy()
+/*!
+    \internal
+    Destroy the contained QWidgetBackingStore, if not null, and clear the list of
+    widgets using the backing store.
+ */
+void QWidgetBackingStoreTracker::destroy()
 {
     delete m_ptr;
     m_ptr = 0;
-    m_visibleWidgets.clear();
-}
-
-void QRefCountedWidgetBackingStore::widgetShown(QWidget *w)
+    m_widgets.clear();
+}
+
+/*!
+    \internal
+    Add the widget to the list of widgets currently using the backing store.
+    If the widget was already in the list, this function is a no-op.
+ */
+void QWidgetBackingStoreTracker::registerWidget(QWidget *w)
 {
     Q_ASSERT(m_ptr);
     Q_ASSERT(w->internalWinId());
     Q_ASSERT(qt_widget_private(w)->maybeBackingStore() == m_ptr);
-    m_visibleWidgets.insert(w);
-}
-
-void QRefCountedWidgetBackingStore::widgetHidden(QWidget *w)
-{
-    if (m_visibleWidgets.remove(w) && m_visibleWidgets.isEmpty()) {
+    m_widgets.insert(w);
+}
+
+/*!
+    \internal
+    Remove the widget from the list of widgets currently using the backing store.
+    If the widget was in the list, and removing it causes the list to be empty,
+    the backing store is deleted.
+    If the widget was not in the list, this function is a no-op.
+ */
+void QWidgetBackingStoreTracker::unregisterWidget(QWidget *w)
+{
+    if (m_widgets.remove(w) && m_widgets.isEmpty()) {
         delete m_ptr;
         m_ptr = 0;
     }
@@ -1241,7 +1274,16 @@
     q->setAttribute(Qt::WA_WState_Hidden);
 
     //give potential windows a bigger "pre-initial" size; create_sys() will give them a new size later
+#ifdef Q_OS_SYMBIAN
+    if (isGLWidget) {
+        // Don't waste GPU mem for unnecessary large egl surface
+        data.crect = QRect(0,0,2,2);
+    } else {
+        data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,360,640);
+    }
+#else
     data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,640,480);
+#endif
 
     focus_next = focus_prev = q;
 
@@ -4822,6 +4864,8 @@
     has been called for the parent do not inherit the parent's layout
     direction.
 
+    This method no longer affects text layout direction since Qt 4.7.
+
     \sa QApplication::layoutDirection
 */
 void QWidget::setLayoutDirection(Qt::LayoutDirection direction)
@@ -9924,7 +9968,7 @@
         desktopWidget = parent;
     bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget;
 
-#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC)
+#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
     if (newParent && parent && !desktopWidget) {
         if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings))
             parent->d_func()->enforceNativeChildren();
@@ -10578,7 +10622,7 @@
     }
     case Qt::WA_PaintOnScreen:
         d->updateIsOpaque();
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
         // Recreate the widget if it's already created as an alien widget and
         // WA_PaintOnScreen is enabled. Paint on screen widgets must have win id.
         // So must their children.
@@ -12045,8 +12089,8 @@
 {
     Q_D(QWidget);
     if (d->gestureContext.remove(gesture)) {
-        QGestureManager *manager = QGestureManager::instance();
-        manager->cleanupCachedGestures(this, gesture);
+        if (QGestureManager *manager = QGestureManager::instance())
+            manager->cleanupCachedGestures(this, gesture);
     }
 }
 #endif // QT_NO_GESTURES