- Fix insane width of lines in health graphic qt5transition
authorunc0rr
Sat, 10 Mar 2018 23:16:22 +0100
branchqt5transition
changeset 13158 99dd144f0a54
parent 12897 fc47fc4af6bd
child 13159 6f189da00c25
- Fix insane width of lines in health graphic - Fix scene leak
QTfrontend/ui/page/pagegamestats.cpp
QTfrontend/ui/page/pagegamestats.h
--- a/QTfrontend/ui/page/pagegamestats.cpp	Wed Jan 24 22:20:10 2018 +0100
+++ b/QTfrontend/ui/page/pagegamestats.cpp	Sat Mar 10 23:16:22 2018 +0100
@@ -78,6 +78,7 @@
     gbl->addWidget(graphic);
     graphic->scale(1.0, -1.0);
     graphic->setBackgroundBrush(QBrush(Qt::black));
+    graphic->setRenderHint(QPainter::Antialiasing, true);
 
     labelGameWin = new QLabel(this);
     labelGameWin->setTextFormat(Qt::RichText);
@@ -172,7 +173,8 @@
         labelGraphTitle->hide();
         graphic->hide();
     } else {
-        QGraphicsScene * scene = new QGraphicsScene();
+        graphic->setScene(Q_NULLPTR);
+        m_scene.reset(new QGraphicsScene(this));
 
         QMap<quint32, QVector<quint32> >::const_iterator i = healthPoints.constBegin();
         while (i != healthPoints.constEnd())
@@ -188,11 +190,15 @@
             for(int t = 1; t < hps.size(); ++t)
                 path.lineTo(t, hps[t]);
 
-            scene->addPath(path, QPen(c));
+            QPen pen(c);
+            pen.setWidth(2);
+            pen.setCosmetic(true);
+
+            m_scene->addPath(path, pen);
             ++i;
         }
 
-        graphic->setScene(scene);
+        graphic->setScene(m_scene.data());
         graphic->fitInView(graphic->sceneRect());
     }
 }
--- a/QTfrontend/ui/page/pagegamestats.h	Wed Jan 24 22:20:10 2018 +0100
+++ b/QTfrontend/ui/page/pagegamestats.h	Sat Mar 10 23:16:22 2018 +0100
@@ -70,6 +70,7 @@
         unsigned int playerPosition;
         quint32 lastColor;
         bool defaultGraphTitle;
+        QScopedPointer<QGraphicsScene> m_scene;
 
     protected:
         QLayout * bodyLayoutDefinition();