FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse - RestoreState() – wrong column sequence
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
xBrowse - RestoreState() – wrong column sequence
Posted: Fri Nov 05, 2010 12:12 PM
Hi,

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

Original browse:


Browse with changed column sequence:


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


Sample:
Code (fw): Select all Collapse
#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
Posts: 274
Joined: Fri Apr 04, 2008 01:25 PM
Re: xBrowse - RestoreState() – wrong column sequence
Posted: Fri Nov 05, 2010 01: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
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: xBrowse - RestoreState() – wrong column sequence
Posted: Fri Nov 05, 2010 01: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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse - RestoreState() – wrong column sequence
Posted: Sat Nov 06, 2010 03:06 PM
Instead of
Code (fw): Select all Collapse
      @ 0, 0 XBROWSE oBrw OF oWnd LINES CELL

please modify adding the alias
Code (fw): Select all Collapse
      @ 0, 0 XBROWSE oBrw OF oWnd ALIAS 'RSTRSTT' LINES CELL

Also,
modify
Code (fw): Select all Collapse
      oBrw:RestoreState( cState )

as
Code (fw): Select all Collapse
if ! Empty( cState )
      oBrw:RestoreState( cState )
endif

Please try with these modifications.
Regards



G. N. Rao.

Hyderabad, India
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: xBrowse - RestoreState() – wrong column sequence
Posted: Sat Nov 06, 2010 04: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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse - RestoreState() – wrong column sequence
Posted: Sat Nov 06, 2010 05:39 PM
I am sorry.
Please add AUTOCOLS also
Code (fw): Select all Collapse
@ 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
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: xBrowse - RestoreState() – wrong column sequence
Posted: Sat Nov 06, 2010 06: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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse - RestoreState() – wrong column sequence
Posted: 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
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: xBrowse - RestoreState() – wrong column sequence
Posted: Mon Nov 08, 2010 09: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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse - RestoreState() – wrong column sequence
Posted: Mon Nov 08, 2010 11:20 AM
Mr. Frose,

Will you please try by replacing SaveState and RestoreState methods with the following code?
Code (fw): Select all Collapse
//----------------------------------------------------------------------------//

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
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: xBrowse - RestoreState() – wrong column sequence
Posted: 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
Posts: 274
Joined: Fri Apr 04, 2008 01:25 PM
Re: xBrowse - RestoreState() – wrong column sequence
Posted: Mon Nov 08, 2010 03: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

Continue the discussion