Fix crash on account deletion
authorChristian Kamm <mail@ckamm.de>
Thu, 6 Jul 2017 11:43:34 +0000 (13:43 +0200)
committerckamm <mail@ckamm.de>
Thu, 6 Jul 2017 12:34:02 +0000 (14:34 +0200)
commitd01065b9a12e69ca493a232f3a8e8f3d416fed52
tree78535e7432c55a07f6cdb5512afa55eeab087f6c
parentce8341ca1fd21d946e8c056430025f08d586e380
Fix crash on account deletion

Calling forgetSensitiveData() on account deletion leads to a timer for
clearQNAMCache() being queued. Then the Account object is deleted. The
Credentials object stays alive for now because it has a deleteLater
deleter.

If the timer calls into a slot on the Credentials object, the _account
pointer will be invalid at this time.

As a workaround, move the target slot to Account - that way it will not
be called as the account object is already destroyed.

However since Account and Credentials are mutually dependent, it would
be much preferable if their lifetimes were linked, avoiding this
category of bugs.

The current behavior was introduced in
d40c56eda561e3a541bf1b23f70fa8d659d3037e and I currently don't
understand why - maybe there's another way of dealing with the problem
that existed then.
src/libsync/account.cpp
src/libsync/account.h
src/libsync/creds/httpcredentials.cpp
src/libsync/creds/httpcredentials.h