summaryrefslogtreecommitdiff
path: root/beos
diff options
context:
space:
mode:
authorFran├žois Revol <revol@free.fr>2013-03-22 00:25:27 +0100
committerFran├žois Revol <revol@free.fr>2013-03-22 00:25:27 +0100
commit48dc679d7bfe9f45bd50d86882d88a9ddb1d659c (patch)
tree87f47512c30ddaffd12d558086757010f6726989 /beos
parent15cb6886f2ddee80dc5163aae95d148044bc6882 (diff)
downloadnetsurf-48dc679d7bfe9f45bd50d86882d88a9ddb1d659c.tar.gz
netsurf-48dc679d7bfe9f45bd50d86882d88a9ddb1d659c.tar.bz2
beos: Fix replicants
Waiting on the semaphore was not enough, it was causing a crash on replicant removal. Now we wait for the replicant main thread to exit. It fixes replicants, at least when a single one is used per application. Using more than one still causes issues due to some libs not liking being used twice (hlcache it seems).
Diffstat (limited to 'beos')
-rw-r--r--beos/scaffolding.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index 7f2b12096..9954dd678 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -142,6 +142,7 @@ struct replicant_thread_info {
static int open_windows = 0; /**< current number of open browsers */
static NSBaseView *replicant_view = NULL; /**< if not NULL, the replicant View we are running NetSurf for */
static sem_id replicant_done_sem = -1;
+static thread_id replicant_thread = -1;
static void nsbeos_window_update_back_forward(struct beos_scaffolding *);
static void nsbeos_throb(void *);
@@ -224,9 +225,14 @@ NSBaseView::NSBaseView(BMessage *archive)
NSBaseView::~NSBaseView()
{
//warn_user ("~NSBaseView()", NULL);
- BMessage *message = new BMessage(B_QUIT_REQUESTED);
- nsbeos_pipe_message_top(message, NULL, fScaffolding);
- while (acquire_sem(replicant_done_sem) == EINTR);
+ if (replicated) {
+ BMessage *message = new BMessage(B_QUIT_REQUESTED);
+ nsbeos_pipe_message_top(message, NULL, fScaffolding);
+ while (acquire_sem(replicant_done_sem) == EINTR);
+ //debugger("plop");
+ status_t status = -1;
+ wait_for_thread(replicant_thread, &status);
+ }
}
@@ -397,15 +403,15 @@ NSBaseView::Instantiate(BMessage *archive)
gui_init_replicant(2, info->args);
replicant_done_sem = create_sem(0, "NS Replicant created");
- thread_id nsMainThread = spawn_thread(nsbeos_replicant_main_thread,
+ replicant_thread = spawn_thread(nsbeos_replicant_main_thread,
"NetSurf Main Thread", B_NORMAL_PRIORITY, info);
- if (nsMainThread < B_OK) {
+ if (replicant_thread < B_OK) {
delete_sem(replicant_done_sem);
delete info;
delete view;
return NULL;
}
- resume_thread(nsMainThread);
+ resume_thread(replicant_thread);
//XXX: deadlocks BeHappy
//while (acquire_sem(replicant_done_sem) == EINTR);