Results 1 to 5 of 5

Thread: using a model view on a "local" dialog causes a seg fault on close

  1. #1
    Join Date
    Dec 2009
    Posts
    22
    Thanks
    3
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default using a model view on a "local" dialog causes a seg fault on close

    Hi All,
    I open a "local" dialog from my mainwindow. Using
    Qt Code:
    1. Add_Dialog madd_dialog;
    2.  
    3. madd_dialog.setModal( true );
    4. madd_dialog.exec( );
    To copy to clipboard, switch view to plain text mode 

    everything works fine however when I go to close it I get a segmentation fault.
    On commenting out everything except the constructor and de-constructor I've found that putting a model in my class produces the crash, so my class shows
    Qt Code:
    1. private:
    2. Ui::Add_Dialog *ui;
    3.  
    4. // QStandardItemModel model;
    To copy to clipboard, switch view to plain text mode 

    if I comment out model it works fine. I presume this is something to do with memory however am not knowledge of Qt is not enough to work out the issue.

    Also related to this does the debugger have a backtrace like ddd so when I get a seg fault I can see what's causing it.


    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: using a model view on a "local" dialog causes a seg fault on close

    If you have a crash, then the stack trace of that crash is a valuable source of information on where it actually crashed.

    Cheers,
    _

    P.S. no need to set modality, QDialog::exec() does that already

  3. #3
    Join Date
    Dec 2009
    Posts
    22
    Thanks
    3
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: using a model view on a "local" dialog causes a seg fault on close

    Hi,
    in Qt the stack shows "0 ??" from ddd "#0 0x00000000 in ?? ()" also in ddd backtrace normally shows all your function calls on the stack and I can set an execution point in the function then just step to the seg fault. However again backtrace just shows #0 0x0000000 in ??(). To be honest I've never seen this before, can anyone advise on this. The error occurs when I close a dialog with either the x button or calling this->close. I f I comment out the model from the class the error doesn't happen. Thanks

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: using a model view on a "local" dialog causes a seg fault on close

    Maybe your code is built in release mode and thus no trace is available. Or maybe the stack is corrupted. The code should not crash just because you have a model as a member variable. Did you try rebuilding the project?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Dec 2009
    Posts
    22
    Thanks
    3
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: using a model view on a "local" dialog causes a seg fault on close

    Ok solved it, when I set up the dialog I use
    Qt Code:
    1. madd_dialog.setModal( true );
    2. madd_dialog.exec( );
    To copy to clipboard, switch view to plain text mode 
    if I comment out setmodel it works. Don't know why as the tutorials I'm following always call this function. I only commented out because of anda's advise that it's not needed. However this seems to have go everything working. No idea why don't know enough about Qt.

Similar Threads

  1. "Render" Qt dialog window from ".ui" file
    By BitEater in forum Qt Programming
    Replies: 1
    Last Post: 8th July 2011, 14:40
  2. Replies: 0
    Last Post: 15th April 2011, 19:04
  3. Model "knows" the asking view
    By lotek in forum Newbie
    Replies: 5
    Last Post: 12th November 2010, 00:03
  4. windows xp "local security settings"
    By mickey in forum General Discussion
    Replies: 1
    Last Post: 7th August 2008, 03:54
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

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.