PSA: Enable KCrash for you application

Magno Lomardo magnussolidus at gmail.com
Thu Aug 8 15:34:27 BST 2024


Hi!

Would be possible to put this info into the docs, if it isn't already there?

I believe this is really important and deserves a spotlight on the docs.
Thoughts on that?

Regards,
Magno Lomardo


On Thu, Aug 8, 2024 at 11:24 AM Nicolas Fella <nicolas.fella at gmx.de> wrote:

> Hi,
>
> TL;DR: Call KCrash::initialize() after setting up KAboutData
>
> crash reporting via DrKonqi to Bugzilla and Sentry is powered by the
> KCrash framework, which acts as the crash handler inside the application.
>
> To install the crash handler you need to call KCrash::initialize() in
> your application's main function. Since the crash handler relies on
> information from KAboutData you should do it after the call to
> KAboutData::setApplicationData(). For best results make sure to include
> the application version in the about data.
>
> You can verify that it is working correctly by doing "killall -SEGV
> myapp" and checking that DrKonqi appears and lets you submit a report.
>
> Why am I sending this now? Some background:
>
> In KF5 linking against KF5::Crash would automatically install the crash
> handler for your application even without the explicity
> KCrash::initalize(). This approach had some caveats:
>
> - It doesn't work when linking with -as-needed, which is the default in
> some distributions
>
> - Similarly it won't work with static builds
>
> - It can result in the crash handler being installed for non-KDE apps
> that happen to load KF5::Crash, e.g. via out platform plugins
>
> For these reasons for KF6 we dropped this approach (see
> https://invent.kde.org/frameworks/kcrash/-/merge_requests/51), meaning
> one must explicitly opt into our crash handling. A large number of our
> applications does that already, but there's also a significant number
> that doesn't. Please check your applications for that.
>
> Cheers
>
> Nico
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-devel/attachments/20240808/31d41aa3/attachment.htm>


More information about the kde-devel mailing list