valgrind: use after free

sal/osl/unx/conditn.cxx:90: pthread_cond_destroy failed: Device or resource busy
sal/osl/unx/conditn.cxx:92: pthread_mutex_destroy failed: Device or resource busy

"Desktop disposed before terminating it"

seen under valgrind with CppunitTest_sccomp_lpsolver

Change-Id: I643cf114b902c38a6a54487fd78c55d84ed78cfc
diff --git a/extensions/source/update/check/updatecheckjob.cxx b/extensions/source/update/check/updatecheckjob.cxx
index ba41067..5d48471 100644
--- a/extensions/source/update/check/updatecheckjob.cxx
+++ b/extensions/source/update/check/updatecheckjob.cxx
@@ -106,9 +106,9 @@ private:
    std::unique_ptr< InitUpdateCheckJobThread > m_pInitThread;

    void handleExtensionUpdates( const uno::Sequence< beans::NamedValue > &rListProp );
    void terminateAndJoinThread();
};


InitUpdateCheckJobThread::InitUpdateCheckJobThread(
            const uno::Reference< uno::XComponentContext > &xContext,
            const uno::Sequence< beans::NamedValue > &xParameters,
@@ -155,7 +155,6 @@ UpdateCheckJob::~UpdateCheckJob()
{
}


uno::Sequence< OUString >
UpdateCheckJob::getServiceNames()
{
@@ -281,6 +280,7 @@ void SAL_CALL UpdateCheckJob::disposing( lang::EventObject const & rEvt )

    if ( shutDown && m_xDesktop.is() )
    {
        terminateAndJoinThread();
        m_xDesktop->removeTerminateListener( this );
        m_xDesktop.clear();
    }
@@ -293,19 +293,23 @@ void SAL_CALL UpdateCheckJob::queryTermination( lang::EventObject const & )
{
}


void SAL_CALL UpdateCheckJob::notifyTermination( lang::EventObject const & )
    throw ( uno::RuntimeException, std::exception )
void UpdateCheckJob::terminateAndJoinThread()
{
    if ( m_pInitThread.get() != nullptr )
    {
        m_pInitThread->setTerminating();
        m_pInitThread->join();
        m_pInitThread.reset();
    }
}

} // anonymous namespace
void SAL_CALL UpdateCheckJob::notifyTermination( lang::EventObject const & )
    throw ( uno::RuntimeException, std::exception )
{
    terminateAndJoinThread();
}

} // anonymous namespace

static uno::Reference<uno::XInterface> SAL_CALL
createJobInstance(const uno::Reference<uno::XComponentContext>& xContext)