summaryrefslogtreecommitdiffstats
path: root/base/win/scoped_handle.h
diff options
context:
space:
mode:
Diffstat (limited to 'base/win/scoped_handle.h')
-rw-r--r--base/win/scoped_handle.h15
1 files changed, 5 insertions, 10 deletions
diff --git a/base/win/scoped_handle.h b/base/win/scoped_handle.h
index 3378d00..7111c1a 100644
--- a/base/win/scoped_handle.h
+++ b/base/win/scoped_handle.h
@@ -49,7 +49,8 @@ class GenericScopedHandle {
}
// Move constructor for C++03 move emulation of this type.
- GenericScopedHandle(RValue& other) : handle_(other.Take()) {
+ GenericScopedHandle(RValue& other) : handle_(Traits::NullHandle()) {
+ Set(other.Take());
}
~GenericScopedHandle() {
@@ -62,9 +63,9 @@ class GenericScopedHandle {
// Move operator= for C++03 move emulation of this type.
GenericScopedHandle& operator=(RValue& other) {
- // Swapping the handles helps to avoid problems while assigning a handle
- // to itself. It is also cheap and matches base::scoped_ptr behavior.
- Swap(other);
+ if (this != &other) {
+ Set(other.Take());
+ }
return *this;
}
@@ -97,12 +98,6 @@ class GenericScopedHandle {
return &handle_;
}
- void Swap(GenericScopedHandle& other) {
- Handle tmp = handle_;
- handle_ = other.handle_;
- other.handle_ = tmp;
- }
-
// Transfers ownership away from this object.
Handle Take() {
Handle temp = handle_;