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

Porting to Qt6 #648

Open
nuqleo opened this issue Nov 29, 2023 · 42 comments
Open

Porting to Qt6 #648

nuqleo opened this issue Nov 29, 2023 · 42 comments
Labels
development This ticket describes a part of a development process

Comments

@nuqleo
Copy link

nuqleo commented Nov 29, 2023

The parent ticket

QMS-#

What do you plan to do

Hi,
I'm tring to compile qmapshack 1.17.0 with qt 6.6.0.
I created simple patch

--- qmapshack-V_1.17.0/cmake/Modules/Qt5PatchedLinguistToolsMacros.cmake	2023-07-20 17:13:59.000000000 +0300
+++ qmapshack-V_1.17.0.qt6/cmake/Modules/Qt5PatchedLinguistToolsMacros.cmake	2023-11-29 16:05:30.417881046 +0200
@@ -76,7 +76,7 @@ function(QT5_PATCHED_CREATE_TRANSLATION
           file(WRITE ${_ts_lst_file} "${_lst_file_srcs}")
         endif()
         add_custom_command(OUTPUT ${_ts_file}
-            COMMAND ${Qt5_LUPDATE_EXECUTABLE}
+            COMMAND /usr/lib64/qt6/bin/lupdate
             ARGS ${_lupdate_options} "@${_ts_lst_file}" -ts ${_ts_file}
             DEPENDS ${_my_sources} ${_ts_lst_file} VERBATIM)
     endforeach()
@@ -102,7 +102,7 @@ function(QT5_PATCHED_ADD_TRANSLATION _qm
         endif()
 
         add_custom_command(OUTPUT ${qm}
-            COMMAND ${Qt5_LRELEASE_EXECUTABLE}
+            COMMAND /usr/lib64/qt6/bin/lrelease
             ARGS ${_abs_FILE} -qm ${qm}
             DEPENDS ${_abs_FILE} VERBATIM
         )
--- qmapshack-V_1.17.0/CMakeLists.txt	2023-07-20 17:13:59.000000000 +0300
+++ qmapshack-V_1.17.0.qt6/CMakeLists.txt	2023-11-29 16:05:30.416881060 +0200
@@ -101,16 +101,16 @@ if (APPLE)
 
     if(NOT DEFINED QT_DEV_PATH)
         message(WARNING "QT_DEV_PATH not set!!!")
-        set(QT_DEV_PATH "${HOMEBREW_PREFIX}/opt/qt5" CACHE PATH "Path to Qt installation")
+        set(QT_DEV_PATH "${HOMEBREW_PREFIX}/opt/qt6" CACHE PATH "Path to Qt installation")
     endif()
     message("QT_DEV_PATH = ${QT_DEV_PATH}")
 
     if(NOT DEFINED ROUTINO_DEV_PATH)
         set(ROUTINO_DEV_PATH "${LOCAL_DEV}" CACHE PATH "Path to directory containing routino include and lib, e.g. lib/routino")
     endif(NOT DEFINED ROUTINO_DEV_PATH)
-    if(NOT DEFINED QuaZip-Qt5_DIR)
-        set(QuaZip-Qt5_DIR "${LOCAL_DEV}/lib/cmake/QuaZip-Qt5" CACHE PATH "Path to directory containing quazip cmake config files, e.g. lib/cmake/QuaZip-Qt5-1.3")
-    endif(NOT DEFINED QuaZip-Qt5_DIR)
+    if(NOT DEFINED QuaZip-Qt6_DIR)
+        set(QuaZip-Qt6_DIR "${LOCAL_DEV}/lib/cmake/QuaZip-Qt6" CACHE PATH "Path to directory containing quazip cmake config files, e.g. lib/cmake/QuaZip-Qt6-1.3")
+    endif(NOT DEFINED QuaZip-Qt6_DIR)
     if(NOT DEFINED PROJ_DEV_PATH)
         set(PROJ_DEV_PATH "${LOCAL_DEV}/lib/cmake/proj" CACHE PATH "Path to directory containing PROJ include and lib, e.g. lib/cmake/proj")
     endif(NOT DEFINED PROJ_DEV_PATH)
@@ -173,27 +173,27 @@ cxx_add_flag_if_supported(-Woverloaded-v
 ###############################################################################################
 # Find all required packages and setup internal variables
 ###############################################################################################
-find_package(Qt5Widgets             REQUIRED)
-find_package(Qt5Core                REQUIRED)
-find_package(Qt5Xml                 REQUIRED)
-find_package(Qt5Sql                 REQUIRED)
-find_package(Qt5LinguistTools       REQUIRED)
-find_package(Qt5PrintSupport        REQUIRED)
-find_package(Qt5UiTools             REQUIRED)
-find_package(Qt5Network             REQUIRED)
-find_package(Qt5WebEngineWidgets    REQUIRED)
-find_package(Qt5Qml                 REQUIRED)
-find_package(Qt5Help                REQUIRED)
+find_package(Qt6Widgets             REQUIRED)
+find_package(Qt6Core                REQUIRED)
+find_package(Qt6Xml                 REQUIRED)
+find_package(Qt6Sql                 REQUIRED)
+find_package(Qt6LinguistTools       REQUIRED)
+find_package(Qt6PrintSupport        REQUIRED)
+find_package(Qt6UiTools             REQUIRED)
+find_package(Qt6Network             REQUIRED)
+find_package(Qt6WebEngineWidgets    REQUIRED)
+find_package(Qt6Qml                 REQUIRED)
+find_package(Qt6Help                REQUIRED)
 find_package(GDAL                   REQUIRED)
 find_package(PROJ                   REQUIRED)
 find_package(JPEG                   REQUIRED)
 find_package(ROUTINO                REQUIRED)
-find_package(QuaZip-Qt5             REQUIRED)
+find_package(QuaZip-Qt6             REQUIRED)
 find_package(ALGLIB                         ) # optional as we can use our local version
 
 
-if(${Qt5Widgets_VERSION} VERSION_LESS 5.15.2)
-    message( SEND_ERROR "You need at least Qt5.15.2 or newer.")
+if(${Qt6Widgets_VERSION} VERSION_LESS 5.15.2)
+    message( SEND_ERROR "You need at least Qt6.15.2 or newer.")
 endif()
 
 if(${PROJ_VERSION} VERSION_LESS 8.0.0)
@@ -201,10 +201,10 @@ if(${PROJ_VERSION} VERSION_LESS 8.0.0)
 endif()
 
 if(USE_QT5DBus)
-    find_package(Qt5DBus REQUIRED)
-    if(Qt5DBus_FOUND)
+    find_package(Qt6DBus REQUIRED)
+    if(Qt6DBus_FOUND)
         add_definitions(-DHAVE_DBUS)
-    endif(Qt5DBus_FOUND)
+    endif(Qt6DBus_FOUND)
 endif(USE_QT5DBus)
 
 # Everything included. Let's finetune the mess a bit more
--- qmapshack-V_1.17.0/src/qmapshack/CMakeLists.txt	2023-07-20 17:13:59.000000000 +0300
+++ qmapshack-V_1.17.0.qt6/src/qmapshack/CMakeLists.txt	2023-11-29 16:05:30.416881060 +0200
@@ -367,12 +367,12 @@ set( SRCS
 )
 
 
-if(Qt5DBus_FOUND)
+if(Qt6DBus_FOUND)
 set( SRCS
     ${SRCS}
     device/CDeviceWatcherLinux.cpp
 )
-endif(Qt5DBus_FOUND)
+endif(Qt6DBus_FOUND)
 
 
 if (APPLE)
@@ -744,12 +744,12 @@ set( HDRS
 )
 
 
-if(Qt5DBus_FOUND)
+if(Qt6DBus_FOUND)
 set( HDRS
     ${HDRS}
     device/CDeviceWatcherLinux.h
 )
-endif(Qt5DBus_FOUND)
+endif(Qt6DBus_FOUND)
 
 
 if(APPLE)
@@ -904,8 +904,8 @@ set( RCS
 # Some Qt magic
 ###############################################################################################
 
-qt5_wrap_ui(UI_HDRS ${UIS})
-qt5_add_resources(RC_SRCS ${RCS})
+qt6_wrap_ui(UI_HDRS ${UIS})
+qt6_add_resources(RC_SRCS ${RCS})
 
 ###############################################################################################
 # Translation related stuff
@@ -975,22 +975,22 @@ if(${DEVELOPMENT_VERSION})
     )
 endif(${DEVELOPMENT_VERSION})
 
-if(Qt5DBus_FOUND)
-    set(DBUS_LIB Qt5::DBus)
-else(Qt5DBus_FOUND)
+if(Qt6DBus_FOUND)
+    set(DBUS_LIB Qt6::DBus)
+else(Qt6DBus_FOUND)
     set(DBUS_LIB)
-endif(Qt5DBus_FOUND)
+endif(Qt6DBus_FOUND)
 
 target_link_libraries(${APPLICATION_NAME}
-    Qt5::Widgets
-    Qt5::Xml
-    Qt5::Sql
-    Qt5::PrintSupport
-    Qt5::UiTools
-    Qt5::Network
-    Qt5::WebEngineWidgets
-    Qt5::Qml
-    Qt5::Help
+    Qt6::Widgets
+    Qt6::Xml
+    Qt6::Sql
+    Qt6::PrintSupport
+    Qt6::UiTools
+    Qt6::Network
+    Qt6::WebEngineWidgets
+    Qt6::Qml
+    Qt6::Help
     ${DBUS_LIB}
     ${GDAL_LIBRARIES}
     ${PROJ_LIBRARIES}
--- qmapshack-V_1.17.0/src/qmaptool/CMakeLists.txt	2023-07-20 17:13:59.000000000 +0300
+++ qmapshack-V_1.17.0.qt6/src/qmaptool/CMakeLists.txt	2023-11-29 16:05:30.416881060 +0200
@@ -194,8 +194,8 @@ set( RCS
 # Some Qt magic
 ###############################################################################################
 
-qt5_wrap_ui(UI_HDRS ${UIS})
-qt5_add_resources(RC_SRCS ${RCS})
+qt6_wrap_ui(UI_HDRS ${UIS})
+qt6_add_resources(RC_SRCS ${RCS})
 
 ###############################################################################################
 # Translation related stuff
@@ -259,9 +259,9 @@ target_compile_definitions(${APPLICATION
 )
 
 target_link_libraries(${APPLICATION_NAME}
-    Qt5::Widgets
-    Qt5::Network
-    Qt5::Help
+    Qt6::Widgets
+    Qt6::Network
+    Qt6::Help
     ${GDAL_LIBRARIES}
     ${PROJ_LIBRARIES}
 )
--- qmapshack-V_1.17.0/src/qmt_map2jnx/CMakeLists.txt	2023-07-20 17:13:59.000000000 +0300
+++ qmapshack-V_1.17.0.qt6/src/qmt_map2jnx/CMakeLists.txt	2023-11-29 16:05:30.416881060 +0200
@@ -50,8 +50,8 @@ IF(WIN32)
 ENDIF(WIN32)
 
 TARGET_LINK_LIBRARIES(${APPLICATION_NAME}
-    Qt5::Core
-    Qt5::Gui
+    Qt6::Core
+    Qt6::Gui
     ${GDAL_LIBRARIES}
     ${PROJ_LIBRARIES}
     ${JPEG_LIBRARIES})
--- qmapshack-V_1.17.0/src/qmt_rgb2pct/CMakeLists.txt	2023-07-20 17:13:59.000000000 +0300
+++ qmapshack-V_1.17.0.qt6/src/qmt_rgb2pct/CMakeLists.txt	2023-11-29 16:05:30.416881060 +0200
@@ -37,8 +37,8 @@ set( RCS
 # Some Qt magic
 ###############################################################################################
 
-qt5_wrap_ui(UI_HDRS ${UIS})
-qt5_add_resources(RC_SRCS ${RCS})
+qt6_wrap_ui(UI_HDRS ${UIS})
+qt6_add_resources(RC_SRCS ${RCS})
 
 ###############################################################################################
 # Translation related stuff
@@ -90,7 +90,7 @@ target_compile_definitions(${APPLICATION
 )
 
 target_link_libraries(${APPLICATION_NAME}
-    Qt5::Core
+    Qt6::Core
     ${GDAL_LIBRARIES}
     ${PROJ_LIBRARIES}
 )
--- qmapshack-V_1.17.0/test/unittest/CMakeLists.txt	2023-07-20 17:13:59.000000000 +0300
+++ qmapshack-V_1.17.0.qt6/test/unittest/CMakeLists.txt	2023-11-29 16:05:30.416881060 +0200
@@ -3,29 +3,29 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
 # Instruct CMake to run moc automatically when needed.
 set(CMAKE_AUTOMOC ON)
 
-find_package(Qt5Test)
+find_package(Qt6Test)
 
-find_package(Qt5Widgets)
-find_package(Qt5Core)
-find_package(Qt5Xml)
-find_package(Qt5Script)
-find_package(Qt5Sql)
-find_package(Qt5WebKitWidgets)
-find_package(Qt5LinguistTools)
-find_package(Qt5PrintSupport)
+find_package(Qt6Widgets)
+find_package(Qt6Core)
+find_package(Qt6Xml)
+find_package(Qt6Script)
+find_package(Qt6Sql)
+find_package(Qt6WebKitWidgets)
+find_package(Qt6LinguistTools)
+find_package(Qt6PrintSupport)
 if(UNIX)
-    if(Qt5DBus_FOUND)
-        find_package(Qt5DBus)
-    endif(Qt5DBus_FOUND)
+    if(Qt6DBus_FOUND)
+        find_package(Qt6DBus)
+    endif(Qt6DBus_FOUND)
 endif(UNIX)
 find_package(GDAL REQUIRED)
 find_package(PROJ REQUIRED)
 find_package(ROUTINO REQUIRED)
 
 if(UNIX)
-    if(Qt5DBus_FOUND)
-        set(DBUS_LIB Qt5::DBus)
-    endif(Qt5DBus_FOUND)
+    if(Qt6DBus_FOUND)
+        set(DBUS_LIB Qt6::DBus)
+    endif(Qt6DBus_FOUND)
 else(UNIX)
     set(DBUS_LIB)
 endif(UNIX)
@@ -48,7 +48,7 @@ include_directories(
     ${ALGLIB_INCLUDE_DIRS}
 )
 
-qt5_add_resources(RC_SRCS ./../../src/resources.qrc)
+qt6_add_resources(RC_SRCS ./../../src/resources.qrc)
 
 add_executable(qttest EXCLUDE_FROM_ALL
     main.cpp
@@ -66,13 +66,13 @@ add_executable(qttest EXCLUDE_FROM_ALL
 file(COPY input DESTINATION ${CMAKE_BINARY_DIR}/bin/)
 
 target_link_libraries(qttest
-    Qt5::Widgets
-    Qt5::Xml
-    Qt5::Script
-    Qt5::Sql
-    Qt5::WebKitWidgets
-    Qt5::PrintSupport
-    Qt5::Test
+    Qt6::Widgets
+    Qt6::Xml
+    Qt6::Script
+    Qt6::Sql
+    Qt6::WebKitWidgets
+    Qt6::PrintSupport
+    Qt6::Test
     QMS
     ${DBUS_LIB}
     ${GDAL_LIBRARIES}

but compilation failed in qmapshack

In file included from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/AL3DETLKD3/moc_CHelpBrowser.cpp:9,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/mocs_compilation.cpp:3:
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/AL3DETLKD3/../../../../../src/common/help/CHelpBrowser.h:35:8: error: ‘void CHelpBrowser::setSource(const QUrl&)’ marked ‘override’, but does not override
   35 |   void setSource(const QUrl& url) override;
      |        ^~~~~~~~~
In file included from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmapshack/gis/IGisItem.h:36,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmapshack/gis/rte/router/CRouterSetup.h:24,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/ui_IMainWindow.h:25,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/EWIEGA46WW/../../../../../src/qmapshack/CMainWindow.h:27,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/EWIEGA46WW/moc_CMainWindow.cpp:9,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/mocs_compilation.cpp:6:
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmapshack/units/IUnit.h:161:16: error: ‘QRegExp’ does not name a type
  161 |   static const QRegExp reCoord1;
      |                ^~~~~~~
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmapshack/units/IUnit.h:162:16: error: ‘QRegExp’ does not name a type
  162 |   static const QRegExp reCoord2;
      |                ^~~~~~~
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmapshack/units/IUnit.h:163:16: error: ‘QRegExp’ does not name a type
  163 |   static const QRegExp reCoord3;
      |                ^~~~~~~
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmapshack/units/IUnit.h:164:16: error: ‘QRegExp’ does not name a type
  164 |   static const QRegExp reCoord4;
      |                ^~~~~~~
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmapshack/units/IUnit.h:165:16: error: ‘QRegExp’ does not name a type
  165 |   static const QRegExp reCoord5;
      |                ^~~~~~~
In file included from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/KGLXD3X7AI/moc_CCanvas.cpp:9,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/mocs_compilation.cpp:7:
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/KGLXD3X7AI/../../../../../src/qmapshack/canvas/CCanvas.h:209:8: error: ‘void CCanvas::enterEvent(QEvent*)’ marked ‘override’, but does not override
  209 |   void enterEvent(QEvent* e) override;
      |        ^~~~~~~~~~
In file included from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/KMTMJ3IBZ2/../../../../../src/qmapshack/gis/CGisListWks.h:28,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/KMTMJ3IBZ2/moc_CGisListWks.cpp:9,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/mocs_compilation.cpp:24:
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmapshack/gis/trk/CTrackData.h:271:32: warning: ‘template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator’ is deprecated [-Wdeprecated-declarations]
  271 |   class iterator : public std::iterator<std::forward_iterator_tag, T2> {
      |                                ^~~~~~~~
In file included from /usr/include/c++/13/bits/stl_iterator_base_funcs.h:66,
                 from /usr/include/c++/13/variant:43,
                 from /usr/include/qt6/QtCore/qtypeinfo.h:11,
                 from /usr/include/qt6/QtCore/qglobal.h:47,
                 from /usr/include/qt6/QtGui/qtguiglobal.h:7,
                 from /usr/include/qt6/QtWidgets/qtwidgetsglobal.h:7,
                 from /usr/include/qt6/QtWidgets/qdockwidget.h:7,
                 from /usr/include/qt6/QtWidgets/QDockWidget:1,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/AL3DETLKD3/../../../../../src/common/help/CHelp.h:22,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/AL3DETLKD3/moc_CHelp.cpp:9,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/mocs_compilation.cpp:2:
/usr/include/c++/13/bits/stl_iterator_base_types.h:127:34: note: declared here
  127 |     struct _GLIBCXX17_DEPRECATED iterator
      |                                  ^~~~~~~~
In file included from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/KMTMJ3IBZ2/moc_CGisWorkspace.cpp:9,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/mocs_compilation.cpp:25:
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/KMTMJ3IBZ2/../../../../../src/qmapshack/gis/CGisWorkspace.h:292:70: error: ‘Null’ is not a member of ‘QString’
  292 |   void addWptByPos(const QPointF& pt, const QString& name = QString::Null(),
      |                                                                      ^~~~
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/KMTMJ3IBZ2/../../../../../src/qmapshack/gis/CGisWorkspace.h:293:51: error: ‘Null’ is not a member of ‘QString’
  293 |                    const QString& desc = QString::Null()) const;
      |                                                   ^~~~
In file included from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/DFBPGI5U35/../../../../../src/qmapshack/gis/ovl/CScrOptOvlArea.h:23,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/DFBPGI5U35/moc_CScrOptOvlArea.cpp:9,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/mocs_compilation.cpp:39:
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmapshack/mouse/IScrOpt.h:51:8: error: ‘void IScrOpt::enterEvent(QEvent*)’ marked ‘override’, but does not override
   51 |   void enterEvent(QEvent* e) override;
      |        ^~~~~~~~~~
In file included from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/PP5OLYOB7B/moc_CRouterBRouterTilesSelect.cpp:9,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/mocs_compilation.cpp:55:
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/PP5OLYOB7B/../../../../../src/qmapshack/gis/rte/router/brouter/CRouterBRouterTilesSelect.h:62:16: error: ‘QRegExp’ does not name a type
   62 |   static const QRegExp regExpTileName;
      |                ^~~~~~~
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/PP5OLYOB7B/../../../../../src/qmapshack/gis/rte/router/brouter/CRouterBRouterTilesSelect.h:63:16: error: ‘QRegExp’ does not name a type
   63 |   static const QRegExp regExpDate;
      |                ^~~~~~~
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/PP5OLYOB7B/../../../../../src/qmapshack/gis/rte/router/brouter/CRouterBRouterTilesSelect.h:64:16: error: ‘QRegExp’ does not name a type
   64 |   static const QRegExp regExpSize;
      |                ^~~~~~~
In file included from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/VQTIZUGSAA/../../../../../src/qmapshack/map/CMapIMG.h:27,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/VQTIZUGSAA/moc_CMapIMG.cpp:9,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/mocs_compilation.cpp:127:
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmapshack/map/garmin/CGarminTyp.h:182:3: error: ‘QTextCodec’ does not name a type
  182 |   QTextCodec* getCodec(quint16 codepage);
      |   ^~~~~~~~~~
In file included from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/DMHAXLKN4Z/../../../../../src/qmapshack/plot/CPlot.h:26,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/DMHAXLKN4Z/moc_CPlot.cpp:9,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmapshack/qmapshack_autogen/mocs_compilation.cpp:164:
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmapshack/plot/IPlot.h:79:8: error: ‘void IPlot::enterEvent(QEvent*)’ marked ‘override’, but does not override
   79 |   void enterEvent(QEvent* e) override;
      |        ^~~~~~~~~~
make[2]: *** [src/qmapshack/CMakeFiles/qmapshack.dir/build.make:1973: src/qmapshack/CMakeFiles/qmapshack.dir/qmapshack_autogen/mocs_compilation.cpp.o] Error 1
make[2]: Leaving directory '/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build'
make[1]: *** [CMakeFiles/Makefile2:185: src/qmapshack/CMakeFiles/qmapshack.dir/all] Error 2
make[1]: Leaving directory '/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build'
make: *** [Makefile:159: all] Error 2

in qmaptool

In file included from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/AL3DETLKD3/moc_CHelpBrowser.cpp:9,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/mocs_compilation.cpp:3:
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/AL3DETLKD3/../../../../../src/common/help/CHelpBrowser.h:35:8: error: ‘void CHelpBrowser::setSource(const QUrl&)’ marked ‘override’, but does not override
   35 |   void setSource(const QUrl& url) override;
      |        ^~~~~~~~~
In file included from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/ui_IMainWindow.h:23,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/EWIEGA46WW/../../../../../src/qmaptool/CMainWindow.h:24,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/EWIEGA46WW/moc_CMainWindow.cpp:9,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/mocs_compilation.cpp:7:
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmaptool/canvas/CCanvas.h:63:8: error: ‘void CCanvas::enterEvent(QEvent*)’ marked ‘override’, but does not override
   63 |   void enterEvent(QEvent* e) override;
      |        ^~~~~~~~~~
In file included from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmaptool/canvas/IDrawContext.h:26,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/KGLXD3X7AI/../../../../../src/qmaptool/canvas/CDrawContextPixel.h:22,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/KGLXD3X7AI/moc_CDrawContextPixel.cpp:9,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/mocs_compilation.cpp:9:
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmaptool/units/IUnit.h:123:16: error: ‘QRegExp’ does not name a type
  123 |   static const QRegExp reCoord1;
      |                ^~~~~~~
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmaptool/units/IUnit.h:124:16: error: ‘QRegExp’ does not name a type
  124 |   static const QRegExp reCoord2;
      |                ^~~~~~~
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmaptool/units/IUnit.h:125:16: error: ‘QRegExp’ does not name a type
  125 |   static const QRegExp reCoord3;
      |                ^~~~~~~
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmaptool/units/IUnit.h:126:16: error: ‘QRegExp’ does not name a type
  126 |   static const QRegExp reCoord4;
      |                ^~~~~~~
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmaptool/units/IUnit.h:127:16: error: ‘QRegExp’ does not name a type
  127 |   static const QRegExp reCoord5;
      |                ^~~~~~~
In file included from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/HU7TA6T7T7/moc_CItemListWidget.cpp:9,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/mocs_compilation.cpp:12:
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/HU7TA6T7T7/../../../../../src/qmaptool/items/CItemListWidget.h: In member function ‘void CItemListWidget::sort(LessThan)’:
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/HU7TA6T7T7/../../../../../src/qmaptool/items/CItemListWidget.h:52:42: warning: ‘constexpr typename std::add_const<_Tp>::type& qAsConst(T&) [with T = QList<QListWidgetItem*>; typename std::add_const<_Tp>::type = const QList<QListWidgetItem*>]’ is deprecated: Use std::as_const() instead. [-Wdeprecated-declarations]
   52 |     for (QListWidgetItem* item : qAsConst(items)) {
      |                                  ~~~~~~~~^~~~~~~
In file included from /usr/include/qt6/QtCore/qforeach.h:11,
                 from /usr/include/qt6/QtCore/qglobal.h:57,
                 from /usr/include/qt6/QtGui/qtguiglobal.h:7,
                 from /usr/include/qt6/QtWidgets/qtwidgetsglobal.h:7,
                 from /usr/include/qt6/QtWidgets/qdockwidget.h:7,
                 from /usr/include/qt6/QtWidgets/QDockWidget:1,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/AL3DETLKD3/../../../../../src/common/help/CHelp.h:22,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/AL3DETLKD3/moc_CHelp.cpp:9,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/mocs_compilation.cpp:2:
/usr/include/qt6/QtCore/qttypetraits.h:33:45: note: declared here
   33 | constexpr typename std::add_const<T>::type &qAsConst(T &t) noexcept { return t; }
      |                                             ^~~~~~~~
In file included from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/HU7TA6T7T7/moc_CItemTreeWidget.cpp:9,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/mocs_compilation.cpp:14:
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/HU7TA6T7T7/../../../../../src/qmaptool/items/CItemTreeWidget.h: In member function ‘void CItemTreeWidget::sort(LessThan)’:
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build/src/qmaptool/qmaptool_autogen/HU7TA6T7T7/../../../../../src/qmaptool/items/CItemTreeWidget.h:53:42: warning: ‘constexpr typename std::add_const<_Tp>::type& qAsConst(T&) [with T = QList<QTreeWidgetItem*>; typename std::add_const<_Tp>::type = const QList<QTreeWidgetItem*>]’ is deprecated: Use std::as_const() instead. [-Wdeprecated-declarations]
   53 |     for (QTreeWidgetItem *item : qAsConst(items)) {
      |                                  ~~~~~~~~^~~~~~~
/usr/include/qt6/QtCore/qttypetraits.h:33:45: note: declared here
   33 | constexpr typename std::add_const<T>::type &qAsConst(T &t) noexcept { return t; }
      |                                             ^~~~~~~~
make[2]: *** [src/qmaptool/CMakeFiles/qmaptool.dir/build.make:316: src/qmaptool/CMakeFiles/qmaptool.dir/qmaptool_autogen/mocs_compilation.cpp.o] Error 1
make[2]: Leaving directory '/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build'
make[1]: *** [CMakeFiles/Makefile2:237: src/qmaptool/CMakeFiles/qmaptool.dir/all] Error 2
make[1]: Leaving directory '/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build'
make: *** [Makefile:159: all] Error 2

and in qmt_rgb2pct

/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmt_rgb2pct/main.cpp: In function ‘void loadTranslations()’:
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmt_rgb2pct/main.cpp:50:47: warning: ‘static QString QLibraryInfo::location(LibraryLocation)’ is deprecated: Use path() [-Wdeprecated-declarations]
   50 |   QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
      |                         ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/qt6/QtCore/QtCore:140,
                 from /root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmt_rgb2pct/main.cpp:19:
/usr/include/qt6/QtCore/qlibraryinfo.h:48:20: note: declared here
   48 |     static QString location(LibraryLocation location)
      |                    ^~~~~~~~
/root/rpmbuild/BUILD/qmapshack-V_1.17.0/src/qmt_rgb2pct/main.cpp:52:27: error: ‘QRegExp’ was not declared in this scope
   52 |   translationPath.replace(QRegExp("bin$"), "share/" APP_STR "/translations");
      |                           ^~~~~~~
make[2]: *** [src/qmt_rgb2pct/CMakeFiles/qmt_rgb2pct.dir/build.make:97: src/qmt_rgb2pct/CMakeFiles/qmt_rgb2pct.dir/main.cpp.o] Error 1
make[2]: Leaving directory '/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build'
make[1]: *** [CMakeFiles/Makefile2:289: src/qmt_rgb2pct/CMakeFiles/qmt_rgb2pct.dir/all] Error 2
make[1]: Leaving directory '/root/rpmbuild/BUILD/qmapshack-V_1.17.0/redhat-linux-build'
make: *** [Makefile:159: all] Error 2

Is there plans to port QMapShack to Qt6?

The result will be

Successful compilation with Qt6.

@nuqleo nuqleo added the development This ticket describes a part of a development process label Nov 29, 2023
@nuqleo
Copy link
Author

nuqleo commented Nov 29, 2023

Switch from QRegExp to QRegularExpression example LubosD/twinkle#301

@kiozen
Copy link
Collaborator

kiozen commented Nov 30, 2023

No port to Qt6 planned, yet. But go ahead and open a PR once you have a working version that is ready to review.

see https://github.com/Maproom/qmapshack/wiki/DeveloperCommitCode

@a17r
Copy link

a17r commented Sep 5, 2024

Qt5WebEngine is now really on its last legs and a real burden to maintain for quite some time. Distributions are actively going to start rooting out revdeps soon. Without Qt5WebEngine this package could survive much longer in distributions' respositories, but still the need to port to Qt6 is there.

@frankystone
Copy link

Just wanted to mention that the current porting_qt6 branch compiles and runs fine here under archlinux. I just needed to install quazip-qt6.

@frankystone
Copy link

When switching between v1.17.1 and the porting_qt6 branch there is an issue with german umlauts.

Normally i work only with the porting_qt6 branch and all works fine. If i switch to version 1.17.1 (installed as package in archlinux) all works fine also. But switching back to the porting_qt6 branch the DEM data can't be found anymore. Reason is a mismatch in en/decoding the name of the folder(note the term "Höhendaten"):
qmapshack_german_umlauts

I have to remove the entry of the folder and add it again to get the DEM data back.

@wthaem
Copy link
Contributor

wthaem commented Oct 12, 2024

Comparing a string literal (which is of type const char*) directly with a QString may fail in Qt6.

Original issue found in src\qmapshack\map\CMapRMAP.cpp: rmap can't be loaded anymore.

Expression "CompeGPSRasterImage" != QString(charbuf) works in Qt5 but not in Qt6

From ChatGPT comment on this issue:

In Qt 5, the expression "CompeGPSRasterImage" != QString(charbuf) works because Qt 5 allows implicit conversions between certain types, such as between const char* and QString. However, in Qt 6, stricter type safety has been enforced, and implicit conversions between const char* and QString are no longer as lenient. This means that comparing a string literal (which is of type const char*) directly with a QString may lead to compilation errors in Qt 6.

To resolve this issue, you need to explicitly convert the const char* (or string literal) to a QString before performing the comparison.

Fixes recommended by ChatGPT didn't work for me.

My beginners work-around in CMapRMAP.cpp:

  QString str = "CompeGPSRasterImage";
  
  QString substring = QString(charbuf).left(19); 
  QString substring1 = str.left(19); 
  
  if (substring != substring1) {
  // if (str.toUtf8() != charbuf) {   <=========== fails
  // if (QString("CompeGPSRasterImage") != QString(charbuf)) {  <============ fails
    QMessageBox::warning(CMainWindow::getBestWidgetForParent(), tr("Error..."), tr("This is not a TwoNav RMAP file."),
                         QMessageBox::Abort, QMessageBox::Abort); 
    return;
  }

Experts will understand and simplify this.

It is likely that this issue can be found elsewhere in the QMS/QMT sources. Therefore, a bug fix (a PR) for the above-mentioned file was not yet prepared.

Is there an easy general approach (compiler switch?) for identifying this issue in the sources (in my case there wasn't any compiler error, instead a rmap file couldn't be loaded)?

@wthaem
Copy link
Contributor

wthaem commented Oct 22, 2024

SSL error in Qt6 version, but not in Qt5 version

Qt6 version error when calling a WMTS tile (sorry for German message):

Request to 
"https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&\
LAYER=HR.ORTHOIMAGERY.ORTHOPHOTOS&STYLE=normal&\
TILEMATRIXSET=PM_6_19&TILEMATRIX=12&TILEROW=1407&\
TILECOL=2075&FORMAT=image/jpeg" failed: 
"Im Ablauf des SSL-Protokolls ist ein Fehler aufgetreten.: 
Das angegebene Zertifikat kann in diesem Fall nicht verwendet werden"

Loading this tile (and others) with QMS Qt5 version or with Firefox succeeds without any error.

Any hints how to debug this error?

Others WMTS/TMS maps using https can be rendered without error.

@kiozen
Copy link
Collaborator

kiozen commented Oct 23, 2024

Don't you have to install some SSL stuff next to QT in Windows? Maybe you missed it or some outdated version is used. I would interpret the message as some corrupted or outdated certificate failing.

@wthaem
Copy link
Contributor

wthaem commented Oct 23, 2024

Thanks for the hint: An update of the libcrypto*.dll and libssl*.dll (in my case: an update of gisinternals) was the solution.

@frankystone
Copy link

When connecting a garmin device the folders aren't shown in qmapshack anymore for me. There is a warning of Broken filename passed to function

build_QMapShack/bin/qmapshack --debug
[...]
2024-11-04 21:13:15.575 [debug] Sanity test passed.
2024-11-04 21:13:16.189 [debug] model: "GARMIN Card" vendor: "Garmin" idLabel: "KARTE 60GB"
2024-11-04 21:13:16.707 [warning] Broken filename passed to function
2024-11-04 21:13:17.221 [debug] model: "GARMIN Flash" vendor: "Garmin" idLabel: "GARMIN"
2024-11-04 21:13:17.438 [warning] Broken filename passed to function

With version 1.17.1 the corresponding output is:

[...]
2024-11-04 21:24:07.290 [debug] Sanity test passed.
2024-11-04 21:24:07.985 [debug] model: "GARMIN Card" vendor: "Garmin" idLabel: "KARTE 60GB"
2024-11-04 21:24:10.324 [debug] Probe device at "/run/media/kaputtnik/KARTE 60GB" "/org/freedesktop/UDisks2/block_devices/sdg1" "KARTE 60GB"
2024-11-04 21:24:10.528 [debug] "/run/media/kaputtnik/KARTE 60GB/Garmin/GPX"
2024-11-04 21:24:10.528 [debug] "/run/media/kaputtnik/KARTE 60GB/Garmin/JPEG"
2024-11-04 21:24:10.528 [debug] "/run/media/kaputtnik/KARTE 60GB/Garmin/GeocachePhotos"
2024-11-04 21:24:10.528 [debug] "/run/media/kaputtnik/KARTE 60GB/Garmin/Activities"
2024-11-04 21:24:10.528 [debug] "/run/media/kaputtnik/KARTE 60GB/Garmin/GPX"
2024-11-04 21:24:10.528 [debug] "/run/media/kaputtnik/KARTE 60GB/Garmin/Locations"
2024-11-04 21:24:10.528 [debug] "/run/media/kaputtnik/KARTE 60GB"
2024-11-04 21:24:10.528 [debug] "/run/media/kaputtnik/KARTE 60GB"
2024-11-04 21:24:10.839 [debug] reading files from device:  "/run/media/kaputtnik/KARTE 60GB/Garmin/GPX"
[...]

@kkarsten62
Copy link
Contributor

kkarsten62 commented Nov 5, 2024

2024-11-04 21:13:16.707 [warning] Broken filename passed to function

Same for me with GARMIN Edge 1000.

I thought first it's related to my build in a VM and USB are not really bypassed to the VM.
But with deeper debugging:

void IDeviceWatcher::probeForDevice(const QString& mountPoint, const QString& path, const QString& label) {
  qDebug() << "mountPoint=" << mountPoint;

I get for:
QMS 1.17.1 branch "dev" | Fedora 40 | Wayland | Gnome 46 | Qt 5.15.5

2024-11-05 10:23:58.699 [debug] model: "GARMIN Card" vendor: "Garmin" idLabel: "GARMIN"
==> 2024-11-05 10:24:38.509 [debug] mountPoint= "/run/media/karl/GARMIN"

and for:
QMS 1.17.1 branch "porting_qt6" | Fedora 41 | Wayland | Gnome 47 | Qt 6.8.0

2024-11-05 10:41:57.061 [debug] model: "GARMIN Flash" vendor: "Garmin" idLabel: "GARMIN"
==> 2024-11-05 10:42:23.422 [debug] mountPoint= "/run/media/karl/GARMIN\u0000"

I guess QDBusMessage will reply mountpoint path with a trailing zero char.

A quick hack solve it for me:

QString CDeviceWatcherLinux::readMountPoint(const QString& path) {
[...]
  if (!points.isEmpty()) {
    QString point = points.first();
    // delete possible trailing zero char
    if (point.indexOf('\000', point.length() - 1) == (point.length() - 1)) {
      point = point.left(point.length() - 1);
    }
    return point;
  }
  return "";
}

@kiozen : Should I provide this fix for "porting_qt6"? If yes, how to proceed against branch "porting_qt6"?

@frankystone
Copy link

My guess is that QString in QT6 uses always UTF16 encoded strings. Linux by default produces UTF8 encoded strings afaik.

The proper solution might be is to use QString::fromStdString for such strings. But i am not sure about that, these encodings are a bit tricky, e.g i do not know if this may fail on windows machines.

Just stripping out some chars is definitely not a good solution, imho.

@frankystone
Copy link

Ok, you are right. DBus will return 0 as the last byte. E.g. this is the output if my device is mounted at sdg1.

$:> qdbus --system --literal org.freedesktop.UDisks2 /org/freedesktop/UDisks2/block_devices/sdg1 org.freedesktop.UDisks2.Filesystem.MountPoints
[Variant: [Argument: aay {{47, 114, 117, 110, 47, 109, 101, 100, 105, 97, 47, 107, 97, 112, 117, 116, 116, 110, 105, 107, 47, 75, 65, 82, 84, 69, 32, 54, 48, 71, 66, 0}}]]

Didn't get around all documentation but it seems QString in version 5.x stripped the leading zero and in version 6.x a \0 terminated string is produced.

For me changing this line

to

    points.append(point.chopped(1));

will do the trick. Probably there are better solutions for this issue.

@wthaem
Copy link
Contributor

wthaem commented Nov 5, 2024

My issue "Comparing a string literal (which is of type const char*) directly with a QString may fail in Qt6." mentioned earlier in this thread and @frankystone's string issue seem to have the same source.

@frankystone
Copy link

@wthaem I think the main problem of comparing char* with QString in your case is that the encoding of the read data of the file in not known.

For the DBus thing it's well known. According to the output of qdbus its aay

Argument: aay

which means this is an array of array of unsigned 8-bit values. The y stands for ASCII. Source: D-Bus specification

With this information one can convert the QBytearray to a QString and thus my solution from above could maybe better written as:

  for (const QByteArray& point : std::as_const(list)) {
    points.append(QString::fromLatin1(point, -1));          // converting
  }

See fromLatin1()

@kkarsten62 does this also work for you?

@kiozen
Copy link
Collaborator

kiozen commented Nov 6, 2024

Thanks for testing the porting branch. This is really crucial as this bug demonstrates. Keep up the good work!

And sorry for my late reply. Private constrains do not allow me to spend much time on QMapshack. This includes the open issues like translation etc.

Anyways I could get hold of an hour to provide a PR: #696

Please test on Linux and Windows.

The QBus API of Qt is really the worst I ever saw. Including the mess of the ever growing classes to work with strings. Actively removing the trailing 0 seems to be the only way to fix it. The whole encodeing/decoding wasn't well designed in Qt5 and IMHO it's got worse in Qt6.

@frankystone
Copy link

All those API updates are a pain. The older you get, the more pain they make… Did maintain a Django/Python driven website for many, many years with some updates of Django and switching from python2.7 to python3.x. My motivation to maintain it further is going to reach 0… It's just no fun anymore.

@frankystone
Copy link

Is there an easy general approach (compiler switch?) for identifying this issue in the sources (in my case there wasn't any compiler error, instead a rmap file couldn't be loaded)?

I've tried to grep over the code:

$:> grep -rn -E 'QString(.*) !='
src/qmapshack/device/CDeviceGarmin.cpp:125:  if (dirArchive.exists() && (dirArchive.entryList(QStringList("*.gpx")).count() != 0)) {

$:> grep -rn -E '!= QString(.*)'
src/qmaptool/overlay/refmap/CProjWizard.cpp:116:    if (di.pszOGCDatumName != QString()) {
src/qmaptool/overlay/refmap/CProjWizard.cpp:165:  if (di.pszOGCDatumName != QString()) {
src/qmapshack/map/CMapRMAP.cpp:43:  if ("CompeGPSRasterImage" != QString(charbuf)) {
src/qmapshack/grid/CProjWizard.cpp:114:    if (di.pszOGCDatumName != QString()) {
src/qmapshack/grid/CProjWizard.cpp:163:  if (di.pszOGCDatumName != QString()) {

But i don't know if this covers all possibilities.

@kiozen
Copy link
Collaborator

kiozen commented Nov 8, 2024

I would search for all QByteArray usage and check. But I lack the time. I hope I can find a couple of minutes to fix RMAP support next week. And then I will merge the PR.

@frankystone
Copy link

That's a lot of stuff… The number beside the filename is the line number, eg 7 is the line number in CMakeLists.txt.user:7: The output grepping over the QMS-694 branch

$:> grep -rn 'QByteArray'
CMakeLists.txt.user:7:  <value type="QByteArray">{e69f8491-77c5-4d14-aeaa-fe640e86d8b2}</value>
CMakeLists.txt.user:22:     <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
CMakeLists.txt.user:28:     <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
CMakeLists.txt.user:32:   <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
grep: .git/objects/pack/pack-f65b87322ae4a774be7acfbe05ad52a26c06999f.pack: Übereinstimmungen in Binärdatei
src/qmaptool/overlay/COverlayRefMap.cpp:76:  QByteArray buffer;
src/qmaptool/overlay/COverlayRefMap.cpp:97:  QByteArray buffer;
src/qmaptool/canvas/CCanvas.cpp:30:  loadIndicator1 = new QMovie("://animation/loader.gif", QByteArray(), this);
src/qmaptool/units/IUnit.h:73:  static QByteArray pos2timezone(const QPointF& pos);
src/qmaptool/units/IUnit.h:84:  static void getTimeZoneSetup(tz_mode_e& mode, QByteArray& zone, bool& format) {
src/qmaptool/units/IUnit.h:90:  static void setTimeZoneSetup(tz_mode_e mode, const QByteArray& zone, bool format) {
src/qmaptool/units/IUnit.h:115:  static QByteArray timeZone;
src/qmaptool/units/IUnit.cpp:34:QByteArray IUnit::timeZone = "UTC";
src/qmaptool/units/IUnit.cpp:585:QByteArray IUnit::pos2timezone(const QPointF& pos) {
src/qmaptool/units/CTimeZoneSetup.cpp:26:  QByteArray zone;
src/qmaptool/units/CTimeZoneSetup.cpp:68:  QByteArray zone = comboTimeZone->currentText().toLatin1();
src/qmaptool/setup/CAppSetupWin.h:39:  QByteArray path;
src/qmt_rgb2pct/CApp.cpp:29:  QByteArray array = str.toUtf8();
src/qmt_rgb2pct/CApp.cpp:35:  QByteArray array = str.toUtf8();
src/qmt_rgb2pct/CApp.cpp:134:  QByteArray buf = sctFilename.toUtf8();
src/qmt_rgb2pct/CApp.cpp:192:    QByteArray buffer1(xsize, 0);
src/qmt_rgb2pct/CApp.cpp:193:    QByteArray buffer2(xsize, 0);
src/qmapshack/helpers/CTimeDialog.cpp:31:  const QByteArray& zone = cfg.value("timezone", QTimeZone::systemTimeZone().id()).toByteArray();
src/qmapshack/helpers/CTimeDialog.cpp:34:  const QList<QByteArray>& ids = QTimeZone::availableTimeZoneIds();
src/qmapshack/helpers/CTimeDialog.cpp:35:  foreach (const QByteArray& id, ids) {
src/qmapshack/CMainWindow.cpp:126:  QByteArray tz;
src/qmapshack/CMainWindow.cpp:575:  QByteArray tz;
src/qmapshack/CMainWindow.cpp:1486:bool CMainWindow::nativeEvent(const QByteArray& eventType, void* message, qintptr* result) {
src/qmapshack/canvas/CCanvas.cpp:114:  loadIndicator1 = new QMovie("://animation/loader.gif", QByteArray(), this);
src/qmapshack/canvas/CCanvas.cpp:120:  loadIndicator2 = new QMovie("://animation/loader2.gif", QByteArray(), this);
src/qmapshack/canvas/CCanvas.cpp:126:  loadIndicator3 = new QMovie("://animation/loader3.gif", QByteArray(), this);
src/qmapshack/map/CMapGEMF.cpp:70:    QByteArray name(NAMEBUFLEN, 0);
src/qmapshack/map/CMapGEMF.cpp:253:      QByteArray imageData(size, 0);
src/qmapshack/map/CMapIMG.cpp:415:    QByteArray array = file.readAll();
src/qmapshack/map/CMapIMG.cpp:431:      QByteArray array;
src/qmapshack/map/CMapIMG.cpp:443:void CMapIMG::readFile(CFileExt& file, quint32 offset, quint32 size, QByteArray& data) {
src/qmapshack/map/CMapIMG.cpp:448:  data = QByteArray::fromRawData(file.data(offset, size), size);
src/qmapshack/map/CMapIMG.cpp:499:  QByteArray imghdr;
src/qmapshack/map/CMapIMG.cpp:510:  mapdesc = QByteArray((const char*)pImgHdr->desc1, 20);
src/qmapshack/map/CMapIMG.cpp:517:  QByteArray FATblock;
src/qmapshack/map/CMapIMG.cpp:657:  QByteArray trehdr;
src/qmapshack/map/CMapIMG.cpp:708:  QByteArray maplevel;
src/qmapshack/map/CMapIMG.cpp:750:  QByteArray subdiv_n;
src/qmapshack/map/CMapIMG.cpp:761:  QByteArray rgnhdr;
src/qmapshack/map/CMapIMG.cpp:885:    QByteArray subdiv2;
src/qmapshack/map/CMapIMG.cpp:973:    QByteArray lblhdr;
src/qmapshack/map/CMapIMG.cpp:980:    QByteArray nethdr;
src/qmapshack/map/CMapIMG.cpp:1244:    QByteArray rgndata;
src/qmapshack/map/CMapIMG.cpp:1308:void CMapIMG::loadSubDiv(CFileExt& file, const subdiv_desc_t& subdiv, IGarminStrTbl* strtbl, const QByteArray& rgndata,
src/qmapshack/map/garmin/CGarminTyp.cpp:36:bool CGarminTyp::decode(const QByteArray& array, QMap<quint32, polygon_property>& polygons,
src/qmapshack/map/garmin/CGarminTyp.cpp:448:        QByteArray str;
src/qmapshack/map/garmin/CGarminTyp.cpp:799:        QByteArray str;
src/qmapshack/map/garmin/CGarminTyp.cpp:1113:        QByteArray str;
src/qmapshack/map/garmin/IGarminStrTbl.h:25:class QByteArray;
src/qmapshack/map/garmin/IGarminStrTbl.h:53:  void readFile(CFileExt& file, quint32 offset, quint32 size, QByteArray& data);
src/qmapshack/map/garmin/CGarminStrTblUtf8.cpp:41:  QByteArray data;
src/qmapshack/map/garmin/CGarminStrTbl6.cpp:119:  QByteArray data;
src/qmapshack/map/garmin/CGarminTyp.h:167:  bool decode(const QByteArray& array, QMap<quint32, polygon_property>& polygons,
src/qmapshack/map/garmin/CGarminStrTbl8.cpp:42:  QByteArray data;
src/qmapshack/map/garmin/IGarminStrTbl.cpp:62:void IGarminStrTbl::readFile(CFileExt& file, quint32 offset, quint32 size, QByteArray& data) {
src/qmapshack/map/garmin/IGarminStrTbl.cpp:68:  data = QByteArray::fromRawData(file.data(offset, size), size);
src/qmapshack/map/garmin/IGarminStrTbl.cpp:99:    QByteArray buffer;
src/qmapshack/map/garmin/IGarminStrTbl.cpp:108:    QByteArray data;
src/qmapshack/map/CMapIMG.h:162:  void readFile(CFileExt& file, quint32 offset, quint32 size, QByteArray& data);
src/qmapshack/map/CMapIMG.h:165:  void loadSubDiv(CFileExt& file, const subdiv_desc_t& subdiv, IGarminStrTbl* strtbl, const QByteArray& rgndata,
src/qmapshack/map/CMapRMAP.cpp:40:  QByteArray charbuf(20, 0);
src/qmapshack/map/CMapJNX.cpp:28:static void readCString(QDataStream& stream, QByteArray& ba) {
src/qmapshack/map/CMapJNX.cpp:156:      QByteArray ba;
src/qmapshack/map/CMapJNX.cpp:170:    QByteArray ba;
src/qmapshack/map/CMapJNX.cpp:317:    QByteArray data(1024 * 1024 * 4, 0);
src/qmapshack/map/CMapJNX.cpp:320:    // Maybe the QByteArray declaration should be fixed ;-)
src/qmapshack/units/IUnit.h:107:  static QByteArray pos2timezone(const QPointF& pos);
src/qmapshack/units/IUnit.h:120:  static void getTimeZoneSetup(tz_mode_e& mode, QByteArray& zone, bool& format) {
src/qmapshack/units/IUnit.h:126:  static void setTimeZoneSetup(tz_mode_e mode, const QByteArray& zone, bool format) {
src/qmapshack/units/IUnit.h:153:  static QByteArray timeZone;
src/qmapshack/units/IUnit.cpp:35:QByteArray IUnit::timeZone = "UTC";
src/qmapshack/units/IUnit.cpp:754:QByteArray IUnit::pos2timezone(const QPointF& pos) {
src/qmapshack/units/CTimeZoneSetup.cpp:26:  QByteArray zone;
src/qmapshack/units/CTimeZoneSetup.cpp:68:  QByteArray zone = comboTimeZone->currentText().toLatin1();
src/qmapshack/setup/CAppSetupWin.h:36:  QByteArray path;
src/qmapshack/gis/db/IDBFolderSql.cpp:119:  QByteArray msg;
src/qmapshack/gis/db/CDBProject.cpp:50:  QByteArray data = query.value(2).toByteArray();
src/qmapshack/gis/db/CDBProject.cpp:270:  QByteArray data;
src/qmapshack/gis/db/CDBProject.cpp:367:  QByteArray data;
src/qmapshack/gis/db/CDBProject.cpp:575:  QByteArray data;
src/qmapshack/gis/db/CDBProject.cpp:682:  QByteArray data = query.value(2).toByteArray();
src/qmapshack/gis/qms/serialization.cpp:492:  QByteArray buffer;
src/qmapshack/gis/qms/serialization.cpp:530:  QByteArray buffer;
src/qmapshack/gis/qms/serialization.cpp:623:  QByteArray buffer;
src/qmapshack/gis/qms/serialization.cpp:674:  QByteArray buffer;
src/qmapshack/gis/qms/serialization.cpp:699:  QByteArray buffer;
src/qmapshack/gis/qms/serialization.cpp:753:  QByteArray buffer;
src/qmapshack/gis/qms/serialization.cpp:786:  QByteArray buffer;
src/qmapshack/gis/qms/serialization.cpp:836:  QByteArray buffer;
src/qmapshack/gis/CGisListDB.cpp:883:    QByteArray datagram;
src/qmapshack/gis/trk/filter/CFilterNewDate.cpp:29:  QByteArray zone;
src/qmapshack/gis/search/CGeoSearch.h:59:  void parseNominatim(const QByteArray& data);
src/qmapshack/gis/search/CGeoSearch.h:60:  void parseGeonamesSearch(const QByteArray& data);
src/qmapshack/gis/search/CGeoSearch.h:61:  void parseGeonamesAddress(const QByteArray& data);
src/qmapshack/gis/search/CGeoSearch.h:62:  void parseGoogle(const QByteArray& data);
src/qmapshack/gis/search/CGeoSearch.cpp:205:  QByteArray data = reply->readAll();
src/qmapshack/gis/search/CGeoSearch.cpp:325:void CGeoSearch::parseGoogle(const QByteArray& data) {
src/qmapshack/gis/search/CGeoSearch.cpp:370:void CGeoSearch::parseGeonamesSearch(const QByteArray& data) {
src/qmapshack/gis/search/CGeoSearch.cpp:438:void CGeoSearch::parseGeonamesAddress(const QByteArray& data) {
src/qmapshack/gis/search/CGeoSearch.cpp:562:void CGeoSearch::parseNominatim(const QByteArray& data) {
src/qmapshack/gis/prj/IGisProject.cpp:173:    QByteArray buffer;
src/qmapshack/gis/prj/IGisProject.cpp:819:  QByteArray buffer;
src/qmapshack/gis/IGisItem.cpp:201:    QByteArray buffer;
src/qmapshack/gis/IGisItem.cpp:226:    QByteArray data(query.value(0).toByteArray());
src/qmapshack/gis/fit/decoder/CFitByteDataTransformer.h:37:  static QByteArray getBytes(quint8* rawData, quint8 length);
src/qmapshack/gis/fit/decoder/CFitByteDataTransformer.cpp:145:QByteArray CFitByteDataTransformer::getBytes(quint8* rawData, quint8 length) {
src/qmapshack/gis/fit/decoder/CFitByteDataTransformer.cpp:146:  return QByteArray((const char*)rawData, length);
src/qmapshack/gis/qlb/CQlbProject.h:36:  void loadWpts(QByteArray& array);
src/qmapshack/gis/qlb/CQlbProject.h:37:  void loadTrks(QByteArray& array);
src/qmapshack/gis/qlb/CQlbProject.h:38:  void loadRtes(QByteArray& array);
src/qmapshack/gis/qlb/CQlbProject.h:39:  void loadOvls(QByteArray& array);
src/qmapshack/gis/qlb/CQlbProject.cpp:75:void CQlbProject::loadWpts(QByteArray& array) {
src/qmapshack/gis/qlb/CQlbProject.cpp:86:void CQlbProject::loadTrks(QByteArray& array) {
src/qmapshack/gis/qlb/CQlbProject.cpp:97:void CQlbProject::loadRtes(QByteArray& array) {
src/qmapshack/gis/qlb/CQlbProject.cpp:108:void CQlbProject::loadOvls(QByteArray& array) {
src/qmapshack/gis/rte/router/CRouterBRouter.cpp:333:    const QByteArray& res = reply->readAll();
src/qmapshack/gis/rte/router/CRouterBRouter.cpp:458:    const QByteArray& res = reply->readAll();
src/qmapshack/gis/rte/router/CRouterMapQuest.cpp:30:const QByteArray CRouterMapQuest::keyMapQuest = "Fmjtd%7Cluu2n16t2h%2Crw%3Do5-haya0";
src/qmapshack/gis/rte/router/CRouterMapQuest.cpp:289:  QByteArray res = reply->readAll();
src/qmapshack/gis/rte/router/brouter/CRouterBRouterSetup.cpp:671:      const QByteArray& content = file.readAll();
src/qmapshack/gis/rte/router/brouter/CRouterBRouterSetup.cpp:703:  const QByteArray& content = reply->readAll();
src/qmapshack/gis/rte/router/brouter/CRouterBRouterDownloadPage.cpp:73:  request.setRawHeader(QByteArray("Accept"), QByteArray("application/vnd.github+json"));
src/qmapshack/gis/rte/router/brouter/CRouterBRouterDownloadPage.cpp:74:  request.setRawHeader(QByteArray("X-GitHub-Api-Version"), QByteArray("2022-11-28"));
src/qmapshack/gis/rte/router/brouter/CRouterBRouterDownloadPage.cpp:123:    QByteArray content = reply->readAll();
src/qmapshack/gis/rte/router/CRouterMapQuest.h:48:  static const QByteArray keyMapQuest;
src/qmapshack/gis/IGisItem.h:55:    QByteArray data;
src/qmapshack/gis/CGisListWks.cpp:741:    QByteArray data;
src/qmapshack/gis/CGisListWks.cpp:790:      QByteArray data = query.value(5).toByteArray();
src/qmapshack/CMainWindow.h:129:  bool nativeEvent(const QByteArray& eventType, void* message, qintptr* result);
src/qmapshack/CMainWindow.h:223:  QByteArray dockStates;
src/qmapshack/qlgt/CQlgtFolder.cpp:46:    QByteArray data = query.value(1).toByteArray();
src/qmapshack/qlgt/CQmsDb.cpp:152:  QByteArray data;
src/qmapshack/qlgt/CQmsDb.cpp:222:  QByteArray data;
src/qmapshack/qlgt/CQlgtDiary.cpp:25:  QByteArray data;
src/qmapshack/qlgt/CQlgtDb.cpp:272:          QByteArray bytes;
src/qmapshack/qlgt/CQlgtDb.cpp:305:          QByteArray array = query.value(1).toByteArray();
src/qmapshack/qlgt/CQlgtDb.cpp:359:          QByteArray array = query.value(1).toByteArray();
src/qmapshack/qlgt/CQlgtDb.cpp:601:    QByteArray data = query.value(1).toByteArray();
src/qmapshack/qlgt/IQlgtOverlay.cpp:25:  QByteArray data;
src/qmapshack/qlgt/CQlb.h:21:#include <QByteArray>
src/qmapshack/qlgt/CQlb.h:36:    qint32 eWpt, QByteArray wpts
src/qmapshack/qlgt/CQlb.h:64:  QByteArray& waypoints() { return wpts; }
src/qmapshack/qlgt/CQlb.h:66:  QByteArray& tracks() { return trks; }
src/qmapshack/qlgt/CQlb.h:68:  QByteArray& diary() { return drys; }
src/qmapshack/qlgt/CQlb.h:70:  QByteArray& overlays() { return ovls; }
src/qmapshack/qlgt/CQlb.h:72:  QByteArray& routes() { return rtes; }
src/qmapshack/qlgt/CQlb.h:74:  QByteArray& mapsels() { return sels; }
src/qmapshack/qlgt/CQlb.h:84:  QByteArray wpts;
src/qmapshack/qlgt/CQlb.h:86:  QByteArray trks;
src/qmapshack/qlgt/CQlb.h:88:  QByteArray rtes;
src/qmapshack/qlgt/CQlb.h:90:  QByteArray drys;
src/qmapshack/qlgt/CQlb.h:92:  QByteArray ovls;
src/qmapshack/qlgt/CQlb.h:94:  QByteArray sels;
src/qmapshack/qlgt/CQlgtTrack.cpp:42:  QByteArray data;
src/qmapshack/qlgt/CQlgtRoute.cpp:25:  QByteArray data;
src/qmapshack/qlgt/CQlgtWpt.cpp:27:  QByteArray data;
src/qmapshack/CMakeLists.txt.user:7:  <value type="QByteArray">{e69f8491-77c5-4d14-aeaa-fe640e86d8b2}</value>
src/qmapshack/CMakeLists.txt.user:22:     <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
src/qmapshack/CMakeLists.txt.user:28:     <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
src/qmapshack/CMakeLists.txt.user:32:   <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
src/qmapshack/device/CDeviceWatcherLinux.cpp:184:    // This translates to an array of QByteArray. Don't know why there
src/qmapshack/device/CDeviceWatcherLinux.cpp:191:      QByteArray data;
src/qmapshack/realtime/gpstether/CRtGpsTetherInfo.cpp:254:  const QByteArray& data = line.toLatin1();
src/qmapshack/realtime/gpstether/CRtGpsTetherRecord.cpp:24:  QByteArray data;
src/qmapshack/realtime/IRtRecord.h:78:  virtual bool writeEntry(const QByteArray& data);
src/qmapshack/realtime/IRtRecord.h:91:  virtual bool readEntry(QByteArray& data);
src/qmapshack/realtime/IRtRecord.cpp:52:    QByteArray data;
src/qmapshack/realtime/IRtRecord.cpp:69:bool IRtRecord::writeEntry(const QByteArray& data) {
src/qmapshack/realtime/IRtRecord.cpp:93:bool IRtRecord::readEntry(QByteArray& data) {
src/qmapshack/realtime/ais/CRtAisInfo.h:64:  using fAisHandler = std::function<void(const QByteArray&)>;
src/qmapshack/realtime/ais/CRtAisInfo.h:65:  fAisHandler aisDefault = [&](const QByteArray& t) { qDebug() << QString::number(t[0]) << "unknown"; };
src/qmapshack/realtime/ais/CRtAisInfo.h:118:  quint32 get6bitInt(const QByteArray& data, int start, int count);
src/qmapshack/realtime/ais/CRtAisInfo.h:119:  qint64 get6bitSignedInt(const QByteArray& data, int start, int count);
src/qmapshack/realtime/ais/CRtAisInfo.h:120:  void getString(const QByteArray& data, QString& string, int start, int count);
src/qmapshack/realtime/ais/CRtAisInfo.h:261:  void aisClassAcommon(const QByteArray& data);
src/qmapshack/realtime/ais/CRtAisInfo.h:262:  void aisStaticAndVoyage(const QByteArray& data);
src/qmapshack/realtime/ais/CRtAisInfo.h:263:  void aisClassBcommon(const QByteArray& data);
src/qmapshack/realtime/ais/CRtAisInfo.h:264:  void aisAidToNavigation(const QByteArray& data);
src/qmapshack/realtime/ais/CRtAisInfo.h:265:  void aisStatic(const QByteArray& data);
src/qmapshack/realtime/ais/CRtAisInfo.h:275:  QByteArray assembler;
src/qmapshack/realtime/ais/CRtAisRecord.cpp:24:  QByteArray data;
src/qmapshack/realtime/ais/CRtAisInfo.cpp:56:  aisDict[positionReportClassA] = [&](const QByteArray& t) { aisClassAcommon(t); };
src/qmapshack/realtime/ais/CRtAisInfo.cpp:57:  aisDict[positionReportClassAassignedScheduled] = [&](const QByteArray& t) { aisClassAcommon(t); };
src/qmapshack/realtime/ais/CRtAisInfo.cpp:58:  aisDict[positionReportClassAresponseToInterrogation] = [&](const QByteArray& t) { aisClassAcommon(t); };
src/qmapshack/realtime/ais/CRtAisInfo.cpp:59:  aisDict[staticAndVoyageRelatedData] = [&](const QByteArray& t) { aisStaticAndVoyage(t); };
src/qmapshack/realtime/ais/CRtAisInfo.cpp:60:  aisDict[standardClassBpositionReport] = [&](const QByteArray& t) { aisClassBcommon(t); };
src/qmapshack/realtime/ais/CRtAisInfo.cpp:61:  aisDict[extendedClassBequipmentPositionReport] = [&](const QByteArray& t) { aisClassBcommon(t); };
src/qmapshack/realtime/ais/CRtAisInfo.cpp:62:  aisDict[aidToNavigationReport] = [&](const QByteArray& t) { aisAidToNavigation(t); };
src/qmapshack/realtime/ais/CRtAisInfo.cpp:63:  aisDict[staticDataReport] = [&](const QByteArray& t) { aisStatic(t); };
src/qmapshack/realtime/ais/CRtAisInfo.cpp:196:  const QByteArray& data = line.toLatin1();
src/qmapshack/realtime/ais/CRtAisInfo.cpp:209:  const QByteArray& payload = tokens[5].toLatin1();
src/qmapshack/realtime/ais/CRtAisInfo.cpp:215:  QByteArray data(payload.size(), 0);
src/qmapshack/realtime/ais/CRtAisInfo.cpp:251:void CRtAisInfo::aisClassAcommon(const QByteArray& data) {
src/qmapshack/realtime/ais/CRtAisInfo.cpp:280:void CRtAisInfo::aisStaticAndVoyage(const QByteArray& data) {
src/qmapshack/realtime/ais/CRtAisInfo.cpp:324:void CRtAisInfo::aisClassBcommon(const QByteArray& data) {
src/qmapshack/realtime/ais/CRtAisInfo.cpp:370:void CRtAisInfo::aisAidToNavigation(const QByteArray& data) {
src/qmapshack/realtime/ais/CRtAisInfo.cpp:405:void CRtAisInfo::aisStatic(const QByteArray& data) {
src/qmapshack/realtime/ais/CRtAisInfo.cpp:453:quint32 CRtAisInfo::get6bitInt(const QByteArray& data, int start, int count) {
src/qmapshack/realtime/ais/CRtAisInfo.cpp:484:qint64 CRtAisInfo::get6bitSignedInt(const QByteArray& data, int start, int count) {
src/qmapshack/realtime/ais/CRtAisInfo.cpp:496:void CRtAisInfo::getString(const QByteArray& data, QString& string, int start, int count) {
src/qmapshack/realtime/opensky/CRtOpenSky.cpp:262:  QByteArray data = reply->readAll();
src/qmapshack/realtime/opensky/CRtOpenSkyRecord.cpp:24:  QByteArray data;

@frankystone
Copy link

frankystone commented Nov 12, 2024

I can't scroll the list of waypoint icons with the porting_qt6 branch. To reproduce:

  • Add a new waypoint
  • Click on the waypoint icon
  • Try to scroll down the list

Scrolling down produces an "up arrow" at the top of the list, but the list doesn't scroll down. So it is not possible to choose an icon which is below the display.

Window manager kwin on X11

@wthaem
Copy link
Contributor

wthaem commented Nov 13, 2024

I can't scroll the list of waypoint icons with the porting_qt6 branch.

Couldn't find any issue on Windows 10. Can change waypoint icon without problem.

@frankystone
Copy link

Another small issue:

  • Add a new map view
  • Click rename map view

The editbox to change name of the view has a "&" sign somewhere in the name. This happens also for existing map views. The name of the mapviews tab is clean though.
qmapshack_qt6_rename_mapview

@wthaem
Copy link
Contributor

wthaem commented Nov 13, 2024

Again: everything ok with Windows10.

@frankystone
Copy link

Started with a fresh environment by renaming the folder containing qmapshack.conf and workspace.db. Also removed the language, still the same for me. Looking into qmapshack.conf there are several entries like:

Views\View%201\backColor=#ffffbf
[...]
Views\View%201\scales=0

The map view name shown in QMS was View 1, so i wonder where the %20 is coming from.

@wthaem how are those entries in your qmapshack.conf?

@kiozen
Copy link
Collaborator

kiozen commented Nov 14, 2024

I tried to reproduce both issues.

  1. Waypoint Icon: The list of icons is scaled the way that it fits into the screen. No need to scroll. Do you have a special screen size? Maybe related to Can't return sidebar windows to sidebar (Plasma Wayland) #691

  2. No & in the view name. If I recall right the & is used in Qt to mark the shortcut key when part of the name. But I do not see why this should happen. See ctor of CCanvas. Also see https://doc.qt.io/qt-6/qtabwidget.html#addTab

The %20 is an escape sequence for the space in the name. HTTP URLs use the same mechanism.

@wthaem
Copy link
Contributor

wthaem commented Nov 14, 2024

In my case Views\Ansicht%201\backColor=#ffffbf as it should be. For explanation see last comment by kiozen.

@frankystone
Copy link

Thanks for the explanation and testing.

Waypoint Icon: The list of icons is scaled the way that it fits into the screen. No need to scroll. Do you have a special screen size?

The list never fitted onto my screen, also with QMS 1.17.1. My screen size is 1920 x 1080 pixel:

$:> xrandr 
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
DisplayPort-0 disconnected (normal left inverted right x axis y axis)
HDMI-A-0 disconnected (normal left inverted right x axis y axis)
DVI-D-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 527mm x 296mm
   1920x1080     60.00*+  50.00    59.94 
   [...]

Screenshot of full screen height, i can't scroll to a waypoint icon below "Gas Station":
qmapshack_qt6_waypoints

Name of view, i can live with that ;)

@kiozen
Copy link
Collaborator

kiozen commented Nov 14, 2024

Strange the list always looked like this on all of my machines

Screenshot from 2024-11-14 09-49-13

@wthaem
Copy link
Contributor

wthaem commented Nov 14, 2024

Strange the list always looked like this on all of my machines

On so it looks on Windows.

@frankystone
Copy link

Looks like on my machine qt thinks my screen is much bigger … will ask in the arch linux forum if they have any ideas why this might happen.

@frankystone
Copy link

@frankystone
Copy link

Can someone with a multi column waypoint list please check menu->sizeHint() in

QMenu* menu = getWptIconMenu("", nullptr, "", parent);
QAction* action = menu->exec(QCursor::pos());

Here it says (256, 3154) which i believe is the cause of my problem with the waypoint list.

I have tried to set different QSizePolicys but all of them depend on sizeHint() somehow and didn't worked for me.

At least: If i add menu->setMaximumHeight(1080); it's possible for me to scroll the single column list again. But this is not a solution at all.

@vincentxavier
Copy link

Thanks for the explanation and testing.

Waypoint Icon: The list of icons is scaled the way that it fits into the screen. No need to scroll. Do you have a special screen size?

The list never fitted onto my screen, also with QMS 1.17.1. My screen size is 1920 x 1080 pixel:

$:> xrandr 
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
DisplayPort-0 disconnected (normal left inverted right x axis y axis)
HDMI-A-0 disconnected (normal left inverted right x axis y axis)
DVI-D-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 527mm x 296mm
   1920x1080     60.00*+  50.00    59.94 
   [...]

Screenshot of full screen height, i can't scroll to a waypoint icon below "Gas Station": qmapshack_qt6_waypoints

Name of view, i can live with that ;)

I confirm. same bug on linux/wayland

@frankystone
Copy link

frankystone commented Nov 28, 2024

I spend some days to get any information about this issue but couldn't find any, except that qt devs say a QMenu shouldn't contain so much entries and one should consider to rethink this. But this isn't an explanation for this issue nor a solution, imho. @vincentxavier which window manager do you use?

As far i can tell using openbox as a window manger the way-point-icon-list is multicolumn, whereas using i3 and kwin the list is single column and can not be scrolled with QT 6. Looking at the screenshot from @kiozen he uses some Gnome window manager and @wthaem uses windows.

Edit: At least i am not alone :-)

@vincentxavier
Copy link

vincentxavier commented Nov 28, 2024 via email

@kiozen
Copy link
Collaborator

kiozen commented Nov 29, 2024

Just for the records: I use Mint Linux with Gnome. And Tuxedo OS with KDE on my systems. The menu is displayed as multi-column perfectly fitting the screen on all systems.

qt devs say a QMenu shouldn't contain so much entries and one should consider to rethink this

Oh dear. That is a lot of confidence in their own product.

Did anyone test against a Qt version directly installed from the Qt binary servers? Packages shipped with distributions are sometimes weird. Just had my share of that with GDAL packages yesterday.

@frankystone
Copy link

Did anyone test against a Qt version directly installed from the Qt binary servers? Packages shipped with distributions are sometimes weird.

archlinux packages are as close to upstream as they can, if they change anything then adjusting the system file paths in configs. source

And i have tested the behavior with the openbox window manager on the same machine, just in another virtual console (STRG+ALT+Fx). So it uses the same qt-version.

All i can tell is that that with each call to menu->addAction() in this loop

for (const QString& key : qAsConst(keys)) {
const QString& icon = wptIcons[key].path;
QPixmap pixmap = loadIcon(icon);
QAction* action = menu->addAction(pixmap, key);
action->setProperty("iconName", key);
if (obj != nullptr) {
QAction::connect(action, SIGNAL(triggered(bool)), obj, slot);
}
}

the sizeHint grows in height per 27 px . But the behavior is different with kwin and openbox:

  • with openbox: if the screen height (1080 in my case) is reached the width changes also and the height of sizeHint will not change anymore. The result at the end of the loop is sizeHint() = QSize(696, 1075)
  • with kwin: it adds those 27 px to the height until the loop ends. The result in the end of the loop is sizeHint() = QSize(252, 3154)

According to the documentation the values of sizeHint holds the recommended size for the widget. Since here the sizeHint has a height of 3154 it will exceed the screen height when displayed.

Another difference from openbox and kwin is that the initial values of sizeHint are different (taken directly after initialization of the menu QMenu* menu = new QMenu(title, parent);):

  • openbox: initial values are QSize(-1, -1), which is an invalid size and no preferred size is used
  • kwin: initial values are QSize(3, 3)

I have tried to subclass QMenu to override sizeHint() to return initially QSize(-1, -1) but due to my little knowledge of c++ i made probably a failure and this didn't worked.

I have also added a new user on my machine so default values are set and some misconfiguration can be excluded. But the result is the same.

All these calculations made by qt are a bit hidden, at least i couldn't find any information how sizeHint is initially calculated and how addAction() may affect the recalculation of sizeHint.

Lost in QT 😄

@frankystone
Copy link

If someone wants to test, i've made a branch which produces debug output: https://github.com/frankystone/qmapshack/tree/debug_qmenu

Example output on my machine:

2024-11-29 18:10:24.153 [debug] sizeHint initial:  QSize(3, 3)
2024-11-29 18:10:24.153 [debug] size initial:  QSize(100, 30)
2024-11-29 18:10:24.153 [debug] sizePolicy QSizePolicy(horizontalPolicy = QSizePolicy::Preferred, verticalPolicy = QSizePolicy::Preferred)
2024-11-29 18:10:24.153 [debug] geometry initial:  QRect(0,0 100x30)
2024-11-29 18:10:24.153 [debug] layout initial:  QObject(0x0)

2024-11-29 18:10:24.157 [debug] sizeHint end:  QSize(252, 3154)
2024-11-29 18:10:24.157 [debug] size end:  QSize(100, 30)
2024-11-29 18:10:24.157 [debug] sizePolicy end:  QSizePolicy(horizontalPolicy = QSizePolicy::Preferred, verticalPolicy = QSizePolicy::Preferred)
2024-11-29 18:10:24.157 [debug] geometry end:  QRect(0,0 100x30)
2024-11-29 18:10:24.157 [debug] layout end:  QObject(0x0)

This branch contains also some lines (commented now) which at least gives the possibility to scroll the single column again.

@frankystone
Copy link

It seems i found the culprit: It's the style (Design) of the desktop. If i switch the global design of my desktop to "Oxygen" ... tadaaaa... the menu is multi column. If i switch back to "Breeze" it's single column again. Now my desktop is messed up, but hey this was worth it.
After digging into this much more it's sufficient to change the "application style" to "Oxygen". This setting can be found in System settings -> Color and Designs -> Application style (might be called different in detail, i just have translated from german).

@vincentxavier you can test another style by starting qmapshack like path/to/qmapshack -style windows. See QStyle

Will dig much more into this...

@frankystone
Copy link

A quick and dirty workaround:

  // Workaround a bug when using breeze as application style
  // "windows" is a default style shipped with qt
  const auto & cur_style = QApplication::style()->objectName();
  if (cur_style == "breeze") {
      QStyle* style = QStyleFactory::create("windows");
      menu->setStyle(style);
  }

@vincentxavier
Copy link

vincentxavier commented Dec 1, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development This ticket describes a part of a development process
Projects
None yet
Development

No branches or pull requests

7 participants