fix: Enhance destruction safety in capture management during applicat…#775
Merged
deepin-bot[bot] merged 1 commit intoDec 11, 2025
Merged
fix: Enhance destruction safety in capture management during applicat…#775deepin-bot[bot] merged 1 commit into
deepin-bot[bot] merged 1 commit into
Conversation
…ion shutdown - Updated destruction logic in TreelandCaptureManager and TreelandCaptureContext to skip operations when the application is closing down, preventing potential crashes. - Introduced a new destroySession method to safely handle session destruction with appropriate checks for initialization and manager activity. - Improved logging to provide clearer insights during the destruction process, ensuring better debugging and stability in Wayland environments. fix: 在应用退出时增强捕获管理的销毁安全性 - 更新 TreelandCaptureManager 和 TreelandCaptureContext 的销毁逻辑:应用关闭时跳过相关操作,避免潜在崩溃。 - 新增 destroySession 方法:在会话销毁前检查初始化状态与管理器活跃度,确保安全退出。 - 改进日志:在销毁流程中提供更清晰的日志,便于 Wayland 环境下的调试和稳定性分析。 bug: https://pms.uniontech.com/bug-view-342837.html
deepin pr auto review我来对这段代码进行审查:
在 TreelandCaptureManager 析构函数中:
在 TreelandCaptureContext 析构函数中:
在 main_window.cpp 中的 onTreelandSwitchToRecordUI() 方法:
具体改进建议: // 在 TreelandCaptureManager 析构函数中
if (QCoreApplication::closingDown()) {
qCWarning(dsrApp) << "Skip TreelandCaptureManager::destroy because app closing down";
} else if (isActive() && waylandDisplay()) {
destroy();
// 销毁 Wayland 扩展
} else {
qCWarning(dsrApp) << "Skip TreelandCaptureManager::destroy - inactive or invalid display";
}
// 在 destroySession() 中
void TreelandCaptureContext::destroySession()
{
if (!m_session) {
return;
}
qCDebug(dsrApp) << "Log: TreelandCaptureContext::destroySession - destroying session object.";
if (QCoreApplication::closingDown()) {
qCWarning(dsrApp) << "Skip session destroy because app closing down";
} else {
auto manager = TreelandCaptureManager::instance();
if (manager && manager->isActive() && m_session->isInitialized()) {
m_session->destroy();
} else {
qCWarning(dsrApp) << "Skip session destroy because not initialized or manager inactive";
}
}
// 先释放资源再删除对象
m_session->cleanup(); // 如果有清理资源的方法
delete m_session;
m_session = nullptr;
Q_EMIT sessionChanged();
}
// 在 main_window.cpp 中抽取工具栏配置方法
void MainWindow::setupToolBarForTreeland()
{
if (!m_toolBar) {
return;
}
m_toolBar->setAttribute(Qt::WA_ShowWithoutActivating, true);
m_toolBar->setFocusPolicy(Qt::NoFocus);
m_toolBar->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool |
Qt::WindowStaysOnTopHint | Qt::BypassWindowManagerHint);
if (m_toolBar->windowHandle()) {
m_toolBar->windowHandle()->setParent(nullptr);
}
}这些改进主要关注于:
|
lzwind
approved these changes
Dec 11, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengzhongyuan365-dev, lzwind 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 |
Member
Author
|
/merge |
Contributor
|
This pr cannot be merged! (status: unstable) |
Member
Author
|
/forcemerge |
Contributor
|
This pr force merged! (status: unstable) |
d18e6fa
into
linuxdeepin:develop/snipe
6 of 7 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…ion shutdown
fix: 在应用退出时增强捕获管理的销毁安全性
bug: https://pms.uniontech.com/bug-view-342837.html