Professional Web Applications Themes

NSOutlineView, calling reloadData during setObjectValue causes crash? - Mac Programming

I've got two very similar things going on in both an NSOutlineView and an NSTableView. If the user edits the text in the leftmost column, this changes the key in a dictionary, which can cause the data to be reordered. If this happens in outlineView:setObjectValue:forTableColumn:byItem, I send a reloadData: to the NSOutlineView instance after the data used by the data source has been changed. In an NSTableView, this works fine. In an NSOutlineView, this causes a crash sometime after setObjectValue: has returned. I've checked and re-checked my data source. Especially since an NSTableView works just fine, is there a known ...

  1. #1

    Default NSOutlineView, calling reloadData during setObjectValue causes crash?

    I've got two very similar things going on in both an NSOutlineView and an
    NSTableView. If the user edits the text in the leftmost column, this
    changes the key in a dictionary, which can cause the data to be reordered.
    If this happens in outlineView:setObjectValue:forTableColumn:byItem, I send
    a reloadData: to the NSOutlineView instance after the data used by the data
    source has been changed.

    In an NSTableView, this works fine. In an NSOutlineView, this causes a
    crash sometime after setObjectValue: has returned. I've checked and
    re-checked my data source. Especially since an NSTableView works just fine,
    is there a known problem or limitation that isn't doented about doing
    this in an NSOutlineView? If there's something else I need to do instead,
    what is it?

    Paul Forgey Guest

  2. #2

    Default Re: NSOutlineView, calling reloadData during setObjectValue causescrash?

    In <OTidndWhkvX6IPuiXTWc-gspeakeasy.net> Paul Forgey wrote:
    > I've got two very similar things going on in both an NSOutlineView and
    > an NSTableView. If the user edits the text in the leftmost column,
    > this changes the key in a dictionary, which can cause the data to be
    > reordered. If this happens in outlineView:setObjectValue:
    > forTableColumn:byItem, I send a reloadData: to the NSOutlineView
    > instance after the data used by the data source has been changed.
    >
    > In an NSTableView, this works fine. In an NSOutlineView, this causes
    > a crash sometime after setObjectValue: has returned. I've checked and
    > re-checked my data source. Especially since an NSTableView works just
    > fine, is there a known problem or limitation that isn't doented
    > about doing this in an NSOutlineView? If there's something else I
    > need to do instead, what is it?
    If you believe the problem is that you're calling reloadData *during*
    setObjectValue, then you can test that hypothesis by calling reloadData *
    after* setObjectValue has returned. You can arrange that easily through
    delayed execution. m.

    --
    matt neuburg, phd = [email]matttidbits.com[/email], [url]http://www.tidbits.com/matt[/url]
    REALbasic: The Definitive Guide! 2nd edition!
    [url]http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt[/url]
    Subscribe to TidBITS. It's free and smart.
    matt neuburg Guest

  3. #3

    Default Re: NSOutlineView, calling reloadData during setObjectValue causes crash?

    matt neuburg <matttidbits.com> wrote in message news:<20030916095229915-0700news.la.sbcglobal.net>...
    > In <OTidndWhkvX6IPuiXTWc-gspeakeasy.net> Paul Forgey wrote:
    > > I've got two very similar things going on in both an NSOutlineView and
    > > an NSTableView. If the user edits the text in the leftmost column,
    > > this changes the key in a dictionary, which can cause the data to be
    > > reordered. If this happens in outlineView:setObjectValue:
    > > forTableColumn:byItem, I send a reloadData: to the NSOutlineView
    > > instance after the data used by the data source has been changed.
    > >
    > > In an NSTableView, this works fine. In an NSOutlineView, this causes
    > > a crash sometime after setObjectValue: has returned. I've checked and
    > > re-checked my data source. Especially since an NSTableView works just
    > > fine, is there a known problem or limitation that isn't doented
    > > about doing this in an NSOutlineView? If there's something else I
    > > need to do instead, what is it?
    >
    > If you believe the problem is that you're calling reloadData *during*
    > setObjectValue, then you can test that hypothesis by calling reloadData *
    > after* setObjectValue has returned. You can arrange that easily through
    > delayed execution. m.
    I'm not quite certain how I would go about doing that. I did,
    however, add a temporary method to send a reloadData to the
    NSOutlineView in response to a temporary menu item. The NSOutlineView
    reloads just fine when I do this (that doesn't solve my problem of
    course).

    I'm not certain calling reloadData during setObjectValue is really the
    problem, since the doentation seems to suggest reloadData simply
    sets a flag that is read the next time the view is displayed.
    Paul Forgey Guest

  4. #4

    Default Re: NSOutlineView, calling reloadData during setObjectValue causes crash?

    In article <207eddbd.0309171145.5397a6f7posting.google.com >,
    [email]paulfaphrodite.com[/email] (Paul Forgey) wrote:
    > > You can arrange that easily through
    > > delayed execution. m.
    >
    > I'm not quite certain how I would go about doing that.
    It is (as usual with Cocoa) unbelievably easy.

    Instead of:

    [thingy reloadData]

    you do:

    [thingy performSelector:selector(reloadData) withObject:nil withDelay:0]

    This will send reloadData once you get done doing what you're doing and
    your program returns to the run loop.
    Michael Ash Guest

  5. #5

    Default Re: NSOutlineView, calling reloadData during setObjectValue causes crash?

    Michael Ash <mailmikeash.com> wrote in message news:<mail-5C9C01.22033817092003localhost>...
    > In article <207eddbd.0309171145.5397a6f7posting.google.com >,
    > [email]paulfaphrodite.com[/email] (Paul Forgey) wrote:
    >
    > > > You can arrange that easily through
    > > > delayed execution. m.
    > >
    > > I'm not quite certain how I would go about doing that.
    >
    > It is (as usual with Cocoa) unbelievably easy.
    >
    > Instead of:
    >
    > [thingy reloadData]
    >
    > you do:
    >
    > [thingy performSelector:selector(reloadData) withObject:nil withDelay:0]
    >
    > This will send reloadData once you get done doing what you're doing and
    > your program returns to the run loop.
    That solved it. Thanks! This means reloadData: does do more than
    setting a state flag, and the NSOutlineView in fact can't handle
    reloadData: during setObjectData:
    Paul Forgey Guest

Similar Threads

  1. #40677 [NEW]: PHP crash when calling Java
    By poon dot fung at comcast dot net in forum PHP Bugs
    Replies: 7
    Last Post: July 18th, 12:19 AM
  2. Replies: 2
    Last Post: November 28th, 04:28 PM
  3. Replies: 2
    Last Post: November 15th, 04:06 PM
  4. InDesign CS CE non-stop CRASH, CRASH, CRASH, CRASH, CRASH, CRASH
    By kajzica@adobeforums.com in forum Adobe Indesign Windows
    Replies: 15
    Last Post: July 2nd, 07:57 PM
  5. Replies: 0
    Last Post: July 29th, 10:54 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139