Fabien Costantini wrote:
>  > possibly manifest the same bug, e.g. my recent fl_text_extents() mod ?
> 
> To reply this specific question ; I would say YES it can happen in your code 
> IMHO because it heavily relies on fl_gc which has proven to be sometimes NULL 
> (even if for a short period of time most of the time)
> Note that my defensive approach consisting of providing a valid hdc in most 
> situations will limit (quite a lot) such problem to cause a bug but may not 
> prevent it as I said in my last reply especially if we happen to use these 
> kind of api for non screen surfaces with different dpi as an example.
> 
> Ideally, we should change those API like fl_width(), fl_text_extents() and 
> the like ; to include a gc parameter so that we force the developer to assume 
> the responsibility for providing a valid one each time we use it.
> I thought about that one but didn't dare to make such a change because of the 
> large regression risk in the code as it would represent many changes as you 
> can guess.

There is no reason to do that. The fltk2.0 code fixed this by making a 
function called getDC() that always returns a non-null HDC object. It 
also has code similar to the X code to create a permanent small 
off-screen window so there is a window always available to pass to 
functions. This saves a lot of trouble.

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to