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. index out of range
Forum Updated to NodeBB v4.3 + New Features

index out of range

Scheduled Pinned Locked Moved Solved General and Desktop
20 Posts 6 Posters 3.2k Views 3 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi
    If you put break point in main.cpp at first line in main, it
    never comes there but crashes before ?

    ODБOïO 1 Reply Last reply
    1
    • Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #3

      By calling items.append(....) your QList can not go out of index range.

      Where else do you use the QList<PosItem> items?

      ODБOïO 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi
        If you put break point in main.cpp at first line in main, it
        never comes there but crashes before ?

        ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by
        #4

        @mrjj said in index out of range:

        at first line in main

        i just putted one in main.cpp but yes, it still craches.

        My main window pops but another window pops directly saying :

        Microsoft Visual C++ Runtime Library
        Debug error !
        Program : c:\Qt\5.13.0\msvc2017_64\bin\QtCored.dll
        Module : 5.13.0
        File C:\5.13.0\msvc2017_64\include\QtCore/qlist.h
        Line ! 560

        ASSERT failure in QList<T>::at: "index out of range" , file
        c:\QT\5.13.0\msvc2017_64\includeQtCore/qlist.h, line 560

        1 Reply Last reply
        0
        • Pl45m4P Pl45m4

          By calling items.append(....) your QList can not go out of index range.

          Where else do you use the QList<PosItem> items?

          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by
          #5

          @Pl45m4 said in index out of range:

          Where else

          nowhere, it is altered only with append()

          mrjjM 1 Reply Last reply
          0
          • ODБOïO ODБOï

            @Pl45m4 said in index out of range:

            Where else

            nowhere, it is altered only with append()

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @LeLev
            "My main window pops"
            meaning it will enter the main, and then crash after your mainwin is created ?

            ODБOïO 1 Reply Last reply
            1
            • mrjjM mrjj

              @LeLev
              "My main window pops"
              meaning it will enter the main, and then crash after your mainwin is created ?

              ODБOïO Offline
              ODБOïO Offline
              ODБOï
              wrote on last edited by ODБOï
              #7

              @mrjj said in index out of range:

              rash after your mainwin is created ?

              it is almost at the same time, when i hit Run button , i can see my mainwindow + the error window appearing at the same time

              https://postimg.cc/w1251HXT

              mrjjM 1 Reply Last reply
              0
              • ODБOïO ODБOï

                @mrjj said in index out of range:

                rash after your mainwin is created ?

                it is almost at the same time, when i hit Run button , i can see my mainwindow + the error window appearing at the same time

                https://postimg.cc/w1251HXT

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @LeLev
                well im asking if you hit f5 debug and have break point at the main.cpp first line.
                (in main function)
                if it goes there as else its a global var that does it.

                You can also try on the
                QList<PosItem> items;
                right click on items and ask where it being used and see if any does

                or
                items.at(x)

                ODБOïO 2 Replies Last reply
                1
                • mrjjM mrjj

                  @LeLev
                  well im asking if you hit f5 debug and have break point at the main.cpp first line.
                  (in main function)
                  if it goes there as else its a global var that does it.

                  You can also try on the
                  QList<PosItem> items;
                  right click on items and ask where it being used and see if any does

                  or
                  items.at(x)

                  ODБOïO Offline
                  ODБOïO Offline
                  ODБOï
                  wrote on last edited by ODБOï
                  #9

                  @mrjj said in index out of range:

                  well im asking if you hit f5 debug and have break point at the main.cpp first line.

                  Yes i'm running in DEBUG (F5) and i have break point in first line of my main()

                  @mrjj said in index out of range:

                  right click on items and ask where it being used and see if any does

                  or
                  items.at(x)

                  items is used exclusively in void preProcessFile(QString filepath) function

                  mrjjM 1 Reply Last reply
                  0
                  • ODБOïO ODБOï

                    @mrjj said in index out of range:

                    well im asking if you hit f5 debug and have break point at the main.cpp first line.

                    Yes i'm running in DEBUG (F5) and i have break point in first line of my main()

                    @mrjj said in index out of range:

                    right click on items and ask where it being used and see if any does

                    or
                    items.at(x)

                    items is used exclusively in void preProcessFile(QString filepath) function

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by mrjj
                    #10

                    @LeLev said in index out of range:

                    preProcessFile

                    Then cant you set break point where you call
                    preProcessFile(xx) and single step with f10 F11 into it to see what line that makes it crash ?

                    ODБOïO 1 Reply Last reply
                    1
                    • mrjjM mrjj

                      @LeLev said in index out of range:

                      preProcessFile

                      Then cant you set break point where you call
                      preProcessFile(xx) and single step with f10 F11 into it to see what line that makes it crash ?

                      ODБOïO Offline
                      ODБOïO Offline
                      ODБOï
                      wrote on last edited by
                      #11

                      @mrjj said in index out of range:

                      cant you

                      i want to, but my app crashes as soon i hit f5 or start in debug mod btn

                      https://postimg.cc/w1251HXT

                      ODБOïO 1 Reply Last reply
                      0
                      • ODБOïO ODБOï

                        @mrjj said in index out of range:

                        cant you

                        i want to, but my app crashes as soon i hit f5 or start in debug mod btn

                        https://postimg.cc/w1251HXT

                        ODБOïO Offline
                        ODБOïO Offline
                        ODБOï
                        wrote on last edited by
                        #12

                        for some reason if i change my compiler from msvc to minGW i can now run in DEBUG mod !

                        mrjjM JonBJ 2 Replies Last reply
                        0
                        • ODБOïO ODБOï

                          for some reason if i change my compiler from msvc to minGW i can now run in DEBUG mod !

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #13

                          @LeLev
                          Ok, could be something wrong with the visual studio install and the crash is not related to
                          your code as such.

                          1 Reply Last reply
                          1
                          • ODБOïO ODБOï

                            for some reason if i change my compiler from msvc to minGW i can now run in DEBUG mod !

                            JonBJ Online
                            JonBJ Online
                            JonB
                            wrote on last edited by JonB
                            #14

                            @LeLev

                            for some reason if i change my compiler from msvc to minGW i can now run in DEBUG mod !

                            For whatever your Qt project is, are you saying you can & do freely switch compilers between MSVC & minGW? So you have Qt, and whatever other libraries you use, available for both and it doesn't matter to you which compiler you use? You shouldn't be switching compilers just to magically get your debugging to work right now.

                            Surely, you need to decide on one compiler or the other (and being able to debug always reliably is vital) and then do all your development with that?

                            ODБOïO 1 Reply Last reply
                            0
                            • JonBJ JonB

                              @LeLev

                              for some reason if i change my compiler from msvc to minGW i can now run in DEBUG mod !

                              For whatever your Qt project is, are you saying you can & do freely switch compilers between MSVC & minGW? So you have Qt, and whatever other libraries you use, available for both and it doesn't matter to you which compiler you use? You shouldn't be switching compilers just to magically get your debugging to work right now.

                              Surely, you need to decide on one compiler or the other (and being able to debug always reliably is vital) and then do all your development with that?

                              ODБOïO Offline
                              ODБOïO Offline
                              ODБOï
                              wrote on last edited by ODБOï
                              #15

                              @JonB said in index out of range:

                              For whatever your Qt project is, are you saying you can & do freely switch compilers between MSVC & minGW?

                              @JonB said in index out of range:

                              So you have Qt, and whatever other libraries you use, available for both and it doesn't matter to you which compiler you use?

                              yes I am my own boss and I do what I want, i can recompile my libs with needed compiler

                              @JonB said in index out of range:

                              You shouldn't be switching compilers just to magically get your debugging to work right now.

                              why not ? you have 2 'equivalent tools' one is broken, what you do ?

                              @JonB said in index out of range:

                              Surely, you need to decide on one compiler or the other (and being able to debug always reliably is vital) and then do all your development with that?

                              yes ?

                              JonBJ kshegunovK J.HilkJ 3 Replies Last reply
                              0
                              • ODБOïO ODБOï

                                @JonB said in index out of range:

                                For whatever your Qt project is, are you saying you can & do freely switch compilers between MSVC & minGW?

                                @JonB said in index out of range:

                                So you have Qt, and whatever other libraries you use, available for both and it doesn't matter to you which compiler you use?

                                yes I am my own boss and I do what I want, i can recompile my libs with needed compiler

                                @JonB said in index out of range:

                                You shouldn't be switching compilers just to magically get your debugging to work right now.

                                why not ? you have 2 'equivalent tools' one is broken, what you do ?

                                @JonB said in index out of range:

                                Surely, you need to decide on one compiler or the other (and being able to debug always reliably is vital) and then do all your development with that?

                                yes ?

                                JonBJ Online
                                JonBJ Online
                                JonB
                                wrote on last edited by
                                #16

                                @LeLev

                                why not ? you have 2 'equivalent tools' one is broken, what you do ?

                                Permanently change over to the one which is not broken, chuck the other one away, and don't look back.

                                Your call, of course.

                                1 Reply Last reply
                                1
                                • ODБOïO ODБOï

                                  @JonB said in index out of range:

                                  For whatever your Qt project is, are you saying you can & do freely switch compilers between MSVC & minGW?

                                  @JonB said in index out of range:

                                  So you have Qt, and whatever other libraries you use, available for both and it doesn't matter to you which compiler you use?

                                  yes I am my own boss and I do what I want, i can recompile my libs with needed compiler

                                  @JonB said in index out of range:

                                  You shouldn't be switching compilers just to magically get your debugging to work right now.

                                  why not ? you have 2 'equivalent tools' one is broken, what you do ?

                                  @JonB said in index out of range:

                                  Surely, you need to decide on one compiler or the other (and being able to debug always reliably is vital) and then do all your development with that?

                                  yes ?

                                  kshegunovK Offline
                                  kshegunovK Offline
                                  kshegunov
                                  Moderators
                                  wrote on last edited by
                                  #17

                                  @LeLev said in index out of range:

                                  why not ? you have 2 'equivalent tools' one is broken, what you do ?

                                  I've personally found 2 bugs in MSVC and about that many in gcc (one of which I even reported), however I'm pretty sure neither is "broken". Please provide a stack trace from the crash (and yes the error is in the user code, everything QList is inlined).

                                  Read and abide by the Qt Code of Conduct

                                  1 Reply Last reply
                                  1
                                  • ODБOïO ODБOï

                                    @JonB said in index out of range:

                                    For whatever your Qt project is, are you saying you can & do freely switch compilers between MSVC & minGW?

                                    @JonB said in index out of range:

                                    So you have Qt, and whatever other libraries you use, available for both and it doesn't matter to you which compiler you use?

                                    yes I am my own boss and I do what I want, i can recompile my libs with needed compiler

                                    @JonB said in index out of range:

                                    You shouldn't be switching compilers just to magically get your debugging to work right now.

                                    why not ? you have 2 'equivalent tools' one is broken, what you do ?

                                    @JonB said in index out of range:

                                    Surely, you need to decide on one compiler or the other (and being able to debug always reliably is vital) and then do all your development with that?

                                    yes ?

                                    J.HilkJ Offline
                                    J.HilkJ Offline
                                    J.Hilk
                                    Moderators
                                    wrote on last edited by
                                    #18

                                    @LeLev have you tried start and break on main option ?

                                    0_1563515176092_b37715d1-3e8f-43eb-90e4-96de46beb3c2-image.png

                                    F10 on Windows


                                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                                    Q: What's that?
                                    A: It's blue light.
                                    Q: What does it do?
                                    A: It turns blue.

                                    1 Reply Last reply
                                    2
                                    • mrjjM mrjj

                                      @LeLev
                                      well im asking if you hit f5 debug and have break point at the main.cpp first line.
                                      (in main function)
                                      if it goes there as else its a global var that does it.

                                      You can also try on the
                                      QList<PosItem> items;
                                      right click on items and ask where it being used and see if any does

                                      or
                                      items.at(x)

                                      ODБOïO Offline
                                      ODБOïO Offline
                                      ODБOï
                                      wrote on last edited by ODБOï
                                      #19

                                      hi
                                      @mrjj said in index out of range:

                                      or
                                      items.at(x)

                                      sorry i said i never do this calls,but in the lib itself there is that call. Just after closing the file writePath() is called:

                                      void RenderItemList::writePath(QPainter& painter, bool updatedFromFile)
                                      {
                                          QPainterPath path;
                                          ItemToBase *item = list.at(0); // << crash here
                                          item->setParams(scale, windowSize.height(), offsetx, offsety);
                                      

                                      erros

                                      #  else
                                          RaiseFailFastException(nullptr, nullptr, 0);
                                      #  endif
                                       qt_message_fatal(QtFatalMsg, context, message);
                                      { Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::at", "index out of range");
                                      

                                      i saw ind debug mod that list was empty .. i initialised it after reading the file, now everything works correctly.

                                      thank you for help

                                      Pl45m4P 1 Reply Last reply
                                      1
                                      • ODБOïO ODБOï

                                        hi
                                        @mrjj said in index out of range:

                                        or
                                        items.at(x)

                                        sorry i said i never do this calls,but in the lib itself there is that call. Just after closing the file writePath() is called:

                                        void RenderItemList::writePath(QPainter& painter, bool updatedFromFile)
                                        {
                                            QPainterPath path;
                                            ItemToBase *item = list.at(0); // << crash here
                                            item->setParams(scale, windowSize.height(), offsetx, offsety);
                                        

                                        erros

                                        #  else
                                            RaiseFailFastException(nullptr, nullptr, 0);
                                        #  endif
                                         qt_message_fatal(QtFatalMsg, context, message);
                                        { Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::at", "index out of range");
                                        

                                        i saw ind debug mod that list was empty .. i initialised it after reading the file, now everything works correctly.

                                        thank you for help

                                        Pl45m4P Offline
                                        Pl45m4P Offline
                                        Pl45m4
                                        wrote on last edited by Pl45m4
                                        #20
                                        This post is deleted!
                                        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