[gjs: 17/22] toggle: Add utility function to handle all toggles
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 17/22] toggle: Add utility function to handle all toggles
- Date: Fri, 23 Apr 2021 04:56:07 +0000 (UTC)
commit 3ebcc34eddfde2deaae18f6b77fff61892fbee60
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Sat Apr 3 04:48:04 2021 +0200
toggle: Add utility function to handle all toggles
Avoid redo the same in various places, just do it once.
gi/object.cpp | 4 +---
gi/toggle.cpp | 8 ++++++--
gi/toggle.h | 1 +
3 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index a8ac6d86..b32f094f 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -1401,9 +1401,7 @@ ObjectInstance::release_native_object(void)
void
gjs_object_clear_toggles(void)
{
- auto& toggle_queue = ToggleQueue::get_default();
- while (toggle_queue.handle_toggle(toggle_handler))
- ;
+ ToggleQueue::get_default().handle_all_toggles(toggle_handler);
}
void
diff --git a/gi/toggle.cpp b/gi/toggle.cpp
index 9714ebdb..f627f3ad 100644
--- a/gi/toggle.cpp
+++ b/gi/toggle.cpp
@@ -44,12 +44,16 @@ ToggleQueue::find_and_erase_operation_locked(const GObject *gobj,
return had_toggle;
}
+void ToggleQueue::handle_all_toggles(Handler handler) {
+ while (handle_toggle(handler))
+ ;
+}
+
gboolean
ToggleQueue::idle_handle_toggle(void *data)
{
auto self = static_cast<ToggleQueue *>(data);
- while (self->handle_toggle(self->m_toggle_handler))
- ;
+ self->handle_all_toggles(self->m_toggle_handler);
return G_SOURCE_REMOVE;
}
diff --git a/gi/toggle.h b/gi/toggle.h
index 9c9ab2db..ae7228b8 100644
--- a/gi/toggle.h
+++ b/gi/toggle.h
@@ -75,6 +75,7 @@ private:
* want to wait for it to be processed in idle time. Returns false if queue
* is empty. */
bool handle_toggle(Handler handler);
+ void handle_all_toggles(Handler handler);
/* Checks if the gobj is currently being handled, to avoid recursion */
bool is_being_handled(GObject* gobj);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]