beos: Partial replicant instanciation fix

* use the correct resources
* work around a deadlock, allows BeHappy to start, though removing
the replicant from Tracker crashes
This commit is contained in:
François Revol 2012-11-25 19:47:48 +01:00
parent 8a12a8d545
commit 38b17e1112
4 changed files with 45 additions and 9 deletions

View File

@ -66,7 +66,7 @@ struct fetch_rsrc_context {
static struct fetch_rsrc_context *ring = NULL;
static BResources *gAppResources = NULL;
BResources *gAppResources = NULL;
static bool fetch_rsrc_initialise(lwc_string *scheme)
{

View File

@ -457,6 +457,12 @@ int main(int argc, char** argv)
options.Append("x-vnd.NetSurf");
}
if (!replicated) {
// create the Application object before trying to use messages
// so we can open an alert in case of error.
new NSBrowserApplication;
}
char* messages = "/boot/apps/netsurf/res/en/Messages";
/* initialise netsurf */
@ -472,6 +478,27 @@ int main(int argc, char** argv)
return 0;
}
/** called when replicated from NSBaseView::Instantiate() */
int gui_init_replicant(int argc, char** argv)
{
setbuf(stderr, NULL);
BPath options;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &options, true) == B_OK) {
options.Append("x-vnd.NetSurf");
}
char* messages = "/boot/apps/netsurf/res/en/Messages";
/* initialise netsurf */
netsurf_init(&argc, &argv, options.Path(), messages);
gui_init(argc, argv);
gui_init2(argc, argv);
return 0;
}
/* Documented in desktop/options.h */
void gui_options_init_defaults(void)
{
@ -487,7 +514,6 @@ void gui_init(int argc, char** argv)
if (pipe(sEventPipe) < 0)
return;
if (!replicated) {
new NSBrowserApplication;
sBAppThreadID = spawn_thread(bapp_thread, "BApplication(NetSurf)", B_NORMAL_PRIORITY, (void *)find_thread(NULL));
if (sBAppThreadID < B_OK)
return; /* #### handle errors */

View File

@ -30,6 +30,8 @@
#define CALLED() fprintf(stderr, "%s()\n", __FUNCTION__);
extern bool replicated;
int gui_init_replicant(int argc, char** argv);
#if 0 /* GTK */
//extern GladeXML *gladeWindows;

View File

@ -174,6 +174,10 @@ static int32 nsbeos_replicant_main_thread(void *_arg);
// in beos_gui.cpp
extern int main(int argc, char** argv);
// in fetch_rsrc.cpp
extern BResources *gAppResources;
#warning XXX
#if 0 /* GTK */
static gboolean nsbeos_window_url_activate_event(beosWidget *, gpointer);
@ -521,6 +525,10 @@ NSBaseView::Instantiate(BMessage *archive)
//netsurf_init(2, info->args);
//return NULL;
// do as much as possible in this thread to avoid deadlocks
gui_init_replicant(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);
@ -531,7 +539,8 @@ NSBaseView::Instantiate(BMessage *archive)
return NULL;
}
resume_thread(nsMainThread);
while (acquire_sem(replicant_done_sem) == EINTR);
//XXX: deadlocks BeHappy
//while (acquire_sem(replicant_done_sem) == EINTR);
return view;
}
@ -650,12 +659,11 @@ NSBrowserWindow::WindowActivated(bool active)
int32 nsbeos_replicant_main_thread(void *_arg)
{
struct replicant_thread_info *info = (struct replicant_thread_info *)_arg;
int32 ret;
ret = main(2, info->args);
//netsurf_main_loop();
//netsurf_exit();
int32 ret = 0;
netsurf_main_loop();
netsurf_exit();
delete info;
//release
delete_sem(replicant_done_sem);
return ret;
}
@ -1761,7 +1769,7 @@ void BBitmapButton::SetBitmap(const char* attrname)
{
#ifdef __HAIKU__
size_t size = 0;
const void* data = BApplication::AppResources()->LoadResource('VICN', attrname, &size);
const void* data = gAppResources->LoadResource('VICN', attrname, &size);
if (!data) {
printf("CANT LOAD RESOURCE %s\n", attrname);