D28478: [FileProtocol] change statx stat_dev() to return makedev(major, minor)
Ahmad Samir
noreply at phabricator.kde.org
Thu Apr 9 19:49:19 BST 2020
ahmadsamir added a comment.
hmm... first this is a copy-paste "error" on my part, I personally never use & when the RHS is a temporary (I don't see the point).
Anyway; looking at statResult():
const UDSEntry &StatJob::statResult() const
{
return d_func()->m_statResult;
}
it is returning a const &, and the docs say:
> Call this in the slot connected to result, and only after making sure no error happened.
here we used job->exec(), it may finish and get deleted; KJob docs say:
> KJob and its subclasses are meant to be used in a fire-and-forget way. Jobs will delete themselves when they finish using deleteLater() (although this behaviour can be changed), so a job instance will disappear after the next event loop run.
The test never failed before for me; but it seems I can trigger a SIGSEGV by running the test many times in a row; it's my "educated guess", sort of confirmed by using job->setAutoDelete(false), that the job may finish and get deleted by the time we call entry.numberValue() on line 1534.
So, to use job->statResult() to initialize a var &, that has to happen from a slot connected to result(); but if we call job->exec(), then later on we want to use the UDSEntry then we can't use var &, but rather take a copy.
And maybe statResult() shouldn't return a reference (or a const reference for that matter, because if the caller uses 'entry = job->statResult()'
then statResult() returning a const & doesn't make any difference if it's copied...).
@dfaure, WDYT?
REPOSITORY
R241 KIO
REVISION DETAIL
https://phabricator.kde.org/D28478
To: ahmadsamir, #frameworks, dfaure, meven, bruns
Cc: kde-frameworks-devel, LeGast00n, cblack, GB_2, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20200409/5d84dd90/attachment.html>
More information about the Kde-frameworks-devel
mailing list