[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - svx/source

Lionel Elie Mamane lionel at mamane.lu
Fri Aug 7 10:08:04 PDT 2015


 svx/source/form/formcontrolling.cxx |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

New commits:
commit 3ec3220bbb5ed19f4a862a9ad67131f4fc31fbf1
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Tue Jul 21 17:31:56 2015 +0200

    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 at libreoffice.org>
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>

diff --git a/svx/source/form/formcontrolling.cxx b/svx/source/form/formcontrolling.cxx
index e2ef294..cf4455f 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;


More information about the Libreoffice-commits mailing list