Changeset 82805 in webkit
- Timestamp:
- Apr 4, 2011 1:50:50 AM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r82797 r82805 1 2011-04-04 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 Reviewed by Martin Robinson. 4 5 [GTK] Main loop sources are leaked in RunLoopGtk 6 https://bugs.webkit.org/show_bug.cgi?id=57618 7 8 * Platform/RunLoop.h: 9 (RunLoop::TimerBase::isRepeating): 10 * Platform/gtk/RunLoopGtk.cpp: 11 (RunLoop::~RunLoop): Make sure main loop is currently running 12 before calling g_main_loop_quit(), RunLoop::stop() might have been 13 called. 14 (RunLoop::wakeUp): Use an idle source with default priority 15 instead of a timeout one with a 0 interval. 16 (RunLoop::TimerBase::clearTimerSource): New method to clear the 17 timer. 18 (RunLoop::TimerBase::destroyNotifyCallback): Destroy notify 19 callback called when the source is destroyed to clear the timer. 20 (RunLoop::TimerBase::timerFiredCallback): Use the same callback for 21 repeating and no repeating timers. 22 (RunLoop::TimerBase::start): g_source_attach() increments the 23 source reference counter, so use GRefPtr to make sure the source 24 is freed. 25 (RunLoop::TimerBase::stop): Use clearTimerSource(). 26 1 27 2011-04-03 Dan Bernstein <mitz@apple.com> 2 28 -
trunk/Source/WebKit2/Platform/RunLoop.h
r73142 r82805 35 35 #include <wtf/Vector.h> 36 36 #if PLATFORM(GTK) 37 #include <wtf/gobject/GRefPtr.h> 37 38 typedef struct _GSource GSource; 38 39 typedef struct _GMainLoop GMainLoop; … … 87 88 bool m_isRepeating; 88 89 #elif PLATFORM(GTK) 89 static gboolean oneShotTimerFired(RunLoop::TimerBase*); 90 static gboolean repeatingTimerFired(RunLoop::TimerBase*); 91 void resetTimerSource(); 92 GSource* m_timerSource; 90 static gboolean timerFiredCallback(RunLoop::TimerBase*); 91 static void destroyNotifyCallback(RunLoop::TimerBase*); 92 gboolean isRepeating() const { return m_isRepeating; } 93 void clearTimerSource(); 94 GRefPtr<GSource> m_timerSource; 95 gboolean m_isRepeating; 93 96 #endif 94 97 }; -
trunk/Source/WebKit2/Platform/gtk/RunLoopGtk.cpp
r76916 r82805 42 42 { 43 43 if (m_runLoopMain) { 44 g_main_loop_quit(m_runLoopMain); 44 if (g_main_loop_is_running(m_runLoopMain)) 45 g_main_loop_quit(m_runLoopMain); 45 46 g_main_loop_unref(m_runLoopMain); 46 47 } … … 73 74 void RunLoop::wakeUp() 74 75 { 75 GSource* source = g_timeout_source_new(0); 76 g_source_set_callback(source, reinterpret_cast<GSourceFunc>(&RunLoop::queueWork), this, 0); 77 g_source_attach(source, m_runLoopContext); 76 GRefPtr<GSource> source = adoptGRef(g_idle_source_new()); 77 g_source_set_priority(source.get(), G_PRIORITY_DEFAULT); 78 g_source_set_callback(source.get(), reinterpret_cast<GSourceFunc>(&RunLoop::queueWork), this, 0); 79 g_source_attach(source.get(), m_runLoopContext); 78 80 79 81 g_main_context_wakeup(m_runLoopContext); … … 91 93 } 92 94 93 void RunLoop::TimerBase:: resetTimerSource()95 void RunLoop::TimerBase::clearTimerSource() 94 96 { 95 97 m_timerSource = 0; 96 98 } 97 99 98 gboolean RunLoop::TimerBase::oneShotTimerFired(RunLoop::TimerBase* timer) 100 void RunLoop::TimerBase::destroyNotifyCallback(RunLoop::TimerBase* timer) 101 { 102 timer->clearTimerSource(); 103 } 104 105 gboolean RunLoop::TimerBase::timerFiredCallback(RunLoop::TimerBase* timer) 99 106 { 100 107 timer->fired(); 101 timer->resetTimerSource(); 102 return FALSE; 103 } 104 105 gboolean RunLoop::TimerBase::repeatingTimerFired(RunLoop::TimerBase* timer) 106 { 107 timer->fired(); 108 return TRUE; 108 return timer->isRepeating(); 109 109 } 110 110 … … 114 114 stop(); 115 115 116 m_timerSource = g_timeout_source_new(static_cast<guint>(fireInterval)); 117 if (repeat) 118 g_source_set_callback(m_timerSource, reinterpret_cast<GSourceFunc>(&RunLoop::TimerBase::repeatingTimerFired), this, 0); 119 else 120 g_source_set_callback(m_timerSource, reinterpret_cast<GSourceFunc>(&RunLoop::TimerBase::oneShotTimerFired), this, 0); 121 g_source_attach(m_timerSource, m_runLoop->m_runLoopContext); 116 m_timerSource = adoptGRef(g_timeout_source_new(static_cast<guint>(fireInterval * 1000))); 117 m_isRepeating = repeat; 118 g_source_set_callback(m_timerSource.get(), reinterpret_cast<GSourceFunc>(&RunLoop::TimerBase::timerFiredCallback), this, 119 reinterpret_cast<GDestroyNotify>(&RunLoop::TimerBase::destroyNotifyCallback)); 120 g_source_attach(m_timerSource.get(), m_runLoop->m_runLoopContext); 122 121 } 123 122 … … 127 126 return; 128 127 129 g_source_destroy(m_timerSource );130 m_timerSource = 0;128 g_source_destroy(m_timerSource.get()); 129 clearTimerSource(); 131 130 } 132 131
Note: See TracChangeset
for help on using the changeset viewer.