diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2015-03-20 17:24:08 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-04-10 13:01:48 +0100 |
commit | 8fb4672aef888fc5a582ca9508799ecdbe777c42 (patch) | |
tree | 346757e6c1bc9664a53270f868a1762edf094e2d /vcl | |
parent | d1091fd50adb1c01d1b1393fd662278611f9e7e1 (diff) |
ScopedVclPtr: needs an = operator to make life flow.
Without this, assigning to a ScopedVclPtr instance thus:
pScopedVclPtr = new Foo();
constructed a new intermediate ScopedVCLPtr, used a default assignment
operator, unhelpfully disposing the new Foo before it could make it to
pScopedVclPtr => add operator, and hide problematic constructors.
Change-Id: Icc0da962938bf115eac0c24a6a76cfeb66ddf23a
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/README.lifecycle | 8 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 3 |
2 files changed, 9 insertions, 2 deletions
diff --git a/vcl/README.lifecycle b/vcl/README.lifecycle index 201e212a9c77..1ee7eab7ea6b 100644 --- a/vcl/README.lifecycle +++ b/vcl/README.lifecycle @@ -67,6 +67,14 @@ to lingering pointers to freed objects. 'dispose' methods, in order to provide a minimal initial behavioral change. + As such a VclPtr can have three states: + + VclPtr<PushButton> pButton; + ... + assert (pButton == nullptr || !pButton); // null + assert (pButton && !pButton->IsDisposed()); // alive + assert (pButton && pButton->IsDisposed()); // disposed + ** ScopedVclPtr - making disposes easier While replacing existing code with new, it can be a bit diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 2af94700afce..b04bad14da0f 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -2264,8 +2264,7 @@ vcl::Font Window::GetPointFont() const void Window::Show( bool bVisible, sal_uInt16 nFlags ) { - - if ( mpWindowImpl->mbVisible == bVisible ) + if ( IsDisposed() || mpWindowImpl->mbVisible == bVisible ) return; ImplDelData aDogTag( this ); |