Fix using avatars from the gallery and from local files
ClosedPublic

Authored by ngraham on Nov 13 2017, 3:25 PM.

Details

Summary

BUG: 385151

Use a KIO::copy job to ensure that ~/.face gets created correctly, and delete any temp files once they're no longer needed.

Test Plan

Tested in KDE Neon. With this change, ~/.face gets created properly, both when it did not previously exist (i.e. when the user is setting a picture for the first time), and also when it did previously exist (i.e. when the user is changing their picture). Tested for gallery avatars as well as several local files (.png, .jpg, .webp).

Diff Detail

Repository
R128 User Manager
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ngraham created this revision.Nov 13 2017, 3:25 PM
Restricted Application added a project: Plasma. · View Herald TranscriptNov 13 2017, 3:25 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
ngraham retitled this revision from Fix using avatars from the gallery to Fix using avatars from the gallery and from local files.Nov 13 2017, 3:28 PM
ngraham edited the test plan for this revision. (Show Details)
davidedmundson accepted this revision.Nov 13 2017, 3:42 PM

Please check we're not now leaking a file in /tmp when the user uses the pixmap region selector with a custom image.

This revision is now accepted and ready to land.Nov 13 2017, 3:42 PM

Yes, it looks like in that case, we leak /tmp/systemsettings.[number] since it's copied, not moved. I'll have to explicitly handle that case.

Actually, deleting the file in /tmp breaks it all over again in the same way, which is probably why this was broken when it was using a moveJob. Looks like we may have to live with having a file in /tmp, or else embark on a bigger change.

ngraham updated this revision to Diff 22306.Nov 14 2017, 2:59 AM

Found a way to safely remove the temp file and keep everything working

ngraham edited the summary of this revision. (Show Details)Nov 14 2017, 3:50 AM

@davidedmundson, does your approval still hold with the new change to clean up /tmp?

Not really. "Kcmshell5 usermanager" will still then leak.

Do you have any other ideas for solutions?

ngraham updated this revision to Diff 22374.Nov 15 2017, 2:20 AM

Consider any source file in /tmp/ to be a temp file that we should clear, so we don't leak files when run by kcmshell5 (or anything similar)

ngraham updated this revision to Diff 22375.Nov 15 2017, 5:37 AM

Rely on KF 5.40 and simplify the code a ton

Restricted Application added a subscriber: Dolphin. · View Herald TranscriptNov 15 2017, 5:37 AM
ngraham updated this revision to Diff 22377.Nov 15 2017, 5:49 AM

Restore correct diff

ngraham removed a subscriber: Dolphin.Nov 15 2017, 5:50 AM
davidedmundson accepted this revision.Nov 15 2017, 3:59 PM

No objections. It fixes a bug...

But, if you have the time, I'm sure we could come up wtih something much more elegant with some refactoring.

(like storing the pixmap in infToSave, and then just writing it into .face directly)

src/accountinfo.cpp
458–462

I know this isn't a line you've changed, and I hate it when reviewers comment about something unrelated, but it's on the screen and annoying me.

model->setData( some qstring)
model->data().value<QPixmap>()

how is that ever going to work?

Thanks for the approval. I'll land this, then the refactoring onto my to-do list. I agree that the current code is a bit stinky and could benefit from a more direct approach.

This revision was automatically updated to reflect the committed changes.