summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-08-25 12:36:37 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-08-25 12:36:37 +0200
commitd20575b65d9b6d0f13e3b284bff32d181b19a888 (patch)
treea3eacff46a8767ad0301e2d0360d127c3b85a388
parentMerge commit 'refs/merge-requests/2291' of git://gitorious.org/rekonq/mainlin... (diff)
downloadrekonq-d20575b65d9b6d0f13e3b284bff32d181b19a888.tar.xz
Adding QWeakPointers for the walletbar and the previewselectorbar.
While this can be overkilling for the previewselectorbar, I'd like doing it for all the bars in our next stable, moving them INSIDE the webtab class, so that each webtab has its findbar, its zoombar and so on. This should fix BUG: 243508 Please, let me know if it's not the case.. Thanks!
-rw-r--r--src/webtab.cpp38
-rw-r--r--src/webtab.h8
2 files changed, 35 insertions, 11 deletions
diff --git a/src/webtab.cpp b/src/webtab.cpp
index 0b58d7c5..d5c5b478 100644
--- a/src/webtab.cpp
+++ b/src/webtab.cpp
@@ -92,6 +92,8 @@ WebTab::WebTab(QWidget *parent)
WebTab::~WebTab()
{
+ _walletBar.clear();
+ _previewSelectorBar.clear();
}
@@ -131,6 +133,12 @@ void WebTab::updateProgress(int p)
void WebTab::loadFinished(bool)
{
m_progress = 0;
+ if(_walletBar.isNull())
+ {
+ kDebug() << "OK, it's null";
+ }
+ else
+ kDebug() << "NO, it's NOT null";
}
@@ -142,27 +150,35 @@ void WebTab::createWalletBar(const QString &key, const QUrl &url)
if (blackList.contains(urlString))
return;
+ if(!_walletBar.isNull())
+ {
+ _walletBar.clear();
+ }
KWebWallet *wallet = page()->wallet();
- WalletBar *walletBar = new WalletBar(this);
- walletBar->onSaveFormData(key, url);
- qobject_cast<QVBoxLayout *>(layout())->insertWidget(0, walletBar);
+ _walletBar = new WalletBar(this);
+ _walletBar.data()->onSaveFormData(key, url);
+ qobject_cast<QVBoxLayout *>(layout())->insertWidget(0, _walletBar.data() );
- connect(walletBar, SIGNAL(saveFormDataAccepted(const QString &)),
+ connect(_walletBar.data(), SIGNAL(saveFormDataAccepted(const QString &)),
wallet, SLOT(acceptSaveFormDataRequest(const QString &)));
- connect(walletBar, SIGNAL(saveFormDataRejected(const QString &)),
+ connect(_walletBar.data(), SIGNAL(saveFormDataRejected(const QString &)),
wallet, SLOT(rejectSaveFormDataRequest(const QString &)));
}
void WebTab::createPreviewSelectorBar(int index)
{
- PreviewSelectorBar *bar = new PreviewSelectorBar(index, this);
- qobject_cast<QVBoxLayout *>(layout())->insertWidget(0, bar);
+ if(!_previewSelectorBar.isNull())
+ {
+ _previewSelectorBar.clear();
+ }
+ _previewSelectorBar = new PreviewSelectorBar(index, this);
+ qobject_cast<QVBoxLayout *>(layout())->insertWidget(0, _previewSelectorBar.data());
- connect(page(), SIGNAL(loadStarted()), bar, SLOT(loadProgress()));
- connect(page(), SIGNAL(loadProgress(int)), bar, SLOT(loadProgress()));
- connect(page(), SIGNAL(loadFinished(bool)), bar, SLOT(loadFinished()));
- connect(page()->mainFrame(), SIGNAL(urlChanged(QUrl)), bar, SLOT(verifyUrl()));
+ connect(page(), SIGNAL(loadStarted()), _previewSelectorBar.data(), SLOT(loadProgress()));
+ connect(page(), SIGNAL(loadProgress(int)), _previewSelectorBar.data(), SLOT(loadProgress()));
+ connect(page(), SIGNAL(loadFinished(bool)), _previewSelectorBar.data(), SLOT(loadFinished()));
+ connect(page()->mainFrame(), SIGNAL(urlChanged(QUrl)), _previewSelectorBar.data(), SLOT(verifyUrl()));
}
diff --git a/src/webtab.h b/src/webtab.h
index e34bbccf..a24418ef 100644
--- a/src/webtab.h
+++ b/src/webtab.h
@@ -41,6 +41,11 @@
// Qt Includes
#include <QWidget>
+#include <QWeakPointer>
+
+// Forward Declarations
+class WalletBar;
+class PreviewSelectorBar;
class REKONQ_TESTS_EXPORT WebTab : public QWidget
@@ -74,6 +79,9 @@ private:
WebView *_view;
int m_progress;
+
+ QWeakPointer<WalletBar> _walletBar;
+ QWeakPointer<PreviewSelectorBar> _previewSelectorBar;
};
#endif