Skip to content

Change static globals and static initialization in KisResourceTypes

Alvin Wong requested to merge alvinwong/krita:alvin/resource-types-static into master

These commits changes a number of things:

  • KisResourceTypes.h had static globals, which causes them to be instantiated in every translation unit that includes it. This MR changes them to extern globals and defined in KisResourceTypes.cpp.
  • The QString ones are now initialized using QStringLiteral.
  • ResourceName::resourceTypeToName was constructing a fresh QMap on every call, and also translates the KLocalizedStrings every time. This MR changes this to be statically initialized once on the first call.

The first two items reduces bloat and static initialization overhead, though it is negligible.

The last item fixes https://bugs.kde.org/show_bug.cgi?id=438116.

Test Plan

  • Build with translations, and check that the first combobox in the "Manage Resources" dialog contains translated strings (if the strings are translated) or doesn't lag (if the strings are untranslated).

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.

Merge request reports