fix the revertable lock of window_manager
This commit is contained in:
@@ -1158,7 +1158,9 @@ namespace detail
|
||||
}
|
||||
|
||||
++(context->event_pump_ref_count);
|
||||
wd_manager().internal_lock().revert();
|
||||
|
||||
auto & lock = wd_manager().internal_lock();
|
||||
lock.revert();
|
||||
|
||||
native_window_type owner_native = 0;
|
||||
core_window_t * owner = 0;
|
||||
@@ -1183,8 +1185,9 @@ namespace detail
|
||||
owner->flags.enabled = true;
|
||||
native_interface::enable_window(owner_native, true);
|
||||
}
|
||||
|
||||
wd_manager().internal_lock().forward();
|
||||
|
||||
lock.forward();
|
||||
|
||||
if(0 == --(context->event_pump_ref_count))
|
||||
{
|
||||
if(0 == modal_window || 0 == context->window_count)
|
||||
|
||||
@@ -335,7 +335,7 @@ namespace detail
|
||||
|
||||
void window_manager::revertible_mutex::revert()
|
||||
{
|
||||
if(impl_->thread.ref && (impl_->thread.tid == nana::system::this_thread_id()))
|
||||
if(impl_->thread.tid == nana::system::this_thread_id())
|
||||
{
|
||||
std::size_t cnt = impl_->thread.ref;
|
||||
|
||||
@@ -346,24 +346,30 @@ namespace detail
|
||||
for (std::size_t i = 0; i < cnt; ++i)
|
||||
impl_->mutex.unlock();
|
||||
}
|
||||
else
|
||||
throw std::runtime_error("The revert is not allowed");
|
||||
}
|
||||
|
||||
void window_manager::revertible_mutex::forward()
|
||||
{
|
||||
impl_->mutex.lock();
|
||||
|
||||
if(impl_->invoke_stack.size())
|
||||
{
|
||||
auto thr = impl_->invoke_stack.back();
|
||||
|
||||
impl_->invoke_stack.pop_back();
|
||||
|
||||
if(thr.tid == nana::system::this_thread_id())
|
||||
{
|
||||
impl_->invoke_stack.pop_back();
|
||||
for (std::size_t i = 0; i < thr.ref; ++i)
|
||||
impl_->mutex.lock();
|
||||
impl_->thread = thr;
|
||||
}
|
||||
else
|
||||
throw std::runtime_error("Nana.GUI: The forward is not matched.");
|
||||
throw std::runtime_error("The forward is not matched. Please report this issue");
|
||||
}
|
||||
|
||||
impl_->mutex.unlock();
|
||||
}
|
||||
//end class revertible_mutex
|
||||
|
||||
Reference in New Issue
Block a user