PDA

View Full Version : Crash on QString Destructor



ToddAtWSU
14th June 2007, 13:47
I have a program that I open a dialog to show a listing of files and the user chooses some files to open. I read in some data from the files and populate a QTable with a bunch of QVariant data and after filling the table, I return out of the function. Whenever I try to return, my program Segmentation Faults and when I run the program in DBX, the stack says it dies on the return call, and then in QString::~QString(this = 0xffbedf18) at line 846 and then in QShared::deref( this = 0x303000a8) at line 50. I only create 4 QStrings in the entire function, 2 when I create a QProgressDialog as the first 2 arguments, and 2 towards the end of my document when I say

QString strName = QString( "string blah..." )
I have printed out the string these hold and the addresses of the QStrings and they are all valid, so I don't think I have invalid addresses anywhere. Does anyone have any idea why I would be crashing? Thanks!

ToddAtWSU
14th June 2007, 14:28
Well, it has nothing to do with Qt...just a mistake made by me. I was using a char[] to initialize a QVariant inside my QTable and I made the array long enough for my string (I used sprintf and %07.3) but forgot to add a character to the array for the NULL terminator. Once I increased the size of my array by 1, everything worked like a charm. Sorry to waste the space on this, I just could not solve it and with the debugger dying in the QString destructor I thought it was Qt related. I should have known it couldn't be Qt!