If spawning a shell in a tab failed, the tab wouldn't be removed by the

cleanup thread, since, not being attached to the window, Window() 
returned NULL. Now CustomTermView::NotifyQuit() accounts for this, and 
sends the message to the first window in the BApplication. Moreover, 
RemoveTab() would always remove the currently selected tab, and not the 
requested one.
Changed a printf() to fprintf(). 


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23558 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2008-01-16 11:33:47 +00:00
parent 523f71ee2b
commit 5dda419aeb
2 changed files with 16 additions and 6 deletions
+2 -1
View File
@@ -311,7 +311,7 @@ Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **arg
} }
if (master < 0) { if (master < 0) {
printf("didn't find any available pseudo ttys."); fprintf(stderr, "didn't find any available pseudo ttys.");
return B_ERROR; return B_ERROR;
} }
@@ -490,6 +490,7 @@ Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **arg
/* /*
* Exec failed. * Exec failed.
*/ */
sleep(1); sleep(1);
const char *spawnAlertMessage = "alert --stop " const char *spawnAlertMessage = "alert --stop "
"'Cannot execute \"%s\":\n" "'Cannot execute \"%s\":\n"
+14 -5
View File
@@ -269,7 +269,7 @@ TermWindow::MessageReceived(BMessage *message)
be_app->GetAppInfo(&info); be_app->GetAppInfo(&info);
// try launching two different ways to work around possible problems // try launching two different ways to work around possible problems
if (be_roster->Launch(&info.ref)!=B_OK) if (be_roster->Launch(&info.ref) != B_OK)
be_roster->Launch(TERM_SIGNATURE); be_roster->Launch(TERM_SIGNATURE);
break; break;
} }
@@ -664,7 +664,7 @@ void
TermWindow::_RemoveTab(int32 index) TermWindow::_RemoveTab(int32 index)
{ {
if (fTabView->CountTabs() > 1) if (fTabView->CountTabs() > 1)
delete fTabView->RemoveTab(fTabView->Selection()); delete fTabView->RemoveTab(index);
else else
PostMessage(B_QUIT_REQUESTED); PostMessage(B_QUIT_REQUESTED);
} }
@@ -735,11 +735,20 @@ CustomTermView::CustomTermView(int32 rows, int32 columns, int32 argc, const char
void void
CustomTermView::NotifyQuit(int32 reason) CustomTermView::NotifyQuit(int32 reason)
{ {
if (Window()) { BWindow *window = Window();
if (window == NULL)
window = be_app->WindowAt(0);
// TODO: If we got this from a view in a tab not currently selected,
// Window() will be NULL, as the view is detached.
// So we send the message to the first application window
// This isn't so cool, but for now, a Terminal app has only one
// window.
if (window != NULL) {
BMessage message(kCloseView); BMessage message(kCloseView);
message.AddPointer("termView", this); message.AddPointer("termView", this);
message.AddInt32("reason", reason); message.AddInt32("reason", reason);
Window()->PostMessage(&message); window->PostMessage(&message);
} }
} }