diff options
Diffstat (limited to 'o3d')
-rw-r--r-- | o3d/core/cross/client.cc | 3 | ||||
-rw-r--r-- | o3d/core/cross/client.h | 9 | ||||
-rw-r--r-- | o3d/plugin/mac/plugin_mac.mm | 7 |
3 files changed, 16 insertions, 3 deletions
diff --git a/o3d/core/cross/client.cc b/o3d/core/cross/client.cc index 0097d67..a6f9c32 100644 --- a/o3d/core/cross/client.cc +++ b/o3d/core/cross/client.cc @@ -82,6 +82,7 @@ Client::Client(ServiceLocator* service_locator) render_mode_(RENDERMODE_CONTINUOUS), texture_on_hold_(false), event_manager_(), + is_ticking_(false), last_tick_time_(0), root_(NULL), #ifdef OS_WIN @@ -175,6 +176,7 @@ void Client::ClearTickCallback() { } bool Client::Tick() { + is_ticking_ = true; ElapsedTimeTimer timer; float seconds_elapsed = tick_elapsed_time_timer_.GetElapsedTimeAndReset(); tick_event_.set_elapsed_time(seconds_elapsed); @@ -216,6 +218,7 @@ bool Client::Tick() { } } + is_ticking_ = false; return message_check_ok; } diff --git a/o3d/core/cross/client.h b/o3d/core/cross/client.h index 158f1eb..1dcb36d 100644 --- a/o3d/core/cross/client.h +++ b/o3d/core/cross/client.h @@ -298,6 +298,12 @@ class Client { // true if message check was ok. bool Tick(); + // Indicates whether a call to Tick() is in progress. This is needed + // to avoid reentrancy problems on some platforms. + bool IsTicking() const { + return is_ticking_; + } + // Searches in the Client for an object by its id. This function is for // Javascript. // Parameters: @@ -497,6 +503,9 @@ class Client { // Timer for getting the elapsed time between tick updates. ElapsedTimeTimer tick_elapsed_time_timer_; + // Whether a call to Tick() is currently active. + bool is_ticking_; + // Used to gather render time from mulitple RenderTree calls. float total_time_to_render_; diff --git a/o3d/plugin/mac/plugin_mac.mm b/o3d/plugin/mac/plugin_mac.mm index 488a7b6..26c8f7c 100644 --- a/o3d/plugin/mac/plugin_mac.mm +++ b/o3d/plugin/mac/plugin_mac.mm @@ -237,9 +237,10 @@ void RenderTimer::TimerCallback(CFRunLoopTimerRef timer, void* info) { NPP instance = instances_[i]; PluginObject* obj = static_cast<PluginObject*>(instance->pdata); - // RenderClient() may cause events to be processed, leading to - // reentrant calling of this code. Detect and avoid this case. - if (obj->client()->IsRendering()) { + // RenderClient() and Tick() may cause events to be processed, + // leading to reentrant calling of this code. Detect and avoid + // this case. + if (obj->client()->IsRendering() || obj->client()->IsTicking()) { continue; } |