diff --git a/.gitattributes b/.gitattributes index 76081617b2..fbed7d1294 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11695,6 +11695,7 @@ tests/webtbs/tw1948.pp svneol=native#text/plain tests/webtbs/tw1950.pp svneol=native#text/plain tests/webtbs/tw19548.pp svneol=native#text/pascal tests/webtbs/tw1964.pp svneol=native#text/plain +tests/webtbs/tw19700.pp svneol=native#text/plain tests/webtbs/tw1996.pp svneol=native#text/plain tests/webtbs/tw2001.pp svneol=native#text/plain tests/webtbs/tw2002.pp svneol=native#text/plain diff --git a/compiler/ncgutil.pas b/compiler/ncgutil.pas index 4303aba898..9040632a26 100644 --- a/compiler/ncgutil.pas +++ b/compiler/ncgutil.pas @@ -1037,7 +1037,11 @@ implementation tmploc:=l; location_force_mem(list,tmploc); cg.a_load_loc_cgpara(list,tmploc,cgpara); - location_freetemp(list,tmploc); + { do not free the tmploc in case the original value was + already in memory, because the caller (ncgcal) will then + free it again later } + if not(l.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then + location_freetemp(list,tmploc); end else {$endif not cpu64bitalu} diff --git a/tests/webtbs/tw19700.pp b/tests/webtbs/tw19700.pp new file mode 100644 index 0000000000..142ba08f02 --- /dev/null +++ b/tests/webtbs/tw19700.pp @@ -0,0 +1,26 @@ +{ %target=darwin } +{ %norun } + +{$mode objfpc} +{$modeswitch objectivec1} + +program Main; +uses + CocoaAll; + +type + TSomeView = objcclass (NSView) + function canvasPointFromEvent (theEvent: NSEvent): NSPoint; message 'canvasPointFromEvent:'; + end; + +function TSomeView.canvasPointFromEvent (theEvent: NSEvent): NSPoint; +begin + result := convertPoint_fromView(theEvent.locationInWindow, nil); +end; + +var + argc: LongInt; + argv: PPChar; +begin + NSApplicationMain(argc, argv); +end.