diff --git a/runner17/lpbengine.dll b/runner17/lpbengine.dll index dee7322..9717482 100644 Binary files a/runner17/lpbengine.dll and b/runner17/lpbengine.dll differ diff --git a/runner17/lpbengined.dll b/runner17/lpbengined.dll index b7bb41e..da1de4f 100644 Binary files a/runner17/lpbengined.dll and b/runner17/lpbengined.dll differ diff --git a/runner17/lpdesigner.dll b/runner17/lpdesigner.dll index e7832e4..855843d 100644 Binary files a/runner17/lpdesigner.dll and b/runner17/lpdesigner.dll differ diff --git a/runner17/lpdesignerd.dll b/runner17/lpdesignerd.dll index 9fbe23e..72a68d5 100644 Binary files a/runner17/lpdesignerd.dll and b/runner17/lpdesignerd.dll differ diff --git a/src/lpMain/CoreCtrl/QDetectorDesignerMgr.cpp b/src/lpMain/CoreCtrl/QDetectorDesignerMgr.cpp index b94fa2b..9f7f0fe 100644 --- a/src/lpMain/CoreCtrl/QDetectorDesignerMgr.cpp +++ b/src/lpMain/CoreCtrl/QDetectorDesignerMgr.cpp @@ -8,7 +8,7 @@ QDetectorDesignerMgr::QDetectorDesignerMgr() QDetectorDesignerMgr::~QDetectorDesignerMgr() { -// Quit(); + Quit(); } bool QDetectorDesignerMgr::Initialize(IDetectorEngine* lpDE) @@ -29,7 +29,7 @@ bool QDetectorDesignerMgr::Initialize(IDetectorEngine* lpDE) qDebug() << "lib load ok"; FnLpDesignerNewInstance pfnLpNewInstance = (FnLpDesignerNewInstance)m_lib.resolve("LpDesignerNewInstance"); if (pfnLpNewInstance) - pfnLpNewInstance(&m_pDesigner, m_pDE, this); + pfnLpNewInstance(&m_pDesigner, m_pDE, nullptr); if (!m_pDesigner) return false; @@ -44,13 +44,14 @@ IDetectorUI* QDetectorDesignerMgr::GetDesignerInterface() const void QDetectorDesignerMgr::Quit() { - if (m_lib.isLoaded()) - m_lib.unload(); + if (m_pDesigner) { delete m_pDesigner; m_pDesigner = NULL; - } + } + if (m_lib.isLoaded()) + m_lib.unload(); } void QDetectorDesignerMgr::OnManualTrigger() diff --git a/src/lpMain/CoreCtrl/QDetectorDesignerMgr.h b/src/lpMain/CoreCtrl/QDetectorDesignerMgr.h index c1931ed..60c7ada 100644 --- a/src/lpMain/CoreCtrl/QDetectorDesignerMgr.h +++ b/src/lpMain/CoreCtrl/QDetectorDesignerMgr.h @@ -5,7 +5,7 @@ #include ".\lpdesigner.h" #include "qobject.h" -class QDetectorDesignerMgr : public QObject, public IDetectorUISink +class QDetectorDesignerMgr : public QObject { Q_OBJECT public: diff --git a/src/lpMain/ModelTable.cpp b/src/lpMain/ModelTable.cpp index 226a3cf..727b18d 100644 --- a/src/lpMain/ModelTable.cpp +++ b/src/lpMain/ModelTable.cpp @@ -92,6 +92,7 @@ ModelView::ModelView(QTableView *pView, IStation *pStation) m_pView->setSelectionBehavior(QAbstractItemView::SelectRows); //QObject::connect(pView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(onSelectItem(const QModelIndex&))); m_pModel = new ModelModel(pStation); + m_pModel->setParent(this); m_pView->setModel(m_pModel); } diff --git a/src/lpMain/WfColossus.cpp b/src/lpMain/WfColossus.cpp index 1ec48ac..f408447 100644 --- a/src/lpMain/WfColossus.cpp +++ b/src/lpMain/WfColossus.cpp @@ -336,6 +336,8 @@ QString WfColossus::combineWithSymbol(QString s1, QString s2) class IDetectorSolutionMgr * WfColossus::ptrSolMgr() const { + if (!m_pDetEngine) + return nullptr; void * p; m_pDetEngine->GetDataInterface(SOLUTIONMGR, &p); return (IDetectorSolutionMgr*)p; diff --git a/src/lpMain/WfCtrl.cpp b/src/lpMain/WfCtrl.cpp index 1af3a32..eb4a46d 100644 --- a/src/lpMain/WfCtrl.cpp +++ b/src/lpMain/WfCtrl.cpp @@ -14,7 +14,7 @@ CWfCtrl::CWfCtrl(ICoreCtrl* p1, WfColossus* p3) { m_nOnlineMode = false; - //m_pConnectChecker = new WorkChecker; + m_pConnectChecker = new WorkChecker; m_pCoreCtrl = p1; m_pColossus = p3; m_setting = new QSettings(QCoreApplication::applicationDirPath()+"\\user\\systemfile.ini", QSettings::IniFormat); @@ -67,8 +67,16 @@ CWfCtrl::~CWfCtrl() } m_pDCThreadList.clear(); //m_pColossus->setOnlineModel(m_nOnlineMode); - delete m_pConnectChecker; - delete m_pWfDb; + if (m_pConnectChecker) + { + delete m_pConnectChecker; + m_pConnectChecker = nullptr; + } + if (m_pWfDb) { + delete m_pWfDb; + m_pWfDb = nullptr; + } + qDeleteAll(m_pStationMap); m_pStationMap.clear(); qDeleteAll(m_mpModels); @@ -138,6 +146,8 @@ bool CWfCtrl::initModel() bool CWfCtrl::initStation() { + if (!m_pCoreCtrl) + return false; QStringList camKeys = m_pCoreCtrl->ICameraKeys(); for (QStringList::iterator it = camKeys.begin(); it != camKeys.end(); ++it) { TP_CAMERA_OPTION camOpt; diff --git a/tpvs17/Enchanter/main.cpp b/tpvs17/Enchanter/main.cpp index 847ad79..0f5f784 100644 --- a/tpvs17/Enchanter/main.cpp +++ b/tpvs17/Enchanter/main.cpp @@ -31,5 +31,11 @@ int main(int argc, char *argv[]) else { QMessageBox::information(0, "", QObject::tr("lpMain加载失败")); } + if (pMain) { + delete pMain; + pMain = nullptr; + } + if (lib.isLoaded()) + lib.unload(); return 0; } diff --git a/tpvs17/lpMain/CMainWin.cpp b/tpvs17/lpMain/CMainWin.cpp index c9c0859..8909a26 100644 --- a/tpvs17/lpMain/CMainWin.cpp +++ b/tpvs17/lpMain/CMainWin.cpp @@ -40,11 +40,7 @@ CMainWin::CMainWin(QWidget *parent) connect(m_pCameraTrig, SIGNAL(sgTrig()), this, SLOT(onTrigImage())); onInitStatus(); - if (!m_DesignerMgr.Initialize(m_pDetectorEngine)) { - qWarning() << "Initialize is false"; - - } - connect(&m_DesignerMgr, SIGNAL(sgCloseWindow()), this, SLOT(onMainFrameClose())); + connect(m_pDesignerMgr, SIGNAL(sgCloseWindow()), this, SLOT(onMainFrameClose())); connect(&m_testWid, SIGNAL(sgTestMode(int)), this, SLOT(onTestMode(int))); m_pColossus = new WfColossus(m_pDetectorEngine); @@ -126,11 +122,22 @@ CMainWin::CMainWin(QWidget *parent) CMainWin::~CMainWin() { - if (m_pStatus) { - DELETE_POINTER(m_pStatusTrig); - DELETE_POINTER(m_pStatus); + if (m_pDllDetectorEngine) + { + delete m_pDllDetectorEngine; + m_pDllDetectorEngine = nullptr; + } + //load coretrl + if (m_pDllCoreCtrl) + { + delete m_pDllCoreCtrl; + m_pDllCoreCtrl = nullptr; } - DELETE_POINTER(m_pVersion); +// if (m_pDesignerMgr) +// { +// delete m_pDesignerMgr; +// m_pDesignerMgr = nullptr; +// } DELETE_POINTER(m_pCameraTrig); DELETE_POINTER(m_pWfCtrl); DELETE_POINTER(m_pColossus); @@ -195,7 +202,7 @@ void CMainWin::IVariantMapToUI(emTpUiDataType dataType, const QString& camKey, c QString str2 = pStation->currentRunningModel(); int ID = pStation->stationId(); QString strModelName = QString("%1_%2").arg(ID).arg(str2); - QString strImgPath;// = genSavePath(strModelName, image); + QString strImgPath = genSavePath(strModelName, image); Struct2SaveData nStructData; nStructData.dAngle = dAngle; nStructData.errorType = errorType; @@ -610,14 +617,14 @@ void CMainWin::onInitStatus() m_pLbConnect = new class QLabel(QObject::tr("连接状态:")); m_pLbConnect->setMinimumWidth(c_nWidth); - m_pLbDiskSpace = new class QLabel(QObject::tr("硬盘剩余空间:xxx.xG")); - m_pLbDiskSpace->setMinimumWidth(c_nWidth); + //m_pLbDiskSpace = new class QLabel(QObject::tr("硬盘剩余空间:xxx.xG")); + //m_pLbDiskSpace->setMinimumWidth(c_nWidth); ui.statusBar->addWidget(m_pLbOnLine); ui.statusBar->addWidget(m_pLbConnect); ui.statusBar->addWidget(m_pLbUser); ui.statusBar->addWidget(m_pLbCurrentTime); - ui.statusBar->addWidget(m_pLbDiskSpace); + //ui.statusBar->addWidget(m_pLbDiskSpace); } void CMainWin::onUpdateStatus() @@ -628,28 +635,28 @@ void CMainWin::onUpdateStatus() //m_pLbCurrentTime->setStyleSheet("font: 14px;"); } -// if (m_pLbOnLine && m_pCtrl) { -// QString strOnlineState = QString(QObject::tr("检测模式:")) -// + (m_pCtrl->IOnlineMode() == true ? QObject::tr("在线模式") : QObject::tr("离线模式")); -// m_pLbOnLine->setText(strOnlineState); -// // m_pLbOnLine->setStyleSheet("font: bold 14px;"); -// } + if (m_pLbOnLine && m_pWfCtrl) { + QString strOnlineState = QString(QObject::tr("检测模式:")) + + (m_pWfCtrl->IOnlineMode() == true ? QObject::tr("在线模式") : QObject::tr("离线模式")); + m_pLbOnLine->setText(strOnlineState); + // m_pLbOnLine->setStyleSheet("font: bold 14px;"); + } - if (m_pLbConnect) { + if (m_pLbConnect && m_pWfCtrl) { QString strOnlineState = QString(QObject::tr("连接状态:")) - + (true == true ? QObject::tr("连接正常") : QObject::tr("连接异常")); + + (m_pWfCtrl->IConnectStatus() == true ? QObject::tr("连接正常") : QObject::tr("连接异常")); m_pLbConnect->setText(strOnlineState); } if (m_pLbUser) { - QString strUser; - m_pLbUser->setText(QObject::tr("用户: ") + strUser); - } - if (m_pLbDiskSpace) - { - QString strDiskSpace = QString(QObject::tr("硬盘剩余空间:%1G")).arg(100 / 1024.0); - m_pLbDiskSpace->setText(strDiskSpace); + + m_pLbUser->setText(QObject::tr("用户: ") + m_strUserName.isEmpty()==true?QObject::tr("未登录"):m_strUserName); } +// if (m_pLbDiskSpace) +// { +// QString strDiskSpace = QString(QObject::tr("硬盘剩余空间:%1G")).arg(100 / 1024.0); +// m_pLbDiskSpace->setText(strDiskSpace); +// } } bool CMainWin::onInitCoreCtrl() @@ -676,6 +683,13 @@ bool CMainWin::onInitCoreCtrl() } m_pDllDetectorEngine->Initialize(m_pCoreCtrl); + if (NULL == m_pDesignerMgr) + { + m_pDesignerMgr = new QDetectorDesignerMgr(); + if (!m_pDesignerMgr->Initialize(m_pDetectorEngine)) { + qWarning() << "Initialize is false"; + } + } return true; } @@ -788,7 +802,9 @@ void CMainWin::writeConfig() IDetectorUI* CMainWin::GetDesignerInterface() const { - return m_DesignerMgr.GetDesignerInterface(); + if (m_pDesignerMgr) + return m_pDesignerMgr->GetDesignerInterface(); + return nullptr; } void CMainWin::saveSolution() @@ -867,6 +883,7 @@ Q_SLOT void CMainWin::onLogInOut(QString strName, int level, int state) if (m_pWfCtrl) { m_pWfCtrl->ISetUserInfo(strName, level); onChangeUI(strName, level); + m_strUserName = strName; } if (state == 0) { diff --git a/tpvs17/lpMain/CMainWin.h b/tpvs17/lpMain/CMainWin.h index 56f1e6e..4e44905 100644 --- a/tpvs17/lpMain/CMainWin.h +++ b/tpvs17/lpMain/CMainWin.h @@ -80,7 +80,6 @@ private:// private: IDetectorUI* GetDesignerInterface() const; - QDetectorDesignerMgr m_DesignerMgr; void saveSolution(); int lastNum(QString str); Q_SLOT void onMainFrameClose(); @@ -116,22 +115,22 @@ private: private: CDllCoreCtrl* m_pDllCoreCtrl{nullptr}; CDllDetectorEngine* m_pDllDetectorEngine{nullptr}; + QDetectorDesignerMgr* m_pDesignerMgr{nullptr}; ICoreCtrl* m_pCoreCtrl{nullptr}; IDetectorEngine* m_pDetectorEngine{nullptr}; StationDB *m_db{nullptr}; - class AutoTrigger *m_pCameraTrig; - class AutoTrigger *m_pStatusTrig; - class ModelLists *m_pModelList; - class IWfCtrl *m_pWfCtrl; - class WfColossus *m_pColossus; - class WfStatus *m_pStatus; - class CVersion *m_pVersion; + class AutoTrigger *m_pCameraTrig{nullptr}; + class AutoTrigger *m_pStatusTrig{ nullptr }; + class IWfCtrl *m_pWfCtrl{ nullptr }; + class WfColossus *m_pColossus{ nullptr }; QTestModeWid m_testWid; QModelMangerUI m_mangeWid; QAboutUI m_aboutWid; + + QString m_strUserName; }; #endif