- 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
This commit is contained in:
royqh1979 2021-11-06 10:36:25 +08:00
parent 49ec38c685
commit ba23aa93af
4 changed files with 63 additions and 8 deletions

View File

@ -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

View File

@ -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()<<content;
content = getHTTPBody(content);
// qDebug()<<"*********";
// qDebug()<<content;
if (content.isEmpty()) {
return;
}
QJsonParseError error;
QJsonDocument doc = QJsonDocument::fromJson(content,&error);
if (error.error!=QJsonParseError::NoError) {
@ -2728,7 +2747,6 @@ void MainWindow::onNewProblemConnection()
ui->lstProblemSet->setCurrentIndex(mOJProblemSetModel.index(0,0));
}
}
clientConnection->disconnectFromHost();
}
void MainWindow::onEditorClosed()

View File

@ -272,7 +272,7 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing">
<number>7</number>
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
@ -288,9 +288,18 @@
</property>
<item>
<widget class="QLabel" name="lblProblemSet">
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>Problem Set</string>
</property>
<property name="margin">
<number>5</number>
</property>
</widget>
</item>
<item>
@ -497,7 +506,7 @@
<enum>QTabWidget::South</enum>
</property>
<property name="currentIndex">
<number>3</number>
<number>6</number>
</property>
<property name="iconSize">
<size>
@ -1089,6 +1098,10 @@
</layout>
</widget>
<widget class="QWidget" name="tabProblem">
<attribute name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/images/newlook24/015-compres.png</normaloff>:/icons/images/newlook24/015-compres.png</iconset>
</attribute>
<attribute name="title">
<string>Problem</string>
</attribute>
@ -1112,6 +1125,9 @@
</property>
<widget class="QWidget" name="widget_4" native="true">
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
@ -1126,9 +1142,15 @@
</property>
<item>
<widget class="QLabel" name="lblProblem">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="text">
<string>Problem</string>
</property>
<property name="margin">
<number>5</number>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
@ -1305,17 +1327,28 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QTextEdit" name="txtProblemCaseInput"/>
<widget class="QTextEdit" name="txtProblemCaseInput">
<property name="lineWrapMode">
<enum>QTextEdit::NoWrap</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QTextEdit" name="txtProblemCaseOutput">
<property name="lineWrapMode">
<enum>QTextEdit::NoWrap</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QTextEdit" name="txtProblemCaseExpected"/>
<widget class="QTextEdit" name="txtProblemCaseExpected">
<property name="lineWrapMode">
<enum>QTextEdit::NoWrap</enum>
</property>
</widget>
</item>
</layout>
</widget>

View File

@ -42,4 +42,6 @@ struct OJProblemSet {
QVector<POJProblem> problems;
};
using POJProblemSet = std::shared_ptr<OJProblemSet>;
#endif // OJPROBLEMSET_H