Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Dynamically changes the Image source may lead to crash ?

    QML and Qt Quick
    2
    2
    502
    Loading More Posts
    • 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.
    • Renaud G.
      Renaud G. last edited by

      Hello everyone !

      I would like your opinion about some strange crashes I experienced on embedded application.

      The application has many image items and the source of those items are depending on one value.
      When we are in manual, we display all manual images and when we change to automatic mode. Many image sources change to another image file.
      We experience some crashes when it change.

      Example:

      Image {
           source: isManual ? "../../manual/image_200.png" : "../../automatic/image_200.png"
      }
      Image {
           source: isManual ? "../../manual/image_201.png" : "../../automatic/image_201.png"
      }
      […]
      

      I compiled Qt in debug mode and found out the crashes occur inside this function: int QSGOpaqueTextureMaterial::compare(const QSGMaterial *o) const
      I put outputs message in Qt to show the path of image calling this method.
      It always used by Image item with the source changing according to parameter.

      My theory:
      As I understand, the cache system is full so it drops some images but at the same time, update requests are sent and requests are managed after the deletion of images. 
      The problem occurs on the embedded platform when the main thread has to manage heavy network communication.
      On regular computers (or/and without the network communication) it does not occur.

      I'm wondering if my idea is possible or am I completely wrong ?

      Rolisteam: RPG virtual tabletop software in Qt: www.rolisteam.org : https://github.com/Rolisteam/rolisteam
      Github: https://github.com/obiwankennedy

      A 1 Reply Last reply Reply Quote 0
      • A
        ambershark @Renaud G. last edited by

        @Renaud-G. It sounds feasible. What I would look at along those lines is your mainthread not getting a chance to handle all outstanding gui messages before things are changed/cleaned.

        Is it possible to move your network stuff to a different thread allowing your main thread's event queue to be a bit leaner?

        It's also possible that your original image's memory is cleaned up and when the compare() happens it is referencing memory that is gone.. What is the code on the line where it is crashing? This would probably be a bug in Qt though so it's a bit less likely.

        My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

        1 Reply Last reply Reply Quote 2
        • First post
          Last post