[futurebasic] Re: [FB] Slowdown in Leopard?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2007 : Group Archive : Group : All Groups

From: Lake Group <lakegroupltd@...>
Date: Wed, 14 Nov 2007 17:32:52 -0500
>> Should we be changing IsHandleValid everywhere?
> Not necessarily everywhere. Keep in mind we are bypassing an Apple  
> bug. Hopefully, at some point it will be fixed. The primary place to  
> fix is the runtime appearance include(as covered by Robert P  
> earlier) because that impacts every program compiled with the  
> appearance runtime.

Good point, Brian. Everything seems to be fine with changes *just* in  
the Appearance.incl, so I'll go with just those changes, for now.

> Also, this code snippet begs more questions that could only be  
> answered by looking at the code that calls this fn.  Array is  
> defined as a pointer to long in the argument list. Presumably, the  
> long is a handle (if so, it should be defined as one). Dereferencing  
> array (array.nil&) and passing it to IsHandleValid looks suspect,  
> but again without looking at the calling code....


The values coming in are in the form of arrays and in some cases  
arrays of records. Here's some short code (DBFD Example #1 sans most  
of the remarks) that fails with MyIsHandleValid (in the DBFD Include,  
so you'll need to update that file to invoke the crash.) . (And make  
no mistake about it, Alain's code is a Godsend! ;-)

Thanks,
DL


// -- >>  
-----------------------------------------------------------------------------------------------------
Include "DataBrowser For Dummies.Incl"


Local Fn MyGetSetItemData( browser As ControlRef,            ¬
                         itemID As DataBrowserItemID,     ¬
                    theProperty As DataBrowserPropertyID, ¬
                       itemData As DataBrowserItemDataRef,¬
                       setValue As Boolean )
// we must return a specific error like shown below, because
// we will not handle all the requests the DataBrowser
// may address to the program. We send back _noErr, if all
// goes well.
Dim err As OSStatus : err = _errDataBrowserPropertyNotSupported
// see if the DataBrowser is requesting information about our unique  
column
Long If setValue = _false And theProperty = 1
// each item (aka row) will display the string
// "ItemID" followed by its identifier
err = Fn BrowserSetString( itemData,"ItemID" + Str$(itemID) )
End If
End Fn = err

clear Local Fn BuildWindow
Dim   r           As Rect
Dim @ browser     As ControlRef
Dim   list(1)     As ColumnRecord
Dim   itemID(100) As DataBrowserItemID
Dim   i           As Long

SetRect( r, 100, 100, 600, 400 )
Appearance Window  1, "DataBrowser For Dummies",  
@r ,_kDocumentWindowClass, ¬
             _kWindowInWindowMenuAttribute  
_kWindowStandardDocumentAttributes

// tell the DataBrowser which function to call
// for getting and setting the data in the cells
list.procs[_GetSetItemData] = @Fn MyGetSetItemData

// first column must start at index 1
// we must provide an array of columns
Dim col : col = 1
// unique identifier for the column
list.columnID   (col) = 1
// title that appears in the header
list.title      (col) = "Test"
// data type in the cells
list.cellContentType(col) = _kDataBrowserTextType
// minimum width and maximum
list.minWidth   (col) = 10
list.maxWidth   (col) = 280

// create the browser
Fn BrowserCreate( browser, _nil, col, list(0) )
Long If browser
// create 100 itemIDs stored in an array
For i = 1 To 100
itemID(i) = i * 10
Next
// add those itemIDs in the DataBrowser. That's all!
Fn BrowserAddItems( browser, 100, itemID(0) )
End If
End Fn

Fn BuildWindow


Include "Subs Quick Event Loop.Incl"

// -- >>  
-----------------------------------------------------------------------------------------------------



On Nov 14, 2007, at 4:54 PM, Brian Stevens wrote:

>
> On Nov 14, 2007, at 2:25 PM, Lake Group wrote:
>
>> Should we be changing IsHandleValid everywhere?
> Not necessarily everywhere. Keep in mind we are bypassing an Apple  
> bug. Hopefully, at some point it will be fixed. The primary place to  
> fix is the runtime appearance include(as covered by Robert P  
> earlier) because that impacts every program compiled with the  
> appearance runtime.
>
>
>
>
>> Using MyIsHandleValid in the situation below (from DataBrowser for  
>> Dummies) causes a crash.
> I'm sure Alain would agree that some of this code needs review  
> especially in light of OS X. For example, handle locks are not  
> really necessary in OS X.
>
> Also, this code snippet begs more questions that could only be  
> answered by looking at the code that calls this fn.  Array is  
> defined as a pointer to long in the argument list. Presumably, the  
> long is a handle (if so, it should be defined as one). Dereferencing  
> array (array.nil&) and passing it to IsHandleValid looks suspect,  
> but again without looking at the calling code....
>
>
>
>> Assuming there's pointer/handle situation here.  There are 9 or 10  
>> fn's in the DB for Dummies that pass  array.nil&. Perhaps there are  
>> others of this nature scattered about?
> Maybe. Again, this code needs a review not only for a substitute for  
> IsHandleValid, but also for other methods.
>
> Your code might need to be adapted to use Robert's substitute for  
> IsHandleValid. For example, the pointer to a long type  in Fn  
> BrowserAddItems does not match the handle type defined in Robert's  
> function. The point is to bypass IsHandleValid for now. This effort  
> will probably require some thinking and study to get all code working.
>
>
>
>>
>> Also, Drag and Drop is out in all my FB apps. (Used code from FB  
>> sample code.)
> By "out", I assume this means D&D is not working?  Unfortunately,  
> this is not enough information to help you. BTW: FB sample code  
> should not be relied upon to be flawless. Some of that code is stale  
> and needs updating.
>
>
> Brian S.
>
> --
> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...
>