From 765075b1d0534f84934e73cee97dd33fc8448b27 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 3 Mar 2026 21:35:11 -1000 Subject: [PATCH] tweaks --- esphome/components/api/proto.h | 3 ++- script/api_protobuf/api_protobuf.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/esphome/components/api/proto.h b/esphome/components/api/proto.h index cf03f48be8..702208d9de 100644 --- a/esphome/components/api/proto.h +++ b/esphome/components/api/proto.h @@ -468,7 +468,8 @@ class ProtoMessage { virtual const char *message_name() const { return "unknown"; } #endif - // Non-virtual: messages are never deleted polymorphically. + protected: + // Non-virtual destructor is protected to prevent polymorphic deletion. ~ProtoMessage() = default; }; diff --git a/script/api_protobuf/api_protobuf.py b/script/api_protobuf/api_protobuf.py index b00cbab37a..85352689e6 100755 --- a/script/api_protobuf/api_protobuf.py +++ b/script/api_protobuf/api_protobuf.py @@ -280,6 +280,9 @@ class TypeInfo(ABC): """ field_id_size = self.calculate_field_id_size() method = f"calc_{base_method}_force" if force else f"calc_{base_method}" + # calc_bool_force only takes field_id_size (no value needed - bool is always 1 byte) + if base_method == "bool" and force: + return f"size += ProtoSize::{method}({field_id_size});" value = value_expr or name return f"size += ProtoSize::{method}({field_id_size}, {value});"