It works fine now.

>    if(V3DS_box)
>    {
>       delete V3DS_box;
>       V3DS_box = NULL;
>    }

thanks.















> On 3 Oct 2012, at 21:08, Furqan wrote:
>
> > What I am doing is, I am creating a box in fl_double window like this.
> >=20
> > V3DS_box =3D new Fl_Box(FL_DOWN_FRAME, 400, 10, w+10, h+10, "");
> >=20
> > but I need to execute the main subroutine several times without =
> closing the fl_double window, if I close fl_double window then its ok. =
> but without closing the window, I got an error, because every time =
> fl_box creates on the same fl_double window. So, here I need to delete =
> V3DS_box first in order to do the operation again. The issue is how can =
> delete the box. I tried like this,
> >=20
> > if(V3DS_box) free(V3DS_box);
> > V3DS_box =3D new Fl_Box(FL_DOWN_FRAME, 400, 10, w+10, h+10, "");
> >=20
> > in debug mode, it gives no error but in release mode, the system goes =
> to not responding and crashed. So, what is the solution of delete fltk =
> allocations ? how can i delete first and recreate this box. ?
>
>
> What are you trying to do? I don't understand why you are creating a new =
> box every time...
>
> If the box is created as a child of the Fl_Window, then when the window =
> is deleted, the box will be deleted. But you are not deleting the =
> window... or the box... So, why do you recreate the box on each =
> iteration?
> There must be something I am not understanding here.
>
>
> Anyway, to address your question:
>
> You have created the box using the C++ "new" operator. Therefore, you =
> should delete it by calling the C++ "delete" operator, NOT by calling =
> "free". The "free" operation is appropriate for items allocated using =
> C-style mallocs for example, but NOT for C++ "new" allocations.
>
> So, your code wants to say:
>
>    if(V3DS_box)
>    {
>       delete V3DS_box;
>       V3DS_box =3D NULL;
>    }
>
>
> Or, simply do not recreate it if it already exists:
>
>
>    if(V3DS_box)
>    {
>       // do nothing as we already have the box=20
>    }
>    else
>    {
>       V3DS_box =3D new Fl_Box(FL_DOWN_FRAME, 400, 10, w+10, h+10, "");
>    }
>
>
> Either way ought to work.
>
>
>
>

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

Reply via email to