diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-02-21 09:17:28 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-02-21 09:17:28 +0100 |
commit | 2525432106823ff3df7f6bb2d44c0a376356a1a8 (patch) | |
tree | 17549b4a8161e733b2185b56b018ca08803b19ae /tools/designer/src | |
parent | e0a4c25a2276b998bc1514073bbe68d1eefb4345 (diff) | |
download | qt4-tools-2525432106823ff3df7f6bb2d44c0a376356a1a8.tar.gz |
Designer: Check for 0-spacing when loading grid settings.
Task-number: QTBUG-17542
Diffstat (limited to 'tools/designer/src')
-rw-r--r-- | tools/designer/src/lib/shared/grid.cpp | 20 |
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 6add8bd2d8..ba991c782d 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 |