summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-11-24 14:00:30 +0100
committerStephan Bergmann <sbergman@redhat.com>2014-11-24 14:00:30 +0100
commit94d2de0ba1f010be7acf0d00ce5b2ed4ed2b895b (patch)
tree09a9153f6f8ecdef341d91368d4575e9ae77837d
parent7839633fb356285652ed96f4bf3f85bcd5b561a4 (diff)
rhbz#1167250: Avoid X11Clipboard already being destroyed in constructor
...via SelectionManager::run's aKeep acquring and releasing getReference() Change-Id: I18696d30c41ca9ae101261668cbf54cb0a6c45fc
-rw-r--r--vcl/unx/generic/dtrans/X11_clipboard.cxx15
-rw-r--r--vcl/unx/generic/dtrans/X11_clipboard.hxx6
-rw-r--r--vcl/unx/generic/dtrans/X11_service.cxx4
3 files changed, 18 insertions, 7 deletions
diff --git a/vcl/unx/generic/dtrans/X11_clipboard.cxx b/vcl/unx/generic/dtrans/X11_clipboard.cxx
index 4e6b953e1728..95d44a548eee 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 626992780f62..ba83636aac74 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 6d5a8fbadd9d..4ec02c123416 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()