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: treeland font init failed #251

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

kegechen
Copy link
Contributor

@kegechen kegechen commented Dec 3, 2024

DPlatformTheme::font() is async call in treeland and will fallback to QGenericUnixTheme::font which resolveMask is FamiliesResolved|SizeResolved
defaultSystemFontName: Sans Serif (FamiliesResolved) defaultSystemFontSize: 9 (SizeResolved)
Remove the resolveMask to reset font on font changed

DPlatformTheme::font() is async call in treeland and
will fallback to `QGenericUnixTheme::font` which resolveMask is
`FamiliesResolved|SizeResolved`
defaultSystemFontName: Sans Serif (FamiliesResolved)
defaultSystemFontSize: 9 (SizeResolved)
Remove the resolveMask to reset font on font changed
@kegechen kegechen requested a review from 18202781743 December 3, 2024 08:27
deepin-ci-robot added a commit to linuxdeepin/qt6integration that referenced this pull request Dec 3, 2024
Synchronize source files from linuxdeepin/qt5integration.

Source-pull-request: linuxdeepin/qt5integration#251
@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

代码审查意见:

  1. 代码重复createUnresolveFont函数被多次调用,建议将其提取为一个公共函数,以减少代码重复。

  2. 静态变量初始化:在createUnresolveFont函数中,静态变量sysFontfixedFont在函数内部被初始化,这可能导致在多线程环境下出现竞争条件。建议将静态变量的初始化移到函数外部,或者使用Q_GLOBAL_STATIC宏来确保线程安全。

  3. 错误处理:在font_size的计算中,如果font_name.mid(font_size_index + 1).toDouble()失败,应该有错误处理机制,而不是直接返回nullptr。可以考虑抛出异常或者返回一个默认字体。

  4. 内存泄漏:如果font_name.isEmpty()为真,createUnresolveFont函数会返回一个新创建的QFont对象,但是没有相应的删除操作,可能会导致内存泄漏。建议在函数返回之前检查font_name是否为空,并在这种情况下返回一个默认的QFont对象。

  5. 代码可读性:在font函数中,if (font_name.isEmpty())的判断条件被重复使用,建议将这部分逻辑提取到一个单独的函数中,以提高代码的可读性。

  6. 线程安全QScopedPointer的使用确保了在对象不再使用时能够正确地释放内存。但是,如果createUnresolveFont函数在多线程环境下被调用,需要确保QFont对象的创建和销毁是线程安全的。

  7. 注释:代码中缺少必要的注释,特别是对于createUnresolveFont函数和setResolveMask函数的使用,这可能会影响其他开发者的理解。

综上所述,建议对代码进行重构,以提高代码的可维护性、可读性和安全性。

@kegechen kegechen requested review from mhduiy and asterwyx December 3, 2024 08:28
@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, kegechen

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

@kegechen kegechen merged commit b149d09 into linuxdeepin:master Dec 3, 2024
16 of 20 checks passed
kegechen pushed a commit to linuxdeepin/qt6integration that referenced this pull request Dec 3, 2024
Synchronize source files from linuxdeepin/qt5integration.

Source-pull-request: linuxdeepin/qt5integration#251
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