Skip to content

Commit

Permalink
πŸ“ docs: more clear explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
eshanized committed Jan 2, 2025
1 parent 343266f commit e4f1558
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion qt/snigdhaosblackbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,27 @@ void SnigdhaOSBlackbox::updateState(QString state) {
}

void SnigdhaOSBlackbox::relaunchSelf(QString param) {
// Get the current application's binary path and file information.
auto binary = QFileInfo(QCoreApplication::applicationFilePath());

// Check if the modification time of the binary has changed since the last run.
if (executable_modify_date != binary.lastModified()) {
execlp(binary.absoluteFilePath().toUtf8().constData(), binary.fileName().toUtf8().constData(), param.toUtf8().constData(), NULL);
// If the modification time has changed, relaunch the application with the given parameter.

// execlp is used to execute the current binary again, passing the parameter 'param'.
// It replaces the current process with a new instance of the application.
execlp(
binary.absoluteFilePath().toUtf8().constData(), // Path to the executable file.
binary.fileName().toUtf8().constData(), // Name of the executable (e.g., "SnigdhaOS").
param.toUtf8().constData(), // Parameter to pass to the executable.
NULL // Terminate the argument list.
);

// Exit the current instance of the application after relaunching.
exit(0);
}
else {
// If the executable has not been modified, just update the application's state using the provided parameter.
updateState(param);
}
}
Expand Down

0 comments on commit e4f1558

Please sign in to comment.