summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFran├žois Revel <mmu_man@netsurf-browser.org>2008-10-16 20:52:00 +0000
committerFran├žois Revel <mmu_man@netsurf-browser.org>2008-10-16 20:52:00 +0000
commit3f0ded25ba5388da0ff546a2f44f3c1bbb817dae (patch)
treeef759e0ae2462683d1560c8a3a5198e25d6805c3
parentf33fd2c604a2e1d332211db3cc5147b23920c685 (diff)
downloadnetsurf-3f0ded25ba5388da0ff546a2f44f3c1bbb817dae.tar.gz
netsurf-3f0ded25ba5388da0ff546a2f44f3c1bbb817dae.tar.bz2
Call netsurf_init() from the thread creating the replicant, then the main loop from the thread we created. This avoids a deadlock with the replicant in BeHappy in Haiku. (I should probably make BTranslatorRoster not lock be_app anyway though).
svn path=/trunk/netsurf/; revision=5588
-rw-r--r--beos/beos_gui.cpp6
-rw-r--r--beos/beos_scaffolding.cpp30
2 files changed, 22 insertions, 14 deletions
diff --git a/beos/beos_gui.cpp b/beos/beos_gui.cpp
index 2e8d2ca0f..83f0d88b5 100644
--- a/beos/beos_gui.cpp
+++ b/beos/beos_gui.cpp
@@ -308,8 +308,10 @@ image_id nsbeos_find_app_path(char *path)
if (((char *)&nsbeos_find_app_path >= (char *)info.text)
&& ((char *)&nsbeos_find_app_path < (char *)info.text + info.text_size)) {
//fprintf(stderr, "match\n");
- if (path)
- strlcpy(path, info.name, B_PATH_NAME_LENGTH);
+ if (path) {
+ memset(path, 0, B_PATH_NAME_LENGTH);
+ strncpy(path, info.name, B_PATH_NAME_LENGTH-1);
+ }
return info.id;
}
}
diff --git a/beos/beos_scaffolding.cpp b/beos/beos_scaffolding.cpp
index 652628855..24c5d27de 100644
--- a/beos/beos_scaffolding.cpp
+++ b/beos/beos_scaffolding.cpp
@@ -147,7 +147,9 @@ struct menu_events {
// passed to the replicant main thread
struct replicant_thread_info {
+ char app[B_PATH_NAME_LENGTH];
BString url;
+ char *args[3];
};
@@ -485,22 +487,31 @@ NSBaseView::Instantiate(BMessage *archive)
if (archive->FindString("url", &url) < B_OK) {
return NULL;
}
+
+ struct replicant_thread_info *info = new replicant_thread_info;
+ info->url = url;
+ if (nsbeos_find_app_path(info->app) < B_OK)
+ return NULL;
+ info->args[0] = info->app;
+ info->args[1] = (char *)info->url.String();
+ info->args[2] = NULL;
NSBaseView *view = new NSBaseView(archive);
replicant_view = view;
replicated = true;
- struct replicant_thread_info info;
- info.url = url;
+ netsurf_init(2, info->args);
+
replicant_done_sem = create_sem(0, "NS Replicant created");
thread_id nsMainThread = spawn_thread(nsbeos_replicant_main_thread,
"NetSurf Main Thread", B_NORMAL_PRIORITY, &info);
if (nsMainThread < B_OK) {
delete_sem(replicant_done_sem);
+ delete info;
delete view;
return NULL;
}
resume_thread(nsMainThread);
- while (acquire_sem(replicant_done_sem) == EINTR);
+ //while (acquire_sem(replicant_done_sem) == EINTR);
delete_sem(replicant_done_sem);
return view;
@@ -590,16 +601,11 @@ NSBrowserWindow::QuitRequested(void)
int32 nsbeos_replicant_main_thread(void *_arg)
{
- char app[B_PATH_NAME_LENGTH];
- if (nsbeos_find_app_path(app) < B_OK)
- return B_ERROR;
struct replicant_thread_info *info = (struct replicant_thread_info *)_arg;
- // info becomes invalid once we created the scaffolding and released .sem
- BString url(info->url);
- char *args[] = { app, (char *)url.String(), NULL };
- //XXX find path with get_next_image()
- int ret = netsurf_main(2, args);
- return ret;
+ netsurf_main_loop();
+ netsurf_exit();
+ delete info;
+ return 0;
}