ActivityListModel: fix possible crash in slotActivitiesReceived
authorOlivier Goffart <ogoffart@woboq.com>
Mon, 6 Mar 2017 15:14:09 +0000 (16:14 +0100)
committerOlivier Goffart <olivier@woboq.com>
Mon, 6 Mar 2017 16:25:22 +0000 (17:25 +0100)
commitf4495c5c80c5f303b0b0542e87be23129ceba3b0
treeb7ad0a01cf1b2b73cf53d63571d32b758851bea6
parentf862c626a182c58c245228cf8c4fb00ab29fb869
ActivityListModel: fix possible crash in slotActivitiesReceived

Backtrace from the crash reporter:

Crash: EXCEPTION_ACCESS_VIOLATION_READ at 0x401
  File "moc_activitylistmo_M5OEXJ7XGJYTWT.cpp", line 92, in OCC::ActivityListModel::qt_static_metacall
  File "qobject.cpp", line 3730, in QMetaObject::activate
  File "moc_networkjobs_7AMNCW4BBANVRK.cpp", line 1342, in OCC::JsonApiJob::jsonReceived
  File "networkjobs.cpp", line 714, in OCC::JsonApiJob::finished
  File "abstractnetworkjob.cpp", line 207, in OCC::AbstractNetworkJob::slotFinished
  File "moc_abstractnetwor_PFI2TXGQHRE33H.cpp", line 98, in OCC::AbstractNetworkJob::qt_static_metacall
  File "qobject.cpp", line 3730, in QMetaObject::activate
  File "moc_qnetworkreply.cpp", line 367, in QNetworkReply::finished
  File "qnetworkreplyhttpimpl.cpp", line 2100, in QNetworkReplyHttpImplPrivate::finished
  File "qnetworkreplyhttpimpl.cpp", line 279, in QNetworkReplyHttpImpl::abort

My theory is that the AccountState stored in a property of the job was destroyed.
before the job timed out.
Therefore, the qobject_cast within the qvariant_cast would call the metaObject()
virtual function on a dangling pointer.

Fix it by storing a QPointer instead which will track the deletion.
src/gui/activitylistmodel.cpp