core: turn struct dive string data into std::string

Much easier memory management!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-29 20:40:18 +02:00 committed by bstoeger
parent 2b3d2f1020
commit 3cb04d230b
34 changed files with 208 additions and 313 deletions

View file

@ -1093,7 +1093,7 @@ void DivePlannerPointsModel::updateDiveProfile()
#endif
final_deco_state = plan_deco_state;
}
emit calculatedPlanNotes(QString(d->notes));
emit calculatedPlanNotes(QString::fromStdString(d->notes));
#if DEBUG_PLAN
@ -1268,10 +1268,10 @@ finish:
void DivePlannerPointsModel::computeVariationsDone(QString variations)
{
QString notes = QString(d->notes);
free(d->notes);
d->notes = copy_qstring(notes.replace("VARIATIONS", variations));
emit calculatedPlanNotes(QString(d->notes));
QString notes = QString::fromStdString(d->notes);
notes = notes.replace("VARIATIONS", variations);
d->notes = notes.toStdString();
emit calculatedPlanNotes(notes);
}
void DivePlannerPointsModel::createPlan(bool saveAsNew)
@ -1298,7 +1298,7 @@ void DivePlannerPointsModel::createPlan(bool saveAsNew)
// Try to identify old planner output and remove only this part
// Treat user provided text as plain text.
QTextDocument notesDocument;
notesDocument.setHtml(current_dive->notes);
notesDocument.setHtml(QString::fromStdString(current_dive->notes));
QString oldnotes(notesDocument.toPlainText());
QString disclaimer = get_planner_disclaimer();
int disclaimerMid = disclaimer.indexOf("%s");
@ -1320,8 +1320,8 @@ void DivePlannerPointsModel::createPlan(bool saveAsNew)
}
// Deal with line breaks
oldnotes.replace("\n", "<br>");
oldnotes.append(d->notes);
d->notes = copy_qstring(oldnotes);
oldnotes.append(QString::fromStdString(d->notes));
d->notes = oldnotes.toStdString();
// If we save as new create a copy of the dive here
}