summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2015-07-21 17:31:56 +0200
committerLionel Elie Mamane <lionel@mamane.lu>2015-07-21 18:05:51 +0200
commitba30fabf3ca88fedc05d521c9ec06a0b77007661 (patch)
treed04218c5a24e9d18a3bd693d036c6b44fd8421c3
parentb28ec7f462fcbb612b1c8a89af84c7c2601a5c65 (diff)
Listen to error only while operating on controller.
Else, on any action done directly (not through the FormControllerHelper) on the controller and raising an SQL error, this would silently swallow the error message, and the operation would fail without any message to the user. E.g. when validating an insertion or modification in a grid control by moving the cursor to a different line (as opposed to clicking the "Save Record" button). Change-Id: Ie569d9c826609f803f7b312c0469907155558ef2
-rw-r--r--svx/source/form/formcontrolling.cxx12
1 files changed, 7 insertions, 5 deletions
diff --git a/svx/source/form/formcontrolling.cxx b/svx/source/form/formcontrolling.cxx
index db5d2be47e18..6fcf0a7b6782 100644
--- a/svx/source/form/formcontrolling.cxx
+++ b/svx/source/form/formcontrolling.cxx
@@ -240,11 +240,6 @@ namespace svx
m_xFormOperations = FormOperations::createWithFormController( comphelper::getProcessComponentContext(), _rxController );
if ( m_xFormOperations.is() )
m_xFormOperations->setFeatureInvalidation( this );
-
- // to prevent the controller from displaying any error messages which happen while we operate on it,
- // we add ourself as XSQLErrorListener. By contract, a FormController displays errors if and only if
- // no SQLErrorListeners are registered.
- _rxController->addSQLErrorListener( this );
}
catch( const Exception& )
{
@@ -333,6 +328,11 @@ namespace svx
const_cast< FormControllerHelper* >( this )->m_aOperationError.clear();
try
{
+ // to prevent the controller from displaying any error messages which happen while we operate on it,
+ // we add ourself as XSQLErrorListener. By contract, a FormController displays errors if and only if
+ // no SQLErrorListeners are registered.
+ m_xFormOperations->getController()->addSQLErrorListener( const_cast< FormControllerHelper* >(this) );
+
switch ( _eWhat )
{
case COMMIT_CONTROL:
@@ -359,10 +359,12 @@ namespace svx
}
catch ( const SQLException& )
{
+ m_xFormOperations->getController()->removeSQLErrorListener( const_cast< FormControllerHelper* >(this) );
aError = ::cppu::getCaughtException();
}
catch( const Exception& )
{
+ m_xFormOperations->getController()->removeSQLErrorListener( const_cast< FormControllerHelper* >(this) );
SQLException aFallbackError;
aFallbackError.Message = ::comphelper::anyToString( ::cppu::getCaughtException() );
aError <<= aFallbackError;