Kaydet (Commit) 3ec3220b authored tarafından Lionel Elie Mamane's avatar Lionel Elie Mamane Kaydeden (comit) Christian Lohmaier

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/17268Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>
üst 107edbf3
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment