OSDN Git Service

remove pre 4.3 layout restoration code
authorIvailo Monev <xakepa10@laimg.moc>
Wed, 29 May 2019 22:12:55 +0000 (22:12 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Wed, 29 May 2019 22:12:55 +0000 (22:12 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/gui/image/qpixmap.h
src/gui/widgets/qmainwindowlayout.cpp
src/gui/widgets/qmainwindowlayout_p.h
src/gui/widgets/qtoolbararealayout.cpp
src/gui/widgets/qtoolbararealayout_p.h

index f6b0e68..5554db8 100644 (file)
@@ -175,7 +175,6 @@ public:
 protected:
     int metric(PaintDeviceMetric) const;
 
-
 private:
     QExplicitlySharedDataPointer<QPixmapData> data;
 
index dfa4239..ff54e8e 100644 (file)
@@ -611,12 +611,8 @@ static QList<T> findChildrenHelper(const QObject *o)
     return result;
 }
 
-//pre4.3 tests the format that was used before 4.3
-bool QMainWindowLayoutState::checkFormat(QDataStream &stream, bool pre43)
+bool QMainWindowLayoutState::checkFormat(QDataStream &stream)
 {
-#ifdef QT_NO_TOOLBAR
-    Q_UNUSED(pre43);
-#endif
     while (!stream.atEnd()) {
         uchar marker;
         stream >> marker;
@@ -628,7 +624,7 @@ bool QMainWindowLayoutState::checkFormat(QDataStream &stream, bool pre43)
                 {
                     QList<QToolBar *> toolBars = findChildrenHelper<QToolBar*>(mainWindow);
                     if (!toolBarAreaLayout.restoreState(stream, toolBars, marker,
-                        pre43 /*testing 4.3 format*/, true /*testing*/)) {
+                        true /*testing*/)) {
                             return false;
                     }
                 }
@@ -669,13 +665,8 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
     }
 
     QDataStream ds(copy);
-    const bool oldFormat = !checkFormat(ds, false);
-    if (oldFormat) {
-        //we should try with the old format
-        QDataStream ds2(copy);
-        if (!checkFormat(ds2, true)) {
-            return false; //format unknown
-        }
+    if (!checkFormat(ds)) {
+        return false; //format unknown
     }
 
     QDataStream stream(copy);
@@ -716,7 +707,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
             case QToolBarAreaLayout::ToolBarStateMarkerEx:
                 {
                     QList<QToolBar *> toolBars = findChildrenHelper<QToolBar*>(mainWindow);
-                    if (!toolBarAreaLayout.restoreState(stream, toolBars, marker, oldFormat))
+                    if (!toolBarAreaLayout.restoreState(stream, toolBars, marker))
                         return false;
 
                     for (int i = 0; i < toolBars.size(); ++i) {
@@ -1474,7 +1465,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
 #ifndef QT_NO_TOOLBAR
     if (QToolBar *tb = qobject_cast<QToolBar*>(widget)) {
         QToolBarLayout *tbl = qobject_cast<QToolBarLayout*>(tb->layout());
-        if (tbl->animating) {
+        if (tbl && tbl->animating) {
             tbl->animating = false;
             if (tbl->expanded)
                 tbl->layoutActions(tb->size());
@@ -1503,7 +1494,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
 
 #ifndef QT_NO_DOCKWIDGET
 #ifndef QT_NO_TABBAR
-        if (qobject_cast<QDockWidget*>(widget) != 0) {
+        if (qobject_cast<QDockWidget*>(widget)) {
             // info() might return null if the widget is destroyed while
             // animating but before the animationFinished signal is received.
             if (QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(widget))
index cdb24cc..0dae6b1 100644 (file)
@@ -138,7 +138,7 @@ public:
     QLayoutItem *unplug(const QList<int> &path, QMainWindowLayoutState *savedState = 0);
 
     void saveState(QDataStream &stream) const;
-    bool checkFormat(QDataStream &stream, bool pre43);
+    bool checkFormat(QDataStream &stream);
     bool restoreState(QDataStream &stream, const QMainWindowLayoutState &oldState);
 };
 
index 9e28642..7b85d55 100644 (file)
@@ -1291,21 +1291,15 @@ void QToolBarAreaLayout::saveState(QDataStream &stream) const
     }
 }
 
-static inline int getInt(QDataStream &stream, Qt::Orientation o, bool pre43)
+static inline int getInt(QDataStream &stream)
 {
-    if (pre43) {
-        QPoint p;
-        stream >> p;
-        return pick(o, p);
-    } else {
-        int x;
-        stream >> x;
-        return x;
-    }
+    int x;
+    stream >> x;
+    return x;
 }
 
 
-bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*> &_toolBars, uchar tmarker, bool pre43, bool testing)
+bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*> &_toolBars, uchar tmarker, bool testing)
 {
     QList<QToolBar*> toolBars = _toolBars;
     int lines;
@@ -1330,8 +1324,8 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
             stream >> objectName;
             uchar shown;
             stream >> shown;
-            item.pos = getInt(stream, dock.o, pre43);
-            item.size = getInt(stream, dock.o, pre43);
+            item.pos = getInt(stream);
+            item.size = getInt(stream);
 
             /*
                4.3.0 added floating toolbars, but failed to add the ability to restore them.
@@ -1344,9 +1338,9 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
             QRect rect;
             bool floating = false;
             uint geom0, geom1;
-            geom0 = getInt(stream, dock.o, pre43);
+            geom0 = getInt(stream);
             if (tmarker == ToolBarStateMarkerEx) {
-                geom1 = getInt(stream, dock.o, pre43);
+                geom1 = getInt(stream);
                 rect = unpackRect(geom0, geom1, &floating);
             }
 
index 9629ba6..0c0c4f1 100644 (file)
@@ -238,7 +238,7 @@ public:
     QLayoutItem *unplug(const QList<int> &path, QToolBarAreaLayout *other);
 
     void saveState(QDataStream &stream) const;
-    bool restoreState(QDataStream &stream, const QList<QToolBar*> &toolBars, uchar tmarker, bool pre43, bool testing = false);
+    bool restoreState(QDataStream &stream, const QList<QToolBar*> &toolBars, uchar tmarker, bool testing = false);
     bool isEmpty() const;
 };