summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2015-07-21 17:31:56 +0200
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2015-08-07 17:07:42 +0000
commit3ec3220bbb5ed19f4a862a9ad67131f4fc31fbf1 (patch)
tree1ee8528a25f74fec457cb76fb2c7a4c044f2b695 /svx
parent107edbf3c1d109f915b5fbed03d2625c0a45d780 (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 Reviewed-on: https://gerrit.libreoffice.org/17268 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Diffstat (limited to 'svx')
-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 e2ef294cc503..cf4455fa83e3 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;