From be939cb6366a5cafed1a62ce71b058525582a85d Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 7 Oct 2023 20:42:55 -0700 Subject: [PATCH] [ntcore] Fix notification of SetDefaultEntryValue (#5733) --- ntcore/src/main/native/cpp/LocalStorage.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ntcore/src/main/native/cpp/LocalStorage.cpp b/ntcore/src/main/native/cpp/LocalStorage.cpp index ecece47761..98ab73bc02 100644 --- a/ntcore/src/main/native/cpp/LocalStorage.cpp +++ b/ntcore/src/main/native/cpp/LocalStorage.cpp @@ -954,17 +954,20 @@ bool LocalStorage::Impl::SetDefaultEntryValue(NT_Handle pubsubentryHandle, if (topic->type == NT_UNASSIGNED) { topic->type = value.type(); } + Value newValue; if (topic->type == value.type()) { - topic->lastValue = value; + newValue = value; } else if (IsNumericCompatible(topic->type, value.type())) { - topic->lastValue = ConvertNumericValue(value, topic->type); + newValue = ConvertNumericValue(value, topic->type); } else { return true; } - topic->lastValue.SetTime(0); - topic->lastValue.SetServerTime(0); + newValue.SetTime(0); + newValue.SetServerTime(0); if (publisher) { - PublishLocalValue(publisher, topic->lastValue, true); + PublishLocalValue(publisher, newValue, true); + } else { + topic->lastValue = newValue; } return true; }