PDA

View Full Version : MVC App crashes in release mode



prasad_N
21st September 2015, 18:18
Hi,
I have an issue in my application, I am working with MVC. I have customised view, model & proxy model.
When i build this app in debug mode it working fine & cool, But when i build this app in release mode The app is crashing.
I tried debugging it & found its crashing when it calls proxyModel::columnCount()


When I debug I see call stack Info as below (Starting from main & crashing at columnCount())


proxyModel::columnCount(); //App is crashing here
headeview->setModel(model);
view->setModel(model);
.......
........
main()

my model from qabstractitemmodel:


int model::columnCount(const QModelIndex &parent) const
{
return 1;
}

I have nothing Implemented in proxy except filterAcceptRows()
Sorry but not able to provide much code. What might gone wrong in my application ??



And 1 more Qs: Is there simple or standard way to debug MVC, I see debugging MVC is very difficult.

d_stranz
21st September 2015, 18:41
In debug mode, the debugger will initialize variables during startup. Pointers are initialized to a known (but non-valid) value, like "0xeaeaeaea". In release mode, this doesn't happen. Variables and especially pointers have random values. So almost certainly the instance of your proxy model that is calling into "columnCount()" is a bad or uninitialized pointer.

Use the debugger to make sure all of your pointer instances are correct. Make sure you aren't creating your proxy model on the stack and then passing the address of the stack instance in as an argument that is intended to be a heap pointer instead.

jefftee
22nd September 2015, 03:35
And 1 more Qs: Is there simple or standard way to debug MVC, I see debugging MVC is very difficult.
The model::columnCount you show is certainly *not* causing your crash. More likely, the pointer to your model has become invalid or not initialized correctly, etc. Please show how you create the model, proxy model, initialize the model in your view, etc.

Once you get past your current issue, the best method I've found for debugging custom models is:

http://doc.qt.io/qt-5/modelview.html#3-5-debugging-with-modeltest

prasad_N
22nd September 2015, 07:22
Thanks guys.. Did work, problem with uninitialized pointer in constructor & one more silly mistake


1. model::model() : m_parent(nullPtr)
2. int model::childCount()
{
m_childs.count; //did put return here but, compiler did not warn
}