Fix memory leaks (#6879)

* Replace knobFModel with std::vector

* Create QPixmap's on the stack

* Assign parent for QGraphicsScene
A call to QGraphicsView::setScene does not make
the view take ownership of the scene.

* Do not allocate QList on the heap

* Use static QPixmap's
The QPixmap's need to be created within the constructor, and not outside
where they are defined, since it can't find them otherwise.
I'm not too sure why.

* Clear m_vi2->knobFModel in destructor

* Use local static QPixmap's

* Do not allocate QPixmap with new in AudioFileProcessor

* Do not allocate QPixmap with new in Nes

* Do not allocate QPixmap with new in Organic

* Do not allocate QPixmap with new in SaControlsDialog

* Do not allocate QPixmap with new in Vestige

* Do not allocate QPixmap with new for FileBrowser

* Do not allocate QPixmap with new in MixerLine

* Do not allocate QPixmap with new in SendButtonIndicator

* Do not allocate QPixmap with new in AutomationClipView

* Do not allocate QPixmap with new in MidiClipView

* Do not allocate QPixmap with new in AutomationEditor

* Do not allocate QPixmap with new in PianoRoll

* Do not allocate QPixmap with new in TimeLineWidget

* Do not allocate QPixmap with new in EnvelopeAndLfoView

* Do not allocate QPixmap with new in PianoView

* Do not allocate QPixmap with new in ComboBox

* Do not allocate QPixmap with new in Fader

* Do not allocate QPixmap with new for LcdWidget

* Do not allocate QPixmap with new for LedCheckbox

* Use m_ as prefix for members

* Use uniform initialization
I already started using uniform initialization for the QPixmap changes
for some reason, so I'm finishing that up.

* Uniform initiaization

* And then he realized he was making copies...

* Do not call QPixmap copy constructor

* Do not call QPixmap copy constructor in SaControlsDialog

* Do not make pixmap's static for Lcd's and Led's

* Initialize pixmaps in-class

* Fix few mistakes and formatting
This commit is contained in:
saker
2023-11-19 00:44:15 -05:00
committed by GitHub
parent fad0011508
commit aa050ae0b7
43 changed files with 289 additions and 729 deletions

View File

@@ -451,19 +451,12 @@ namespace gui
{
QPixmap * AudioFileProcessorView::s_artwork = nullptr;
AudioFileProcessorView::AudioFileProcessorView( Instrument * _instrument,
QWidget * _parent ) :
InstrumentViewFixedSize( _instrument, _parent )
{
if( s_artwork == nullptr )
{
s_artwork = new QPixmap( PLUGIN_NAME::getIconPixmap(
"artwork" ) );
}
m_openAudioFileButton = new PixmapButton( this );
m_openAudioFileButton->setCursor( QCursor( Qt::PointingHandCursor ) );
m_openAudioFileButton->move( 227, 72 );
@@ -649,7 +642,8 @@ void AudioFileProcessorView::paintEvent( QPaintEvent * )
{
QPainter p( this );
p.drawPixmap( 0, 0, *s_artwork );
static auto s_artwork = PLUGIN_NAME::getIconPixmap("artwork");
p.drawPixmap(0, 0, s_artwork);
auto a = castModel<AudioFileProcessor>();

View File

@@ -145,7 +145,6 @@ protected:
private:
virtual void modelChanged();
static QPixmap * s_artwork;
AudioFileProcessorWaveView * m_waveView;
Knob * m_ampKnob;

View File

@@ -72,17 +72,17 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) :
setBand( 6, &controls->m_highShelfActiveModel, &controls->m_highShelfFreqModel, &controls->m_highShelfResModel, &controls->m_highShelfGainModel, QColor(255 ,255, 255), tr( "High-shelf" ), &controls->m_highShelfPeakL, &controls->m_highShelfPeakR,0,0,0,0,0,0 );
setBand( 7, &controls->m_lpActiveModel, &controls->m_lpFreqModel, &controls->m_lpResModel, 0, QColor(255 ,255, 255), tr( "LP" ) ,0,0,0,0,0, &controls->m_lp12Model, &controls->m_lp24Model, &controls->m_lp48Model);
auto faderBg = new QPixmap(PLUGIN_NAME::getIconPixmap("faderback"));
auto faderLeds = new QPixmap(PLUGIN_NAME::getIconPixmap("faderleds"));
auto faderKnob = new QPixmap(PLUGIN_NAME::getIconPixmap("faderknob"));
static auto s_faderBg = PLUGIN_NAME::getIconPixmap("faderback");
static auto s_faderLeds = PLUGIN_NAME::getIconPixmap("faderleds");
static auto s_faderKnob = PLUGIN_NAME::getIconPixmap("faderknob");
auto GainFaderIn = new EqFader(&controls->m_inGainModel, tr("Input gain"), this, faderBg, faderLeds, faderKnob,
auto GainFaderIn = new EqFader(&controls->m_inGainModel, tr("Input gain"), this, &s_faderBg, &s_faderLeds, &s_faderKnob,
&controls->m_inPeakL, &controls->m_inPeakR);
GainFaderIn->move( 23, 295 );
GainFaderIn->setDisplayConversion( false );
GainFaderIn->setHintText( tr( "Gain" ), "dBv");
auto GainFaderOut = new EqFader(&controls->m_outGainModel, tr("Output gain"), this, faderBg, faderLeds, faderKnob,
auto GainFaderOut = new EqFader(&controls->m_outGainModel, tr("Output gain"), this, &s_faderBg, &s_faderLeds, &s_faderKnob,
&controls->m_outPeakL, &controls->m_outPeakR);
GainFaderOut->move( 453, 295);
GainFaderOut->setDisplayConversion( false );
@@ -92,8 +92,8 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) :
int distance = 126;
for( int i = 1; i < m_parameterWidget->bandCount() - 1; i++ )
{
auto gainFader = new EqFader(m_parameterWidget->getBandModels(i)->gain, tr(""), this, faderBg, faderLeds,
faderKnob, m_parameterWidget->getBandModels(i)->peakL, m_parameterWidget->getBandModels(i)->peakR);
auto gainFader = new EqFader(m_parameterWidget->getBandModels(i)->gain, tr(""), this, &s_faderBg, &s_faderLeds,
&s_faderKnob, m_parameterWidget->getBandModels(i)->peakL, m_parameterWidget->getBandModels(i)->peakR);
gainFader->move( distance, 295 );
distance += 44;
gainFader->setMinimumHeight(80);
@@ -242,4 +242,4 @@ EqBand* EqControlsDialog::setBand(int index, BoolModel* active, FloatModel* freq
}
} // namespace lmms::gui
} // namespace lmms::gui

View File

@@ -56,7 +56,7 @@ EqParameterWidget::EqParameterWidget( QWidget *parent, EqControls * controls ) :
m_pixelsPerOctave = EqHandle::freqToXPixel( 10000, m_displayWidth ) - EqHandle::freqToXPixel( 5000, m_displayWidth );
//GraphicsScene and GraphicsView stuff
auto scene = new QGraphicsScene();
auto scene = new QGraphicsScene(this);
scene->setSceneRect( 0, 0, m_displayWidth, m_displayHeigth );
auto view = new QGraphicsView(this);
view->setStyleSheet( "border-style: none; background: transparent;" );
@@ -65,22 +65,22 @@ EqParameterWidget::EqParameterWidget( QWidget *parent, EqControls * controls ) :
view->setScene( scene );
//adds the handles
m_handleList = new QList<EqHandle*>;
m_handleList.reserve(bandCount());
for ( int i = 0; i < bandCount(); i++ )
{
m_handle = new EqHandle ( i, m_displayWidth, m_displayHeigth );
m_handleList->append( m_handle );
m_handleList.append(m_handle);
m_handle->setZValue( 1 );
scene->addItem( m_handle );
}
//adds the curve widget
m_eqcurve = new EqCurve( m_handleList, m_displayWidth, m_displayHeigth );
m_eqcurve = new EqCurve(&m_handleList, m_displayWidth, m_displayHeigth);
scene->addItem( m_eqcurve );
for ( int i = 0; i < bandCount(); i++ )
{
// if the data of handle position has changed update the models
QObject::connect( m_handleList->at( i ) ,SIGNAL( positionChanged() ), this ,SLOT( updateModels() ) );
QObject::connect(m_handleList.at(i), SIGNAL(positionChanged()), this, SLOT(updateModels()));
}
}
@@ -112,16 +112,13 @@ void EqParameterWidget::updateHandle()
m_eqcurve->setModelChanged( true );
for( int i = 0 ; i < bandCount(); i++ )
{
if ( !m_handleList->at( i )->mousePressed() ) //prevents a short circuit between handle and data model
if (!m_handleList.at(i)->mousePressed()) // prevents a short circuit between handle and data model
{
//sets the band on active if a fader or a knob is moved
bool hover = false; // prevents an action if handle is moved
for ( int j = 0; j < bandCount(); j++ )
{
if ( m_handleList->at(j)->isMouseHover() )
{
hover = true;
}
if (m_handleList.at(j)->isMouseHover()) { hover = true; }
}
if ( !hover )
{
@@ -131,17 +128,14 @@ void EqParameterWidget::updateHandle()
}
changeHandle( i );
}
else
{
m_handleList->at( i )->setHandleActive( m_bands[i].active->value() );
}
else { m_handleList.at(i)->setHandleActive(m_bands[i].active->value()); }
}
if ( m_bands[0].hp12->value() ) m_handleList->at( 0 )->sethp12();
if ( m_bands[0].hp24->value() ) m_handleList->at( 0 )->sethp24();
if ( m_bands[0].hp48->value() ) m_handleList->at( 0 )->sethp48();
if ( m_bands[7].lp12->value() ) m_handleList->at( 7 )->setlp12();
if ( m_bands[7].lp24->value() ) m_handleList->at( 7 )->setlp24();
if ( m_bands[7].lp48->value() ) m_handleList->at( 7 )->setlp48();
if (m_bands[0].hp12->value()) m_handleList.at(0)->sethp12();
if (m_bands[0].hp24->value()) m_handleList.at(0)->sethp24();
if (m_bands[0].hp48->value()) m_handleList.at(0)->sethp48();
if (m_bands[7].lp12->value()) m_handleList.at(7)->setlp12();
if (m_bands[7].lp24->value()) m_handleList.at(7)->setlp24();
if (m_bands[7].lp48->value()) m_handleList.at(7)->setlp48();
}
@@ -151,7 +145,7 @@ void EqParameterWidget::changeHandle( int i )
{
//fill x, y, and bw with data from model
float x = EqHandle::freqToXPixel( m_bands[i].freq->value(), m_displayWidth );
float y = m_handleList->at( i )->y();
float y = m_handleList.at(i)->y();
//for pass filters there is no gain model
if( m_bands[i].gain )
{
@@ -164,48 +158,45 @@ void EqParameterWidget::changeHandle( int i )
switch ( i )
{
case 0 :
m_handleList->at( i )->setType( EqHandleType::HighPass );
m_handleList->at( i )->setPos( x, m_displayHeigth / 2 );
m_handleList.at(i)->setType(EqHandleType::HighPass);
m_handleList.at(i)->setPos(x, m_displayHeigth / 2);
break;
case 1:
m_handleList->at( i )->setType( EqHandleType::LowShelf );
m_handleList->at( i )->setPos( x, y );
m_handleList.at(i)->setType(EqHandleType::LowShelf);
m_handleList.at(i)->setPos(x, y);
break;
case 2:
m_handleList->at( i )->setType( EqHandleType::Para );
m_handleList->at( i )->setPos( x, y );
m_handleList.at(i)->setType(EqHandleType::Para);
m_handleList.at(i)->setPos(x, y);
break;
case 3:
m_handleList->at( i )->setType( EqHandleType::Para );
m_handleList->at( i )->setPos( x, y );
m_handleList.at(i)->setType(EqHandleType::Para);
m_handleList.at(i)->setPos(x, y);
break;
case 4:
m_handleList->at( i )->setType( EqHandleType::Para );
m_handleList->at( i )->setPos( x, y );
m_handleList.at(i)->setType(EqHandleType::Para);
m_handleList.at(i)->setPos(x, y);
break;
case 5:
m_handleList->at( i )->setType( EqHandleType::Para );
m_handleList->at( i )->setPos( x, y );
m_handleList.at(i)->setType(EqHandleType::Para);
m_handleList.at(i)->setPos(x, y);
break;
case 6:
m_handleList->at( i )->setType( EqHandleType::HighShelf );
m_handleList->at( i )->setPos( x, y );
m_handleList.at(i)->setType(EqHandleType::HighShelf);
m_handleList.at(i)->setPos(x, y);
break;
case 7:
m_handleList->at( i )->setType( EqHandleType::LowPass );
m_handleList->at( i )->setPos( QPointF( x, m_displayHeigth / 2 ) );
m_handleList.at(i)->setType(EqHandleType::LowPass);
m_handleList.at(i)->setPos(QPointF(x, m_displayHeigth / 2));
break;
}
// set resonance/bandwidth for each handle
if ( m_handleList->at( i )->getResonance() != bw )
{
m_handleList->at( i )->setResonance( bw );
}
if (m_handleList.at(i)->getResonance() != bw) { m_handleList.at(i)->setResonance(bw); }
// and the active status
m_handleList->at( i )->setHandleActive( m_bands[i].active->value() );
m_handleList->at( i )->update();
m_handleList.at(i)->setHandleActive(m_bands[i].active->value());
m_handleList.at(i)->update();
m_eqcurve->update();
}
@@ -216,19 +207,17 @@ void EqParameterWidget::updateModels()
{
for ( int i=0 ; i < bandCount(); i++ )
{
m_bands[i].freq->setValue( EqHandle::xPixelToFreq( m_handleList->at( i )->x(), m_displayWidth ) );
m_bands[i].freq->setValue(EqHandle::xPixelToFreq(m_handleList.at(i)->x(), m_displayWidth));
if( m_bands[i].gain )
{
m_bands[i].gain->setValue( EqHandle::yPixelToGain( m_handleList->at(i)->y(), m_displayHeigth, m_pixelsPerUnitHeight ) );
m_bands[i].gain->setValue(
EqHandle::yPixelToGain(m_handleList.at(i)->y(), m_displayHeigth, m_pixelsPerUnitHeight));
}
m_bands[i].res->setValue( m_handleList->at( i )->getResonance() );
m_bands[i].res->setValue(m_handleList.at(i)->getResonance());
//identifies the handle which is moved and set the band active
if ( sender() == m_handleList->at( i ) )
{
m_bands[i].active->setValue( true );
}
if (sender() == m_handleList.at(i)) { m_bands[i].active->setValue(true); }
}
m_eqcurve->update();
}

View File

@@ -75,7 +75,7 @@ class EqParameterWidget : public QWidget
public:
explicit EqParameterWidget( QWidget *parent = 0, EqControls * controls = 0 );
~EqParameterWidget() override;
QList<EqHandle*> *m_handleList;
QList<EqHandle*> m_handleList;
const int bandCount()
{

View File

@@ -719,7 +719,6 @@ namespace gui
{
QPixmap * NesInstrumentView::s_artwork = nullptr;
NesInstrumentView::NesInstrumentView( Instrument * instrument, QWidget * parent ) :
@@ -728,12 +727,8 @@ NesInstrumentView::NesInstrumentView( Instrument * instrument, QWidget * parent
setAutoFillBackground( true );
QPalette pal;
if( s_artwork == nullptr )
{
s_artwork = new QPixmap( PLUGIN_NAME::getIconPixmap( "artwork" ) );
}
pal.setBrush( backgroundRole(), *s_artwork );
static auto s_artwork = PLUGIN_NAME::getIconPixmap("artwork");
pal.setBrush(backgroundRole(), s_artwork);
setPalette( pal );
const int KNOB_Y1 = 24;

View File

@@ -372,7 +372,6 @@ private:
Knob * m_masterVolKnob;
Knob * m_vibratoKnob;
static QPixmap * s_artwork;
};

View File

@@ -60,7 +60,6 @@ Plugin::Descriptor PLUGIN_EXPORT organic_plugin_descriptor =
}
QPixmap * gui::OrganicInstrumentView::s_artwork = nullptr;
float * OrganicInstrument::s_harmonics = nullptr;
/***********************************************************************
@@ -420,8 +419,8 @@ OrganicInstrumentView::OrganicInstrumentView( Instrument * _instrument,
setAutoFillBackground( true );
QPalette pal;
pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap(
"artwork" ) );
static auto s_artwork = PLUGIN_NAME::getIconPixmap("artwork");
pal.setBrush(backgroundRole(), s_artwork);
setPalette( pal );
// setup knob for FX1
@@ -451,12 +450,6 @@ OrganicInstrumentView::OrganicInstrumentView( Instrument * _instrument,
oi, SLOT( randomiseSettings() ) );
if( s_artwork == nullptr )
{
s_artwork = new QPixmap( PLUGIN_NAME::getIconPixmap(
"artwork" ) );
}
}

View File

@@ -227,7 +227,6 @@ private:
int m_numOscillators;
static QPixmap * s_artwork;
protected slots:
void updateKnobHint();

View File

@@ -89,28 +89,28 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor)
// pause and freeze buttons
auto pauseButton = new PixmapButton(this, tr("Pause"));
pauseButton->setToolTip(tr("Pause data acquisition"));
auto pauseOnPixmap = new QPixmap(
PLUGIN_NAME::getIconPixmap("play").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
auto pauseOffPixmap = new QPixmap(
PLUGIN_NAME::getIconPixmap("pause").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
pauseOnPixmap->setDevicePixelRatio(devicePixelRatio());
pauseOffPixmap->setDevicePixelRatio(devicePixelRatio());
pauseButton->setActiveGraphic(*pauseOnPixmap);
pauseButton->setInactiveGraphic(*pauseOffPixmap);
static auto s_pauseOnPixmap
= PLUGIN_NAME::getIconPixmap("play").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
static auto s_pauseOffPixmap
= PLUGIN_NAME::getIconPixmap("pause").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
s_pauseOnPixmap.setDevicePixelRatio(devicePixelRatio());
s_pauseOffPixmap.setDevicePixelRatio(devicePixelRatio());
pauseButton->setActiveGraphic(s_pauseOnPixmap);
pauseButton->setInactiveGraphic(s_pauseOffPixmap);
pauseButton->setCheckable(true);
pauseButton->setModel(&controls->m_pauseModel);
config_layout->addWidget(pauseButton, 0, 0, 2, 1, Qt::AlignHCenter);
auto refFreezeButton = new PixmapButton(this, tr("Reference freeze"));
refFreezeButton->setToolTip(tr("Freeze current input as a reference / disable falloff in peak-hold mode."));
auto freezeOnPixmap = new QPixmap(
PLUGIN_NAME::getIconPixmap("freeze").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
auto freezeOffPixmap = new QPixmap(
PLUGIN_NAME::getIconPixmap("freeze_off").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
freezeOnPixmap->setDevicePixelRatio(devicePixelRatio());
freezeOffPixmap->setDevicePixelRatio(devicePixelRatio());
refFreezeButton->setActiveGraphic(*freezeOnPixmap);
refFreezeButton->setInactiveGraphic(*freezeOffPixmap);
static auto s_freezeOnPixmap
= PLUGIN_NAME::getIconPixmap("freeze").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
static auto s_freezeOffPixmap
= PLUGIN_NAME::getIconPixmap("freeze_off").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
s_freezeOnPixmap.setDevicePixelRatio(devicePixelRatio());
s_freezeOffPixmap.setDevicePixelRatio(devicePixelRatio());
refFreezeButton->setActiveGraphic(s_freezeOnPixmap);
refFreezeButton->setInactiveGraphic(s_freezeOffPixmap);
refFreezeButton->setCheckable(true);
refFreezeButton->setModel(&controls->m_refFreezeModel);
config_layout->addWidget(refFreezeButton, 2, 0, 2, 1, Qt::AlignHCenter);
@@ -147,14 +147,14 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor)
// frequency: linear / log. switch and range selector
auto logXButton = new PixmapButton(this, tr("Logarithmic frequency"));
logXButton->setToolTip(tr("Switch between logarithmic and linear frequency scale"));
auto logXOnPixmap = new QPixmap(
PLUGIN_NAME::getIconPixmap("x_log").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
auto logXOffPixmap = new QPixmap(
PLUGIN_NAME::getIconPixmap("x_linear").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
logXOnPixmap->setDevicePixelRatio(devicePixelRatio());
logXOffPixmap->setDevicePixelRatio(devicePixelRatio());
logXButton->setActiveGraphic(*logXOnPixmap);
logXButton->setInactiveGraphic(*logXOffPixmap);
static auto s_logXOnPixmap
= PLUGIN_NAME::getIconPixmap("x_log").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
static auto s_logXOffPixmap
= PLUGIN_NAME::getIconPixmap("x_linear").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
s_logXOnPixmap.setDevicePixelRatio(devicePixelRatio());
s_logXOffPixmap.setDevicePixelRatio(devicePixelRatio());
logXButton->setActiveGraphic(s_logXOnPixmap);
logXButton->setInactiveGraphic(s_logXOffPixmap);
logXButton->setCheckable(true);
logXButton->setModel(&controls->m_logXModel);
config_layout->addWidget(logXButton, 0, 2, 2, 1, Qt::AlignRight);
@@ -169,14 +169,14 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor)
// amplitude: linear / log switch and range selector
auto logYButton = new PixmapButton(this, tr("Logarithmic amplitude"));
logYButton->setToolTip(tr("Switch between logarithmic and linear amplitude scale"));
auto logYOnPixmap = new QPixmap(
PLUGIN_NAME::getIconPixmap("y_log").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
auto logYOffPixmap = new QPixmap(
PLUGIN_NAME::getIconPixmap("y_linear").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
logYOnPixmap->setDevicePixelRatio(devicePixelRatio());
logYOffPixmap->setDevicePixelRatio(devicePixelRatio());
logYButton->setActiveGraphic(*logYOnPixmap);
logYButton->setInactiveGraphic(*logYOffPixmap);
static auto s_logYOnPixmap
= PLUGIN_NAME::getIconPixmap("y_log").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
static auto s_logYOffPixmap
= PLUGIN_NAME::getIconPixmap("y_linear").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
s_logYOnPixmap.setDevicePixelRatio(devicePixelRatio());
s_logYOffPixmap.setDevicePixelRatio(devicePixelRatio());
logYButton->setActiveGraphic(s_logYOnPixmap);
logYButton->setInactiveGraphic(s_logYOffPixmap);
logYButton->setCheckable(true);
logYButton->setModel(&controls->m_logYModel);
config_layout->addWidget(logYButton, 2, 2, 2, 1, Qt::AlignRight);
@@ -190,9 +190,9 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor)
// FFT: block size: icon and selector
auto blockSizeLabel = new QLabel("", this);
auto blockSizeIcon = new QPixmap(PLUGIN_NAME::getIconPixmap("block_size"));
blockSizeIcon->setDevicePixelRatio(devicePixelRatio());
blockSizeLabel->setPixmap(blockSizeIcon->scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
static auto s_blockSizeIcon = PLUGIN_NAME::getIconPixmap("block_size");
s_blockSizeIcon.setDevicePixelRatio(devicePixelRatio());
blockSizeLabel->setPixmap(s_blockSizeIcon.scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
config_layout->addWidget(blockSizeLabel, 0, 4, 2, 1, Qt::AlignRight);
auto blockSizeCombo = new ComboBox(this, tr("FFT block size"));
@@ -206,9 +206,9 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor)
// FFT: window type: icon and selector
auto windowLabel = new QLabel("", this);
auto windowIcon = new QPixmap(PLUGIN_NAME::getIconPixmap("window"));
windowIcon->setDevicePixelRatio(devicePixelRatio());
windowLabel->setPixmap(windowIcon->scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
static auto s_windowIcon = PLUGIN_NAME::getIconPixmap("window");
s_windowIcon.setDevicePixelRatio(devicePixelRatio());
windowLabel->setPixmap(s_windowIcon.scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
config_layout->addWidget(windowLabel, 2, 4, 2, 1, Qt::AlignRight);
auto windowCombo = new ComboBox(this, tr("FFT window type"));
@@ -307,14 +307,14 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor)
// Advanced settings button
auto advancedButton = new PixmapButton(this, tr("Advanced settings"));
advancedButton->setToolTip(tr("Access advanced settings"));
auto advancedOnPixmap = new QPixmap(PLUGIN_NAME::getIconPixmap("advanced_on")
.scaled(advButtonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
auto advancedOffPixmap = new QPixmap(PLUGIN_NAME::getIconPixmap("advanced_off")
.scaled(advButtonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
advancedOnPixmap->setDevicePixelRatio(devicePixelRatio());
advancedOffPixmap->setDevicePixelRatio(devicePixelRatio());
advancedButton->setActiveGraphic(*advancedOnPixmap);
advancedButton->setInactiveGraphic(*advancedOffPixmap);
static auto s_advancedOnPixmap = PLUGIN_NAME::getIconPixmap("advanced_on")
.scaled(advButtonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
static auto s_advancedOffPixmap = PLUGIN_NAME::getIconPixmap("advanced_off")
.scaled(advButtonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
s_advancedOnPixmap.setDevicePixelRatio(devicePixelRatio());
s_advancedOffPixmap.setDevicePixelRatio(devicePixelRatio());
advancedButton->setActiveGraphic(s_advancedOnPixmap);
advancedButton->setInactiveGraphic(s_advancedOffPixmap);
advancedButton->setCheckable(true);
controls_layout->addStretch(0);
controls_layout->addWidget(advancedButton);

View File

@@ -485,21 +485,11 @@ gui::PluginView * VestigeInstrument::instantiateView( QWidget * _parent )
namespace gui
{
QPixmap * VestigeInstrumentView::s_artwork = nullptr;
QPixmap * ManageVestigeInstrumentView::s_artwork = nullptr;
VestigeInstrumentView::VestigeInstrumentView( Instrument * _instrument,
QWidget * _parent ) :
InstrumentViewFixedSize( _instrument, _parent ),
lastPosInMenu (0)
{
if( s_artwork == nullptr )
{
s_artwork = new QPixmap( PLUGIN_NAME::getIconPixmap(
"artwork" ) );
}
m_openPluginButton = new PixmapButton( this, "" );
m_openPluginButton->setCheckable( false );
m_openPluginButton->setCursor( Qt::PointingHandCursor );
@@ -881,7 +871,8 @@ void VestigeInstrumentView::paintEvent( QPaintEvent * )
{
QPainter p( this );
p.drawPixmap( 0, 0, *s_artwork );
static auto s_artwork = PLUGIN_NAME::getIconPixmap("artwork");
p.drawPixmap(0, 0, s_artwork);
QString plugin_name = ( m_vi->m_plugin != nullptr ) ?
m_vi->m_plugin->name()/* + QString::number(

View File

@@ -131,8 +131,6 @@ protected:
private:
static QPixmap * s_artwork;
VestigeInstrument * m_vi;
QWidget *widget;
@@ -175,7 +173,6 @@ protected:
private:
virtual void modelChanged();
static QPixmap * s_artwork;
VestigeInstrument * m_vi;

View File

@@ -50,7 +50,6 @@ VstEffectControls::VstEffectControls( VstEffect * _eff ) :
EffectControls( _eff ),
m_effect( _eff ),
m_subWindow( nullptr ),
knobFModel( nullptr ),
ctrHandle( nullptr ),
lastPosInMenu (0),
m_vstGuiVisible ( true )
@@ -84,7 +83,7 @@ void VstEffectControls::loadSettings( const QDomElement & _this )
const QMap<QString, QString> & dump = m_effect->m_plugin->parameterDump();
paramCount = dump.size();
auto paramStr = std::array<char, 35>{};
knobFModel = new FloatModel *[ paramCount ];
knobFModel.resize(paramCount);
QStringList s_dumpValues;
for( int i = 0; i < paramCount; i++ )
{
@@ -131,7 +130,7 @@ void VstEffectControls::saveSettings( QDomDocument & _doc, QDomElement & _this )
if( m_effect->m_plugin != nullptr )
{
m_effect->m_plugin->saveSettings( _doc, _this );
if (knobFModel != nullptr) {
if (!knobFModel.empty()) {
const QMap<QString, QString> & dump = m_effect->m_plugin->parameterDump();
paramCount = dump.size();
auto paramStr = std::array<char, 35>{};
@@ -376,8 +375,9 @@ ManageVSTEffectView::ManageVSTEffectView( VstEffect * _eff, VstEffectControls *
vstKnobs = new CustomTextKnob *[ m_vi->paramCount ];
bool hasKnobModel = true;
if (m_vi->knobFModel == nullptr) {
m_vi->knobFModel = new FloatModel *[ m_vi->paramCount ];
if (m_vi->knobFModel.empty())
{
m_vi->knobFModel.resize(m_vi->paramCount);
hasKnobModel = false;
}
@@ -543,7 +543,7 @@ void ManageVSTEffectView::syncParameterText()
ManageVSTEffectView::~ManageVSTEffectView()
{
if( m_vi2->knobFModel != nullptr )
if (!m_vi2->knobFModel.empty())
{
for( int i = 0; i < m_vi2->paramCount; i++ )
{
@@ -558,11 +558,7 @@ ManageVSTEffectView::~ManageVSTEffectView()
vstKnobs = nullptr;
}
if( m_vi2->knobFModel != nullptr )
{
delete [] m_vi2->knobFModel;
m_vi2->knobFModel = nullptr;
}
m_vi2->knobFModel.clear();
if( m_vi2->m_scrollArea != nullptr )
{

View File

@@ -89,7 +89,7 @@ private:
QMdiSubWindow * m_subWindow;
QScrollArea * m_scrollArea;
FloatModel ** knobFModel;
std::vector<FloatModel*> knobFModel;
int paramCount;
QObject * ctrHandle;