Skip to content

#14511 Activate 3D view after importing grid model from summary case - #14604

Open
magnesj wants to merge 1 commit into
OPM:devfrom
magnesj:claude/14511-activate-3d-view-after-grid-import
Open

#14511 Activate 3D view after importing grid model from summary case#14604
magnesj wants to merge 1 commit into
OPM:devfrom
magnesj:claude/14511-activate-3d-view-after-grid-import

Conversation

@magnesj

@magnesj magnesj commented Aug 25, 2026

Copy link
Copy Markdown
Member

Fixes #14511

When importing a grid model from a Summary Case (or from an individual realization of an Ensemble Summary Case), the 3D view was created but stayed in the background — focus remained on the summary plot window.

RimReloadCaseTools::openOrImportGridModelFromSummaryCase() had two paths. The "grid already imported" path activated the first view, but the "import from file" path returned right after openEclipseCaseFromFile() without activating anything. In addition, RicShowMainWindowFeature::showMainWindow() only does show()/raise(), which is not enough to get the 3D window in front of the plot window.

Changes:

  • Raise the 3D window using QApplication::processEvents() followed by RiuMainWindow::activateWindow(), the same pattern already used in RiaImportEclipseCaseTools::openEclipseFilesFromFileNames().

The import path in openOrImportGridModelFromSummaryCase() returned right
after opening the Eclipse case, leaving the newly created 3D view in the
background while focus stayed on the summary plot window.

Extract the activation into a shared activateFirstView() helper, and use
processEvents() followed by activateWindow() to raise the 3D window on top
of the plot window, matching the pattern already used in
RiaImportEclipseCaseTools::openEclipseFilesFromFileNames().
@magnesj
magnesj requested a review from kriben August 26, 2026 12:23

@kriben kriben left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of QApplication::processEvents(). Official docs says use is discouraged: https://doc.qt.io/qt-6/qcoreapplication.html#processEvents

Comment on lines +281 to +288
if ( RiaGuiApplication::isRunning() && RiuMainWindow::instance() )
{
// Call process events to clear the queue. This makes sure that we are able to raise the 3D window on top of the
// plot window. Otherwise the event processing ends up with the plot window on top.
QApplication::processEvents();
RiuMainWindow::instance()->activateWindow();
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QApplication::processEvents() introduces a nested event loop and can execute unrelated UI actions, including closing/deleting the main window, before the following activateWindow() call.

Prefer deferred activation:

  auto* mainWindow = RiuMainWindow::instance();                                                                                                                                                                                                               
  if ( RiaGuiApplication::isRunning() && mainWindow )                                                                                                                                                                                                         
  {                                                                                                                                                                                                                                                           
      QTimer::singleShot( 0,                                                                                                                                                                                                                                  
                          mainWindow,                                                                                                                                                                                                                         
                          [mainWindow]()                                                                                                                                                                                                                      
                          {                                                                                                                                                                                                                                   
                              mainWindow->raise();                                                                                                                                                                                                            
                              mainWindow->activateWindow();                                                                                                                                                                                                   
                          } );                                                                                                                                                                                                                                
  }                                                                                                                                                                                                                                                           

Using mainWindow as the timer context cancels the callback if it is destroyed. It also lets pending show/window events finish without reentrant processing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatically switch focus to 3D View after importing a grid model from Summary Cases

2 participants