avoid basic ide crash in code autocompletion

due to code completion and user defined types

type MyType
  a as string
  b as string
end type

dim aa as MyType

typing
aa.b.
the last point led to crash

remaining problem
code autocorrection now shows wrong behaviour as
aa.b.
autocorrects (wrongly) to
aaaa.

Change-Id: I3e05680cd9d82f7dc124c5923f9858e22961896e
Reviewed-on: https://gerrit.libreoffice.org/17824
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Laurent Godard 2015-08-18 09:24:26 +02:00 committed by Caolán McNamara
parent 222f10e773
commit ddb43837ca

View File

@ -860,8 +860,10 @@ void EditorWindow::HandleCodeCompletion()
if( aVect.empty() )//nothing to do if( aVect.empty() )//nothing to do
return; return;
OUString sBaseName = aVect[0];//variable name OUString sBaseName = aVect[0];//variable name
OUString sVarType = aCodeCompleteCache.GetVarType( sBaseName ); OUString sVarType = aCodeCompleteCache.GetVarType( sBaseName );
if( !sVarType.isEmpty() && CodeCompleteOptions::IsAutoCorrectOn() ) if( !sVarType.isEmpty() && CodeCompleteOptions::IsAutoCorrectOn() )
{//correct variable name, if autocorrection on {//correct variable name, if autocorrection on
const OUString& sStr = aCodeCompleteCache.GetCorrectCaseVarName( sBaseName, GetActualSubName(nLine) ); const OUString& sStr = aCodeCompleteCache.GetCorrectCaseVarName( sBaseName, GetActualSubName(nLine) );
@ -3002,6 +3004,10 @@ std::vector< OUString > UnoTypeCodeCompletetor::GetXIdlClassFields() const
bool UnoTypeCodeCompletetor::CheckField( const OUString& sFieldName ) bool UnoTypeCodeCompletetor::CheckField( const OUString& sFieldName )
{// modifies xClass!!! {// modifies xClass!!!
if ( xClass == NULL )
return false;
Reference< reflection::XIdlField> xField = xClass->getField( sFieldName ); Reference< reflection::XIdlField> xField = xClass->getField( sFieldName );
if( xField != NULL ) if( xField != NULL )
{ {
@ -3016,6 +3022,11 @@ bool UnoTypeCodeCompletetor::CheckField( const OUString& sFieldName )
bool UnoTypeCodeCompletetor::CheckMethod( const OUString& sMethName ) bool UnoTypeCodeCompletetor::CheckMethod( const OUString& sMethName )
{// modifies xClass!!! {// modifies xClass!!!
if ( xClass == NULL )
return false;
Reference< reflection::XIdlMethod> xMethod = xClass->getMethod( sMethName ); Reference< reflection::XIdlMethod> xMethod = xClass->getMethod( sMethName );
if( xMethod != NULL ) //method OK, check return type if( xMethod != NULL ) //method OK, check return type
{ {