Bug 443788

Summary: Attempting to share via email when there are no suitable email clients installed causes the calling app to crash in Purpose::EmailJob::start()
Product: [Frameworks and Libraries] frameworks-purpose Reporter: Kalzi <kalzwayed>
Component: generalAssignee: Aleix Pol <aleixpol>
Status: RESOLVED FIXED    
Severity: crash CC: bharadwaj.raju777, nate, sbmichael
Priority: NOR Keywords: usability
Version: 5.87.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 5.88
Attachments: crash backtrace

Description Kalzi 2021-10-15 14:00:04 UTC
SUMMARY
When right-click on a desktop icon/folder, hover over "share" and choose "send via email", the desktop would blink, goes black for a second then "refreshes". I don't think that this is a normal behavior. I think that there should be a message that tells me "there isn't an email app" or something like that, since I don't have an email app.

STEPS TO REPRODUCE
1. No email app installed
2. Right-click on a folder/file on the desktop
3. Hover over "share" and choose "share via email"

OBSERVED RESULT
Screen would blink/panic, goes black for a brief second, then acts like it just "refreshed". 

EXPECTED RESULT
When trying to share a folder/file (or any shareable thing) via email, and the system detects that there isn't an email app installed, a message should pop up notifying the user that there isn't an email app, and the share cannot be completed.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: KDE Neon User Edition
(available in About System)
KDE Plasma Version: 5.23
KDE Frameworks Version: 5.87
Qt Version: 5.15.3

ADDITIONAL INFORMATION
Comment 1 Michael SB 2021-10-15 15:57:47 UTC
Created attachment 142478 [details]
crash backtrace
Comment 2 Michael SB 2021-10-15 16:01:49 UTC
Forgot to mention I reproduced this bug on KDE Neon Testing edition with Frameworks 5.88.0
Comment 3 Michael SB 2021-10-15 16:07:08 UTC
Sorry for piling another comment (this bugtracker really should have a feature to edit comments) but I also just confirmed that this issue happens as Kalzi described not only with desktop files or folders but with any file or folder when using the Dolphin share-by-email sub-menu leading to Dolphin crashing. It is reproducible 100% of the time.
Comment 4 Nate Graham 2021-10-15 16:25:34 UTC
Thanks, that backtrace is helpful. Pasting the relevant part inline:


#5  KService::desktopEntryName (this=0x0) at ./src/services/kservice.cpp:930
#6  0x00007f3fcda02222 in (anonymous namespace)::EmailJob::start (this=0x5597d3c16d00) at ./src/plugins/email/emailplugin.cpp:40
#7  0x00007f3fcdbb18df in Purpose::JobController::startJob (this=0x5597d80eef70) at ./src/jobcontroller.cpp:45
#8  0x00007f3fcdbb1950 in Purpose::JobController::configure (this=<optimized out>) at ./src/jobcontroller.cpp:22
#9  0x00007f3fcdba63f6 in Purpose::JobController::qt_static_metacall (_o=_o@entry=0x5597d80eef70, _c=_c@entry=QMetaObject::InvokeMetaMethod, _id=_id@entry=5, _a=_a@entry=0x7fffcb46f680) at ./obj-x86_64-linux-gnu/src/KF5Purpose_autogen/EWIEGA46WW/moc_jobcontroller.cpp:148
#10 0x00007f3fcdba7073 in Purpose::JobController::qt_metacall (this=0x5597d80eef70, _c=QMetaObject::InvokeMetaMethod, _id=5, _a=0x7fffcb46f680) at ./obj-x86_64-linux-gnu/src/KF5Purpose_autogen/EWIEGA46WW/moc_jobcontroller.cpp:257

Looks like it's not handling the case of zero email apps, so it passes a blank string or a nullptr to kservice, which crashes.
Comment 5 Bug Janitor Service 2021-10-15 16:31:15 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/purpose/-/merge_requests/41
Comment 6 Kalzi 2021-10-15 16:44:52 UTC
This is an absolutely useless comment, but yaaay, this is my first official contribution to KDE Plasma that has been confirmed and assigned.
Comment 7 Aleix Pol 2021-10-15 16:58:07 UTC
🥳 cheers! and to many more!
Comment 8 Aleix Pol 2021-10-17 20:25:03 UTC
Git commit eb8e6026ae2d87c29041f949176dfc0ad5c5d5da by Aleix Pol Gonzalez, on behalf of Aleix Pol.
Committed on 17/10/2021 at 20:24.
Pushed by apol into branch 'master'.

email: Ensure we don't crash when there's no mailto preferredService

M  +1    -1    src/plugins/email/emailplugin.cpp

https://invent.kde.org/frameworks/purpose/commit/eb8e6026ae2d87c29041f949176dfc0ad5c5d5da