Title: [184333] trunk/Source/WTF
- Revision
- 184333
- Author
- [email protected]
- Date
- 2015-05-14 02:32:49 -0700 (Thu, 14 May 2015)
Log Message
[GTK] RunLoop constructor should properly retrieve or establish the thread-default GMainContext
https://bugs.webkit.org/show_bug.cgi?id=144732
Reviewed by Carlos Garcia Campos.
RunLoop constructor in the GTK implementation should use the
existing thread-default context, create a new one if not on
the main thread, or use the global-default one if on the main
thread.
In RunLoop::run(), the GMainContext should then be pushed as
the thread-default before calling g_main_loop_run(), and popped
off when the main loop stops.
* wtf/gtk/RunLoopGtk.cpp:
(WTF::RunLoop::RunLoop):
(WTF::RunLoop::run):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (184332 => 184333)
--- trunk/Source/WTF/ChangeLog 2015-05-14 07:59:14 UTC (rev 184332)
+++ trunk/Source/WTF/ChangeLog 2015-05-14 09:32:49 UTC (rev 184333)
@@ -1,3 +1,23 @@
+2015-05-14 Žan Doberšek <[email protected]>
+
+ [GTK] RunLoop constructor should properly retrieve or establish the thread-default GMainContext
+ https://bugs.webkit.org/show_bug.cgi?id=144732
+
+ Reviewed by Carlos Garcia Campos.
+
+ RunLoop constructor in the GTK implementation should use the
+ existing thread-default context, create a new one if not on
+ the main thread, or use the global-default one if on the main
+ thread.
+
+ In RunLoop::run(), the GMainContext should then be pushed as
+ the thread-default before calling g_main_loop_run(), and popped
+ off when the main loop stops.
+
+ * wtf/gtk/RunLoopGtk.cpp:
+ (WTF::RunLoop::RunLoop):
+ (WTF::RunLoop::run):
+
2015-05-13 Oliver Hunt <[email protected]>
Ensure that all the smart pointer types in WTF clear their pointer before deref
https://bugs.webkit.org/show_bug.cgi?id=143789
Modified: trunk/Source/WTF/wtf/gtk/RunLoopGtk.cpp (184332 => 184333)
--- trunk/Source/WTF/wtf/gtk/RunLoopGtk.cpp 2015-05-14 07:59:14 UTC (rev 184332)
+++ trunk/Source/WTF/wtf/gtk/RunLoopGtk.cpp 2015-05-14 09:32:49 UTC (rev 184333)
@@ -34,9 +34,11 @@
RunLoop::RunLoop()
{
- // g_main_context_default() doesn't add an extra reference.
- m_mainContext = isMainThread() ? g_main_context_default() : adoptGRef(g_main_context_new());
+ m_mainContext = g_main_context_get_thread_default();
+ if (!m_mainContext)
+ m_mainContext = isMainThread() ? g_main_context_default() : adoptGRef(g_main_context_new());
ASSERT(m_mainContext);
+
GRefPtr<GMainLoop> innermostLoop = adoptGRef(g_main_loop_new(m_mainContext.get(), FALSE));
ASSERT(innermostLoop);
m_mainLoops.append(innermostLoop);
@@ -54,20 +56,27 @@
void RunLoop::run()
{
RunLoop& runLoop = RunLoop::current();
+ GMainContext* mainContext = runLoop.m_mainContext.get();
// The innermost main loop should always be there.
ASSERT(!runLoop.m_mainLoops.isEmpty());
GMainLoop* innermostLoop = runLoop.m_mainLoops[0].get();
if (!g_main_loop_is_running(innermostLoop)) {
+ g_main_context_push_thread_default(mainContext);
g_main_loop_run(innermostLoop);
+ g_main_context_pop_thread_default(mainContext);
return;
}
// Create and run a nested loop if the innermost one was already running.
- GMainLoop* nestedMainLoop = g_main_loop_new(runLoop.m_mainContext.get(), FALSE);
+ GMainLoop* nestedMainLoop = g_main_loop_new(mainContext, FALSE);
runLoop.m_mainLoops.append(adoptGRef(nestedMainLoop));
+
+ g_main_context_push_thread_default(mainContext);
g_main_loop_run(nestedMainLoop);
+ g_main_context_pop_thread_default(mainContext);
+
runLoop.m_mainLoops.removeLast();
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes