From db637e7f83a4f981be7087eac03636c028e85379 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 22 Dec 2009 22:20:26 +0000 Subject: [PATCH] build on 10.4 --- direct/src/plugin_npapi/ppInstance.cxx | 19 ++++++++++++------- direct/src/plugin_npapi/ppInstance.h | 1 + 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/direct/src/plugin_npapi/ppInstance.cxx b/direct/src/plugin_npapi/ppInstance.cxx index eaab0bcde7..cd2dcfb65e 100644 --- a/direct/src/plugin_npapi/ppInstance.cxx +++ b/direct/src/plugin_npapi/ppInstance.cxx @@ -85,6 +85,11 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, _python_window_open = false; #ifdef __APPLE__ + // Get the run loop in the browser thread. (CFRunLoopGetMain() is + // only 10.5 or higher. Plus, the browser thread is not necessarily + // the "main" thread.) + _run_loop_main = CFRunLoopGetCurrent(); + CFRetain(_run_loop_main); _request_timer = NULL; #endif // __APPLE__ } @@ -99,11 +104,12 @@ PPInstance:: cleanup_window(); #ifdef __APPLE__ - if (_request_timer != NULL) { - CFRunLoopTimerInvalidate(_request_timer); - CFRelease(_request_timer); - _request_timer = NULL; - } + if (_request_timer != NULL) { + CFRunLoopTimerInvalidate(_request_timer); + CFRelease(_request_timer); + } + _run_loop_main = CFRunLoopGetCurrent(); + CFRelease(_run_loop_main); #endif // __APPLE__ if (_p3d_inst != NULL) { @@ -1032,8 +1038,7 @@ request_ready(P3D_instance *instance) { timer_context.info = inst; inst->_request_timer = CFRunLoopTimerCreate (NULL, 0, 0, 0, 0, timer_callback, &timer_context); - CFRunLoopRef run_loop = CFRunLoopGetMain(); - CFRunLoopAddTimer(run_loop, inst->_request_timer, kCFRunLoopCommonModes); + CFRunLoopAddTimer(inst->_run_loop_main, inst->_request_timer, kCFRunLoopCommonModes); #endif // __APPLE__ // Doesn't appear to be a reliable way to simulate this in Linux. diff --git a/direct/src/plugin_npapi/ppInstance.h b/direct/src/plugin_npapi/ppInstance.h index 69c08e852f..f8b8d8bb40 100644 --- a/direct/src/plugin_npapi/ppInstance.h +++ b/direct/src/plugin_npapi/ppInstance.h @@ -187,6 +187,7 @@ private: #endif // _WIN32 #ifdef __APPLE__ + CFRunLoopRef _run_loop_main; CFRunLoopTimerRef _request_timer; #endif // __APPLE__