Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / October 2004



Tip: Looking for answers? Try searching our database.

color picker crashes one second use

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Keith Wiley - 28 Oct 2004 21:47 GMT
I am using NPickColor (as opposed to PickColor or GetColor) because IM
suggests that it is the most recent and most preferred).  The first time I
call it, works perfectly.  The second time, every time I run the program,
the program crashes.  This is what I've got:

pascal Boolean ColorPickerEventProc(EventRecord *event)
{
    return false;
}

pascal void ColorPickerColorChanged(SInt32 userData, NPMColor *newColor)
{
}

void SomeFunction()
{
    NColorPickerInfo cpi;
    cpi.theColor.color.rgb.red = currentColor.red;
    cpi.theColor.color.rgb.green = currentColor.green;
    cpi.theColor.color.rgb.blue = currentColor.blue;
    cpi.dstProfile = NULL;    //Use default profile
    cpi.placeWhere = kAtSpecifiedOrigin;    //Doesn't seem to work,
but oh well!
    cpi.dialogOrigin = where;    //Doesn't seem to work, but oh
well!
    cpi.pickerType = 0;    //Use last used type
    UserEventUPP eventProcUPP = NewUserEventUPP(ColorPickerEventProc);
    cpi.eventProc = eventProcUPP;
    NColorChangedUPP colorChangedUPP =
NewNColorChangedUPP(ColorPickerColorChanged);
    cpi.colorProc = colorChangedUPP;
    cpi.colorProcData = 0;    //user data passed to color changed
callback
    cpi.prompt[0] = 0;    //This dialog has no text prompt
    cpi.mInfo.editMenuID = 130;
    cpi.mInfo.cutItem = 4;
    cpi.mInfo.copyItem = 5;
    cpi.mInfo.pasteItem = 6;
    cpi.mInfo.clearItem = 7;
    cpi.mInfo.undoItem = 1;

    if (NPickColor(&cpi) == noErr && cpi.newColorChosen)
    {
        //process new color
    }

    DisposeUserEventUPP(eventProcUPP);
    DisposeNColorChangedUPP(colorChangedUPP);
}

It's hard to describe the crash.  It's an access fault exception that
occurs deep inside the colorsync routines, a long ways from my code.

If anyone knows how to get this working properly, I would appreciate it.

Thank you very much.

________________________________________________________________________
Keith Wiley         kwiley@cs.unm.edu         http://www.unm.edu/~keithw

"Yet mark his perfect self-contentment, and hence learn his lesson,
that to be self-contented is to be vile and ignorant, and that to
aspire is better than to be blindly and impotently happy."
                                           --  Edwin A. Abbott, Flatland
________________________________________________________________________
David Phillip Oster - 28 Oct 2004 22:48 GMT
Does it still crash if you write the UPP functions as:

static UserEventUPP eventProcUPP = NULL;
if(NULL == eventProcUPP){
  eventProcUPP = NewUserEventUPP(ColorPickerEventProc);
}

and NEVER delete the UPPs? (They are allocations that are never deleted,
but they are allocated exactly once.) If there were a bug in the Dispose
functions, it could show up as a failure on the NEXT call to the dialog.
Keith Wiley - 29 Oct 2004 19:14 GMT
I appreciate the help, but this suggestion didn't work (it was a good idea
though).  Has anyone successfully used the color picker interface?

> Does it still crash if you write the UPP functions as:
>
[quoted text clipped - 6 lines]
> but they are allocated exactly once.) If there were a bug in the Dispose
> functions, it could show up as a failure on the NEXT call to the dialog.

________________________________________________________________________
Keith Wiley         kwiley@cs.unm.edu         http://www.unm.edu/~keithw

"Yet mark his perfect self-contentment, and hence learn his lesson,
that to be self-contented is to be vile and ignorant, and that to
aspire is better than to be blindly and impotently happy."
                                           --  Edwin A. Abbott, Flatland
________________________________________________________________________
Eric VERGNAUD - 30 Oct 2004 00:39 GMT
dans l'article Pine.LNX.4.60.0410281440020.18319@albuquerque.cs.unm.edu,
Keith Wiley à kwiley@cs.unm.edu a écrit le 28/10/04 22:47 :

Since your procs are empty, did you try WITHOUT the procs (with ull proc
ptrs) ?

> I am using NPickColor (as opposed to PickColor or GetColor) because IM
> suggests that it is the most recent and most preferred).  The first time I
[quoted text clipped - 61 lines]
>                                           --  Edwin A. Abbott, Flatland
> ________________________________________________________________________
Keith Wiley - 30 Oct 2004 17:53 GMT
Yep, that was the first way I did it.  I thought the crash might be coming
from a need for those procs, or even by the system trying to access NULL
pointers to nonexistent procs (which could conceivably cause a crash of
course), but it doesn't work either way.  I don't get it.  How hard can it
be, yet no one can see anything wrong with my code.

Does no one use these libraries?  At this point I'm looking for
clarification that they even work right at all, or if they simply can't be
used.

...in which case, how do people pick colors?  I'm using GetColor right
now, which works like a dream (except the placement doesn't work, it
always goes to the center of the screen), but GetColor is described as
very old and use of it is highly discouraged.

I don't know what to do.

> dans l'article Pine.LNX.4.60.0410281440020.18319@albuquerque.cs.unm.edu,
> Keith Wiley à kwiley@cs.unm.edu a écrit le 28/10/04 22:47 :
[quoted text clipped - 67 lines]
>>                                           --  Edwin A. Abbott, Flatland
>> ________________________________________________________________________

________________________________________________________________________
Keith Wiley         kwiley@cs.unm.edu         http://www.unm.edu/~keithw

"Yet mark his perfect self-contentment, and hence learn his lesson,
that to be self-contented is to be vile and ignorant, and that to
aspire is better than to be blindly and impotently happy."
                                           --  Edwin A. Abbott, Flatland
________________________________________________________________________
Eric VERGNAUD - 30 Oct 2004 20:08 GMT
dans l'article Pine.LNX.4.60.0410301051060.15348@oberon.cs.unm.edu, Keith
Wiley à kwiley@cs.unm.edu a écrit le 30/10/04 18:53 :

> Yep, that was the first way I did it.  I thought the crash might be coming
> from a need for those procs, or even by the system trying to access NULL
[quoted text clipped - 12 lines]
>
> I don't know what to do.

I'm using the Cocoa color picker with no problem.

Eric
Jøhnny Fävòrítê (it means "halo, then resonate") - 31 Oct 2004 07:33 GMT
> I'm using the Cocoa color picker with no problem.

yeah, me too.  and i'm pretty sure that, once you create the color
picker window, it is not destroyed until program exit.  that could
account for things being different the second time it is used.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.