- 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 Version 0.8.1 For Dev-C++ 7 Beta
- fix: ConsolePaurser.exe only exits when press ENTER - 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 Version 0.8 For Dev-C++ 7 Beta
- fix: find in the current file is not correcly saved in the search history - 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() void MainWindow::onNewProblemConnection()
{ {
QTcpSocket* clientConnection = mTcpServer.nextPendingConnection(); QTcpSocket* clientConnection = mTcpServer.nextPendingConnection();
mTcpServer.connect(clientConnection, &QAbstractSocket::disconnected,
connect(clientConnection, &QAbstractSocket::disconnected,
clientConnection, &QObject::deleteLater); clientConnection, &QObject::deleteLater);
QByteArray content; QByteArray content;
int unreadCount = 0;
while (clientConnection->state() == QTcpSocket::ConnectedState) { while (clientConnection->state() == QTcpSocket::ConnectedState) {
clientConnection->waitForReadyRead(); clientConnection->waitForReadyRead(100);
content += clientConnection->readAll(); QByteArray readed = clientConnection->readAll();
if (readed.isEmpty()) {
unreadCount ++;
if (!content.isEmpty() || unreadCount>30)
break;
} else {
unreadCount = 0;
}
content += readed;
} }
content += clientConnection->readAll(); content += clientConnection->readAll();
clientConnection->write("HTTP/1.1 200 OK");
clientConnection->disconnectFromHost();
// qDebug()<<"---------";
// qDebug()<<content;
content = getHTTPBody(content); content = getHTTPBody(content);
// qDebug()<<"*********";
// qDebug()<<content;
if (content.isEmpty()) {
return;
}
QJsonParseError error; QJsonParseError error;
QJsonDocument doc = QJsonDocument::fromJson(content,&error); QJsonDocument doc = QJsonDocument::fromJson(content,&error);
if (error.error!=QJsonParseError::NoError) { if (error.error!=QJsonParseError::NoError) {
@ -2728,7 +2747,6 @@ void MainWindow::onNewProblemConnection()
ui->lstProblemSet->setCurrentIndex(mOJProblemSetModel.index(0,0)); ui->lstProblemSet->setCurrentIndex(mOJProblemSetModel.index(0,0));
} }
} }
clientConnection->disconnectFromHost();
} }
void MainWindow::onEditorClosed() void MainWindow::onEditorClosed()

View File

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

View File

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