Solved 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
-
@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?
-
@jsulm O declared it as: QImage img;
And it said I needed a constructor.
-
@Manu_NaFu Did you include QImage header file?
-
@jsulm I did, i created the pointer as QImage *image;
Instead of a normal variable. -
@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.
-
@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.
-
@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
-
@Manu_NaFu
To be clear: are you resizing yourcv
data before or after you assign it to theQImage
? If theQImage
or whatever is using the original data buffer passed to it, you cannot execute anything which changes that buffer. Just checking.. -
@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
-
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.