Re: [fpc-pascal] Problem with interfaces

2007-08-26 Thread Joao Morais

Joao Morais wrote:
I simply don't know how to register the issue since I can't create a 
small sample that reproduce it, but I can send about 1 mb of sources to 
a volunteer though.


Was this one forgotten? Let me know how can I help.

--
Joao Morais

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


Re: [fpc-pascal] Problem with interfaces

2007-08-21 Thread Joao Morais

Micha Nelissen wrote:

Joao Morais wrote:

The first call that I make to DefaultObj from *another* unit recreate
the object, because, I don't know why, the _holder var points again to nil.


Try to use a data watchpoint to watch when the variable is being
changed. Hopefully that will point to the root cause.


Thanks for the advice.

Have tried 'watch _MVPFACTORY', gdb confirmed a hardware watchpoint, it 
complains a little (Hardware watchpoint 1: _MVPFACTORY -- 20 times) when 
I run the application but don't stop. Did I miss something?



Did you also try
printing the address of the variable (I assume global variables aren't
moving, but who knows?)


Always the same address.

Well, what I have observed so far: this issue happens when the variable 
points to an interface, changing to an object pointer the problem 
disapear. Moreover the _release method of the interface isn't called so 
it sounds rather impossible that my code is changing the value of the 
variable. Compiling and launching the code with D5 the problem disapear.


I simply don't know how to register the issue since I can't create a 
small sample that reproduce it, but I can send about 1 mb of sources to 
a volunteer though.


Thanks for your help.

--
Joao Morais
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Problem with interfaces

2007-08-20 Thread Micha Nelissen
Joao Morais wrote:
> The first call that I make to DefaultObj from *another* unit recreate
> the object, because, I don't know why, the _holder var points again to nil.

Try to use a data watchpoint to watch when the variable is being
changed. Hopefully that will point to the root cause. Did you also try
printing the address of the variable (I assume global variables aren't
moving, but who knows?)

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


Re: [fpc-pascal] Problem with interfaces

2007-08-20 Thread Joao Morais

Darius Blaszijk wrote:
I've had similar issues some time ago. Have you tried FPC 2.3.1? It has 
a some interface fixes.


Nope. Trunk, rev. 8290 and still broken :-/

Thanks.

--
Joao Morais





Joao Morais wrote:


Hello,

I have the following code:

{$mode objfpc}
interface

...

function DefaultObj: TObject;

implementation

var
  _Holder: IHolder;

function DefaultObj: TObject;
begin
  if not Assigned(_Holder) then
_Holder := THolder.Create(TSomeClass.Create);
  Result := _Holder.Instance;
end;

IHolder is an interface that the THolder class implements. The first 
call to the DefaultObj function creates the holder instance, as 
expected. New calls to the same function doesn't recreate it. Again, 
as expected.


The first call that I make to DefaultObj from *another* unit recreate 
the object, because, I don't know why, the _holder var points again to 
nil.


Changing the type of the _holder to THolder (ie an object pointer 
instead of an interface pointer) everything works flawlessly.


I have tried to create a small sample but couldn't reproduce the 
issue, anyway the source of the problem is gpl code. It fails under 
2.0.4 and current fixes_2_2 branch. Hints?


Thanks.

--
Joao Morais




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


Re: [fpc-pascal] Problem with interfaces

2007-08-19 Thread Darius Blaszijk
I've had similar issues some time ago. Have you tried FPC 2.3.1? It has 
a some interface fixes.


Darius

Joao Morais wrote:


Hello,

I have the following code:

{$mode objfpc}
interface

...

function DefaultObj: TObject;

implementation

var
  _Holder: IHolder;

function DefaultObj: TObject;
begin
  if not Assigned(_Holder) then
_Holder := THolder.Create(TSomeClass.Create);
  Result := _Holder.Instance;
end;

IHolder is an interface that the THolder class implements. The first 
call to the DefaultObj function creates the holder instance, as 
expected. New calls to the same function doesn't recreate it. Again, 
as expected.


The first call that I make to DefaultObj from *another* unit recreate 
the object, because, I don't know why, the _holder var points again to 
nil.


Changing the type of the _holder to THolder (ie an object pointer 
instead of an interface pointer) everything works flawlessly.


I have tried to create a small sample but couldn't reproduce the 
issue, anyway the source of the problem is gpl code. It fails under 
2.0.4 and current fixes_2_2 branch. Hints?


Thanks.

--
Joao Morais

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



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


[fpc-pascal] Problem with interfaces

2007-08-19 Thread Joao Morais


Hello,

I have the following code:

{$mode objfpc}
interface

...

function DefaultObj: TObject;

implementation

var
  _Holder: IHolder;

function DefaultObj: TObject;
begin
  if not Assigned(_Holder) then
_Holder := THolder.Create(TSomeClass.Create);
  Result := _Holder.Instance;
end;

IHolder is an interface that the THolder class implements. The first 
call to the DefaultObj function creates the holder instance, as 
expected. New calls to the same function doesn't recreate it. Again, as 
expected.


The first call that I make to DefaultObj from *another* unit recreate 
the object, because, I don't know why, the _holder var points again to nil.


Changing the type of the _holder to THolder (ie an object pointer 
instead of an interface pointer) everything works flawlessly.


I have tried to create a small sample but couldn't reproduce the issue, 
anyway the source of the problem is gpl code. It fails under 2.0.4 and 
current fixes_2_2 branch. Hints?


Thanks.

--
Joao Morais

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