-
Notifications
You must be signed in to change notification settings - Fork 80
fix: Enhance destruction safety in capture management during applicat… #775
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: Enhance destruction safety in capture management during applicat… #775
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);
}
}这些改进主要关注于:
|
|
[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 |
|
/merge |
|
This pr cannot be merged! (status: unstable) |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
d18e6fa
into
linuxdeepin:develop/snipe
…ion shutdown
fix: 在应用退出时增强捕获管理的销毁安全性
bug: https://pms.uniontech.com/bug-view-342837.html