D14443: Use nullptr

Elvis Angelaccio noreply at phabricator.kde.org
Tue Jul 31 22:13:12 BST 2018


elvisangelaccio requested changes to this revision.
elvisangelaccio added a comment.
This revision now requires changes to proceed.


  In D14443#299704 <https://phabricator.kde.org/D14443#299704>, @hallas wrote:
  
  > Just out of curiosity, what is the motivation for this change? What do we gain by assigning pointers to nullptr? Would it instead make sense to use a smart pointer? Maybe unique_ptr or a Qt version?
  
  
  Yes, porting to smart pointers (wherever possible) would be the best. But setting deleted pointers to null is a common practice because it will help to find some kind of bugs (even though it will hide a double delete, which isn't that good).

INLINE COMMENTS

> kitemlistview.cpp:309
>      m_widgetCreator = widgetCreator;
> +    widgetCreator = nullptr;
>  }

Not needed, `widgetCreator` is a local variable that's going out of scope.

> kitemlistview.cpp:324
>      m_groupHeaderCreator = groupHeaderCreator;
> +    groupHeaderCreator = nullptr;
>  }

Same here.

> kitemlistview.cpp:2712
>          delete widget;
> +        widget = nullptr;
>      }

Same here.

> kstandarditemmodel.cpp:68
>          delete item;
> +        item = nullptr;
>          return;

Same here, but ok. This one could make sense in case one day someone removes the return.

> kstandarditemmodel.cpp:238
>  }
> -

Unrelated whitespace change

> kitemlistviewanimation.cpp:189
>          delete propertyAnim;
> +        propertyAnim = nullptr;
>  

Same here, not needed.

> kitemlistviewanimation.cpp:236
>  }
> -

Unrelated whitespace change

> folderspanel.cpp:65
>          delete view;
> +        view = nullptr;
>      }

Not needed.

> folderspanel.cpp:369
>  }
> -

Unrelated whitespace change

> placespanel.cpp:484
>      delete dialog;
> +    dialog = nullptr;
>  }

Not needed.

> kfileitemmodeltest.cpp:1645
>      delete mimeData;
> +    mimeData = nullptr;
>  }

Not needed.

> dolphinview.cpp:999
>      delete menu;
> +    menu = nullptr;
>  }

Not needed.

> dolphinviewactionhandler.cpp:581
>      delete dialog;
> +    dialog = nullptr;
>  }

Not needed.

> tooltipmanager.cpp:86
>      delete m_fileMetaDataWidget;
> +    m_fileMetaDataWidget = nullptr;
>      m_fileMetaDataWidget = new DolphinFileMetaDataWidget();

Not needed, we are already assigning it one line below.

> tooltipmanager.cpp:212
>  }
> -

Unrelated whitespace change

REPOSITORY
  R318 Dolphin

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

To: al1xz, #dolphin, elvisangelaccio
Cc: elvisangelaccio, broulik, hallas, markg, kfm-devel, spoorun, navarromorales, firef, andrebarros, emmanuelp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20180731/40a2403b/attachment.htm>


More information about the kfm-devel mailing list