Commit 86942f09 authored by Pino Toscano's avatar Pino Toscano

- open the temporary file name only after any option is set to it (fix crash...

- open the temporary file name only after any option is set to it (fix crash when asking to print to pdf)
- close the file before sending it for printing, so we can be sure it is written as a whole

svn path=/trunk/KDE/kdegraphics/okular/; revision=899239
parent 211f082f
......@@ -107,8 +107,6 @@ bool GSGenerator::print( QPrinter& printer )
// Create tempfile to write to
KTemporaryFile tf;
tf.setSuffix( ".ps" );
if ( !tf.open() )
return false;
// Get list of pages to print
QList<int> pageList = Okular::FilePrinter::pageList( printer,
......@@ -123,6 +121,9 @@ bool GSGenerator::print( QPrinter& printer )
tf.setSuffix(".pdf");
}
if ( !tf.open() )
return false;
SpectreExporter *exporter = spectre_exporter_new( m_internalDocument, exportFormat );
SpectreStatus exportStatus = spectre_exporter_begin( exporter, tf.fileName().toAscii() );
......@@ -137,18 +138,19 @@ bool GSGenerator::print( QPrinter& printer )
spectre_exporter_free( exporter );
const QString fileName = tf.fileName();
tf.close();
if ( exportStatus == SPECTRE_STATUS_SUCCESS && endStatus == SPECTRE_STATUS_SUCCESS )
{
tf.setAutoRemove( false );
int ret = Okular::FilePrinter::printFile( printer, tf.fileName(),
int ret = Okular::FilePrinter::printFile( printer, fileName,
Okular::FilePrinter::SystemDeletesFiles,
Okular::FilePrinter::ApplicationSelectsPages,
document()->bookmarkedPageRange() );
if ( ret >= 0 ) result = true;
}
tf.close();
return result;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment