Skip to content

Commit

Permalink
Revert "TermViewStates: Check if fView is NULL before using it."
Browse files Browse the repository at this point in the history
This reverts commit b84955c.
  • Loading branch information
jscipione committed Jun 5, 2014
1 parent 4bf5fb9 commit 7a21420
Showing 1 changed file with 10 additions and 47 deletions.
57 changes: 10 additions & 47 deletions src/apps/terminal/TermViewStates.cpp
@@ -1,16 +1,13 @@
/*
* Copyright 2004-2014, Haiku, Inc.
* Copyright 2001-2013, Haiku, Inc.
* Copyright 2003-2004 Kian Duffy, myob@users.sourceforge.net
* Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai.
* All rights reserved.
*
* Distributed under the terms of the MIT license.
* All rights reserved. Distributed under the terms of the MIT license.
*
* Authors:
* Stefano Ceccherini, stefano.ceccherini@gmail.com
* Kian Duffy, myob@users.sourceforge.net
* Y.Hayakawa, hida@sawada.riec.tohoku.ac.jp
* John Scipione, jscipione@gmail.com
* Ingo Weinhold, ingo_weinhold@gmx.de
* Clemens Zeidler, haiku@Clemens-Zeidler.de
* Siarzhuk Zharski, zharik@gmx.li
Expand Down Expand Up @@ -155,9 +152,6 @@ TermView::StandardBaseState::StandardBaseState(TermView* view)
bool
TermView::StandardBaseState::_StandardMouseMoved(BPoint where, int32 modifiers)
{
if (fView == NULL)
return false;

if (!fView->fReportAnyMouseEvent && !fView->fReportButtonMouseEvent)
return false;

Expand Down Expand Up @@ -199,9 +193,6 @@ TermView::DefaultState::ModifiersChanged(int32 oldModifiers, int32 modifiers)
void
TermView::DefaultState::KeyDown(const char* bytes, int32 numBytes)
{
if (fView == NULL || fView->Looper() == NULL)
return;

int32 key;
int32 mod;
int32 rawChar;
Expand Down Expand Up @@ -375,9 +366,6 @@ TermView::DefaultState::KeyDown(const char* bytes, int32 numBytes)
void
TermView::DefaultState::MouseDown(BPoint where, int32 buttons, int32 modifiers)
{
if (fView == NULL)
return;

if (fView->fReportAnyMouseEvent || fView->fReportButtonMouseEvent
|| fView->fReportNormalMouseEvent || fView->fReportX10MouseEvent) {
TermPos clickPos = fView->_ConvertToTerminal(where);
Expand Down Expand Up @@ -414,16 +402,15 @@ TermView::DefaultState::MouseMoved(BPoint where, uint32 transit,
void
TermView::DefaultState::WindowActivated(bool active)
{
if (active && fView != NULL)
if (active)
_CheckEnterHyperLinkState(fView->fModifiers);
}


bool
TermView::DefaultState::_CheckEnterHyperLinkState(int32 modifiers)
{
if ((modifiers & B_COMMAND_KEY) != 0 && fView != NULL
&& fView->Window() != NULL && fView->Window()->IsActive()) {
if ((modifiers & B_COMMAND_KEY) != 0 && fView->Window()->IsActive()) {
fView->_NextState(fView->fHyperLinkState);
return true;
}
Expand All @@ -448,9 +435,6 @@ TermView::SelectState::SelectState(TermView* view)
void
TermView::SelectState::Prepare(BPoint where, int32 modifiers)
{
if (fView == NULL || fView->Window() == NULL)
return;

int32 clicks;
fView->Window()->CurrentMessage()->FindInt32("clicks", &clicks);

Expand Down Expand Up @@ -608,9 +592,6 @@ TermView::SelectState::MouseUp(BPoint where, int32 buttons)
fCheckMouseTracking = false;
fMouseTracking = false;

if (fView == NULL)
return;

if (fView->fAutoScrollRunner != NULL) {
delete fView->fAutoScrollRunner;
fView->fAutoScrollRunner = NULL;
Expand All @@ -635,9 +616,6 @@ TermView::SelectState::MouseUp(BPoint where, int32 buttons)
void
TermView::SelectState::_AutoScrollUpdate()
{
if (fView == NULL)
return;

if (fMouseTracking && fView->fAutoScrollRunner != NULL
&& fView->fScrollBar != NULL) {
float value = fView->fScrollBar->Value();
Expand Down Expand Up @@ -674,9 +652,6 @@ TermView::HyperLinkState::HyperLinkState(TermView* view)
void
TermView::HyperLinkState::Entered()
{
if (fView == NULL)
return;

ActiveProcessInfo activeProcessInfo;
if (fView->GetActiveProcessInfo(activeProcessInfo))
fCurrentDirectory = activeProcessInfo.CurrentDirectory();
Expand All @@ -697,9 +672,6 @@ TermView::HyperLinkState::Exited()
void
TermView::HyperLinkState::ModifiersChanged(int32 oldModifiers, int32 modifiers)
{
if (fView == NULL)
return;

if ((modifiers & B_COMMAND_KEY) == 0)
fView->_NextState(fView->fDefaultState);
else
Expand All @@ -722,10 +694,8 @@ TermView::HyperLinkState::MouseDown(BPoint where, int32 buttons,
if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0) {
link.Open();
} else if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
if (fView != NULL) {
fView->fHyperLinkMenuState->Prepare(where, link);
fView->_NextState(fView->fHyperLinkMenuState);
}
fView->fHyperLinkMenuState->Prepare(where, link);
fView->_NextState(fView->fHyperLinkMenuState);
}
}

Expand All @@ -741,7 +711,7 @@ TermView::HyperLinkState::MouseMoved(BPoint where, uint32 transit,
void
TermView::HyperLinkState::WindowActivated(bool active)
{
if (!active && fView != NULL)
if (!active)
fView->_NextState(fView->fDefaultState);
}

Expand All @@ -763,10 +733,7 @@ TermView::HyperLinkState::ForegroundColor()
rgb_color
TermView::HyperLinkState::BackgroundColor()
{
if (fView != NULL)
return fView->fTextBackColor;

return make_color(255, 255, 255);
return fView->fTextBackColor;
}


Expand Down Expand Up @@ -1000,9 +967,6 @@ TermView::HyperLinkState::_ActivateHighlight(const TermPos& start,
}

fHighlight.SetRange(start, end);
if (fView == NULL)
return;

fView->_AddHighlight(&fHighlight);
BCursor cursor(B_CURSOR_ID_FOLLOW_LINK);
fView->SetViewCursor(&cursor);
Expand All @@ -1013,7 +977,7 @@ TermView::HyperLinkState::_ActivateHighlight(const TermPos& start,
void
TermView::HyperLinkState::_DeactivateHighlight()
{
if (fHighlightActive && fView != NULL) {
if (fHighlightActive) {
fView->_RemoveHighlight(&fHighlight);
BCursor cursor(B_CURSOR_ID_SYSTEM_DEFAULT);
fView->SetViewCursor(&cursor);
Expand Down Expand Up @@ -1124,8 +1088,7 @@ TermView::HyperLinkMenuState::MessageReceived(BMessage* message)
}

case kMessageMenuClosed:
if (fView != NULL)
fView->_NextState(fView->fDefaultState);
fView->_NextState(fView->fDefaultState);
return true;
}

Expand Down

0 comments on commit 7a21420

Please sign in to comment.