Question

I have a plugin where I want to prevent the browser from closing as im saving some data that take a unknown random amount of time.

data_ready = false;
data_ready = saveData(); //using a random amount of time as the user has to specify a location
boost::unique_lock<boost::mutex> lock(mut); 
while(!data_ready)  {
    cond.wait(lock);
}

Asking location for saving the data is prompted but crashes immediately after, which im guessing is the lock. How could I make the browser wait for the user to be finished saving data?

Was it helpful?

Solution

You can't. It is up to you to make sure that the plugin never blocks the main thread and that all threads you start are shut down in time. Congratulations and welcome to the wonderful world of browser plugins =]

Some people have gotten around this by launching an external application that does the real work that won't close until it's done.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top