summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRachit Gupta <rachitgupta1792@gmail.com>2014-07-10 23:23:12 +0530
committerRachit Gupta <rachitgupta1792@gmail.com>2014-07-10 23:23:12 +0530
commitbba5ba8a7e02e8f35d1a5f9e65723a19fdc57d28 (patch)
treef624a5f3e5b7bc2d93b207b598b7f5f77975e4d0
parentThe "Select personas installed via extensions" label is invisible by default. (diff)
downloadcore-bba5ba8a7e02e8f35d1a5f9e65723a19fdc57d28.tar.gz
core-bba5ba8a7e02e8f35d1a5f9e65723a19fdc57d28.zip
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
-rw-r--r--cui/source/options/personalization.cxx28
-rw-r--r--cui/source/options/personalization.hxx3
2 files changed, 26 insertions, 5 deletions
diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx
index e67318a7ce0e..d69076eb2f4a 100644
--- a/cui/source/options/personalization.cxx
+++ b/cui/source/options/personalization.cxx
@@ -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;
diff --git a/cui/source/options/personalization.hxx b/cui/source/options/personalization.hxx
index a09226e14254..92ce3de819f2 100644
--- a/cui/source/options/personalization.hxx
+++ b/cui/source/options/personalization.hxx
@@ -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