From d3d5d0851a3ca982ed5c057d88f5d336395e71e5 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Sun, 27 Nov 2016 23:03:35 -0500 Subject: [PATCH 1/4] Added validation to window/position config value from .ini file --- spyder/config/user.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spyder/config/user.py b/spyder/config/user.py index 75457f1a908..d66a66f4775 100644 --- a/spyder/config/user.py +++ b/spyder/config/user.py @@ -19,6 +19,7 @@ import os.path as osp import shutil import time +import sys # Local imports from spyder.config.base import (get_conf_path, get_home_dir, @@ -26,6 +27,7 @@ from spyder.utils.programs import check_version from spyder.py3compat import configparser as cp from spyder.py3compat import PY2, is_text_string, to_text_string +from qtpy.QtWidgets import QApplication # Std imports for Python 2 if PY2: @@ -397,6 +399,17 @@ def get(self, section, option, default=NoDefault): value = ast.literal_eval(value) except (SyntaxError, ValueError): pass + + # It's necessary to verify if the window/position value is valid + # with the current screen. See issue 3748 + if option == 'window/position': + width = value[0] + height = value[1] + screenShape = QApplication.desktop().geometry() + current_width = screenShape.width() + current_height = screenShape.height() + if current_width < width or current_height < height: + value = self.get_default(section, option) return value def set_default(self, section, option, default_value): From 1b3f4653bb9c139dc15de964b4ecb471be8df56b Mon Sep 17 00:00:00 2001 From: dalthviz Date: Sun, 27 Nov 2016 23:12:45 -0500 Subject: [PATCH 2/4] Deleted unused sys import --- spyder/config/user.py | 1 - 1 file changed, 1 deletion(-) diff --git a/spyder/config/user.py b/spyder/config/user.py index d66a66f4775..6a627ff1847 100644 --- a/spyder/config/user.py +++ b/spyder/config/user.py @@ -19,7 +19,6 @@ import os.path as osp import shutil import time -import sys # Local imports from spyder.config.base import (get_conf_path, get_home_dir, From 41cf6045de0374ebd1a0d65b1c1bc740b1e9d519 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Wed, 30 Nov 2016 22:52:37 -0500 Subject: [PATCH 3/4] Use of the validation of 'window/position' in mainwindow.py --- spyder/app/mainwindow.py | 11 +++++++++++ spyder/config/user.py | 12 ------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py index 74aba590c6e..0a30ea77236 100644 --- a/spyder/app/mainwindow.py +++ b/spyder/app/mainwindow.py @@ -1319,6 +1319,17 @@ def load_window_settings(self, prefix, default=False, section='main'): else: hexstate = get_func(section, prefix+'state', None) pos = get_func(section, prefix+'position') + + # It's necessary to verify if the window/position value is valid + # with the current screen. See issue 3748 + width = pos[0] + height = pos[1] + screenShape = QApplication.desktop().geometry() + current_width = screenShape.width() + current_height = screenShape.height() + if current_width < width or current_height < height: + pos = CONF.get_default(section, prefix+'position') + is_maximized = get_func(section, prefix+'is_maximized') is_fullscreen = get_func(section, prefix+'is_fullscreen') return hexstate, window_size, prefs_dialog_size, pos, is_maximized, \ diff --git a/spyder/config/user.py b/spyder/config/user.py index 6a627ff1847..75457f1a908 100644 --- a/spyder/config/user.py +++ b/spyder/config/user.py @@ -26,7 +26,6 @@ from spyder.utils.programs import check_version from spyder.py3compat import configparser as cp from spyder.py3compat import PY2, is_text_string, to_text_string -from qtpy.QtWidgets import QApplication # Std imports for Python 2 if PY2: @@ -398,17 +397,6 @@ def get(self, section, option, default=NoDefault): value = ast.literal_eval(value) except (SyntaxError, ValueError): pass - - # It's necessary to verify if the window/position value is valid - # with the current screen. See issue 3748 - if option == 'window/position': - width = value[0] - height = value[1] - screenShape = QApplication.desktop().geometry() - current_width = screenShape.width() - current_height = screenShape.height() - if current_width < width or current_height < height: - value = self.get_default(section, option) return value def set_default(self, section, option, default_value): From 0060c93b958286d8815257a044d4f053611464e8 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Thu, 1 Dec 2016 19:52:29 -0500 Subject: [PATCH 4/4] Changed name for screen_shape variable. --- spyder/app/mainwindow.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py index 0a30ea77236..eccafc7b4a7 100644 --- a/spyder/app/mainwindow.py +++ b/spyder/app/mainwindow.py @@ -1324,9 +1324,9 @@ def load_window_settings(self, prefix, default=False, section='main'): # with the current screen. See issue 3748 width = pos[0] height = pos[1] - screenShape = QApplication.desktop().geometry() - current_width = screenShape.width() - current_height = screenShape.height() + screen_shape = QApplication.desktop().geometry() + current_width = screen_shape.width() + current_height = screen_shape.height() if current_width < width or current_height < height: pos = CONF.get_default(section, prefix+'position')