Ticket #4087: 0001-AttributError-fixed.patch

File 0001-AttributError-fixed.patch, 1.7 KB (added by humitos, 11 years ago)

Checks if the widget is attached to the main window before trying to change the cursor

  • browser.py

    From b842b87d4e78181c9e54234e9c1d422d7cd51d4f Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Mon, 29 Oct 2012 09:29:16 -0300
    Subject: [PATCH Browse] AttributError fixed
    
    Avoid to change the cursor (WATCH or LEFT_PTR) if the TabbedView
    widget is not attached to the main window yet.
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     browser.py | 10 +++++++---
     1 file changed, 7 insertions(+), 3 deletions(-)
    
    diff --git a/browser.py b/browser.py
    index fad804f..2639d0b 100644
    a b class TabbedView(BrowserNotebook): 
    197197        on the current browser.
    198198
    199199        """
    200         if self.props.current_browser != widget:
     200        window = self.get_window()
     201        if self.props.current_browser != widget or window is None:
     202            # do not change the cursor if the browser that changes its
     203            # state is not the current one OR if TabbedView is not
     204            # attached to the main window yet
    201205            return
    202206
    203207        status = widget.get_load_status()
    204208        if status in (WebKit.LoadStatus.PROVISIONAL,
    205209                      WebKit.LoadStatus.COMMITTED,
    206210                      WebKit.LoadStatus.FIRST_VISUALLY_NON_EMPTY_LAYOUT):
    207             self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH))
     211            window.set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH))
    208212        elif status in (WebKit.LoadStatus.FAILED,
    209213                        WebKit.LoadStatus.FINISHED):
    210             self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.LEFT_PTR))
     214            window.set_cursor(Gdk.Cursor(Gdk.CursorType.LEFT_PTR))
    211215
    212216    def add_tab(self, next_to_current=False):
    213217        browser = Browser()