浏览代码

UI: Fix leak with paint event of volume slider

This fixes a memory leak introduced in [1] where a new QColor is not
balanced by a delete.

[1] UI: Update volume meter appearance
https://github.com/obsproject/obs-studio/commit/52ae5fc4bd518c67edd8ab94121ace05d9076892

Signed-off-by: pkv <[email protected]>
(cherry picked from commit 19abab097d6482de805bf6d73bd17975050b673c)
pkv 1 年之前
父节点
当前提交
7554532364
共有 1 个文件被更改,包括 3 次插入4 次删除
  1. 3 4
      UI/volume-control.cpp

+ 3 - 4
UI/volume-control.cpp

@@ -1555,8 +1555,7 @@ void VolumeSlider::paintEvent(QPaintEvent *event)
 	}
 
 	QPainter painter(this);
-	QColor *tickColor = new QColor;
-	tickColor->setRgb(91, 98, 115, 255);
+	QColor tickColor(91, 98, 115, 255);
 
 	obs_fader_conversion_t fader_db_to_def = obs_fader_db_to_def(fad);
 
@@ -1582,7 +1581,7 @@ void VolumeSlider::paintEvent(QPaintEvent *event)
 
 			float xPos = groove.left() + (tickValue * sliderWidth) +
 				     (handle.width() / 2);
-			painter.fillRect(xPos, yPos, 1, tickLength, *tickColor);
+			painter.fillRect(xPos, yPos, 1, tickLength, tickColor);
 		}
 	}
 
@@ -1601,7 +1600,7 @@ void VolumeSlider::paintEvent(QPaintEvent *event)
 			float yPos = groove.height() + groove.top() -
 				     (tickValue * sliderHeight) -
 				     (handle.height() / 2);
-			painter.fillRect(xPos, yPos, tickLength, 1, *tickColor);
+			painter.fillRect(xPos, yPos, tickLength, 1, tickColor);
 		}
 	}