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. 6
      Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp

6
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,10 +370,12 @@ void plMouseDevice::ShowCursor(bool override)
plMouseDevice::bCursorHidden = false; plMouseDevice::bCursorHidden = false;
plMouseDevice::bCursorOverride = false; plMouseDevice::bCursorOverride = false;
if( fInstance->fCursor == nil ) if (fInstance) {
if (!fInstance->fCursor)
fInstance->CreateCursor(fInstance->fCursorID); fInstance->CreateCursor(fInstance->fCursorID);
fInstance->fCursor->SetVisible(true); fInstance->fCursor->SetVisible(true);
} }
}
void plMouseDevice::NewCursor(char* cursor) void plMouseDevice::NewCursor(char* cursor)
{ {

Loading…
Cancel
Save