Changeset 62251 in webkit


Ignore:
Timestamp:
Jul 1, 2010 5:17:13 AM (14 years ago)
Author:
jocelyn.turcotte@nokia.com
Message:

2010-07-01 Jocelyn Turcotte <jocelyn.turcotte@nokia.com>

Reviewed by Kenneth Rohde Christiansen.

[Qt] Create QComboBoxes when clicked and destroy on hide.
https://bugs.webkit.org/show_bug.cgi?id=41451

Currently a QComboBox is created for each RenderMenuList and
it gets destroyed either when the RenderMenuList or the
QWebView (its Qt parent) is destroyed. This cause a crash
when the QWebView is destroyed before the render tree (which
is kept in cache).

This patch aim to destroy the QComboBox as soon as its popup
gets hidden, and likewise, create it only when the popup is
requested to be shown.
It also removes the unneeded reference to the QGraphicsProxyWidget,
destroying the QComboBox automatically destroys its bound
proxywidget.

  • WebCoreSupport/QtFallbackWebPopup.cpp: (WebCore::QtFallbackWebPopupCombo::hidePopup): (WebCore::QtFallbackWebPopup::QtFallbackWebPopup): (WebCore::QtFallbackWebPopup::~QtFallbackWebPopup): (WebCore::QtFallbackWebPopup::show): (WebCore::QtFallbackWebPopup::hide): (WebCore::QtFallbackWebPopup::destroyPopup): (WebCore::QtFallbackWebPopup::populate):
  • WebCoreSupport/QtFallbackWebPopup.h:
Location:
trunk/WebKit/qt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/qt/ChangeLog

    r62249 r62251  
     12010-07-01  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        [Qt] Create QComboBoxes when clicked and destroy on hide.
     6        https://bugs.webkit.org/show_bug.cgi?id=41451
     7
     8        Currently a QComboBox is created for each RenderMenuList and
     9        it gets destroyed either when the RenderMenuList or the
     10        QWebView (its Qt parent) is destroyed. This cause a crash
     11        when the QWebView is destroyed before the render tree (which
     12        is kept in cache).
     13
     14        This patch aim to destroy the QComboBox as soon as its popup
     15        gets hidden, and likewise, create it only when the popup is
     16        requested to be shown.
     17        It also removes the unneeded reference to the QGraphicsProxyWidget,
     18        destroying the QComboBox automatically destroys its bound
     19        proxywidget.
     20
     21        * WebCoreSupport/QtFallbackWebPopup.cpp:
     22        (WebCore::QtFallbackWebPopupCombo::hidePopup):
     23        (WebCore::QtFallbackWebPopup::QtFallbackWebPopup):
     24        (WebCore::QtFallbackWebPopup::~QtFallbackWebPopup):
     25        (WebCore::QtFallbackWebPopup::show):
     26        (WebCore::QtFallbackWebPopup::hide):
     27        (WebCore::QtFallbackWebPopup::destroyPopup):
     28        (WebCore::QtFallbackWebPopup::populate):
     29        * WebCoreSupport/QtFallbackWebPopup.h:
     30
    1312010-07-01  Satish Sampath  <satish@chromium.org>
    232
  • trunk/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp

    r62193 r62251  
    7676    QComboBox::hidePopup();
    7777
    78     if (QGraphicsProxyWidget* proxy = graphicsProxyWidget())
    79         proxy->setVisible(false);
    80 
    8178    if (!m_ownerPopup.m_popupVisible)
    8279        return;
     
    8481    m_ownerPopup.m_popupVisible = false;
    8582    m_ownerPopup.popupDidHide();
     83    m_ownerPopup.destroyPopup();
    8684}
    8785
     
    103101    : QtAbstractWebPopup()
    104102    , m_popupVisible(false)
    105     , m_combo(new QtFallbackWebPopupCombo(*this))
    106     , m_proxy(0)
    107 {
    108     connect(m_combo, SIGNAL(activated(int)),
    109             SLOT(activeChanged(int)), Qt::QueuedConnection);
     103    , m_combo(0)
     104{
    110105}
    111106
    112107QtFallbackWebPopup::~QtFallbackWebPopup()
    113108{
    114     // If we create a proxy, then the deletion of the proxy and the
    115     // combo will be done by the proxy's parent (QGraphicsWebView)
    116     if (!m_proxy && m_combo)
    117         m_combo->deleteLater();
     109    destroyPopup();
    118110}
    119111
     
    126118    TRAP_IGNORE(showS60BrowserDialog());
    127119#else
     120
     121    destroyPopup();
     122    m_combo = new QtFallbackWebPopupCombo(*this);
     123    connect(m_combo, SIGNAL(activated(int)),
     124            SLOT(activeChanged(int)), Qt::QueuedConnection);
     125
    128126    populate();
    129127    m_combo->setCurrentIndex(currentIndex());
     
    131129    QRect rect = geometry();
    132130    if (QGraphicsWebView *webView = qobject_cast<QGraphicsWebView*>(pageClient()->pluginParent())) {
    133         if (!m_proxy) {
    134             m_proxy = new QGraphicsProxyWidget(webView);
    135             m_proxy->setWidget(m_combo);
    136         } else
    137             m_proxy->setVisible(true);
    138         m_proxy->setGeometry(rect);
     131        QGraphicsProxyWidget* proxy = new QGraphicsProxyWidget(webView);
     132        proxy->setWidget(m_combo);
     133        proxy->setGeometry(rect);
    139134    } else {
    140135        m_combo->setParent(pageClient()->ownerWidget());
     
    205200void QtFallbackWebPopup::hide()
    206201{
    207     m_combo->hidePopup();
     202    // Destroying the QComboBox here cause problems if the popup is in the
     203    // middle of its show animation. Instead we rely on the fact that the
     204    // Qt::Popup window will hide itself on mouse events outside its window.
     205}
     206
     207void QtFallbackWebPopup::destroyPopup()
     208{
     209    if (m_combo) {
     210        m_combo->deleteLater();
     211        m_combo = 0;
     212    }
    208213}
    209214
    210215void QtFallbackWebPopup::populate()
    211216{
    212     m_combo->clear();
    213 
    214217    QStandardItemModel* model = qobject_cast<QStandardItemModel*>(m_combo->model());
    215218    Q_ASSERT(model);
  • trunk/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h

    r62193 r62251  
    4343    virtual void hide();
    4444
     45    void destroyPopup();
     46
    4547private slots:
    4648    void activeChanged(int);
     
    5052    bool m_popupVisible;
    5153    QtFallbackWebPopupCombo* m_combo;
    52     QGraphicsProxyWidget* m_proxy;
    5354
    5455    void populate();
Note: See TracChangeset for help on using the changeset viewer.