Deprecate KPluginMetaData::fromDesktopFile & implicit codepath in constructor
Open, NormalPublic

Description

This method & the constructor will convert the desktop file at runtime to a JSON object, which far more expensive to just reading a JSON file.

Most of the usages are compatibility logic anyways and in case of KPackage the usages should be phased out.
If consumers want minimal changes until T14564 is implemented the kcoreaddons_desktop_to_json cmake macro can be used to convert the file at buildtime.

The only legitimate usecases are the DBus runners in KRunner, but there the usage is only internal and could be ported to KConfig after KF6 branching. The Dbus runners should be compatible from KF5->KF6.

See also discussion in https://invent.kde.org/frameworks/kcoreaddons/-/merge_requests/117#note_279605.

If there are other usecases please add them here.

alex created this task.Aug 7 2021, 5:22 AM
alex added a comment.Sep 11 2021, 7:21 AM

This also includes the metaDataFile method, which consequently becaomes obsolete.

alex added a comment.Dec 14 2021, 4:03 PM

I am not sure how one would go about deprecating the implicit codepath. One could of course do runtime warnings.

Another idea could be to deprecate the constructor all-together, create a fromJsonFile method and then use the constructor suggested in T15094 when one wants create KPluginMetaData object with a filename that points to a C++ plugin. Using the visibility wrappers we could add a default parameters to this constructor so that consumers don't need to change the method calls when they disable deprecated API.

In hindsight I feel like I should not have "designed" the KPluginMetaData API this way. I don't really like constructors that can fail and leave the object in an invalid state. But changing that now doesn't make any sense.

Maybe we should add a new constructor + from method that takes a flags enum with permitted "plugin file formats"?

alex added a comment.Dec 28 2021, 2:54 PM

Maybe we should add a new constructor + from method that takes a flags enum with permitted "plugin file formats"?

I don't think we need it, because with the deprecation we would only have two "plugin file formats". Considering that we rarely use the json one directly, I proposed to create a new method fromJsonFile method. (I think you had the same idea on a MR, but in a different context).

alex added a comment.Dec 29 2021, 6:46 AM

For reference: https://invent.kde.org/frameworks/kcoreaddons/-/merge_requests/175

I brought this up on the KF6 weekly and there a runtime warning for the implicit code path was seen as the best solution for deprecating the desktop files. My suggestion with the enum value for allowing empty metadata & the deprecation visibility wrappers was seen as fragile, because people often do not test the code after increasing the deprecation versions.

alex triaged this task as Normal priority.Jan 6 2022, 11:36 AM
alex moved this task from Backlog to Done on the KF6 board.Feb 18 2023, 7:13 PM