Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. std::string destructor crashing in Release when using ::toStdString methods
Forum Updated to NodeBB v4.3 + New Features

std::string destructor crashing in Release when using ::toStdString methods

Scheduled Pinned Locked Moved Solved General and Desktop
42 Posts 9 Posters 22.6k Views 6 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hudson
    wrote on 27 May 2016, 07:36 last edited by
    #41

    I was recently working with Qt, overridden new/delete operator, and got the similar issue.

    It caused a problem that QByteArray::toStdString() made a std::string which avoided calling the overridden version of new.

    However, when the std::string was destructed in my program, it called the overridden version of delete. Bomb!

    Maybe it is a reasonable practice to avoid using std::string returned by Qt or other 3rd party library. Or you should rebuild all of them with the exactly same environment.

    K 1 Reply Last reply 27 May 2016, 08:20
    0
    • H Hudson
      27 May 2016, 07:36

      I was recently working with Qt, overridden new/delete operator, and got the similar issue.

      It caused a problem that QByteArray::toStdString() made a std::string which avoided calling the overridden version of new.

      However, when the std::string was destructed in my program, it called the overridden version of delete. Bomb!

      Maybe it is a reasonable practice to avoid using std::string returned by Qt or other 3rd party library. Or you should rebuild all of them with the exactly same environment.

      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 27 May 2016, 08:20 last edited by
      #42

      @Hudson said:

      Maybe it is a reasonable practice to avoid using std::string returned by Qt or other 3rd party library.

      Actually in your case, forgive me for being so blunt, I'd say it would be a reasonable practice to avoid writing new/delete operators for classes you don't own (i.e. such that are not written by you). And as a side note creating std::strings in the heap is a bit questionable.

      Also I don't see how Qt could have called an overloaded new so you can call delete on it. There's no new in QByteArray::toStdString,

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0

      41/42

      27 May 2016, 07:36

      • Login

      • Login or register to search.
      41 out of 42
      • First post
        41/42
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved