fix: check before destroy callback

This commit is contained in:
dantmnf
2024-06-11 23:42:17 +08:00
parent 33bca2e82a
commit 1b2cc439f2
2 changed files with 4 additions and 3 deletions

View File

@@ -101,7 +101,9 @@ Assistant::~Assistant()
if (m_msg_thread.joinable()) {
m_msg_thread.join();
}
m_callback(static_cast<AsstMsgId>(AsstMsg::Destroyed), "{}", m_callback_arg);
if (m_callback) {
m_callback(static_cast<AsstMsgId>(AsstMsg::Destroyed), "{}", m_callback_arg);
}
}
bool asst::Assistant::set_instance_option(InstanceOptionKey key, const std::string& value)

View File

@@ -93,8 +93,7 @@ class Asst:
self.__ptr = Asst.__lib.AsstCreate()
def __del__(self):
if self.__callback:
Asst.__lib.AsstDestroy(self.__ptr)
Asst.__lib.AsstDestroy(self.__ptr)
self.__ptr = None
def set_instance_option(self, option_type: InstanceOptionType, option_value: str):