diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp index 702af4a036..df224091cb 100644 --- a/src/apps/terminal/TermWindow.cpp +++ b/src/apps/terminal/TermWindow.cpp @@ -43,7 +43,6 @@ #include "TermScrollView.h" #include "TermView.h" - const static int32 kMaxTabs = 6; const static int32 kTermViewOffset = 3; @@ -232,18 +231,22 @@ TermWindow::_InitWindow() bool -TermWindow::QuitRequested() +TermWindow::_CanClose(int32 index) { bool warnOnExit = PrefHandler::Default()->getBool(PREF_WARN_ON_EXIT); if (!warnOnExit) - return BWindow::QuitRequested(); + return true; bool isBusy = false; - for (int32 i = 0; i < fSessions.CountItems(); i++) { - if (_TermViewAt(i)->IsShellBusy()) { - isBusy = true; - break; + if (index != -1) + isBusy = _TermViewAt(index)->IsShellBusy(); + else { + for (int32 i = 0; i < fSessions.CountItems(); i++) { + if (_TermViewAt(i)->IsShellBusy()) { + isBusy = true; + break; + } } } @@ -258,6 +261,16 @@ TermWindow::QuitRequested() return false; } + return true; +} + + +bool +TermWindow::QuitRequested() +{ + if (!_CanClose(-1)) + return false; + BMessage position = BMessage(MSG_SAVE_WINDOW_POSITION); position.AddRect("rect", Frame()); position.AddInt32("workspaces", Workspaces()); @@ -900,6 +913,8 @@ void TermWindow::_RemoveTab(int32 index) { if (fSessions.CountItems() > 1) { + if (!_CanClose(index)) + return; if (Session* session = (Session*)fSessions.RemoveItem(index)) { if (fSessions.CountItems() == 1) { fTabView->SetScrollView(dynamic_cast( diff --git a/src/apps/terminal/TermWindow.h b/src/apps/terminal/TermWindow.h index e179b6b57f..d37ddb6067 100644 --- a/src/apps/terminal/TermWindow.h +++ b/src/apps/terminal/TermWindow.h @@ -80,6 +80,7 @@ private: void _DoPrint(); void _AddTab(Arguments *args); void _RemoveTab(int32 index); + bool _CanClose(int32 index); TermViewContainerView* _ActiveTermViewContainerView() const; TermViewContainerView* _TermViewContainerViewAt(int32 index) const; TermView* _ActiveTermView() const;