From 1124f3d43a10b81b0f85a02be2b898e65bf11637 Mon Sep 17 00:00:00 2001 From: Nicolai Ommer Date: Sat, 17 Apr 2021 11:52:03 +0200 Subject: [PATCH] Initialize SSLWorld completely before activation --- src/mainwindow.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 37002b90..4ff4c1a4 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -448,16 +448,19 @@ void MainWindow::changeBallDamping() void MainWindow::restartSimulator() { - delete glwidget->ssl; - glwidget->ssl = new SSLWorld(glwidget,glwidget->cfg,glwidget->forms[FORMATION_INSIDE_1],glwidget->forms[FORMATION_INSIDE_1]); - glwidget->ssl->glinit(); - glwidget->ssl->visionServer = visionServer; - glwidget->ssl->commandSocket = commandSocket; - glwidget->ssl->blueStatusSocket = blueStatusSocket; - glwidget->ssl->yellowStatusSocket = yellowStatusSocket; - glwidget->ssl->simControlSocket = simControlSocket; - glwidget->ssl->blueControlSocket = blueControlSocket; - glwidget->ssl->yellowControlSocket = yellowControlSocket; + auto newWorld = new SSLWorld(glwidget,glwidget->cfg,glwidget->forms[FORMATION_INSIDE_1],glwidget->forms[FORMATION_INSIDE_1]); + newWorld->glinit(); + newWorld->visionServer = visionServer; + newWorld->commandSocket = commandSocket; + newWorld->blueStatusSocket = blueStatusSocket; + newWorld->yellowStatusSocket = yellowStatusSocket; + newWorld->simControlSocket = simControlSocket; + newWorld->blueControlSocket = blueControlSocket; + newWorld->yellowControlSocket = yellowControlSocket; + + auto oldWorld = glwidget->ssl; + glwidget->ssl = newWorld; + delete oldWorld; } void MainWindow::ballMenuTriggered(QAction* act)