Bug 69725 - kword printing to pdf crashes if filename contains a blank
Summary: kword printing to pdf crashes if filename contains a blank
Status: CLOSED FIXED
Alias: None
Product: kdeprint
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Michael Goffioul
URL:
Keywords:
: 71259 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-12-06 14:26 UTC by Ferdinand Gassauer
Modified: 2008-12-31 13:25 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ferdinand Gassauer 2003-12-06 14:26:02 UTC
Version:           1.2.94 (using KDE 3.1.94 (3.2 Beta 2), compiled sources)
Compiler:          gcc version 3.3.1 (SuSE Linux)
OS:          Linux (i686) release 2.4.21-144-default

A print error occurred. Error message received from system:

gs -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$out{/d2/dokumente/ASP/test**** Unable to open the initial device, quitting. 0test.pdf} -sPAPERSIZE=a4 -c .setpdfwrite -f '/tmp/kde-gassauer/kdeprint_1xFjwAxc' : execution failed with message:
%2

may be this belongs to kprint ?
cu
ferdinand
Comment 1 Nicolas Goutte 2003-12-06 21:31:27 UTC
Can you try it from another KDE application, please?
Comment 2 Ferdinand Gassauer 2003-12-06 22:25:21 UTC
Subject: Re:  kword printing to pdf crashes if filename contains a blank

> ------- Can you try it from another KDE application, please?
I could not reproduce this error with kspread nor with kedit, I guess it has 
something to to with the rename option if trying to print to the same file 
name
it seems never to happen if this filename contains no blanks
but all of this is very vague
not very much help :-(
Comment 3 Nicolas Goutte 2003-12-26 21:32:31 UTC
See also bug #71259 (not sure if it is a duplicate or not)
Comment 4 Nicolas Goutte 2004-02-20 17:52:57 UTC
Looking again at this bug, I really think that it is a kdeprint problem.

What I find curious is that the error message "**** Unable to open the initial device, quitting" seems to be in the middle of the file name but that the error is simply "%2".

Have a nice day!
Comment 5 Michael Goffioul 2004-02-24 13:57:24 UTC
It happens when printing twice with the same file name containing a space. The first time, the user enters the filename and it works OK. The second time, the print dialog contains the already filled-in filename, but it's encoded and the space char is replaced by %20, which leads to an error when "gs" is invoked for the PDF conversion.

The strange message in the middle of the command line simply comes from the fact that this message is generated using QString(...).args() construction, and that the string now contains the tag "%2" (the char '0' is ignored) which is replaced by the actual system error message. What happens is the following:

QString("gs... -sOutputFile=...test%20test.pdf ...: %1").arg("*** Unable...")

The error message is replaced at the garbage "%2" instead of the wanted "%1" tag.

Comment 6 Michael Goffioul 2004-02-24 14:42:00 UTC
*** Bug 71259 has been marked as a duplicate of this bug. ***
Comment 7 Michael Goffioul 2004-02-24 16:41:53 UTC
CVS commit by goffioul: 

Fix encoding error when updating output filename
CCMAIL: 69725-done@bugs.kde.org


  M +9 -8      kprintdialog.cpp   1.77


--- kdelibs/kdeprint/kprintdialog.cpp  #1.76:1.77
@@ -569,7 +569,7 @@ void KPrintDialog::initialize(KPrinter *
         // Initialize output filename
         if (!d->m_printer->outputFileName().isEmpty())
-                d->m_file->lineEdit()->setText(d->m_printer->outputFileName());
+                d->m_file->setURL( d->m_printer->outputFileName() );
         else if (!d->m_printer->docFileName().isEmpty())
-                d->m_file->lineEdit()->setText(d->m_printer->docDirectory()+"/"+d->m_printer->docFileName()+".ps");
+                d->m_file->setURL( d->m_printer->docDirectory()+"/"+d->m_printer->docFileName()+".ps" );
 
         if ( d->m_printers->count() > 0 )
@@ -661,5 +661,6 @@ void KPrintDialog::done(int result)
                         if (!checkOutputFile()) return;
                         d->m_printer->setOutputToFile(true);
-                        d->m_printer->setOutputFileName(d->m_file->lineEdit()->text());
+                        /* be sure to decode the output filename */
+                        d->m_printer->setOutputFileName( KURL::decode_string( d->m_file->url() ) );
                 }
                 else
@@ -692,5 +693,5 @@ bool KPrintDialog::checkOutputFile()
 {
         bool    value(false);
-        if (d->m_file->lineEdit()->text().isEmpty())
+        if (d->m_file->url().isEmpty())
                 KMessageBox::error(this,i18n("The output filename is empty."));
         else
@@ -711,5 +712,5 @@ bool KPrintDialog::checkOutputFile()
                                 //value = (KMessageBox::warningYesNo(this,i18n("File \"%1\" already exists. Overwrite?").arg(f.absFilePath())) == KMessageBox::Yes);
                                 time_t mtimeDest = f.lastModified().toTime_t();
-                                KIO::RenameDlg dlg( this, i18n( "Print" ), QString::null, d->m_file->lineEdit()->text(),
+                                KIO::RenameDlg dlg( this, i18n( "Print" ), QString::null, d->m_file->url(),
                                                 KIO::M_OVERWRITE, ( time_t ) -1, f.size(), ( time_t ) -1, f.created().toTime_t() , mtimeDest+1, mtimeDest, true );
                                 int result = dlg.exec();
@@ -725,5 +726,5 @@ bool KPrintDialog::checkOutputFile()
                                         case KIO::R_RENAME:
                                                 url = dlg.newDestURL();
-                                                d->m_file->lineEdit()->setText( url.path() );
+                                                d->m_file->setURL( url.path() );
                                                 value = true;
                                                 anotherCheck = true;
@@ -786,5 +787,5 @@ void KPrintDialog::setOutputFileExtensio
                 {
                         url.setFileName( f.left( p ) + "." + ext );
-                        d->m_file->setURL( url.url() );
+                        d->m_file->setURL( KURL::decode_string( url.url() ) );
                 }
         }
@@ -892,5 +893,5 @@ void KPrintDialog::slotHelp()
 void KPrintDialog::slotOutputFileSelected(const QString& txt)
 {
-        d->m_file->lineEdit()->setText(txt);
+        d->m_file->setURL( txt );
 }
 


Comment 8 John Layt 2008-12-31 13:25:11 UTC
Closing old Resolved status bug.