Bug 443788 - Attempting to share via email when there are no suitable email clients installed causes the calling app to crash in Purpose::EmailJob::start()
Summary: Attempting to share via email when there are no suitable email clients instal...
Alias: None
Product: frameworks-purpose
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.87.0
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: Aleix Pol
Keywords: usability
Depends on:
Reported: 2021-10-15 14:00 UTC by Kalzi
Modified: 2021-10-19 18:22 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.88

crash backtrace (75.90 KB, text/vnd.kde.kcrash-report)
2021-10-15 15:57 UTC, Michael SB

Note You need to log in before you can comment on or make changes to this bug.
Description Kalzi 2021-10-15 14:00:04 UTC
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.

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

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

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.

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

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