[vlc-devel] [PATCH 2/6] qt: QLinkedList is deprecated in Qt 5.15

Pierre Lamot pierre at videolabs.io
Thu May 28 14:41:53 CEST 2020


---
 .../gui/qt/widgets/native/interface_widgets.cpp   | 15 ++++++++-------
 .../gui/qt/widgets/native/interface_widgets.hpp   |  3 +--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/modules/gui/qt/widgets/native/interface_widgets.cpp b/modules/gui/qt/widgets/native/interface_widgets.cpp
index f509760d88..7e40bcea5f 100644
--- a/modules/gui/qt/widgets/native/interface_widgets.cpp
+++ b/modules/gui/qt/widgets/native/interface_widgets.cpp
@@ -540,7 +540,7 @@ void BackgroundWidget::contextMenuEvent( QContextMenuEvent *event )
 EasterEggBackgroundWidget::EasterEggBackgroundWidget( intf_thread_t *p_intf )
     : BackgroundWidget( p_intf )
 {
-    flakes = new QLinkedList<flake *>();
+    flakes = new std::list<flake *>();
     i_rate = 2;
     i_speed = 1;
     b_enabled = false;
@@ -593,7 +593,7 @@ void EasterEggBackgroundWidget::spawnFlakes()
 
     int i_spawn = ( (double) qrand() / RAND_MAX ) * i_rate;
 
-    QLinkedList<flake *>::iterator it = flakes->begin();
+    auto it = flakes->begin();
     while( it != flakes->end() )
     {
         flake *current = *it;
@@ -613,15 +613,16 @@ void EasterEggBackgroundWidget::spawnFlakes()
         flake *f = new flake;
         f->point.setX( qrand() * w );
         f->b_fat = ( qrand() < ( RAND_MAX * .33 ) );
-        flakes->append( f );
+        flakes->push_back( f );
     }
     update();
 }
 
 void EasterEggBackgroundWidget::reset()
 {
-    while ( !flakes->isEmpty() )
-        delete flakes->takeFirst();
+    for(flake* f: *flakes)
+        delete f;
+    flakes->clear();
 }
 
 void EasterEggBackgroundWidget::paintEvent( QPaintEvent *e )
@@ -631,8 +632,8 @@ void EasterEggBackgroundWidget::paintEvent( QPaintEvent *e )
     painter.setBrush( QBrush( QColor(Qt::white) ) );
     painter.setPen( QPen(Qt::white) );
 
-    QLinkedList<flake *>::const_iterator it = flakes->constBegin();
-    while( it != flakes->constEnd() )
+    auto it = flakes->cbegin();
+    while( it != flakes->cend() )
     {
         const flake * const f = *(it++);
         if ( f->b_fat )
diff --git a/modules/gui/qt/widgets/native/interface_widgets.hpp b/modules/gui/qt/widgets/native/interface_widgets.hpp
index 1e2a54fc64..2418cf5bf4 100644
--- a/modules/gui/qt/widgets/native/interface_widgets.hpp
+++ b/modules/gui/qt/widgets/native/interface_widgets.hpp
@@ -40,7 +40,6 @@
 #include <QLabel>
 #include <QMouseEvent>
 #include <QPropertyAnimation>
-#include <QLinkedList>
 
 class QMenu;
 class QSlider;
@@ -153,7 +152,7 @@ private:
         bool b_fat;
     };
     QTimer *timer;
-    QLinkedList<flake *> *flakes;
+    std::list<flake *> *flakes;
     int i_rate;
     int i_speed;
     bool b_enabled;
-- 
2.25.1



More information about the vlc-devel mailing list