[education/rkward] rkward: Fix potential crash on exit

Thomas Friedrichsmeier null at kde.org
Sat Apr 9 13:49:20 BST 2022


Git commit c89200b530955cfc6ebc429b2f638834edd79eb9 by Thomas Friedrichsmeier.
Committed on 09/04/2022 at 12:49.
Pushed by tfry into branch 'master'.

Fix potential crash on exit

M  +1    -1    rkward/rbackend/rkrinterface.cpp
M  +1    -0    rkward/rkconsole.cpp

https://invent.kde.org/education/rkward/commit/c89200b530955cfc6ebc429b2f638834edd79eb9

diff --git a/rkward/rbackend/rkrinterface.cpp b/rkward/rbackend/rkrinterface.cpp
index aa7f8cb7..56681b0e 100644
--- a/rkward/rbackend/rkrinterface.cpp
+++ b/rkward/rbackend/rkrinterface.cpp
@@ -441,7 +441,7 @@ void RInterface::flushOutput (bool forced) {
 	foreach (ROutput *output, list) {
 		if (all_current_commands.isEmpty ()) {
 			RK_DEBUG (RBACKEND, DL_DEBUG, "output without receiver'%s'", qPrintable (output->output));
-			RKConsole::mainConsole()->insertSpontaneousROutput(output);
+			if (RKConsole::mainConsole()) RKConsole::mainConsole()->insertSpontaneousROutput(output);  // the "if" is to prevent crash, should output arrive during exit
 			delete output;
 			continue;	// to delete the other output pointers, too
 		} else {
diff --git a/rkward/rkconsole.cpp b/rkward/rkconsole.cpp
index ecd5bcc5..96b4c823 100644
--- a/rkward/rkconsole.cpp
+++ b/rkward/rkconsole.cpp
@@ -164,6 +164,7 @@ RKConsole::RKConsole (QWidget *parent, bool tool_window, const char *name) : RKM
 RKConsole::~RKConsole () {
 	RK_TRACE (APP);
 
+	if (this == main_console) main_console = nullptr;
 	RKSettingsModuleConsole::saveCommandHistory (commands_history.getHistory ());
 }
 


More information about the rkward-tracker mailing list