https://bugs.kde.org/show_bug.cgi?id=431706

            Bug ID: 431706
           Summary: DefaultValueGetter for Url type uses fromUserInput
                    which doesn't handle "qrc:/"
           Product: frameworks-kconfig
           Version: 5.68.0
          Platform: Other
                OS: All
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: matt...@mjdsystems.ca
          Reporter: m...@dawidwrobel.com
                CC: kdelibs-b...@kde.org
  Target Milestone: ---

SUMMARY

A default value helper for a kcfg entry of a "Url" type that has a default
value pointing to "qrc:/" Qt resource (which itself is a valid Url) will return
a QUrl object initialized improperly with a malformed "file:qrc:/" value. 

This is due to the fact that the helper uses QUrl::fromUserInput() to parse the
provided value, which in turn does not handle the "qrc:/" Urls, and Qt refuses
to make it to. Relevant discussion about fromLocalFile() that behaves
identically here: 
https://bugreports.qt.io/browse/QTBUG-44165

The proposed solution is to make the helper detect the qrc:/ substring and
initialize QUrl object directly: 

    if (urlString.startsWith(QStringLiteral("qrc:/"))) {
      return QUrl(urlString));
    }
    else {
      return QUrl::fromUserInput(urlString)


STEPS TO REPRODUCE
1. Add a kcfg entry:
    <entry name="SomeConfigSwitch" type="Url">
      <default>qrc:/someConfigValue</default>
    </entry>
2. Add "DefaultValueGetters=true" to .kcfgc file
3. auto defaultConfigUrlValue =
PluginSettings::defaultSomeConfigSwitchValue().url()

OBSERVED RESULT
Notice that defaultConfigUrlValue is "file:qrc:/someConfigValue"


EXPECTED RESULT
defaultConfigUrlValue should be "qrc:/someConfigValue"

SOFTWARE/OS VERSIONS
Linux: Ubuntu 20.04.1 LTS
KDE Frameworks Version: 5.68
Qt Version: 5.12

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to