TurboPack / SynEdit

SynEdit is a syntax highlighting edit control, not based on the Windows common controls.
226 stars 75 forks source link

Error when paint clipping rectangle is empty. #162

Closed MShark67 closed 2 years ago

MShark67 commented 2 years ago

In TCustomSynEdit.Paint it first gets the ClipRect from the canvas. It looks like under certain conditions this rect can be empty. If it is empty, the gutter still tries to paint itself, which leads to a "The parameter is incorrect." error when TSynDWrite.ImagingFactory.CreateBitmap is called with a height of zero. It looks like text line painting correctly exits in the case of no lines to paint, it looks like PaintGutter just needs a similar check. Unfortunately I can't always replicate the problem, so I don't know exactly what causes paint to be called with an empty cliprect, but it has to do with loading a very large file or turning word wrap on for a large (wide) file.

MShark67 commented 2 years ago

Would it make sense to add this to TCustomSynEdit.Paint?

  rcClip := Canvas.ClipRect;
  if rcClip.IsEmpty then
    Exit;

I still can't reliably cause it. I think it might have something to do with a paint message getting through while the window is being "ghosted" by the OS due to the main message window not responding during a long main thread process.

pyscripter commented 2 years ago

Please check if you are still getting the errors.

MShark67 commented 2 years ago

I think this has fixed it, thanks!!