[Gambas-devel] Segmentation fault / qt component

Daniel Campos daniel.campos at ...103...
Fri Dec 24 14:10:06 CET 2004


Hi Benoit:

This code finish with a segmentation fault:

PUBLIC SUB Button1_MouseDown()
 
  DIM hCur AS Cursor
 
  hCur=NEW Cursor(NULL)
  Button1.Cursor =hCur
 
END

I proppose the following patch at Cmouse.cpp in gb.qt:


BEGIN_METHOD(CCURSOR_new, GB_OBJECT picture; GB_INTEGER x; GB_INTEGER y)

  CPICTURE *pict = (CPICTURE *)VARG(picture);

  THIS->x = VARGOPT(x, -1);
  THIS->y = VARGOPT(y, -1);

  if (!pict)
      THIS->cursor =  new QCursor(QPixmap(), THIS->x, THIS->y);
  else
      THIS->cursor = new QCursor(*(pict->pixmap), THIS->x, THIS->y);

END_METHOD

When "picture" is null, a default cursor is created, instead of crashing.

Regards,

Daniel Campos





More information about the Devel mailing list