Prevent crash on building of a view that fails. A dummy view is shown with the error on failure of a view.
svn: r17551
This commit is contained in:
parent
c07c19dfe3
commit
273ad7c240
@ -878,6 +878,7 @@ class ViewManager(CLIManager):
|
||||
self.current_views = defaults[2]
|
||||
|
||||
self.__load_sidebar_plugins()
|
||||
|
||||
self.goto_page(defaults[0], defaults[1])
|
||||
|
||||
if not self.file_loaded:
|
||||
@ -1148,6 +1149,11 @@ class ViewManager(CLIManager):
|
||||
return cat_num
|
||||
return None
|
||||
|
||||
def __create_dummy_page(self, pdata, error):
|
||||
from gui.views.pageview import DummyPage
|
||||
return DummyPage(pdata.name, pdata, self.dbstate, self.uistate,
|
||||
_("View failed to load. Check error output."), error)
|
||||
|
||||
def __create_page(self, pdata, page_def):
|
||||
"""
|
||||
Create a new page and set it as the current page.
|
||||
@ -1158,7 +1164,7 @@ class ViewManager(CLIManager):
|
||||
import traceback
|
||||
LOG.warn("View '%s' failed to load." % pdata.id)
|
||||
traceback.print_exc()
|
||||
return
|
||||
page = self.__create_dummy_page(pdata, traceback.format_exc())
|
||||
|
||||
try:
|
||||
page_display = page.get_display()
|
||||
@ -1166,7 +1172,9 @@ class ViewManager(CLIManager):
|
||||
import traceback
|
||||
print("ERROR: '%s' failed to create view" % pdata.name)
|
||||
traceback.print_exc()
|
||||
return
|
||||
page = self.__create_dummy_page(pdata, traceback.format_exc())
|
||||
page_display = page.get_display()
|
||||
|
||||
page.define_actions()
|
||||
page.post()
|
||||
|
||||
@ -1180,6 +1188,7 @@ class ViewManager(CLIManager):
|
||||
hbox.add(gtk.Label(pdata.name))
|
||||
hbox.show_all()
|
||||
page_num = self.notebook.append_page(page.get_display(), hbox)
|
||||
return page
|
||||
|
||||
def view_changed(self, notebook, page, page_num):
|
||||
"""
|
||||
|
@ -632,3 +632,27 @@ class ViewConfigureDialog(ConfigureDialog):
|
||||
|
||||
def build_menu_names(self, obj):
|
||||
return (_('Configure %s View') % self.ident, None)
|
||||
|
||||
class DummyPage(PageView):
|
||||
"""
|
||||
A Dummy page for testing or errors
|
||||
"""
|
||||
def __init__(self, title, pdata, dbstate, uistate, msg1="", msg2=""):
|
||||
self.msg = msg1
|
||||
self.msg2 = msg2
|
||||
PageView.__init__(self, title, pdata, dbstate, uistate)
|
||||
|
||||
def build_widget(self):
|
||||
box = gtk.VBox(False, 1)
|
||||
#top widget at the top
|
||||
box.pack_start(gtk.Label(_('View %(name)s: %(msg)s') % {
|
||||
'name': self.title,
|
||||
'msg': self.msg}), False, False, 0 )
|
||||
tv = gtk.TextView()
|
||||
tb = tv.get_buffer()
|
||||
tb.insert_at_cursor(self.msg2)
|
||||
box.pack_start(tv, False, False, 0)
|
||||
return box
|
||||
|
||||
def build_tree(self):
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user