- Singleton object, one of the third party library use singleton and my application is multithreaded, so they were on fire. lesson learned: singleton is bad
- Smart pointer, another third party uses smart pointer to manage memory, therefore depends on state it might help me clean up my memory :). lesson learned: raw pointer isn;t that difficult then the behavior is better understood so use more raw pointer
- Unreset windows event, if a event was created with manual reset attribute, the state will stay set until it is manually resetted, this make your program only work correctly at the first time
- thread id, GetThreadId() is only available on window vista and 64bit xp. on xp stored the id yourself. and the question is where to get the id? if you used _beginthread or _beginthreadex, it is the thrdadd parameter
- WM_USER event doesn't dispatch by DispatchMessage(), the reason still a big mistery, hopefully i could find out soon
- if you got interlocking problem while you delete child window with DestroyWindow(), try set exstyle to WS_EX_NOPARENTNOTIFY when you create child window, this could prevent the interlocking. (more testing needed)
- the infamous, interface class no virtual destructor problem, see my previous post
- and many more careless mistakes that do not worth to mention here
Tuesday, May 12, 2009
Another lesson learned
8 hours brain frying debugging finally solved a crashed bug. yes it's a single bug reported in Bugzilla, but it's actually contributed by many sources.
Wednesday, May 6, 2009
destructor of interface derived class will never get called
interface struct in C++ is a structure contained only pure virtual functions. no data member shall be declared in interface struct. and because of this no constructor and destructor needed.
here come the pitfall, consider this
struct IBase
{
virtual void doSomething() = 0;
}
class Derived : public IBase
{
Derived() { text = new char[64]; }
virtual ~Derived() { delete [] text; }
virtual void doSomething() { printf("%s", text);
}
IBase *obj = new Derived();
delete obj;
It was looking perfectly fine to me, until i placed a break point in the derived class destructor. one of the solution is to add a virtual destructor to IBase, but this is ugly and unbalance. the solution I adopted was use self made init() and uninit() insteads.
Monday, May 4, 2009
OpenGL Stack overflow
This strange problem bugging me for some time. the scenario is create opengl rendering context on an existing window, opengl render successfully until the window resize or window bring to top, the window crash immediately after that.
The problem was caused by the opengl context was created on a window that wasn't build for opengl, there are some requirement for a opengl ( i got the hint from this MSDN help)
The solution is create a child window for the exisitng window, the settings work for me was:
[quote]
exStyle = WS_EX_TOPMOST;
style = WS_CHILD | WS_VISIBLE;
[/quote]
Subscribe to:
Comments (Atom)