Constructor no longer crashes when data == NULL.

Now exports B_CURSOR_SYSTEM_DEFAULT and B_CURSOR_I_BEAM - maybe they should
be part of AppDefs.cpp, though.
Style update.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8200 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2004-06-27 22:23:29 +00:00
parent 32081c1ebb
commit 917cf3f748
+35 -48
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2004, Haiku
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@@ -21,7 +21,7 @@
//
// File Name: Cursor.cpp
// Author: Frans van Nispen ([email protected])
// Gabe Yoder ([email protected])
// Gabe Yoder ([email protected])
// Description: BCursor describes a view-wide or application-wide cursor.
//------------------------------------------------------------------------------
/**
@@ -32,6 +32,7 @@
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <AppDefs.h>
#include <Cursor.h>
#include <PortLink.h>
#include <PortMessage.h>
@@ -40,43 +41,43 @@
// Project Includes ------------------------------------------------------------
#include <ServerProtocol.h>
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
const BCursor *B_CURSOR_SYSTEM_DEFAULT;
const BCursor *B_CURSOR_I_BEAM;
// these are initialized in BApplication::InitData()
//------------------------------------------------------------------------------
BCursor::BCursor(const void *cursorData)
{
int8 *data = (int8 *)cursorData;
m_serverToken = 0;
if ( data[0] != 16 )
if (data == NULL
|| data[0] != 16 // size
|| data[1] != 1 // depth
|| data[2] >= 16 || data[3] >= 16) // hot-spot
return;
if ( data[1] != 1 )
return;
if ( (data[2] >= 16) || (data[3] >= 16) )
return;
// Send data directly to server
BPrivate::BAppServerLink serverlink;
PortMessage msg;
serverlink.SetOpCode(AS_CREATE_BCURSOR);
serverlink.Attach(cursorData,68);
serverlink.Attach(cursorData, 68);
serverlink.FlushWithReply(&msg);
msg.Read<int32>(&m_serverToken);
}
//------------------------------------------------------------------------------
// undefined on BeOS
BCursor::BCursor(BMessage *data)
{
m_serverToken = 0;
m_serverToken = 0;
}
//------------------------------------------------------------------------------
BCursor::~BCursor()
{
// Notify server to deallocate server-side objects for this cursor
@@ -85,49 +86,35 @@ BCursor::~BCursor()
serverlink.Attach<int32>(m_serverToken);
serverlink.Flush();
}
//------------------------------------------------------------------------------
// not implemented on BeOS
status_t BCursor::Archive(BMessage *into, bool deep) const
{
return B_OK;
}
//------------------------------------------------------------------------------
// not implemented on BeOS
BArchivable *BCursor::Instantiate(BMessage *data)
{
return NULL;
}
//------------------------------------------------------------------------------
status_t BCursor::Perform(perform_code d, void *arg)
status_t
BCursor::Perform(perform_code d, void *arg)
{
/*
printf("perform %d\n", (int)d);
*/
return B_OK;
}
//------------------------------------------------------------------------------
void BCursor::_ReservedCursor1()
{
}
//------------------------------------------------------------------------------
void BCursor::_ReservedCursor2()
{
}
//------------------------------------------------------------------------------
void BCursor::_ReservedCursor3()
{
}
//------------------------------------------------------------------------------
void BCursor::_ReservedCursor4()
{
}
//------------------------------------------------------------------------------
/*
* $Log $
*
* $Id $
*
*/
void BCursor::_ReservedCursor1() {}
void BCursor::_ReservedCursor2() {}
void BCursor::_ReservedCursor3() {}
void BCursor::_ReservedCursor4() {}