Results 1 to 8 of 8

Thread: Dialog error in Windows, but not on Mac

  1. #1
    Join Date
    Jan 2012
    Posts
    46
    Thanks
    11
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Dialog error in Windows, but not on Mac

    All --

    Just doing some testing to verify that my app works correctly in Windows and Mac, and just noticed that the following code in my mainwindow.cpp works exactly as I expect on my Mac (where I do my primary development), but the same code does not generate the dialog and throws the following error: "QDialog::exec: Recursive call detected" because the dialog isn't created. As this code was written a year ago I'm having trouble believing that I've missed this before but that's another story...

    mainwindow.h
    Qt Code:
    1. namespace Ui {
    2. class MainWindow;
    3. }
    4.  
    5. class MainWindow : public QMainWindow
    6. {
    7. Q_OBJECT
    8.  
    9. public:
    10. explicit MainWindow(QWidget *parent = 0);
    11. ~MainWindow();
    12.  
    13. RAOEntryDialog *RAO_Edit;
    14. };
    To copy to clipboard, switch view to plain text mode 

    mainwindow.cpp

    Qt Code:
    1. //****************************************************************************
    2. void MainWindow::on_SurgePB_clicked()
    3. {
    4. //**********************************************
    5. //* Create a pop-up dialog to allow the user *
    6. //* to perform large-scale editing of period *
    7. //* and phase data related to RAOs... *
    8. //**********************************************
    9. if (!RAO_Edit)
    10. {
    11. RAO_Edit = new RAOEntryDialog(surgemodel, "SURGE", user, rig_id,
    12. rig_dataset, this);
    13.  
    14. connect(RAO_Edit, SIGNAL(edit_rao_signal(int)),
    15. this, SLOT(process_rao_edits(int)));
    16. }
    17.  
    18. RAO_Edit->exec();
    19.  
    20. }
    To copy to clipboard, switch view to plain text mode 

    If instead of the "if" statement I simply create the dialog then delete it after the "exec()" command it works fine - and that's probably a better way of preventing memory leaks anyway - but I was wondering if someone has a theory of why there's a different behavior on the different platforms (Windows 7 and Mac 10.7.5)

    thanks!


    Kodi

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Dialog error in Windows, but not on Mac

    Make sure RAO_Edit is initialized to 0 in the ctor?
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. The following user says thank you to Santosh Reddy for this useful post:

    mtnbiker66 (11th February 2013)

  4. #3
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Dialog error in Windows, but not on Mac

    where do you set RAO_Edit = 0 (or NULL)?

    If you do not do this, then !RAO_Edit will be true just because RAO_Edit is unitialised and contains junk.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  5. The following user says thank you to amleto for this useful post:

    mtnbiker66 (11th February 2013)

  6. #4
    Join Date
    Jan 2012
    Posts
    46
    Thanks
    11
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Dialog error in Windows, but not on Mac

    (facepalm)

    Well, that's embarrassing - I completely forgot to initialize it! It was working on the Mac just by shear luck and probably worked on my Windows machine in the past for the same reason. Thanks for pointing out what should have been dead obvious

    Kodi

  7. #5
    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: Dialog error in Windows, but not on Mac

    If I had $1 for every time I've pounded my head on the wall trying to figure out unexplained behavior, only to have it turn out to be an uninitialized variable, I wouldn't have to work any more...

  8. #6
    Join Date
    Jan 2012
    Posts
    46
    Thanks
    11
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Dialog error in Windows, but not on Mac

    You'd think after programming for almost 30 years I would have looked for the obvious first!

  9. #7
    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: Dialog error in Windows, but not on Mac

    Quote Originally Posted by mtnbiker66 View Post
    You'd think after programming for almost 30 years I would have looked for the obvious first!
    Ditto. I chalk it up to "early onset old-timer's disorder".

  10. #8
    Join Date
    Jan 2012
    Posts
    46
    Thanks
    11
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Dialog error in Windows, but not on Mac

    Quote Originally Posted by d_stranz View Post
    Ditto. I chalk it up to "early onset old-timer's disorder".
    I chalk it up to 1) being a father of a 20 month old 2) working a second job in the evenings and 3) has a spouse who works from home That's also my excuse for the hair graying and falling out, too...

Similar Threads

  1. Replies: 4
    Last Post: 29th April 2014, 16:20
  2. Dialog block in windows
    By giusepped in forum Qt Programming
    Replies: 1
    Last Post: 23rd December 2008, 21:43
  3. Dialog block in windows
    By giusepped in forum Qt Programming
    Replies: 2
    Last Post: 17th December 2008, 13:42
  4. Dialog on right click on windows?
    By vishal.chauhan in forum Qt Programming
    Replies: 5
    Last Post: 4th August 2008, 09:36
  5. QTable gives error when put on a dialog??
    By darpan in forum Qt Tools
    Replies: 3
    Last Post: 7th August 2006, 19:57

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.