fix: 修复拔掉显示器任务栏崩溃的问题

拔掉主屏幕显示器后,如果设置了仅显示在主屏,那么任务栏会找不到显示的屏幕。导致空指针从而崩溃

Log: 修复拔掉显示器任务栏崩溃的问题
Task: https://pms.uniontech.com/zentao/task-view-61658.html
Change-Id: Ic9d431fc7828039bec9600789a406bf1d8e8f15a
This commit is contained in:
范朋程 2021-02-18 15:01:45 +08:00 committed by fanpengcheng
parent 735c6f5a86
commit 5c30551353

View File

@ -90,12 +90,26 @@ public:
QMapIterator<Monitor *, MonitorInter *>it(m_monitorInfo);
while (it.hasNext()) {
it.next();
// 仅显示在主屏的情况下,可用屏幕信息只提供主屏幕
if ((!m_showInPrimary && it.key()->enable())
|| (m_showInPrimary && it.key()->name() == m_primary)) {
list << it.key();
// 仅显示在主屏的情况下,可用屏幕信息只提供主屏幕(m_primary有可能不是主屏幕的名字数据还没来得及切换过来)
// 问题场景连接双屏设置任务栏仅显示在主屏gsettings然后拔掉主屏幕显示器任务栏崩溃
if (it.key()->enable()) {
if (m_showInPrimary) {
if (it.key()->name() == m_primary) {
list.clear();
list.append(it.key());
return list;
}
if (!list.isEmpty()) {
list.removeAt(0);
list.push_front(it.key());
} else
list << it.key();
} else
list << it.key();
}
}
return list;
}
/**