Browse Source

Fix plMouseDevice crash

plMouseDevice::HideCursor can crash if it is called before the cursor is
created. This happens if the client pops up a disconnected dialog before
initialization is complete. I've seen it happen!
Adam Johnson 11 years ago
parent
commit
acb980332f
  1. 10
      Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp

10
Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp

@ -352,7 +352,7 @@ void plMouseDevice::SetCursorY(float y)
void plMouseDevice::HideCursor(bool override) void plMouseDevice::HideCursor(bool override)
{ {
if( fInstance->fCursor != nil ) if ( fInstance && fInstance->fCursor )
fInstance->fCursor->SetVisible( false ); fInstance->fCursor->SetVisible( false );
plMouseDevice::bCursorOverride = (override != 0); plMouseDevice::bCursorOverride = (override != 0);
@ -370,9 +370,11 @@ void plMouseDevice::ShowCursor(bool override)
plMouseDevice::bCursorHidden = false; plMouseDevice::bCursorHidden = false;
plMouseDevice::bCursorOverride = false; plMouseDevice::bCursorOverride = false;
if( fInstance->fCursor == nil ) if (fInstance) {
fInstance->CreateCursor( fInstance->fCursorID ); if (!fInstance->fCursor)
fInstance->fCursor->SetVisible( true ); fInstance->CreateCursor(fInstance->fCursorID);
fInstance->fCursor->SetVisible(true);
}
} }
void plMouseDevice::NewCursor(char* cursor) void plMouseDevice::NewCursor(char* cursor)

Loading…
Cancel
Save