fix:修正主动中断检查后崩溃问题。
This commit is contained in:
@@ -13,6 +13,7 @@ LoadingDialog::LoadingDialog(QWidget* parent) : QDialog(parent)
|
||||
*/
|
||||
void LoadingDialog::initUi()
|
||||
{
|
||||
isUserCancel_ = false;
|
||||
this->setFixedSize(250, 250);
|
||||
m_pCenterFrame = new QFrame(this);
|
||||
m_pCenterFrame->setGeometry(10, 10, 230, 230);
|
||||
@@ -50,7 +51,10 @@ void LoadingDialog::initUi()
|
||||
"}");
|
||||
m_pCancelBtn->setGeometry(25, 180, 180, 35);
|
||||
m_pCancelBtn->setEnabled(true);
|
||||
connect(m_pCancelBtn, &QPushButton::clicked, this, &LoadingDialog::cancelBtnClicked);
|
||||
connect(m_pCancelBtn, &QPushButton::clicked, this, [this]() {
|
||||
isUserCancel_ = true;
|
||||
cancelBtnClicked();
|
||||
});
|
||||
|
||||
// 实例阴影shadow
|
||||
QGraphicsDropShadowEffect* shadow = new QGraphicsDropShadowEffect(this);
|
||||
@@ -138,6 +142,11 @@ int LoadingDialog::exec()
|
||||
return QDialog::exec();
|
||||
}
|
||||
|
||||
bool LoadingDialog::isUserCancel() const
|
||||
{
|
||||
return isUserCancel_;
|
||||
}
|
||||
|
||||
LoadingDialog::~LoadingDialog()
|
||||
{
|
||||
delete m_pLoadingMovie;
|
||||
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
|
||||
public:
|
||||
int exec() override;
|
||||
bool isUserCancel() const;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
@@ -39,6 +40,7 @@ public slots:
|
||||
void cancelBtnClicked();
|
||||
|
||||
private:
|
||||
bool isUserCancel_{};
|
||||
QFrame* m_pCenterFrame;
|
||||
QLabel* m_pMovieLabel;
|
||||
QMovie* m_pLoadingMovie;
|
||||
|
||||
@@ -172,6 +172,11 @@ QVector<TransTask> CheckCondition::GetTasks() const
|
||||
return tasks_;
|
||||
}
|
||||
|
||||
bool CheckCondition::IsQuit() const
|
||||
{
|
||||
return isAlreadyInter_;
|
||||
}
|
||||
|
||||
void CheckCondition::recvFrame(QSharedPointer<FrameBuffer> frame)
|
||||
{
|
||||
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
|
||||
@@ -199,12 +204,18 @@ void CheckCondition::interrupCheck()
|
||||
if (!isAlreadyInter_) {
|
||||
isAlreadyInter_ = true;
|
||||
qWarning() << tr("中断文件校验......");
|
||||
tasks_.clear();
|
||||
emit sigCheckOver();
|
||||
}
|
||||
}
|
||||
|
||||
void CheckCondition::run()
|
||||
{
|
||||
if (tasks_.empty()) {
|
||||
qInfo() << tr("没有需要校验的文件或者被中断......");
|
||||
return;
|
||||
}
|
||||
|
||||
qInfo() << tr("开始文件校验......");
|
||||
isRun_ = true;
|
||||
msg_.clear();
|
||||
@@ -243,7 +254,11 @@ void CheckCondition::run()
|
||||
return;
|
||||
}
|
||||
while (isRun_) {
|
||||
QThread::msleep(10);
|
||||
QThread::msleep(1);
|
||||
if (isAlreadyInter_) {
|
||||
qInfo() << tr("线程中断文件校验等待......");
|
||||
return;
|
||||
}
|
||||
if (msg_.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ public:
|
||||
void SetClientCore(ClientCore* clientCore);
|
||||
void SetTasks(const QVector<TransTask>& tasks);
|
||||
QVector<TransTask> GetTasks() const;
|
||||
bool IsQuit() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void sigCheckOver();
|
||||
|
||||
Reference in New Issue
Block a user