mirror of
https://github.com/LMMS/lmms.git
synced 2026-05-10 07:47:16 -04:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user