日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

QT 防止FTP 上传软件在断连处 Crash

發布時間:2025/4/9 c/c++ 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 QT 防止FTP 上传软件在断连处 Crash 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

前段時間發現項目中的上傳FTP軟件有可能會在從服務器申請斷連時Crash, 所以加了一個Timer。

由于項目代碼行數過大, 此處上傳部分代碼片段。

timeoutTimer = new QTimer();connect(timeoutTimer, SIGNAL(timeout()), this, SLOT(doTimeout()));timeoutTimer->setInterval(4000); case QFtp::Closing:// The connection is closing down, but it is not yet closed. (The state will be Unconnected when the connection is closed.)pMain->debug( "Status(%d) = disconnecting from HOST", type );timeoutTimer->start();break; case QFtp::Unconnected:// There is no connection to the host.pMain->debug( "Status(%d) = disconnected status", type );if ( communicator->isPerforming() ) {communicator->abortRequest(); // abort performing command, maybe done(ERROR) should be called later }timeoutTimer->stop(); //stop timerbreak; /** *@projectName BoeB9Project *@author Hasan **/ void FtpHelper::doTimeout() {pMain->debug("debug154545 timeout !!!!!!!");pMain->sendProxyMessage("MesUPLOADTimeout", ProxyMessage::Notify);timeoutTimer->stop(); }

在此進程發出MesUPLOADTimeout 信息之后, 項目主進程會從代理Proxy中接受此信息并進行處理。

/***@projectName BoeB9Project*@author Hasan**/ void BoeB9QtmCellInlineMain::restartUploader() {QProcess proc;QString c = "taskkill /im uploader.exe /f";proc.execute(c);proc.close();info("********info terminate uploader");QProcess *proc1 = new QProcess(this);proc1->start("cmd.exe", QStringList() <<"/c" << "c:///ORBKwsmcu/bin/start_uploader.bat");delete proc1;info("********info start uploader again"); }

主進程重啟上傳軟件,從而跳過斷連。

轉載于:https://www.cnblogs.com/hasan/p/9161750.html

總結

以上是生活随笔為你收集整理的QT 防止FTP 上传软件在断连处 Crash的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。