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. [SOLVED]Is This a Qt BUG?

[SOLVED]Is This a Qt BUG?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 953 Views
  • 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.
  • P Offline
    P Offline
    puksec
    wrote on last edited by
    #1

    Hi all,

    I am facing something that looks like a qt bug but I need confirmation from someone more qualified. Here it is:

    Inside on_tableView_doubleClicked() slot I am closing (delete this;) the tableView parent form (QDialog started with exec()). At this point my application crashes.

    When I call on_tableView_doubleClicked() from any other place in my code all is o.k., but if the actual double click happen it crashes.

    Interesting thing is that if I postpone closing with QTimer::singleShot(1 ms) all is O.k. This is why I am suspecting that this is Qt bug.

    If this looks like Qt bug to you, please encourage my to report it :).

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi,

      It's not a Qt bug.

      @
      // Replace this...
      delete this;

      // ...with this:
      this->deleteLater();
      @

      delete this can cause crashes because you delete the object when it is still trying to process events. deleteLater() will wait for all the events to finish processing -- then it's safe to delete the object.

      Always use deleteLater() to delete QObjects, unless you are trying to do low-level memory management. (Most people don't need to do this)

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • P Offline
        P Offline
        puksec
        wrote on last edited by
        #3

        deleteLater() did the trick. Thant you.

        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