Commit f4d11e7
committed
refactor: move plugin factory preparation before module loading
1. Extracted plugin factory preparation logic from
LoadPluginTask::doLoadSo() into new method preparePluginFactory()
2. Modified LoadPluginTask::doLoadSo() to LoadPluginTask::createData()
that uses pre-prepared factory
3. Added factory pointer to PluginData structure to store prepared
factory instance
4. Moved factory preparation to occur before loadModule() in plugin
loading sequence
5. Simplified createData() method to focus only on object creation from
factory
6. Added proper cleanup of factory pointer in PluginManager destructor
This refactoring separates factory preparation from object creation,
allowing factory initialization to happen earlier in the plugin loading
process. The change improves code organization by separating concerns:
factory loading/validation vs. object instantiation. This prepares
for potential optimizations where factory preparation could be done in
parallel or at different stages of application startup.
Influence:
1. Verify plugin loading still works correctly for all control center
modules
2. Test plugin loading with both valid and invalid .so files
3. Verify error handling when factory preparation fails
4. Test memory management and cleanup of factory instances
5. Ensure plugin status updates are still emitted correctly
6. Verify thread safety during factory preparation and object creation
7. Test with plugins that have parent/child relationships in their
created objects
refactor: 将插件工厂准备逻辑前移到模块加载之前执行
1. 从 LoadPluginTask::doLoadSo() 中提取插件工厂准备逻辑到新的
preparePluginFactory() 方法
2. 将 LoadPluginTask::doLoadSo() 重命名为 LoadPluginTask::createData(),
使用预先准备的工厂
3. 在 PluginData 结构中添加工厂指针以存储准备好的工厂实例
4. 将工厂准备移动到插件加载序列中的 loadModule() 之前执行
5. 简化 createData() 方法,专注于从工厂创建对象
6. 在 PluginManager 析构函数中添加工厂指针的适当清理
此次重构将工厂准备与对象创建分离,允许工厂初始化在插件加载过程的更早阶段
进行。这一改动通过分离关注点(工厂加载/验证 vs. 对象实例化)改善了代码组
织。这为潜在的优化做好了准备,工厂准备可以并行进行或在应用程序启动的不同
阶段执行。
Influence:
1. 验证所有控制中心模块的插件加载是否仍然正常工作
2. 测试使用有效和无效 .so 文件的插件加载
3. 验证工厂准备失败时的错误处理
4. 测试工厂实例的内存管理和清理
5. 确保插件状态更新仍然正确发出
6. 验证工厂准备和对象创建期间的线程安全性
7. 测试具有父子关系的插件对象的创建1 parent 2b4569d commit f4d11e7
2 files changed
Lines changed: 70 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| |||
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| 91 | + | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
| |||
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
114 | | - | |
| 116 | + | |
115 | 117 | | |
116 | 118 | | |
117 | 119 | | |
| |||
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
124 | | - | |
| 126 | + | |
125 | 127 | | |
126 | 128 | | |
127 | 129 | | |
128 | | - | |
| 130 | + | |
129 | 131 | | |
130 | | - | |
131 | | - | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
142 | 144 | | |
143 | | - | |
144 | | - | |
145 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
146 | 148 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
177 | 152 | | |
178 | | - | |
179 | | - | |
180 | 153 | | |
181 | 154 | | |
182 | 155 | | |
| |||
192 | 165 | | |
193 | 166 | | |
194 | 167 | | |
195 | | - | |
| 168 | + | |
196 | 169 | | |
197 | 170 | | |
198 | 171 | | |
| |||
224 | 197 | | |
225 | 198 | | |
226 | 199 | | |
| 200 | + | |
227 | 201 | | |
228 | 202 | | |
229 | 203 | | |
| |||
305 | 279 | | |
306 | 280 | | |
307 | 281 | | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
308 | 325 | | |
309 | 326 | | |
310 | 327 | | |
| |||
341 | 358 | | |
342 | 359 | | |
343 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
344 | 365 | | |
345 | 366 | | |
346 | 367 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
42 | 41 | | |
43 | 42 | | |
44 | 43 | | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
0 commit comments