realbasic-plugins
[Top] [All Lists]

Re: CFStrings on Win32

To: REALbasic Plugins <realbasic-plugins at lists dot realsoftware dot com>
Subject: Re: CFStrings on Win32
From: Chris Little <cslittle at mac dot com>
Date: Fri, 27 Jan 2006 11:27:39 -0500
Delivered-to: realbasic-plugins at lists dot realsoftware dot com
Thread-index: AcYjSE/LjqNTdI87Edqp0QAKldpEygABRlb2AAFBkY0AAwnXJw==
Thread-topic: CFStrings on Win32
on 1/27/06 10:00 AM, Dave Addey at listmail1 at dsl dot pipex dot com wrote:

> static void FileLocationSetter (REALobject instance, long param, REALstring
> value)
> {
>     ClassData (RB_SongLoader, instance, RB_SongLoaderData, me);
>     SongLoaderDataRef myParameters = (SongLoaderDataRef)me->myParametersRef;
>     myParameters->FileLocation = value;
> }

This looks suspicious. You're keeping a reference to the passed in string
without locking it.  I wonder if the memory management on Windows is biting
you.

The code should look like:

static void FileLocationSetter (REALobject instance, long param, REALstring
value)
{
    ClassData (RB_SongLoader, instance, RB_SongLoaderData, me);
    SongLoaderDataRef myParameters =(SongLoaderDataRef)me->myParametersRef;

    if ( myParameters->FileLocation )
        REALUnlockString( myParameters->FileLocation ) ;

    REALLockString( value ) ;
    myParameters->FileLocation = value;
}

Of course you would have to change the destructor to have the same unlock
code.

Chris


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>