Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

prevent reusing kernel IDs

previous method of using tab count allowed collisions when closing and reopening tabs.
  • Loading branch information...
commit 2059d0a040aeb7edf44d1051ae9013c17591c17e 1 parent cfc7e4a
@minrk minrk authored
Showing with 10 additions and 2 deletions.
  1. +10 −2 IPython/frontend/qt/console/mainwindow.py
View
12 IPython/frontend/qt/console/mainwindow.py
@@ -63,6 +63,7 @@ def __init__(self, app,
"""
super(MainWindow, self).__init__()
+ self._kernel_counter = 0
self._app = app
self.confirm_exit = confirm_exit
self.new_frontend_factory = new_frontend_factory
@@ -97,6 +98,13 @@ def update_tab_bar_visibility(self):
self.close()
@property
+ def next_kernel_id(self):
+ """constantly increasing counter for kernel IDs"""
+ c = self._kernel_counter
+ self._kernel_counter += 1
+ return c
+
+ @property
def active_frontend(self):
return self.tab_widget.currentWidget()
@@ -115,7 +123,7 @@ def create_tab_with_current_kernel(self):
# don't keep stacking slaves
name = current_widget_name
else:
- name = str('('+current_widget_name+') slave')
+ name = '(%s) slave' % current_widget_name
self.add_tab_with_frontend(widget,name=name)
def close_tab(self,current_tab):
@@ -231,7 +239,7 @@ def add_tab_with_frontend(self,frontend,name=None):
"""
if not name:
- name=str('kernel '+str(self.tab_widget.count()))
+ name = 'kernel %i' % self.next_kernel_id
self.tab_widget.addTab(frontend,name)
self.update_tab_bar_visibility()
self.make_frontend_visible(frontend)
Please sign in to comment.
Something went wrong with that request. Please try again.