forked from qt-creator/qt-creator
Editor: fix hanging when using invalid printer page rect
Some printer seem to return an empty page rect for some configuration which results in an invalide page count and a freezing ui. Do not print anything and return in that case. Fixes: QTCREATORBUG-24110 Change-Id: I42349bc97734e3f6a67502482d2b02959e865665 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -1164,6 +1164,10 @@ void TextEditorWidgetPrivate::print(QPrinter *printer)
|
||||
if (!p.isActive())
|
||||
return;
|
||||
|
||||
QRectF pageRect(printer->pageRect());
|
||||
if (pageRect.isEmpty())
|
||||
return;
|
||||
|
||||
doc = doc->clone(doc);
|
||||
Utils::ExecuteOnDestruction docDeleter([doc]() { delete doc; });
|
||||
|
||||
@@ -1217,7 +1221,6 @@ void TextEditorWidgetPrivate::print(QPrinter *printer)
|
||||
fmt.setMargin(margin);
|
||||
doc->rootFrame()->setFrameFormat(fmt);
|
||||
|
||||
QRectF pageRect(printer->pageRect());
|
||||
QRectF body = QRectF(0, 0, pageRect.width(), pageRect.height());
|
||||
QFontMetrics fontMetrics(doc->defaultFont(), p.device());
|
||||
|
||||
|
Reference in New Issue
Block a user