From ecd79a2cc15697b7e1349f9963a6ab4b19564305 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 15 Jun 2008 16:13:33 +0000 Subject: [PATCH] Allow unsetting the listener. With multiple tabs there's only one terminal view that is attached to the window and can receive messages at all. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25964 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/terminal/TerminalBuffer.cpp | 30 ++++++++++++++++++++-------- src/apps/terminal/TerminalBuffer.h | 2 ++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/apps/terminal/TerminalBuffer.cpp b/src/apps/terminal/TerminalBuffer.cpp index de2b6a20fa..0d837208a4 100644 --- a/src/apps/terminal/TerminalBuffer.cpp +++ b/src/apps/terminal/TerminalBuffer.cpp @@ -17,7 +17,8 @@ TerminalBuffer::TerminalBuffer() : BLocker("terminal buffer"), - fEncoding(M_UTF8) + fEncoding(M_UTF8), + fListenerValid(false) { } @@ -41,6 +42,14 @@ void TerminalBuffer::SetListener(BMessenger listener) { fListener = listener; + fListenerValid = true; +} + + +void +TerminalBuffer::UnsetListener() +{ + fListenerValid = false; } @@ -61,23 +70,28 @@ TerminalBuffer::SetEncoding(int encoding) void TerminalBuffer::SetTitle(const char* title) { - BMessage message(MSG_SET_TERMNAL_TITLE); - message.AddString("title", title); - fListener.SendMessage(&message); + if (fListenerValid) { + BMessage message(MSG_SET_TERMNAL_TITLE); + message.AddString("title", title); + fListener.SendMessage(&message); + } } void TerminalBuffer::NotifyQuit(int32 reason) { - BMessage message(MSG_QUIT_TERMNAL); - message.AddInt32("reason", reason); - fListener.SendMessage(&message); + if (fListenerValid) { + BMessage message(MSG_QUIT_TERMNAL); + message.AddInt32("reason", reason); + fListener.SendMessage(&message); + } } void TerminalBuffer::NotifyListener() { - fListener.SendMessage(MSG_TERMINAL_BUFFER_CHANGED); + if (fListenerValid) + fListener.SendMessage(MSG_TERMINAL_BUFFER_CHANGED); } diff --git a/src/apps/terminal/TerminalBuffer.h b/src/apps/terminal/TerminalBuffer.h index 203c8d650d..31287d88f1 100644 --- a/src/apps/terminal/TerminalBuffer.h +++ b/src/apps/terminal/TerminalBuffer.h @@ -20,6 +20,7 @@ public: int32 historySize); void SetListener(BMessenger listener); + void UnsetListener(); int Encoding() const; void SetEncoding(int encoding); @@ -35,6 +36,7 @@ private: // listener/dirty region management BMessenger fListener; + bool fListenerValid; };