Fix potential memory leak.

This commit is contained in:
Roman Telezhynskyi 2021-05-04 09:21:34 +03:00
parent ca20519fa7
commit c61087ed5d

View File

@ -765,7 +765,7 @@ void VPMainWindow::generateTiledPdf(QString fileName)
PageOrientation tilesOrientation = m_layout->GetTilesOrientation(); PageOrientation tilesOrientation = m_layout->GetTilesOrientation();
// ------------- Set up the printer // ------------- Set up the printer
QPrinter* printer = new QPrinter(); auto printer = QScopedPointer<QPrinter>(new QPrinter());
printer->setCreator(QGuiApplication::applicationDisplayName()+QChar(QChar::Space)+ printer->setCreator(QGuiApplication::applicationDisplayName()+QChar(QChar::Space)+
QCoreApplication::applicationVersion()); QCoreApplication::applicationVersion());
@ -788,7 +788,7 @@ void VPMainWindow::generateTiledPdf(QString fileName)
// ------------- Set up the painter // ------------- Set up the painter
QPainter painter; QPainter painter;
if (not painter.begin(printer)) if (not painter.begin(printer.data()))
{ // failed to open file { // failed to open file
qCritical() << tr("Failed to open file, is it writable?"); qCritical() << tr("Failed to open file, is it writable?");
return; return;