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. function crashes
Forum Updated to NodeBB v4.3 + New Features

function crashes

Scheduled Pinned Locked Moved Unsolved General and Desktop
32 Posts 4 Posters 5.6k 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.
  • S Offline
    S Offline
    saber
    wrote on 8 May 2018, 09:15 last edited by
    #1

    here is the function to update cpu information .
    when i open this app 2 at the same time it crashes.

    void ResourcesPage::updateCpuChart()
    {
        static int second = 0;
    
        QList<int> cpuPercents = im->getCpuPercents();
    
        QVector<QLineSeries *> seriesList = cpuChart->getSeriesList();
    
        for (int j = 0; j < seriesList.count(); j++){
            int p = cpuPercents.at(j+1);
    
            for (int i = 0; i < (second < 61 ? second : 61); i++)
                seriesList.at(j)->replace(i, (i+1), seriesList.at(j)->at(i).y());
    
            seriesList.at(j)->insert(0, QPointF(0, p));
    
            seriesList.at(j)->setName(QString("CPU%1 %2%").arg(j+1).arg(p));
    
            if(second > 61) seriesList.at(j)->removePoints(61, 1);
        }
    
        second++;
    
        cpuChart->setSeriesList(seriesList);
    }
    

    HERE IS DEBUG OUTPUT OF THIS ERROR.

    0_1525770909776_Screenshot_2018-05-07_20-06-38.png

    T 1 Reply Last reply 8 May 2018, 09:51
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 8 May 2018, 09:20 last edited by
      #2

      Hi
      For second app, maybe is is empty ?
      Something like
      seriesList.at(j)->replace(i, (i+1), seriesList.at(j)->at(i).y());

      might crash if seriesList is empty or i is out of bounds.
      I would add more checks and see what is going on.

      T 1 Reply Last reply 8 May 2018, 09:37
      3
      • M mrjj
        8 May 2018, 09:20

        Hi
        For second app, maybe is is empty ?
        Something like
        seriesList.at(j)->replace(i, (i+1), seriesList.at(j)->at(i).y());

        might crash if seriesList is empty or i is out of bounds.
        I would add more checks and see what is going on.

        T Offline
        T Offline
        Taz742
        wrote on 8 May 2018, 09:37 last edited by
        #3

        @mrjj
        seriesList have 4 items.

        Do what you want.

        1 Reply Last reply
        1
        • S saber
          8 May 2018, 09:15

          here is the function to update cpu information .
          when i open this app 2 at the same time it crashes.

          void ResourcesPage::updateCpuChart()
          {
              static int second = 0;
          
              QList<int> cpuPercents = im->getCpuPercents();
          
              QVector<QLineSeries *> seriesList = cpuChart->getSeriesList();
          
              for (int j = 0; j < seriesList.count(); j++){
                  int p = cpuPercents.at(j+1);
          
                  for (int i = 0; i < (second < 61 ? second : 61); i++)
                      seriesList.at(j)->replace(i, (i+1), seriesList.at(j)->at(i).y());
          
                  seriesList.at(j)->insert(0, QPointF(0, p));
          
                  seriesList.at(j)->setName(QString("CPU%1 %2%").arg(j+1).arg(p));
          
                  if(second > 61) seriesList.at(j)->removePoints(61, 1);
              }
          
              second++;
          
              cpuChart->setSeriesList(seriesList);
          }
          

          HERE IS DEBUG OUTPUT OF THIS ERROR.

          0_1525770909776_Screenshot_2018-05-07_20-06-38.png

          T Offline
          T Offline
          Taz742
          wrote on 8 May 2018, 09:51 last edited by Taz742 5 Aug 2018, 09:53
          #4

          @saber said in function crashes:

              for (int i = 0; i < (second < 61 ? second : 61); i++)
                  seriesList.at(j)->replace(i, (i+1), seriesList.at(j)->at(i).y());
          

          maybe

              for (int i = 0; i < std::min(std::min(second, seriesList.at(j)->points().size() - 1), 61); i++)
                  seriesList.at(j)->replace(i, (i+1), seriesList.at(j)->at(i).y());
          

          ?

          Do what you want.

          S 1 Reply Last reply 9 May 2018, 10:18
          2
          • T Taz742
            8 May 2018, 09:51

            @saber said in function crashes:

                for (int i = 0; i < (second < 61 ? second : 61); i++)
                    seriesList.at(j)->replace(i, (i+1), seriesList.at(j)->at(i).y());
            

            maybe

                for (int i = 0; i < std::min(std::min(second, seriesList.at(j)->points().size() - 1), 61); i++)
                    seriesList.at(j)->replace(i, (i+1), seriesList.at(j)->at(i).y());
            

            ?

            S Offline
            S Offline
            saber
            wrote on 9 May 2018, 10:18 last edited by
            #5

            @Taz742
            not working .
            two same window crash the app.

            M T 2 Replies Last reply 9 May 2018, 10:21
            0
            • S saber
              9 May 2018, 10:18

              @Taz742
              not working .
              two same window crash the app.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 9 May 2018, 10:21 last edited by
              #6

              @saber
              Hi
              Why not debug it then?
              Should be easy to spot what is going on in debugger since you seem to hard crash.

              1 Reply Last reply
              4
              • S saber
                9 May 2018, 10:18

                @Taz742
                not working .
                two same window crash the app.

                T Offline
                T Offline
                Taz742
                wrote on 9 May 2018, 10:44 last edited by
                #7

                @saber
                When window crashed what is 'i'-s value?

                Do what you want.

                S 1 Reply Last reply 11 May 2018, 08:54
                1
                • T Taz742
                  9 May 2018, 10:44

                  @saber
                  When window crashed what is 'i'-s value?

                  S Offline
                  S Offline
                  saber
                  wrote on 11 May 2018, 08:54 last edited by
                  #8

                  @Taz742
                  0_1526028838554_qt.png

                  M 1 Reply Last reply 11 May 2018, 09:08
                  0
                  • S saber
                    11 May 2018, 08:54

                    @Taz742
                    0_1526028838554_qt.png

                    M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 11 May 2018, 09:08 last edited by
                    #9

                    @saber
                    I put my money you crash in the
                    seriesList.at(j)->at(i).y() part.

                    S 1 Reply Last reply 11 May 2018, 10:12
                    1
                    • M mrjj
                      11 May 2018, 09:08

                      @saber
                      I put my money you crash in the
                      seriesList.at(j)->at(i).y() part.

                      S Offline
                      S Offline
                      saber
                      wrote on 11 May 2018, 10:12 last edited by
                      #10

                      @mrjj
                      sorry.
                      not a clue ,how to fix or what's the error.

                      M 1 Reply Last reply 11 May 2018, 10:22
                      0
                      • S saber
                        11 May 2018, 10:12

                        @mrjj
                        sorry.
                        not a clue ,how to fix or what's the error.

                        M Offline
                        M Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on 11 May 2018, 10:22 last edited by
                        #11

                        @saber
                        Hi
                        I would insert qDebug() for size() of all lists involved and
                        also dump the values of i and j.
                        Its hard to guess at since normally one inspects the runtime variables in the debugger to see if all
                        are within bounds.

                        what does seriesList.at(j) return ? a QString or list ?

                        S 1 Reply Last reply 11 May 2018, 10:28
                        0
                        • M mrjj
                          11 May 2018, 10:22

                          @saber
                          Hi
                          I would insert qDebug() for size() of all lists involved and
                          also dump the values of i and j.
                          Its hard to guess at since normally one inspects the runtime variables in the debugger to see if all
                          are within bounds.

                          what does seriesList.at(j) return ? a QString or list ?

                          S Offline
                          S Offline
                          saber
                          wrote on 11 May 2018, 10:28 last edited by
                          #12

                          @mrjj
                          this
                          0_1526034483163_qw.png

                          M 1 Reply Last reply 11 May 2018, 10:34
                          0
                          • S saber
                            11 May 2018, 10:28

                            @mrjj
                            this
                            0_1526034483163_qw.png

                            M Offline
                            M Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on 11 May 2018, 10:34 last edited by mrjj 5 Nov 2018, 10:39
                            #13

                            @saber
                            Ok so its a Qlineseries pointer
                            Looking at its replace, it seems to be this one ?
                            void QXYSeries::replace(int index, qreal newX, qreal newY)

                            anyway, you can split to multiple statements so its more clear which part that crashes.

                            for (int i = 0; i < (second < 61 ? second : 61); i++) {
                            auto Line= seriesList.at(j);
                            auto value = seriesList.at(j)->at(i).y();
                            Line->replace(i, (i+1),value );
                            }

                            S 1 Reply Last reply 11 May 2018, 11:00
                            0
                            • M mrjj
                              11 May 2018, 10:34

                              @saber
                              Ok so its a Qlineseries pointer
                              Looking at its replace, it seems to be this one ?
                              void QXYSeries::replace(int index, qreal newX, qreal newY)

                              anyway, you can split to multiple statements so its more clear which part that crashes.

                              for (int i = 0; i < (second < 61 ? second : 61); i++) {
                              auto Line= seriesList.at(j);
                              auto value = seriesList.at(j)->at(i).y();
                              Line->replace(i, (i+1),value );
                              }

                              S Offline
                              S Offline
                              saber
                              wrote on 11 May 2018, 11:00 last edited by
                              #14

                              @mrjj
                              sorry .i have no idea how to do that ,as our lead developer is gone for now.
                              so we are in short of intelligences .
                              here is the app .if you have some time ........
                              CoreBox

                              M 1 Reply Last reply 11 May 2018, 11:15
                              0
                              • S saber
                                11 May 2018, 11:00

                                @mrjj
                                sorry .i have no idea how to do that ,as our lead developer is gone for now.
                                so we are in short of intelligences .
                                here is the app .if you have some time ........
                                CoreBox

                                M Offline
                                M Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on 11 May 2018, 11:15 last edited by
                                #15

                                @saber
                                Hi
                                Will it work on any linux?
                                Also, you are trying to fix the
                                Known Bugs
                                Opening two dashboard ,crash the whole app. <<< -- that one ?

                                S 1 Reply Last reply 12 May 2018, 03:23
                                0
                                • M mrjj
                                  11 May 2018, 11:15

                                  @saber
                                  Hi
                                  Will it work on any linux?
                                  Also, you are trying to fix the
                                  Known Bugs
                                  Opening two dashboard ,crash the whole app. <<< -- that one ?

                                  S Offline
                                  S Offline
                                  saber
                                  wrote on 12 May 2018, 03:23 last edited by saber 5 Dec 2018, 03:25
                                  #16

                                  @mrjj
                                  yes it wiil run on any linux. as far as i know.
                                  because it has little dependences(qt,file,libmagic-dev/libmagic-mgc/libmagic1)
                                  and yes for now i want to fix the "Opening two dashboard ,crash the whole app"
                                  but it also have other bugs here

                                  my way to fix all this and add this feature by opening issue in qt forum.
                                  as i don't know the high level coding.

                                  i was intendant to do a invitation to join this project in this forum .but i was woried as it will be right way to that.
                                  if you have some time to fix this issue........

                                  M 1 Reply Last reply 12 May 2018, 08:47
                                  0
                                  • S saber
                                    12 May 2018, 03:23

                                    @mrjj
                                    yes it wiil run on any linux. as far as i know.
                                    because it has little dependences(qt,file,libmagic-dev/libmagic-mgc/libmagic1)
                                    and yes for now i want to fix the "Opening two dashboard ,crash the whole app"
                                    but it also have other bugs here

                                    my way to fix all this and add this feature by opening issue in qt forum.
                                    as i don't know the high level coding.

                                    i was intendant to do a invitation to join this project in this forum .but i was woried as it will be right way to that.
                                    if you have some time to fix this issue........

                                    M Offline
                                    M Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on 12 May 2018, 08:47 last edited by
                                    #17

                                    @saber
                                    Ok, seems like a big project.
                                    What ever happen to the person that wrote the code ?

                                    S 1 Reply Last reply 12 May 2018, 09:40
                                    0
                                    • M mrjj
                                      12 May 2018, 08:47

                                      @saber
                                      Ok, seems like a big project.
                                      What ever happen to the person that wrote the code ?

                                      S Offline
                                      S Offline
                                      saber
                                      wrote on 12 May 2018, 09:40 last edited by
                                      #18

                                      @mrjj
                                      it is not a bigg project.
                                      me and my friend made this app.
                                      my view , his code. he is has no interest and time for it now.
                                      so what you are thinking to .....

                                      M 1 Reply Last reply 12 May 2018, 09:51
                                      0
                                      • S saber
                                        12 May 2018, 09:40

                                        @mrjj
                                        it is not a bigg project.
                                        me and my friend made this app.
                                        my view , his code. he is has no interest and time for it now.
                                        so what you are thinking to .....

                                        M Offline
                                        M Offline
                                        mrjj
                                        Lifetime Qt Champion
                                        wrote on 12 May 2018, 09:51 last edited by
                                        #19

                                        @saber
                                        Ok, so you Designed it and he programmed it. sweet.
                                        Currently im spring cleaning pc so i have no linux around before monday.

                                        But if its easy to build, i might have a look at that bug next week.

                                        That said i have huge project at work so I cant help program it
                                        like project member.

                                        S 1 Reply Last reply 12 May 2018, 09:59
                                        0
                                        • M mrjj
                                          12 May 2018, 09:51

                                          @saber
                                          Ok, so you Designed it and he programmed it. sweet.
                                          Currently im spring cleaning pc so i have no linux around before monday.

                                          But if its easy to build, i might have a look at that bug next week.

                                          That said i have huge project at work so I cant help program it
                                          like project member.

                                          S Offline
                                          S Offline
                                          saber
                                          wrote on 12 May 2018, 09:59 last edited by
                                          #20

                                          @mrjj
                                          thanks for helping.
                                          it is easy to build .just the 2 dependencies .
                                          thats ok ,if you could not join as a project member.
                                          programar like you need little time to solve this listed problems.

                                          looking forward to hear for you.

                                          M 1 Reply Last reply 12 May 2018, 10:01
                                          0

                                          1/32

                                          8 May 2018, 09:15

                                          • Login

                                          • Login or register to search.
                                          1 out of 32
                                          • First post
                                            1/32
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved