From 4daad1ce37017ea5a5b4bbeb3013bf63ee50b1d3 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 15 Nov 2017 14:00:46 +0100 Subject: [PATCH] skip invalid data on reading project frame bounds --- .../openapi/wm/impl/ProjectFrameBounds.kt | 24 +++++-------------- .../openapi/wm/impl/WindowInfoImpl.java | 23 +++--------------- 2 files changed, 9 insertions(+), 38 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ProjectFrameBounds.kt b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ProjectFrameBounds.kt index f9431239a537..8917af6a3a43 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ProjectFrameBounds.kt +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ProjectFrameBounds.kt @@ -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 diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowInfoImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowInfoImpl.java index 9b7658b57a89..1b727bd6d6b2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowInfoImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowInfoImpl.java @@ -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));