分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

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

发布时间:2023-09-06 01:59责任编辑:顾先生关键词:暂无标签

前段时间发现项目中的上传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 timer ???????break;
/** ?*@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");}

主进程重启上传软件,从而跳过断连。

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

原文地址:https://www.cnblogs.com/hasan/p/9161750.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved