Hi Viktor,

My test cannot fail with the current version of TGET since :Pos() will not allow the assignment to :nPos of a non-editable position. Therefore, this issue is closed. HOWEVER...

I do not like to see such fragile code - The loop in :DelEnd() is highly dependent on other methods in order to not fail (ie. the :Pos() method). Some future change could cause this loop to go into an endless state again.

Therefore, IMHO, protection against this should be added to this loop. IOW, any loop should have a clear exit strategy which is NOT dependant on code outside of the scope of that method.

Regards,
Randy.


At 10:44 AM 6/26/2008, you wrote:
Hi Randy,

Okay, that clears it up.

Before implementing your fix, I think it would be
best to find such a test case which exploits it.

This way maybe we can even find a better fix on
lower level.

Brgds,
Viktor

On 2008.06.26., at 15:15, Randy Portnoff wrote:

Hi Viktor,

I am very sorry, I just realized I am using an older version of TGET
- In the current TGET, the :Pos() method does not allow the
assignment of a non-editable position to the :nPos var - Therefore,
in the case below, when you assign o:pos := 1, it is actually
assigning 2 and thereby protecting the loop in :DelEnd().

Again, sorry... However, I still feel that the loop in DelEnd()
looks dangerous!

Regards,
Randy.


At 08:17 AM 6/26/2008, you wrote:
Hi Randy,

I've added a small test case, but I couldn't reproduce the loop:

  cStr07 := Space(20)
  SetPos( 14, 16 )
  o := _GET_( cStr07, "cStr07", "(999) 999-9999",, )
  o:display()
  o:setFocus()
  o:pos := 1
  o:delEnd()

What am I missing?

Brgds,
Viktor

On 2008.06.25., at 19:27, Randy Portnoff wrote:

Hi Viktor,

Ok, I think I know what is happening here and is partially my fault
- However, I still feel that extra protection needs to be added to
this loop.

The picture is "(999) 999-9999"

When this endless loop occurs, I am doing this:

oGet:Pos := 1
oGet:DelEnd()

I say this is my fault since I am setting :Pos to 1, but the first
position is not an editable position.

So, what is happening is that nPos is getting set to 1 in :DelEnd()
(due to my assignment above) and then ::Pos is stopping at 2
since :Left() in :backSpaceLow() cannot get to 1 (due to the
picture) and hence the endless loop.

So, I fixed this in my Harbour build by checking for a change
to ::nPos as follows:

METHOD delEnd() CLASS Get

 LOCAL nPos, nLast

 IF ::hasFocus

    nPos := ::nPos
    ::pos := ::nMaxEdit
    nLast := ::nPos + 1

    ::deleteLow()
    DO WHILE ::nPos > nPos .and. ::nPos < nLast
       nLast := ::nPos
       ::backSpaceLow()
    ENDDO

    ::display()
 ENDIF

 RETURN Self


At 12:10 PM 6/25/2008, you wrote:
Hi Randy,

Probably. If we can get a small test case
together, I will add it to rto_get.prg, and
I can try it with Clipper too.

So, var is 20 chars string, picture is "(999) 999-9999".
What keys do you press to get into the endless loop?

Brgds,
Viktor

On 2008.06.25., at 18:04, Randy Portnoff wrote:

Hi all,

I think there is a bug in TGET's delEnd() method - The loop...

DO WHILE ::nPos > nPos
 ::backSpaceLow()
ENDDO

...can become endless in some circumstances. While I cannot
reproduce it in a DOS app, my GUI app (that implements its own
masked edits using TGET) can using a 20-character character
variable
and a picture as "(999) 999-9999" - If I reduce the variable to 14
characters (ie. to match the picture length), it seems to work ok.

So, I'm not sure if this should be classified as a bug or not.

Regards,
Randy.

P.S. The use of :Pos and :nPos is very confusing in TGET.PRG


_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour


_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour


_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour


_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to