Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.57 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Why aren't my destructors called when throwing from a win32 timer callback?
  2. class CFoo
  3. {
  4. public:
  5.     ~CFoo() {printf(__FUNCTION__ "n");}
  6. };
  7.  
  8. std::vector< CFoo > GetFooVect()
  9. {
  10.     std::vector< CFoo > rValue;
  11.     rValue.push_back(CFoo());
  12.     rValue.push_back(CFoo());
  13.     rValue.push_back(CFoo());
  14.     return rValue;
  15. }
  16.  
  17. VOID CALLBACK Timer(HWND hwnd,
  18.     UINT uMsg,
  19.     UINT_PTR idEvent,
  20.     DWORD dwTime)
  21. {
  22.     // My destructors aren't called?
  23.     std::vector< CFoo> fooVect = GetFooVect();
  24.  
  25.     // I'm destroyed
  26.     CFoo aFoo;
  27.  
  28.     throw FooExcept();
  29.     printf("Also Heren");
  30. }