[vte] terminal: Skip commit signal emission when there are no handlers
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] terminal: Skip commit signal emission when there are no handlers
- Date: Thu, 21 Nov 2019 19:02:14 +0000 (UTC)
commit bc680aaa835daed9ed8cc0e4b9f2e1dfa4848afb
Author: Christian Persch <chpe src gnome org>
Date: Thu Nov 21 20:01:30 2019 +0100
terminal: Skip commit signal emission when there are no handlers
src/vte.cc | 3 +++
src/widget.cc | 9 +++++++++
src/widget.hh | 2 ++
3 files changed, 14 insertions(+)
---
diff --git a/src/vte.cc b/src/vte.cc
index d43bc314..b4527155 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -736,6 +736,9 @@ Terminal::emit_commit(std::string_view const& str)
if (str.size() == 0)
return;
+ if (!widget() || !widget()->should_emit_signal(SIGNAL_COMMIT))
+ return;
+
_vte_debug_print(VTE_DEBUG_SIGNALS,
"Emitting `commit' of %" G_GSSIZE_FORMAT" bytes.\n", str.size());
diff --git a/src/widget.cc b/src/widget.cc
index c93b3a2e..ed2cc4df 100644
--- a/src/widget.cc
+++ b/src/widget.cc
@@ -428,6 +428,15 @@ Widget::size_allocate(GtkAllocation* allocation) noexcept
allocation->height);
}
+bool
+Widget::should_emit_signal(int id) noexcept
+{
+ return g_signal_has_handler_pending(object(),
+ signals[id],
+ 0 /* detail */,
+ false /* not interested in blocked handlers */) != FALSE;
+}
+
void
Widget::unmap() noexcept
{
diff --git a/src/widget.hh b/src/widget.hh
index d442b3fe..d904fe33 100644
--- a/src/widget.hh
+++ b/src/widget.hh
@@ -136,6 +136,8 @@ public:
void feed_child(std::string_view const& str) { terminal()->feed_child(str); }
void feed_child_binary(std::string_view const& str) { terminal()->feed_child_binary(str); }
+ bool should_emit_signal(int id) noexcept;
+
protected:
enum class CursorType {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]