Ver código fonte

frontend: Force update volume meter backgrounds

Warchamp7 2 semanas atrás
pai
commit
30633344e9

+ 8 - 6
frontend/components/VolumeMeter.cpp

@@ -275,7 +275,8 @@ void VolumeMeter::setPeakMeterType(enum obs_peak_meter_type peakMeterType)
 		break;
 	}
 
-	updateBackgroundCache();
+	bool forceUpdate = true;
+	updateBackgroundCache(forceUpdate);
 }
 
 VolumeMeter::VolumeMeter(QWidget *parent, obs_source_t *source)
@@ -455,7 +456,8 @@ void VolumeMeter::refreshColors()
 	setForegroundWarningColor(getForegroundWarningColor());
 	setForegroundErrorColor(getForegroundErrorColor());
 
-	updateBackgroundCache();
+	bool forceUpdate = true;
+	updateBackgroundCache(forceUpdate);
 }
 
 QRect VolumeMeter::getBarRect() const
@@ -648,17 +650,17 @@ void VolumeMeter::paintVTicks(QPainter &painter, int x, int y, int height)
 	}
 }
 
-void VolumeMeter::updateBackgroundCache()
+void VolumeMeter::updateBackgroundCache(bool force)
 {
-	if (!size().isValid()) {
+	if (!force && !size().isValid()) {
 		return;
 	}
 
-	if (backgroundCache.size() == size() && !backgroundCache.isNull()) {
+	if (!force && backgroundCache.size() == size() && !backgroundCache.isNull()) {
 		return;
 	}
 
-	if (displayNrAudioChannels <= 0) {
+	if (!force && displayNrAudioChannels <= 0) {
 		return;
 	}
 

+ 1 - 1
frontend/components/VolumeMeter.hpp

@@ -83,7 +83,7 @@ private:
 	uint64_t displayInputPeakHoldLastUpdateTime[MAX_AUDIO_CHANNELS];
 
 	QPixmap backgroundCache;
-	void updateBackgroundCache();
+	void updateBackgroundCache(bool force = false);
 
 	QFont tickFont;
 	QRect tickTextTokenRect;