Bug avec contextual menu et vue perso, App plante -> Debuggeur -> EXC_BAD_ACCES

elfelf Membre
13:37 modifié dans Vos applications #1
Bonjour,

Pour le mode editeur de mon petit jeu j'ai utilisé un menu contextuel pour choisire le type de "tuile" à  insérer.
Comme le mode editeur est asser similaire au mode jeu j'ai utilisé la même custom view. Ce menu est créer par code est ne contiens que des images 34x34 px. Quand j'utilise pour la première fois ce menu tout marche bien, mais des que j'édite une tuile, si j'essaye de faire réapparaitre le menu, l'application plante et retourne un code EXC_BAD_ACCES.

J'ai passé une journée entière à  essayer de trouver d'où venais ce bug, et après des tonnes de tests, j'ai trouvé que si je suprimmer les images dans le menu tout fonctionnais bien.

Quelqu'un aurrais une idée d'où ce bug viens? Car je tiens à  mes images!!!

elf

Réponses

  • BruBru Membre
    13:37 modifié #2
    dans 1145426010:

    Quand j'utilise pour la première fois ce menu tout marche bien, mais des que j'édite une tuile, si j'essaye de faire réapparaitre le menu, l'application plante et retourne un code EXC_BAD_ACCES.
    J'ai passé une journée entière à  essayer de trouver d'où venais ce bug, et après des tonnes de tests, j'ai trouvé que si je suprimmer les images dans le menu tout fonctionnais bien.
    Quelqu'un aurrais une idée d'où ce bug viens? Car je tiens à  mes images!!!


    EXC_BAD_ACCESS est souvent dû à  release de trop sur un objet.

    Le bug, il vient certainement de ton application !
    Mais sans code, sans rien, tu n'auras rien !

    .
  • elfelf Membre
    13:37 modifié #3
    NSLog(@&quot;create menu&quot;);<br />	editorMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@&quot;Editor&quot;];<br /><br />	NSMenuItem *newItem;<br />			<br />&nbsp; &nbsp; newItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:@&quot;&quot; action:NULL keyEquivalent:@&quot;&quot;];<br />&nbsp; &nbsp; [newItem setImage:[[NSImage imageNamed:@&quot;wall&quot;] retain]];<br />&nbsp; &nbsp; [newItem setTarget:self];<br />	[newItem setTag:TILE_WALL];<br />&nbsp; &nbsp; [newItem setAction:@selector(changeTileForEditing:)];<br />&nbsp; &nbsp; [editorMenu addItem:newItem];<br />&nbsp; &nbsp; [newItem release];<br />	<br />&nbsp; &nbsp; newItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:@&quot;&quot; action:NULL keyEquivalent:@&quot;&quot;];<br />&nbsp; &nbsp; [newItem setImage:[[NSImage imageNamed:@&quot;player&quot;] retain]];<br />&nbsp; &nbsp; [newItem setTarget:self];<br />	[newItem setTag:TILE_PLAYER];<br />&nbsp; &nbsp; [newItem setAction:@selector(changeTileForEditing:)];<br />&nbsp; &nbsp; [editorMenu addItem:newItem];<br />&nbsp; &nbsp; [newItem release];<br />	<br />&nbsp; &nbsp; newItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:@&quot;&quot; action:NULL keyEquivalent:@&quot;&quot;];<br />&nbsp; &nbsp; [newItem setImage:[[NSImage imageNamed:@&quot;objective&quot;] retain]];<br />&nbsp; &nbsp; [newItem setTarget:self];<br />	[newItem setTag:TILE_OBJECTIVE];<br />&nbsp; &nbsp; [newItem setAction:@selector(changeTileForEditing:)];<br />&nbsp; &nbsp; [editorMenu addItem:newItem];<br />&nbsp; &nbsp; [newItem release];<br />	<br />&nbsp; &nbsp; newItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:@&quot;&quot; action:NULL keyEquivalent:@&quot;&quot;];<br />&nbsp; &nbsp; [newItem setImage:[[NSImage imageNamed:@&quot;empty&quot;] retain]];<br />&nbsp; &nbsp; [newItem setTarget:self];<br />	[newItem setTag:TILE_EMPTY];<br />&nbsp; &nbsp; [newItem setAction:@selector(changeTileForEditing:)];<br />&nbsp; &nbsp; [editorMenu addItem:newItem];<br />&nbsp; &nbsp; [newItem release];<br />	<br />&nbsp; &nbsp; newItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:@&quot;&quot; action:NULL keyEquivalent:@&quot;&quot;];<br />&nbsp; &nbsp; [newItem setImage:[[NSImage imageNamed:@&quot;box&quot;] retain]];<br />&nbsp; &nbsp; [newItem setTarget:self];<br />	[newItem setTag:TILE_BOX];<br />&nbsp; &nbsp; [newItem setAction:@selector(changeTileForEditing:)];<br />&nbsp; &nbsp; [editorMenu addItem:newItem];<br />&nbsp; &nbsp; [newItem release];<br />	<br />&nbsp; &nbsp; newItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:@&quot;&quot; action:NULL keyEquivalent:@&quot;&quot;];<br />&nbsp; &nbsp; [newItem setImage:[[NSImage imageNamed:@&quot;box_ok&quot;] retain]];<br />&nbsp; &nbsp; [newItem setTarget:self];<br />	[newItem setTag:TILE_BOX_OK];<br />&nbsp; &nbsp; [newItem setAction:@selector(changeTileForEditing:)];<br />&nbsp; &nbsp; [editorMenu addItem:newItem];<br />&nbsp; &nbsp; [newItem release];<br />
    
  • LeChatNoirLeChatNoir Membre, Modérateur
    13:37 modifié #4
    Je ferai pas ça : [NSImage imageNamed:@objective] retain]

    Le retain est inutile car une image importée dans ton projet (dans les ressources) est instanciée au lancement de ton appli et releasé à  la fin de ton appli.

    Donc je virerai les retain...

    Hope this help...
  • BruBru Membre
    13:37 modifié #5
    Le code me semble propre.

    Sauf que généralement, on évite d'utiliser allocWithZone: (un alloc seul suffit pour NSMenu et NSMenuItem).

    De plus, le retain sur les images est inutile (mais pas pour les mêmes raisons que celles du Chat Noir), car le fait de faire unset: fait un retain implicte.

    L'erreur peut venir d'autre part, et par coà¯ncidence, semble apparaitre dans ce code.

    Tu peux éventuellement utiliser les zombies pour détecter les retains surnuméraires... Mais le mieux est de récupérer le crash-report de l'appli quand elle plante et de nous le montrer.

    .
  • elfelf Membre
    13:37 modifié #6
    Pour ce qui est des images avec les retains c'était suite à  un conseil de quelqu'un qui m'avais dit que j'aurrais du mettre des retains: avant que je ne les mettes ça ne fonctionnais pas non plus...

    Voilà  le crash report. Je ne vois pas trop en quoi ça pourrais aider mais bon, chui po un pro non plus! :fouf):

    Date/Time:      2006-04-20 07:20:32.175 +0200
    OS Version:    10.4.6 (Build 8I127)
    Report Version: 4

    Command: Isoko
    Path:    /Volumes/Fichiers/kenneth/Desktop/Programation/Programmes/Cocoa/Isoko/build/Release/Isoko.app/Contents/MacOS/Isoko
    Parent:  WindowServer [1495]

    Version: ??? (0.1)

    PID:    1683
    Thread: 0

    Exception:  EXC_BAD_ACCESS (0x0001)
    Codes:      KERN_PROTECTION_FAILURE (0x0002) at 0x00000000

    Thread 0 Crashed:
    0  libobjc.A.dylib  0x90a49bf4 objc_msgSend_stret + 20
    1  com.apple.AppKit  0x938443e8 CreateMenuImageFromImage + 52
    2  com.apple.AppKit  0x937592ec AdjustCarbonMenuItem + 2228
    3  com.apple.AppKit  0x93843b3c _NSPopUpCarbonMenu2 + 448
    4  com.apple.AppKit  0x9384396c _NSPopUpCarbonMenu1 + 44
    5  com.apple.AppKit  0x9389b140 -[NSCarbonMenuImpl _popUpContextMenu:withEvent:forView:withFont:] + 168
    6  com.apple.AppKit  0x9389afc0 -[NSMenu _popUpContextMenu:withEvent:forView:withFont:] + 216
    7  com.apple.AppKit  0x9377c5c0 -[NSWindow sendEvent:] + 6424
    8  com.apple.AppKit  0x93724ef4 -[NSApplication sendEvent:] + 4172
    9  com.apple.AppKit  0x9371c330 -[NSApplication run] + 508
    10  com.apple.AppKit  0x9380ce68 NSApplicationMain + 452
    11  com.seosoft.isoko 0x00001ee4 _start + 340 (crt.c:272)
    12  com.seosoft.isoko 0x00001d8c start + 60

    Thread 1:
    0  libSystem.B.dylib 0x9000b0a8 mach_msg_trap + 8
    1  libSystem.B.dylib 0x9000affc mach_msg + 60
    2  com.unsanity.ape  0xc0002afc __ape_internal + 3300 (icplusplus.c:28)
    3  com.unsanity.ape  0xc0001910 __ape_agent + 64 (icplusplus.c:28)
    4  libSystem.B.dylib 0x9002ba68 _pthread_body + 96

    Thread 0 crashed with PPC Thread State 64:
      srr0: 0x0000000090a49bf4 srr1: 0x000000000200f030                        vrsave: 0x0000000000000000
        cr: 0x44022284          xer: 0x0000000020000007  lr: 0x00000000938443e8  ctr: 0x0000000090a49be0
        r0: 0x00000000938443e8  r1: 0x00000000bfffeb80  r2: 0x0000000000000000  r3: 0x00000000bfffebd0
        r4: 0x0000000000353ab0  r5: 0x0000000090abc2e0  r6: 0x0000000000000000  r7: 0x0000000000000001
        r8: 0x0000000000000000  r9: 0x0000000001855e34  r10: 0x00000000bfffebb0  r11: 0x00000000a371b70c
      r12: 0x000000000005b45b  r13: 0x0000000000000001  r14: 0x0000000000000100  r15: 0x0000000000000000
      r16: 0x0000000000000000  r17: 0x0000000000000000  r18: 0x0000000000000000  r19: 0x0000000000000000
      r20: 0x0000000000000000  r21: 0x0000000000000000  r22: 0x0000000000005154  r23: 0x0000000000000001
      r24: 0x0000000000380160  r25: 0x00000000003548e0  r26: 0x00000000a3751c10  r27: 0x00000000a3751854
      r28: 0x0000000000000000  r29: 0x0000000000353ab0  r30: 0x0000000000000000  r31: 0x00000000938443bc

    Binary Images Description:
        0x1000 -    0x4fff com.seosoft.isoko ??? (0.1) /Volumes/Fichiers/kenneth/Desktop/Programation/Programmes/Cocoa/Isoko/build/Release/Isoko.app/Contents/MacOS/Isoko
      0x205000 -  0x234fff com.unsanity.shapeshifter ShapeShifter Version 2.2 (2.2) /Volumes/Fichiers/kenneth/Library/Application Enhancers/ShapeShifter.ape/Contents/MacOS/ShapeShifter
      0x784000 -  0x785fff com.presenta.iGetterIMBundle 2.4 /Volumes/Fichiers/kenneth/Library/InputManagers/iGetterIMBundle/iGetterIMBundle.bundle/Contents/MacOS/iGetterIMBundle
      0x789000 -  0x790fff com.unsanity.smartcrashreports Smart Crash Reports version 1.0.2 (1.0.2) /Volumes/Fichiers/kenneth/Library/InputManagers/Smart Crash Reports/Smart Crash Reports.bundle/Contents/MacOS/Smart Crash Reports
      0x795000 -  0x797fff net.culater.SIMBL 0.8 (8) /Volumes/Fichiers/kenneth/Library/InputManagers/SIMBL/SIMBL.bundle/Contents/MacOS/SIMBL
      0x7a4000 -  0x7a4fff com.ksuther.chaxloader ??? (1.4) /Volumes/Fichiers/kenneth/Library/InputManagers/Chax/Chax.bundle/Contents/MacOS/Chax
      0x7a8000 -  0x7a8fff com.growl.GrowlSafariLoader 1.0 /Volumes/Fichiers/kenneth/Library/InputManagers/GrowlSafari/GrowlSafariLoader.bundle/Contents/MacOS/GrowlSafariLoader
    0x3af5000 -  0x3af7fff com.presenta.iGetterCMPlugIn iGetterCMPlugin version 2.4 (2.4) /Volumes/Fichiers/kenneth/Library/Contextual Menu Items/iGetterCMPlugIn.plugin/Contents/MacOS/iGetterCMPlugIn
    0x3afb000 -  0x3afdfff com.apple.AutomatorCMM 1.0 (48) /System/Library/Contextual Menu Items/AutomatorCMM.plugin/Contents/MacOS/AutomatorCMM
    0x3b00000 -  0x3b04fff com.apple.FolderActionsMenu 1.3 /System/Library/Contextual Menu Items/FolderActionsMenu.plugin/Contents/MacOS/FolderActionsMenu
    0x3b08000 -  0x3b08fff com.apple.SpotLightCM 1.0 (121.20.2) /System/Library/Contextual Menu Items/SpotlightCM.plugin/Contents/MacOS/SpotlightCM
    0x3b0b000 -  0x3b21fff com.pixture.CalculateSizeCM CalculateSizeCM version 1.3 (1.3) /Library/Contextual Menu Items/CalculateSizeCM.plugin/Contents/MacOS/CalculateSizeCM
    0x4cca000 -  0x4d0cfff com.pixture.QuickImageCM QuickImageCM version 2.4 (2.4) /Volumes/Fichiers/kenneth/Library/Contextual Menu Items/QuickImageCM.plugin/Contents/MacOS/QuickImageCM
    0x4d34000 -  0x4d49fff com.roxio.ToastItPlugin ToastIt 1.1.1 (build 16) (1.1.1) /Volumes/Fichiers/kenneth/Library/Contextual Menu Items/ToastIt.plugin/Contents/MacOS/ToastIt
    0x8fa79000 - 0x8fd27fff com.apple.QuickTime 7.0.4 /System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime
    0x8fe00000 - 0x8fe51fff dyld 44.4 /usr/lib/dyld
    0x90000000 - 0x901bbfff libSystem.B.dylib /usr/lib/libSystem.B.dylib
    0x90213000 - 0x90218fff libmathCommon.A.dylib /usr/lib/system/libmathCommon.A.dylib
    0x9021a000 - 0x9026dfff com.apple.CoreText 1.0.1 (???) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreText.framework/Versions/A/CoreText
    0x9029a000 - 0x9034bfff ATS /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
    0x9037a000 - 0x90734fff com.apple.CoreGraphics 1.258.27 (???) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
    0x907c1000 - 0x9089afff com.apple.CoreFoundation 6.4.4 (368.25) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
    0x908e3000 - 0x908e3fff com.apple.CoreServices 10.4 (???) /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
    0x908e5000 - 0x909e7fff libicucore.A.dylib /usr/lib/libicucore.A.dylib
    0x90a41000 - 0x90ac5fff libobjc.A.dylib /usr/lib/libobjc.A.dylib
    0x90aef000 - 0x90b5dfff com.apple.framework.IOKit 1.4 (???) /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
    0x90b74000 - 0x90b86fff libauto.dylib /usr/lib/libauto.dylib
    0x90b8d000 - 0x90e65fff com.apple.CoreServices.CarbonCore 681.3 (671.2) /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
    0x90ecb000 - 0x90f4bfff com.apple.CoreServices.OSServices 4.1 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
    0x90f95000 - 0x90fd6fff com.apple.CFNetwork 129.13 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
    0x90feb000 - 0x91003fff com.apple.WebServices 1.1.2 (1.1.0) /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/WebServicesCore.framework/Versions/A/WebServicesCore
    0x91013000 - 0x91094fff com.apple.SearchKit 1.0.5 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
    0x910da000 - 0x91104fff com.apple.Metadata 10.4.4 (121.36) /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
    0x91115000 - 0x91123fff libz.1.dylib /usr/lib/libz.1.dylib
    0x91126000 - 0x912e9fff com.apple.security 4.3 (25966) /System/Library/Frameworks/Security.framework/Versions/A/Security
    0x913ec000 - 0x913f5fff com.apple.DiskArbitration 2.1 /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
    0x913fc000 - 0x91423fff com.apple.SystemConfiguration 1.8.2 /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
    0x91436000 - 0x91441fff libgcc_s.1.dylib /usr/lib/libgcc_s.1.dylib
    0x91446000 - 0x91466fff libmx.A.dylib /usr/lib/libmx.A.dylib
    0x9146c000 - 0x91474fff libbsm.dylib /usr/lib/libbsm.dylib
    0x91478000 - 0x914f3fff com.apple.audio.CoreAudio 3.0.3 /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
    0x91530000 - 0x91530fff com.apple.ApplicationServices 10.4 (???) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
    0x91532000 - 0x9156afff com.apple.AE 1.5 (297) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
    0x91585000 - 0x91652fff com.apple.ColorSync 4.4.4 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync.framework/Versions/A/ColorSync
    0x916a7000 - 0x91738fff com.apple.print.framework.PrintCore 4.5 (177.10) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore
    0x9177f000 - 0x91836fff com.apple.QD 3.8.19 (???) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD
    0x91873000 - 0x918d1fff com.apple.HIServices 1.5.1 (???) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
    0x918ff000 - 0x91923fff com.apple.LangAnalysis 1.6.1 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis
    0x91937000 - 0x9195cfff com.apple.FindByContent 1.5 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/FindByContent.framework/Versions/A/FindByContent
    0x9196f000 - 0x919b1fff com.apple.LaunchServices 168.10 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
    0x919cd000 - 0x919e1fff com.apple.speech.synthesis.framework 3.3 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
    0x919ef000 - 0x91a2efff com.apple.ImageIO.framework 1.4.6 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO
    0x91a44000 - 0x91b0cfff libcrypto.0.9.7.dylib /usr/lib/libcrypto.0.9.7.dylib
    0x91b5a000 - 0x91b6ffff libcups.2.dylib /usr/lib/libcups.2.dylib
    0x91b74000 - 0x91b91fff libJPEG.dylib /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
    0x91b96000 - 0x91c05fff libJP2.dylib /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libJP2.dylib
    0x91c1c000 - 0x91c20fff libGIF.dylib /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib
    0x91c22000 - 0x91c69fff libRaw.dylib /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libRaw.dylib
    0x91c6e000 - 0x91cabfff libTIFF.dylib /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
    0x91cb2000 - 0x91ccbfff libPng.dylib /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib
    0x91cd0000 - 0x91cd3fff libRadiance.dylib /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib
    0x91cd5000 - 0x91cd5fff com.apple.Accelerate 1.2.1 (Accelerate 1.2.1) /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
    0x91cd7000 - 0x91db7fff com.apple.vImage 2.3 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
    0x91dbf000 - 0x91ddefff com.apple.Accelerate.vecLib 3.2.1 (vecLib 3.2.1) /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib
    0x91e4a000 - 0x91eb8fff libvMisc.dylib /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
    0x91ec3000 - 0x91f57fff libvDSP.dylib /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
    0x91f71000 - 0x924f9fff libBLAS.dylib /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
    0x9252c000 - 0x92857fff libLAPACK.dylib /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
    0x92887000 - 0x9290ffff com.apple.DesktopServices 1.3.3 /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv
    0x92950000 - 0x92b7bfff com.apple.Foundation 6.4.5 (567.26) /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
    0x92c99000 - 0x92d77fff libxml2.2.dylib /usr/lib/libxml2.2.dylib
    0x92d97000 - 0x92e85fff libiconv.2.dylib /usr/lib/libiconv.2.dylib
    0x92e97000 - 0x92eb5fff libGL.dylib /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
    0x92ec0000 - 0x92f1afff libGLU.dylib /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
    0x92f38000 - 0x92f38fff com.apple.Carbon 10.4 (???) /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
    0x92f3a000 - 0x92f4efff com.apple.ImageCapture 3.0 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
    0x92f66000 - 0x92f76fff com.apple.speech.recognition.framework 3.4 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/Versions/A/SpeechRecognition
    0x92f82000 - 0x92f97fff com.apple.securityhi 2.0 (203) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
    0x92fa9000 - 0x93030fff com.apple.ink.framework 101.2 (69) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink
    0x93044000 - 0x9304ffff com.apple.help 1.0.3 (32) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
    0x93059000 - 0x93086fff com.apple.openscripting 1.2.5 (???) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
    0x930a0000 - 0x930b0fff com.apple.print.framework.Print 5.0 (190.1) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
    0x930bc000 - 0x93122fff com.apple.htmlrendering 1.1.2 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HTMLRendering.framework/Versions/A/HTMLRendering
    0x93153000 - 0x931a2fff com.apple.NavigationServices 3.4.4 (3.4.3) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/NavigationServices.framework/Versions/A/NavigationServices
    0x931d0000 - 0x931edfff com.apple.audio.SoundManager 3.9 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CarbonSound.framework/Versions/A/CarbonSound
    0x931ff000 - 0x9320cfff com.apple.CommonPanels 1.2.2 (73) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
    0x93215000 - 0x93522fff com.apple.HIToolbox 1.4.6 (???) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
    0x93671000 - 0x9367dfff com.apple.opengl 1.4.7 /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
    0x93716000 - 0x93716fff com.apple.Cocoa 6.4 (???) /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
    0x93718000 - 0x93d4bfff com.apple.AppKit 6.4.4 (824.33) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
    0x940d8000 - 0x94148fff com.apple.CoreData 80 /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
    0x94181000 - 0x9424bfff com.apple.audio.toolbox.AudioToolbox 1.4.1 /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
    0x9429f000 - 0x9429ffff com.apple.audio.units.AudioUnit 1.4 /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit
    0x942a1000 - 0x94455fff com.apple.QuartzCore 1.4.7 /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
    0x944a8000 - 0x944e5fff libsqlite3.0.dylib /usr/lib/libsqlite3.0.dylib
    0x944ed000 - 0x9453dfff libGLImage.dylib /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib
    0x946e0000 - 0x946effff libCGATS.A.dylib /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libCGATS.A.dylib
    0x946f7000 - 0x94703fff libCSync.A.dylib /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libCSync.A.dylib
    0x94749000 - 0x94761fff libRIP.A.dylib /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libRIP.A.dylib
    0x94768000 - 0x947d9fff libstdc++.6.dylib /usr/lib/libstdc++.6.dylib
    0x96b13000 - 0x96bb6fff libcrypto.0.9.dylib /usr/lib/libcrypto.0.9.dylib
    0xc0000000 - 0xc000ffff com.unsanity.ape 1.5.1 /Library/Frameworks/ApplicationEnhancer.framework/Versions/A/ApplicationEnhancer

    Model: PowerBook3,5, BootROM 4.5.3f2, 1 processors, PowerPC G4  (3.3), 1 GHz, 1 GB
    Graphics: ATY,RV250M9, ATY,RV250M9, AGP, 64 MB
    Memory Module: SODIMM0/J16TOP, 512 MB, SDRAM, PC133U-333
    Memory Module: SODIMM1/J16BOTTOM, 512 MB, SDRAM, PC133U-333
    AirPort: AirPort, 9.52
    Modem: MicroDash, Euro, V.92, 1.0F, APPLE VERSION 2.6.6
    Network Service: AirPort, AirPort, en1
    PCI Card: TXN,PCI1410-02, cardbus, PC Card
    Parallel ATA Device: TOSHIBA MK6021GAS, 55.89 GB
    Parallel ATA Device: MATSHITADVD-R  UJ-815,
    USB Device: Microsoft 3-Button Mouse with IntelliEye(TM), Microsoft, Up to 1.5 Mb/sec, 500 mA
  • BruBru Membre
    13:37 modifié #7
    Bon, il est clair que le problème semble se situer sur setImage:.

    Pour éliminer d'autres pistes, peux tu faire ceci :
    remplacer les [NSImage imageNamed:@...] par l'équivalent :
    NSImage *img;<br />...<br />img=[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForImageResource:@&quot;image.tif&quot;]]<br />[newItem&nbsp; setImage:img];<br />[img release];
    


    Ce test va permettre de mieux cerner l'origine du bug.

    .
  • elfelf Membre
    13:37 modifié #8
    J'ai utilisé ton code et ça fonctionne!

    Je ne comprens toujours pas pourquoi ça fesais cela, et je ne vois qu'une réponse possible.
    Entre ces deux codes il y a une subtile différence:
    Le premier: l'image est autoreleasée alors que avec ton code elle l'est manuellement!
    C'est probablement de la que ça viens...

    En tout cas merci beaucoups!
  • LeChatNoirLeChatNoir Membre, Modérateur
    13:37 modifié #9
    Les images étaient bien incluses dans les ressources de ton projet ?
  • elfelf Membre
    13:37 modifié #10
    Oui oui. D'ailleur si elle ne l'étaient pas ça ne fonctionnerais pas avec la nouvelle manière non plus...
  • LeChatNoirLeChatNoir Membre, Modérateur
    13:37 modifié #11
    Exact. Etrange donc. Il doit y avoir une explication mais là  je vois pas...
  • 13:37 modifié #12
    De toute façon si elles n'y étaient pas, les 2 méthodes renverraient nil et il n'y aurait pas de problème. (l'erreur renvoyée étant fréquente quand un pointeur pointe vers un vers un objet qui a été deallocé)
  • AntilogAntilog Membre
    13:37 modifié #13
    Je ne suis pas certain que ton problème soit corrigé, étant donné que les deux solutions sont équivalentes  :(

    Seulement, les bugs d'autorelease ont la faculté de très facilement se cacher. Le simple fait d'utiliser moins l'autorelease pool dans la seconde solution peut masquer le problème, qui risque de réapparaà®tre plus tard!

    J'ai typiquement ce genre de réaction lorsque je fais un release sur un objet déjà  autoreleasé.

    Le problème étant que le plantage dans ce cas se fait bien après l'erreur, et pas dans le code correspondant  >:(
  • BruBru Membre
    13:37 modifié #14
    dans 1145612461:

    Je ne suis pas certain que ton problème soit corrigé, étant donné que les deux solutions sont équivalentes  :(
    Seulement, les bugs d'autorelease ont la faculté de très facilement se cacher. Le simple fait d'utiliser moins l'autorelease pool dans la seconde solution peut masquer le problème, qui risque de réapparaà®tre plus tard!
    J'ai typiquement ce genre de réaction lorsque je fais un release sur un objet déjà  autoreleasé.
    Le problème étant que le plantage dans ce cas se fait bien après l'erreur, et pas dans le code correspondant  >:(


    La solution que j'ai donné à  Elf était d'éviter l'utilisation de l'autorelasePool...
    Il appert apparemment que le problème est à  ce niveau.

    Et pourquoi le suppute-je ?
    C'est l'énoncé de Elf qui m'a intrigué :
    dans 1145426010:

    Quand j'utilise pour la première fois ce menu tout marche bien, mais des que j'édite une tuile, si j'essaye de faire réapparaitre le menu, l'application plante et retourne un code EXC_BAD_ACCES.

    Quelque chose qui marche 1 fois, mais qui peu de temps après ne marche plus, et génère une erreur mémoire... Ca pue typiquement l'objet qui a été désalloué entre temps !
    Or qu'est ce qui est susceptible de désallouer un objet "un peu plus tard" si ce n'est l'autorelasePool...

    Maintenant, je n'ai pas réussi à  reproduire ce "bug".
    Un menu créé dans un awakeFromNib, qui utilise des images chargées par imageNamed:, et qui  est ensuite attaché à  un NSView via setMenu: ne provoque aucun plantage chez moi.

    D'une part, nous n'avons pas la partie de code intéressante (celle qui permet d'attacher le menu crée à  la vue, ou celle qui appelle le menu), ensuite, il faudrait connaitre la version de l'AppKit qu'il utilise, etc...

    .
  • AntilogAntilog Membre
    13:37 modifié #15
    Oui, j'avais l'impression que Elf se contenait de la solution actuelle à  son problème, c'est pour cela que je m'en suis mêlé  ;)

    Comme tu le dis depuis le début, ça sent l'autorelease!
    Dans ce cas-là , personnellement, je relis les sources en recherchant et vérifiant:
    - les créations d'objets
    - les retain
    - les release et autorelease

    En général, je trouve pas mal de petits problème en regardant de plus près..., surtout des objets qui ne seraient jamais désalloués  >:)

    Mais, bon, c'est aussi parce que je suis bien trop laxiste  :brule:
Connectez-vous ou Inscrivez-vous pour répondre.