On Freitag, 22. Mai 2015 12:26:08 CEST, Jan Kundrát wrote:
...but the m_associatedWebView is a QPointer, and it is guarded
And this is why guarded pointers are shit - they do weird things ;-)
The object is still there, but it's only a qwidget - but we access the
dying object as if it still was a real webview.
So we either would have to emit the destroyed signal explicitly in our
destructor or connect the destroyed signal to a more robust hander:
diff --git a/src/Gui/FindBar.cpp b/src/Gui/FindBar.cpp
index f1823cd..0f20284 100644
--- a/src/Gui/FindBar.cpp
+++ b/src/Gui/FindBar.cpp
@@ -135,6 +135,12 @@ bool FindBar::highlightAllState() const
return m_highlightAll->isChecked();
}
+void FindBar::resetAssociatedWebView()
+{
+ m_associatedWebView = 0L;
+ m_lineEdit->clear();
+ QWidget::hide();
+}
void FindBar::setVisible(bool visible)
{
@@ -183,6 +189,8 @@ void FindBar::notifyMatch(bool match)
void FindBar::find(const QString & search)
{
+ if (!m_associatedWebView)
+ return;
_lastStringSearched = search;
updateHighlight();
findNext();
@@ -304,7 +312,8 @@ void FindBar::setAssociatedWebView(EmbeddedWebView
*webView)
// highlighting is fancy, but terribly expensive - disable by
default for fat messages
m_highlightAll->setChecked(!m_associatedWebView->staticWidth());
// Automatically hide this FindBar widget when the underlying
webview goes away
- connect(m_associatedWebView, SIGNAL(destroyed(QObject*)), this,
SLOT(hide()));
+ connect(m_associatedWebView, SIGNAL(destroyed(QObject*)),
+ this, SLOT(resetAssociatedWebView()));
}
}
diff --git a/src/Gui/FindBar.h b/src/Gui/FindBar.h
index db99796..40b519e 100644
--- a/src/Gui/FindBar.h
+++ b/src/Gui/FindBar.h
@@ -63,6 +63,7 @@ private slots:
void findNext();
void findPrevious();
void updateHighlight();
+ void resetAssociatedWebView();
signals:
void searchString(const QString &);
Feel free to test and commit and push, I won't have access to my git ssh
key today :-(
Notice that the m_lineEdit->clear(); is a slight behavioral change and
clears the search when opening another mail.
Cheers,
Thomas