Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]How to prevent this crash?
Qt 6.11 is out! See what's new in the release blog

[Solved]How to prevent this crash?

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

    Hi and welcome to DevNet.

    Did you check that imageData is a valid pointer ?

    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
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #3

      Your myImage is probably declared as private, hence it's not accesible. Either make it public, or use a getter to get the pointer. Then the pointer == NULL will work (make sure you explicitly set it to null in the constructor or somewhere. Pointers, just like variables in c++, are not automatically initialised to 0).

      (Z(:^

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #4

        [quote author="SGaist" date="1363868284"]Hi and welcome to DevNet.

        Did you check that imageData is a valid pointer ?[/quote]

        How can I check it?

        [quote author="sierdzio" date="1363868421"]Your myImage is probably declared as private, hence it's not accesible. Either make it public, or use a getter to get the pointer. Then the pointer == NULL will work (make sure you explicitly set it to null in the constructor or somewhere. Pointers, just like variables in c++, are not automatically initialised to 0).[/quote]

        It's not declared as private. The code runs perfect for some time & passes million times over this line but it crashes there fore some reason.

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #5

          Ah, ok. Then check for validity of imageData before using it:
          @
          if (imageData && imageData->myImage==NULL) {
          ...
          }
          @

          (Z(:^

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

            As sierdzio said: check for imageData == NULL before doing imageData->myImage == NULL

            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
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #7

              Of course. Why could I have thought about this before. Thanks guys. How do you mark the thread as solved?

              1 Reply Last reply
              0
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #8

                Edit your initial post and add "[Solved]". I've already tagged it for you.

                (Z(:^

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

                  You're welcome

                  Simply edit the thread title and add [Solved]

                  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
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #10

                    Thanks guys. You two are parallel processing here :D

                    1 Reply Last reply
                    0
                    • sierdzioS Offline
                      sierdzioS Offline
                      sierdzio
                      Moderators
                      wrote on last edited by
                      #11

                      Hehe, yes it would seem so :)

                      (Z(:^

                      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
                      • Unsolved