@@ -12,7 +12,7 @@ bool check_version(const std::string& func_name)
1212 return false ;
1313 }
1414 auto version = version_func ();
15- LogInfo << " Version :" << version;
15+ LogInfo << typeid (ControlUnitT). name () << " Library version :" << version;
1616
1717 if (std::strcmp (version, MAA_VERSION ) != 0 ) {
1818 LogWarn << " ControlUnit and MaaFramework are not same version,"
@@ -58,7 +58,12 @@ std::shared_ptr<MAA_CTRL_UNIT_NS::ControlUnitAPI> AdbControlUnitLibraryHolder::c
5858 return nullptr ;
5959 }
6060
61- return std::shared_ptr<MAA_CTRL_UNIT_NS ::ControlUnitAPI>(control_unit_handle, destroy_control_unit_func);
61+ auto destroy_control_unit = [destroy_control_unit_func](MaaControlUnitHandle handle) {
62+ destroy_control_unit_func (handle);
63+ unload_library ();
64+ };
65+
66+ return std::shared_ptr<MAA_CTRL_UNIT_NS ::ControlUnitAPI>(control_unit_handle, destroy_control_unit);
6267}
6368
6469std::shared_ptr<MAA_CTRL_UNIT_NS ::ControlUnitAPI> DbgControlUnitLibraryHolder::create_control_unit (
@@ -94,7 +99,12 @@ std::shared_ptr<MAA_CTRL_UNIT_NS::ControlUnitAPI> DbgControlUnitLibraryHolder::c
9499 return nullptr ;
95100 }
96101
97- return std::shared_ptr<MAA_CTRL_UNIT_NS ::ControlUnitAPI>(control_unit_handle, destroy_control_unit_func);
102+ auto destroy_control_unit = [destroy_control_unit_func](MaaControlUnitHandle handle) {
103+ destroy_control_unit_func (handle);
104+ unload_library ();
105+ };
106+
107+ return std::shared_ptr<MAA_CTRL_UNIT_NS ::ControlUnitAPI>(control_unit_handle, destroy_control_unit);
98108}
99109
100110std::shared_ptr<MAA_CTRL_UNIT_NS ::ControlUnitAPI> ThriftControlUnitLibraryHolder::create_control_unit (
@@ -130,7 +140,12 @@ std::shared_ptr<MAA_CTRL_UNIT_NS::ControlUnitAPI> ThriftControlUnitLibraryHolder
130140 return nullptr ;
131141 }
132142
133- return std::shared_ptr<MAA_CTRL_UNIT_NS ::ControlUnitAPI>(control_unit_handle, destroy_control_unit_func);
143+ auto destroy_control_unit = [destroy_control_unit_func](MaaControlUnitHandle handle) {
144+ destroy_control_unit_func (handle);
145+ unload_library ();
146+ };
147+
148+ return std::shared_ptr<MAA_CTRL_UNIT_NS ::ControlUnitAPI>(control_unit_handle, destroy_control_unit);
134149}
135150
136151MAA_CTRL_NS_END
0 commit comments