Kaydet (Commit) e372d28c authored tarafından Rachit Gupta's avatar Rachit Gupta Kaydeden (comit) Jan Holesovsky

Fixed thread related issues.

Added a data member m_bExecute which defaults to true but is set to
false when StopExecution is called. During execution, the member's value
is checked at various positions, if it is false, the execution is stopped
by returning from the execute method.

Following issues have been resolved:

* Multiple searches can be performed. The previous search is halted.
* Cancel button can be pressed in between any search or application of
  the persona.
* A theme can be selected and applied by clicking on OK while the search
  is being done.

Change-Id: Ic76c224ca0d317a6e1a44b3e8933a3ba50b371cb
üst 95771f49
......@@ -112,7 +112,10 @@ OUString SelectPersonaDialog::GetSelectedPersona() const
IMPL_LINK( SelectPersonaDialog, SearchPersonas, PushButton*, pButton )
{
OUString searchTerm;
if( pButton == m_pSearchButton)
if( m_rSearchThread.is() )
m_rSearchThread->StopExecution();
if( pButton == m_pSearchButton )
searchTerm = m_pEdit->GetText();
else
{
......@@ -146,14 +149,17 @@ IMPL_LINK( SelectPersonaDialog, ActionOK, PushButton*, /* pButton */ )
}
else
{
if( m_rSearchThread.is() )
m_rSearchThread->StopExecution();
EndDialog( RET_OK );
}
return 0;
}
IMPL_LINK( SelectPersonaDialog, ActionCancel, PushButton*, /* pButton */ )
{
if( m_rSearchThread.is() )
m_rSearchThread->terminate();
m_rSearchThread->StopExecution();
EndDialog( RET_CANCEL );
return 0;
......@@ -161,6 +167,9 @@ IMPL_LINK( SelectPersonaDialog, ActionCancel, PushButton*, /* pButton */ )
IMPL_LINK( SelectPersonaDialog, SelectPersona, PushButton*, pButton )
{
if( m_rSearchThread.is() )
m_rSearchThread->StopExecution();
for( sal_Int32 index = 0; index < 9; index++ )
{
if( pButton == m_vResultList[index] )
......@@ -526,7 +535,8 @@ SearchAndParseThread::SearchAndParseThread( SelectPersonaDialog* pDialog,
const OUString& rURL ) :
Thread( "cuiPersonasSearchThread" ),
m_pPersonaDialog( pDialog ),
m_aURL( rURL )
m_aURL( rURL ),
m_bExecute( true )
{
}
......@@ -587,6 +597,9 @@ void SearchAndParseThread::execute()
aFilter.ImportGraphic( aGraphic, aURLObj );
Bitmap aBmp = aGraphic.GetBitmap();
if( !m_bExecute )
return;
// for VCL to be able to do visual changes in the thread
SolarMutexGuard aGuard;
m_pPersonaDialog->SetImages( Image( aBmp ), nIndex++ );
......@@ -594,8 +607,10 @@ void SearchAndParseThread::execute()
m_pPersonaDialog->AddPersonaSetting( aPersonaSetting );
}
SolarMutexGuard aGuard;
if( !m_bExecute )
return;
SolarMutexGuard aGuard;
sProgress = "";
m_pPersonaDialog->SetProgress( sProgress );
m_pPersonaDialog->setOptimalLayoutSize();
......@@ -657,6 +672,9 @@ void SearchAndParseThread::execute()
return;
}
if( !m_bExecute )
return;
SolarMutexGuard aGuard;
aPersonaSetting = aHeaderFile + ";" + aFooterFile + ";" + aTextColor + ";" + aAccentColor;
......
......@@ -116,6 +116,7 @@ private:
SelectPersonaDialog *m_pPersonaDialog;
OUString m_aURL;
bool m_bExecute;
virtual ~SearchAndParseThread();
virtual void execute() SAL_OVERRIDE;
......@@ -125,6 +126,8 @@ public:
SearchAndParseThread( SelectPersonaDialog* pDialog,
const OUString& rURL );
void StopExecution() { m_bExecute = false; }
};
#endif // INCLUDED_CUI_SOURCE_OPTIONS_PERSONALIZATION_HXX
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment