Results 1 to 4 of 4

Thread: MVC App crashes in release mode

  1. #1
    Join Date
    Jun 2015
    Location
    India
    Posts
    185
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default MVC App crashes in release mode

    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:

    Qt Code:
    1. int model::columnCount(const QModelIndex &parent) const
    2. {
    3. return 1;
    4. }
    To copy to clipboard, switch view to plain text mode 

    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.
    Thanks :-)

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: MVC App crashes in release mode

    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.

  3. #3
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: MVC App crashes in release mode

    Quote Originally Posted by prasad_N View Post
    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...with-modeltest
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  4. #4
    Join Date
    Jun 2015
    Location
    India
    Posts
    185
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: MVC App crashes in release mode

    Thanks guys.. Did work, problem with uninitialized pointer in constructor & one more silly mistake

    Qt Code:
    1. 1. model::model() : m_parent(nullPtr)
    2. 2. int model::childCount()
    3. {
    4. m_childs.count; //did put return here but, compiler did not warn
    5. }
    To copy to clipboard, switch view to plain text mode 
    Thanks :-)

Similar Threads

  1. Replies: 1
    Last Post: 23rd April 2014, 11:03
  2. Crashes in release mode (ntdll.dll errors)
    By ehnuh in forum Qt Programming
    Replies: 1
    Last Post: 19th December 2012, 11:19
  3. Replies: 1
    Last Post: 7th March 2012, 22:34
  4. Replies: 1
    Last Post: 2nd November 2009, 13:02
  5. Replies: 9
    Last Post: 15th April 2009, 07:23

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.