Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Patches for Code::Blocks linked with wxWidgets 3.0 Runtime issues
(1/1)
stahta01:
This thread for small patches to fix CB Runtime crashes/error logging when linked wxWidgets 3.0.
Half of the time it crashes on startup when linked against wxWidgets 3.0 branch.
Tim S.
--- Code: ---Index: src/src/splashscreen.cpp
===================================================================
--- src/src/splashscreen.cpp (revision 9506)
+++ src/src/splashscreen.cpp (working copy)
@@ -99,10 +99,12 @@
void cbSplashScreen::OnEraseBackground(wxEraseEvent &event)
{
+#if !wxCHECK_VERSION(3, 0, 0)
wxDC *dc = event.GetDC();
if (dc)
DoPaint(*dc); // why not? :)
+#endif
}
void cbSplashScreen::OnTimer(wxTimerEvent &)
--- End code ---
The message you get if it does not crash is from the next line in file "src/msw/dcclient.cpp".
--- Code: ---wxFAIL_MSG( wxT("wxPaintDCImpl may be created only in EVT_PAINT handler!") );
--- End code ---
oBFusCATed:
The question is do we really need the erase background event. What is its purpose?
It seems to work fine without it on wxGTK 2.8.
stahta01:
--- Quote from: oBFusCATed on December 29, 2013, 06:00:00 pm ---The question is do we really need the erase background event. What is its purpose?
It seems to work fine without it on wxGTK 2.8.
--- End quote ---
I would guess its NOT needed; but, I am not an wxWidgets expert, so it is really just a guess.
Tim S.
MortenMacFly:
--- Quote from: stahta01 on December 29, 2013, 08:09:22 pm ---I would guess its NOT needed; but, I am not an wxWidgets expert, so it is really just a guess.
--- End quote ---
Yes, I think so, too (not needed).
ollydbg:
We should use a wxClientDC to draw something in OnEraseBackground.
See this page:
http://www.informit.com/articles/article.aspx?p=405047
Code:
--- Code: ---BEGIN_EVENT_TABLE(MyWindow, wxWindow)
EVT_ERASE_BACKGROUND(MyWindow::OnErase)
END_EVENT_TABLE()
void MyWindow::OnErase(wxEraseEvent& event)
{
wxClientDC* clientDC = NULL;
if (!event.GetDC())
clientDC = new wxClientDC(this);
wxDC* dc = clientDC ? clientDC : event.GetDC() ;
wxSize sz = GetClientSize();
wxEffects effects;
effects.TileBitmap(wxRect(0, 0, sz.x, sz.y), *dc, m_bitmap);
if (clientDC)
delete clientDC;
}
--- End code ---
So, it is wrong to call DoPaint() here which receive a wrong wxClientDC instance.
Another issue is:
--- Code: ---void cbSplashScreen::OnPaint(wxPaintEvent &)
{
// an obscure statement in the wxWidgets book says to
// allocate the DC even if you don't paint to avoid
// a paint loop. //pecan 2006/04/3
wxPaintDC paint_dc(this);
DoPaint(paint_dc);
}
void cbSplashScreen::OnEraseBackground(wxEraseEvent &event)
{
wxDC *dc = event.GetDC();
if (dc)
DoPaint(*dc); // why not? :)
}
--- End code ---
I think usually erase background event is happened before paint event, so we always paint the screen twice? So, I think we can leave the OnEraseBackground function body empty, this can also avoid flickering (see: Flicker-Free Drawing - WxWiki)
Navigation
[0] Message Index
Go to full version