Ignore:
Timestamp:
10/25/15 14:37:06 (9 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
cef
Phase:
public
Message:

Added a life-span handler for the SimBrief browser page as the browser is closed on Windows when navigating to another page in the flight wizard (re #279).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/flight.py

    r711 r712  
    21392139class SimBriefingPage(Page):
    21402140    """Page to display the SimBrief HTML briefing."""
     2141    class BrowserLifeSpanHandler(object):
     2142        """The life-span handler of a browser."""
     2143        def __init__(self, simBriefingPage):
     2144            """Construct the life-span handler for the given page."""
     2145            self._simBriefingPage = simBriefingPage
     2146
     2147        def OnBeforeClose(self, browser):
     2148            """Called before closing the browser."""
     2149            self._simBriefingPage._invalidateBrowser()
     2150
    21412151    def __init__(self, wizard):
    21422152        """Construct the setup page."""
     
    21672177        """Activate the SimBrief flight plan page"""
    21682178        if self._browser is None:
    2169             url = "file://" + SimBriefSetupPage.getHTMLFilePath()
    2170             self._browser = cef.startInContainer(self._container, url)
     2179            self._startBrowser()
    21712180        else:
    21722181            self._browser.Reload()
     2182
     2183    def grabDefault(self):
     2184        """If the page has a default button, make it the default one."""
     2185        super(SimBriefingPage, self).grabDefault()
     2186
     2187        if self._browser is None:
     2188            self._startBrowser()
    21732189
    21742190    def _backClicked(self, button):
     
    21852201
    21862202        self._wizard.nextPage()
     2203
     2204    def _startBrowser(self):
     2205        """Start the browser.
     2206
     2207        If a container is needed, create one."""
     2208        if self._container is None:
     2209            self._container = cef.getContainer()
     2210            self._alignment.add(self._container)
     2211
     2212        url = "file://" + SimBriefSetupPage.getHTMLFilePath()
     2213        self._browser = cef.startInContainer(self._container, url)
     2214
     2215        lifeSpanHandler = SimBriefingPage.BrowserLifeSpanHandler(self)
     2216        self._browser.SetClientHandler(lifeSpanHandler)
     2217
     2218    def _invalidateBrowser(self):
     2219        """Invalidate the browser (and associated stuff)."""
     2220        self._alignment.remove(self._container)
     2221        self._container = None
     2222        self._browser = None
    21872223
    21882224#-----------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.