fix(terminal): free the scroll bar and foreground process info of a closed session

main
reionwong 4 weeks ago
parent 96fb498e09
commit ace21f4a24

@ -630,6 +630,7 @@ Session::~Session()
close();
delete _emulation;
delete _shellProcess;
delete _foregroundProcessInfo;
// delete _zmodemProc;
}

@ -448,7 +448,7 @@ TerminalDisplay::TerminalDisplay(QQuickItem *parent)
// create scroll bar for scrolling output up and down
// set the scroll bar's slider to occupy the whole area of the scroll bar initially
_scrollBar = new ScrollBar();
_scrollBar = new ScrollBar(this);
// since the contrast with the terminal background may not be enough,
// the scrollbar should be auto-filled if not transient
if (!_scrollBar->isTransient())

@ -1,3 +1,4 @@
#include <QPointer>
#include <QQuickWindow>
#include <QTest>
#include <QWheelEvent>
@ -145,6 +146,17 @@ private slots:
QVERIFY(value() > 0);
}
// Every closed tab destroys a display; its scroll bar goes with it.
void closingTheDisplayFreesItsScrollBar()
{
const QPointer<ScrollBar> scrollBar = m_display->findChild<ScrollBar *>();
QVERIFY(scrollBar);
delete m_display;
m_display = nullptr;
QVERIFY(scrollBar.isNull());
}
private:
int value() const { return m_display->property("scrollbarCurrentValue").toInt(); }
int maximum() const { return m_display->property("scrollbarMaximum").toInt(); }

Loading…
Cancel
Save