I am using the Qt5 addin with visual studio 2010. I am trying to populate a QMap on the heap with a char ID and QWidget* value as well as populate a QVBoxLayout with the QWidget*. I get a run time break from a QMap call of detch inside the insert function. I have tried using std::shared_ptr with the widget address. Anyone have any ideas of what might be happening.
Asked
Active
Viewed 363 times
0
-
It would help if you could provide some minimal code example that reproduces the issue or at least some extract from the code where the issue occurs. Personally, I had issues in the past with QMap due to multi-threaded use (which is not supported), but without knowing more about your issue this would just be a guess. – Martin Höher Apr 24 '18 at 13:54
-
Im not going across threads. Pretty much a for loop parsing xml tags and based on attributes different widgets are instanciated. From there i put a char* key with the address of the widget as value into a qmap in the subclass of qhboxlayout – Mike Apr 24 '18 at 18:50
-
NOTE: the first line of code in qmap insert is an internal call dettach which is where it breaks. – Mike Apr 24 '18 at 18:51
-
AFAIK QMap is implicitly shared. Detach is used on write operations on it to create a copy (on write) if necessary. Having it crash there, my best guess would be that your QMap instance is not properly initialized, which causes the issue as soon as the internal data pointer is accessed. But to be sure, some code would still be good I guess ;) – Martin Höher Apr 24 '18 at 19:59
-
Ill put some up when i get home from work. Its possible when i put it on the heap that becomes an issue but i only did so bc i was getting the same crash when it was shallow (on stack). Ill put some code up in a bit – Mike Apr 24 '18 at 20:10