kicad-developers team mailing list archive
Mailing list archive
Re: Mac & "invalid context"
Dick Hollenbeck <dick@...>
Sat, 27 Oct 2007 23:31:11 -0500
Thunderbird 18.104.22.168pre (X11/20071023)
Marius Kintel wrote:
Kicad was written over a 15 year period, and going back to the start
computers were slower then. One of the considerations then might have
been to "show progress" when loading a board, or doing any type of long
processing, things which now happen in a blink of the eye. One way that
progress is shown, is to draw things on the screen while they are
happening. A good example is loading a board file.
I've been digging deeper into this issue and think I found the cause
of my problems with invalid graphic contexts:
The Mac port of wxWidgets does not support having nested contexts
In short, this means that the following is illegal and any draw
command will fail:
<- draw something here;
One example of where this is done in KiCad (this seems to be done all
over the place):
wxClientDC dc( DrawPanel );
This function eventually calls
WinEDA_BasePcbFrame::Compile_Ratsnest( wxDC* DC ...), which again
calls WinEDA_MsgPanel::EraseMsgBox(), which creates a new context:
wxClientDC dc( this );
This one is easy to fix, but there are more, to an unknown extent.
In general (I'm not familiar with wxWidgets), it's considered nice to
only draw stuff on the paint event itself. I guess this school of
thought is not followed in KiCad, either accidentally or for some
I'm wondering if anyone has any insights, ideas etc. about what to do
Today, this may not be appropriate. Each situation is different, so
don't over extrapolate what I am saying. But in certain situations the
drawing simply does not need to happen until the operation is complete,
because the screen can be redrawn so quickly now.
Obviously this does not extend to situations where drawing does need to
take place interactively, such as dragging operations.
So experiment. And also, you may want to take a look at the wxWidgets
source and also post questions on that list. Perhaps there is an easy
way to increase its functionality to make it compatible with Kicad
source as is.