[fpc-devel] SDL on Mac OS X 10.5 and fpc 2.3.1

2008-05-05 Thread Schindler Karl-Michael

Hi all,

SDL is used in the program Ultrastar.

on macosx 10.5 and fpc 2.3.1 sdl_init leads to a large number of  
warnings.


This is the line with sdl_init:

SDL_Init(SDL_INIT_VIDEO or SDL_INIT_TIMER);

This is the related part of the output:

2008-05-05 01:17:26.689 UltraStar[22982:807] ***
_NSAutoreleaseNoPool(): Object 0x121f0d0 of class NSCFNumber
autoreleased with no pool in place - just leaking

Stack: (0x9609d12f 0x95fa9ec2 0x9577ede1 0x92059b78 0x920584f9
0x92068736 0x957db1aa 0x957d93b0 0x957d90f5 0x957d8aa4 0x957d85e3
0x957d65df 0x4dbc96 0x4d1d0b 0x4a5f70 0x4a5fa7 0x55977 0x2540 0x1cbc5
0x250b 0x2439)
2008-05-05 01:17:26.691 UltraStar[22982:807] ***

_NSAutoreleaseNoPool(): Object 0x121f550 of class NSCFNumber
autoreleased with no pool in place - just leaking

Stack: (0x9609d12f 0x95fa9ec2 0x9577ee19 0x92059b78 0x920584f9
0x92068736 0x957db1aa 0x957d93b0 0x957d90f5 0x957d8aa4 0x957d85e3
0x957d65df 0x4dbc96 0x4d1d0b 0x4a5f70 0x4a5fa7 0x55977 0x2540 0x1cbc5
0x250b 0x2439)

and about 50 more.

the program continues.

later this line

screen := SDL_SetVideoMode(W, H, (Depth+1) * 16, SDL_OPENGL or  
SDL_RESIZABLE)


gives similar output:

2008-05-05 01:17:27.301 UltraStar[22982:807] ***
_NSAutoreleaseNoPool(): Object 0x12520c0 of class
NSMutableParagraphStyle autoreleased with no pool in place - just
leaking

Stack: (0x9609d12f 0x95fa9ec2 0x9578cf64 0x92059b78 0x92059a4c
0x920584f9 0x92068996 0x9578ff52 0x9578fa7a 0x9578f4fe 0x4deb2f
0x4dc2ac 0x4d204e 0x51322 0x50dc1 0x55f90 0x2540 0x1cbc5 0x250b 0x2439)
2008-05-05 01:17:27.302 UltraStar[22982:807] ***

_NSAutoreleaseNoPool(): Object 0x12525b0 of class NSCFDictionary
autoreleased with no pool in place - just leaking

Stack: (0x9609d12f 0x95fa9ec2 0x91b98e5c 0x9578cfa8 0x92059b78
0x92059a4c 0x920584f9 0x92068996 0x9578ff52 0x9578fa7a 0x9578f4fe
0x4deb2f 0x4dc2ac 0x4d204e 0x51322 0x50dc1 0x55f90 0x2540 0x1cbc5
0x250b 0x2439)

going on until the final crash:

2008-05-05 01:17:27.342 UltraStar[22982:807] ***
_NSAutoreleaseNoPool(): Object 0x1256e30 of class NSCFData
autoreleased with no pool in place - just leaking

Stack: (0x9609d12f 0x95fa9ec2 0x95fbe2a5 0x95fbde81 0x91b9c1e2
0x9205d0fb 0x95874b81 0x95790683 0x9578fb41 0x9578f4fe 0x4deb2f
0x4dc2ac 0x4d204e 0x51322 0x50dc1 0x55f90 0x2540 0x1cbc5 0x250b 0x2439)

2008-05-05 01:17:27.343 UltraStar[22982:807] *** Terminating app due
to uncaught exception 'NSInternalInconsistencyException', reason:
'Error (1002) creating CGSWindow'

2008-05-05 01:17:27.344 UltraStar[22982:807] Stack: (
2444870219,
2449854715,
2444869675,
2444869738,
2508676964,
2508671815,
2507736707,
2507733825,
250773,
5106479,
5096108,
5054542,
332578,
331201,
352144,
9536,
117701,
9483,
9273
)
Trace/BPT trap

Any help or hints? - Michael Schindler aka mischi.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] SDL on Mac OS X 10.5 and fpc 2.3.1

2008-05-05 Thread Adriaan van Os

Schindler Karl-Michael wrote:


SDL is used in the program Ultrastar.

on macosx 10.5 and fpc 2.3.1 sdl_init leads to a large number of warnings.

This is the line with sdl_init:

SDL_Init(SDL_INIT_VIDEO or SDL_INIT_TIMER);

This is the related part of the output:

2008-05-05 01:17:26.689 UltraStar[22982:807] ***
_NSAutoreleaseNoPool(): Object 0x121f0d0 of class NSCFNumber
autoreleased with no pool in place - just leaking


This problem disappears if you alloc and init an NSAutoreleasePool object, see 
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSAutoreleasePool_Class/Reference/Reference.html


Regards,

Adriaan van Os
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] SDL on Mac OS X 10.5 and fpc 2.3.1

2008-05-05 Thread Jonas Maebe


On 05 May 2008, at 09:50, Schindler Karl-Michael wrote:


SDL is used in the program Ultrastar.

on macosx 10.5 and fpc 2.3.1 sdl_init leads to a large number of  
warnings.


This is the line with sdl_init:

   SDL_Init(SDL_INIT_VIDEO or SDL_INIT_TIMER);

This is the related part of the output:

2008-05-05 01:17:26.689 UltraStar[22982:807] ***
_NSAutoreleaseNoPool(): Object 0x121f0d0 of class NSCFNumber
autoreleased with no pool in place - just leaking


This happens if libSDL_main is not used (properly). Did you follow the  
instructions at http://wiki.lazarus.freepascal.org/FPC_and_SDL#Mac_OS_X_specific_issues 
 ?


(in particular the -XMSDL_main parameter)


Jonas
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] VarArray 64bit clean patch

2008-05-05 Thread petr . kristan
On Mon, Apr 28, 2008 at 10:19:37AM +0200, [EMAIL PROTECTED] wrote:
 On Sat, Apr 26, 2008 at 07:28:46PM +0200, Florian Klaempfl wrote:
  [EMAIL PROTECTED] schrieb:
  Hi.
  
  Today I worked on VarArrays. Here is 64-bit friendly VariantArray
  patch.
  Testing program is attached too. Implementation was tested on i386
  and
  AMD64 linux with valgrind.
  
  The patch is contains more changes. Are they tested too? What's
  their 
  purpose?
My previous version of patch breaks windows VarArray implementation
using oleaut32.dll. In attachment is new commented patch.
Patch leaves varInt64 and varQWord disabled in variants.pp 
(VarTypeIsValidArrayType),
but internally supports them.

Patch was tested on Linux i386, AMD64 and Win32 by attached program
vari.pas. Behaviour is the same on all platforms. Test was compilled
with Delphi and Kylix with the same results.

Comments are welcome.

Petr

-- 
Ing. Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709
Index: rtl/inc/variants.pp
===
--- rtl/inc/variants.pp	(revision 10840)
+++ rtl/inc/variants.pp	(working copy)
# Enables inserting variants arrays into variant -- my old patch from 21.03.
@@ -3223,7 +3223,7 @@
   Result:=true
 else
   begin
-Result:=(aVarType and not(varByRef)) in [varEmpty,varNull,varSmallInt,varInteger,
+Result:=(aVarType and not(varByRef) and not(varArray)) in [varEmpty,varNull,varSmallInt,varInteger,
 {$ifndef FPUNONE}
   varSingle,varDouble,varDate,
 {$endif}
Index: rtl/objpas/varutils.inc
===
--- rtl/objpas/varutils.inc	(revision 10840)
+++ rtl/objpas/varutils.inc	(working copy)
# Enables internally varShortInt,varWord,varLongWord,varInt64,varQWord elements in VarArray
@@ -379,22 +379,17 @@
   end;
 end;
 
-Type
-  TVartypes = varEmpty..varByte;
-
 Const
-  Supportedpsas : set of TVarTypes =
-[varSmallint,varInteger,
+  Supportedpsas = [varSmallint,varInteger,
 {$ifndef FPUNONE}
  varSingle,varDouble,varCurrency,varDate,
 {$endif}
- varOleStr,varDispatch,varError,varBoolean,varVariant,varUnknown,varByte];
-  psaElementSizes : Array [varEmpty..varByte] of Byte =
-(0,0,2,4,4,8,8,8,4,4,4,2,16,4,0,0,0,1);
-  psaElementFlags : Array [varEmpty..varByte] of Longint =
+ varOleStr,varDispatch,varError,varBoolean,varVariant,varUnknown,varShortInt,varByte,
+ varWord,varLongWord,varInt64,varQWord];
+  psaElementFlags : Array [varEmpty..varQWord] of Longint =
 (ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,
  ARR_OLESTR,ARR_DISPATCH,ARR_NONE,ARR_NONE,ARR_VARIANT,ARR_UNKNOWN,
- ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE);
+ ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE);
 
 Function SafeArrayCreate(VarType, Dim: DWord; const Bounds: TVarArrayBoundArray): PVarArray;stdcall;
   var
# Remake calculating ElementSize from static const array psaElementSizes to 64-bit friendly SizeOf function   
@@ -409,7 +404,31 @@
   exit;
 Result^.DimCount:=Dim;
 Result^.Flags:=psaElementFlags[VarType];
-Result^.ElementSize:=psaElementSizes[VarType];
+case VarType of
+  varEmpty: Result^.ElementSize:=0;
+  varNull: Result^.ElementSize:=0;
+  varSmallInt: Result^.ElementSize:=SizeOf(SmallInt);
+  varInteger: Result^.ElementSize:=SizeOf(Integer);
+{$ifndef FPUNONE}
+  varSingle: Result^.ElementSize:=SizeOf(Single);
+  varDouble: Result^.ElementSize:=SizeOf(double);
+  varCurrency: Result^.ElementSize:=SizeOf(Currency);
+  varDate: Result^.ElementSize:=SizeOf(TDatetime);
+{$endif}
+  varOleStr: Result^.ElementSize:=SizeOf(PWideString);
+  varDispatch: Result^.ElementSize:=SizeOf(IInterface);
+  varError: Result^.ElementSize:=SizeOf(TError);
+  varBoolean: Result^.ElementSize:=SizeOf(Boolean);
+  varVariant: Result^.ElementSize:=SizeOf(TVarData);
+  varUnknown: Result^.ElementSize:=SizeOf(IUnknown);
+  varDecimal: Result^.ElementSize:=0; //???
+  varShortInt: Result^.ElementSize:=SizeOf(ShortInt);
+  varByte: Result^.ElementSize:=SizeOf(Byte);
+  varWord: Result^.ElementSize:=SizeOf(Word);
+  varLongWord: Result^.ElementSize:=SizeOf(LongWord);
+  varInt64: Result^.ElementSize:=SizeOf(Int64);
+  varQWord: Result^.ElementSize:=SizeOf(QWord);
+end;
 Result^.LockCount := 0;
 for i:=0 to Dim-1 do
   begin
# Enables varOleStr Get/Put into VarArray   
@@ -722,7 +741,7 @@
   vatInterface:
 NoInterfaces; // Just assign...
   vatWideString:
-NoWideStrings; // Just assign...
+CopyAsWideString(PWideChar(Data^), PWideChar(P^));
 end;
   except
 On E : Exception do
@@ -747,7 +766,7 @@
   vatInterface:
 NoInterfaces;
   vatWideString:
-NoWideStrings;
+

[fpc-devel] How to use fpFlock?

2008-05-05 Thread amir

Hi,

I have many process wanting to write in a file. Each process is going to 
open the file as a writeonly (using Assignfile and rewrite or fpOpen 
with o_WrOnly). But there is a risk that two processes simultaneously 
trying to write a message in the file. I want to use fpflock to avoid 
this. Is it possible? What I done is something like this:


AssignFile (OutputFile, FileName);
fpflock (OutputFile, LOCK_EX);
Rewrite (OutputFile);
...

The description of fpFlock does not  say anything about the default 
behavior of fpFlock (Is it blocking?). What I saw told me that it is not 
blocking.


Is it the correct way of using fpFlock?


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel