Fixed segfault in QApplication::exec by copying argc and argv into ui class

also reenabled writing to the QPlainTextEdit
This commit is contained in:
Darren VanBuren 2017-07-24 05:51:13 -07:00
parent 13f5fbf8b0
commit 65d123ce2c
4 changed files with 15 additions and 7 deletions

View file

@ -30,6 +30,6 @@
</Objective-C-extensions>
</value>
</option>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (1)" />
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</component>
</project>

View file

@ -171,6 +171,8 @@ int main(int argc, char *argv[]) {
exit(1);
}
ui *uiInstance = new ui(argc, argv);
char netBuf[8192];
// TEMP: Retreiving test file from HTTP daemon w/ TLS
@ -180,7 +182,7 @@ int main(int argc, char *argv[]) {
if(ret < 0) {
const PRErrorCode err = PR_GetError();
fprintf(stderr, "Error writing data to socket, code %d: %s\n", err, PR_ErrorToName(err));
// uiInstance->mainLog->appendPlainText("Error writing data to socket, see stderr.");
uiInstance->mainLog->appendPlainText("Error writing data to socket, see stderr.");
}
// Get the response
@ -188,10 +190,10 @@ int main(int argc, char *argv[]) {
if(ret < 0) {
const PRErrorCode err = PR_GetError();
fprintf(stderr, "Error reading data from socket, code %d: %s\n", err, PR_ErrorToName(err));
// uiInstance->mainLog->appendPlainText("Error writing data from socket, see stderr.");
uiInstance->mainLog->appendPlainText("Error writing data from socket, see stderr.");
} else {
printf("%s\n", netBuf);
// uiInstance->mainLog->appendPlainText(netBuf);
uiInstance->mainLog->appendPlainText(netBuf);
}
if(PR_Shutdown(nssSocket, PR_SHUTDOWN_BOTH) != PR_SUCCESS) {
@ -204,9 +206,11 @@ int main(int argc, char *argv[]) {
char messageBuf[1024];
sprintf(messageBuf, "Found IP Address: %s", ipString);
// uiInstance->mainLog->appendPlainText(messageBuf);
uiInstance->mainLog->appendPlainText(messageBuf);
fprintf(stderr, "argc = %d, strlen(argv[0]) = %d\n", argc, (int)strlen(argv[0]));
ui *uiInstance = new ui(argc, argv);
int qAppRetCode = uiInstance->exec();
// Shutdown of NSS

4
ui.cpp
View file

@ -1,7 +1,9 @@
#include "ui.h"
ui::ui(int argc, char **argv) {
app = new QApplication(argc, argv);
this->argc = argc;
this->argv = argv;
app = new QApplication(this->argc, this->argv);
mainWindow = new QWidget();
mainWindow->resize(1280, 720);
mainWindow->setWindowTitle("oksirc - early Qt test");

2
ui.h
View file

@ -7,6 +7,8 @@ class ui : public QObject {
public:
ui(int, char **);
int argc;
char **argv;
int exec();
void sendButtonClicked(bool);
void returnOnTextEntry();