修复部分UI内存泄漏;

This commit is contained in:
jixiaoxu 2023-02-22 11:05:58 +08:00
parent f34b82e5b6
commit a10dff25c6
3 changed files with 9 additions and 5 deletions

View File

@ -105,7 +105,7 @@ bool GetModelData::cmpApp(QStringList &arg_1, QStringList &arg_2)
QVector<QStringList> GetModelData::getRecentData() QVector<QStringList> GetModelData::getRecentData()
{ {
QVector<QStringList> recentDataVector = QVector<QStringList>(); QVector<QStringList> recentDataVector = QVector<QStringList>();
enumerator = new Peony::FileEnumerator(this); enumerator = new Peony::FileEnumerator();
enumerator->setEnumerateDirectory("recent:///"); enumerator->setEnumerateDirectory("recent:///");
enumerator->enumerateSync(); enumerator->enumerateSync();
@ -126,6 +126,10 @@ QVector<QStringList> GetModelData::getRecentData()
} }
qSort(recentDataVector.begin(), recentDataVector.end(), cmpApp); qSort(recentDataVector.begin(), recentDataVector.end(), cmpApp);
if (enumerator) {
delete enumerator;
enumerator = nullptr;
}
return recentDataVector; return recentDataVector;
} }

View File

@ -25,6 +25,7 @@
KListView::KListView(QWidget *parent): KListView::KListView(QWidget *parent):
QListView(parent) QListView(parent)
{ {
m_listmodel = new QStandardItemModel(this);
} }
KListView::~KListView() KListView::~KListView()
@ -42,7 +43,6 @@ KListView::~KListView()
void KListView::addData(QStringList data) void KListView::addData(QStringList data)
{ {
m_listmodel = new QStandardItemModel(this);
this->setModel(m_listmodel); this->setModel(m_listmodel);
Q_FOREACH(QString desktopfp, data) { Q_FOREACH(QString desktopfp, data) {

View File

@ -23,8 +23,8 @@ SplitBarFrame::SplitBarFrame(QWidget *parent, QString category, int width, int h
m_width(width), m_width(width),
m_height(height), m_height(height),
m_module(module), m_module(module),
m_textLabel(new QLabel), m_textLabel(new QLabel(this)),
m_line(new QFrame) m_line(new QFrame(this))
{ {
initAppBtn(); initAppBtn();
} }
@ -40,7 +40,7 @@ void SplitBarFrame::initAppBtn()
//按钮透明 //按钮透明
this->setFocusPolicy(Qt::NoFocus); this->setFocusPolicy(Qt::NoFocus);
this->setAttribute(Qt::WA_TranslucentBackground); this->setAttribute(Qt::WA_TranslucentBackground);
QHBoxLayout *layout = new QHBoxLayout; QHBoxLayout *layout = new QHBoxLayout(this);
layout->setContentsMargins(15, 0, 0, 0); layout->setContentsMargins(15, 0, 0, 0);
layout->setSpacing(6); layout->setSpacing(6);
m_textLabel->setAutoFillBackground(false); m_textLabel->setAutoFillBackground(false);