Skip to content

Commit e31663b

Browse files
More reboot changes
1 parent 4d8c659 commit e31663b

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

src/HomeWidget.cpp

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -146,28 +146,33 @@ void HomeWidget::reboot()
146146
movie->setScaledSize(QSize(200, 240));
147147
gifLabel->setMovie(movie);
148148
movie->start();
149-
gifLabel->show();
150149

151150
msgBox.setText("");
152-
msgBox.exec();
153-
// Stop create3_server.service
154-
QProcess create3ServerStop;
155-
create3ServerStop.start("sudo", QStringList() << "systemctl" << "stop" << "create3_server.service");
156-
bool create3StopRet = create3ServerStop.waitForFinished();
157-
if (!create3StopRet || create3ServerStop.exitCode() != 0)
158-
{
159-
QMessageBox::information(this, "Failed", "Create 3 server could not be stopped.");
160-
return;
161-
}
162-
163-
// Reboot the system
164-
QProcess rebootProcess;
165-
rebootProcess.start("sudo", QStringList() << "reboot");
166-
bool rebootRet = rebootProcess.waitForFinished();
167-
if (!rebootRet || rebootProcess.exitCode() != 0)
168-
{
169-
QMessageBox::information(this, "Failed", "Reboot failed.");
170-
}
151+
msgBox.show();
152+
// Use a QTimer to delay the reboot process
153+
QTimer::singleShot(2000, [this, msgBox]() {
154+
// Stop create3_server.service
155+
QProcess create3ServerStop;
156+
create3ServerStop.start("sudo", QStringList() << "systemctl" << "stop" << "create3_server.service");
157+
bool create3StopRet = create3ServerStop.waitForFinished();
158+
if (!create3StopRet || create3ServerStop.exitCode() != 0)
159+
{
160+
QMessageBox::information(this, "Failed", "Create 3 server could not be stopped.");
161+
msgBox->close();
162+
return;
163+
}
164+
165+
// Reboot the system
166+
QProcess rebootProcess;
167+
rebootProcess.start("sudo", QStringList() << "reboot");
168+
bool rebootRet = rebootProcess.waitForFinished();
169+
if (!rebootRet || rebootProcess.exitCode() != 0)
170+
{
171+
QMessageBox::information(this, "Failed", "Reboot failed.");
172+
}
173+
174+
msgBox->close();
175+
});
171176
#else
172177
QMessageBox::information(this, "Not Available", "Reboot is only available on the kovan.");
173178
#endif

0 commit comments

Comments
 (0)