CtrlDraw: Improved debug checking w.r.t. exceptions

git-svn-id: svn://ultimatepp.org/upp/trunk@7957 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-12-09 14:39:22 +00:00
parent 312af12b0a
commit 072d280e4f
2 changed files with 7 additions and 2 deletions

View file

@ -242,6 +242,7 @@ Rect Ctrl::GetVoidRect() const
#ifdef _DEBUG
struct sDrawLevelCheck {
Draw& w;
int lvl;
@ -252,7 +253,7 @@ struct sDrawLevelCheck {
}
sDrawLevelCheck(Draw& w, const Ctrl *q) : w(w), lvl(w.GetCloffLevel()), q(q) {}
~sDrawLevelCheck() { Check(); }
// NOTE: Checking level in destructor is a bad idea because of exceptions
};
#define LEVELCHECK(w, q) sDrawLevelCheck _x_(w, q)
@ -341,6 +342,7 @@ void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) {
ApplyTransform(TS_AFTER_CTRL_PAINT);
//glPopMatrix();
w.PopContext();
DOLEVELCHECK;
}
#else
void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) {
@ -417,6 +419,7 @@ void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) {
}
w.End();
}
DOLEVELCHECK;
}
#endif
@ -471,6 +474,7 @@ bool Ctrl::PaintOpaqueAreas(SystemDraw& w, const Rect& r, const Rect& clip, bool
LEVELCHECK(bw, this);
Paint(bw);
PaintCaret(bw);
DOLEVELCHECK;
}
bw.Put(w, opaque.TopLeft());
}
@ -482,6 +486,7 @@ bool Ctrl::PaintOpaqueAreas(SystemDraw& w, const Rect& r, const Rect& clip, bool
LEVELCHECK(w, this);
Paint(w);
PaintCaret(w);
DOLEVELCHECK;
}
w.End();
w.End();

View file

@ -62,7 +62,6 @@ bool PassWindowsKey(int wParam);
LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
GuiLock __;
eventid++;
ASSERT_(!painting || IsPanicMode(), "WindowProc invoked for " + Name() + " while in Paint routine");
// LLOG("Ctrl::WindowProc(" << message << ") in " << ::Name(this) << ", focus " << (void *)::GetFocus());
Ptr<Ctrl> _this = this;
HWND hwnd = GetHWND();
@ -86,6 +85,7 @@ LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
}
#endif
case WM_PAINT:
ASSERT_(!painting || IsPanicMode(), "WM_PAINT invoked for " + Name() + " while in Paint routine");
ASSERT(hwnd);
if(hwnd) {
PAINTSTRUCT ps;