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. Qt exit code 3
Forum Updated to NodeBB v4.3 + New Features

Qt exit code 3

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.1k Views
  • 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.
  • M Offline
    M Offline
    Martinuccia_96
    wrote on 16 Apr 2020, 08:52 last edited by
    #1

    I have a QtextEdit. To save all the characters that I insert on the edit block, I use a dynamic vector.
    It is built in the following way:

    std::vector<std::vector<symbol>> symbols
    

    The starting dimension is 1 for the interior vector and 1 for the exterior vector.
    symbol is a class:

    symbol(wchar_t ch, int siteId, int counter, const std::vector<int> &pos, bool verified=false);
    

    When I insert characters in a position that overcomes the dimension of the vector, I resize it, with the following method:

    void document::checkIndex(unsigned int i0, unsigned int i1) {
        double mult_fac=1.5;
        if(i0>=symbols.capacity()){
            symbols.resize((i0+1)*mult_fac);
    
    }
        if(i1>=symbols[i0].capacity())
            symbols[i0].resize((i1 + 1)*mult_fac, emptySymbol);
    
    }
    

    The problem is that sometimes, when I continue to insert characters on my QTextEditBlock as in the following picture:
    WhatsApp Image 2020-04-16 at 10.50.43.jpeg
    my program crashed with the exit code3.
    I think that it a problem of memory allocation, but I can't solve it.

    J 1 Reply Last reply 16 Apr 2020, 08:56
    0
    • M Martinuccia_96
      16 Apr 2020, 08:52

      I have a QtextEdit. To save all the characters that I insert on the edit block, I use a dynamic vector.
      It is built in the following way:

      std::vector<std::vector<symbol>> symbols
      

      The starting dimension is 1 for the interior vector and 1 for the exterior vector.
      symbol is a class:

      symbol(wchar_t ch, int siteId, int counter, const std::vector<int> &pos, bool verified=false);
      

      When I insert characters in a position that overcomes the dimension of the vector, I resize it, with the following method:

      void document::checkIndex(unsigned int i0, unsigned int i1) {
          double mult_fac=1.5;
          if(i0>=symbols.capacity()){
              symbols.resize((i0+1)*mult_fac);
      
      }
          if(i1>=symbols[i0].capacity())
              symbols[i0].resize((i1 + 1)*mult_fac, emptySymbol);
      
      }
      

      The problem is that sometimes, when I continue to insert characters on my QTextEditBlock as in the following picture:
      WhatsApp Image 2020-04-16 at 10.50.43.jpeg
      my program crashed with the exit code3.
      I think that it a problem of memory allocation, but I can't solve it.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 16 Apr 2020, 08:56 last edited by
      #2

      @Martinuccia_96 Not sure how your question is related to Qt.
      Did you use debugger to find out where exactly it crashes?
      Please do so and post the stacktrace after crash.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      1/2

      16 Apr 2020, 08:52

      • Login

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