From feb5eb180de5e25ee6ee630b66f9cd876df60652 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 26 May 2016 17:02:09 +0100 Subject: avoid a global uno::Reference to the current XCommandEnvironment because the Env is kept until we exit, which we get away with now. But we won't get away with it if we set the parent window property of the InteractionHandler belonging to the Env. Because we then end up trying to destroy the vcl dialog well after all the vcl, etc infrastructure is torn down and crash on exit. Here I'm assuming that its safe to use a WeakReference because we're just using this to smuggle into the c-style callbacks a Reference to a Env currently belonging to something else Change-Id: I2d6b90ae23d5a24431dc49d4316bdc3194560403 (cherry picked from commit 8cce65007b506da38ca79ee8b5cdd62a1460fddd) --- ucb/source/ucp/cmis/auth_provider.cxx | 14 ++++++++++++-- ucb/source/ucp/cmis/auth_provider.hxx | 7 ++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ucb/source/ucp/cmis/auth_provider.cxx b/ucb/source/ucp/cmis/auth_provider.cxx index 0c3e4c0ec52f..ea833b15c859 100644 --- a/ucb/source/ucp/cmis/auth_provider.cxx +++ b/ucb/source/ucp/cmis/auth_provider.cxx @@ -22,8 +22,6 @@ using namespace std; namespace cmis { - css::uno::Reference< css::ucb::XCommandEnvironment> - AuthProvider::sm_xEnv; bool AuthProvider::authenticationQuery( string& username, string& password ) { if ( m_xEnv.is() ) @@ -66,6 +64,18 @@ namespace cmis return false; } + css::uno::WeakReference< css::ucb::XCommandEnvironment> AuthProvider::sm_xEnv; + + void AuthProvider::setXEnv(const css::uno::Reference< css::ucb::XCommandEnvironment>& xEnv ) + { + sm_xEnv = xEnv; + } + + css::uno::Reference< css::ucb::XCommandEnvironment> AuthProvider::getXEnv() + { + return sm_xEnv; + } + char* AuthProvider::onedriveAuthCodeFallback( const char* url, const char* /*username*/, const char* /*password*/ ) diff --git a/ucb/source/ucp/cmis/auth_provider.hxx b/ucb/source/ucp/cmis/auth_provider.hxx index e633e95bd012..c2d1e18e200b 100644 --- a/ucb/source/ucp/cmis/auth_provider.hxx +++ b/ucb/source/ucp/cmis/auth_provider.hxx @@ -12,13 +12,14 @@ #include #include +#include namespace cmis { class AuthProvider : public libcmis::AuthProvider { const css::uno::Reference< css::ucb::XCommandEnvironment>& m_xEnv; - static css::uno::Reference< css::ucb::XCommandEnvironment> sm_xEnv; + static css::uno::WeakReference< css::ucb::XCommandEnvironment> sm_xEnv; OUString m_sUrl; OUString m_sBindingUrl; @@ -38,9 +39,9 @@ namespace cmis const char* /*username*/, const char* /*password*/ ); - static void setXEnv( const css::uno::Reference< css::ucb::XCommandEnvironment>& xEnv ) { sm_xEnv = xEnv; } + static void setXEnv( const css::uno::Reference< css::ucb::XCommandEnvironment>& xEnv ); + static css::uno::Reference< css::ucb::XCommandEnvironment> getXEnv(); - static const css::uno::Reference< css::ucb::XCommandEnvironment>& getXEnv( ) { return sm_xEnv; } }; } -- cgit