diff --git a/debian/changelog b/debian/changelog index 48f0624..e69c7b1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ qtermwidget (0.9.0-1ubuntu1) UNRELEASED; urgency=medium * Update the maintainer and Vcs-* for maintaining in Lubuntu. + * Add patch reworking memory management of filter-related objects. -- Simon Quigley Tue, 10 Jul 2018 22:07:08 -0500 diff --git a/debian/patches/rework-memory-management-filter-related-objects.patch b/debian/patches/rework-memory-management-filter-related-objects.patch new file mode 100644 index 0000000..7f33499 --- /dev/null +++ b/debian/patches/rework-memory-management-filter-related-objects.patch @@ -0,0 +1,171 @@ +Description: Rework memory management of filter-related objects +Author: Yen Chi Hsuan +Origin: upstream +Bug: https://github.com/lxqt/qterminal/issues/358 +Applied-Upstream: commit:0154e03 +Last-Update: 2018-07-10 +--- a/lib/Filter.cpp ++++ b/lib/Filter.cpp +@@ -22,6 +22,7 @@ + + // System + #include ++#include + + // Qt + #include +@@ -195,7 +196,15 @@ Filter::~Filter() + } + void Filter::reset() + { +- qDeleteAll(_hotspotList); ++ QListIterator iter(_hotspotList); ++ while (iter.hasNext()) ++ { ++ HotSpot* currentHotSpot = iter.next(); ++ if (currentHotSpot->hasAnotherParent()) { ++ continue; ++ } ++ delete currentHotSpot; ++ } + _hotspots.clear(); + _hotspotList.clear(); + } +@@ -287,10 +296,13 @@ Filter::HotSpot::HotSpot(int startLine , + , _endLine(endLine) + , _endColumn(endColumn) + , _type(NotSpecified) ++ , _hasAnotherParent(false) + { + } +-QList Filter::HotSpot::actions() ++QList Filter::HotSpot::actions(QWidget* parent) + { ++ Q_UNUSED(parent); ++ + return QList(); + } + int Filter::HotSpot::startLine() const +@@ -502,14 +514,28 @@ FilterObject* UrlFilter::HotSpot::getUrl + return _urlObject; + } + +-QList UrlFilter::HotSpot::actions() ++class UrlAction : public QAction { ++public: ++ UrlAction(QWidget* parent, std::shared_ptr hotspotPtr) ++ : QAction(parent) ++ , _hotspotPtr(hotspotPtr) ++ { ++ } ++ ++private: ++ std::shared_ptr _hotspotPtr; ++}; ++ ++QList UrlFilter::HotSpot::actions(QWidget* parent) + { ++ this->_hasAnotherParent = true; + QList list; + + const UrlType kind = urlType(); + +- QAction* openAction = new QAction(_urlObject); +- QAction* copyAction = new QAction(_urlObject);; ++ std::shared_ptr hotspotPtr(this); ++ UrlAction* openAction = new UrlAction(parent, hotspotPtr); ++ UrlAction* copyAction = new UrlAction(parent, hotspotPtr); + + Q_ASSERT( kind == StandardUrl || kind == Email ); + +--- a/lib/Filter.h ++++ b/lib/Filter.h +@@ -115,19 +115,22 @@ public: + * Returns a list of actions associated with the hotspot which can be used in a + * menu or toolbar + */ +- virtual QList actions(); ++ virtual QList actions(QWidget* parent); ++ ++ bool hasAnotherParent() const { return _hasAnotherParent; } + + protected: + /** Sets the type of a hotspot. This should only be set once */ + void setType(Type type); + ++ bool _hasAnotherParent; ++ + private: + int _startLine; + int _startColumn; + int _endLine; + int _endColumn; + Type _type; +- + }; + + /** Constructs a new filter. */ +@@ -256,7 +259,7 @@ public: + + FilterObject* getUrlObject() const; + +- virtual QList actions(); ++ virtual QList actions(QWidget* parent); + + /** + * Open a web browser at the current URL. The url itself can be determined using +--- a/lib/TerminalDisplay.cpp ++++ b/lib/TerminalDisplay.cpp +@@ -1957,14 +1957,14 @@ void TerminalDisplay::mousePressEvent(QM + } + } + +-QList TerminalDisplay::filterActions(const QPoint& position) ++QList TerminalDisplay::filterActions(const QPoint& position, QWidget* parent) + { + int charLine, charColumn; + getCharacterPosition(position,charLine,charColumn); + + Filter::HotSpot* spot = _filterChain->hotSpotAt(charLine,charColumn); + +- return spot ? spot->actions() : QList(); ++ return spot ? spot->actions(parent) : QList(); + } + + void TerminalDisplay::mouseMoveEvent(QMouseEvent* ev) +--- a/lib/TerminalDisplay.h ++++ b/lib/TerminalDisplay.h +@@ -158,7 +158,7 @@ public: + * Returns a list of menu actions created by the filters for the content + * at the given @p position. + */ +- QList filterActions(const QPoint& position); ++ QList filterActions(const QPoint& position, QWidget* parent); + + /** Returns true if the cursor is set to blink or false otherwise. */ + bool blinkingCursor() { return _hasBlinkingCursor; } +--- a/lib/qtermwidget.cpp ++++ b/lib/qtermwidget.cpp +@@ -694,9 +694,9 @@ Filter::HotSpot* QTermWidget::getHotSpot + return m_impl->m_terminalDisplay->filterChain()->hotSpotAt(row, column); + } + +-QList QTermWidget::filterActions(const QPoint& position) ++QList QTermWidget::filterActions(const QPoint& position, QWidget* parent) + { +- return m_impl->m_terminalDisplay->filterActions(position); ++ return m_impl->m_terminalDisplay->filterActions(position, parent); + } + + int QTermWidget::getPtySlaveFd() const +--- a/lib/qtermwidget.h ++++ b/lib/qtermwidget.h +@@ -186,7 +186,7 @@ public: + /* + * Proxy for TerminalDisplay::filterActions + * */ +- QList filterActions(const QPoint& position); ++ QList filterActions(const QPoint& position, QWidget* parent); + + /** + * Returns a pty slave file descriptor. diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..3258f55 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +rework-memory-management-filter-related-objects.patch