Hi Pritpal,
first of all I hope text below will be clear because argument is complex and my English is not very good as my C knowledge.
Sometimes can be useful delay emitting signals (give me a cent for this).
Reading Qt docs related with QObject connect, can be used a numeric argument to informs Qt about "connection type"
(
http://doc.qt.io/qt-5/qt.html#ConnectionType-enum)
I'm interested about Qt::QueuedConnection as Qt doc writes:
"The slot is invoked when control returns to the event loop of the receiver's thread. The slot is executed in the receiver's thread."Perhaps, perhaps, ... this can solve the problem, but I need to do test
So, I read
hbqt_misc.prg about
:connect() method and than
hbqt_hbqslots.cpp about
hbqt_connect(...) function
In the last function, we have two situations
Qt: HBQT_CONNECT( object, signal, object, string ) related with hbqt_QtConnect
HB: HBQT_CONNECT( object, signal, codeblock ) related with hbConnect
both
hbqt_QtConnect and
hbConnect use
Qt::AutoConnection by default (and this is right as per Qt doc).
But I'm not able to do test because this argument can't be used with HbQt.
The question: can be added this numeric argument?
eg
hbqtObject:connect( <signal>, <block> [,<connectionType] )Alternative: can you guide me to write (see below) right C code?
I have figured out a (skeleton) solution, but remember: I'm not C programmer
HB_FUNC( HBQT_CONNECT )
{
int ret = -1;
int iPCount = hb_pcount();
int connectionType = Qt::AutoConnection
if ( ( iPCount >= 3 && HB_ISBLOCK( 3 ) ) HB_ISBLOCK give us the ability to distinguish about Qt or HB call
{
// arguments for hbConnect
connectionType = iPCount < 4 ? Qt::AutoConnection : hb_parni( 4 );
// here check connectionType >= Qt::AutoConnection && <= Qt::UniqueConnection by default Qt::AutoConnection
// but I dont' know right C code
// more or less your code but hbconnect with one more argument
if( HB_ISCHAR( 2 ) && hbqt_par_isDerivedFrom( 1, "QOBJECT" ) )
{
HBQSlots * receiverSlots = hbqt_bindGetReceiverSlotsByHbObject( hb_param( 1, HB_IT_OBJECT ) );
if( receiverSlots )
{
ret = receiverSlots->hbConnect( ....., connectionType );
hb_retni( ret );
}
}
// hbConnect failure
hb_errRT_BASE( EG_ARG, 9999, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
else
{
// arguments for hbqt_QtConnect OR general failure
connectionType = iPCount < 5 ? Qt::AutoConnection : hb_parni( 5 );
// here check connectionType >= Qt::AutoConnection && <= Qt::UniqueConnection by default Qt::AutoConnection
// but I dont' know right C code
// more or less your code but hbqt_QtConnect with one more argument
if( HB_ISCHAR( 2 ) && HB_ISCHAR( 4 ) && hbqt_par_isDerivedFrom( 1, "QOBJECT" ) && hbqt_par_isDerivedFrom( 3, "QOBJECT" ) )
{
ret = hbqt_QtConnect( ....., connectionType );
hb_retni( ret );
}
// hbqt_QtConnect OR general failure
hb_errRT_BASE( EG_ARG, 9999, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}Now
hbConnect with one more argument "int connectionType" (probably we need to re-check argument if function can be called somewhere)
Instead of
if( QMetaObject::connect( object, signalId, this, slotId + QObject::staticMetaObject.methodCount(), Qt::AutoConnection ) )we can call
if( QMetaObject::connect( object, signalId, this, slotId + QObject::staticMetaObject.methodCount(), connectionType ) )Now
hbqt_QtConnect with one more argument "int connectionType" (probably we need to re-check argument if function can be called somewhere)
Instead of
if( QMetaObject::connect( sender, signalId, receiver, slotId, Qt::AutoConnection ) )we can call
if( QMetaObject::connect( sender, signalId, receiver, slotId, connectionType ) )Best regards
Luigi Ferraris