Bug 120343 - loading non-existing postscript file fails
Summary: loading non-existing postscript file fails
Status: RESOLVED FIXED
Alias: None
Product: kpdf
Classification: Unmaintained
Component: general (show other bugs)
Version: 0.5
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Albert Astals Cid
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-17 20:38 UTC by Tommi Uimonen
Modified: 2006-01-18 22:58 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tommi Uimonen 2006-01-17 20:38:16 UTC
Version:           0.5 (using KDE KDE 3.5.0)
Installed from:    Debian testing/unstable Packages
OS:                Linux

make sure you don't have foo.ps in /tmp and try following:

kpdf /tmp/foo.ps

output is:

Error: /undefinedfilename in (/tmp/foo.ps)
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push
Dictionary stack:
   --dict:1121/1686(ro)(G)--   --dict:0/20(G)--   --dict:80/200(L)--
Current allocation mode is local
Last OS error: 2
ESP Ghostscript 815.01: Unrecoverable error, exit code 1

And blank page opens.

If I try the same with foo.pdf (also non-existing) I get error describing that the file is not found. I should get the same error dialog with the foo.ps file
Comment 1 Albert Astals Cid 2006-01-18 22:58:13 UTC
SVN commit 499855 by aacid:

Make non-exisant ps file loading fail gracefully
BUGS: 120343


 M  +17 -12    part.cpp  


--- branches/KDE/3.5/kdegraphics/kpdf/part.cpp #499854:499855
@@ -362,20 +362,25 @@
         QString app = KStandardDirs::findExe( "ps2pdf" );
         if ( !app.isNull() )
         {
-            KTempFile tf( QString::null, ".pdf" );
-            if ( tf.status() == 0 )
-            {
-                tf.close();
-                m_temporaryLocalFile = tf.name();
+            if ( QFile::exists(m_file) )
+	    {
+                KTempFile tf( QString::null, ".pdf" );
+                if ( tf.status() == 0 )
+                {
+                    tf.close();
+                    m_temporaryLocalFile = tf.name();
 
-                KProcess *p = new KProcess;
-                *p << app;
-                *p << m_file << m_temporaryLocalFile;
-                m_pageView->showText(i18n("Converting from ps to pdf..."), 0);
-                connect(p, SIGNAL(processExited(KProcess *)), this, SLOT(psTransformEnded()));
-                p -> start();
-                return true;
+                    KProcess *p = new KProcess;
+                    *p << app;
+                    *p << m_file << m_temporaryLocalFile;
+                    m_pageView->showText(i18n("Converting from ps to pdf..."), 0);
+                    connect(p, SIGNAL(processExited(KProcess *)), this, SLOT(psTransformEnded()));
+                    p -> start();
+                    return true;
+                }
+                else return false;
             }
+            else return false;
         }
         else
         {