c++ - Constructing new variables within a class making my program crash -


hi start off with:

coding in c++

using qt creator version 5.4.1

so i'm having problem program when start constructing new classes member variables, program crashes. i've tried assigning values them, in header, in class constructor , in class initialization neither helping. these figure causing problem:

the class called wfsfeatureviewer uses header file , qt ui file. ui initialized on construction.

std::vector<customlineitem*> m_line_items; std::vector<custompointitem*> m_point_items; std::vector<custompolygonitem*> m_polygon_items; 

they simple polygon/line/point items subclassed qgraphicspolygonitem,pointitem , line item. nothing them. if exclude these guys class doesn't crash (but vital member variables class)

i'm wondering if speed i'm creating class at? 5-60 of these , crashes. wfsfeatureviewer class gets added qlistwidgetview. using loop creates bunch of them user see. here's how looks:

// used index pass the wfsfeatureviewer int = 0;  // loop wfs feature names , elements for(auto feature_itr : m_layer_elements) {     // increment per loop     i++;      // create new wfsfeatureviewer     auto wfs_viewer(new wfsfeatureviewer());      qobject::connect(wfs_viewer,&wfsfeatureviewer::sendnewshps,this,&dialogwfsreader::catchnewshps);      //set ui data , base wfs later reading.     wfs_viewer->setelementandname(feature_itr.first,feature_itr.second);     wfs_viewer->setindex(i);     wfs_viewer->setwfsbaseurl(m_ui->m_line_wfs_name->text().tostdstring());      // loop layer count wfsviewer     for(auto layer_itr : m_layer_count)     {         // check if correct name         if(layer_itr.first == feature_itr.first)         {             // set layer count             wfs_viewer->setlayercount(layer_itr.second);         }     }     // loop shape type     for(auto shp_itr : m_layer_shp_type)     {         // check if correct name         if(shp_itr.first == feature_itr.first)         {             // set shape type             wfs_viewer->setshapetype(shp_itr.second);         }     }      // create new qlistwidgetitem     qlistwidgetitem* item(new qlistwidgetitem);      // add qlistwidget     m_ui->m_list_layers->additem(item);      // set wfs_viewer onto item     m_ui->m_list_layers->setitemwidget(item,wfs_viewer);      // give size     item->setsizehint(qsize(100,210));      // , adjust ui     wfs_viewer->adjustsize(); } 

so can loop quite few times, meaning lots of new objects getting created, comes out 10-30mb of ram if load 70-100 classes in.

i'm not sure whats causing this, im not getting heap error know i'm not killing heap.

okay i've seemed have fixed now, stops crashing once when creating new classes. full clean, qmake , rebuild fixed issue. not sure causing it. fixed now, post here again if find proper answer solution.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -