diff options
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qfont.cpp | 24 | ||||
-rw-r--r-- | src/gui/text/qfont.h | 4 | ||||
-rw-r--r-- | src/gui/text/qtextdocument_p.cpp | 42 | ||||
-rw-r--r-- | src/gui/text/qtextdocument_p.h | 4 |
4 files changed, 37 insertions, 37 deletions
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 96905d0f7..3443a6479 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -217,7 +217,6 @@ QFontPrivate::QFontPrivate() rawMode(false), underline(false), overline(false), strikeOut(false), kerning(true), capital(0), letterSpacingIsAbsolute(false), scFont(0) { - ref = 1; #ifdef Q_WS_X11 if (QX11Info::display()) screen = QX11Info::appScreen(); @@ -237,7 +236,6 @@ QFontPrivate::QFontPrivate(const QFontPrivate &other) letterSpacing(other.letterSpacing), wordSpacing(other.wordSpacing), scFont(other.scFont) { - ref = 1; #ifdef Q_WS_WIN hdc = other.hdc; #endif @@ -721,11 +719,11 @@ QFont::QFont(const QFont &font, QPaintDevice *pd) const int screen = 0; #endif if (font.d->dpi != dpi || font.d->screen != screen ) { - d.reset(new QFontPrivate(*font.d)); + d = new QFontPrivate(*font.d); d->dpi = dpi; d->screen = screen; } else { - d.assign(font.d.data()); + d = font.d.data(); } #ifdef Q_WS_WIN if (pd->devType() == QInternal::Printer && pd->getDC()) @@ -737,9 +735,8 @@ QFont::QFont(const QFont &font, QPaintDevice *pd) \internal */ QFont::QFont(QFontPrivate *data) - : resolve_mask(QFont::AllPropertiesResolved) + : d(data), resolve_mask(QFont::AllPropertiesResolved) { - d.assign(data); } /*! \internal @@ -766,9 +763,8 @@ void QFont::detach() \sa QApplication::setFont(), QApplication::font() */ QFont::QFont() - :resolve_mask(0) + : d(QApplication::font().d.data()), resolve_mask(0) { - d.assign(QApplication::font().d.data()); } /*! @@ -790,10 +786,8 @@ QFont::QFont() setStyleHint() QApplication::font() */ QFont::QFont(const QString &family, int pointSize, int weight, bool italic) + : d(new QFontPrivate()), resolve_mask(QFont::FamilyResolved) { - d.reset(new QFontPrivate()); - resolve_mask = QFont::FamilyResolved; - if (pointSize <= 0) { #ifdef Q_OS_SYMBIAN pointSize = 7; @@ -821,9 +815,8 @@ QFont::QFont(const QString &family, int pointSize, int weight, bool italic) Constructs a font that is a copy of \a font. */ QFont::QFont(const QFont &font) + : d(font.d.data()), resolve_mask(font.resolve_mask) { - d.assign(font.d.data()); - resolve_mask = font.resolve_mask; } /*! @@ -838,7 +831,7 @@ QFont::~QFont() */ QFont &QFont::operator=(const QFont &font) { - d.assign(font.d.data()); + d = font.d.data(); resolve_mask = font.resolve_mask; return *this; } @@ -2197,8 +2190,7 @@ QDataStream &operator<<(QDataStream &s, const QFont &font) */ QDataStream &operator>>(QDataStream &s, QFont &font) { - font.d.assign(0); - font.d.reset(new QFontPrivate); + font.d = new QFontPrivate; font.resolve_mask = QFont::AllPropertiesResolved; quint8 styleHint, styleStrategy = QFont::PreferDefault, charSet, weight, bits; diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index 10ec0628b..e91e0176d 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -44,7 +44,7 @@ #include <QtGui/qwindowdefs.h> #include <QtCore/qstring.h> -#include <QtCore/qscopedpointer.h> +#include <QtCore/qsharedpointer.h> #if defined(Q_WS_X11) || defined(Q_WS_QWS) typedef struct FT_FaceRec_* FT_Face; @@ -313,7 +313,7 @@ private: friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QFont &); #endif - QScopedSharedPointer<QFontPrivate> d; + QExplicitlySharedDataPointer<QFontPrivate> d; uint resolve_mask; }; diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index a4dee6a3a..dec44ab26 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -63,10 +63,10 @@ QT_BEGIN_NAMESPACE // The VxWorks DIAB compiler crashes when initializing the anonymouse union with { a7 } #if !defined(Q_CC_DIAB) # define QT_INIT_TEXTUNDOCOMMAND(c, a1, a2, a3, a4, a5, a6, a7, a8) \ - QTextUndoCommand c = { a1, a2, a3, a4, a5, a6, { a7 }, a8 } + QTextUndoCommand c = { a1, a2, 0, 0, a3, a4, a5, a6, { a7 }, a8 } #else # define QT_INIT_TEXTUNDOCOMMAND(c, a1, a2, a3, a4, a5, a6, a7, a8) \ - QTextUndoCommand c = { a1, a2, a3, a4, a5, a6 }; c.blockFormat = a7; c.revision = a8 + QTextUndoCommand c = { a1, a2, 0, 0, a3, a4, a5, a6 }; c.blockFormat = a7; c.revision = a8 #endif /* @@ -967,14 +967,18 @@ int QTextDocumentPrivate::undoRedo(bool undo) B->revision = c.revision; } - if (undo) { - if (undoState == 0 || !undoStack[undoState-1].block) - break; - } else { + if (!undo) ++undoState; - if (undoState == undoStack.size() || !undoStack[undoState-1].block) - break; - } + + bool inBlock = ( + undoState > 0 + && undoState < undoStack.size() + && undoStack[undoState].block_part + && undoStack[undoState-1].block_part + && !undoStack[undoState-1].block_end + ); + if (!inBlock) + break; } undoEnabled = true; int editPos = -1; @@ -999,7 +1003,8 @@ void QTextDocumentPrivate::appendUndoItem(QAbstractUndoItem *item) QTextUndoCommand c; c.command = QTextUndoCommand::Custom; - c.block = editBlock != 0; + c.block_part = editBlock != 0; + c.block_end = 0; c.operation = QTextUndoCommand::MoveCursor; c.format = 0; c.strPos = 0; @@ -1020,9 +1025,10 @@ void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c) if (!undoStack.isEmpty() && modified) { QTextUndoCommand &last = undoStack[undoState - 1]; - if ( (last.block && c.block) // part of the same block => can merge - || (!c.block && !last.block // two single undo items => can merge - && (undoState < 2 || !undoStack[undoState-2].block))) { + + if ( (last.block_part && c.block_part && !last.block_end) // part of the same block => can merge + || (!c.block_part && !last.block_part)) { // two single undo items => can merge + if (last.tryMerge(c)) return; } @@ -1034,7 +1040,7 @@ void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c) emitUndoAvailable(true); emitRedoAvailable(false); - if (!c.block) + if (!c.block_part) emit document()->undoCommandAdded(); } @@ -1100,7 +1106,7 @@ void QTextDocumentPrivate::joinPreviousEditBlock() beginEditBlock(); if (undoEnabled && undoState) - undoStack[undoState - 1].block = true; + undoStack[undoState - 1].block_end = false; } void QTextDocumentPrivate::endEditBlock() @@ -1109,10 +1115,10 @@ void QTextDocumentPrivate::endEditBlock() return; if (undoEnabled && undoState > 0) { - const bool wasBlocking = undoStack[undoState - 1].block; - undoStack[undoState - 1].block = false; - if (wasBlocking) + if (undoStack[undoState - 1].block_part) { + undoStack[undoState - 1].block_end = true; emit document()->undoCommandAdded(); + } } finishEdit(); diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index 55aa17eec..363309cdb 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -139,7 +139,9 @@ public: MoveCursor = 1 }; quint16 command; - quint8 block; ///< All undo commands that have this set to true are combined with the preceding command on undo/redo. + uint block_part : 1; // all commands that are part of an undo block (including the first and the last one) have this set to 1 + uint block_end : 1; // the last command in an undo block has this set to 1. + uint block_padding : 6; // padding since block used to be a quint8 quint8 operation; int format; quint32 strPos; |