Skip to content

Commit 220cb2c

Browse files
committed
refactor/utilities: 优化 PluginClient 构造函数和成员变量初始化
- 在 PluginClient 构造函数中使用 HKU_CHECK 宏检查插件加载是否成功 - 初始化 m_impl 成员变量为 nullptr,确保其始终处于有效状态
1 parent 9356bc0 commit 220cb2c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

hikyuu/utilities/plugin/PluginClient.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class PluginClient : public InterfaceT {
1717
PluginClient() = delete;
1818
PluginClient(const std::string &path, const std::string &filename) {
1919
m_loader = std::make_unique<PluginLoader>(path);
20-
m_loader->load(filename);
20+
HKU_CHECK(m_loader->load(filename), "load plugin failed! {}/{}", path, filename);
2121
m_impl = m_loader->instance<InterfaceT>();
2222
}
2323
virtual ~PluginClient() = default;
@@ -46,7 +46,7 @@ class PluginClient : public InterfaceT {
4646
}
4747

4848
protected:
49-
InterfaceT *m_impl;
49+
InterfaceT *m_impl{nullptr};
5050

5151
protected:
5252
std::unique_ptr<PluginLoader> m_loader;

0 commit comments

Comments
 (0)