Kaydet (Commit) 8d562e6b authored tarafından Jack Jansen's avatar Jack Jansen

Very large scripts folders could crash the IDE, because it runs out

of Menu IDs (of which there are only 255 in Carbon). Fixed by stopping
examining the scripts folder when we allocate menu ID 200.

Fixes #959291. Need to backport.
üst d6d35d95
...@@ -275,17 +275,21 @@ class Application(FrameWork.Application): ...@@ -275,17 +275,21 @@ class Application(FrameWork.Application):
self.makeusermenus() self.makeusermenus()
def scriptswalk(self, top, menu, done=None): def scriptswalk(self, top, menu, done=None):
if menu.id > 200:
import W
W.Message("Scripts folder not completely traversed: running out of menus")
return False
if done is None: if done is None:
done = {} done = {}
if done.has_key(top): if done.has_key(top):
return return True
done[top] = 1 done[top] = 1
import os, string import os, string
try: try:
names = os.listdir(top) names = os.listdir(top)
except os.error: except os.error:
FrameWork.MenuItem(menu, '(Scripts Folder not found)', None, None) FrameWork.MenuItem(menu, '(Scripts Folder not found)', None, None)
return return True
savedir = os.getcwd() savedir = os.getcwd()
os.chdir(top) os.chdir(top)
for name in names: for name in names:
...@@ -306,7 +310,8 @@ class Application(FrameWork.Application): ...@@ -306,7 +310,8 @@ class Application(FrameWork.Application):
menu.addseparator() menu.addseparator()
elif isdir: elif isdir:
submenu = FrameWork.SubMenu(menu, name) submenu = FrameWork.SubMenu(menu, name)
self.scriptswalk(path, submenu, done) if not self.scriptswalk(path, submenu, done):
return False
else: else:
creator, type = MacOS.GetCreatorAndType(path) creator, type = MacOS.GetCreatorAndType(path)
if type == 'TEXT': if type == 'TEXT':
...@@ -316,6 +321,7 @@ class Application(FrameWork.Application): ...@@ -316,6 +321,7 @@ class Application(FrameWork.Application):
self._scripts[(menu.id, item.item)] = path self._scripts[(menu.id, item.item)] = path
done[path] = 1 done[path] = 1
os.chdir(savedir) os.chdir(savedir)
return True
def domenu_script(self, id, item, window, event): def domenu_script(self, id, item, window, event):
(what, message, when, where, modifiers) = event (what, message, when, where, modifiers) = event
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment