xBrowse - RestoreState() – wrong column sequence

xBrowse - RestoreState() – wrong column sequence

Postby frose » Fri Nov 05, 2010 12:12 pm

Hi,

changing the column sequence, RestoreState() results in a wrong column <-> data relation!

Original browse:
Image

Browse with changed column sequence:
Image

Browse with wrong relations after two "SaveState() - RestoreState()" iterations:
Image

Sample:
Code: Select all  Expand view
#include "fivewin.ch"
#include "xbrowse.ch"
#include "FILEIO.CH"

function Main()

   local oWnd, oBrw, oCol
   LOCAL cState := ""
   LOCAL aState
   LOCAL i
   LOCAL nFileHandle
   
   REQUEST DBFCDX
   USE RSTRSTT
   INDEX ON Field->Prmtr_txt TO RSTRSTT
   SET ORDER TO "RSTRSTT"

   IF FILE( "rstrstts.txt" )
       nFileHandle := FOpen( "rstrstts.txt", FO_READ )
      FSeek( nFileHandle, 0, FS_SET )
      HB_FReadLine( nFileHandle, @cState )
      FClose( nFileHandle )
   ENDIF

      GO TOP
      DEFINE WINDOW oWnd TITLE "Test RestoreState() FWH 1010"
      @ 0, 0 XBROWSE oBrw OF oWnd LINES CELL
      oBrw:nMarqueeStyle = MARQSTYLE_HIGHLROW
      oBrw:CreateFromCode()
      aState := ARead( HexToStr( SubStr( cState, 5 ) ) )
      oBrw:RestoreState( cState )
     
      FOR each oCol in oBrw:aCols
          IF oCol:nWidth > 500
            oCol:nWidth := 150
         ENDIF
      NEXT

      oWnd:oClient := oBrw
     
      ACTIVATE WINDOW oWnd VALID ( cState := oBrw:SaveState(), .T. )
     
      nFileHandle := FCreate( "rstrstts.txt", FO_EXCLUSIVE )
      FWrite( nFileHandle, cState )
      FClose( nFileHandle )

RETURN NIL

 
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: xBrowse - RestoreState() – wrong column sequence

Postby gkuhnert » Fri Nov 05, 2010 1:07 pm

Frose,

I can confirm, that this error occurs in some constellations. Now I have the first name in the column for surname. If I change the order of columns again to another sequence, everything is fine. If I change back, the error is there again.
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands

Re: xBrowse - RestoreState() – wrong column sequence

Postby frose » Fri Nov 05, 2010 1:16 pm

Gilbert,

seems we are the Beta-testers :wink:
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: xBrowse - RestoreState() – wrong column sequence

Postby nageswaragunupudi » Sat Nov 06, 2010 3:06 pm

Instead of
Code: Select all  Expand view
     @ 0, 0 XBROWSE oBrw OF oWnd LINES CELL

please modify adding the alias
Code: Select all  Expand view
     @ 0, 0 XBROWSE oBrw OF oWnd ALIAS 'RSTRSTT' LINES CELL

Also,
modify
Code: Select all  Expand view
     oBrw:RestoreState( cState )

as
Code: Select all  Expand view
if ! Empty( cState )
      oBrw:RestoreState( cState )
endif

Please try with these modifications.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10630
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse - RestoreState() – wrong column sequence

Postby frose » Sat Nov 06, 2010 4:03 pm

Dear Mr. Rao,

same behaviour as before!

Please let me emphasise one detail once more, perhaps it's important for you: The wrong column sequence starts after the SECOND "SaveState() - RestoreState()" iteration!

Here the steps in detail:
- changing the sequence
- closing the program, saving <cState> first time
- starting the program, all is OK!
- closing the program (without changing anything), saving <cState> second time
- starting the program, wrong sequence!
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: xBrowse - RestoreState() – wrong column sequence

Postby nageswaragunupudi » Sat Nov 06, 2010 5:39 pm

I am sorry.
Please add AUTOCOLS also
Code: Select all  Expand view
@ 0, 0 XBROWSE oBrw OF oWnd AUTOCOLS ALIAS 'RSTRSTT' LINES CELL

Will you please try with this change and report the result please?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10630
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse - RestoreState() – wrong column sequence

Postby frose » Sat Nov 06, 2010 6:10 pm

Dear Mr. Rao,

nothing changed, still wrong sequences :(

Did you test it? Have you a functional sample? I'm a little bit confused :?

Can you give some comments for better understanding whats going on?
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: xBrowse - RestoreState() – wrong column sequence

Postby nageswaragunupudi » Sun Nov 07, 2010 12:19 pm

Mr. Frose,

Yes, it is a problem to be resolved. Shall try to come up with a fix soon.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10630
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse - RestoreState() – wrong column sequence

Postby frose » Mon Nov 08, 2010 9:11 am

Mr. Rao,

thank you for the info.

Kind regards from cold and grey Germany
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: xBrowse - RestoreState() – wrong column sequence

Postby nageswaragunupudi » Mon Nov 08, 2010 11:20 am

Mr. Frose,

Will you please try by replacing SaveState and RestoreState methods with the following code?
Code: Select all  Expand view
//----------------------------------------------------------------------------//

METHOD SaveState( aAdditionalData ) CLASS TXBrowse

   local aData    := { "nCreationOrders", "nRowHeight", "nWidths", "lHides", "cGrpHdrs", "cHeaders" }
   local aState   := {}

   if ValType( aAdditionalData ) == 'A'
      AEval( aAdditionalData, { |c| AAdd( aData, c ) } )
   endif

   AEval( aData, { |c| AAdd( aState, { c, OSend( Self, c ) } ) } ) // modified
   aState[ 1, 1 ] := "ReArrangeCols"

return "XSS:" + HB_StrToHex( ASave( aState ) )

//----------------------------------------------------------------------------//

METHOD RestoreState( cState ) CLASS TXBrowse

   local aState

   if Left( cState, 4 ) == 'XSS:'
      aState      := ARead( HB_HexToStr( SubStr( cState, 5 ) ) )
      ::ReArrangeCols( aState[ 1, 2 ] )  // added
      AEval( aState, { |a| OSend( Self, "_" + a[ 1 ], a[ 2 ] ) }, 2 ) // modified
      AEval( aState[ 1, 2 ], { |n,i| ::aCols[ i ]:nCreationOrder := n } ) // added
   else
      ::OldRestoreState( cState )
   endif

   ::GetDisplayCols()
   ::Refresh()

return nil

//----------------------------------------------------------------------------//
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10630
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse - RestoreState() – wrong column sequence

Postby frose » Mon Nov 08, 2010 11:31 am

Mr. Rao,

it's working fine now, thank you very much :D
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: xBrowse - RestoreState() – wrong column sequence

Postby gkuhnert » Mon Nov 08, 2010 3:11 pm

Frank, Rao,

seems to work for me too now. Thank you very much!
(will these changes be included in the next release?)
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], nageswaragunupudi and 107 guests