maplibre / maplibre-native-qt

MapLibre Qt Bindings and Qt Location Plugin
34 stars 12 forks source link

Create struc `Style` with empty url possible #107

Closed bongbui321 closed 5 months ago

bongbui321 commented 5 months ago

This helps solves the problem of compiling with Qt 5.12, making it possible to create Styles with QVector

ntadej commented 5 months ago

Thanks for the contribution!

Can you maybe also paste the compilation error you get without this patch to se if we can work around it in another way. If we can't, we probably need to add some sanity checks where Style is used.

bongbui321 commented 5 months ago

Here is the error, thank you for the quick response. Also do you happen to know if qt5 location private dev will be available on the upcoming ubuntu 24.04? it seems that it is not available on 20.04 and 22.04 (I'm not sure on this one)

In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/QVector:1,
                 from /home/bongb/maplibre-native-qt/src/core/types.hpp:14,
                 from /home/bongb/maplibre-native-qt/build/src/core/include/QMapLibre/Types:1,
                 from /home/bongb/maplibre-native-qt/src/core/settings.hpp:10,
                 from /home/bongb/maplibre-native-qt/src/core/settings.cpp:6:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qvector.h: In instantiation of ‘void QVector<T>::reallocData(int, int, QArrayData::AllocationOptions) [with T = QMapLibre::Style; QArrayData::AllocationOptions = QFlags<QArrayData::AllocationOption>]’:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qvector.h:705:20:   required from ‘void QVector<T>::append(T&&) [with T = QMapLibre::Style]’
/home/bongb/maplibre-native-qt/src/core/settings.cpp:456:109:   required from here
/usr/include/x86_64-linux-gnu/qt5/QtCore/qvector.h:607:33: error: no matching function for call to ‘QMapLibre::Style::Style()’
  607 |                                 new (dst++) T();
      |                                 ^~~~~~~~~~~~~~~
In file included from /home/bongb/maplibre-native-qt/build/src/core/include/QMapLibre/Types:1,
                 from /home/bongb/maplibre-native-qt/src/core/settings.hpp:10,
                 from /home/bongb/maplibre-native-qt/src/core/settings.cpp:6:
/home/bongb/maplibre-native-qt/src/core/types.hpp:45:14: note: candidate: ‘QMapLibre::Style::Style(QString, QString)’
   45 |     explicit Style(QString url_, QString name_ = QString())
      |              ^~~~~
/home/bongb/maplibre-native-qt/src/core/types.hpp:45:14: note:   candidate expects 2 arguments, 0 provided
/home/bongb/maplibre-native-qt/src/core/types.hpp:29:31: note: candidate: ‘QMapLibre::Style::Style(const QMapLibre::Style&)’
   29 | struct Q_MAPLIBRE_CORE_EXPORT Style {
      |                               ^~~~~
/home/bongb/maplibre-native-qt/src/core/types.hpp:29:31: note:   candidate expects 1 argument, 0 provided
/home/bongb/maplibre-native-qt/src/core/types.hpp:29:31: note: candidate: ‘QMapLibre::Style::Style(QMapLibre::Style&&)’
/home/bongb/maplibre-native-qt/src/core/types.hpp:29:31: note:   candidate expects 1 argument, 0 provided
[ 94%] Building CXX object src/core/CMakeFiles/Core.dir/style/layer_parameter.cpp.o
make[2]: *** [src/core/CMakeFiles/Core.dir/build.make:146: src/core/CMakeFiles/Core.dir/settings.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:365: src/core/CMakeFiles/Core.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
codecov[bot] commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (91e64b0) 45.27% compared to head (89a352f) 45.27%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #107 +/- ## ======================================= Coverage 45.27% 45.27% ======================================= Files 35 35 Lines 2125 2125 ======================================= Hits 962 962 Misses 1163 1163 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ntadej commented 5 months ago

OK, can you then maybe protect your change for Qt versions below 5.15 using

#if QT_VERSION M QT_VERSION_CHECK(5, 15, 0)

and so that for supported versions we explicitly require the first argument.

bongbui321 commented 5 months ago

Added sanity check