[vlc-commits] [Git][videolan/vlc][master] 4 commits: qt: avoid mixing const and non-const iterators

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Aug 31 09:48:51 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
8c1ab0d4 by Johannes Kauffmann at 2023-08-31T09:09:40+00:00
qt: avoid mixing const and non-const iterators

Found with Clazy, using clazy-strict-iterators

- - - - -
40616419 by Johannes Kauffmann at 2023-08-31T09:09:40+00:00
qt: build with QT_STRICT_ITERATORS

This will prevent implicit conversion from iterator to const_iterator in
the future.

Adding the define in qt.hpp is not sufficient, as it is not included
early enough in simple_preferences.cpp.

- - - - -
1720fef0 by Johannes Kauffmann at 2023-08-31T09:09:40+00:00
qt: avoid temporary allocation for qDeleteAll

Found with Clazy, using clazy-qdeleteall

- - - - -
e1c8bf95 by Johannes Kauffmann at 2023-08-31T09:09:40+00:00
qt: remove deprecated Q_ENUMS usage

Use Q_ENUM and move under the enum itself.

- - - - -


5 changed files:

- modules/gui/qt/Makefile.am
- modules/gui/qt/dialogs/dialogs/dialogmodel.hpp
- modules/gui/qt/dialogs/epg/EPGView.cpp
- modules/gui/qt/dialogs/preferences/simple_preferences.cpp
- modules/gui/qt/meson.build


Changes:

=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -21,6 +21,7 @@ vlc_qt_check_CPPFLAGS = $(AM_CPPFLAGS)
 vlc_qt_check_LDADD = $(vlc_qt_libs)
 
 libqt_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) \
+	-DQT_STRICT_ITERATORS \
 	-I$(srcdir)/gui/qt -I$(builddir)/gui/qt/ \
 	-I$(builddir)/gui/qt/dialogs/extended \
 	-I$(builddir)/gui/qt/dialogs/fingerprint \


=====================================
modules/gui/qt/dialogs/dialogs/dialogmodel.hpp
=====================================
@@ -57,8 +57,6 @@ class DialogErrorModel : public QAbstractListModel, public Singleton<DialogError
 {
     Q_OBJECT
 
-    Q_ENUMS(DialogRoles)
-
     Q_PROPERTY(int count READ count NOTIFY countChanged FINAL)
     Q_PROPERTY(QString notificationText READ notificationText NOTIFY countChanged FINAL)
     Q_PROPERTY(int repeatedMessageCount READ repeatedMessageCount NOTIFY countChanged FINAL)
@@ -69,6 +67,7 @@ public: // Enums
         DIALOG_TITLE = Qt::UserRole + 1,
         DIALOG_TEXT
     };
+    Q_ENUM(DialogRoles)
 
 private:
     struct DialogError
@@ -118,13 +117,12 @@ class DialogModel : public QObject
 {
     Q_OBJECT
 
-    Q_ENUMS(QuestionType)
-
     Q_PROPERTY(MainCtx* ctx READ getCtx WRITE setCtx NOTIFY ctxChanged FINAL)
 
 public: // Enums
     // NOTE: Is it really useful to have this declared here ?
     enum QuestionType { QUESTION_NORMAL, QUESTION_WARNING, QUESTION_CRITICAL };
+    Q_ENUM(QuestionType)
 
 public:
     explicit DialogModel(QObject *parent = nullptr);


=====================================
modules/gui/qt/dialogs/epg/EPGView.cpp
=====================================
@@ -158,7 +158,7 @@ bool EPGView::updateEPG( const vlc_epg_t * const *pp_epg, size_t i_epg )
 void EPGView::reset()
 {
     /* clean our items storage and remove them from the scene */
-    qDeleteAll(programs.values());
+    qDeleteAll(programs);
     programs.clear();
     m_startTime = m_maxTime = QDateTime();
 }


=====================================
modules/gui/qt/dialogs/preferences/simple_preferences.cpp
=====================================
@@ -1137,7 +1137,7 @@ void SPrefsPanel::apply()
 
     /* Generic save for ever panel */
     QList<ConfigControl *>::const_iterator i;
-    for( i = controls.begin() ; i != controls.end() ; ++i )
+    for( i = controls.cbegin() ; i != controls.cend() ; ++i )
     {
         ConfigControl *c = qobject_cast<ConfigControl *>(*i);
         c->doApply();


=====================================
modules/gui/qt/meson.build
=====================================
@@ -7,7 +7,7 @@ qt5 = import('qt5')
 qt_include_dir = include_directories('.')
 
 qt_extra_deps = []
-qt_extra_flags = []
+qt_extra_flags = ['-DQT_STRICT_ITERATORS']
 qt_cppargs = []
 
 qt5_dep = dependency('qt5',



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f80c6dadb581d3c329cbd1e3354aa2af5896392d...e1c8bf95d02e42f0743e9d27adb49c083ddb0128

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f80c6dadb581d3c329cbd1e3354aa2af5896392d...e1c8bf95d02e42f0743e9d27adb49c083ddb0128
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list