Unverified Commit 66d7bd3d authored by Summer Stapleton's avatar Summer Stapleton Committed by GitHub
Browse files

Merge pull request #233 from TracieSucharski/ipceDocks

Fix cleanup of views and temporary fix to geometry/state settings.
parents 1204b95d b808f0b6
Loading
Loading
Loading
Loading
+25 −21
Original line number Diff line number Diff line
@@ -95,11 +95,14 @@ namespace Isis {
      m_directory = new Directory(this);
      connect(m_directory, SIGNAL( newWidgetAvailable(QWidget *) ),
              this, SLOT( addView(QWidget *) ) );
      connect(m_directory, SIGNAL(viewClosed(QWidget *)), this, SLOT(removeView(QWidget *)));
      connect(m_directory, SIGNAL(viewClosed(QWidget *)),
              this, SLOT(removeView(QWidget *)));
      connect(m_directory, SIGNAL( directoryCleaned() ),
              this, SLOT( removeAllViews() ) );
      connect(m_directory->project(), SIGNAL(projectLoaded(Project *)),
              this, SLOT(readSettings(Project *)));
      connect(m_directory->project(), SIGNAL(projectSaved(Project *)),
              this, SLOT(writeSettings(Project *)));
      connect(m_directory, SIGNAL( newWarning() ),
              this, SLOT( raiseWarningTab() ) );
    }
@@ -165,9 +168,6 @@ namespace Isis {
    createMenus();
    createToolBars();

//  setTabbedViewMode();
//  centralWidget->setTabsMovable(true);
//  centralWidget->setTabsClosable(true);
    // Read default app settings
    readSettings(m_directory->project() );

@@ -207,11 +207,24 @@ namespace Isis {
    // Connections for cleanup in both directions to make sure both views and docks are cleaned up
    connect(newWidget, SIGNAL(destroyed(QObject *)), dock, SLOT(deleteLater()));
    connect(dock, SIGNAL(destroyed(QObject *)), newWidget, SLOT(deleteLater()));
    // The list of dock widgets needs cleanup as each view is destroyed
    connect(dock, SIGNAL(destroyed(QObject *)),
            this, SLOT(cleanupViewDockList(QObject *)));

    // Save view docks for cleanup during a project close
    m_viewDocks.append(dock);
  }


  void IpceMainWindow::cleanupViewDockList(QObject *obj) {

    QDockWidget *dock = static_cast<QDockWidget *>(obj);
    if (dock) {
      m_viewDocks.removeAll(dock);
    }
  }


  /**
   * @description This slot is connected from Directory::viewClosed(QWidget *) signal.  It will 
   * close the given view and delete the view. This was written to handle
@@ -231,22 +244,13 @@ namespace Isis {
   */
  void IpceMainWindow::removeAllViews() {
    setWindowTitle("ipce");
//  qDebug()<<"IpceMainWindow::removeAllViews  directory footprint count = "<<m_directory->footprint2DViews().count();
//  qDebug()<<"                                directory cube disp count = "<<m_directory->cubeDnViews().count();

    // Find all children of IpceMainWindow and close
    QList<QDockWidget *> dockedWidgets = findChildren<QDockWidget *>();
//  qDebug()<<"           # docks before removal = "<<dockedWidgets.count();
    foreach (QDockWidget *dock, m_viewDocks) {
      if (dock) {
        removeDockWidget(dock);
        m_viewDocks.removeAll(dock);
        delete dock;
      }

    QList<QDockWidget *> dockedWidgets2 = findChildren<QDockWidget *>();
//  qDebug()<<"           any docks left"<<dockedWidgets2.count();
//  qDebug()<<"IpceMainWindow::removeAllViews  directory footprint count = "<<m_directory->footprint2DViews().count();
//  qDebug()<<"                                directory cube disp count = "<<m_directory->cubeDnViews().count();
    }
    m_viewDocks.clear();
  }

@@ -539,7 +543,7 @@ namespace Isis {
   *   @history 2017-10-17 Tyler Wilson Added a [recent projects] group for the saving and
   *                           restoring of recently opened projects.  References #4492.
   */
  void IpceMainWindow::writeSettings(const Project *project) const {
  void IpceMainWindow::writeSettings(Project *project) {

    // Ensure that we are not using a NULL pointer
    if (!project) {
@@ -751,7 +755,7 @@ namespace Isis {
        m_directory->project()->save();
      }
    }
    writeSettings(m_directory->project());
    //writeSettings(m_directory->project());
    m_directory->project()->clear();

    QMainWindow::closeEvent(event);
+3 −1
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ namespace Isis {
   *                           for cleanup because there is no way to get the dock from the view.
   *                           Cleanup connections are made for the views and the docks to ensure
   *                           that cleanup happens for both.  Fixes #5433.
   *   @history 2018-06-13 Tracie Sucharski - Fixed cleanup of views and QDockWidgets. 
   *  
   */
  class IpceMainWindow : public QMainWindow {
@@ -152,6 +153,7 @@ namespace Isis {
      void removeAllViews();

      void readSettings(Project *);
      void writeSettings(Project *project);

    protected:
      void closeEvent(QCloseEvent *event);
@@ -164,6 +166,7 @@ namespace Isis {
      void tabAllViews();

      void raiseWarningTab();
      void cleanupViewDockList(QObject *obj);
    private:
      Q_DISABLE_COPY(IpceMainWindow);

@@ -173,7 +176,6 @@ namespace Isis {
      void createMenus();
      void createToolBars();

      void writeSettings(const Project *project) const;

    private:
      /**
+2 −0
Original line number Diff line number Diff line
@@ -2429,6 +2429,8 @@ namespace Isis {

    directoryStateWriter.writeEndDocument();
    m_isOpen = true;

    emit projectSaved(this);
  }


+13 −2
Original line number Diff line number Diff line
@@ -256,6 +256,17 @@ namespace Isis {
   *  @history 2018-06-06 Kaitlyn Lee - activeControlModified() calls setClean(false) to enable the save
   *                           button when the active control net is modified, i.e. a point is modified.
   *  
   *  !!!!!!!!!!!!!   Delete following history entry when project save/restore geometry/state
   *                   implemented
   *  !!!!!!!!!!!!!!!
   *  @history 2018-06-08 Tracie Sucharski - Quick fix for the project save/restore prototype: The
   *                          changes made to readSettings, writeSettings cause following problem:
   *                          save project with view, close view and exit, the project
   *                          geometry/state is saved on closeEvent instead of project save. Quickly
   *                          added signal when project is saved, so the writeSettings can happen
   *                          for project.  This will be cleaned up when save/restore is fully
   *                          implemented.
   *  
   */
  class Project : public QObject {
    Q_OBJECT
@@ -479,7 +490,7 @@ namespace Isis {
       * Emitted when project is saved.
       *
       */
      void projectSave(FileName projectName);
      void projectSaved(Project *);

      /**
       * Emitted when project location moved