Commit 16e6d336 authored by Christian Esken's avatar Christian Esken
Browse files

Fix some more memory leaking.

CCBUGS: 309464
parent 3be72f82
......@@ -516,6 +516,7 @@ Mixer_ALSA::close()
deinitAlsaPolling();
closeCommon();
return ret;
}
......
......@@ -45,16 +45,14 @@ m_devnum (device) , m_isOpen(false), m_recommendedMaster(), _mixer(mixer), _poll
}
int Mixer_Backend::shutdown()
void Mixer_Backend::closeCommon()
{
int ret = close();
freeMixDevices();
return ret;
}
int Mixer_Backend::close()
{
kDebug() << "Implicit close on " << this << ". Please instead call close() explicitly (before destroying this object)";
kDebug() << "Implicit close on " << this << ". Please instead call closeCommon() and close() explicitly (in concrete Backend destructor)";
// ^^^ Background. before the destructor runs, the C++ runtime changes the virtual pointers to point back
// to the common base class. So what actually runs is not run Mixer_ALSA::close(), but this method.
//
......@@ -65,10 +63,13 @@ int Mixer_Backend::close()
Mixer_Backend::~Mixer_Backend()
{
if (!m_mixDevices.isEmpty())
{
kDebug() << "Implicit close on " << this << ". Please instead call closeCommon() and close() explicitly (in concrete Backend destructor)";
}
kDebug() << "Destruct " << this;
// qDebug() << "Running Mixer_Backend destructor";
delete _pollingTimer;
shutdown();
}
void Mixer_Backend::freeMixDevices()
......@@ -97,7 +98,7 @@ bool Mixer_Backend::openIfValid() {
} // could be opened
else
{
shutdown();
//shutdown();
}
return valid;
}
......
......@@ -57,9 +57,9 @@ protected:
virtual int close();
/*
* Shutdown deinitializes this MixerBackend, freeing resources and calling close()
* Shutdown deinitializes this MixerBackend, freeing resources
*/
virtual int shutdown();
void closeCommon();
/*
* Returns the driver name, e.g. "ALSA" or "OSS". This virtual method is for looking up the
......
......@@ -57,6 +57,7 @@ int Mixer_MPRIS2::open()
int Mixer_MPRIS2::close()
{
m_isOpen = false;
closeCommon();
return 0;
}
......@@ -436,6 +437,7 @@ void MPrisAppdata::volumeChangedIncoming(QString /*ifc*/,QVariantMap msg ,QStrin
Mixer_MPRIS2::~Mixer_MPRIS2()
{
close();
}
MPrisAppdata::MPrisAppdata()
......
......@@ -187,6 +187,7 @@ int Mixer_OSS::close()
_pollingTimer->stop();
m_isOpen = false;
int l_i_ret = ::close(m_fd);
closeCommon();
return l_i_ret;
}
......
......@@ -482,6 +482,7 @@ int Mixer_OSS4::close()
m_isOpen = false;
int l_i_ret = ::close(m_fd);
m_recommendedMaster.reset();
closeCommon();
return l_i_ret;
}
......
......@@ -995,6 +995,8 @@ Mixer_PULSE::~Mixer_PULSE()
}
}
}
closeCommon();
}
int Mixer_PULSE::open()
......@@ -1047,6 +1049,7 @@ int Mixer_PULSE::open()
int Mixer_PULSE::close()
{
closeCommon();
return 1;
}
......
......@@ -222,6 +222,7 @@ int Mixer_SUN::close()
_pollingTimer->stop();
m_isOpen = false;
int l_i_ret = ::close( fd );
closeCommon();
return l_i_ret;
}
......
......@@ -297,7 +297,7 @@ bool Mixer::openIfValid(int cardId)
void Mixer::close()
{
if ( _mixerBackend != 0)
_mixerBackend->shutdown();
_mixerBackend->closeCommon();
}
......
......@@ -158,7 +158,7 @@ void OSDWidget::themeUpdated()
if (!Plasma::Theme::defaultTheme()->imagePath("icons/audio").isEmpty()) {
QFontMetrics fm(m_volumeLabel->font());
iconSize = QSize(fm.height(), fm.height());
// Leak prio=low The old Plasma::Svg is not freed on a themeUpdated(), also it is not freed in the destructor
// Leak | low prio | The old Plasma::Svg is not freed on a themeUpdated(), also it is not freed in the destructor
Plasma::Svg *svgIcon = new Plasma::Svg(this);
svgIcon->setImagePath("icons/audio");
svgIcon->setContainsMultipleImages(true);
......
......@@ -283,6 +283,11 @@ QWidget* ViewDockAreaPopup::add(shared_ptr<MixDevice> md)
QString dummyMatchAll("*");
QString matchAllPlaybackAndTheCswitch("pvolume,cvolume,pswitch,cswitch");
// Leak | relevant | pctl Each time a stream is added, a new ProfControl gets created.
// It cannot be deleted in ~MixDeviceWidget, as ProfControl* ownership is not consistent.
// here a new pctl is created (could be deleted), but in ViewSliders the ProcControl is taken from the
// MixDevice, which in turn uses it from the GUIProfile.
// Summarizing: ProfControl* is either owned by the GUIProfile or created new (ownership unclear).
ProfControl *pctl = new ProfControl( dummyMatchAll, matchAllPlaybackAndTheCswitch);
if ( !md->isApplicationStream() )
......
Supports Markdown
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