[mythtv-commits] Ticket #13013: Correct plist.cpp ParseBinaryDate processing

MythTV noreply at mythtv.org
Sat Mar 11 19:49:49 UTC 2017

#13013: Correct plist.cpp ParseBinaryDate processing
     Reporter:  Gary Buhrmaster                  |      Owner:
  <gary.buhrmaster@…>                            |
         Type:  Patch - Bug Fix                  |     Status:  new
     Priority:  minor                            |  Milestone:  unknown
    Component:  MythTV - General                 |    Version:  Master Head
     Severity:  medium                           |   Keywords:
Ticket locked:  0                                |
 Correct plist.cpp ParseBinaryDate processing

 gcc correctly warns about a bare time.addMSecs (it returns a QTime):

 plist.cpp: In member function ‘QVariant PList::ParseBinaryDate(quint8*)’:
 plist.cpp:467:30: warning: ignoring return value of ‘QTime
 QTime::addMSecs(int) const’, declared with attribute warn_unused_result
      time.addMSecs(msec % 1000);
 In file included from /usr/include/qt5/QtCore/QDateTime:1:0,
                  from plist.cpp:32:
 /usr/include/qt5/QtCore/qdatetime.h:178:11: note: declared here
      QTime addMSecs(int ms) const Q_REQUIRED_RESULT;

 If I understand the code correctly, the intent is to add in the msec
 offset value into the converted time, with the gyrations needed due to the
 limitation of the older QDateTime fromTime_t member (seconds only).

 Note that in Qt 5.8, QDateTime::fromTime_t is depcrecated, and since Qt
 5.2, a new function QDateTime::fromMSecsSinceEpoch exists that appears to
 do what was originally desired.

 Kill the warning (bug), and prepare for the future, with the following
 proposed patch:

 WARNING: Compile tested only (caveat emptor).

 diff --git a/mythtv/libs/libmythbase/plist.cpp
 index c21a776..9aba9b0 100644
 --- a/mythtv/libs/libmythbase/plist.cpp
 +++ b/mythtv/libs/libmythbase/plist.cpp
 @@ -459,16 +459,13 @@ QVariant PList::ParseBinaryDate(quint8 *data)
      quint64 count = GetBinaryCount(&data);
      if (count != 3)
          return result;

      convert_float(data, 8);
      quint64 msec = *((double*)data) * 1000.0f;
 -    result = QDateTime::fromTime_t(msec / 1000);
 -    QTime time = result.time();
 -    time.addMSecs(msec % 1000);
 -    result.setTime(time);
 +    result = QDateTime::fromMSecsSinceEpoch(msec, Qt::UTC);
      LOG(VB_GENERAL, LOG_DEBUG, LOC + QString("Date:
      return QVariant(result);

  QVariant PList::ParseBinaryData(quint8 *data)

Ticket URL: <https://code.mythtv.org/trac/ticket/13013>
MythTV <http://www.mythtv.org>
MythTV Media Center

More information about the mythtv-commits mailing list