summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyuno/inc/pyuno.hxx16
1 files changed, 13 insertions, 3 deletions
diff --git a/pyuno/inc/pyuno.hxx b/pyuno/inc/pyuno.hxx
index c80d9b13f8fc..bd1166683408 100644
--- a/pyuno/inc/pyuno.hxx
+++ b/pyuno/inc/pyuno.hxx
@@ -101,7 +101,8 @@ public:
throw std::bad_alloc();
}
- PyRef( const PyRef &r ) : m( r.get() ) { Py_XINCREF( m ); }
+ PyRef(const PyRef &r) : m(r.get()) { Py_XINCREF(m); }
+ PyRef(PyRef &&r) : m(r.get()) { r.scratch(); }
~PyRef() { Py_XDECREF( m ); }
@@ -113,11 +114,20 @@ public:
return m;
}
- PyRef & operator = ( const PyRef & r )
+ PyRef& operator=(const PyRef& r)
{
PyObject *tmp = m;
m = r.getAcquired();
- Py_XDECREF( tmp );
+ Py_XDECREF(tmp);
+ return *this;
+ }
+
+ PyRef& operator=(PyRef&& r)
+ {
+ PyObject *tmp = m;
+ m = r.get();
+ r.scratch();
+ Py_XDECREF(tmp);
return *this;
}