Source: qcustomplot
Version: 2.0.1+dfsg1-1
Tags: patch
User: debian-qt-...@lists.debian.org
Usertags: qt5.14

Dear Maintainer,

One of qcustomplot autopkgtests fails when run against Qt 5.14, currently
available in experimental. It fails because of stderr:

  [ 83%] Building CXX object CMakeFiles/plots.dir/mainwindow.cpp.o
  /tmp/tmp.vk2CMqIqRc/src/mainwindow.cpp: In member function ‘void 
MainWindow::realtimeDataSlot()’:
  /tmp/tmp.vk2CMqIqRc/src/mainwindow.cpp:1386:29: warning: ‘int 
QTime::elapsed() const’ is deprecated: Use QElapsedTimer instead 
[-Wdeprecated-declarations]
   1386 |   double key = time.elapsed()/1000.0; // time elapsed since start of 
demo, in seconds
        |                             ^
  In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/QDateTime:1,
                   from /usr/include/qcustomplot.h:61,
                   from /tmp/tmp.vk2CMqIqRc/src/mainwindow.h:47,
                   from /tmp/tmp.vk2CMqIqRc/src/mainwindow.cpp:42:
  /usr/include/x86_64-linux-gnu/qt5/QtCore/qdatetime.h:230:54: note: declared 
here
    230 |     QT_DEPRECATED_X("Use QElapsedTimer instead") int elapsed() const;
        |                                                      ^~~~~~~

Attached is a patch that changes the code to use QElapsedTimer, as suggested.
It works with Qt 5.12 too.

--
Dmitry Shachnev
Description: use QElapsedTimer instead of deprecated QTime::elapsed()
Author: Dmitry Shachnev <mity...@debian.org>
Forwarded: no
Last-Update: 2020-05-19

--- a/examples/plots/mainwindow.cpp
+++ b/examples/plots/mainwindow.cpp
@@ -1381,9 +1381,11 @@ void MainWindow::setupFinancialDemo(QCus
 
 void MainWindow::realtimeDataSlot()
 {
-  static QTime time(QTime::currentTime());
+  static QElapsedTimer timer;
+  if (!timer.isValid())
+    timer.start();
   // calculate two new data points:
-  double key = time.elapsed()/1000.0; // time elapsed since start of demo, in seconds
+  double key = timer.elapsed()/1000.0; // time elapsed since start of demo, in seconds
   static double lastPointKey = 0;
   if (key-lastPointKey > 0.002) // at most add point every 2 ms
   {

Attachment: signature.asc
Description: PGP signature

Reply via email to