Skip to content

Commit f828811

Browse files
committed
Plugins::FtpServer: add process error
1 parent 69651a5 commit f828811

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

Plugins/FtpServer/BackendFtpServer.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,13 @@ CBackend::OnInitReturnValue CBackendFtpServer::OnInit()
5555
}
5656
}
5757
if(bListen) {
58-
qInfo(log) << "The ftp server listen in" << m_Para->GetPort();
58+
QString szMsg = tr("Ftp server listen in %1").arg(m_Para->GetPort());
59+
qInfo(log) << szMsg;
60+
emit sigInformation(szMsg);
5961
} else {
60-
QString szErr = tr("The ftp server is not listening in %1").arg(m_Para->GetPort());
62+
QString szErr = tr("Ftp server is not listening in %1").arg(m_Para->GetPort());
6163
emit sigError(-1, szErr);
64+
return OnInitReturnValue::Fail;
6265
}
6366
return OnInitReturnValue::NotUseOnProcess;
6467
}

Plugins/FtpServer/OperateFtpServer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ QSharedPointer<CParameterFtpServer> COperateFtpServer::GetParameter()
141141
void COperateFtpServer::slotStart(bool checked)
142142
{
143143
qDebug(log) << Q_FUNC_INFO << m_pStart->isChecked();
144+
bool check = false;
144145
if(!checked) {
145146
m_pStart->setText(tr("Start server"));
146147
m_pStart->setToolTip(m_pStart->text());
@@ -163,6 +164,10 @@ void COperateFtpServer::slotStart(bool checked)
163164
qCritical(log) << "new CBackendThread fail";
164165
return;
165166
}
166-
167+
check = connect(this, &COperateFtpServer::sigError,
168+
this, [this](const int nError, const QString &szError){
169+
m_pStart->setChecked(false);
170+
});
171+
Q_ASSERT(check);
167172
m_pThread->start();
168173
}

Src/BackendThread.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
class PLUGIN_EXPORT CBackendThread : public QThread
1515
{
1616
Q_OBJECT
17+
1718
public:
1819
explicit CBackendThread(COperate *pOperate = nullptr, bool bSignal = true);
1920
virtual ~CBackendThread() override;
@@ -22,6 +23,7 @@ class PLUGIN_EXPORT CBackendThread : public QThread
2223
* \note Use this replace QThread::quit, QThread::exit, QThread::terminate
2324
*/
2425
virtual void quit();
26+
2527
protected:
2628
virtual void run() override;
2729
COperate* m_pOperate;

0 commit comments

Comments
 (0)