[KPhotoAlbum] Crash in pixmapLoaded

Andreas Neustifter andreas.neustifter at gmail.com
Tue Dec 15 21:45:37 GMT 2015


Hi,

okay this is complicated (to explain) and maybe the solution is too
compilcated but this is what was possible (for me) without a major
rearchitecture.

All the ImageRequest's that are handed to AsyncLoader return their results
by calling pixmapLoaded from the creating object.

My machine is quite slow and I have many videos in my library so when video
thumbnails are requestes from AsyncLoader (for e.g. the image merger) KPA
crashes reproducibly when the requesting object is deleted before the
request is processes because the request uses
request->client()->pixmapLoaded() to hand the result to a non-existent
requestor.

My solution is to
1.) add the ability to mark a request as obsolete.
https://github.com/astifter/kphotoalbum-astifter-branch/commit/1ab3a1ec5536b6428ef8d47029883e46cc795894

2.) use that information in to make sure requests are dropped/do not send
data when the request is obsolete.
https://github.com/astifter/kphotoalbum-astifter-branch/commit/1c02f7692eec1b08d79f9a9a254ef5af5b4a1bbd

3.) make sure all the objects creating ImageRequest's handle them properly:
 - NULL request pointer on construct
 - store pointer to request when creating it
 - NULL the request pointer when pixmapLoaded is called
 - when requestor is destroyed mark possibly open request as obsolete.
https://github.com/astifter/kphotoalbum-astifter-branch/commit/9268038d101727b6444fed35971b6bb32bfa36c8

It would be cleaner to handle this with a shared_ptr to client in the
request but this would disrupt the code even more (I would have to make
sure that all objects creating the ImageRequest are heap-allocated as well.

Feedback, comments?

Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kphotoalbum/attachments/20151215/d784395b/attachment.htm>


More information about the Kphotoalbum mailing list