From aab1cfd289296972ef32124f749e3b565b634535 Mon Sep 17 00:00:00 2001 From: Leon Matthes Date: Mon, 15 Jul 2024 16:52:44 +0200 Subject: [PATCH] Document that throwing within a slot is UB We currently don't really deal with this correctly. Until we do so, at least mention that it's UB. --- src/kdbindings/connection_evaluator.h | 2 ++ src/kdbindings/signal.h | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/kdbindings/connection_evaluator.h b/src/kdbindings/connection_evaluator.h index 64b0caa..83ffdb9 100644 --- a/src/kdbindings/connection_evaluator.h +++ b/src/kdbindings/connection_evaluator.h @@ -58,6 +58,8 @@ class ConnectionEvaluator * * This function is responsible for evaluating and executing deferred connections. * This function is thread safe. + * + * @warning Evaluating slots that throw an exception is currently undefined behavior. */ void evaluateDeferredConnections() { diff --git a/src/kdbindings/signal.h b/src/kdbindings/signal.h index 75b2c2d..ace595c 100644 --- a/src/kdbindings/signal.h +++ b/src/kdbindings/signal.h @@ -329,6 +329,10 @@ class Signal * * @return An instance of ConnectionHandle, that can be used to disconnect * or temporarily block the connection. + * + * @warning Connecting functions to a signal that throw an exception when called is currently undefined behavior. + * All connected functions should handle their own exceptions. + * For backwards-compatibility, the slot function is not required to be noexcept. */ KDBINDINGS_WARN_UNUSED ConnectionHandle connect(std::function const &slot) { @@ -346,6 +350,10 @@ class Signal * * @param slot A std::function that takes a ConnectionHandle reference followed by the signal's parameter types. * @return A ConnectionHandle to the newly established connection, allowing for advanced connection management. + * + * @warning Connecting functions to a signal that throw an exception when called is currently undefined behavior. + * All connected functions should handle their own exceptions. + * For backwards-compatibility, the slot function is not required to be noexcept. */ ConnectionHandle connectReflective(std::function const &slot) { @@ -371,6 +379,10 @@ class Signal * @note * The Signal class itself is not thread-safe. While the ConnectionEvaluator is inherently * thread-safe, ensure that any concurrent access to this Signal is protected externally to maintain thread safety. + * + * @warning Connecting functions to a signal that throw an exception when called is currently undefined behavior. + * All connected functions should handle their own exceptions. + * For backwards-compatibility, the slot function is not required to be noexcept. */ KDBINDINGS_WARN_UNUSED ConnectionHandle connectDeferred(const std::shared_ptr &evaluator, std::function const &slot) { @@ -410,6 +422,10 @@ class Signal * @return An instance of a Signal::ConnectionHandle that refers to this connection. * Warning: When connecting a member function you must use the returned ConnectionHandle * to disconnect when the object containing the slot goes out of scope! + * + * @warning Connecting functions to a signal that throw an exception when called is currently undefined behavior. + * All connected functions should handle their own exceptions. + * For backwards-compatibility, the slot function is not required to be noexcept. **/ // The enable_if_t makes sure that this connect function specialization is only // available if we provide a function that cannot be otherwise converted to a