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. EXPRESSION: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) - Error after program close?

EXPRESSION: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) - Error after program close?

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

    I get the "EXPRESSION: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)" error after program close., as a pop-up.

    It is caused somewhere in this function below, because it started when I created it, and arises when I call it.
    I call it using:

    @ treeWidget(&fullPack, &sh3dcFullPack);

    @
    I initialize the QTreeWidgetItems in my header file like this:
    @

    QTreeWidgetItem sh3dcFullPack;
    QTreeWidgetItem fullPack;
    

    @

    Function:

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You create sh3dcFullPack and fullPack on the stack. Then you add them to the tree widget. When tree widget is destroyed it destroys all of its items so basically calls delete on these items. This is of course invalid in case of these two.

      Create them on the heap instead (via new) and let tree widget handle it.
      Apart from that you shouldn't create instances in a header anyway. You won't be able to include it in two places because this would be multiple definition error. Declare just pointers in the header and initialize in cpp. Better yet - put these in a proper class.

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

        [quote author="Chris Kawa" date="1389520592"]You create sh3dcFullPack and fullPack on the stack. Then you add them to the tree widget. When tree widget is destroyed it destroys all of its items so basically calls delete on these items. This is of course invalid in case of these two.

        Create them on the heap instead (via new) and let tree widget handle it.
        Apart from that you shouldn't create instances in a header anyway. You won't be able to include it in two places because this would be multiple definition error. Declare just pointers in the header and initialize in cpp. Better yet - put these in a proper class.[/quote]

        That fixed it, thank you. I put pointer declarations in the header and initialized them in the class constructor using "new".

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Great. I'm glad I could help.
          Please add [solved] to the title to let others know there's an answer here.

          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