Skip to content

Commit 15fc69c

Browse files
shuaijiedeepin-bot[bot]
authored andcommitted
fix: 修复窗口偶现闪退
调用DApplication setOverrideCursor窗口偶现闪退 Log: 修复窗口偶现闪退 Bug: https://pms.uniontech.com/bug-view-251039.html
1 parent fd48a57 commit 15fc69c

4 files changed

Lines changed: 31 additions & 18 deletions

File tree

deepin-devicemanager/src/GenerateDevice/LoadInfoThread.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
DWIDGET_USE_NAMESPACE
2121
static bool firstLoadFlag = true;
22+
2223
LoadInfoThread::LoadInfoThread()
2324
: mp_ReadFilePool()
2425
, mp_GenerateDevicePool()
@@ -99,8 +100,6 @@ void LoadInfoThread::run()
99100

100101
emit finished("finish");
101102
m_Running = false;
102-
// 一定要有否则指针一直显示圆圈与setOverrideCursor成对使用
103-
DApplication::restoreOverrideCursor();
104103
}
105104

106105
void LoadInfoThread::slotFinishedReadFilePool(const QString &)
@@ -109,11 +108,7 @@ void LoadInfoThread::slotFinishedReadFilePool(const QString &)
109108
// 首次加载刷新
110109
if (firstLoadFlag) {
111110
firstLoadFlag = false;
112-
DBusInterface::getInstance()->refreshInfo();
113-
QTimer::singleShot(2000, this, [ = ]() { //test the x86 the fast desktop PC need 2s
114-
DApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
115-
start();
116-
});
111+
emit finishedReadFilePool();
117112
}
118113
}
119114

deepin-devicemanager/src/GenerateDevice/LoadInfoThread.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class LoadInfoThread : public QThread
2626

2727
signals:
2828
void finished(const QString &message);
29+
void finishedReadFilePool();
2930

3031
protected:
3132
void run() override;

deepin-devicemanager/src/Page/MainWindow.cpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ MainWindow::MainWindow(QWidget *parent)
122122
txgpu.start();
123123
txgpu.wait();
124124
monitorNumber = txgpu.getMonitorNumber();
125+
connect(mp_WorkingThread, &LoadInfoThread::finishedReadFilePool, this, [ = ]() {
126+
refreshDataBaseLater();
127+
});
128+
}
129+
void MainWindow::refreshDataBaseLater()
130+
{
131+
DBusInterface::getInstance()->refreshInfo();
132+
QTimer::singleShot(2000, this, [ = ]() { //test the x86 the fast desktop PC need 2s
133+
// 加载设备信息
134+
refreshDataBase();
135+
});
125136
}
126137

127138
MainWindow::~MainWindow()
@@ -408,11 +419,14 @@ void MainWindow::initWidgets()
408419

409420
void MainWindow::refreshDataBase()
410421
{
411-
// 设置应用程序强制光标为cursor
412-
DApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
413-
414-
if (mp_WorkingThread)
422+
if (mp_WorkingThread) {
423+
/* 一定要与 restoreOverrideCursor 成对使用*/
424+
if(!m_statusCursorIsWait) {
425+
DApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
426+
m_statusCursorIsWait = true;
427+
}
415428
mp_WorkingThread->start();
429+
}
416430
}
417431

418432
void MainWindow::slotSetPage(QString page)
@@ -437,8 +451,11 @@ void MainWindow::slotLoadingFinish(const QString &message)
437451
if (message == "finish") {
438452
begin = true;
439453

440-
// 一定要有否则指针一直显示圆圈与setOverrideCursor成对使用
454+
/* 一定要有与 setOverrideCursor 成对使用 否则指针一直显示圆圈*/
455+
if( m_statusCursorIsWait) {
456+
m_statusCursorIsWait = false;
441457
DApplication::restoreOverrideCursor();
458+
}
442459

443460
// 信息显示界面
444461
// 获取设备类型列表
@@ -523,11 +540,7 @@ void MainWindow::slotListItemClicked(const QString &itemStr)
523540
DBusInterface::getInstance()->getInfo("is_server_running", info);
524541
//请求后台更新信息
525542
if (!info.toInt()) {
526-
DBusInterface::getInstance()->refreshInfo();
527-
QTimer::singleShot(2000, this, [ = ]() {
528-
// 加载设备信息
529-
refreshDataBase();
530-
});
543+
refreshDataBaseLater();
531544
}
532545
qDebug()<< "Monitor refreshInfo" << __LINE__ << QDateTime::currentDateTime().toString("hh:mm:ss") << info << monitorNumber;
533546
monitorNumber = txgpu.getMonitorNumber();

deepin-devicemanager/src/Page/MainWindow.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ class MainWindow : public DMainWindow
117117
* @brief refreshDataBase:刷新设备信息
118118
*/
119119
void refreshDataBase();
120-
120+
/**
121+
* @brief refreshDataBaseLater:刷新设备信息
122+
*/
123+
void refreshDataBaseLater();
121124
private slots:
122125
/**
123126
* @brief slotSetPage
@@ -170,6 +173,7 @@ private slots:
170173
bool m_refreshing = false; // 判断界面是否正在刷新
171174
bool m_IsFirstRefresh = true;
172175
bool m_ShowDriverPage = false;
176+
bool m_statusCursorIsWait = false;
173177
};
174178

175179
#endif // MAINWINDOW_H

0 commit comments

Comments
 (0)