2011-03-28 Andreas Kling <kling@webkit.org>

        Reviewed by Benjamin Poulain.

        [Qt] Crash when calling QWebFrame::render() in response to QWebPage::repaintRequested()
        https://bugs.webkit.org/show_bug.cgi?id=52629

        * WebCoreSupport/ChromeClientQt.cpp:
        (WebCore::ChromeClientQt::invalidateContentsAndWindow): Make the emission of
        QWebPage::repaintRequested() use a Qt::QueuedConnection.

        * tests/qwebpage/tst_qwebpage.cpp:
        (RepaintRequestedRenderer::RepaintRequestedRenderer):
        (RepaintRequestedRenderer::onRepaintRequested):
        (tst_QWebPage::renderOnRepaintRequestedShouldNotRecurse): Test that calling
        QWebFrame::render() in a slot connected to to QWebPage::repaintRequested()
        doesn't cause recursive signal emissions.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@82142 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e64197fc
2011-03-28 Andreas Kling <kling@webkit.org>
Reviewed by Benjamin Poulain.
[Qt] Crash when calling QWebFrame::render() in response to QWebPage::repaintRequested()
https://bugs.webkit.org/show_bug.cgi?id=52629
* WebCoreSupport/ChromeClientQt.cpp:
(WebCore::ChromeClientQt::invalidateContentsAndWindow): Make the emission of
QWebPage::repaintRequested() use a Qt::QueuedConnection.
* tests/qwebpage/tst_qwebpage.cpp:
(RepaintRequestedRenderer::RepaintRequestedRenderer):
(RepaintRequestedRenderer::onRepaintRequested):
(tst_QWebPage::renderOnRepaintRequestedShouldNotRecurse): Test that calling
QWebFrame::render() in a slot connected to to QWebPage::repaintRequested()
doesn't cause recursive signal emissions.
2011-03-28 Benjamin Poulain <benjamin.poulain@nokia.com>
Reviewed by Andreas Kling.
......
......@@ -411,7 +411,7 @@ void ChromeClientQt::invalidateContentsAndWindow(const IntRect& windowRect, bool
if (!rect.isEmpty())
platformPageClient()->update(rect);
}
emit m_webPage->repaintRequested(windowRect);
QMetaObject::invokeMethod(m_webPage, "repaintRequested", Qt::QueuedConnection, Q_ARG(QRect, windowRect));
// FIXME: There is no "immediate" support for window painting. This should be done always whenever the flag
// is set.
......
......@@ -140,6 +140,7 @@ private slots:
void infiniteLoopJS();
void navigatorCookieEnabled();
void deleteQWebViewTwice();
void renderOnRepaintRequestedShouldNotRecurse();
#ifdef Q_OS_MAC
void macCopyUnicodeToClipboard();
......@@ -2798,5 +2799,54 @@ void tst_QWebPage::deleteQWebViewTwice()
}
}
class RepaintRequestedRenderer : public QObject {
Q_OBJECT
public:
RepaintRequestedRenderer(QWebPage* page, QPainter* painter)
: m_page(page)
, m_painter(painter)
, m_recursionCount(0)
{
connect(m_page, SIGNAL(repaintRequested(QRect)), this, SLOT(onRepaintRequested(QRect)));
}
signals:
void finished();
private slots:
void onRepaintRequested(const QRect& rect)
{
QCOMPARE(m_recursionCount, 0);
m_recursionCount++;
m_page->mainFrame()->render(m_painter, rect);
m_recursionCount--;
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
}
private:
QWebPage* m_page;
QPainter* m_painter;
int m_recursionCount;
};
void tst_QWebPage::renderOnRepaintRequestedShouldNotRecurse()
{
QSize viewportSize(720, 576);
QWebPage page;
QImage image(viewportSize, QImage::Format_ARGB32);
QPainter painter(&image);
page.setPreferredContentsSize(viewportSize);
page.setViewportSize(viewportSize);
RepaintRequestedRenderer r(&page, &painter);
page.mainFrame()->setHtml("zalan loves trunk", QUrl());
QVERIFY(::waitForSignal(&r, SIGNAL(finished())));
}
QTEST_MAIN(tst_QWebPage)
#include "tst_qwebpage.moc"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment