Kaydet (Commit) b6bd432a authored tarafından Michael Meeks's avatar Michael Meeks

vcl: more VclPtr debugging docs in the README.lifecycle.

Change-Id: I49d06d54157e1e7c5b7ce2aa3f8917763de6826d
üst 087f7fe5
...@@ -299,4 +299,28 @@ ways and often both. ...@@ -299,4 +299,28 @@ ways and often both.
cleanup methods, especially LoseFocus continue to work even cleanup methods, especially LoseFocus continue to work even
on disposed Window sub-class instances. on disposed Window sub-class instances.
** It crashes with some invalid memory ...
Assuming that the invalid memory is a Window sub-class itself,
then almost certainly there is some cockup in the
reference-counting; eg. if you hit an OutputDevice::release
assert on mnRefCount - then almost certainly you have a
Window that has already been destroyed. This can easily
happen via this sort of pattern:
ModelessDialog *pDlg = VclPtr<ModelessDialog>(nullptr /* parent */);
// by here the pDlg quite probably points to free'd memory
...
It is necessary in these cases to ensure that the *pDlg is
a VclPtr<ModelessDialog> instead.
** It crashes with some invalid memory #2 ...
Often a ::dispose method will free some pImpl member, but
not NULL it; and (cf. above) we can now get various virtual
methods called post-dispose; so:
a) delete pImpl; pImpl = NULL; // in the destructor
b) if (pImpl && ...) // in the subsequently called method
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment