@ -382,7 +382,6 @@ RPCConsole::RPCConsole(const PlatformStyle *_platformStyle, QWidget *parent) :
// based timer interface
// based timer interface
RPCSetTimerInterfaceIfUnset ( rpcTimerInterface ) ;
RPCSetTimerInterfaceIfUnset ( rpcTimerInterface ) ;
startExecutor ( ) ;
setTrafficGraphRange ( INITIAL_TRAFFIC_GRAPH_MINS ) ;
setTrafficGraphRange ( INITIAL_TRAFFIC_GRAPH_MINS ) ;
ui - > detailWidget - > hide ( ) ;
ui - > detailWidget - > hide ( ) ;
@ -396,7 +395,6 @@ RPCConsole::RPCConsole(const PlatformStyle *_platformStyle, QWidget *parent) :
RPCConsole : : ~ RPCConsole ( )
RPCConsole : : ~ RPCConsole ( )
{
{
GUIUtil : : saveWindowGeometry ( " nRPCConsoleWindow " , this ) ;
GUIUtil : : saveWindowGeometry ( " nRPCConsoleWindow " , this ) ;
Q_EMIT stopExecutor ( ) ;
RPCUnsetTimerInterface ( rpcTimerInterface ) ;
RPCUnsetTimerInterface ( rpcTimerInterface ) ;
delete rpcTimerInterface ;
delete rpcTimerInterface ;
delete ui ;
delete ui ;
@ -565,6 +563,14 @@ void RPCConsole::setClientModel(ClientModel *model)
autoCompleter = new QCompleter ( wordList , this ) ;
autoCompleter = new QCompleter ( wordList , this ) ;
ui - > lineEdit - > setCompleter ( autoCompleter ) ;
ui - > lineEdit - > setCompleter ( autoCompleter ) ;
autoCompleter - > popup ( ) - > installEventFilter ( this ) ;
autoCompleter - > popup ( ) - > installEventFilter ( this ) ;
// Start thread to execute RPC commands.
startExecutor ( ) ;
}
if ( ! model ) {
// Client model is being set to 0, this means shutdown() is about to be called.
// Make sure we clean up the executor thread
Q_EMIT stopExecutor ( ) ;
thread . wait ( ) ;
}
}
}
}
@ -759,9 +765,8 @@ void RPCConsole::browseHistory(int offset)
void RPCConsole : : startExecutor ( )
void RPCConsole : : startExecutor ( )
{
{
QThread * thread = new QThread ;
RPCExecutor * executor = new RPCExecutor ( ) ;
RPCExecutor * executor = new RPCExecutor ( ) ;
executor - > moveToThread ( thread ) ;
executor - > moveToThread ( & thread ) ;
// Replies from executor object must go to this object
// Replies from executor object must go to this object
connect ( executor , SIGNAL ( reply ( int , QString ) ) , this , SLOT ( message ( int , QString ) ) ) ;
connect ( executor , SIGNAL ( reply ( int , QString ) ) , this , SLOT ( message ( int , QString ) ) ) ;
@ -769,16 +774,15 @@ void RPCConsole::startExecutor()
connect ( this , SIGNAL ( cmdRequest ( QString ) ) , executor , SLOT ( request ( QString ) ) ) ;
connect ( this , SIGNAL ( cmdRequest ( QString ) ) , executor , SLOT ( request ( QString ) ) ) ;
// On stopExecutor signal
// On stopExecutor signal
// - queue executor for deletion (in execution thread)
// - quit the Qt event loop in the execution thread
// - quit the Qt event loop in the execution thread
connect ( this , SIGNAL ( stopExecutor ( ) ) , executor , SLOT ( deleteLater ( ) ) ) ;
connect ( this , SIGNAL ( stopExecutor ( ) ) , & thread , SLOT ( quit ( ) ) ) ;
connect ( this , SIGNAL ( stopExecutor ( ) ) , thread , SLOT ( quit ( ) ) ) ;
// - queue executor for deletion (in execution thread)
// Queue the thread for deletion (in this thread) when it is finished
connect ( & thread , SIGNAL ( finished ( ) ) , executor , SLOT ( deleteLater ( ) ) , Qt : : DirectConnection ) ;
connect ( thread , SIGNAL ( finished ( ) ) , thread , SLOT ( deleteLater ( ) ) ) ;
connect ( & thread , SIGNAL ( finished ( ) ) , this , SLOT ( test ( ) ) , Qt : : DirectConnection ) ;
// Default implementation of QThread::run() simply spins up an event loop in the thread,
// Default implementation of QThread::run() simply spins up an event loop in the thread,
// which is what we want.
// which is what we want.
thread - > start ( ) ;
thread . start ( ) ;
}
}
void RPCConsole : : on_tabWidget_currentChanged ( int index )
void RPCConsole : : on_tabWidget_currentChanged ( int index )