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. QVector<QVector<Node*> > strange behaviour
Forum Updated to NodeBB v4.3 + New Features

QVector<QVector<Node*> > strange behaviour

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.8k 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.
  • V Offline
    V Offline
    Veaceslav
    wrote on last edited by
    #1

    Hello, i've searched the forum, but i didn't find anything relevant to my problem:

    I have a class named Node that contains QVector<QVector<Node*> > link;

    and with this constructor:

    @ Node(int conMax)
    {
    link = QVector<QVector<Node*> >(conMax);

    }@
    

    and i use:

    @
    Node* nod = new Node(4);

    nod->link[2].append(anotherNode);
    @

    well it sometimes work but sometimes, when i made a bigger test,
    it crashes and gdb reports segfault in QVector<Node*>::append(Node&*)

    only after changing constructor to:
    @ Node(int conMax)
    {
    link = QVector<QVector<Node*> >(conMax +4);

    }@
    

    crash dissapeared. I'm afraid that for even bigger input, crash can appear again.

    I do something wrong?

    I need the first QVector to have a certain size, so i can could insert everywhere in that range.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      conMax does only define the size of "outer" vector. How do you define the size of the "inner" vector?

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Veaceslav
        wrote on last edited by
        #3

        Well i need to define a size only for outer vector, because i use [] operator.

        For inner vector i don't have a defined size, and i use append.

        Or something like
        @
        QVector vector;

        vector.append(element);
        @

        works without a size specified...

        For inner vector i let him expand on it's own...

        1 Reply Last reply
        0
        • W Offline
          W Offline
          Wilk
          wrote on last edited by
          #4

          Hello.
          I've tried to reproduce your problem, but everything went right.
          My suggetions are:

          Analize you code and think of what may go wrong. This might save your time.

          Make sure you don't use index that's out of range.

          Look at call stack at the moment when you get SIGSEGV.

          Look at data structures under debugger since the moment right before creation of your Node object. Look for everything that doesn'n change after object construction or anything that has a strange value.

          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