[Qt-interest] error

Arnold Krille arnold at arnoldarts.de
Fri Mar 20 17:06:44 CET 2009


Hi,

On Friday 20 March 2009 08:47:46 Sujan Dasmahapatra wrote:
> I am writing like this for this error
> Error:
> *** glibc detected *** double free or corruption (out):
> 0x0000000000768340 ***
> ////////////////////////////////////////////////////////////////////////
> ////////
> //In the header file(tablewidget.h)
> QList <QTableWidgetIem *> item;
> QList <Geometry *> geometry;
> QList <QString> filenames;
> int count;
>
> ////////////////////////////////////////////////////////////////////////
> //////////
> //In the source file (tablewidget.cpp)
> Void TableWidget::~TableWidget()
> {
> 	if(count>0)
> 	{
> 		for(int i=0; i<count; i++)
> 		{
> 			delete item[count];
> 			delete geometry[count];
> 		}
>
> 		count = 0;
> 	}

Her you are deleting the last item in the lists multiple times. Exactly 
"count" times.

> }
>
>
> Void TableWidget::fileNameUpdate(QString filename, Geometry *geometry)
> {
> 	item[count] = new QTbaleWidgetItem(filename,0);
> 	filenames.append(filename);
> 	setItem(count,0,item[count]);
> 	geometry[count] = new Geometry;
> 	geometry[count] = geometry;

As others have already stated: Either geometry is an array of Geometry or an 
array of Geometry* (Hint: there is a difference between these). And assigning 
the array to one of its values, well, its a wonder this compiles. Are you sure 
your compile finishes successfully and you run a new version every time?

> 	count ++;
> }
> ////////////////////////////////////////////////////////////////////////
> ///////////////////
>
> Can anyone plss tell whats the reason I am getting this error.

As I mentioned once or twice: PLEASE GO READ A BEGINNERS BOOK OF C++ AND 
OBJECT ORIENTED PROGRAMMING.

Have fun,

Arnold

PS: No need to CC me, I am subscribed.
PPS: This is probably the last time I answered to one of your mails, sorry.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090320/50ed8016/attachment.bin 


More information about the Qt-interest-old mailing list