summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorRachit Gupta <rachitgupta1792@gmail.com>2014-07-10 23:23:12 +0530
committerJan Holesovsky <kendy@collabora.com>2014-08-14 19:43:32 +0200
commite372d28cbd29cbcd1d36e397a681693272cf9407 (patch)
treecfc554a8592b989ec0f9a10d0f54227976326763 /cui
parent95771f49f064ff7ff6daaee45d4716c930fd5cbb (diff)
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
Diffstat (limited to 'cui')
-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 0d47b7ea493e..58606a84c2b3 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 a3fc9086cfff..2ef49e93b26e 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