summaryrefslogtreecommitdiffstats
path: root/tools/designer/src/lib
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-02-21 08:17:28 (GMT)
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-02-21 08:17:28 (GMT)
commit2525432106823ff3df7f6bb2d44c0a376356a1a8 (patch)
tree17549b4a8161e733b2185b56b018ca08803b19ae /tools/designer/src/lib
parente0a4c25a2276b998bc1514073bbe68d1eefb4345 (diff)
downloadQt-2525432106823ff3df7f6bb2d44c0a376356a1a8.zip
Qt-2525432106823ff3df7f6bb2d44c0a376356a1a8.tar.gz
Qt-2525432106823ff3df7f6bb2d44c0a376356a1a8.tar.bz2
Designer: Check for 0-spacing when loading grid settings.
Task-number: QTBUG-17542
Diffstat (limited to 'tools/designer/src/lib')
-rw-r--r--tools/designer/src/lib/shared/grid.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/tools/designer/src/lib/shared/grid.cpp b/tools/designer/src/lib/shared/grid.cpp
index 6add8bd..ba991c7 100644
--- a/tools/designer/src/lib/shared/grid.cpp
+++ b/tools/designer/src/lib/shared/grid.cpp
@@ -89,12 +89,20 @@ Grid::Grid() :
bool Grid::fromVariantMap(const QVariantMap& vm)
{
- *this = Grid();
- valueFromVariantMap(vm, QLatin1String(KEY_VISIBLE), m_visible);
- valueFromVariantMap(vm, QLatin1String(KEY_SNAPX), m_snapX);
- valueFromVariantMap(vm, QLatin1String(KEY_SNAPY), m_snapY);
- valueFromVariantMap(vm, QLatin1String(KEY_DELTAX), m_deltaX);
- return valueFromVariantMap(vm, QLatin1String(KEY_DELTAY), m_deltaY);
+ Grid grid;
+ bool anyData = valueFromVariantMap(vm, QLatin1String(KEY_VISIBLE), grid.m_visible);
+ anyData |= valueFromVariantMap(vm, QLatin1String(KEY_SNAPX), grid.m_snapX);
+ anyData |= valueFromVariantMap(vm, QLatin1String(KEY_SNAPY), grid.m_snapY);
+ anyData |= valueFromVariantMap(vm, QLatin1String(KEY_DELTAX), grid.m_deltaX);
+ anyData |= valueFromVariantMap(vm, QLatin1String(KEY_DELTAY), grid.m_deltaY);
+ if (!anyData)
+ return false;
+ if (grid.m_deltaX == 0 || grid.m_deltaY == 0) {
+ qWarning("Attempt to set invalid grid with a spacing of 0.");
+ return false;
+ }
+ *this = grid;
+ return true;
}
QVariantMap Grid::toVariantMap(bool forceKeys) const