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. Assertion error while opening the same JSON file twice using QFIle
Forum Updated to NodeBB v4.3 + New Features

Assertion error while opening the same JSON file twice using QFIle

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 550 Views 2 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.
  • D Offline
    D Offline
    dhanush_11
    wrote on last edited by
    #1

    I have 3 signals and slots, which works with dynamic combo box by reading data from JSON file. I face the following error while executing the code,

    ASSERT: "a && i >= 0 && i < (int)a->length" in file serialization\qjsonarray.cpp, line 613

    JonBJ 1 Reply Last reply
    0
    • D dhanush_11

      I have 3 signals and slots, which works with dynamic combo box by reading data from JSON file. I face the following error while executing the code,

      ASSERT: "a && i >= 0 && i < (int)a->length" in file serialization\qjsonarray.cpp, line 613

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @dhanush_11
      Hello and welcome.

      This should not have anything to do with "opening the same JSON file twice using QFIle". For whatever reason, something you have has made an array index go out of bounds. Run your code under the debugger and look at the stack trace when it ASSERTs: follow that back to identify a line in your code whence it emanates.

      For all I know: if the JSON you are reading is malformed (e.g. you write to file after reading it once) I suppose it might be possible to get an ASSERT. Or maybe you're just trying to access a QJsonArray with a bad index. Whatever, nobody will able to answer without more detail.

      D 1 Reply Last reply
      2
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        How are you reading that file ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • Kent-DorfmanK Offline
          Kent-DorfmanK Offline
          Kent-Dorfman
          wrote on last edited by Kent-Dorfman
          #4

          I don't see any adequate grouping of operations in that assert statement so is OP even sure of the conditions under which it occurs? PARENTHESIZE YOUR EXPRESSIONS and DONT USE C-STYLE CASTS in C++

          1 Reply Last reply
          0
          • JonBJ JonB

            @dhanush_11
            Hello and welcome.

            This should not have anything to do with "opening the same JSON file twice using QFIle". For whatever reason, something you have has made an array index go out of bounds. Run your code under the debugger and look at the stack trace when it ASSERTs: follow that back to identify a line in your code whence it emanates.

            For all I know: if the JSON you are reading is malformed (e.g. you write to file after reading it once) I suppose it might be possible to get an ASSERT. Or maybe you're just trying to access a QJsonArray with a bad index. Whatever, nobody will able to answer without more detail.

            D Offline
            D Offline
            dhanush_11
            wrote on last edited by
            #5

            @JonB Thanks !! That was the issue. Index of JsonArray was the problem. I solved it earlier.

            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