From dfc2639746b3b5d21905836ce1b1d12eeb5dcaf0 Mon Sep 17 00:00:00 2001 From: taynpg Date: Thu, 19 Jun 2025 16:20:01 +0800 Subject: [PATCH] some change. --- ClientCore/ClientCore.cpp | 5 ++++- ClientCore/ClientCore.h | 1 - ClientCore/FileTrans.cpp | 2 +- Gui/Control/LogControl.cpp | 11 +++++------ Gui/Control/LogControl.ui | 2 +- Gui/Form/Transform.cpp | 2 +- Gui/frelayGUI.cpp | 6 ++++++ Protocol/Protocol.h | 2 ++ 8 files changed, 20 insertions(+), 11 deletions(-) diff --git a/ClientCore/ClientCore.cpp b/ClientCore/ClientCore.cpp index 1df8872..58249be 100644 --- a/ClientCore/ClientCore.cpp +++ b/ClientCore/ClientCore.cpp @@ -4,6 +4,10 @@ ClientCore::ClientCore(QObject* parent) : QObject(parent) { + qRegisterMetaType>("QSharedPointer"); + qRegisterMetaType("InfoClientVec"); + qRegisterMetaType("DirFileInfoVec"); + socket_ = new QTcpSocket(this); connect(socket_, &QTcpSocket::readyRead, this, &ClientCore::onReadyRead); connect(socket_, &QTcpSocket::disconnected, this, &ClientCore::onDisconnected); @@ -113,7 +117,6 @@ void ClientCore::UseFrame(QSharedPointer frame) case FrameBufferType::FBT_CLI_TRANS_DONE: { sigTransDone(frame); break; - break; } case FrameBufferType::FBT_CLI_CAN_SEND: { sigCanSend(frame); diff --git a/ClientCore/ClientCore.h b/ClientCore/ClientCore.h index d303154..1c8c121 100644 --- a/ClientCore/ClientCore.h +++ b/ClientCore/ClientCore.h @@ -102,7 +102,6 @@ public: QByteArray recvBuffer_; LocalFile localFile_; - std::array)>, 256> frameCall_; }; class SocketWorker : public QThread diff --git a/ClientCore/FileTrans.cpp b/ClientCore/FileTrans.cpp index 67f50f7..ee804f4 100644 --- a/ClientCore/FileTrans.cpp +++ b/ClientCore/FileTrans.cpp @@ -290,7 +290,7 @@ void SendThread::run() // shoule add abort action mark. } - QMetaObject::invokeMethod(this, [this, frame] { + QMetaObject::invokeMethod(cliCore_, [this, frame] { frame->sendRet = cliCore_->Send(frame); if (frame->call) { frame->call(frame); diff --git a/Gui/Control/LogControl.cpp b/Gui/Control/LogControl.cpp index 2e0f552..56c0f3b 100644 --- a/Gui/Control/LogControl.cpp +++ b/Gui/Control/LogControl.cpp @@ -1,6 +1,7 @@ -#include "LogControl.h" +#include "LogControl.h" #include +#include #include #include #include @@ -15,8 +16,6 @@ LogPrint::LogPrint(QWidget* parent) : QWidget(parent), ui(new Ui::LogPrint) void LogPrint::InitControl() { - model_ = new QStandardItemModel(this); - ui->listView->setModel(model_); } std::string LogPrint::now_str() @@ -56,8 +55,8 @@ void LogPrint::Debug(const QString& message) void LogPrint::Print(const QString& message, const QBrush& color) { auto timeStr = QString("%1%2").arg(QString::fromStdString(now_str())).arg(message); - auto* item = new QStandardItem(timeStr); + QListWidgetItem* item = new QListWidgetItem(timeStr); item->setForeground(color); - model_->appendRow(item); - ui->listView->scrollToBottom(); + ui->listWidget->addItem(item); + ui->listWidget->scrollToBottom(); } diff --git a/Gui/Control/LogControl.ui b/Gui/Control/LogControl.ui index 3b8a103..9122df1 100644 --- a/Gui/Control/LogControl.ui +++ b/Gui/Control/LogControl.ui @@ -15,7 +15,7 @@ - + diff --git a/Gui/Form/Transform.cpp b/Gui/Form/Transform.cpp index 37061f4..24c7b38 100644 --- a/Gui/Form/Transform.cpp +++ b/Gui/Form/Transform.cpp @@ -103,7 +103,7 @@ void TransForm::showEvent(QShowEvent* event) { QDialog::showEvent(event); workTh_ = new TranFromTh(this, this); - //fileTrans_->moveToThread(workTh_); + fileTrans_->moveToThread(workTh_); connect(workTh_, &QThread::finished, fileTrans_, &QObject::deleteLater); workTh_->start(); } diff --git a/Gui/frelayGUI.cpp b/Gui/frelayGUI.cpp index e444a4e..dde5bbb 100644 --- a/Gui/frelayGUI.cpp +++ b/Gui/frelayGUI.cpp @@ -8,6 +8,7 @@ #include "Control/LogControl.h" static LogPrint* logPrint = nullptr; +static QMutex logMut; frelayGUI::frelayGUI(QWidget* parent) : QMainWindow(parent), ui(new Ui::frelayGUI) { @@ -27,7 +28,9 @@ frelayGUI::frelayGUI(QWidget* parent) : QMainWindow(parent), ui(new Ui::frelayGU frelayGUI::~frelayGUI() { + QMutexLocker locker(&logMut); delete ui; + logPrint = nullptr; } void frelayGUI::InitControl() @@ -89,6 +92,9 @@ void frelayGUI::ControlLayout() void frelayGUI::ControlMsgHander(QtMsgType type, const QMessageLogContext& context, const QString& msg) { Q_UNUSED(context); + + QMutexLocker locker(&logMut); + if (!logPrint) { return; } diff --git a/Protocol/Protocol.h b/Protocol/Protocol.h index 97e3b8e..e6a93de 100644 --- a/Protocol/Protocol.h +++ b/Protocol/Protocol.h @@ -4,6 +4,7 @@ #include #include #include +#include constexpr quint32 CHUNK_BUF_SIZE = 1 * 1024 * 1024; @@ -52,4 +53,5 @@ public: static QByteArray PackBuffer(const QSharedPointer& frame); }; + #endif // PROTOCOL_H