Jump to content

Browser.destroy(); - problem.


ConnorGuy

Recommended Posts

В 17.08.2021 в 18:41, ConnorGuy сказал:

Here is line 23;

https://imgur.com/aLDzh7w

I cant comment out the browser.destory as this will stop the CEF from closing.

try like this

 

let browser = null;

mp.events.add("client:openATM", () => {
  browser = mp.browsers.new("package://example");
  // other code
});

mp.events.add("client:closeATM", () => {
  browser.destroy();
  browser = null;
  // other code
});

 

Link to comment
Share on other sites

  • 1 year later...

Any of the above methods resulted in the error you posted.
The following code works 100%:

let browser = mp.browsers.new('path/to/yourbrowser.html');

function destroyBrowser() {
    if(browser != null) {
        browser.destroy();
        browser = null;
    }
}

 

Edited by Spliddorama
Link to comment
Share on other sites

 Whenever destroying some entity it's good practice to use

if(mp.entityPoolName.exists(entity))

 

On example from last post:

 

let browser = mp.browsers.new('path/to/yourbrowser.html');

function destroyBrowser() {
    if(browser) {
        if(mp.browsers.exists(browser)) browser.destroy();
        browser = null;
    }
}


Btw it's 1 year old post :)
 

Edited by Kopra
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...