summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjellahlstedt@gmail.com>2023-02-22 13:37:36 +0100
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2023-02-22 13:37:36 +0100
commit313cd3523df7ab292d98f725a6affa55b5fd8f61 (patch)
tree077a8c0bb3190bada34650e7a18101e7dcd6d688
parenta93cc7c1c79db169183f1b03159b67a044f38a37 (diff)
downloadglibmm-313cd3523df7ab292d98f725a6affa55b5fd8f61.tar.gz
Glib::Dispatcher: Add const versions of emit() and operator()()
and deprecate the non-const versions. Fixes #103
-rw-r--r--examples/thread/dispatcher2.cc2
-rw-r--r--glib/glibmm/dispatcher.cc14
-rw-r--r--glib/glibmm/dispatcher.h15
3 files changed, 30 insertions, 1 deletions
diff --git a/examples/thread/dispatcher2.cc b/examples/thread/dispatcher2.cc
index 98011617..46b5c3d1 100644
--- a/examples/thread/dispatcher2.cc
+++ b/examples/thread/dispatcher2.cc
@@ -47,7 +47,7 @@ public:
private:
unsigned int time_;
Glib::Dispatcher signal_increment_;
- Glib::Dispatcher* signal_finished_ptr_;
+ const Glib::Dispatcher* signal_finished_ptr_;
std::mutex startup_mutex_;
std::condition_variable startup_cond_;
diff --git a/glib/glibmm/dispatcher.cc b/glib/glibmm/dispatcher.cc
index 083f948e..dd7dff8d 100644
--- a/glib/glibmm/dispatcher.cc
+++ b/glib/glibmm/dispatcher.cc
@@ -498,6 +498,7 @@ Dispatcher::~Dispatcher() noexcept
DispatchNotifier::unreference_instance(impl_->notifier_, impl_);
}
+#ifndef GLIBMM_DISABLE_DEPRECATED
void
Dispatcher::emit()
{
@@ -509,6 +510,19 @@ Dispatcher::operator()()
{
impl_->notifier_->send_notification(impl_);
}
+#endif // GLIBMM_DISABLE_DEPRECATED
+
+void
+Dispatcher::emit() const
+{
+ impl_->notifier_->send_notification(impl_);
+}
+
+void
+Dispatcher::operator()() const
+{
+ impl_->notifier_->send_notification(impl_);
+}
sigc::connection
Dispatcher::connect(const sigc::slot<void()>& slot)
diff --git a/glib/glibmm/dispatcher.h b/glib/glibmm/dispatcher.h
index 83bd24e9..b27da57b 100644
--- a/glib/glibmm/dispatcher.h
+++ b/glib/glibmm/dispatcher.h
@@ -80,8 +80,23 @@ public:
explicit Dispatcher(const Glib::RefPtr<MainContext>& context);
~Dispatcher() noexcept;
+#ifndef GLIBMM_DISABLE_DEPRECATED
+ /** Same as the const version.
+ * @deprecated 2.76: Use the const version instead.
+ */
void emit();
+ /** Same as the const version.
+ * @deprecated 2.76: Use the const version instead.
+ */
void operator()();
+#endif // GLIBMM_DISABLE_DEPRECATED
+
+ /** @newin{2,76}
+ */
+ void emit() const;
+ /** @newin{2,76}
+ */
+ void operator()() const;
sigc::connection connect(const sigc::slot<void()>& slot);
/** @newin{2,48}