[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: some help with NSBrowser needed
From: |
Sebastian Reitenbach |
Subject: |
Re: some help with NSBrowser needed |
Date: |
Wed, 02 Jan 2013 19:24:22 +0100 |
User-agent: |
SOGoMail 2.0.3 |
On Tuesday, January 1, 2013 22:59 CET, Fred Kiefer <fredkiefer@gmx.de> wrote:
> I think the problematic line is this one:
>
> browser = [[NSBrowser alloc] init];
Even commenting out that line, it still brings up the window, and I still get
the
warning about the negative width.
A backtrace is below, in case of interest.
>
> You create a browser with a zero size frame. (The -init method of NSView
> calls -initWithFrame: with NSZeroRect) When the browser later tries to
> draw its various parts, some of these may end up with negative sizes.
> you could set a breakpoint on NSView.m:1182 to find out which parts are
> affected.
>
> If your code works on Cocoa, but not on GNUstep, we might have to change
> the default rectangle for NSBrowser.
Don't know about if/how it works with Cocoa. I'm lacking a mac ;)
But what I tried was to create a test app, just with minimal code what I have,
and what can I say, this just seems to work. So, now I only need to figure out
why one works, the other not.
thanks,
Sebastian
#0 -[NSView setFrame:] (self=0x832ee404, _cmd=0x2f0b6430, frameRect=
{origin = {x = 21, y = 2}, size = {width = -23, height = 4}})
at NSView.m:1180
#1 0x0f186abd in -[NSClipView setFrame:] (self=0x832ee404, _cmd=0x2f1463e8,
rect={origin = {x = 21, y = 2}, size = {width = -23, height = 4}})
at NSClipView.m:580
#2 0x0f2d9976 in -[NSView resizeWithOldSuperviewSize:] (self=0x832ee404,
_cmd=0x2f1463d0, oldSize={width = 100, height = 100}) at NSView.m:2060
#3 0x0f2d2690 in -[NSView resizeSubviewsWithOldSize:] (self=0x832ee304,
_cmd=0x2f116688, oldSize={width = 100, height = 100}) at NSView.m:1935
#4 0x0f262dcb in -[NSScrollView resizeSubviewsWithOldSize:] (self=0x832ee304,
_cmd=0x2f146320, oldSize=The value of variable 'oldSize' is distributed
across several
locations, and GDB cannot access its value.
) at NSScrollView.m:1270
#5 0x0f2d94b8 in -[NSView setFrame:] (self=0x832ee304, _cmd=0x2f116608,
frameRect={origin = {x = 0, y = 23}, size = {width = 0, height = 0}})
at NSView.m:1228
#6 0x0f2632d9 in -[NSScrollView setFrame:] (self=0x832ee304, _cmd=0x2f0abc00,
rect={origin = {x = 0, y = 23}, size = {width = 0, height = 0}})
at NSScrollView.m:1057
#7 0x0f170822 in -[NSBrowser tile] (self=0x7e3afa04, _cmd=0x2f0aba80)
at NSBrowser.m:1972
#8 0x0f16cfa4 in -[NSBrowser displayColumn:] (self=0x7e3afa04,
_cmd=0x2f0abf18, column=0) at NSBrowser.m:874
#9 0x0f16eaca in -[NSBrowser(Private) _performLoadOfColumn:] (
---Type <return> to continue, or q <return> to quit---
self=0x7e3afa04, _cmd=0x2f0aba78, column=0) at NSBrowser.m:3106
#10 0x0f16d27e in -[NSBrowser addColumn] (self=0x7e3afa04, _cmd=0x2f0ab970)
at NSBrowser.m:817
#11 0x0f16ca4e in -[NSBrowser loadColumnZero] (self=0x7e3afa04,
_cmd=0x2f0ab9b8) at NSBrowser.m:1057
#12 0x0f17012c in -[NSBrowser setPath:] (self=0x7e3afa04, _cmd=0x3c01aa70,
path=0x3c01a4d0) at NSBrowser.m:572
#13 0x1c01c043 in -[CollectionBrowser awakeFromNib] (self=0x888adf04,
_cmd=0x2f169d90) at CollectionBrowser.m:64
#14 0x0f335266 in -[GSNibContainer awakeWithContext:] (self=0x8adecd04,
_cmd=0x2f180348, context=0x7e8b5a04) at GSGormLoading.m:250
#15 0x0f369164 in -[GSGormLoader loadModelData:externalNameTable:withZone:] (
self=0x81b49754, _cmd=0x2f0f6830, data=0x81b49154, context=0x7e8b5a04,
zone=0x233af300) at GSGormLoader.m:120
#16 0x0f21bb76 in -[NSNib instantiateNibWithExternalNameTable:withZone:] (
self=0x835b9664, _cmd=0x2f0ad3b0, externalNameTable=0x7e8b5a04,
zone=0x233af300) at NSNib.m:153
#17 0x0f1747d5 in +[NSBundle(NSBundleAdditions)
loadNibFile:externalNameTable:withZone:] (self=0x2334a1a0, _cmd=0x2f14f3e8,
fileName=0x805f3f84,
context=0x7e8b5a04, zone=0x233af300) at NSBundleAdditions.m:236
#18 0x0f2f91f5 in -[NSWindowController loadWindow] (self=0x888adf04,
_cmd=0x2f14f308) at NSWindowController.m:482
#19 0x0f2f7d41 in -[NSWindowController window] (self=0x888adf04,
---Type <return> to continue, or q <return> to quit---
_cmd=0x2f14f288) at NSWindowController.m:312
#20 0x0f2f83d8 in -[NSWindowController showWindow:] (self=0x888adf04,
_cmd=0x3c0052e8, sender=0x80c66e04) at NSWindowController.m:392
#21 0x1c0041a0 in -[AppController browseCollectionByDirectory:] (
self=0x80c66e04, _cmd=0x88a2b790, sender=0x8469a084) at AppController.m:172
#22 0x0f142412 in -[NSApplication sendAction:to:from:] (self=0x8802bb04,
_cmd=0x2f0ef920, aSelector=0x88a2b790, aTarget=0x80c66e04,
sender=0x8469a084) at NSApplication.m:2231
#23 0x0f209d71 in -[NSMenu performActionForItemAtIndex:] (self=0x8881e4c4,
_cmd=0x2f0f2620, index=1) at NSMenu.m:1315
#24 0x0f21474e in -[NSMenuView _trackWithEvent:startingMenuView:] (
self=0x7fc11804, _cmd=0x2f0f2688, event=0x8b842104, mainWindowMenuView=0x0)
at NSMenuView.m:1819
#25 0x0f211870 in -[NSMenuView trackWithEvent:] (self=0x7fc11804,
_cmd=0x2f0f26f8, event=0x7fdc49c4) at NSMenuView.m:1851
#26 0x0f211adf in -[NSMenuView mouseDown:] (self=0x7fc11804, _cmd=0x2f14dca0,
theEvent=0x7fdc49c4) at NSMenuView.m:1891
#27 0x0f2f2cb9 in -[NSWindow sendEvent:] (self=0x7fc11a04, _cmd=0x2f09ea80,
theEvent=0x7fdc49c4) at NSWindow.m:3790
#28 0x0f144d5c in -[NSApplication sendEvent:] (self=0x8802bb04,
_cmd=0x2f09e9b8, theEvent=0x7fdc49c4) at NSApplication.m:2106
#29 0x0f147bc5 in -[NSApplication run] (self=0x8802bb04, _cmd=0x2f094488)
at NSApplication.m:1563
---Type <return> to continue, or q <return> to quit---
#30 0x0f126ad3 in NSApplicationMain (argc=1, argv=0xcfbd5890) at Functions.m:91
#31 0x1c01c724 in gnustep_base_user_main (argc=1, argv=0xcfbd5890) at main.m:30
#32 0x0343d58e in main (argc=1, argv=Cannot access memory at address 0xc0010
) at NSProcessInfo.m:984
#33 0x1c003767 in ___start (argc=1, argv=0xcfbd5890, envp=0xcfbd5898,
cleanup=0, obj=0x0, ps_strings=0xcfbfdff0)
at /usr/src/lib/csu/i386/crt0.c:104
#34 0x1c0036e2 in _start () at /usr/src/lib/csu/i386/crt0.c:77
>
> Hope this helps,
> Fred
>
>
> On 01.01.2013 18:17, Sebastian Reitenbach wrote:
> > for MPDCon, i want to have a filesystem like browser to browse through the
> > music
> > directories. The Interface is created in Gorm, and in my class, I
> > implemented the
> > "passive" NSBrowser delegate methods:
> >
> > - (NSInteger)browser:(NSBrowser *)sender
> > numberOfRowsInColumn:(NSInteger)column;
> > - (void)browser:(NSBrowser *)sender willDisplayCell:(id)cell
> > atRow:(NSInteger)row column:(NSInteger)column;
> >
> > My class is a subclass of NSWindowController, and is just a NSWindow, with
> > a NSBrowser in it, and one IBOutlet NSBrowser *browser.
> >
> > I can see that both delegate methods get called from within awakeFromNib.
> > There at the end I have:
> >
> > browser = [[NSBrowser alloc] init];
> > [browser setDelegate:self];
> > [browser setPath:@"/"];
> > }
> >
> > the setPath: actually triggers calling the delegate methods. I have some
> > NSLogs in them, to see if
> > they get called:
> >
> > 2013-01-01 17:56:10.400 MPDCon[2484] here in numberOfRowsInColumn 0
> > 2013-01-01 17:56:10.400 MPDCon[2484] returning count: 5
> > 2013-01-01 17:56:10.760 MPDCon[2484] here in willDisplayCell
> > <NSBrowserCell: 0x80c95704> 0 0, adding: /reggae
> > 2013-01-01 17:56:11.031 MPDCon[2484] here in willDisplayCell
> > <NSBrowserCell: 0x80c95584> 1 0, adding: /techno
> > 2013-01-01 17:56:11.287 MPDCon[2484] here in willDisplayCell
> > <NSBrowserCell: 0x80c95044> 2 0, adding: /ska
> > 2013-01-01 17:56:11.539 MPDCon[2484] here in willDisplayCell
> > <NSBrowserCell: 0x80c955c4> 3 0, adding: /folk
> > 2013-01-01 17:56:11.786 MPDCon[2484] here in willDisplayCell
> > <NSBrowserCell: 0x80c95144> 4 0, adding: /other
> > 2013-01-01 17:56:11.787 MPDCon[2484] File NSView.m: 1182. In -[NSView
> > setFrame:] given negative width
> >
> > The delegate methods, as I have them for now, can be seen below.
> > It's my first time dealing with NSBrowser, so I hope its just something
> > easy that I have overlooked while
> > trying to figure out what's (not) going on.
> > I also wonder about the last line of the output from NSView, what this
> > could be about?
> > I'm on OpenBSD i386.
> >
> > cheers,
> > Sebastian
> >
> >
> > - (NSInteger)browser:(NSBrowser *)sender
> > numberOfRowsInColumn:(NSInteger)column
> > {
> > NSLog(@"here in numberOfRowsInColumn %d", column);
> > NSInteger count, blubb=0;
> > NSEnumerator *dirEnum;
> > NSString *dir;
> > NSMutableArray *tmpArray = [NSMutableArray array];
> >
> > dirEnum = [directories objectEnumerator];
> >
> > while ((dir = [dirEnum nextObject]) != nil && blubb < 5)
> > {
> > if ([[dir pathComponents] count] >= column)
> > {
> > dir = [[dir pathComponents] objectAtIndex:column];
> > if (![tmpArray containsObject:dir])
> > {
> > [tmpArray addObject:dir];
> > blubb++;
> > }
> > }
> > }
> > count = [tmpArray count];
> > [tmpArray release];
> > NSLog(@"returning count: %d", count);
> > return count;
> > }
> >
> > - (void)browser:(NSBrowser *)sender willDisplayCell:(id)cell
> > atRow:(NSInteger)row column:(NSInteger)column
> > {
> > NSEnumerator *dirEnum;
> > NSString *dir;
> > NSMutableArray *tmpArray = [NSMutableArray array];
> >
> > dirEnum = [directories objectEnumerator];
> >
> > while ((dir = [dirEnum nextObject]) != nil)
> > {
> > if ([[dir pathComponents] count] >= column)
> > {
> > dir = [[dir pathComponents] objectAtIndex:column];
> > if (![tmpArray containsObject:dir])
> > {
> > //[tmpArray addObject:dir];
> > [tmpArray addObject:[NSString stringWithFormat:@"/%@", dir]];
> > }
> > }
> > }
> > NSLog(@"here in willDisplayCell %@ %d %d, adding: %@", cell, row, column,
> > [tmpArray objectAtIndex:row]);
> > [cell setStringValue:[tmpArray objectAtIndex:row]];
> > [cell setTitle:[tmpArray objectAtIndex:row]];
> > [cell setLoaded: YES];
> > }
>
>
> _______________________________________________
> Discuss-gnustep mailing list
> Discuss-gnustep@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnustep