#1379 Get active view window before displaying file selection dialog

This commit is contained in:
Magne Sjaastad 2017-04-06 10:38:20 +02:00
parent 380de17ae0
commit 6b78d98a74

View File

@ -19,6 +19,7 @@
#include "RicSnapshotViewToClipboardFeature.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
@ -119,6 +120,17 @@ void RicSnapshotViewToFileFeature::onActionTriggered(bool isChecked)
RiaApplication* app = RiaApplication::instance();
RimProject* proj = app->project();
// Get active view window before displaying the file selection dialog
// If this is done after the file save dialog is displayed (and closed)
// app->activeViewWindow() returns NULL on Linux
RimViewWindow* viewWindow = app->activeViewWindow();
if (!viewWindow)
{
RiaLogging::error("No view window is available, nothing to do");
return;
}
QString startPath;
if (!proj->fileName().isEmpty())
{
@ -141,7 +153,6 @@ void RicSnapshotViewToFileFeature::onActionTriggered(bool isChecked)
// Remember the directory to next time
app->setLastUsedDialogDirectory("IMAGE_SNAPSHOT", QFileInfo(fileName).absolutePath());
RimViewWindow* viewWindow = app->activeViewWindow();
RicSnapshotViewToFileFeature::saveSnapshotAs(fileName, viewWindow);
}