Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed custom mode exceptions #589

Open
wants to merge 1 commit into
base: develop/snipe
Choose a base branch
from

Conversation

pengfeixx
Copy link
Contributor

@pengfeixx pengfeixx commented Feb 28, 2025

Fixed custom mode exceptions

Log: Fixed custom mode exceptions

Summary by Sourcery

Fixes custom mode exceptions by adjusting the logic for handling crash recovery and decode mode initialization. It ensures that settings are properly applied and persisted, and prevents potential issues during application startup and settings changes.

Fixed custom mode exceptions

Log: Fixed custom mode exceptions
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 @pengfeixx - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The repeated QEventLoop and QFileSystemWatcher setup in handleSettings and closeEvent should be extracted into a separate function.
  • Consider using an enum instead of integers for set.start.crash to improve readability and maintainability.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

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.

@@ -2877,6 +2877,12 @@ void MainWindow::handleSettings(DSettingsDialog *dsd)
dsd ->show();
#endif

static QEventLoop loop;
Copy link

Choose a reason for hiding this comment

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

issue (complexity): Consider refactoring the blocking "wait-for file change" pattern into a single helper that uses asynchronous signals instead of nested QEventLoop calls to reduce complexity.

Consider refactoring the blocking “wait‐for file change” pattern into a single helper that uses asynchronous signals instead of nested QEventLoop calls. For example, define a helper that wraps a QFileSystemWatcher and emits a signal when a file changes:

// FileWatcherHelper.h
class FileWatcherHelper : public QObject {
    Q_OBJECT
public:
    explicit FileWatcherHelper(const QString &path, QObject *parent = nullptr)
      : QObject(parent), m_fileWatcher(new QFileSystemWatcher(this)) {
        m_fileWatcher->addPath(path);
        connect(m_fileWatcher, &QFileSystemWatcher::fileChanged, this, &FileWatcherHelper::fileUpdated);
    }
signals:
    void fileUpdated();
private:
    QFileSystemWatcher *m_fileWatcher;
};

Then replace the repeated static QEventLoop and QFileSystemWatcher blocks with an asynchronous slot:

// Instead of blocking using loop.exec(), use a slot or lambda
auto watcher = new FileWatcherHelper(Settings::get().configPath(), this);
connect(watcher, &FileWatcherHelper::fileUpdated, this, [this, watcher]() {
    // Execute the logic that should run after file update
    Settings::get().setInternalOption("global_volume", m_nDisplayVolume > 100 ? 100 : m_nDisplayVolume);
    Settings::get().onSetCrash();
    m_pEngine->savePlaybackPosition();
    // Clean up watcher if no longer needed:
    watcher->deleteLater();
});

This approach removes nested loops while preserving the original functionality. Adjust other identical patterns similarly to reduce complexity and improve maintainability.

@deepin-ci-robot
Copy link

deepin pr auto review

代码审查意见:

  1. dmr_settings.cpp文件中,Settings::Settings()构造函数中新增的代码块没有注释说明其目的和功能,建议添加注释以便其他开发者理解。

  2. MainWindow::MainWindow()Platform_MainWindow::Platform_MainWindow()构造函数中,decodeInit()函数被注释掉了,但是decodeInit();被取消注释。如果这是有意为之,建议添加注释说明原因。

  3. MainWindow::handleSettings()Platform_MainWindow::handleSettings()函数中,Settings::get().settings()->setOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  4. MainWindow::closeEvent()Platform_MainWindow::closeEvent()函数中,Settings::get().onSetCrash();被移动到了保存音量值之后,这可能会改变程序的行为。建议确认这一改动是否符合预期。

  5. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,bcatch变量被声明为int类型,但是在case语句中使用了bool类型的比较。这可能会导致逻辑错误。建议将bcatch的类型改为bool,或者修改case语句中的比较操作。

  6. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  7. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,pMpvProxy->setDecodeModel()的参数类型从整数变为了DecodeMode::AUTO,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  8. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->setOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  9. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,dmr::Settings::get().crashCheck();被移动到了case 2分支中,这可能会导致逻辑错误。建议确认这一改动是否符合预期。

  10. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  11. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  12. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  13. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  14. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  15. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  16. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  17. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  18. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  19. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  20. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  21. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  22. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  23. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  24. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  25. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  26. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  27. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  28. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  29. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  30. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  31. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  32. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  33. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  34. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  35. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  36. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  37. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  38. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  39. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  40. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  41. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  42. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  43. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  44. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  45. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  46. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  47. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  48. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  49. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  50. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  51. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  52. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  53. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  54. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  55. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  56. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  57. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  58. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  59. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  60. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  61. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  62. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  63. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  64. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  65. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  66. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  67. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  68. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  69. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()的参数类型从字符串变为了整数,这可能会导致类型不匹配的问题。建议检查所有调用此函数的地方,确保参数类型一致。

  70. MainWindow::decodeInit()Platform_MainWindow::decodeInit()函数中,Settings::get().settings()->getOption()

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pengfeixx, rb-union

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

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