fix: exit error bug.
This commit is contained in:
@@ -95,6 +95,12 @@ void Connecter::setState(ConnectState cs)
|
||||
}
|
||||
}
|
||||
|
||||
void Connecter::Disconnect()
|
||||
{
|
||||
sockWorker_->quit();
|
||||
qWarning() << QString(tr("Disconnected..."));
|
||||
}
|
||||
|
||||
void Connecter::RefreshClient()
|
||||
{
|
||||
InfoMsg info;
|
||||
@@ -138,6 +144,7 @@ void Connecter::InitControl()
|
||||
ui->listView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
connect(ui->listView, &QListView::customContextMenuRequested, this, &Connecter::ShowContextMenu);
|
||||
connect(ui->btnDisconnect, &QPushButton::clicked, this, &Connecter::Disconnect);
|
||||
|
||||
menu_ = new QMenu(this);
|
||||
QAction* acUseThis = menu_->addAction(tr("UseThis"));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#ifndef CONNECTCONTROL_H
|
||||
#ifndef CONNECTCONTROL_H
|
||||
#define CONNECTCONTROL_H
|
||||
|
||||
#include <ClientCore.h>
|
||||
@@ -38,6 +38,7 @@ private:
|
||||
void Connect();
|
||||
void setState(ConnectState cs);
|
||||
void RefreshClient();
|
||||
void Disconnect();
|
||||
void ShowContextMenu(const QPoint& pos);
|
||||
std::string getCurClient();
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ TransForm::TransForm(QWidget* parent) : QDialog(parent), ui(new Ui::TransForm)
|
||||
|
||||
TransForm::~TransForm()
|
||||
{
|
||||
exis_ = true;
|
||||
QThread::msleep(10);
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@@ -27,6 +29,7 @@ void TransForm::SetClientCore(ClientCore* clientCore)
|
||||
|
||||
void TransForm::SetTasks(const QVector<TransTask>& tasks)
|
||||
{
|
||||
exis_ = true;
|
||||
tasks_ = tasks;
|
||||
}
|
||||
|
||||
@@ -37,6 +40,9 @@ void TransForm::startTask()
|
||||
if (task.isUpload) {
|
||||
fileTrans_->ReqSendFile(task);
|
||||
while (true) {
|
||||
if (exis_) {
|
||||
return;
|
||||
}
|
||||
auto progress = fileTrans_->GetSendProgress();
|
||||
if (progress < 0) {
|
||||
emit sigFailed();
|
||||
@@ -52,6 +58,9 @@ void TransForm::startTask()
|
||||
} else {
|
||||
fileTrans_->ReqDownFile(task);
|
||||
while (true) {
|
||||
if (exis_) {
|
||||
return;
|
||||
}
|
||||
auto progress = fileTrans_->GetDownProgress();
|
||||
if (progress < 0) {
|
||||
emit sigFailed();
|
||||
@@ -90,8 +99,7 @@ void TransForm::handleUI(const TransTask& task)
|
||||
ui->edTo->setText(task.remoteId);
|
||||
ui->pedFrom->setPlainText(task.localPath);
|
||||
ui->pedTo->setPlainText(task.remotePath);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->edFrom->setText(task.localId);
|
||||
ui->edTo->setText(task.remoteId);
|
||||
ui->pedFrom->setPlainText(task.remotePath);
|
||||
|
||||
@@ -41,6 +41,7 @@ protected:
|
||||
void showEvent(QShowEvent* event) override;
|
||||
|
||||
private:
|
||||
bool exis_{ false };
|
||||
TranFromTh* workTh_{};
|
||||
QVector<TransTask> tasks_;
|
||||
FileTrans* fileTrans_{};
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "Control/LogControl.h"
|
||||
|
||||
static LogPrint* logPrint = nullptr;
|
||||
static QMutex logMut;
|
||||
|
||||
frelayGUI::frelayGUI(QWidget* parent) : QMainWindow(parent), ui(new Ui::frelayGUI)
|
||||
{
|
||||
@@ -28,9 +27,7 @@ frelayGUI::frelayGUI(QWidget* parent) : QMainWindow(parent), ui(new Ui::frelayGU
|
||||
|
||||
frelayGUI::~frelayGUI()
|
||||
{
|
||||
QMutexLocker locker(&logMut);
|
||||
delete ui;
|
||||
logPrint = nullptr;
|
||||
}
|
||||
|
||||
void frelayGUI::InitControl()
|
||||
@@ -93,9 +90,7 @@ void frelayGUI::ControlMsgHander(QtMsgType type, const QMessageLogContext& conte
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
|
||||
QMutexLocker locker(&logMut);
|
||||
|
||||
if (!logPrint) {
|
||||
if (!qApp || !qobject_cast<frelayGUI*>(qApp->activeWindow())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ int main(int argc, char* argv[])
|
||||
QApplication a(argc, argv);
|
||||
|
||||
qInstallMessageHandler(frelayGUI::ControlMsgHander);
|
||||
qRegisterMetaType<QSharedPointer<FrameBuffer>>("QSharedPointer<FrameBuffer>");
|
||||
qRegisterMetaType<InfoClientVec>("InfoClientVec");
|
||||
qRegisterMetaType<DirFileInfoVec>("DirFileInfoVec");
|
||||
|
||||
#ifdef _WIN32
|
||||
QFont font("Microsoft YaHei", 9);
|
||||
|
||||
Reference in New Issue
Block a user