From 9982623187c6bb68035ed3634420cfef7026182a Mon Sep 17 00:00:00 2001 From: buliabyak Date: Thu, 12 Jun 2008 17:05:57 +0000 Subject: [PATCH] prevent crashing by not running prefs dialog when in command line mode --- src/extension/internal/pdfinput/pdf-input.cpp | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index 1de74541b..e34c76cb1 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -36,6 +36,7 @@ #include "pdf-parser.h" #include "document-private.h" +#include "application/application.h" #include "dialogs/dialog-events.h" #include @@ -626,16 +627,23 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { return NULL; } - PdfImportDialog *dlg = new PdfImportDialog(pdf_doc, uri); - if (!dlg->showDialog()) { - delete dlg; - delete pdf_doc; - return NULL; + PdfImportDialog *dlg = NULL; + if (Inkscape::NSApplication::Application::getUseGui()) { + dlg = new PdfImportDialog(pdf_doc, uri); + if (!dlg->showDialog()) { + delete dlg; + delete pdf_doc; + return NULL; + } } // Get needed page - int page_num = dlg->getSelectedPage(); + int page_num; + if (dlg) + page_num = dlg->getSelectedPage(); + else + page_num = 1; Catalog *catalog = pdf_doc->getCatalog(); Page *page = catalog->getPage(page_num); @@ -653,7 +661,8 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { // Get preferences Inkscape::XML::Node *prefs = builder->getPreferences(); - dlg->getImportSettings(prefs); + if (dlg) + dlg->getImportSettings(prefs); // Apply crop settings PDFRectangle *clipToBox = NULL; -- 2.30.2