From 06f079e528bf135e5d407b15d1bd50a91ce4a888 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Mon, 25 Jul 2011 15:23:54 +0200 Subject: Reset previousGlyph once we reached a new text item The bug was introduced in fd818312. Before that, previousGlyph is only saved in the same text item. After we moved it to LineBreakHelper struct, it will cause crash if the font engine in the new text item no longer contains the sub engine required by previousGlyph. Task-number: QTBUG-20243 Reviewed-by: Eskil --- src/gui/text/qtextlayout.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 183bcea..01adecf 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1869,6 +1869,7 @@ void QTextLine::layout_helper(int maxGlyphs) lbh.currentPosition = qMax(line.from, current.position); end = current.position + eng->length(item); lbh.glyphs = eng->shapedGlyphs(¤t); + lbh.previousGlyph = 0; QFontEngine *fontEngine = eng->fontEngine(current); if (lbh.fontEngine != fontEngine) { lbh.fontEngine = fontEngine; -- cgit v0.12 From 292656a345e33c332316a676465261c13c9a4aba Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Mon, 25 Jul 2011 16:16:50 +0200 Subject: Fix typo in QFontDialog docs Reviewed-by: TrustMe --- src/gui/dialogs/qfontdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/dialogs/qfontdialog.cpp b/src/gui/dialogs/qfontdialog.cpp index 6a646ff..34b6317 100644 --- a/src/gui/dialogs/qfontdialog.cpp +++ b/src/gui/dialogs/qfontdialog.cpp @@ -160,7 +160,7 @@ QFontDialog::QFontDialog(QWidget *parent) \since 4.5 Constructs a standard font dialog with the given \a parent and specified - \a initial color. + \a initial font. */ QFontDialog::QFontDialog(const QFont &initial, QWidget *parent) : QDialog(*new QFontDialogPrivate, parent, DefaultWindowFlags) -- cgit v0.12 From 91be1263b42a0a91daf3f905661e356e31482fd3 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 26 Jul 2011 13:43:48 +0200 Subject: Fix compilation under OSX 10.7 or using llvm-gcc. Use correct error codes instead of type errors. Thanks to Dylan Luke for this patch. Merge-request: 1304 Reviewed-by: Jiang Jiang --- src/gui/kernel/qcocoasharedwindowmethods_mac_p.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h index 3e8ce4e..a2eb484 100644 --- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h +++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h @@ -327,7 +327,7 @@ QT_END_NAMESPACE QWidget *target = [self dragTargetHitTest:sender]; if (!target) - return [super draggingEntered:sender]; + return NSDragOperationNone; if (target->testAttribute(Qt::WA_DropSiteRegistered) == false) return NSDragOperationNone; @@ -339,7 +339,7 @@ QT_END_NAMESPACE { QWidget *target = [self dragTargetHitTest:sender]; if (!target) - return [super draggingUpdated:sender]; + return NSDragOperationNone; if (target == *currentDragTarget()) { // The drag continues to move over the widget that we have sendt @@ -363,7 +363,7 @@ QT_END_NAMESPACE { QWidget *target = [self dragTargetHitTest:sender]; if (!target) - return [super draggingExited:sender]; + return; if (*currentDragTarget()) { [reinterpret_cast((*currentDragTarget())->winId()) draggingExited:sender]; @@ -375,7 +375,7 @@ QT_END_NAMESPACE { QWidget *target = [self dragTargetHitTest:sender]; if (!target) - return [super performDragOperation:sender]; + return NO; BOOL dropResult = NO; if (*currentDragTarget()) { -- cgit v0.12 From cc500b182e26d53ca16136f24a06a111f4374425 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Wed, 27 Jul 2011 10:42:40 +0200 Subject: Save previous font engine for right bearing adjustment In last fix I forgot that fd818312 was for saving and restoring the right bearing (of last visible glyph) when a LineSeparator was hit (which can have a different font engine but usually not visble), thus we can't reset previousGlyph in that case. To make sure we still get correct right bearing from the font engine used to shape previousGlyph, we need to save that font engine as well. It does make the code more complicated than simply saving the right bearing when a QScriptItem boundary is hit, so hopefully it's an optimization worth to be made (following e1915815). Task-number: QTBUG-20423 Reviewed-by: Eskil --- src/gui/text/qtextlayout.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 01adecf..d180f0e 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1715,6 +1715,7 @@ namespace { QFixed minimumRightBearing; QFontEngine *fontEngine; + QFontEngine *previousFontEngine; const unsigned short *logClusters; bool manualWrap; @@ -1735,12 +1736,19 @@ namespace { return glyphs.glyphs[logClusters[currentPosition - 1]]; } - inline void saveCurrentGlyph() + inline void resetPreviousGlyph() { previousGlyph = 0; + previousFontEngine = 0; + } + + inline void saveCurrentGlyph() + { + resetPreviousGlyph(); if (currentPosition > 0 && logClusters[currentPosition - 1] < glyphs.numGlyphs) { previousGlyph = currentGlyph(); // needed to calculate right bearing later + previousFontEngine = fontEngine; } } @@ -1760,8 +1768,11 @@ namespace { inline void adjustPreviousRightBearing() { - if (previousGlyph > 0) - adjustRightBearing(previousGlyph); + if (previousGlyph > 0 && previousFontEngine) { + qreal rb; + previousFontEngine->getGlyphBearings(previousGlyph, 0, &rb); + rightBearing = qMin(QFixed(), QFixed::fromReal(rb)); + } } inline void resetRightBearing() @@ -1851,7 +1862,7 @@ void QTextLine::layout_helper(int maxGlyphs) lbh.currentPosition = line.from; int end = 0; lbh.logClusters = eng->layoutData->logClustersPtr; - lbh.previousGlyph = 0; + lbh.resetPreviousGlyph(); while (newItem < eng->layoutData->items.size()) { lbh.resetRightBearing(); @@ -1869,7 +1880,6 @@ void QTextLine::layout_helper(int maxGlyphs) lbh.currentPosition = qMax(line.from, current.position); end = current.position + eng->length(item); lbh.glyphs = eng->shapedGlyphs(¤t); - lbh.previousGlyph = 0; QFontEngine *fontEngine = eng->fontEngine(current); if (lbh.fontEngine != fontEngine) { lbh.fontEngine = fontEngine; -- cgit v0.12