Fix print to a printer instance

Make sure to use the printer original name as 'cupsPrintFile' function
argument

Testing:
- Create a instance of your print with lpoptions
- Try print a document using the new instance of the printer
- Check if the instance properties was respected

Change-Id: I884b641d1871fe04c7b119c82d4edb4aa41db2f5
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
bb10
Renato Araujo Oliveira Filho 2017-12-19 09:24:51 -03:00
parent 7951d1cdfa
commit 7fd5fe17c2
1 changed files with 5 additions and 2 deletions

View File

@ -239,9 +239,12 @@ void QCupsPrintEnginePrivate::closePrintDevice()
cupsOptStruct.append(opt);
}
// Print the file.
// Print the file
// Cups expect the printer original name without instance, the full name is used only to retrieve the configuration
const auto parts = printerName.splitRef(QLatin1Char('/'));
const auto printerOriginalName = parts.at(0);
cups_option_t* optPtr = cupsOptStruct.size() ? &cupsOptStruct.first() : 0;
cupsPrintFile(printerName.toLocal8Bit().constData(), tempFile.toLocal8Bit().constData(),
cupsPrintFile(printerOriginalName.toLocal8Bit().constData(), tempFile.toLocal8Bit().constData(),
title.toLocal8Bit().constData(), cupsOptStruct.size(), optPtr);
QFile::remove(tempFile);