Results 1 to 2 of 2

Thread: Crash on QString Destructor

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Unhappy Crash on QString Destructor

    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
    Qt Code:
    1. QString strName = QString( "string blah..." )
    To copy to clipboard, switch view to plain text mode 
    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!

  2. #2
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Crash on QString Destructor

    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!

Similar Threads

  1. QString static callback function from CURL
    By tpf80 in forum Qt Programming
    Replies: 12
    Last Post: 16th May 2007, 20:47
  2. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59
  3. QList crash in destructor
    By mclark in forum Newbie
    Replies: 7
    Last Post: 6th December 2006, 15:27
  4. Converting QString to unsigned char
    By salston in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 22:10
  5. [SOLVED] Widget plugin ... how to ?
    By yellowmat in forum Newbie
    Replies: 10
    Last Post: 29th January 2006, 20:41

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.