From ba34f8ec57608307ee4fc4ff38cb536e6eb31266 Mon Sep 17 00:00:00 2001 From: Rowan Walsh <1158758+rowan-walsh@users.noreply.github.com> Date: Fri, 31 Jan 2025 21:17:01 -0800 Subject: [PATCH] Fix bug with repeated log event subscription The bug was caused by the alreadySubscribedToEvents flag not being set after a successful log event subscription. This meant that plc_tag_register_logger() could be called multiple times, causing an error. --- src/libplctag/LibPlcTag.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libplctag/LibPlcTag.cs b/src/libplctag/LibPlcTag.cs index afc24a7d..30f05ce1 100644 --- a/src/libplctag/LibPlcTag.cs +++ b/src/libplctag/LibPlcTag.cs @@ -66,6 +66,8 @@ static private void ensureSubscribeToEvents() var statusAfterRegistration = (Status)_native.plc_tag_register_logger(loggerDelegate); if (statusAfterRegistration != Status.Ok) throw new LibPlcTagException(statusAfterRegistration); + + alreadySubscribedToEvents = true; } static void invokeLogEvent(int tag_id, int debug_level, string message)