From ef583fec48a06e0d28e2365fb930d1a7f98b6a00 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Wed, 1 Dec 2010 02:47:20 +0100 Subject: [PATCH] fix bug #21 (erroneously exiting the UI when trying to export an image on OSX) --- SConstruct | 7 ------- src/qtgui/mainwindow.cpp | 35 ++++++++++++++++++++++++++--------- src/qtgui/mainwindow.h | 1 + 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/SConstruct b/SConstruct index 619c70dc..580c6d9d 100644 --- a/SConstruct +++ b/SConstruct @@ -24,7 +24,6 @@ vars.Add('CXX', 'C++ compiler') vars.Add('CC', 'C compiler') vars.Add('CXXFLAGS', 'C++ flags') vars.Add('CCFLAGS', 'C compiler flags') -vars.Add('STRIP', 'Program for stripping away unused symbols') vars.Add('SHCXXFLAGS', 'C++ flags (for shared libraries)') vars.Add('LINK', 'Linker') vars.Add('LINKFLAGS', 'Linker flags') @@ -217,18 +216,12 @@ else: env = conf.Finish() dist = GetOption('dist') != None -def stripinst_build_function(self, target, source, pkgname = None, use_own = None): - inst = self.Install(target, source) - self.AddPostAction(inst, env['STRIP'] + ' $TARGET') - return inst - def osxlibinst_build_function(self, target, source, pkgname = None, use_own = None): inst = self.Install(target, source) prefix, name = os.path.split(source) self.AddPostAction(inst, 'install_name_tool -id @executable_path/../Frameworks/' + name + ' $TARGET') return inst -env.__class__.StripInst = stripinst_build_function env.__class__.OSXLibInst = osxlibinst_build_function if hasCollada: diff --git a/src/qtgui/mainwindow.cpp b/src/qtgui/mainwindow.cpp index 951f00ca..4d4e8b43 100644 --- a/src/qtgui/mainwindow.cpp +++ b/src/qtgui/mainwindow.cpp @@ -1206,25 +1206,42 @@ inline float toSRGB(float value) { } void MainWindow::on_actionExportImage_triggered() { - SceneContext *ctx = m_context[ui->tabBar->currentIndex()]; - QFileDialog dialog(this, tr("Export image .."), + QFileDialog *dialog = new QFileDialog(this, tr("Export image .."), "", tr("All supported formats (*.exr *.png);;Linear EXR Image (*.exr)" ";; Tonemapped 8-bit PNG Image (*.png)")); QSettings settings("mitsuba-renderer.org", "qtgui"); - dialog.setViewMode(QFileDialog::Detail); - dialog.setAcceptMode(QFileDialog::AcceptSave); + dialog->setViewMode(QFileDialog::Detail); + dialog->setAcceptMode(QFileDialog::AcceptSave); #if defined(__OSX__) - dialog.setOption(QFileDialog::DontUseNativeDialog, true); + dialog->setOption(QFileDialog::DontUseNativeDialog, true); #endif - dialog.restoreState(settings.value("fileDialogState").toByteArray()); + dialog->restoreState(settings.value("fileDialogState").toByteArray()); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->setWindowModality(Qt::WindowModal); + connect(dialog, SIGNAL(finished(int)), this, SLOT(onExportDialogClose(int))); + m_currentChild = dialog; + // prevent a tab drawing artifact on Qt/OSX + m_activeWindowHack = true; + dialog->show(); + qApp->processEvents(); + m_activeWindowHack = false; +} - if (dialog.exec() == QDialog::Accepted) { - QString fileName = dialog.selectedFiles().value(0); +void MainWindow::onExportDialogClose(int reason) { + int currentIndex = ui->tabBar->currentIndex(); + SceneContext *ctx = m_context[currentIndex]; + + QSettings settings("mitsuba-renderer.org", "qtgui"); + QFileDialog *dialog = static_cast(sender()); + m_currentChild = NULL; + + if (reason == QDialog::Accepted) { + QString fileName = dialog->selectedFiles().value(0); Bitmap::EFileFormat format; - settings.setValue("fileDialogState", dialog.saveState()); + settings.setValue("fileDialogState", dialog->saveState()); if (fileName.endsWith(".exr")) { format = Bitmap::EEXR; diff --git a/src/qtgui/mainwindow.h b/src/qtgui/mainwindow.h index 78850271..977906cc 100644 --- a/src/qtgui/mainwindow.h +++ b/src/qtgui/mainwindow.h @@ -150,6 +150,7 @@ private slots: void onPreviewSettingsClose(); void onOpenDialogClose(int reason); void onSaveAsDialogClose(int reason); + void onExportDialogClose(int reason); void onRenderSettingsClose(int reason); void onImportDialogClose(int reason);