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. Bug QPainter crashes
Qt 6.11 is out! See what's new in the release blog

Bug QPainter crashes

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 5 Posters 6.5k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #7

    On a side note, modifying your pen and brush objects after setting them on painter won't modify what painter draws. You should first configure them and once that done set them on painter.

    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
    • S Offline
      S Offline
      Sproza
      wrote on last edited by
      #8

      thanks @SGaist! it should be obvious, a silly mistake on my part. Any ideas about the problem though??

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #9

        What's the size of your snake variable ? Are you sure the coordinates are valid ?

        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
        • S Offline
          S Offline
          Sproza
          wrote on last edited by Sproza
          #10

          Yes, coords are valid (250x and 250y whereas border is 500x500). Size of snake vector is 2.
          Whole code is available at: https://github.com/Sproza/Snake.git
          Just to make it clear because many find it confusing: Snake is a class with snake member vector and I named an instance of Snake "snake" in mainwindow constructor.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sproza
            wrote on last edited by
            #11

            Please? Anyone?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #12

              Can you provide a more complete code sample ? We can only do guesses here since there are a lot of unknowns from your side.

              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
              • mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #13

                Hi
                The code on git do not really compile out of the box.
                Anyway, i saw this

                for(int i = snake.size(); i >= 0; i--)

                if snake.size() is 0 , wont that crash in snake[0].x ?
                as you say >= ?

                jsulmJ 1 Reply Last reply
                0
                • mrjjM mrjj

                  Hi
                  The code on git do not really compile out of the box.
                  Anyway, i saw this

                  for(int i = snake.size(); i >= 0; i--)

                  if snake.size() is 0 , wont that crash in snake[0].x ?
                  as you say >= ?

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #14

                  @mrjj @Sproza Yes, it should be

                  for(int i = snake.size() - 1; i >= 0; i--)
                  

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

                  1 Reply Last reply
                  2
                  • S Offline
                    S Offline
                    Sproza
                    wrote on last edited by
                    #15

                    Yes, in that case it will crash, but snake.size() will never be 0 unless board -> STARTING_LENGTH will be 0. In Snake constructor program pushes additional dot to vector STARTING_LENGTH times.
                    But in reality there wont be way to change STARTING_LENGTH to 0 via menu.
                    So I do no think that's the reason. Just to be sure I tried snake.size() - 1 (although i have no idea why it would work) and it is not the solution.

                    mrjjM 1 Reply Last reply
                    0
                    • S Sproza

                      Yes, in that case it will crash, but snake.size() will never be 0 unless board -> STARTING_LENGTH will be 0. In Snake constructor program pushes additional dot to vector STARTING_LENGTH times.
                      But in reality there wont be way to change STARTING_LENGTH to 0 via menu.
                      So I do no think that's the reason. Just to be sure I tried snake.size() - 1 (although i have no idea why it would work) and it is not the solution.

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

                      @Sproza

                      Ok, since you can run it then why not just find the crash with the debugger ?
                      When it crash the call stack will be shown and you can easy see where the crash happened.

                      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