Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cpn): inputs and mixes must have source #5798

Merged
merged 16 commits into from
Feb 6, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(cpn): inputs and mixes must have source
elecpower committed Jan 24, 2025
commit e3e4a511d390d5a4076a1826f6a5b80d0ab15ab7
4 changes: 2 additions & 2 deletions companion/src/firmwares/edgetx/yaml_modeldata.cpp
Original file line number Diff line number Diff line change
@@ -1014,7 +1014,7 @@ Node convert<ModelData>::encode(const ModelData& rhs)

for (int i = 0; i < CPN_MAX_MIXERS; i++) {
const MixData& mix = rhs.mixData[i];
if (!mix.isEmpty()) {
if (!mix.isEmpty() && mix.srcRaw != SOURCE_TYPE_NONE) {
node["mixData"].push_back(Node(mix));
}
}
@@ -1029,7 +1029,7 @@ Node convert<ModelData>::encode(const ModelData& rhs)
std::set<int> inputs;
for (int i = 0; i < CPN_MAX_EXPOS; i++) {
const ExpoData& expo = rhs.expoData[i];
if (!expo.isEmpty()) {
if (!expo.isEmpty() && expo.srcRaw != SOURCE_TYPE_NONE) {
Node expoNode;
expoNode = expo;
node["expoData"].push_back(expoNode);
29 changes: 29 additions & 0 deletions companion/src/mdichild.cpp
Original file line number Diff line number Diff line change
@@ -1334,6 +1334,35 @@ bool MdiChild::saveAs(bool isNew)

bool MdiChild::saveFile(const QString & filename, bool setCurrent)
{
int cnt = 0;

for (int i = 0; i < (int)radioData.models.size(); i++) {
if (!radioData.models[i].isEmpty()) {
for (int j = 0; j < CPN_MAX_INPUTS; j++) {
if (!radioData.models[i].expoData[j].isEmpty() && radioData.models[i].expoData[j].srcRaw == SOURCE_TYPE_NONE)
cnt++;
}

if (cnt > 0) {
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Model %1 has %2 inputs with no source and these inputs will not be saved. Continue?").arg(radioData.models[i].name).arg(cnt),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No)
return false;
}

cnt = 0;
for (int j = 0; j < CPN_MAX_MIXERS; j++) {
if (!radioData.models[i].mixData[j].isEmpty() && radioData.models[i].mixData[j].srcRaw == SOURCE_TYPE_NONE)
cnt++;
}

if (cnt > 0) {
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Model %1 has %2 mixes with no source and these mixes will not be saved. Continue?").arg(radioData.models[i].name).arg(cnt),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No)
return false;
}
}
}

radioData.fixModelFilenames();
Storage storage(filename);
bool result = storage.write(radioData);