Skip to content

Conversation

@deepin-ci-robot
Copy link
Contributor

@deepin-ci-robot deepin-ci-robot commented Jul 9, 2025

Synchronize source files from linuxdeepin/dde-session-shell.

Source-pull-request: linuxdeepin/dde-session-shell#21

Summary by Sourcery

Sync upstream dde-session-shell changes: enhance plugin loader cleanup and leak prevention, update SPDX license headers, and add Spanish translations.

Enhancements:

  • Centralize plugin loader cleanup by adding cleanupPluginLoader and use QMutexLocker in ModulesLoader destructor to safely clear loaders
  • Use cleanupPluginLoader and deleteLater to free QPluginLoader and QDBusInterface instances on various error paths to prevent leaks

Documentation:

  • Update SPDX license headers and switch to GPL-3.0-or-later in source and header files
  • Add Spanish translation files for es_419, es_AR, es_CL, and es_MX locales

@sourcery-ai
Copy link

sourcery-ai bot commented Jul 9, 2025

Reviewer's Guide

This PR synchronizes upstream changes by refactoring plugin loader cleanup logic in ModulesLoader, introducing centralized cleanupPluginLoader with proper mutex locking and resource deletion, updating SPDX license headers across several source files, and importing new Spanish translation files.

Class diagram for updated ModulesLoader plugin cleanup logic

classDiagram
    class ModulesLoader {
        +~ModulesLoader()
        +void findModule(const QString& path)
        +bool isPluginEnabled(const QFileInfo& module)
        +void unloadPlugin(const QString& path)
        +void cleanupPluginLoader(QPluginLoader* loader)
        -QList<QPluginLoader*> m_pluginLoaders
        -QMutex m_mutex
    }
    class QPluginLoader {
        +bool unload()
        +void deleteLater()
        +QString errorString()
        +QObject* instance()
    }
    ModulesLoader --> QPluginLoader : manages
    ModulesLoader : +cleanupPluginLoader(loader)
    ModulesLoader : now uses cleanupPluginLoader for plugin cleanup
    ModulesLoader : uses QMutexLocker for thread safety
Loading

Class diagram for QDBusInterface resource management in isPluginEnabled

classDiagram
    class ModulesLoader {
        +bool isPluginEnabled(const QFileInfo& module)
    }
    class QDBusInterface {
        +bool isValid()
        +void deleteLater()
        +QVariant property(const char*)
    }
    ModulesLoader --> QDBusInterface : creates and deletes
    ModulesLoader : now calls deleteLater() on invalid QDBusInterface
Loading

File-Level Changes

Change Details Files
Refactor and centralize plugin loader cleanup
  • Wrap destructor cleanup in QMutexLocker and clear m_pluginLoaders
  • Introduce cleanupPluginLoader() method in ModulesLoader header and implementation
  • Replace repeated loader->unload()/deleteLater() calls with cleanupPluginLoader() in findModule
  • Add loader->deleteLater() on version and type skip cases
  • Delete QDBusInterface via deleteLater in isPluginEnabled
src/global_util/plugin_manager/modules_loader.cpp
src/global_util/plugin_manager/modules_loader.h
Add and update SPDX license headers
  • Insert SPDX-FileCopyrightText and SPDX-License-Identifier in pam_inhibit_autologin.c
  • Add SPDX license headers to fullmanagedauthwidget.h and abstractfullbackgroundinterface.h
  • Change license identifier in popupwindow.cpp and popupwindow.h from LGPL to GPL-3.0-or-later
src/pam-inhibit-autologin/pam_inhibit_autologin.c
src/session-widgets/fullmanagedauthwidget.h
src/widgets/abstractfullbackgroundinterface.h
src/widgets/popupwindow.cpp
src/widgets/popupwindow.h
Import new Spanish translation files
  • Add translations for es_419, es_AR, es_CL and es_MX locales
translations/dde-session-shell_es_419.ts
translations/dde-session-shell_es_AR.ts
translations/dde-session-shell_es_CL.ts
translations/dde-session-shell_es_MX.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @deepin-ci-robot - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `src/global_util/plugin_manager/modules_loader.cpp:358` </location>
<code_context>
     }
 }

+void ModulesLoader::cleanupPluginLoader(QPluginLoader* loader)
+{
+    if (loader) {
+        loader->unload();
+        loader->deleteLater();
+    }
+}
+
</code_context>

<issue_to_address>
cleanupPluginLoader does not handle the case where unload fails.

Check the result of loader->unload() and handle or log errors if it fails before calling deleteLater.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
void ModulesLoader::cleanupPluginLoader(QPluginLoader* loader)
{
    if (loader) {
        loader->unload();
        loader->deleteLater();
    }
}
=======
void ModulesLoader::cleanupPluginLoader(QPluginLoader* loader)
{
    if (loader) {
        if (!loader->unload()) {
            qCWarning(DDE_SHELL) << "Failed to unload plugin:" << loader->fileName() << "-" << loader->errorString();
        }
        loader->deleteLater();
    }
}
>>>>>>> REPLACE

</suggested_fix>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +358 to +363
void ModulesLoader::cleanupPluginLoader(QPluginLoader* loader)
{
if (loader) {
loader->unload();
loader->deleteLater();
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: cleanupPluginLoader does not handle the case where unload fails.

Check the result of loader->unload() and handle or log errors if it fails before calling deleteLater.

Suggested change
void ModulesLoader::cleanupPluginLoader(QPluginLoader* loader)
{
if (loader) {
loader->unload();
loader->deleteLater();
}
}
void ModulesLoader::cleanupPluginLoader(QPluginLoader* loader)
{
if (loader) {
if (!loader->unload()) {
qCWarning(DDE_SHELL) << "Failed to unload plugin:" << loader->fileName() << "-" << loader->errorString();
}
loader->deleteLater();
}
}

@deepin-ci-robot
Copy link
Contributor Author

deepin pr auto review

代码审查意见:

  1. .reuse/dep5文件中,新增的cmake部分缺少对cmake文件的详细描述,建议补充说明这些文件的作用和用途。
  2. LICENSES/GPL-3.0-or-later.txt文件中,版权声明和许可证链接的URL已更新,但应确保所有相关文件和文档的版权声明和许可证链接都已更新。
  3. src/global_util/plugin_manager/modules_loader.cpp文件中,cleanupPluginLoader函数的添加是一个好的实践,确保了资源被正确释放,避免了内存泄漏。
  4. src/global_util/plugin_manager/modules_loader.cpp文件中,findModule函数中对于QPluginLoader的删除操作应该放在continue语句之前,以确保在继续下一次循环之前清理资源。
  5. src/global_util/plugin_manager/modules_loader.cpp文件中,isPluginEnabled函数中对于QDBusInterface的删除操作应该放在return false语句之前,以确保在函数返回之前清理资源。
  6. src/pam-inhibit-autologin/pam_inhibit_autologin.c文件中,版权声明和许可证标识已经添加,这是一个好的实践,确保了代码的版权和许可证信息清晰可见。
  7. src/session-widgets/fullmanagedauthwidget.hsrc/widgets/abstractfullbackgroundinterface.hsrc/widgets/popupwindow.cppsrc/widgets/popupwindow.h等文件中,版权声明和许可证标识已经添加,这是一个好的实践,确保了代码的版权和许可证信息清晰可见。
  8. translations/dde-session-shell_es_419.tsdde-session-shell_es_AR.tsdde-session-shell_es_CL.tsdde-session-shell_es_MX.ts等文件中,部分翻译文本为空,需要根据上下文完成翻译。

以上是本次代码提交的审查意见,希望能够帮助到您。

Synchronize source files from linuxdeepin/dde-session-shell.

Source-pull-request: linuxdeepin/dde-session-shell#21
@yixinshark yixinshark merged commit 15e906b into master Jul 10, 2025
26 of 28 checks passed
@deepin-ci-robot
Copy link
Contributor Author

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: deepin-ci-robot, yixinshark

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants