Code

prevent crashing by not running prefs dialog when in command line mode
authorbuliabyak <buliabyak@users.sourceforge.net>
Thu, 12 Jun 2008 17:05:57 +0000 (17:05 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Thu, 12 Jun 2008 17:05:57 +0000 (17:05 +0000)
src/extension/internal/pdfinput/pdf-input.cpp

index 1de74541bb6e2f6013a5cb7757687fca420a1a14..e34c76cb1e84330ad990e0c1421376f6fbd836d0 100644 (file)
@@ -36,6 +36,7 @@
 #include "pdf-parser.h"
 
 #include "document-private.h"
+#include "application/application.h"
 
 #include "dialogs/dialog-events.h"
 #include <gtk/gtkdialog.h>
@@ -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;