QSSASyncProcess修复重复connect导致的触发问题。

qt6
zcy 2022-10-28 15:12:59 +08:00
parent 43cd74b18f
commit c1890fb547
2 changed files with 7 additions and 3 deletions

View File

@ -1946,6 +1946,7 @@ void QssMaskWidget::paintEvent(QPaintEvent *event)
} }
QSSASyncProcess::QSSASyncProcess(QWidget *parent) QSSASyncProcess::QSSASyncProcess(QWidget *parent)
:mFirst(true)
{ {
this->mParent = parent; this->mParent = parent;
} }
@ -1959,9 +1960,11 @@ QSSASyncProcess::~QSSASyncProcess()
int QSSASyncProcess::Start(void *p) int QSSASyncProcess::Start(void *p)
{ {
this->moveToThread(&mThread); this->moveToThread(&mThread);
if(mFirst){
connect(this, SIGNAL(StartRun(void *)), this, SLOT(Run(void *))); connect(this, SIGNAL(StartRun(void *)), this, SLOT(Run(void *)));
connect(&mThread, &QThread::finished, this, &QObject::deleteLater); connect(&mThread, &QThread::finished, this, &QObject::deleteLater);
mFirst = false;
}
mThread.start(); mThread.start();
#ifdef QT_NO_EMIT #ifdef QT_NO_EMIT
StartRun(p); StartRun(p);

1
Qss.h
View File

@ -426,6 +426,7 @@ public slots:
protected: protected:
QWidget *mParent; QWidget *mParent;
QThread mThread; QThread mThread;
bool mFirst;
}; };
#define tipBox(text) QssMessageBox::tips(text) #define tipBox(text) QssMessageBox::tips(text)