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 23.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.
  • HudsonH Offline
    HudsonH Offline
    Hudson
    wrote on 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.

    kshegunovK 1 Reply Last reply
    0
    • HudsonH Hudson

      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.

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on 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

      • Login

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