[vlc-commits] [Git][videolan/vlc][master] 2 commits: qt: CWE-476: NULL Pointer Dereference

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Aug 31 08:32:04 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
b3ab59e1 by Fatih Uzunoglu at 2023-08-31T08:11:22+00:00
qt: CWE-476: NULL Pointer Dereference

- - - - -
5ba34ec3 by Fatih Uzunoglu at 2023-08-31T08:11:22+00:00
qt: do not connect null sender

- - - - -


2 changed files:

- modules/gui/qt/player/control_list_filter.cpp
- modules/gui/qt/player/control_list_filter.hpp


Changes:

=====================================
modules/gui/qt/player/control_list_filter.cpp
=====================================
@@ -28,17 +28,23 @@
 // Ctor / dtor
 
 /* explicit */ ControlListFilter::ControlListFilter(QObject * parent)
-    : QSortFilterProxyModel(parent) {}
+    : QSortFilterProxyModel(parent)
+{
+    connect(this, &QAbstractProxyModel::sourceModelChanged, this, &ControlListFilter::sourceModelChanged1);
+}
 
 // QAbstractProxyModel reimplementation
 
-void ControlListFilter::setSourceModel(QAbstractItemModel * sourceModel) /* override */
+void ControlListFilter::setSourceModel(ControlListModel* sourceModel)
 {
-    assert(sourceModel->inherits("ControlListModel"));
-
     QSortFilterProxyModel::setSourceModel(sourceModel);
 }
 
+ControlListModel *ControlListFilter::sourceModel() const
+{
+    return qobject_cast<ControlListModel*>(QSortFilterProxyModel::sourceModel());
+}
+
 // Protected QSortFilterProxyModel reimplementation
 
 bool ControlListFilter::filterAcceptsRow(int source_row, const QModelIndex &) const /* override */
@@ -93,10 +99,13 @@ void ControlListFilter::setPlayer(PlayerController * player)
 
     m_player = player;
 
-    connect(player, &PlayerController::teletextAvailableChanged, this, &ControlListFilter::invalidateFilter);
-    connect(player, &PlayerController::hasMenuChanged,           this, &ControlListFilter::invalidateFilter);
-    connect(player, &PlayerController::hasChaptersChanged,       this, &ControlListFilter::invalidateFilter);
-    connect(player, &PlayerController::hasTitlesChanged,         this, &ControlListFilter::invalidateFilter);
+    if (player)
+    {
+        connect(player, &PlayerController::teletextAvailableChanged, this, &ControlListFilter::invalidateFilter);
+        connect(player, &PlayerController::hasMenuChanged,           this, &ControlListFilter::invalidateFilter);
+        connect(player, &PlayerController::hasChaptersChanged,       this, &ControlListFilter::invalidateFilter);
+        connect(player, &PlayerController::hasTitlesChanged,         this, &ControlListFilter::invalidateFilter);
+    }
 
     invalidate();
 


=====================================
modules/gui/qt/player/control_list_filter.hpp
=====================================
@@ -27,19 +27,21 @@
 // Forward declarations
 class PlayerController;
 class MainCtx;
+class ControlListModel;
 
 class ControlListFilter : public QSortFilterProxyModel
 {
     Q_OBJECT
 
-    Q_PROPERTY(PlayerController * player READ player WRITE setPlayer NOTIFY playerChanged)
-    Q_PROPERTY(MainCtx* ctx READ ctx WRITE setCtx NOTIFY ctxChanged)
+    Q_PROPERTY(ControlListModel* sourceModel READ sourceModel WRITE setSourceModel NOTIFY sourceModelChanged1 FINAL)
+    Q_PROPERTY(PlayerController * player READ player WRITE setPlayer NOTIFY playerChanged FINAL)
+    Q_PROPERTY(MainCtx* ctx READ ctx WRITE setCtx NOTIFY ctxChanged FINAL)
 
 public:
     explicit ControlListFilter(QObject * parent = nullptr);
 
-public: // QAbstractProxyModel reimplementation
-    void setSourceModel(QAbstractItemModel * sourceModel) override;
+    void setSourceModel(ControlListModel* sourceModel);
+    ControlListModel* sourceModel() const;
 
 protected: // QSortFilterProxyModel reimplementation
     bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const override;
@@ -47,6 +49,7 @@ protected: // QSortFilterProxyModel reimplementation
 signals:
     void playerChanged();
     void ctxChanged();
+    void sourceModelChanged1();
 
 public: // Properties
     PlayerController * player();



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/af3398dc11d9737f0026099eb5f598d24e63644c...5ba34ec3ae591d75656cb5b2fe046dd0197118a6

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/af3398dc11d9737f0026099eb5f598d24e63644c...5ba34ec3ae591d75656cb5b2fe046dd0197118a6
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