037943c
From 920ad92631734fea28178577f7ad10579fd3ca05 Mon Sep 17 00:00:00 2001
037943c
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
037943c
Date: Thu, 18 Dec 2014 15:24:05 +0000
037943c
Subject: [PATCH] Resolves: rhbz#1175142 nStarts ends up as an invalid -1
037943c
037943c
Change-Id: Ic67c5562d0e9936cd6a524ecd4f798aaf885a6e8
037943c
(cherry picked from commit 1cd9420755dc5d5435bf564a992b727c455a3d73)
037943c
(cherry picked from commit 4e8ae0f8187a9d3fa77d737f5de248cfd9b0ed55)
037943c
---
037943c
 vcl/source/control/combobox.cxx | 7 +++++--
037943c
 1 file changed, 5 insertions(+), 2 deletions(-)
037943c
037943c
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
037943c
index a5810f2..8620102 100644
037943c
--- a/vcl/source/control/combobox.cxx
037943c
+++ b/vcl/source/control/combobox.cxx
037943c
@@ -297,7 +297,7 @@ IMPL_LINK( ComboBox, ImplAutocompleteHdl, Edit*, pEdit )
037943c
     {
037943c
         OUString    aFullText = pEdit->GetText();
037943c
         OUString    aStartText = aFullText.copy( 0, (sal_Int32)aSel.Max() );
037943c
-        sal_Int32      nStart = mpImplLB->GetCurrentPos();
037943c
+        sal_Int32   nStart = mpImplLB->GetCurrentPos();
037943c
 
037943c
         if ( nStart == LISTBOX_ENTRY_NOTFOUND )
037943c
             nStart = 0;
037943c
@@ -308,7 +308,10 @@ IMPL_LINK( ComboBox, ImplAutocompleteHdl, Edit*, pEdit )
037943c
         else if ( eAction == AUTOCOMPLETE_TABBACKWARD )
037943c
         {
037943c
             bForward = false;
037943c
-            nStart = nStart ? nStart - 1 : mpImplLB->GetEntryList()->GetEntryCount()-1;
037943c
+            if (nStart)
037943c
+                nStart = nStart - 1;
037943c
+            else if (mpImplLB->GetEntryList()->GetEntryCount())
037943c
+                nStart = mpImplLB->GetEntryList()->GetEntryCount()-1;
037943c
         }
037943c
 
037943c
         sal_Int32 nPos = LISTBOX_ENTRY_NOTFOUND;
037943c
-- 
037943c
1.9.3
037943c