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. Program throws this error and SIGSEV when i try to set a pixmap for a Qlabel: glib-gobject-critical ** g_object_unref: assertion 'g_is_object (object)' failed qt
Forum Updated to NodeBB v4.3 + New Features

Program throws this error and SIGSEV when i try to set a pixmap for a Qlabel: glib-gobject-critical ** g_object_unref: assertion 'g_is_object (object)' failed qt

Scheduled Pinned Locked Moved Solved General and Desktop
17 Posts 5 Posters 1.4k 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
    #4

    From the looks of it you are using multiple threads so yes it does matter.

    As the easiest way to do that, use the copy method of QImage.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    M 1 Reply Last reply
    0
    • SGaistS SGaist

      From the looks of it you are using multiple threads so yes it does matter.

      As the easiest way to do that, use the copy method of QImage.

      M Offline
      M Offline
      Manu_NaFu
      wrote on last edited by
      #5

      @SGaist I created a QImage in my class and did this:

              QImage img(qImage, mat.cols, mat.rows, mat.step, QImage::Format_RGB888);
              *image = img.copy();
              emit(print_img(*image));
      

      But I still get the error.

      I tried eliminating the oart where i resize my map and then the image is loaded fine, but with the dimensions i do not want.

      The map i resize is the map where i get my image:

      cv::Mat mat = map.getMap();
      

      And I resize it with:

      cv::resize(map_,map_,cv::Size(width, heigth));
      

      Thanks for the help.

      1 Reply Last reply
      0
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #6

        @Manu_NaFu said in Program throws this error and SIGSEV when i try to set a pixmap for a Qlabel: glib-gobject-critical ** g_object_unref: assertion 'g_is_object (object)' failed qt:

        *image = img.copy();

        Why a pointer here?

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        M 1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          @Manu_NaFu said in Program throws this error and SIGSEV when i try to set a pixmap for a Qlabel: glib-gobject-critical ** g_object_unref: assertion 'g_is_object (object)' failed qt:

          *image = img.copy();

          Why a pointer here?

          M Offline
          M Offline
          Manu_NaFu
          wrote on last edited by
          #7

          @Christian-Ehrlicher because it doesnt let me declare a QImage in the class so I created a Pointer.

          jsulmJ 1 Reply Last reply
          0
          • M Manu_NaFu

            @Christian-Ehrlicher because it doesnt let me declare a QImage in the class so I created a Pointer.

            jsulmJ Online
            jsulmJ Online
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #8

            @Manu_NaFu said in Program throws this error and SIGSEV when i try to set a pixmap for a Qlabel: glib-gobject-critical ** g_object_unref: assertion 'g_is_object (object)' failed qt:

            because it doesnt let me declare a QImage in the class

            There shouldn't be a problem declaring QImage in your class. How did you declare it and what was the error?

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

            M 1 Reply Last reply
            2
            • jsulmJ jsulm

              @Manu_NaFu said in Program throws this error and SIGSEV when i try to set a pixmap for a Qlabel: glib-gobject-critical ** g_object_unref: assertion 'g_is_object (object)' failed qt:

              because it doesnt let me declare a QImage in the class

              There shouldn't be a problem declaring QImage in your class. How did you declare it and what was the error?

              M Offline
              M Offline
              Manu_NaFu
              wrote on last edited by
              #9

              @jsulm O declared it as: QImage img;

              And it said I needed a constructor.

              jsulmJ 1 Reply Last reply
              0
              • M Manu_NaFu

                @jsulm O declared it as: QImage img;

                And it said I needed a constructor.

                jsulmJ Online
                jsulmJ Online
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #10

                @Manu_NaFu Did you include QImage header file?

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

                M 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @Manu_NaFu Did you include QImage header file?

                  M Offline
                  M Offline
                  Manu_NaFu
                  wrote on last edited by
                  #11

                  @jsulm I did, i created the pointer as QImage *image;
                  Instead of a normal variable.

                  1 Reply Last reply
                  0
                  • Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #12

                    @Manu_NaFu said in Program throws this error and SIGSEV when i try to set a pixmap for a Qlabel: glib-gobject-critical ** g_object_unref: assertion 'g_is_object (object)' failed qt:

                    Instead of a normal variable.

                    What is a 'non-normal' variable??

                    Again: there is no need to declare it as pointer and if you declare it as such you a) have to properly create it with new and b) should clean it up later on. But both is not needed when you declare it as simple object.

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    M 1 Reply Last reply
                    0
                    • Christian EhrlicherC Christian Ehrlicher

                      @Manu_NaFu said in Program throws this error and SIGSEV when i try to set a pixmap for a Qlabel: glib-gobject-critical ** g_object_unref: assertion 'g_is_object (object)' failed qt:

                      Instead of a normal variable.

                      What is a 'non-normal' variable??

                      Again: there is no need to declare it as pointer and if you declare it as such you a) have to properly create it with new and b) should clean it up later on. But both is not needed when you declare it as simple object.

                      M Offline
                      M Offline
                      Manu_NaFu
                      wrote on last edited by
                      #13

                      @Christian-Ehrlicher Somehow now I could declare it. Anyway, it seems to me a problem related to cv::Mat memory allocation instead of Qt. It only fails when I resize the cv::Mat from where i get the image to use as pixmap, so now I don't really know if I should have posted this here.

                      M 1 Reply Last reply
                      0
                      • M Manu_NaFu

                        @Christian-Ehrlicher Somehow now I could declare it. Anyway, it seems to me a problem related to cv::Mat memory allocation instead of Qt. It only fails when I resize the cv::Mat from where i get the image to use as pixmap, so now I don't really know if I should have posted this here.

                        M Offline
                        M Offline
                        Manu_NaFu
                        wrote on last edited by
                        #14

                        @Manu_NaFu Update: it fails when I both resize the cv::Mat and try to use it as pixmap. If I only resize the mat works fine, and if I only use it as pixmap, it also works fine, but for any reason I cannot do both

                        JonBJ 1 Reply Last reply
                        0
                        • M Manu_NaFu

                          @Manu_NaFu Update: it fails when I both resize the cv::Mat and try to use it as pixmap. If I only resize the mat works fine, and if I only use it as pixmap, it also works fine, but for any reason I cannot do both

                          JonBJ Online
                          JonBJ Online
                          JonB
                          wrote on last edited by
                          #15

                          @Manu_NaFu
                          To be clear: are you resizing your cv data before or after you assign it to the QImage? If the QImage or whatever is using the original data buffer passed to it, you cannot execute anything which changes that buffer. Just checking..

                          M 1 Reply Last reply
                          0
                          • JonBJ JonB

                            @Manu_NaFu
                            To be clear: are you resizing your cv data before or after you assign it to the QImage? If the QImage or whatever is using the original data buffer passed to it, you cannot execute anything which changes that buffer. Just checking..

                            M Offline
                            M Offline
                            Manu_NaFu
                            wrote on last edited by
                            #16

                            @JonB I have a class called map, which contains an image, I resize that image at the start of the program, for example to be 200x200. Then i get that image and resize it to be the size of the Qlabel, which is 800x800, then i transform it into a QImage to use it for the pixmap. For that purpose, I do the following:

                            mat = map.getMap();
                            cv::resize(mat,mat,cv::Size(800,800));
                            QImage img((const uchar*)mat.data, mat.cols, mat.rows, mat.step, QImage::Format_RGB888);
                            emit(print_img(img.copy()));
                            usleep((10000/speed_)*1000);
                            

                            This code is in a while loop

                            1 Reply Last reply
                            0
                            • M Offline
                              M Offline
                              Manu_NaFu
                              wrote on last edited by
                              #17

                              I solved the issue by moving the map from the class variables to the run function(), so I do not have to resize the map.

                              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