diff --git a/src/lib/adblock/adblockicon.cpp b/src/lib/adblock/adblockicon.cpp index 2c450df7a..0d4ed1215 100644 --- a/src/lib/adblock/adblockicon.cpp +++ b/src/lib/adblock/adblockicon.cpp @@ -46,6 +46,8 @@ AdBlockIcon::AdBlockIcon(BrowserWindow* window, QWidget* parent) AdBlockIcon::~AdBlockIcon() { + for (int i = 0; i < m_blockedPopups.count(); ++i) + delete m_blockedPopups.at(i).first; } void AdBlockIcon::popupBlocked(const QString &ruleString, const QUrl &url) @@ -59,10 +61,8 @@ void AdBlockIcon::popupBlocked(const QString &ruleString, const QUrl &url) return; } - AdBlockRule rule(filter, subscription); - - QPair pair; - pair.first = rule; + QPair pair; + pair.first = new AdBlockRule(filter, subscription); pair.second = url; m_blockedPopups.append(pair); @@ -138,13 +138,13 @@ void AdBlockIcon::createMenu(QMenu* menu) if (!m_blockedPopups.isEmpty()) { menu->addAction(tr("Blocked Popup Windows"))->setEnabled(false); for (int i = 0; i < m_blockedPopups.count(); i++) { - const QPair &pair = m_blockedPopups.at(i); + const QPair &pair = m_blockedPopups.at(i); QString address = pair.second.toString().right(55); - QString actionText = tr("%1 with (%2)").arg(address, pair.first.filter()).replace(QLatin1Char('&'), QLatin1String("&&")); + QString actionText = tr("%1 with (%2)").arg(address, pair.first->filter()).replace(QLatin1Char('&'), QLatin1String("&&")); QAction* action = menu->addAction(actionText, manager, SLOT(showRule())); - action->setData(QVariant::fromValue((void*)&pair.first)); + action->setData(QVariant::fromValue((void*)pair.first)); } } diff --git a/src/lib/adblock/adblockicon.h b/src/lib/adblock/adblockicon.h index d8e029b08..2b1897c28 100644 --- a/src/lib/adblock/adblockicon.h +++ b/src/lib/adblock/adblockicon.h @@ -52,7 +52,7 @@ private: BrowserWindow* m_window; QAction* m_menuAction; - QVector > m_blockedPopups; + QVector > m_blockedPopups; QTimer* m_flashTimer; int m_timerTicks; diff --git a/src/lib/adblock/adblockrule.h b/src/lib/adblock/adblockrule.h index 945ef32a6..77515e074 100644 --- a/src/lib/adblock/adblockrule.h +++ b/src/lib/adblock/adblockrule.h @@ -60,6 +60,8 @@ class AdBlockSubscription; class QUPZILLA_EXPORT AdBlockRule { + Q_DISABLE_COPY(AdBlockRule) + public: AdBlockRule(const QString &filter = QString(), AdBlockSubscription* subscription = 0); ~AdBlockRule();