diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qscopedpointer.cpp | 4 | ||||
-rw-r--r-- | src/gui/text/qtextdocument.cpp | 9 |
2 files changed, 5 insertions, 8 deletions
diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp index e7dd769..b06112d 100644 --- a/src/corelib/tools/qscopedpointer.cpp +++ b/src/corelib/tools/qscopedpointer.cpp @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE called resource acquisition is initialization(RAII). QScopedPointer guarantees that the object pointed to will get deleted when - the current scope dissapears. + the current scope disappears. Consider this function which does heap allocations, and have various exit points: @@ -227,7 +227,7 @@ QT_BEGIN_NAMESPACE /*! \class QScopedArrayPointer - + \brief The QScopedArrayPointer class stores a pointer to a dynamically allocated array of objects, and deletes it upon destruction. diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index f5d322a..1677ee6 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1679,7 +1679,7 @@ void QTextDocument::print(QPrinter *printer) const return; const QTextDocument *doc = this; - QTextDocument *clonedDoc = 0; + QScopedPointer<QTextDocument> clonedDoc; (void)doc->documentLayout(); // make sure that there is a layout QRectF body = QRectF(QPointF(0, 0), d->pageSize); @@ -1712,7 +1712,7 @@ void QTextDocument::print(QPrinter *printer) const printerPageSize.height() / scaledPageSize.height()); } else { doc = clone(const_cast<QTextDocument *>(this)); - clonedDoc = const_cast<QTextDocument *>(doc); + clonedDoc.reset(const_cast<QTextDocument *>(doc)); for (QTextBlock srcBlock = firstBlock(), dstBlock = clonedDoc->firstBlock(); srcBlock.isValid() && dstBlock.isValid(); @@ -1787,7 +1787,7 @@ void QTextDocument::print(QPrinter *printer) const for (int j = 0; j < pageCopies; ++j) { if (printer->printerState() == QPrinter::Aborted || printer->printerState() == QPrinter::Error) - goto UserCanceled; + return; printPage(page, &p, doc, body, pageNumberPos); if (j < pageCopies - 1) printer->newPage(); @@ -1807,9 +1807,6 @@ void QTextDocument::print(QPrinter *printer) const if ( i < docCopies - 1) printer->newPage(); } - -UserCanceled: - delete clonedDoc; } #endif |