From ba23aa93af6dfd093223d5c3d9062fb5db9223a2 Mon Sep 17 00:00:00 2001 From: royqh1979 Date: Sat, 6 Nov 2021 10:36:25 +0800 Subject: [PATCH] - fix: input/output/expected textedit in the problem view shouldn't autowrap lines - fix: Red Panda C++ will freeze when receiving contents from Competitve Companion in chrome/edge --- NEWS.md | 2 ++ RedPandaIDE/mainwindow.cpp | 26 +++++++++++++++--- RedPandaIDE/mainwindow.ui | 41 ++++++++++++++++++++++++++--- RedPandaIDE/problems/ojproblemset.h | 2 ++ 4 files changed, 63 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8f6a0dbd..cb4e26b6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ Version 0.8.1 For Dev-C++ 7 Beta - fix: ConsolePaurser.exe only exits when press ENTER + - fix: input/output/expected textedit in the problem view shouldn't autowrap lines + - fix: Red Panda C++ will freeze when receiving contents from Competitve Companion in chrome/edge Version 0.8 For Dev-C++ 7 Beta - fix: find in the current file is not correcly saved in the search history diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index b1a90f24..b87f858a 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -2691,15 +2691,34 @@ void MainWindow::onProblemNameChanged(int index) void MainWindow::onNewProblemConnection() { QTcpSocket* clientConnection = mTcpServer.nextPendingConnection(); - mTcpServer.connect(clientConnection, &QAbstractSocket::disconnected, + + connect(clientConnection, &QAbstractSocket::disconnected, clientConnection, &QObject::deleteLater); QByteArray content; + int unreadCount = 0; while (clientConnection->state() == QTcpSocket::ConnectedState) { - clientConnection->waitForReadyRead(); - content += clientConnection->readAll(); + clientConnection->waitForReadyRead(100); + QByteArray readed = clientConnection->readAll(); + if (readed.isEmpty()) { + unreadCount ++; + if (!content.isEmpty() || unreadCount>30) + break; + } else { + unreadCount = 0; + } + content += readed; } content += clientConnection->readAll(); + clientConnection->write("HTTP/1.1 200 OK"); + clientConnection->disconnectFromHost(); +// qDebug()<<"---------"; +// qDebug()<lstProblemSet->setCurrentIndex(mOJProblemSetModel.index(0,0)); } } - clientConnection->disconnectFromHost(); } void MainWindow::onEditorClosed() diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index b82a4f2f..fa230aa6 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -272,7 +272,7 @@ - 7 + 3 0 @@ -288,9 +288,18 @@ + + QFrame::Panel + + + QFrame::Plain + Problem Set + + 5 + @@ -497,7 +506,7 @@ QTabWidget::South - 3 + 6 @@ -1089,6 +1098,10 @@ + + + :/icons/images/newlook24/015-compres.png:/icons/images/newlook24/015-compres.png + Problem @@ -1112,6 +1125,9 @@ + + 3 + 0 @@ -1126,9 +1142,15 @@ + + QFrame::Box + Problem + + 5 + true @@ -1305,17 +1327,28 @@ - + + + QTextEdit::NoWrap + + + + QTextEdit::NoWrap + true - + + + QTextEdit::NoWrap + + diff --git a/RedPandaIDE/problems/ojproblemset.h b/RedPandaIDE/problems/ojproblemset.h index a7a97b9f..9eb07bf2 100644 --- a/RedPandaIDE/problems/ojproblemset.h +++ b/RedPandaIDE/problems/ojproblemset.h @@ -42,4 +42,6 @@ struct OJProblemSet { QVector problems; }; +using POJProblemSet = std::shared_ptr; + #endif // OJPROBLEMSET_H