lokdocview: ignore notifications on view shutdown

Callbacks are processed on idle on the main thread, so by the time we
parse them, possibly the widget is already gone, avoid that problem.

Change-Id: Ie8e16423d1ffe087e0dd21425026f7a5d644c27b
This commit is contained in:
Miklos Vajna
2016-07-15 17:10:47 +02:00
parent c415f37a40
commit 8090b53e0e

View File

@@ -2394,6 +2394,15 @@ static void lok_doc_view_finalize (GObject* object)
LOKDocView* pDocView = LOK_DOC_VIEW (object);
LOKDocViewPrivate& priv = getPrivate(pDocView);
// Ignore notifications sent to this view on shutdown.
std::unique_lock<std::mutex> aGuard(g_aLOKMutex);
std::stringstream ss;
ss << "lok::Document::setView(" << priv->m_nViewId << ")";
g_info("%s", ss.str().c_str());
priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, nullptr, nullptr);
aGuard.unlock();
if (priv->m_pDocument && priv->m_pDocument->pClass->getViews(priv->m_pDocument) > 1)
{
priv->m_pDocument->pClass->destroyView(priv->m_pDocument, priv->m_nViewId);