Saveboxes die with window.
[dom-editor.git] / Dome / AppRun
blob3b4d3fe743a7d96c52c4bce83e48c31067a0ac9f
1 #! /usr/bin/env python
2 # vi: set syntax=python : */
4 import gc
5 show_leaks = True
7 import findrox
8 import rox
10 #rox.setup_app_options('Dome')
12 from rox.Menu import Menu, set_save_name
14 set_save_name('Dome')
16 no_gui_mode = 0
18 # Ugly hack to stop wierd chars appearing...
19 #import xml.dom.html
20 #xml.dom.html.HTML_CHARACTER_ENTITIES = {}
22 import sys
23 from os.path import dirname
25 app_dir = dirname(sys.argv[0])
27 from rox import g, mime
28 from rox.options import Option
29 from Window import Window
30 rox.setup_app_options('Dome')
32 default_font = Option('default_font', 'sans 12')
34 # All options must be registered by the time we get here
35 rox.app_options.notify()
37 #sys.argv.append('--disable-crash-dialog')
38 #import gnome.ui
39 #sys.argv.pop()
41 mime.install_mime_info('Dome')
43 mono = 0
44 while len(sys.argv) > 1 and sys.argv[1].startswith('--'):
45 option = sys.argv[1][2:]
46 del sys.argv[1]
47 if option == 'mono':
48 mono = 1 # Black & White
49 elif option == '':
50 break
51 else:
52 raise Exception("Unknown option", option)
54 def go():
55 if len(sys.argv) > 1:
56 files = sys.argv[1:]
57 del sys.argv[1:] # GnomeCanvas can't cope with -
58 win = apply(Window, files)
59 else:
60 win = Window()
62 win.show()
64 if show_leaks:
65 `[]` # Load repr stuff
66 from Ft.Xml.XPath import XPathParser # Load XPath stuff
67 XPathParser.new().parse('/')
68 import urllib2, urllib
69 r = urllib2.Request('http://www.ecs.soton.ac.uk') # HTTP
70 urllib2.urlopen(r).read(1)
71 del r
72 from encodings import ascii
73 from codecs import lookup
74 import random
75 lookup('ascii')
77 w = Window()
78 w.save()
79 w.destroy() # Init everything
80 del w
82 log = file('leak-log', 'w')
84 gc.collect()
85 old = {}
86 for x in gc.get_objects():
87 old[id(x)] = None
88 #import profile
89 #profile.run('go()')
90 go()
92 rox.mainloop()
94 if show_leaks:
95 import GUIView
96 GUIView.menu.__dict__ = {}
97 del GUIView.menu
98 urllib.urlcleanup()
99 gc.collect()
100 for x in gc.get_objects():
101 if id(x) not in old:
102 print `x`[:80]
103 print>>log, "New %s: %s" % (type(x), `x`)
104 for y in gc.get_referrers(x):
105 if y is not globals() and id(y) in old:
106 if type(y) == dict:
107 print>>log, "\t(dict, key is %s)" % [k for k in y if y[k] is x]
108 print>>log, "\t%s" % `y`