View Full Version : MVC App crashes in release mode

21st September 2015, 19:18
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

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.

21st September 2015, 19: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.

22nd September 2015, 04: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:


22nd September 2015, 08: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