×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Mar 2009
    Location
    Foster City, CA
    Posts
    24

    exception occurs when converting QString to std::string

    Hi,

    I have setup Qt SDK on Windows XP and tried to build my app,
    and then got an exception error when converting QString to
    std::string using QString::toStdString().
    This happens on Simulator Qt for Visual Studio 2008 env.
    I have other project, e.g. 4.6.2 Desktop, and it works fine.

    So I just created a sample hello world app using QtCreator,
    and add the following code MainWindow constructor.

    Code:
    QString qstr = "1234567890123456";
    std::string sstr = qstr.toStdString();
    In this case, when exiting from the constructor function,
    I get an exception error as follow.

    HEAP[testsdk01.exe]: Invalid Address specified to RtlValidateHeap( 00BF0000, 0124B7D8 )

    The issue happens if the QString length is more than 16.

    Is this a bug?

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: exception occurs when converting QString to std::string

    Do you have STL compatibility enabled?

  3. #3
    Registered User
    Join Date
    Mar 2009
    Location
    Foster City, CA
    Posts
    24

    Re: exception occurs when converting QString to std::string

    I guess it is a configure option to build Qt package,
    if so, I don't know whether the Qt for Simulator is enable STL compatibility or not.

    In addition, the toStdString() works if the original string length is less than 16.
    So I think STL compatibility enabled...

  4. #4
    Nokia Developer Expert
    Join Date
    Jul 2009
    Posts
    1

    Re: exception occurs when converting QString to std::string

    This would be a bug and should be filed at bugreports.qt.nokia.com.

    Note, however, that you'd usually use QByteArray ba = qstr.toLatin1() or qstr.toUtf8() followed by std::string sstr = ba.data() or similar as this allows you to communicated the intended encoding directly.

  5. #5
    Registered User
    Join Date
    Mar 2009
    Location
    Foster City, CA
    Posts
    24

    Re: exception occurs when converting QString to std::string

    apoenitz2, thanks for the info.
    I confirmed your workaround worked. I don't get an exception anymore.
    Anyway I will file it as bug.

Similar Threads

  1. Strange exception that only occurs the first time i call a WS operation
    By Infernal01 in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2012-12-18, 10:31
  2. Data abortion occurs during converting image,why?
    By leejx in forum Symbian Media (Closed)
    Replies: 6
    Last Post: 2009-11-27, 07:36
  3. s60 3rd ed emulator crash
    By Kimau in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2008-06-18, 22:12
  4. VS.Net 2003 Carbide 2.01 and epoc32.exe
    By ValentinK in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 2
    Last Post: 2007-01-12, 12:31
  5. can not successfully link any sample using .NET
    By lobotomat in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2002-08-20, 00:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •