Results 1 to 2 of 2

Thread: QString .toStdString heap bug

  1. #1
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QString .toStdString heap bug

    I don't know if it is just me... but I am using 4.1.4 and my program keeps crashing.

    The problem is this. I call a function. In that function I have a text widget that I do a .toStdString() on like so:
    Qt Code:
    1. string sTemp = ui.leServerDir->text().toStdString();
    To copy to clipboard, switch view to plain text mode 

    I am compiling this with VS2003 by the way. The problem is that when the function returns it crashes. It has a problem deallocating the heap for some reason. It does this if sTemp is over 16 characters minus the null term character (so 17). The program doesn't crash when you do this, however:
    Qt Code:
    1. string sTemp = "00000000000000000000";
    To copy to clipboard, switch view to plain text mode 

    I also tried this... and it crashes:
    Qt Code:
    1. QString sTemp = ui.leServerDir->text().toStdString().c_str();
    To copy to clipboard, switch view to plain text mode 

    For some reason QString wouldn't work with "std::string" so I had to convert it to a c string. Doesn't matter, it still crashes when the function cleans up.

    An I doing something wrong? Hopefully this wont be an issue with the new version.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QString .toStdString heap bug

    Can you create a minimal, compilable example, so we can check if it crashes on our systems too?

Similar Threads

  1. QSqlQueryModel + set Write
    By raphaelf in forum Qt Programming
    Replies: 7
    Last Post: 5th June 2006, 09:55
  2. Converting QString to unsigned char
    By salston in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 23:10
  3. Change colour of QString
    By Morea in forum Newbie
    Replies: 9
    Last Post: 10th February 2006, 23:31
  4. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 15:52
  5. [SOLVED] Widget plugin ... how to ?
    By yellowmat in forum Newbie
    Replies: 10
    Last Post: 29th January 2006, 21: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.