Commit 1fa06d61 authored by Simon Eugster's avatar Simon Eugster
Browse files

Check if QPainters were initialised

Related: #745
parent 994afbbd
Pipeline #48197 passed with stage
in 10 minutes and 48 seconds
......@@ -273,7 +273,15 @@ void AbstractScopeWidget::showEvent(QShowEvent *event)
void AbstractScopeWidget::paintEvent(QPaintEvent *)
{
QPainter davinci(this);
QPainter davinci;
bool ok = davinci.begin(this);
if (!ok) {
if (!m_scopeWarningPrinted) {
qDebug() << "Warning: Could not initialise painter for drawing scope.";
m_scopeWarningPrinted = true;
}
return;
}
davinci.drawImage(m_scopeRect.topLeft(), m_imgBackground);
davinci.drawImage(m_scopeRect.topLeft(), m_imgScope);
davinci.drawImage(m_scopeRect.topLeft(), m_imgHUD);
......
......@@ -282,6 +282,8 @@ private:
RescaleDirection m_rescaleDirection{North};
QPoint m_rescaleStartPoint;
bool m_scopeWarningPrinted{false};
protected slots:
void slotContextMenuRequested(const QPoint &pos);
/** To be called when a new frame has been received.
......
......@@ -252,7 +252,12 @@ QImage AudioSpectrum::renderAudioScope(uint, const audioShortVector &audioFrame,
#endif
#ifdef AUDIOSPEC_LINES
QPainter davinci(&spectrum);
QPainter davinci;
bool ok = davinci.begin(&spectrum);
if (!ok) {
qDebug() << "Could not initialise QPainter for Audio spectrum.";
return spectrum;
}
davinci.setPen(QPen(QBrush(spectrumColor.rgba()), 1, Qt::SolidLine));
#endif
......@@ -337,7 +342,12 @@ QImage AudioSpectrum::renderHUD(uint)
QImage hud(m_scopeRect.size(), QImage::Format_ARGB32);
hud.fill(qRgba(0, 0, 0, 0));
QPainter davinci(&hud);
QPainter davinci;
bool ok = davinci.begin(&hud);
if (!ok) {
qDebug() << "Could not initialise QPainter for Audio spectrum HUD.";
return hud;
}
davinci.setPen(AbstractScopeWidget::penLight);
int y;
......
......@@ -10,6 +10,7 @@
#include "spectrogram.h"
#include <QDebug>
#include <QPainter>
#include <QElapsedTimer>
......@@ -182,7 +183,13 @@ QImage Spectrogram::renderHUD(uint)
QImage hud(m_scopeRect.size(), QImage::Format_ARGB32);
hud.fill(qRgba(0, 0, 0, 0));
QPainter davinci(&hud);
QPainter davinci;
bool ok = davinci.begin(&hud);
if (!ok) {
qDebug() << "Warning: Could not initialise QPainter for Spectrogram HUD.";
return hud;
}
davinci.setPen(AbstractScopeWidget::penLight);
// Frame display
......@@ -292,6 +299,7 @@ QImage Spectrogram::renderHUD(uint)
emit signalHUDRenderingFinished(0, 1);
return QImage();
}
QImage Spectrogram::renderAudioScope(uint, const audioShortVector &audioFrame, const int freq, const int num_channels, const int num_samples, const int newData)
{
if (audioFrame.size() > 63 && m_innerScopeRect.width() > 0 && m_innerScopeRect.height() > 0) {
......@@ -348,7 +356,14 @@ QImage Spectrogram::renderAudioScope(uint, const audioShortVector &audioFrame, c
// Draw the spectrum
QImage spectrum(m_scopeRect.size(), QImage::Format_ARGB32);
spectrum.fill(qRgba(0, 0, 0, 0));
QPainter davinci(&spectrum);
QPainter davinci;
bool ok = davinci.begin(&spectrum);
if (!ok) {
qDebug() << "Warning: Could not initialise QPainter for rendering spectrogram.";
return spectrum;
}
const int h = m_innerScopeRect.height();
const int leftDist = m_innerScopeRect.left() - m_scopeRect.left();
const int topDist = m_innerScopeRect.top() - m_scopeRect.top();
......
......@@ -14,6 +14,7 @@
#include "klocalizedstring.h"
#include <QImage>
#include <QPainter>
#include <QDebug>
#include <algorithm>
#include <cmath>
......@@ -100,7 +101,12 @@ QImage HistogramGenerator::calculateHistogram(const QSize &paradeSize, const QIm
const int dist = 40;
QImage histogram(paradeSize, QImage::Format_ARGB32);
QPainter davinci(&histogram);
QPainter davinci;
bool ok = davinci.begin(&histogram);
if (!ok) {
qDebug() << "Could not initialise QPainter for Histogram.";
return histogram;
}
davinci.setPen(QColor(220, 220, 220, 255));
histogram.fill(qRgba(0, 0, 0, 0));
......
......@@ -10,6 +10,7 @@
#include "rgbparade.h"
#include "rgbparadegenerator.h"
#include <QDebug>
#include <QPainter>
#include <QRect>
#include <QElapsedTimer>
......@@ -92,7 +93,12 @@ QImage RGBParade::renderHUD(uint)
QImage hud(m_scopeRect.size(), QImage::Format_ARGB32);
hud.fill(qRgba(0, 0, 0, 0));
QPainter davinci(&hud);
QPainter davinci;
bool ok = davinci.begin(&hud);
if (!ok) {
qDebug() << "Could not initialise QPainter for RGB Parade HUD.";
return hud;
}
davinci.setPen(penLight);
int x = scopeRect().width() - 30;
......
......@@ -12,6 +12,7 @@
#include "klocalizedstring.h"
#include <QColor>
#include <QPainter>
#include <QDebug>
#define CHOP255(a) ((255) < (a) ? (255) : int(a))
#define CHOP1255(a) ((a) < (1) ? (1) : ((a) > (255) ? (255) : (a)))
......@@ -43,7 +44,12 @@ QImage RGBParadeGenerator::calculateRGBParade(const QSize &paradeSize, const QIm
QImage parade(paradeSize, QImage::Format_ARGB32);
parade.fill(Qt::transparent);
QPainter davinci(&parade);
QPainter davinci;
bool ok = davinci.begin(&parade);
if (!ok) {
qDebug() << "Could not initialise QPainter for RGB parade.";
return parade;
}
const uint ww = (uint)paradeSize.width();
const uint wh = (uint)paradeSize.height();
......
......@@ -223,7 +223,12 @@ QImage Vectorscope::renderHUD(uint)
hud = QImage(m_visibleRect.size(), QImage::Format_ARGB32);
hud.fill(qRgba(0, 0, 0, 0));
QPainter davinci(&hud);
QPainter davinci;
bool ok = davinci.begin(&hud);
if (!ok) {
qDebug() << "Could not initialise QPainter for Vectorscope HUD.";
return hud;
}
QPoint widgetCenterPoint = m_scopeRect.topLeft() + m_centerPoint;
int dx = -widgetCenterPoint.x() + m_mousePos.x();
......@@ -290,7 +295,12 @@ QImage Vectorscope::renderBackground(uint)
bg.fill(qRgba(0, 0, 0, 0));
// Set up tools
QPainter davinci(&bg);
QPainter davinci;
bool ok = davinci.begin(&bg);
if (!ok) {
qDebug() << "Could not initialise QPainter for Vectorscope background.";
return bg;
}
davinci.setRenderHint(QPainter::Antialiasing, true);
QPoint vinciPoint;
......
......@@ -119,7 +119,12 @@ QImage Waveform::renderHUD(uint)
QImage hud(m_scopeRect.size(), QImage::Format_ARGB32);
hud.fill(qRgba(0, 0, 0, 0));
QPainter davinci(&hud);
QPainter davinci;
bool ok = davinci.begin(&hud);
if (!ok) {
qDebug() << "Could not initialise QPainter for Waveform HUD.";
return hud;
}
davinci.setPen(penLight);
// qCDebug(KDENLIVE_LOG) << values.value("width");
......
......@@ -16,6 +16,7 @@
#include <QImage>
#include <QPainter>
#include <QSize>
#include <QDebug>
#include <QElapsedTimer>
#include <vector>
......@@ -125,7 +126,13 @@ QImage WaveformGenerator::calculateWaveform(const QSize &waveformSize, const QIm
}
if (drawAxis) {
QPainter davinci(&wave);
QPainter davinci;
bool ok = davinci.begin(&wave);
if (!ok) {
qDebug() << "Could not initialise QPainter for Waveform.";
return wave;
}
QRgb opx;
davinci.setPen(qRgba(150, 255, 200, 32));
davinci.setCompositionMode(QPainter::CompositionMode_Overlay);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment