VirtualBox

Changeset 36814 in vbox


Ignore:
Timestamp:
Apr 22, 2011 1:18:05 PM (14 years ago)
Author:
vboxsync
Message:

Java XPCOM bridge: cleanup, survive multiple inits

Location:
trunk/src
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/glue/glue-java.xsl

    r36270 r36814  
    24462446    private IVirtualBox         vbox;
    24472447    private nsIComponentManager componentManager;
    2448     private nsIServiceManager   servMgr;
    2449 
    2450     private VirtualBoxManager(Mozilla mozilla, nsIServiceManager servMgr)
     2448
     2449    private VirtualBoxManager(Mozilla mozilla)
    24512450    {
    24522451        this.mozilla = mozilla;
    2453         this.servMgr = servMgr;
    24542452        this.componentManager = mozilla.getComponentManager();
    24552453        this.vbox = new IVirtualBox((org.mozilla.interfaces.IVirtualBox) this.componentManager
     
    25032501
    25042502    private static boolean hasInstance = false;
     2503    private static boolean isMozillaInited = false;
    25052504
    25062505    public static synchronized VirtualBoxManager createInstance(String home)
     
    25082507        if (hasInstance)
    25092508            throw new VBoxException(null, "only one instance at the time allowed");
     2509        if (home == null || "".equals(home))
     2510            home = System.getProperty("vbox.home");
    25102511
    25112512        if (home == null)
    2512             home = System.getProperty("vbox.home");
     2513            throw new RuntimeException("vbox.home Java property must be defined to use XPCOM bridge");
    25132514
    25142515        File grePath = new File(home);
     2516
    25152517        Mozilla mozilla = Mozilla.getInstance();
    2516         mozilla.initialize(grePath);
    2517         nsIServiceManager servMgr = null;
    2518         try {
    2519             servMgr = mozilla.initXPCOM(grePath, null);
    2520         } catch (Exception e) {
    2521             e.printStackTrace();
    2522             return null;
     2518        if (!isMozillaInited)
     2519        {
     2520           mozilla.initialize(grePath);
     2521           try {
     2522             mozilla.initXPCOM(grePath, null);
     2523             isMozillaInited = true;
     2524           } catch (Exception e) {
     2525             e.printStackTrace();
     2526             return null;
     2527           }
    25232528        }
    25242529
    25252530        hasInstance = true;
    25262531
    2527         return new VirtualBoxManager(mozilla, servMgr);
     2532        return new VirtualBoxManager(mozilla);
    25282533    }
    25292534
     
    25352540    {
    25362541        deinitPerThread();
    2537         // cleanup
    2538         mozilla.shutdownXPCOM(servMgr);
     2542        // cleanup, we don't do that, as XPCOM bridge doesn't cleanly
     2543        // shuts down, so we prefer to avoid native shutdown
     2544        // mozilla.shutdownXPCOM(null);
    25392545        mozilla = null;
    25402546        hasInstance = false;
  • trunk/src/libs/xpcom18a4/java/src/org/mozilla/xpcom/internal/XPCOMJavaProxy.java

    r29140 r36814  
    256256
    257257}
    258 
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette