[GTK] GtkAdjustmentWatcher idle source not correctly handled
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Jul 2013 15:36:05 +0000 (15:36 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Jul 2013 15:36:05 +0000 (15:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=119003

Reviewed by Martin Robinson.

GtkAdjustmentWatcher::updateAdjustmentsFromScrollbarsLater()
creates a new idle source and initializes
m_updateAdjustmentCallbackId, which is used everywhere and
specially in the destructor to cancel the source when the
GtkAdjustmentWatcher is deleted. However,
m_updateAdjustmentCallbackId is reset to 0 in
GtkAdjustmentWatcher::updateAdjustmentsFromScrollbars() only when
not returning early. This method is public and not only called by
the updateAdjustmentCallback, which means that a call to
updateAdjustmentsFromScrollbars could reset the
m_updateAdjustmentCallbackId without actually destroying the source.

* WebCoreSupport/GtkAdjustmentWatcher.cpp:
(WebKit::GtkAdjustmentWatcher::updateAdjustmentsFromScrollbars):
Cancel the adjustment later idle if it has been scheduled.
(WebKit::GtkAdjustmentWatcher::updateAdjustmentCallback): Reset
m_updateAdjustmentCallbackId.
* WebCoreSupport/GtkAdjustmentWatcher.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@153052 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/GtkAdjustmentWatcher.cpp
Source/WebKit/gtk/WebCoreSupport/GtkAdjustmentWatcher.h

index e3271ca..d991525 100644 (file)
@@ -1,3 +1,29 @@
+2013-07-23  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] GtkAdjustmentWatcher idle source not correctly handled
+        https://bugs.webkit.org/show_bug.cgi?id=119003
+
+        Reviewed by Martin Robinson.
+
+        GtkAdjustmentWatcher::updateAdjustmentsFromScrollbarsLater()
+        creates a new idle source and initializes
+        m_updateAdjustmentCallbackId, which is used everywhere and
+        specially in the destructor to cancel the source when the
+        GtkAdjustmentWatcher is deleted. However,
+        m_updateAdjustmentCallbackId is reset to 0 in
+        GtkAdjustmentWatcher::updateAdjustmentsFromScrollbars() only when
+        not returning early. This method is public and not only called by
+        the updateAdjustmentCallback, which means that a call to
+        updateAdjustmentsFromScrollbars could reset the
+        m_updateAdjustmentCallbackId without actually destroying the source.
+
+        * WebCoreSupport/GtkAdjustmentWatcher.cpp:
+        (WebKit::GtkAdjustmentWatcher::updateAdjustmentsFromScrollbars):
+        Cancel the adjustment later idle if it has been scheduled.
+        (WebKit::GtkAdjustmentWatcher::updateAdjustmentCallback): Reset
+        m_updateAdjustmentCallbackId.
+        * WebCoreSupport/GtkAdjustmentWatcher.h:
+
 2013-07-17  Kangil Han  <kangil.han@samsung.com>
 
         Use toHTMLMediaElement
index b78d12e..24b0403 100644 (file)
@@ -68,11 +68,15 @@ void GtkAdjustmentWatcher::updateAdjustmentsFromScrollbars()
     FrameView* frameView = core(m_webView)->mainFrame()->view();
     updateAdjustmentFromScrollbar(m_horizontalAdjustment.get(), frameView->horizontalScrollbar());
     updateAdjustmentFromScrollbar(m_verticalAdjustment.get(), frameView->verticalScrollbar());
-    m_updateAdjustmentCallbackId = 0;
+    if (m_updateAdjustmentCallbackId) {
+        g_source_remove(m_updateAdjustmentCallbackId);
+        m_updateAdjustmentCallbackId = 0;
+    }
 }
 
-static gboolean updateAdjustmentCallback(GtkAdjustmentWatcher* watcher)
+gboolean GtkAdjustmentWatcher::updateAdjustmentCallback(GtkAdjustmentWatcher* watcher)
 {
+    watcher->m_updateAdjustmentCallbackId = 0;
     watcher->updateAdjustmentsFromScrollbars();
     return FALSE;
 }
index 2f7bee3..e569cdc 100644 (file)
@@ -43,6 +43,8 @@ public:
     bool scrollbarsDisabled() const { return m_scrollbarsDisabled; };
 
 private:
+    static gboolean updateAdjustmentCallback(GtkAdjustmentWatcher*);
+
     WebKitWebView* m_webView;
     GRefPtr<GtkAdjustment> m_horizontalAdjustment;
     GRefPtr<GtkAdjustment> m_verticalAdjustment;