Changeset 65795 in webkit


Ignore:
Timestamp:
Aug 23, 2010 12:59:48 AM (14 years ago)
Author:
ariya@webkit.org
Message:

[Qt] Crash when purging the scratch buffer for the shadow
https://bugs.webkit.org/show_bug.cgi?id=44384

Patch by Ariya Hidayat <ariya@sencha.com> on 2010-08-23
Reviewed by Kenneth Rohde Christiansen.

WebCore::Timer can't be used in a static object bcause it relies on
thread global data, which is invalid once the application instance is
destroyed. To overcome the problem, use QObject's timer support for
the ShadowBuffer class.

  • platform/graphics/qt/ContextShadow.cpp:

(WebCore::):
(WebCore::ShadowBuffer::ShadowBuffer):
(WebCore::ShadowBuffer::schedulePurge):
(WebCore::ShadowBuffer::timerEvent):

Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r65793 r65795  
     12010-08-23  Ariya Hidayat  <ariya@sencha.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        [Qt] Crash when purging the scratch buffer for the shadow
     6        https://bugs.webkit.org/show_bug.cgi?id=44384
     7
     8        WebCore::Timer can't be used in a static object bcause it relies on
     9        thread global data, which is invalid once the application instance is
     10        destroyed. To overcome the problem, use QObject's timer support for
     11        the ShadowBuffer class.
     12
     13        * platform/graphics/qt/ContextShadow.cpp:
     14        (WebCore::):
     15        (WebCore::ShadowBuffer::ShadowBuffer):
     16        (WebCore::ShadowBuffer::schedulePurge):
     17        (WebCore::ShadowBuffer::timerEvent):
     18
    1192010-08-23  Philippe Normand  <pnormand@igalia.com>
    220
  • trunk/WebCore/platform/graphics/qt/ContextShadow.cpp

    r65782 r65795  
    2929#include "ContextShadow.h"
    3030
    31 #include "Timer.h"
     31#include <QTimerEvent>
    3232#include <wtf/Noncopyable.h>
    3333
     
    3838// we create a buffer which will be automatically purged via a timer.
    3939
    40 class ShadowBuffer: public Noncopyable {
     40class ShadowBuffer: public QObject {
    4141public:
    42     ShadowBuffer();
     42    ShadowBuffer(QObject* parent = 0);
    4343
    4444    QImage* scratchImage(const QSize& size);
    4545
    4646    void schedulePurge();
     47
     48protected:
     49    void timerEvent(QTimerEvent* event);
    4750
    4851private:
    4952    QImage image;
    50     void purgeBuffer(Timer<ShadowBuffer>*);
    51     Timer<ShadowBuffer> purgeTimer;
     53    int timerId;
    5254};
    5355
    54 ShadowBuffer::ShadowBuffer()
    55     : purgeTimer(this, &ShadowBuffer::purgeBuffer)
     56ShadowBuffer::ShadowBuffer(QObject* parent)
     57    : QObject(parent)
     58    , timerId(0)
    5659{
    5760}
     
    8588{
    8689    static const double BufferPurgeDelay = 2; // seconds
    87     purgeTimer.startOneShot(BufferPurgeDelay);
    88 }
    89 
    90 void ShadowBuffer::purgeBuffer(Timer<ShadowBuffer>*)
    91 {
    92     image = QImage();
     90    killTimer(timerId);
     91    timerId = startTimer(BufferPurgeDelay * 1000);
     92}
     93
     94void ShadowBuffer::timerEvent(QTimerEvent* event)
     95{
     96    if (event->timerId() == timerId) {
     97        killTimer(timerId);
     98        image = QImage();
     99    }
     100    QObject::timerEvent(event);
    93101}
    94102
Note: See TracChangeset for help on using the changeset viewer.