371 views
in GUI Development by

 

The application code is built for the Raspberry Pi 4...

code snippet...

1. send a request with a callback (signal( slot as the third param,...

NewSequence.TableTransaction( MWModelObjects::TableSequences, MWModel::RowTransactionType.Create, SequenceAdded );

 

2. The application code executes... and a signal command "OnTransactionCompleted" is called (containing the SequenceAdded slot passed as a parameter)

pure ErrorCode = aErrorCode;
pure NewUUID = aNewUUID;

trace "MWModel::RowTransaction.TransactionCompleted about to call OnTransactionCompleted, error, UUID ", ErrorCode, NewUUID;

signal OnTransactionCompleted;

 

3 The callback, run via the signal comand...

var class clsof = classof sender;
var MWModel::RowTransaction transaction = (MWModel::RowTransaction)sender;

trace "Slot Data::SeqenceSaver.SequenceAdded clsof ", clsof;
trace "Slot Data::SeqenceSaver.SequenceAdded sender ", sender;

The sender object is null, if you try to use a trace line to print out the address trace Slot Data::SeqenceSaver.SequenceAdded sender ", sender; the application crashes with a segmentation error.

I would have thought the sender object should never be null, it should always hold the address of the calling (signalling object).

Does anyone know what's going on?

 

 

.

 

 

 

2 Answers

0 votes
by

Hi Andy,
Please check if your slot is also attached to any observer or called via idlesignal.
The implicit parameter sender can be null. Please see Use the implicit parameter sender.
You can set a breakpoint within your slot and check on the call stack if it is called via 'signal'.

Hope this helps,
Rudolf

by

The sender object does seem to contain the required object... but when type cast in the slot code null is returned....

Tracing through the generated C code….

/* 'C' function for method : 'Data::SequenceSaver.SequenceAdded()' */

void DataSequenceSaver_SequenceAdded( DataSequenceSaver _this, XObject sender )

{

  XClass clsof;

  MWModelRowTransaction transaction;

  EwTrace( "%s", EwLoadString( &_Const003B ));

  EwTrace( "%s%*", EwLoadString( &_Const003C ), _this->NewSequence );

  clsof = EwClassOf( sender );

  transaction = EwCastObject( sender, MWModelRowTransaction );

  EwTrace( "%s%$", EwLoadString( &_Const003D ), clsof );

  EwTrace( "%s%*", EwLoadString( &_Const003E ), sender );

  if (( transaction != 0 ) && ( _this->NewSequence != 0 ))

  {

    _this->NewSequenceID = transaction->NewUUID;

    EwTrace( "%s", EwConcatString( EwConcatString( EwLoadString( &_Const003F ),

      EwNewStringInt( _this->NewSequenceID, 0, 10 )), EwLoadString( &_Const0033 )));

    DataSequenceSaver_addTests( _this );

  }

  else

    EwSignal( _this->Super1.OnFinished, ((XObject)_this ));

}

The sender object passed into the function (XObject sender) seems to be of the correct type

Looking at the debugger trace  (MWModelRowTransaction), 

 

But then the sender is cast to MWModelRowTransaction in the code a null is returned (examining transaction using the debugger) ???

Yet the types should match, so why is a null returned,

and why casting the sender to a raw class pointer also returns a null?

 

 

+1 vote
by

Found the problem....

// A Garbadge collection issue !!
var MWModel::RowTransaction transaction = aTable.StartTransaction( aTransactionType, ID );
transaction.OnTransactionCompleted = aOnTransactionCompleted;
 

The pointer was stored locally in the function... (var MWModel::RowTransaction transaction)

The  function containing the [transaction] object pointer terminated,  the OnTransactionComplete slot is fired by a signal command within the transaction object,

The pointer to class MWModel::RowTransaction, (the sender object) had been garbage collected and potentially corrupt and therefore marked as null.

 

 

 

Embedded Wizard Website | Privacy Policy | Imprint

...