This is also the wrong forum to be posting this in.

On Sun, Dec 6, 2009 at 10:41 AM, Danny Price <[email protected]>wrote:

> Even so, the pointer should have been initialised to 0 or NULL in the
> initializer list. Leaving pointers to contain junk is never a good idea.
>
> On 6 Dec 2009, at 17:59, Gilles Valette wrote:
>
> > Message de Danny Price <[email protected]>:
> >
> >> Always use initializer lists.
> >>
> >
> > He can't because this call is not made in a constructor but in a slot
> > corresponding to a button click, and a new thread is created at each
> > click. I am not saying that it is the best way to do it (I actually do
> > not know the goal of the code...), I was just answering to the
> > question about the segfault in the given code.
> >
> > Regards,
> >
> > Gilles
> >
> >> On 6 Dec 2009, at 13:39, Gilles Valette wrote:
> >>
> >>> Message de Soumen banerjee <[email protected]>:
> >>>
> >>>> In the files attached, mainwindow.cpp has the following line
> >>>>
> >>>> connect(ptr,SIGNAL(setlabel(int)),this,SLOT(setLabel(int)));
> >>>>
> >>>> where ptr is of type mythread* which is derived from QThread
> >>>> the application compiles without error but on running, quits with
> >>>> segfault. Omitting the connect line solves the problem but removes all
> >>>> the functionality. How do you connect these together?
> >>>> Regards
> >>>> Soumen
> >>>>
> >>>
> >>> Hi,
> >>>
> >>> In mainwindow.cpp when you call connect, ptr is undefined, causing the
> >>> segfault.
> >>>
> >>> Putting the two lines in this order solves the problem :
> >>>
> >>>    ptr=new mythread(this);
> >>>    connect(ptr,SIGNAL(setlabel(int)),this,SLOT(setLabel(int)));
> >>>
> >>> Hope this helps.
> >>>
> >>> Gilles
> >>>
> >>>
> >>> _______________________________________________
> >>> Qt-creator mailing list
> >>> [email protected]
> >>> http://lists.trolltech.com/mailman/listinfo/qt-creator
> >>
> >> _______________________________________________
> >> Qt-creator mailing list
> >> [email protected]
> >> http://lists.trolltech.com/mailman/listinfo/qt-creator
> >>
> >>
> >
> >
> >
> > --
> > Gilles VALETTE - PhD
> > Maître de conférences en informatique - IUT de Reims
> > Université de Reims Champagne-Ardenne (URCA) - CReSTIC EA3804
> > Rue des Crayères, BP 1035 51687 Reims Cedex 2 (France)
> > Tel: +33 (0)3 26 91 84 58
> > http://www.crestic.univ-reims.fr/fiche.php?id=216
> >
> >
> >
> > _______________________________________________
> > Qt-creator mailing list
> > [email protected]
> > http://lists.trolltech.com/mailman/listinfo/qt-creator
>
>
> _______________________________________________
> Qt-creator mailing list
> [email protected]
> http://lists.trolltech.com/mailman/listinfo/qt-creator
>
_______________________________________________
Qt-creator mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-creator

Reply via email to