fix: use QLibrary to load and check library version#71
fix: use QLibrary to load and check library version#71BLumia merged 1 commit intolinuxdeepin:masterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR removes the dependency on QEventLoop in the plugin loader to prevent crashes when plugin loading fails on Arch Linux and openSUSE. The synchronous blocking approach using QEventLoop::exec() is replaced with an asynchronous sequential loading pattern using callbacks and a queue.
Key changes:
- Replaced synchronous
QEventLoopwith asynchronous sequential loading mechanism - Introduced state tracking variables to manage sequential plugin loading
- Added
loadNextPolicy()slot to handle sequential processing
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/deepin-service-manager/pluginloader.h | Added state tracking members (m_pendingPolicies, m_policyLoadInProgress, m_remainingPolicies) and loadNextPolicy() slot |
| src/deepin-service-manager/pluginloader.cpp | Replaced QEventLoop with asynchronous sequential loading pattern using timer callbacks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
814a7a1 to
3c71648
Compare
deepin pr auto review我来对这个代码修改进行审查:
新代码改用QSemaphore和递归调用loadNextPolicy()的方式,改进了这些问题:
建议改进:
建议的进一步改进: void PluginLoader::loadNextPolicy(const QList<Policy *> &pendingPolicies, QSemaphore *semaphore)
{
if (pendingPolicies.isEmpty()) {
if (semaphore) {
semaphore->release();
}
return;
}
Policy *policy = pendingPolicies.first();
QList<Policy *> remainingPolicies = pendingPolicies.mid(1);
// 添加加载进度通知
emit loadProgressChanged(pendingPolicies.size(), remainingPolicies.size());
const int delay = policy->startDelay * 1000;
QTimer::singleShot(delay, this, [this, policy, remainingPolicies, semaphore] {
ServiceBase *srv = createService(policy);
if (srv == nullptr) {
qCWarning(dsm_PluginLoader) << "Failed to create service for policy:" << policy->name;
// 可以添加失败重试机制
} else {
if (!policy->pluginPath.isEmpty()) {
addPlugin(srv);
}
}
// 使用QTimer::singleShot避免递归调用
QTimer::singleShot(0, this, [this, remainingPolicies, semaphore] {
loadNextPolicy(remainingPolicies, semaphore);
});
});
}总体来说,这次修改是正向的,提高了代码的可维护性和性能,但还可以通过添加进度通知和避免递归调用等方式进一步改进。 |
dlopen 的形式加载插件,目前在 Arch Linux 和 openSUSE 观察到崩溃在 dlclose 时. 此处改为使用 QLibrary 加载插件并检查版本. Log:
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
dlopen 的形式加载插件,目前在 Arch Linux 和 openSUSE 观察到崩溃在 dlclose 时. 此处改为使用 QLibrary 加载插件并检查版本