Skip to content

Commit

Permalink
Avoid leaking the track grip QPixmap at each paintEvent
Browse files Browse the repository at this point in the history
Given that s_grip is not used anywhere else we remove it
and instead of allocating every paintEvent a new QPixmap on the heap,
which is constructed from the cached pixmap,
to then leak it, we just pass the cached pixmap directly.
  • Loading branch information
Smjert committed Jul 19, 2020
1 parent 619b1d6 commit dbe8d58
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
2 changes: 0 additions & 2 deletions include/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,6 @@ private slots:
void clearTrack();

private:
static QPixmap * s_grip;

TrackView * m_trackView;

QPushButton * m_trackOps;
Expand Down
14 changes: 2 additions & 12 deletions src/core/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1830,10 +1830,6 @@ void TrackContentWidget::setEmbossColor( const QBrush & c )
// trackOperationsWidget
// ===========================================================================


QPixmap * TrackOperationsWidget::s_grip = NULL; /*!< grip pixmap */


/*! \brief Create a new trackOperationsWidget
*
* The trackOperationsWidget is the grip and the mute button of a track.
Expand Down Expand Up @@ -1960,17 +1956,11 @@ void TrackOperationsWidget::paintEvent( QPaintEvent * pe )

if( m_trackView->isMovingTrack() == false )
{
s_grip = new QPixmap( embed::getIconPixmap(
"track_op_grip" ) );

p.drawPixmap( 2, 2, *s_grip );
p.drawPixmap( 2, 2, embed::getIconPixmap("track_op_grip"));
}
else
{
s_grip = new QPixmap( embed::getIconPixmap(
"track_op_grip_c" ) );

p.drawPixmap( 2, 2, *s_grip );
p.drawPixmap( 2, 2, embed::getIconPixmap("track_op_grip_c"));
}
}

Expand Down

0 comments on commit dbe8d58

Please sign in to comment.