Ignore:
Timestamp:
08/11/23 14:39:35 (9 months ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

The browser cache can be cleared from the menu (re #368)

File:
1 edited

Legend:

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

    r1096 r1097  
    3434# The SimBrief handler
    3535_simBriefHandler = None
     36
     37# The cache directory
     38cacheDir = os.path.join(GLib.get_user_cache_dir(), "mlxcef")
    3639
    3740#------------------------------------------------------------------------------
     
    222225    print("Initializing CEF with args:", args)
    223226
    224     cacheDir = os.path.join(GLib.get_user_cache_dir(), "mlxcef")
    225 
    226     try:
    227         shutil.rmtree(cacheDir)
    228         print("gui.cef._initializeCEF1: the cache directory is removed")
    229     except Exception as e:
    230         print("gui.cef._initializeCEF1: cache directory removal failed:", e)
    231 
    232227    settings = {
    233228        "debug": True, # cefpython debug messages in console and in log_file
     
    241236            (cefpython.GetModuleDirectory(), "subprocess"),
    242237        "windowless_rendering_enabled": True,
    243         "cache_path": cacheDir
     238        "cache_path": cacheDir,
     239        "persist_session_cookies": True,
     240        "persist_user_preferences": True
    244241    }
    245242
     
    378375#------------------------------------------------------------------------------
    379376
     377def finalizeSimBrief():
     378    """Finallize the (hidden) browser window for SimBrief."""
     379    if _simBriefHandler is not None:
     380        _simBriefHandler.finalize()
     381
     382#------------------------------------------------------------------------------
     383
    380384def finalize():
    381385    """Finalize the Chrome Embedded Framework."""
     
    383387    _toQuit = True
    384388
    385     _simBriefHandler.finalize()
    386 
    387     cefpython.Shutdown()
     389    if os.name!="nt":
     390        cefpython.Shutdown()
     391
     392#------------------------------------------------------------------------------
     393
     394def clearCache():
     395    """Clear the CEF cache directory."""
     396    try:
     397        shutil.rmtree(cacheDir)
     398        print("gui.cef.clearCache: the cache directory is removed")
     399    except Exception as e:
     400        print("gui.cef.clearCache: cache directory removal failed:", e)
    388401
    389402#------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.