Skip to content

Commit

Permalink
cppcheck: Fix "use initialization list" warnings (2).
Browse files Browse the repository at this point in the history
Move member variable assignment from the constructor body into the
function initialization list.

For some reason this change causes the clang-tidy NewDeleteLeaks check
to now determine that some (but not all) of the MusicGenericTree nodes
allocated in PlaylistEditorView::createRootNode are potential memory
leaks.  A pointer to the first node is saved in m_rootNode, and all of
the other nodes are attached as children of that first node (inside
the constructor) so there is no memory leak.  Disable the
NewDeleteLeaks check for that specific function.
  • Loading branch information
linuxdude42 committed Jul 10, 2022
1 parent 70bd5d3 commit 76f7222
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions mythplugins/mythmusic/mythmusic/playlisteditorview.cpp
Expand Up @@ -28,12 +28,11 @@ MusicGenericTree::MusicGenericTree(MusicGenericTree *parent,
const QString &name, const QString &action,
MythUIButtonListItem::CheckState check,
bool showArrow)
: MythGenericTree(name)
: MythGenericTree(name),
m_action(action),
m_check(check),
m_showArrow(showArrow)
{
m_check = check;
m_action = action;
m_showArrow = showArrow;

if (!action.isEmpty())
setSelectable(true);

Expand Down Expand Up @@ -732,6 +731,7 @@ MythMenu* PlaylistEditorView::createSmartPlaylistMenu(void)
return menu;
}

// NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks)
void PlaylistEditorView::createRootNode(void )
{
if (!m_rootNode)
Expand Down Expand Up @@ -800,6 +800,7 @@ void PlaylistEditorView::createRootNode(void )
node = new MusicGenericTree(m_rootNode, tr("Smart Playlists"), "smartplaylists");
node->setDrawArrow(true);
}
// NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)

void PlaylistEditorView::treeItemClicked(MythUIButtonListItem *item)
{
Expand Down

0 comments on commit 76f7222

Please sign in to comment.