Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(872)

Unified Diff: third_party/mojo/src/mojo/public/python/src/common.cc

Issue 975973002: Update mojo sdk to rev f68e697e389943cd9bf9652397312280e96b127a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: shake fist at msvc Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/mojo/src/mojo/public/python/src/common.cc
diff --git a/third_party/mojo/src/mojo/public/python/src/common.cc b/third_party/mojo/src/mojo/public/python/src/common.cc
index e2a832ab389d2903fd6ead2547a6b92934d17af0..d14d718c1f30769a7cd749c8a57b41bf91468b49 100644
--- a/third_party/mojo/src/mojo/public/python/src/common.cc
+++ b/third_party/mojo/src/mojo/public/python/src/common.cc
@@ -41,7 +41,12 @@ ScopedPyRef::ScopedPyRef(PyObject* object) : object_(object) {
ScopedPyRef::ScopedPyRef(PyObject* object, ScopedPyRefAcquire)
: object_(object) {
- Py_XINCREF(object_);
+ if (object_)
+ Py_XINCREF(object_);
+}
+
+ScopedPyRef::ScopedPyRef(const ScopedPyRef& other)
+ : ScopedPyRef(other, kAcquire) {
}
PyObject* ScopedPyRef::Release() {
@@ -57,8 +62,14 @@ ScopedPyRef::~ScopedPyRef() {
}
}
-ScopedPyRef::operator PyObject*() const {
- return object_;
+ScopedPyRef& ScopedPyRef::operator=(const ScopedPyRef& other) {
+ if (other)
+ Py_XINCREF(other);
+ PyObject* old = object_;
+ object_ = other;
+ if (old)
+ Py_DECREF(old);
+ return *this;
}
PythonClosure::PythonClosure(PyObject* callable, const mojo::Closure& quit)

Powered by Google App Engine
This is Rietveld 408576698