[Qt-interest] memory problem

Sujan Dasmahapatra sdh at lmglasfiber.com
Tue Mar 24 12:03:51 CET 2009


item[count] = new QTableWidgetItem(filename,0);
Whats wrong in this ?

fileNameUpdate() is called in some other function where I am getting the QString filename and a geometry,i.e Geometry * geometry and setting that geometry to geometry[count] = geometry;

This part is correct could u check annone what I am doing in the destuctor is correct or not ???

Kind Regards,
Sujan Dasmahapatra

-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Alexandre Beraud
Sent: Tuesday, March 24, 2009 4:29 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] memory problem

Hi,

QList <QTableWidget *> item;
then:
Item[count] = new QTableWidgetItem(filename,0);
What the ... ???
And what's the point of this line: geoMetry = geometry;
What kind of value do you pass to the fileNameUpdate() function ?
Anyhow, most parts of your code are either weird, or incorrect.

Regards,

Alex


Sujan Dasmahapatra a écrit :
>
> Dear Friends I am getting segmentation fault for some memory 
> allocation.Could u tell me anyone whats wrong in this code below.
>
> ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
>
> // In the header file:
>
> QList <QTableWidget *> item;
>
> QList <Geometry *> geoMetry;
>
> int count;
>
> ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
>
> TableWidget::TableWidget()
>
> {
>
> count = 0;
>
> }
>
> TableWidget::~TableWidget()
>
> {
>
> If(count != 0)
>
> {
>
> delete item[count];
>
> delete geoMetry[count];
>
> }
>
> }
>
> TableWidget::fileNameUpdate(QString filename, Geometry *geometry)
>
> {
>
> Item[count] = new QTableWidgetItem(filename,0);
>
> setItem(count,0,item[count]);
>
> geoMetry[count] = new Geometry;
>
> geoMetry = geometry;
>
> count ++;
>
> }
>
> ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
>
> Remember geometry and geometry are different here. geometry is a QList 
> pointer and geometry is Geometry. Can u check the code and let me know 
> if there's any reason for segmentation fault.The way I am deleting is 
> correct or not.?????
>
> Kind regards,
> LM Glasfiber R&D (India) Pvt. Ltd.
>
> Sujan Dasmahapatra
> Project Engineer - CFD
>
> Telephone: +91 80 66470248
> Mobile:
> E-mail: sdh at lmglasfiber.com <mailto:sdh at lmglasfiber.com>
>
> --------------------------------------------------------------
>
> This e-mail and any attachments are confidential. If you are not the 
> named or intended recipient, please notify the sender immediately and 
> do not disclose the contents to any other person, use it for any 
> purpose or store or copy the information in any medium. Any 
> unauthorized disclosure, use or storage is prohibited and might be 
> unlawful.
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>   


-- 
BERAUD Alexandre
Ingénieur Développement

Infflux - Informatique & Flux
Tel: 01 49 57 92 00 - Fax : 01 49 57 92 01
Mail: aberaud at infflux.com
Visitez notre site :  www.infflux.com


_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list