D19913: [plasma-desktop] make it compiles without foreach

Aleix Pol Gonzalez noreply at phabricator.kde.org
Tue Mar 26 14:46:46 GMT 2019


apol added a comment.


  It's bad enough that we need to give things names because Qt keeps detaching on foreach, I'd be giving at least more semantic names to these temporary variables.

INLINE COMMENTS

> coronatest.cpp:149
>  
> -    foreach (auto cont, m_corona->containments()) {
> +    const auto lst = m_corona->containments();
> +    for (auto cont : lst) {

maybe call it containments? naming variables with a typename is bad (we even are using auto to not mention it's a list!)

> datamodel.cpp:401
>          if (list.first().canConvert<QVariantMap>()) {
> -            foreach (const QVariant &item, list) {
> +            for (const QVariant &item : qAsConst(list)) {
>                  const QVariantMap &vh = item.value<QVariantMap>();

It already is const.

> pluginloader.cpp:567
>      //info.service() to be valid and would crash otherwise
> -    foreach (auto& md, plugins) {
> +    for (auto& md : plugins) {
>          auto pi = md.metaDataFileName().endsWith(QLatin1String(".json")) ? KPluginInfo(md) : KPluginInfo(KService::serviceByStorageId(md.metaDataFileName()));

shouldn't it be const?

REPOSITORY
  R242 Plasma Framework (Library)

REVISION DETAIL
  https://phabricator.kde.org/D19913

To: mlaurent, dfaure
Cc: apol, kde-frameworks-devel, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20190326/935c26e3/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list