title: Show dialog before main window
body: <p>I have a windowed application, which crashes after showing information dialog only before QMainWindow is activated.</p>
  
  <p>Information dialog is shown only if passed data is invalid, however it might be a user interaction (file select / drag) or passed as argument, which causes problems. When / how should I show such error dialog than?</p>
  
  <p>Note: When dialog is only shown (with show() method rather than exec()) it doesn't crash, but dialog gets discarded right away even with setModal( true ).</p>
  
  <p>Any ideas? Thanks,</p>
  
  <p>EDIT:</p>
  
  <p>Some code:</p>
  
  <pre><code>int WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, LPSTR lpCmdLine, int nShowCmd)
  {
      QApplication app(__argc, __argv);
      MBViewer viewer;
      viewer.show();
      return app.exec();
  }
  
  MBViewer::MBViewer()
  {
      setAcceptDrops(true);
      m_ui.setupUi(this);
      m_viewer = new Viewer_Widget();
      m_ui.preview_layout-&gt;addWidget(m_viewer);
      parse_parameters();
      connect_controls();
      connect_actions();
  }
  
  void MBViewer::connect_controls()
  {
      (...)
      connect( m_viewer, SIGNAL( view_initialized()), this, SLOT( open_file() ));
      (...)
  }
  
  void MBViewer::open_file()
  {
      // somefile is set in parse_parameters or by user interaction
      if (!somefile.is_valid()) { 
          m_viewer-&gt;reset();
          // This will crash application after user clicked OK button
          QMessageBox::information( this, "Error", "Error text", QMessageBox::Ok );
          return;
      }
      (...)
  }
  </code></pre>