From 917cf3f748cfaedabb84d64e97e0289f10fa557c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 27 Jun 2004 22:23:29 +0000 Subject: [PATCH] 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 --- src/kits/app/Cursor.cpp | 83 +++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 48 deletions(-) diff --git a/src/kits/app/Cursor.cpp b/src/kits/app/Cursor.cpp index b5db89a441..1d87d6501f 100644 --- a/src/kits/app/Cursor.cpp +++ b/src/kits/app/Cursor.cpp @@ -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 (xlr8@tref.nl) -// Gabe Yoder (gyoder@stny.rr.com) +// Gabe Yoder (gyoder@stny.rr.com) // Description: BCursor describes a view-wide or application-wide cursor. //------------------------------------------------------------------------------ /** @@ -32,6 +32,7 @@ // Standard Includes ----------------------------------------------------------- // System Includes ------------------------------------------------------------- +#include #include #include #include @@ -40,43 +41,43 @@ // Project Includes ------------------------------------------------------------ #include -// 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(&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(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() {}