diff options
author | Bastian Koppelmann <kbastian@mail.uni-paderborn.de> | 2022-08-30 13:26:40 +0200 |
---|---|---|
committer | Bastian Koppelmann <kbastian@mail.uni-paderborn.de> | 2022-08-30 15:14:20 +0200 |
commit | 691760ef01179348bd0df1e7ee6da38e6f88d3de (patch) | |
tree | 4a87f35a6f255076ce32f5a86330d0e79739f56b | |
parent | eb0fe23700304dd564bee5b8851dd6affc776ef2 (diff) | |
download | navit-691760ef01179348bd0df1e7ee6da38e6f88d3de.tar.gz |
Fix:gui:qt5_qml: Fix -Wwrite-strings warning
We assign string constants to a char* which will lead to an error if
anyone tries to write that pointer, as constant data is mapped
read-only. This patch makes these const char* pointers.
Fixes the warning:
backend.cpp:588:27: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
588 | _current_street = "Enter Street";
| ^~~~~~~~~~~~~~
-rw-r--r-- | navit/gui/qt5_qml/backend.cpp | 6 | ||||
-rw-r--r-- | navit/gui/qt5_qml/backend.h | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/navit/gui/qt5_qml/backend.cpp b/navit/gui/qt5_qml/backend.cpp index c9733b173..11057c76c 100644 --- a/navit/gui/qt5_qml/backend.cpp +++ b/navit/gui/qt5_qml/backend.cpp @@ -78,9 +78,9 @@ void Backend::get_maps() { label = g_strdup(description.u.str); } else { if (!map_get_attr(attr.u.map, attr_type, &type, NULL)) - type.u.str = ""; + type.u.str = (char*)""; if (!map_get_attr(attr.u.map, attr_data, &data, NULL)) - data.u.str = ""; + data.u.str = (char*)""; label = g_strdup_printf("%s:%s", type.u.str, data.u.str); } is_active = false; @@ -501,7 +501,7 @@ void Backend::updateSearch(QString text) { search->partial = 1; dbg(lvl_debug,"attempting to use country '%s'", _country_iso2); search_attr.type=attr_country_iso2; - search_attr.u.str=_country_iso2; + search_attr.u.str=(char*)_country_iso2; search_list_search(search->sl, &search_attr, 0); while((res=search_list_get_result(search->sl))); diff --git a/navit/gui/qt5_qml/backend.h b/navit/gui/qt5_qml/backend.h index 259be516c..9a27590d5 100644 --- a/navit/gui/qt5_qml/backend.h +++ b/navit/gui/qt5_qml/backend.h @@ -104,10 +104,10 @@ private: VehicleObject * m_currentVehicle; QList<QObject *> _search_results; void set_default_country(); - char * _country_iso2; - char * _current_country; - char * _current_town; - char * _current_street; + const char * _country_iso2; + const char * _current_country; + const char * _current_town; + const char * _current_street; struct search_param *search; enum attr_type _search_context; }; |