[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - vcl/unx

Stephan Bergmann sbergman at redhat.com
Mon Nov 24 08:30:02 PST 2014


 vcl/unx/generic/dtrans/X11_clipboard.cxx |   15 +++++++++++----
 vcl/unx/generic/dtrans/X11_clipboard.hxx |    6 +++++-
 vcl/unx/generic/dtrans/X11_service.cxx   |    4 ++--
 3 files changed, 18 insertions(+), 7 deletions(-)

New commits:
commit 493ecf8f17185bbd9ffe1ac9c58791da6d23b0d9
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Nov 24 14:00:30 2014 +0100

    rhbz#1167250: Avoid X11Clipboard already being destroyed in constructor
    
    ...via SelectionManager::run's aKeep acquring and releasing getReference()
    
    Change-Id: I18696d30c41ca9ae101261668cbf54cb0a6c45fc
    (cherry picked from commit 94d2de0ba1f010be7acf0d00ce5b2ed4ed2b895b)
    Reviewed-on: https://gerrit.libreoffice.org/13102
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/unx/generic/dtrans/X11_clipboard.cxx b/vcl/unx/generic/dtrans/X11_clipboard.cxx
index 4e6b953..95d44a5 100644
--- a/vcl/unx/generic/dtrans/X11_clipboard.cxx
+++ b/vcl/unx/generic/dtrans/X11_clipboard.cxx
@@ -29,6 +29,7 @@
 #include <uno/mapping.hxx>
 #include <cppuhelper/factory.hxx>
 #include <cppuhelper/supportsservice.hxx>
+#include <rtl/ref.hxx>
 #include <rtl/tencinfo.h>
 
 #if OSL_DEBUG_LEVEL > 1
@@ -57,16 +58,22 @@ X11Clipboard::X11Clipboard( SelectionManager& rManager, Atom aSelection ) :
 #if OSL_DEBUG_LEVEL > 1
     fprintf( stderr, "creating instance of X11Clipboard (this=%p)\n", this );
 #endif
+}
 
-    if( m_aSelection != None )
+css::uno::Reference<css::datatransfer::clipboard::XClipboard>
+X11Clipboard::create( SelectionManager& rManager, Atom aSelection )
+{
+    rtl::Reference<X11Clipboard> cb(new X11Clipboard(rManager, aSelection));
+    if( aSelection != None )
     {
-        m_rSelectionManager.registerHandler( m_aSelection, *this );
+        rManager.registerHandler( aSelection, *cb.get() );
     }
     else
     {
-        m_rSelectionManager.registerHandler( XA_PRIMARY, *this );
-        m_rSelectionManager.registerHandler( m_rSelectionManager.getAtom( OUString("CLIPBOARD") ), *this );
+        rManager.registerHandler( XA_PRIMARY, *cb.get() );
+        rManager.registerHandler( rManager.getAtom( OUString("CLIPBOARD") ), *cb.get() );
     }
+    return cb.get();
 }
 
 X11Clipboard::~X11Clipboard()
diff --git a/vcl/unx/generic/dtrans/X11_clipboard.hxx b/vcl/unx/generic/dtrans/X11_clipboard.hxx
index 6269927..ba83636 100644
--- a/vcl/unx/generic/dtrans/X11_clipboard.hxx
+++ b/vcl/unx/generic/dtrans/X11_clipboard.hxx
@@ -46,6 +46,8 @@ namespace x11 {
         ::std::list< css::uno::Reference< css::datatransfer::clipboard::XClipboardListener > > m_aListeners;
         Atom                                                    m_aSelection;
 
+        X11Clipboard( SelectionManager& rManager, Atom aSelection );
+
     protected:
 
         friend class SelectionManager;
@@ -55,7 +57,9 @@ namespace x11 {
 
     public:
 
-        X11Clipboard( SelectionManager& rManager, Atom aSelection );
+        static css::uno::Reference<css::datatransfer::clipboard::XClipboard>
+        create( SelectionManager& rManager, Atom aSelection );
+
         virtual ~X11Clipboard();
 
         static X11Clipboard* get( const OUString& rDisplayName, Atom aSelection );
diff --git a/vcl/unx/generic/dtrans/X11_service.cxx b/vcl/unx/generic/dtrans/X11_service.cxx
index 6d5a8fb..4ec02c1 100644
--- a/vcl/unx/generic/dtrans/X11_service.cxx
+++ b/vcl/unx/generic/dtrans/X11_service.cxx
@@ -77,10 +77,10 @@ css::uno::Reference< XInterface > X11SalInstance::CreateClipboard( const Sequenc
     if( it != m_aInstances.end() )
         return it->second;
 
-    X11Clipboard* pClipboard = new X11Clipboard( rManager, nSelection );
+    css::uno::Reference<css::datatransfer::clipboard::XClipboard> pClipboard = X11Clipboard::create( rManager, nSelection );
     m_aInstances[ nSelection ] = pClipboard;
 
-    return static_cast<OWeakObject*>(pClipboard);
+    return pClipboard;
 }
 
 css::uno::Reference< XInterface > X11SalInstance::CreateDragSource()


More information about the Libreoffice-commits mailing list