Mercurial > dwindows
changeset 2404:d4a044d24529
iOS: Fix crashes with full dwtest run. More thread safety.
Fix missing textStorage in DWMLE init with NSTextContainer.
Retain DWContainer because it might be getting deallocated between threads.
Maybe unnecessary lastAddPoint/lastQueryPoint variable names...
think the retain fixed it, but not sure.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 28 Mar 2021 17:15:13 +0000 |
parents | 20f05d3a9c64 |
children | 38c17a19e00d |
files | ios/dw.m |
diffstat | 1 files changed, 46 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/ios/dw.m Sun Mar 28 07:43:45 2021 +0000 +++ b/ios/dw.m Sun Mar 28 17:15:13 2021 +0000 @@ -1513,7 +1513,7 @@ UIColor *fgcolor, *oddcolor, *evencolor; unsigned long dw_oddcolor, dw_evencolor; unsigned long _DW_COLOR_ROW_ODD, _DW_COLOR_ROW_EVEN; - int lastAddPoint, lastQueryPoint; + int iLastAddPoint, iLastQueryPoint; id scrollview; int filesystem; } @@ -1659,9 +1659,9 @@ { unsigned long start = [tvcols count] * index; NSIndexSet *set = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(start, start + [tvcols count])]; - if(index < lastAddPoint) - { - lastAddPoint++; + if(index < iLastAddPoint) + { + iLastAddPoint++; } [data insertObjects:input atIndexes:set]; [titles insertPointer:NULL atIndex:index]; @@ -1675,7 +1675,7 @@ { if(data) { - lastAddPoint = (int)[titles count]; + iLastAddPoint = (int)[titles count]; [data addObjectsFromArray:input]; [titles addPointer:NULL]; [rowdatas addPointer:NULL]; @@ -1690,7 +1690,7 @@ int count = (int)(number * [tvcols count]); int z; - lastAddPoint = (int)[titles count]; + iLastAddPoint = (int)[titles count]; for(z=0;z<count;z++) { @@ -1736,9 +1736,9 @@ oldtitle = [titles pointerAtIndex:row]; [titles removePointerAtIndex:row]; [rowdatas removePointerAtIndex:row]; - if(lastAddPoint > 0 && lastAddPoint > row) - { - lastAddPoint--; + if(iLastAddPoint > 0 && iLastAddPoint > row) + { + iLastAddPoint--; } if(oldtitle) free(oldtitle); @@ -1760,9 +1760,9 @@ -(void *)getRowData:(int)row { if(rowdatas && row > -1) { return [rowdatas pointerAtIndex:row]; } return NULL; } -(id)getRow:(int)row and:(int)col { if(data && [data count]) { int index = (int)(row * [tvcols count]) + col; return [data objectAtIndex:index]; } return nil; } -(int)cellType:(int)col { return [[types objectAtIndex:col] intValue]; } --(int)lastAddPoint { return lastAddPoint; } --(int)lastQueryPoint { return lastQueryPoint; } --(void)setLastQueryPoint:(int)input { lastQueryPoint = input; } +-(int)lastAddPoint { return iLastAddPoint; } +-(int)lastQueryPoint { return iLastQueryPoint; } +-(void)setLastQueryPoint:(int)input { iLastQueryPoint = input; } -(void)clear { if(data) @@ -1777,7 +1777,7 @@ free(oldtitle); } } - lastAddPoint = 0; + iLastAddPoint = 0; } -(void)setup { @@ -2818,7 +2818,10 @@ * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). * pad: Number of pixels to pad around the box. */ -HWND API dw_scrollbox_new( int type, int pad ) +DW_FUNCTION_DEFINITION(dw_scrollbox_new, HWND, int type, int pad) +DW_FUNCTION_ADD_PARAM2(type, pad) +DW_FUNCTION_RETURN(dw_scrollbox_new, HWND) +DW_FUNCTION_RESTORE_PARAM2(type, int, pad, int) { DWScrollBox *scrollbox = [[DWScrollBox alloc] init]; DWBox *box = dw_box_new(type, pad); @@ -2827,7 +2830,7 @@ [scrollbox setBox:box]; [scrollbox addSubview:tmpbox]; [tmpbox autorelease]; - return scrollbox; + DW_FUNCTION_RETURN_THIS(scrollbox); } /* @@ -3847,7 +3850,7 @@ /* Internal common function to create containers and listboxes */ HWND _dw_cont_new(ULONG cid, int multi) { - DWContainer *cont = [[DWContainer alloc] init]; + DWContainer *cont = [[[DWContainer alloc] init] retain]; [cont setAllowsMultipleSelection:(multi ? YES : NO)]; [cont setDataSource:cont]; @@ -3872,6 +3875,7 @@ DW_FUNCTION_INIT; DWContainer *cont = _dw_cont_new(cid, multi); [cont setup]; + [cont addColumn:@"" andType:DW_CFA_STRING]; DW_FUNCTION_RETURN_THIS(cont); } @@ -4248,7 +4252,9 @@ DW_FUNCTION_RETURN(dw_mle_new, HWND) DW_FUNCTION_RESTORE_PARAM1(cid, ULONG) { - DWMLE *mle = [[DWMLE alloc] init]; + CGRect frame = CGRectMake(0, 0, 100, 50); + NSTextContainer *tc = [[NSTextContainer alloc] initWithSize:frame.size]; + DWMLE *mle = [[DWMLE alloc] initWithFrame:frame textContainer:tc]; UIScrollView *scrollview = [[UIScrollView alloc] init]; CGSize size = [mle intrinsicContentSize]; @@ -6771,7 +6777,10 @@ * handle: Handle to the window. * action: One of the DW_HTML_* constants. */ -void API dw_html_action(HWND handle, int action) +DW_FUNCTION_DEFINITION(dw_html_action, void, HWND handle, int action) +DW_FUNCTION_ADD_PARAM2(handle, action) +DW_FUNCTION_NO_RETURN(dw_html_action) +DW_FUNCTION_RESTORE_PARAM2(handle, HWND, action, int) { DWWebView *html = handle; switch(action) @@ -6796,6 +6805,7 @@ case DW_HTML_PRINT: break; } + DW_FUNCTION_RETURN_NOTHING; } /* @@ -6807,11 +6817,15 @@ * Returns: * 0 on success. */ -int API dw_html_raw(HWND handle, const char *string) +DW_FUNCTION_DEFINITION(dw_html_raw, int, HWND handle, const char *string) +DW_FUNCTION_ADD_PARAM2(handle, string) +DW_FUNCTION_RETURN(dw_html_raw, int) +DW_FUNCTION_RESTORE_PARAM2(handle, HWND, string, const char *) { DWWebView *html = handle; + int retval = DW_ERROR_NONE; [html loadHTMLString:[ NSString stringWithUTF8String:string ] baseURL:nil]; - return DW_ERROR_NONE; + DW_FUNCTION_RETURN_THIS(retval); } /* @@ -6823,11 +6837,15 @@ * Returns: * 0 on success. */ -int API dw_html_url(HWND handle, const char *url) +DW_FUNCTION_DEFINITION(dw_html_url, int, HWND handle, const char *url) +DW_FUNCTION_ADD_PARAM2(handle, url) +DW_FUNCTION_RETURN(dw_html_url, int) +DW_FUNCTION_RESTORE_PARAM2(handle, HWND, url, const char *) { DWWebView *html = handle; + int retval = DW_ERROR_NONE; [html loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[ NSString stringWithUTF8String:url ]]]]; - return DW_ERROR_NONE; + DW_FUNCTION_RETURN_THIS(retval); } /* @@ -6840,9 +6858,13 @@ * Returns: * DW_ERROR_NONE (0) on success. */ -int dw_html_javascript_run(HWND handle, const char *script, void *scriptdata) +DW_FUNCTION_DEFINITION(dw_html_javascript_run, int, HWND handle, const char *script, void *scriptdata) +DW_FUNCTION_ADD_PARAM3(handle, script, scriptdata) +DW_FUNCTION_RETURN(dw_html_javascript_run, int) +DW_FUNCTION_RESTORE_PARAM3(handle, HWND, script, const char *, scriptdata, void *) { DWWebView *html = handle; + int retval = DW_ERROR_NONE; DW_LOCAL_POOL_IN; [html evaluateJavaScript:[NSString stringWithUTF8String:script] completionHandler:^(NSString *result, NSError *error) @@ -6851,7 +6873,7 @@ _dw_event_handler(html, (UIEvent *)params, 18); }]; DW_LOCAL_POOL_OUT; - return DW_ERROR_NONE; + DW_FUNCTION_RETURN_THIS(retval); } /*