From d52b1b456a0defee6d6fe5c3f1e670e4d97c307b Mon Sep 17 00:00:00 2001 From: McDj26 <2645370670@qq.com> Date: Tue, 27 Dec 2022 17:07:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E4=BF=AEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LibManageSystem_Server/addbook.cpp | 2 +- LibManageSystem_Server/mythread.cpp | 4 ++-- LibManageSystem_Server/mythread.h | 2 +- LibManageSystem_Server/tcpserver.cpp | 2 +- LibManagementSystem/communication_module.cpp | 11 +++++++++-- LibManagementSystem/mainwindow.cpp | 2 -- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/LibManageSystem_Server/addbook.cpp b/LibManageSystem_Server/addbook.cpp index 8b6f072..1475dfc 100644 --- a/LibManageSystem_Server/addbook.cpp +++ b/LibManageSystem_Server/addbook.cpp @@ -16,7 +16,7 @@ addbook::addbook(Operat* _db,QWidget *parent) : ); QRegularExpression regExp1("[0-9-]+"); ui->datelEdit->setValidator(new QRegularExpressionValidator(regExp1,this)); - QRegularExpression regExp2("[0-9]+"); + QRegularExpression regExp2("[0-9-]+"); ui->numlEdit->setValidator(new QRegularExpressionValidator(regExp2,this)); QRegularExpression regExp3("[0-9.]+"); ui->pricelEdit->setValidator(new QRegularExpressionValidator(regExp3,this)); diff --git a/LibManageSystem_Server/mythread.cpp b/LibManageSystem_Server/mythread.cpp index 3b04cfc..64e58d0 100644 --- a/LibManageSystem_Server/mythread.cpp +++ b/LibManageSystem_Server/mythread.cpp @@ -576,7 +576,7 @@ void MyThread::FirstTransfer() cur_msg=first_transfer_header + msg_tobe_sent; cur_msg=HammingEncode(cur_msg); socket->write(cur_msg); - socket->waitForReadyRead(500); + socket->waitForDisconnected(1000); } else{ sentsize+=MAX_DAT_SIZE_PER_CLOCK; @@ -613,7 +613,7 @@ void MyThread::ContinueTransfer() sentsize=totalsize; cur_msg=HammingEncode(cur_msg); socket->write(cur_msg); - socket->waitForReadyRead(500); + socket->waitForDisconnected(1000); } else{ transfer_header += QString::number(sentsize+MAX_DAT_SIZE_PER_CLOCK).toStdString() + stopChar; diff --git a/LibManageSystem_Server/mythread.h b/LibManageSystem_Server/mythread.h index 2d23b80..d9c6b1c 100644 --- a/LibManageSystem_Server/mythread.h +++ b/LibManageSystem_Server/mythread.h @@ -9,7 +9,7 @@ #include //每轮循环最大发送数据长度 -#define MAX_DAT_SIZE_PER_CLOCK 5000 +#define MAX_DAT_SIZE_PER_CLOCK 4000 class MyThread : public QObject { diff --git a/LibManageSystem_Server/tcpserver.cpp b/LibManageSystem_Server/tcpserver.cpp index 89f72f3..6141792 100644 --- a/LibManageSystem_Server/tcpserver.cpp +++ b/LibManageSystem_Server/tcpserver.cpp @@ -342,7 +342,7 @@ void TcpServer::visitDataBase(int threadhandle) if(errorType==0) db_data[pos].first.second.message="此书已被预约"; if(errorType==-1) - db_data[pos].first.second.message="您无权预约此书,请检查是否有书籍逾期未还,或是否已经预约其他书籍"; + db_data[pos].first.second.message="您无权预约此书,请检查是否有书籍逾期未还,或是否已经预约其他书籍 "; break; case 6: //取消预约书籍操作 diff --git a/LibManagementSystem/communication_module.cpp b/LibManagementSystem/communication_module.cpp index 63a3274..3f7cca1 100644 --- a/LibManagementSystem/communication_module.cpp +++ b/LibManagementSystem/communication_module.cpp @@ -121,9 +121,16 @@ void communication_module::receiveMsg() QByteArray _msg=socket->readAll(); _msg=HammingDecode(_msg); + char backChar=_msg.back(); + + while(backChar=='\0'){ + _msg.remove(_msg.size()-1,1); + backChar=_msg.back(); + } + qsizetype _msgSize=_msg.size(),start; - if(_msg[0]=='['&&_msg.size()==15){ + if(_msg[0]=='['&&_msg.size()==14){ send(); emit process_update(20); } @@ -141,7 +148,7 @@ void communication_module::receiveMsg() else cur_size=size_dat.toInt(); start=_msg.indexOf(stopChar) + 1; - received_msg += _msg.sliced(start,_msgSize - start - 1); + received_msg += _msg.sliced(start,_msgSize - start); emit process_update(20+int(60*float(cur_size)/float(totalsize))); diff --git a/LibManagementSystem/mainwindow.cpp b/LibManagementSystem/mainwindow.cpp index cbaf8e8..1227824 100644 --- a/LibManagementSystem/mainwindow.cpp +++ b/LibManagementSystem/mainwindow.cpp @@ -30,8 +30,6 @@ MainWindow::MainWindow(QWidget *parent) u_i = new user_info(¤t_user); re = new returnBook(¤t_user); -// lo->setStyleSheet(QString("background-image:url(:images/clientRes/Login.png)")); - // current_user.account = QString("21311144"); // current_user.nickname = QString("哈哈哈名字再长也不怕会自动省略"); // current_user.telephone_number = QString("18320280001"); -- Gitee