The question title is fairly self-explanatory. I'm deleting something twice. But it's really a synchronization problem I'm dealing with here. I'm hoping that there are some sort of "gotchas" that I don't know about when painting or something silly I'm doing wrong with my synchronization. Maybe if I tell you what I'm doing - you can tell me what to look out for and help me solve my problem! I reproduce this problem by causing lots of repaints and by having my OnLButtonClick and OnMouseWheel functions called by these event handlers. I'm also using CStrings and I notice a lot of the time the errors come from their use.
Upon entering OnPaint, OnMouseWheel and OnLButtonClick, I EnterCriticalSection and upon leaving the functions, I LeaveCriticalSection. These 3 functions contain the bulk of the work and they are the ones that cause my member array to have its contents deleted and recreated. It takes quite a lot of quick clicking and moving the mouse wheel to cause repaints before I get errors like "HEAP: Free Heap block cc6988 modified at cc6ba4 after it was freed" or "scalar deleting destructor".
Thank you very much,