listview: infoPtr might be invalid after WM_NOTIFY

Dimi Paun dimi at
Tue Sep 20 10:51:00 CDT 2005

> Dimi, if you think this is ugly, or if you are working on a better
> please do protest.

Well, in part it's a matter of style, and IMO this will clutter the code.
Moreover, the patch as it is now works by accident. For example:

   /* send NM_RELEASEDCAPTURE notification */
-  notify(infoPtr, NM_RELEASEDCAPTURE);
+  notify(infoPtr->hwndSelf, NM_RELEASEDCAPTURE);

   if (!infoPtr->bFocus) SetFocus(infoPtr->hwndSelf);

See, after the notify() the infoPtr may be invalid. This means
that if we assume the control can be deleted at any point we
send out a notification, we have to reget and recheck infoPtr
after every function call. There's got to be a better way.

I personally think an exception-based solution would be better.
This is what exceptions where invented. I know they look alien
in C, but I use them every day in Java for good effect.
It's true, we have to be careful to release resources along the
way, but we have only 6 such allocations that need protecting,
and they are localized. And there we already have a try/catch
simulated with goto's.

Another approach may be to ref count the structure pointed to
by infoPtr, and release it at exit from WinProc when the count
is 0. Sort of a poor man's garbage collection. I'm cool with
this too, and in fact it may be cleaner then the exception-based

Dimi Paun <dimi at>
Lattica, Inc.

More information about the wine-devel mailing list