Readded some logging to stdout.

Changed add-on handling so that it suspends and resumes the thread when another module is picked, instead of trying to outwait it. That helps when the modules set long delays in their displays (like Message).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5015 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
gendusoa 2003-10-14 00:12:30 +00:00
parent 40b7eb39b2
commit 52f5e4a81b

View File

@ -160,9 +160,16 @@ void PreviewView::LoadNewAddon(const char* addOnFilename, BMessage* settingsMsg)
{ {
if (previewData.previewThreadId != 0) if (previewData.previewThreadId != 0)
{ {
std::cout << "Ending old thread id=" << previewData.previewThreadId << '\n';
previewData.stopMe = true; previewData.stopMe = true;
snooze( saver->TickSize() ); // replace :
kill_thread( previewData.previewThreadId ); //snooze( saver->TickSize() );
//kill_thread( previewData.previewThreadId );
// with :
suspend_thread( previewData.previewThreadId );
resume_thread( previewData.previewThreadId );
// end replace
previewData.stopMe = false; previewData.stopMe = false;
previewData.previewThreadId = 0; previewData.previewThreadId = 0;
} }
@ -174,18 +181,22 @@ void PreviewView::LoadNewAddon(const char* addOnFilename, BMessage* settingsMsg)
if (stopSaver) if (stopSaver)
{ {
std::cout << "stopping old saver\n";
saver->StopSaver(); saver->StopSaver();
stopSaver = false; stopSaver = false;
} }
if (stopConfigView) if (stopConfigView)
{ {
std::cout << "stopping config view\n";
saver->StopConfig(); saver->StopConfig();
stopConfigView = false; stopConfigView = false;
} }
if (deleteSaver) if (deleteSaver)
{ {
std::cout << "deleting old saver\n";
delete saver; delete saver;
saver = 0; saver = 0;
deleteSaver = false; deleteSaver = false;
@ -193,6 +204,7 @@ void PreviewView::LoadNewAddon(const char* addOnFilename, BMessage* settingsMsg)
if (removeConfigView) if (removeConfigView)
{ {
std::cout << "removing old config view\n";
settingsBoxPtr->RemoveChild(configView); settingsBoxPtr->RemoveChild(configView);
delete configView; delete configView;
settingsBoxPtr->Draw(settingsBoxPtr->Bounds()); settingsBoxPtr->Draw(settingsBoxPtr->Bounds());
@ -201,12 +213,14 @@ void PreviewView::LoadNewAddon(const char* addOnFilename, BMessage* settingsMsg)
if (noPreview) if (noPreview)
{ {
std::cout << "no preview\n";
noPreviewView->RemoveSelf(); noPreviewView->RemoveSelf();
delete noPreviewView; delete noPreviewView;
} }
if (removePreviewArea) if (removePreviewArea)
{ {
std::cout << "removing preview area\n";
previewArea->RemoveSelf(); previewArea->RemoveSelf();
delete previewArea; delete previewArea;
previewArea=new BView (scale2(1,8,1,2,Bounds()),"sampleScreen",B_FOLLOW_NONE,B_WILL_DRAW); previewArea=new BView (scale2(1,8,1,2,Bounds()),"sampleScreen",B_FOLLOW_NONE,B_WILL_DRAW);
@ -218,6 +232,7 @@ void PreviewView::LoadNewAddon(const char* addOnFilename, BMessage* settingsMsg)
if (unloadAddon) if (unloadAddon)
{ {
std::cout << "unloading add-on\n";
unload_add_on(addonImage); unload_add_on(addonImage);
addonImage = 0; addonImage = 0;
unloadAddon = false; unloadAddon = false;
@ -232,6 +247,8 @@ void PreviewView::LoadNewAddon(const char* addOnFilename, BMessage* settingsMsg)
} }
unloadAddon = true; unloadAddon = true;
std::cout << "Add-on loaded\n";
lastOpStatus = get_image_symbol(addonImage, "instantiate_screen_saver", B_SYMBOL_TYPE_TEXT,(void **) &instantiate); lastOpStatus = get_image_symbol(addonImage, "instantiate_screen_saver", B_SYMBOL_TYPE_TEXT,(void **) &instantiate);
if (lastOpStatus != B_OK) if (lastOpStatus != B_OK)
{ {
@ -241,12 +258,15 @@ void PreviewView::LoadNewAddon(const char* addOnFilename, BMessage* settingsMsg)
return; return;
} }
std::cout << "symbol imported\n";
saver = instantiate(settingsMsg, addonImage); saver = instantiate(settingsMsg, addonImage);
if (saver == 0) if (saver == 0)
{ {
std::cout << "Saver not instantiated.\n"; std::cout << "Saver not instantiated.\n";
return; return;
} }
std::cout << "saver instantiated\n";
deleteSaver = true; deleteSaver = true;
previewData.saver = saver; previewData.saver = saver;
@ -257,6 +277,8 @@ void PreviewView::LoadNewAddon(const char* addOnFilename, BMessage* settingsMsg)
return; return;
} }
std::cout << "InitCheck() says we're a go!\n";
lastOpStatus = saver->StartSaver(previewArea, true); lastOpStatus = saver->StartSaver(previewArea, true);
if ( lastOpStatus != B_OK ) if ( lastOpStatus != B_OK )
{ {
@ -265,6 +287,7 @@ void PreviewView::LoadNewAddon(const char* addOnFilename, BMessage* settingsMsg)
} }
else else
{ {
std::cout << "Saver started\n";
stopSaver = true; stopSaver = true;
noPreview = false; noPreview = false;
} }
@ -279,6 +302,8 @@ void PreviewView::LoadNewAddon(const char* addOnFilename, BMessage* settingsMsg)
stopConfigView = true; stopConfigView = true;
removeConfigView = true; removeConfigView = true;
std::cout << "Config view made\n";
if ( noPreview ) if ( noPreview )
{ {
noPreviewView = new BStringView(previewArea->Bounds(), "no_preview", "NO PREVIEW AVAILABLE"); noPreviewView = new BStringView(previewArea->Bounds(), "no_preview", "NO PREVIEW AVAILABLE");
@ -287,12 +312,14 @@ void PreviewView::LoadNewAddon(const char* addOnFilename, BMessage* settingsMsg)
noPreviewView->SetAlignment(B_ALIGN_CENTER); noPreviewView->SetAlignment(B_ALIGN_CENTER);
noPreviewView->Draw(previewArea->Bounds()); noPreviewView->Draw(previewArea->Bounds());
previewArea->AddChild(noPreviewView); previewArea->AddChild(noPreviewView);
std::cout << "no preview\n";
} }
else else
{ {
previewData.previewThreadId = spawn_thread( previewThread, "preview_thread", 50, NULL ); previewData.previewThreadId = spawn_thread( previewThread, "preview_thread", 50, NULL );
resume_thread( previewData.previewThreadId ); resume_thread( previewData.previewThreadId );
removePreviewArea = true; removePreviewArea = true;
std::cout << "Preview thread started\n";
} }
} // end PreviewView::LoadNewAddon() } // end PreviewView::LoadNewAddon()