Skip to content

Commit

Permalink
Make CodeLoader::installVescPackage() always erase both qml and lisp
Browse files Browse the repository at this point in the history
If one or the other is missing in the package, we still want to erase
the memory, otherwise the code of the old package will stay there and
keep running.

If a package that contains neither qml nor lisp is loaded, it erases
both. That should be the expected outcome.

Reorganizes the logic a bit to hopefully make it more streamlined.
  • Loading branch information
lukash committed Jan 16, 2024
1 parent c38e1fc commit 423e39e
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions codeloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,25 +787,31 @@ bool CodeLoader::installVescPackage(VescPackage pkg)
bool res = true;
QByteArray qml;

if (res && !pkg.qmlFile.isEmpty()) {
if (!pkg.qmlFile.isEmpty()) {
qml = qmlCompress(pkg.qmlFile);
res = qmlErase(qml.size() + 100);
}

if (res && !pkg.qmlFile.isEmpty()) {
res = qmlUpload(qml, pkg.qmlIsFullscreen);
if (res) {
res = qmlUpload(qml, pkg.qmlIsFullscreen);
}
} else {
res = qmlErase(16);
}

if (res && !pkg.lispData.isEmpty()) {
res = lispErase(pkg.lispData.size() + 100);
}
if (res) {
if (!pkg.lispData.isEmpty()) {
res = lispErase(pkg.lispData.size() + 100);

if (res && !pkg.lispData.isEmpty()) {
res = lispUpload(VByteArray(pkg.lispData));
}
if (res) {
res = lispUpload(VByteArray(pkg.lispData));

if (res && !pkg.lispData.isEmpty()) {
mVesc->commands()->lispSetRunning(1);
if (res) {
mVesc->commands()->lispSetRunning(1);
}
}
} else {
res = lispErase(16);
}
}

Utility::sleepWithEventLoop(500);
Expand Down

0 comments on commit 423e39e

Please sign in to comment.