skip invalid data on reading project frame bounds

This commit is contained in:
Vladimir Krivosheev
2017-11-15 14:05:08 +01:00
parent b90e8a567a
commit 4daad1ce37
2 changed files with 9 additions and 38 deletions
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.wm.impl
import com.intellij.openapi.components.*
@@ -104,9 +90,11 @@ fun serializeBounds(bounds: Rectangle, element: Element) {
fun deserializeBounds(element: Element): Rectangle? {
try {
return Rectangle(
element.getAttributeValue(X_ATTR).toInt(), element.getAttributeValue(Y_ATTR).toInt(),
element.getAttributeValue(WIDTH_ATTR).toInt(), element.getAttributeValue(HEIGHT_ATTR).toInt())
val x = element.getAttributeValue(X_ATTR)?.toInt() ?: return null
val y = element.getAttributeValue(Y_ATTR)?.toInt() ?: return null
val w = element.getAttributeValue(WIDTH_ATTR)?.toInt() ?: return null
val h = element.getAttributeValue(HEIGHT_ATTR)?.toInt() ?: return null
return Rectangle(x, y, w, h)
}
catch (ignored: NumberFormatException) {
return null
@@ -1,22 +1,9 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.wm.impl;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.JDOMExternalizable;
import com.intellij.openapi.util.text.StringUtilRt;
import com.intellij.openapi.wm.*;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
@@ -292,11 +279,7 @@ public final class WindowInfoImpl implements Cloneable, JDOMExternalizable, Wind
}
catch (NumberFormatException ignored) {
}
try {
myOrder = Integer.parseInt(element.getAttributeValue(ORDER_ATTR));
}
catch (NumberFormatException ignored) {
}
myOrder = StringUtilRt.parseInt(element.getAttributeValue(ORDER_ATTR), myOrder);
myFloatingBounds = ProjectFrameBoundsKt.deserializeBounds(element);
mySplitMode = Boolean.parseBoolean(element.getAttributeValue(SIDE_TOOL_ATTR));