Accessing canvas warning lazarus / 31-LCL ---------------------------------------------------------------------- timppl · 2012-03-02 08:00 Hello all; In the app I am porting from Delphi I get the following message continually in the output terminal TControlCanvas.CreateHandle WARNING: accessing the canvas of TrackPlan:TTrackPlan is not supported outside of paint message I don't understand what it means, as the code works fine and draws what it is supposed to, whereas the 'not supported' message implies that it should not work. So, what exactly does this message mean? Mandriva 2011, GTK2, Lazarus 35296 Regards Tim ---------------------------------------------------------------------- zeljko · 2012-03-03 11:54 That means that you're trying to paint on canvas out of paint event. It's bad technique and it works visually because gtk2 supports that. eg. qt/carbon/cocoa does not support painting outside of paint event. ---------------------------------------------------------------------- timppl · 2012-03-05 07:16 Hi Zeljko I suspected it was something like that. The code is as written for delphi and as it works on windows and linux/gtk2 refactoring goes to the bottom of the todo pile  Regards Tim ---------------------------------------------------------------------- Thomas Munk · 2013-11-11 10:06 Wouldn't it be fair for LCL to check for TLCLCapability.lcCanDrawOutsideOnPaint before this DebugLn "WARNING: accessing the canvas of... is not supported outside of paint message"? It might not (always) be best practice painting outside a paint event, but in some widgetsets it's not illegal. Therefore, if used, the terminal should not be flooded with this message. ---------------------------------------------------------------------- zeljko · 2013-11-14 07:06 Quote from: Thomas Munk on November 11, 2013, 11:06:16 amWouldn't it be fair for LCL to check for TLCLCapability.lcCanDrawOutsideOnPaint before this DebugLn "WARNING: accessing the canvas of... is not supported outside of paint message"? It might not (always) be best practice painting outside a paint event, but in some widgetsets it's not illegal. Therefore, if used, the terminal should not be flooded with this message. Fixed in r43443. ---------------------------------------------------------------------- Zoran · 2013-11-14 07:38 I disagree. I like to be warned when creating code which will not work well on other architectures/OS-s/widgetsets. If you really know why, there is nothing wrong when you use such techniques, but at least you should be warned. ---------------------------------------------------------------------- zeljko · 2013-11-15 07:41 Quote from: Zoran on November 14, 2013, 08:38:34 amI disagree. I like to be warned when creating code which will not work well on other architectures/OS-s/widgetsets. If you really know why, there is nothing wrong when you use such techniques, but at least you should be warned. You're right too , so now my question raises: should I revert that commit or better what to do ? ---------------------------------------------------------------------- howardpc · 2013-11-15 07:49 I suppose the best of both worlds would be to make the Warning on by default, but add (yet another) compiling option that allows the developer to turn this particular Warning off if desired to write non- cross-platform or questionable code. ---------------------------------------------------------------------- taazz · 2013-11-15 08:55 Isn't there a turn of platform warnings (or something along those lines) directive? why don't you simple add the warning to platform group and let it be turned of when ever needed be. ---------------------------------------------------------------------- Thomas Munk · 2013-11-15 12:50 I agree with howardpc:I think that a default warning is OK as long it can be turned off with a compiler directive - and maybe as taazz mentions: an existing directive? ---------------------------------------------------------------------- Thomas Munk · 2013-11-15 13:01 Maybe a little too quick: Normally LCL is precompiled and wouldn't react to a compiler directive, right? In that case my vote is: Do not warn about something that IS legal on the current platform.