Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

La fonction 'OpenADefaultComponent' de QuickTime plante dans une application écrite avec CodeWarrior 8.3

1 réponse
Avatar
Philippe Legroux
Premièrement, ma configuration est la suivante :

- iMac 700 MHZ / 128 Mo
- Mac OS 10.2.6
- CodeWarrior 8.3
- Universal Headers 3.4.2
- Toutes les librairies ont été reconstruites
- QuickTime 6.3

Dans une application qui utilise QuickTime pour compresser une image
provenant du presse-papiers, la fonction 'OpenADefaultComponent' plante à
chaque fois.
Ci-dessous le code incriminé, suivi du crash log.

//////////////////////////

SInt32 myGetScrap( Handle hDest, ResType theType )
{
SInt32 lenScrap=0;
OSErr Err;
ScrapRef scrap;

Err=GetCurrentScrap(&scrap);
if (Err==noErr)
{
if (!hDest)
Err=GetScrapFlavorSize(scrap,theType,&lenScrap);
else
{
Err=GetScrapFlavorSize(scrap,theType,&lenScrap);
if (Err==noErr)
Err=GetScrapFlavorData(scrap,theType,&lenScrap,*hDest);
else
lenScrap=0;
}
}
else
lenScrap=Err;
return (SInt32)lenScrap;
}


#define kMinQTVersion 0x05018000
#define kGMVersionMask 0xFFFF0000

OSErr ClipBoardCompress()
{
OSErr Err=noErr;
long response;
ComponentInstance stdc=0L;
ComponentResult cr=noErr;
PicHandle thePict=0L;
SInt32 lenScrap;

// QuickTime ?
Err=Gestalt(gestaltQuickTimeVersion, &response);
if ((Err != noErr) || ((response < kMinQTVersion) && (response !=
(kMinQTVersion & kGMVersionMask))))
return (OSErr)Err;

// Check to make sure the image compression manager is installed
Err=Gestalt(gestaltCompressionMgr, &response);
if ((Err != noErr) || (response < 15))
return (OSErr)Err;

thePict = (PicHandle)NewHandle(4);
if (!thePict)
return (OSErr)memFullErr;

// get the Picture from the scrap
HLock((Handle)thePict);
lenScrap=myGetScrap((Handle)thePict, 'PICT');
if (lenScrap <= 0)
goto bail;

// open the standard compression component
// <!!!--- crash here ---!!!>
Err=OpenADefaultComponent(StandardCompressionType,
StandardCompressionSubType, &stdc);
// <!!!--- crash here ---!!!>
if ((Err!=noErr) || (!stdc))
goto bail;

cr=SCDefaultPictHandleSettings(stdc, thePict, 0);

/*
... other code
*/

bail:
if (thePict) KillPicture(thePict);
if (stdc) CloseComponent(stdc);

}

//////////////////////////

**********

Date/Time: 2003-07-17 10:07:32 +0200
OS Version: 10.2.6 (Build 6L60)
Host: Š

Command: Š
PID: 469

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0x88660098

Thread 0 Crashed:
#0 0x90004bc8 in szone_malloc
#1 0x90004a44 in malloc_zone_malloc
#2 0x90235cd4 in RegisterComponentResourcePtr
#3 0x90247e40 in RegisterSystemComponentsClient
#4 0x902741b8 in registerSystemComponents
#5 0x902300b4 in FindNextComponent
#6 0x9023c6e4 in OpenADefaultComponent
#7 0x001ac12c in ClipBoardCompress
#8 0x001b6cec in 0x1b6cec
#9 0x001b7d08 in DoEditMenu
#10 0x001b5594 in 0x1b5594
#11 0x001b49b0 in MainEvent
#12 0x001b4498 in main

//////////////////////////

Quelqu'un a-t-il une suggestion ?

Merci d'avance.

Philippe L.

1 réponse

Avatar
Philippe Legroux
Le 17/07/2003 10:53, dans BB3C30C6.6B3%,
« Philippe Legroux » a écrit :


Premièrement, ma configuration est la suivante :

- iMac 700 MHZ / 128 Mo
- Mac OS 10.2.6
- CodeWarrior 8.3
- Universal Headers 3.4.2
- Toutes les librairies ont été reconstruites
- QuickTime 6.3

Dans une application qui utilise QuickTime pour compresser une image
provenant du presse-papiers, la fonction 'OpenADefaultComponent' plante à
chaque fois.
Ci-dessous le code incriminé, suivi du crash log.

//////////////////////////

SInt32 myGetScrap( Handle hDest, ResType theType )
{
SInt32 lenScrap=0;
OSErr Err;
ScrapRef scrap;

Err=GetCurrentScrap(&scrap);
if (Err==noErr)
{
if (!hDest)
Err=GetScrapFlavorSize(scrap,theType,&lenScrap);
else
{
Err=GetScrapFlavorSize(scrap,theType,&lenScrap);
if (Err==noErr)
Err=GetScrapFlavorData(scrap,theType,&lenScrap,*hDest);
else
lenScrap=0;
}
}
else
lenScrap=Err;
return (SInt32)lenScrap;
}


#define kMinQTVersion 0x05018000
#define kGMVersionMask 0xFFFF0000

OSErr ClipBoardCompress()
{
OSErr Err=noErr;
long response;
ComponentInstance stdc=0L;
ComponentResult cr=noErr;
PicHandle thePict=0L;
SInt32 lenScrap;

// QuickTime ?
Err=Gestalt(gestaltQuickTimeVersion, &response);
if ((Err != noErr) || ((response < kMinQTVersion) && (response ! > (kMinQTVersion & kGMVersionMask))))
return (OSErr)Err;

// Check to make sure the image compression manager is installed
Err=Gestalt(gestaltCompressionMgr, &response);
if ((Err != noErr) || (response < 15))
return (OSErr)Err;

thePict = (PicHandle)NewHandle(4);
if (!thePict)
return (OSErr)memFullErr;

// get the Picture from the scrap
HLock((Handle)thePict);
lenScrap=myGetScrap((Handle)thePict, 'PICT');
if (lenScrap <= 0)
goto bail;

// open the standard compression component
// <!!!--- crash here ---!!!>
Err=OpenADefaultComponent(StandardCompressionType,
StandardCompressionSubType, &stdc);
// <!!!--- crash here ---!!!>
if ((Err!=noErr) || (!stdc))
goto bail;

cr=SCDefaultPictHandleSettings(stdc, thePict, 0);

/*
... other code
*/

bail:
if (thePict) KillPicture(thePict);
if (stdc) CloseComponent(stdc);

}

//////////////////////////

**********

Date/Time: 2003-07-17 10:07:32 +0200
OS Version: 10.2.6 (Build 6L60)
Host: Š

Command: Š
PID: 469

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0x88660098

Thread 0 Crashed:
#0 0x90004bc8 in szone_malloc
#1 0x90004a44 in malloc_zone_malloc
#2 0x90235cd4 in RegisterComponentResourcePtr
#3 0x90247e40 in RegisterSystemComponentsClient
#4 0x902741b8 in registerSystemComponents
#5 0x902300b4 in FindNextComponent
#6 0x9023c6e4 in OpenADefaultComponent
#7 0x001ac12c in ClipBoardCompress
#8 0x001b6cec in 0x1b6cec
#9 0x001b7d08 in DoEditMenu
#10 0x001b5594 in 0x1b5594
#11 0x001b49b0 in MainEvent
#12 0x001b4498 in main

//////////////////////////

Quelqu'un a-t-il une suggestion ?

Merci d'avance.

Philippe L.



En fait j'ai trouvé la solutionŠ

Petit problème d'allocation mémoire pour hDest dans myGetScrap.

Désolé.

Philippe L.