Multi thread error raise support
This commit is contained in:
@@ -40,12 +40,15 @@ std::string getJsonFromPatInf(QObject* obj)
|
||||
|
||||
void ErrorCallback(const char * msg)
|
||||
{
|
||||
DeviceManager::Default()->setErrorOccurred(true);
|
||||
printf("Error Callback , message:%s\r\n", msg);
|
||||
QString m(msg);
|
||||
THROW_ERROR(m);
|
||||
DeviceManager::Default()->emitErrorCallback(msg);
|
||||
}
|
||||
|
||||
void DeviceManager::emitErrorCallback(const char *msg) {
|
||||
this->setErrorOccurred(true);
|
||||
printf("Error Callback , message:%s\r\n", msg);
|
||||
QString m(msg);
|
||||
emit raiseGlobalError( m);
|
||||
}
|
||||
|
||||
|
||||
void DeviceManager::initDevice() {
|
||||
|
||||
@@ -22,6 +22,9 @@ public:
|
||||
bool getErrorOccurred(){
|
||||
return errorOccurred;
|
||||
}
|
||||
void emitErrorCallback(const char * msg);
|
||||
signals:
|
||||
void raiseGlobalError(QString msg);
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent* event) override ;
|
||||
|
||||
@@ -161,6 +161,7 @@ MainWindow::MainWindow(QWidget* parent) :
|
||||
}
|
||||
qApp->processEvents();
|
||||
});
|
||||
connect(DeviceManager::Default(),&DeviceManager::raiseGlobalError,this,&MainWindow::triggerError,Qt::ConnectionType::QueuedConnection);
|
||||
GUIErrorHandle::Default()->init();
|
||||
l = new LoginWindow(this);
|
||||
QThread* t = QThread::create([]() {
|
||||
@@ -262,3 +263,9 @@ void MainWindow::debugConsoleOn() {
|
||||
//clear buffer before redirect;
|
||||
this->console = text_edit;
|
||||
}
|
||||
|
||||
void MainWindow::triggerError(const QString & msg) {
|
||||
QString s(msg);
|
||||
qDebug()<<"invoke trigger error slot msg:"<<msg;
|
||||
EventCenter::Default()->triggerEvent(GUIErrorRaise, nullptr,(QObject*)&s);
|
||||
}
|
||||
|
||||
@@ -28,10 +28,12 @@ public:
|
||||
void requestLogin();
|
||||
QTextEdit* getEdit();
|
||||
void debugConsoleOn();
|
||||
|
||||
public slots:
|
||||
void triggerError(const QString&);
|
||||
protected:
|
||||
void changeEvent(QEvent* event);
|
||||
|
||||
|
||||
private:
|
||||
void loadStyleSheet(const QString& sheetName);
|
||||
cJSON* json_root = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user