mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: introduce copy_qstring() function
strdup(qPrintable(s)) and copy_string(qPrintable(s)) were such common occurrences that they seem worthy of a short helper-function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
b72cc1f317
commit
d1572a8d95
19 changed files with 116 additions and 108 deletions
|
@ -158,7 +158,7 @@ void LocationInformationWidget::acceptChanges()
|
|||
{
|
||||
char *uiString;
|
||||
struct dive_site *currentDs;
|
||||
uiString = copy_string(qPrintable(ui.diveSiteName->text()));
|
||||
uiString = copy_qstring(ui.diveSiteName->text());
|
||||
if (get_dive_site_by_uuid(displayed_dive_site.uuid) != NULL) {
|
||||
currentDs = get_dive_site_by_uuid(displayed_dive_site.uuid);
|
||||
} else {
|
||||
|
@ -175,14 +175,14 @@ void LocationInformationWidget::acceptChanges()
|
|||
} else {
|
||||
free(uiString);
|
||||
}
|
||||
uiString = copy_string(qPrintable(ui.diveSiteDescription->text()));
|
||||
uiString = copy_qstring(ui.diveSiteDescription->text());
|
||||
if (!same_string(uiString, currentDs->description)) {
|
||||
free(currentDs->description);
|
||||
currentDs->description = uiString;
|
||||
} else {
|
||||
free(uiString);
|
||||
}
|
||||
uiString = copy_string(qPrintable(ui.diveSiteCountry->text()));
|
||||
uiString = copy_qstring(ui.diveSiteCountry->text());
|
||||
// if the user entered a different contriy, first update the taxonomy
|
||||
// for the displayed dive site; this below will get copied into the currentDs
|
||||
if (!same_string(uiString, taxonomy_get_country(&displayed_dive_site.taxonomy)) &&
|
||||
|
@ -193,7 +193,7 @@ void LocationInformationWidget::acceptChanges()
|
|||
// now update the currentDs (which we then later copy back ontop of displayed_dive_site
|
||||
copy_dive_site_taxonomy(&displayed_dive_site, currentDs);
|
||||
|
||||
uiString = copy_string(qPrintable(ui.diveSiteNotes->document()->toPlainText()));
|
||||
uiString = copy_qstring(ui.diveSiteNotes->document()->toPlainText());
|
||||
if (!same_string(uiString, currentDs->notes)) {
|
||||
free(currentDs->notes);
|
||||
currentDs->notes = uiString;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue