Strange Error with xbrowse-restorestate

Strange Error with xbrowse-restorestate

Postby gkuhnert » Wed Nov 03, 2010 11:17 am

Hi,

a strange error occurs, trying to use the xbrowse restorestate-method. I'm even unable to catch it from happening with a catch-try-block.
this is my code in that area
Code: Select all  Expand view  RUN
        msginfo("still alive 1")
        TRY
            oLB:RestoreState(GetPvProfString ("XBRW_SPALTEN", MODUL_NAME, , IniLokal()))
        CATCH
            msginfo("dead")
            writepprostring("XBRW_SPALTEN",MODUL_NAME,"", IniLokal())
        END
        msginfo("still alive 2")  // <= this is line 172
 


I still get the message "still alive 1" but neither "dead" nor "still alive 2" will appear. Instead of catching an error, I get an error message:

Application
===========
Path and name: D:\cto_win\eho40\eho.exe (32 bits)
Size: 6,245,888 bytes
Time from start: 0 hours 0 mins 1 secs
Error occurred at: 03.11.2010, 12:00:29
Error description: Error BASE/1109 Argument error: $
Args:
[ 1] = C

[ 2] = U

Stack Calls
===========
Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTHEADER(8713)
Called from: .\source\classes\XBROWSE.PRG => TCTOXBROWSE:PAINTHEADER(1509)
Called from: .\source\classes\XBROWSE.PRG => TCTOXBROWSE:PAINT(1292)
Called from: .\source\classes\XBROWSE.PRG => TCTOXBROWSE:DISPLAY(1195)
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(1459)
Called from: .\source\classes\XBROWSE.PRG => TCTOXBROWSE:HANDLEEVENT(11050)
Called from: .\source\classes\WINDOW.PRG => _FWH(3394)
Called from: => MSGINFO(0)
Called from: AD_MAIN.prg => E_ADRESSEN(172)
Called from: EHO.prg => STARTADRESSEN(1257)
Called from: EHO.prg => (b)EHO_INIT(923)
Called from: .\source\classes\WINDOW.PRG => TWINDOW:KEYDOWN(2546)
Called from: .\source\classes\MDICLIEN.PRG => TMDICLIENT:KEYDOWN(243)
Called from: => TMDICLIENT:HANDLEEVENT(0)
Called from: .\source\classes\WINDOW.PRG => _FWH(3394)
Called from: => WINRUN(0)
Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE(978)
Called from: EHO.prg => MAIN(680)


As the error results from xbrowse.prg, I guess it might be an internal error in this class. This Error occurs with FW1009, but not with fw810. I guess it has a relation to the new way of writing down the Savestate-information. This is the information for this particular browse, that is written down by savestate:
Code: Select all  Expand view  RUN
ADRESSEN=XSS:41BF020600416D000200430D005265417272616E6765436F6C7341580013004E0100314E0100324E0100334E0100344E0100354E0100364E0100374E0100384E0100394E020031304E020031314E020031324E020031334E020031344E020031354E020031364E020031374E020031384E020031394115000200430B005F6E526F774865696768744E02003137417C0002004308005F6E576964746873416C0013004E020034324E020037364E020035354E020037364E03003231364E020033344E03003134364E03003134364E020036394E03003231364E03003238364E03003134364E03003134364E020034384E03003130344E0400313531384E03003130344E020039304E0200333441830002004307005F6C486964657341740013004C03002E462E4C03002E462E4C03002E462E4C03002E462E4C03002E462E4C03002E462E4C03002E462E4C03002E462E4C03002E462E4C03002E462E4C03002E462E4C03002E462E4C03002E462E4C03002E462E4C03002E462E4C03002E462E4C03002E462E4C03002E462E4C03002E462E414C0002004309005F6347727048647273413B00130055000055000055000055000055000055000055000055000055000055000055000055000055000055000055000055000055000055000055000041DE0002004309005F634865616465727341CD0013004309002A20566F726C6167654306005465726D696E4309002A204B656E6E756E674309002A204B642E2D4E722E430700566F726E616D654306002A204E616D654309002A2054656C65666F6E4304004C616E644305002A20504C5A4305002A204F727443060053747261DF6543090054656C65666F6E203243070054656C6566617843070044656269746F72430F00556D732E2D53742E2D49442D4E722E4310002A20417566747261677366656C6465724308002A20556D7361747A4305004F6666656E4304004A616872
 


What's going wrong?
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: Strange Error with xbrowse-restorestate

Postby James Bott » Wed Nov 03, 2010 1:31 pm

Gilbert,

Are you trying to restore using data that was saved from the earlier version?

Called from: .\source\classes\XBROWSE.PRG => TCTOXBROWSE:PAINTHEADER(1509)


I don't recognize the TCTOXBROWSE class. Is this a class you wrote or maybe someone else wrote. I cannot find it searching all of the FW source code.

Have you tried creating a small simple example that shows the error?

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Strange Error with xbrowse-restorestate

Postby gkuhnert » Wed Nov 03, 2010 1:46 pm

James,

Are you trying to restore using data that was saved from the earlier version?

The information I want to restore is written by the actual fw1009-version.


I don't recognize the TCTOXBROWSE class. Is this a class you wrote or maybe someone else wrote. I cannot find it searching all of the FW source code.

the tctoxbrowse-class is a class we derived from TxBrowse. Butt all modified and supplemented methods are properly written to a seperate file called ctoxbrw.prg. As all errors reference to xbrowse.prg, which is unmodified, I assume the error is internally in this file.

Have you tried creating a small simple example that shows the error?

I've tried, but the error won't occur (until now). I even have some other xbrowses, that are called in the same way with no error. But as I cannot read the information, which written by the new savestate-method, anymore, I cannot analyze, what's going on at that moment. Or is it possible to read (as a human) the information behind xss: in any way?
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: Strange Error with xbrowse-restorestate

Postby James Bott » Wed Nov 03, 2010 2:05 pm

Gilbert,

I've tried, but the error won't occur (until now).


Hmm, I am not sure what that means. Yes or no?

I am suggesting writing the simplest xbrowse you can with save and restore buttons and see if you can recreate the error. Have you done this?

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Strange Error with xbrowse-restorestate

Postby gkuhnert » Wed Nov 03, 2010 2:13 pm

James,

James Bott wrote:Hmm, I am not sure what that means. Yes or no?

I am suggesting writing the simplest xbrowse you can with save and restore buttons and see if you can recreate the error. Have you done this?

Yes, I've tried that, but the error won't occur. (That's in a short sentence what I tried to explain ;) )

But I tried also something else now: I modified Line 8709 of xbrowse.prg
from
Code: Select all  Expand view  RUN
cHeader  := ::cHeader

to
Code: Select all  Expand view  RUN
cHeader  := IIF( !empty(::cHeader),::cHeader ,"" )


and now I don't have an error. But also the headers are missing. Maybe the savestate-information is not properly written down, but I don't know how to decrypt it so I can't analyze the information of the savestate.
And the other odd thing is, that the try-catch-block won't change anything in this case. How can it happen, that my program is still crashing?
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: Strange Error with xbrowse-restorestate

Postby James Bott » Wed Nov 03, 2010 2:51 pm

Gilbert,

OK, I think the problem is that you have written a subclass of xbrowse that is based on an older version of FW and now you are using it with a newer version. The error you are getting is that a parameter is either not being passed or it is nil.

I don't have FW 8.10 here but I do have 8.08 and I notice in that version there is no PaintHeader method in xbrowse (there is in TXBrwColumn). In ver 10.9 there is a PaintHeader method in both of the classes. This just points out that there have been some significant changes to xbrowse since ver 8.10.

Since you do not get the error with xbrowse alone, the error is in your subclass. This class is going to have to be debugged. The first thing to try is putting msgInfo( nCol ) at the very top of the TXBrwColumn method PaintHeader().

You might also consider that maybe you don't need the subclass anymore (if the newer xbrowse has whatever features that you added with your subclass).

Regards,
James
Last edited by James Bott on Wed Nov 03, 2010 3:02 pm, edited 1 time in total.
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Strange Error with xbrowse-restorestate

Postby James Bott » Wed Nov 03, 2010 2:54 pm

Gilbert,

What leads you to believe that the error is in the RestoreState() method? According to the error log it is in the TXBrwColumn:PaintHeader() method.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Strange Error with xbrowse-restorestate

Postby James Bott » Wed Nov 03, 2010 3:10 pm

Gilbert,

But I tried also something else now: I modified Line 8709 of xbrowse.prg
from

Code:
cHeader := ::cHeader


Hmm, that is line 8694 in my xbrowse.prg which is ver 10.9 dated 9/2/2010 5:43pm. Are you sure you are using ver 10.9?

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Strange Error with xbrowse-restorestate

Postby gkuhnert » Wed Nov 03, 2010 3:12 pm

James,

thanks for your thoughts. As all references to the error are in the xbrowse.prg and not in ctoxbrw.prg, it seems very unlikely, that the error is to be found in ctoxbrw.prg. On the other hand the headers are missing (instead of a crash), after I changed the paint-header. It seems at some place an undefined cHeader is passed on, which very likely origins from the crypted savestate, which passes on either no headers or there is some other error in there (as the error message states that in "CRLF $ cHeader" the cHeader is of type U(ndefined))

The other thing is, that if the savestate-information is empty, I don't have any problems. And the moment I call restorestate I'm beyond the usage of ctoxbrw-methods.

But my ctoxbrw.prg is no big secret, so I post it here: (and I didn't find anything that could provoke an undefined cHeader in there.)
Code: Select all  Expand view  RUN
#include "FiveWin.ch"
#include "InKey.ch"
#include "xbrowse.ch"

#define COLOR_HIGHLIGHT      13
#define COLOR_HIGHLIGHTTEXT  14
#define COLOR_BTNFACE        15
#define COLOR_BTNTEXT        18


CLASS TCTOXBrowse FROM TXBrowse

DATA lHitTop
DATA lHitBottom
DATA aDataColSizes
DATA nClrBackHead, nClrForeHead
DATA nClrBackFocus, nClrForeFocus
DATA aJustify



METHOD New( nRow, nCol, nWidth, nHeight, bLine, aHeaders, ;
               aColSizes, oWnd, cField, uVal1, uVal2, bChange,;
               bLDblClick, bRClick, oFont, oCursor, nClrFore,;
               nForeBack, cMsg, lUpdate, cAlias, lPixel, bWhen,;
               lDesign, bValid, bLClick, aActions ) CONSTRUCTOR

METHOD ReDefine( nId, bLine, oDlg, aHeaders, aColSizes, cField, uVal1,;
                 uVal2, bChange, bLDblClick, bRClick, oFont,;
                 oCursor, nClrFore, nClrBack, cMsg, lUpdate,;
                 cAlias, bWhen, bValid, bLClick, aActions ) CONSTRUCTOR

METHOD ACOLSIZES(aColSizes) SETGET

METHOD UpStable() INLINE 1

ENDCLASS

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

METHOD New( nRow, nCol, nWidth, nHeight, bLine, aHeaders, ;
               aColSizes, oWnd, cField, uVal1, uVal2, bChange,;
               bLDblClick, bRClick, oFont, oCursor, nClrFore,;
               nForeBack, cMsg, lUpdate, cAlias, lPixel, bWhen,;
               lDesign, bValid, bLClick, aActions )

local nI
local oCol
local cTarget := bLine
local bBlock
local recs

  super:new(oWnd)

  ::cAlias = cAlias
  ::lRefreshOnlyData = .t.

  // Manuelle "Array"-Auflösung. Komma am Ende einfügen, damit jedes Feld mit Komma abgeschlossen wird.
   cTarget=SUBSTR(cTarget,5,len(cTarget)-6)+","

  // Möglicherweise gibt es Elemente, die ein Komma enthalten. Hierauf Folgt immer eine Picture-Klausel.
  // Daher dieses Komma durch Gleichzeichen ersetzen.
  if RAT(",Pict", cTarget) > 0
    cTarget=stuff(cTarget,AT(",Pict",cTarget),5,"=Pict")
  endif

   ::nClrBackHead  := GetSysColor( COLOR_BTNFACE )
   ::nClrForeHead  := GetSysColor( COLOR_BTNTEXT )
   ::nClrBackFocus := GetSysColor( COLOR_HIGHLIGHT )
   ::nClrForeFocus := GetSysColor( COLOR_HIGHLIGHTTEXT )


  for nI:=1 to len(aHeaders)
    oCol:= ::AddCol()
    oCol:cHeader  := IIF( !empty(aHeaders[nI]),aHeaders[nI],"")

    // Feldzuweisung (ggf. mittels Funktion) in eine Variable übergeben
    bBlock := SUBSTR(cTarget, 1, AT(",", cTarget) - 1)

    // Restliches "Array" bilden, in dem das erste Feld rausgenommen wird.
    cTarget = stuff(cTarget, 1, AT(",",cTarget),"")

    // Gleichzeichen wieder durch Komma ersetzen, falls es vorkommt
    if RAT("=Pict", bBlock) > 0
      bBlock = stuff(bBlock,AT("=Pict",bBlock),5,",Pict")
    endif
     oCol:nEditType(0) // GK14062010
    oCol:bStrData := {|| &bBlock }
  next

  ::CreateFromCode()
  ::bLClicked  = bLClick
  ::bLDblClick = bLDblClick
  ::bRClicked  = bRClick
  ::nMarqueeStyle := MARQSTYLE_HIGHLROWMS
  ::nColDividerStyle    := LINESTYLE_BLACK
  ::nRowDividerStyle    := LINESTYLE_BLACK
  ::lColDividerComplete := .t.
  ::nHeaderLines        := 10
  ::nDataLines          := 2
  ::nFreeze             := 0
return Self



METHOD ReDefine( nId, bLine, oDlg, aHeaders, aColSizes, cField, uVal1,;
                 uVal2, bChange, bLDblClick, bRClick, oFont,;
                 oCursor, nClrFore, nClrBack, cMsg, lUpdate,;
                 cAlias, bWhen, bValid, bLClick, aActions )

local nI
local oCol
local recs

  super:new(oDlg)
  ::cAlias = cAlias
  ::lRefreshOnlyData = .f.

  recs := ( cAlias )->( lastrec() )

  if recs <= 0
    oCol:= ::AddCol()
    oCol:cHeader  := "test"
    oCol:bStrData := {|| "test"}
  endif


   ::CreateFromResource(nId)
   ::bLClicked  = bLClick
   ::bLDblClick = bLDblClick
    ::bRClicked  = bRClick
    ::nMarqueeStyle := MARQSTYLE_HIGHLROWMS
   ::nColDividerStyle    := LINESTYLE_BLACK
   ::nRowDividerStyle    := LINESTYLE_BLACK
   ::lColDividerComplete := .t.
   ::nHeaderLines        := 10
   ::nDataLines          := 2
    ::nFreeze             := 0
    ::nClrBackHead  := GetSysColor( COLOR_BTNFACE )
   ::nClrForeHead  := GetSysColor( COLOR_BTNTEXT )
   ::nClrBackFocus := GetSysColor( COLOR_HIGHLIGHT )
   ::nClrForeFocus := GetSysColor( COLOR_HIGHLIGHTTEXT )

return Self


METHOD ACOLSIZES(aColSizes)
local nI
local res
  if PCount() == 1
    ::AdataColSizes:=aColSizes
     /*
     for nI:=1 to len(::aCols)-1
      ::aCols[nI]:nWidth:=::AdataColSizes[nI]
    next
     */

  else
    res := ::AdataColSizes
  endif
return res
 


The main idea behind ctoxbrw was that we wanted to be able to use (almost) the same call of the new()-method as in wBrowse, which made it possible to use xBrowse and wBrowse in the same way.
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: Strange Error with xbrowse-restorestate

Postby gkuhnert » Wed Nov 03, 2010 3:15 pm

James Bott wrote:Gilbert,

But I tried also something else now: I modified Line 8709 of xbrowse.prg
from

Code:
cHeader := ::cHeader


Hmm, that is line 8694 in my xbrowse.prg which is ver 10.9 dated 9/2/2010 5:43pm. Are you sure you are using ver 10.9?

Regards,
James

My xbrowse.prg is dated 09/23/2010 9:17am.
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: Strange Error with xbrowse-restorestate

Postby James Bott » Wed Nov 03, 2010 3:35 pm

My xbrowse.prg is dated 09/23/2010 9:17am.


My mistake. I was looking at ver 10.8.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Strange Error with xbrowse-restorestate

Postby James Bott » Wed Nov 03, 2010 3:38 pm

Gilbert,

My next suggestion would be to start eliminating sections of code in your subclass by commenting them out and seeing if the error goes away. This will narrow it down to a section of code, then you can comment out line-by-line until you find which line is the problem. I would start with the New() method.

If I haven't been clear, let me know.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Strange Error with xbrowse-restorestate

Postby James Bott » Wed Nov 03, 2010 3:44 pm

Gilbert,

I am still not clear why you think the error is in the RestoreState() method?

I just found this in the xbrowse.prg:

METHOD OldRestoreState( cInfo ) // retained for comatibility 10.8 for another few versions

It appears there was a major change in SaveState() method and this was left in for older formats of the save. You might try using OldRestoreState() and see if the problem goes away. However, if you have saved using the new SaveState() method, then this shouldn't be a factor.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Strange Error with xbrowse-restorestate

Postby gkuhnert » Wed Nov 03, 2010 4:14 pm

James,

I only use the new savestate() and restorestate(). I think it might be likely that in some cases savestate doesn't save properly. Therefore I had also asked if there is any possibility to read the saved information with human eyes. Because in any way it seems that the headerinformation is either lost by writing with savestate or by reading with restorestate.

And the other part is that I'd like to intercept crashes by using Try + Catch which doesn't work either.

But tomorrow I'll try to eliminate ctoxbrowse completely so only xbrowse is being used. Thanks for your efforts :D
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: Strange Error with xbrowse-restorestate

Postby frose » Wed Nov 03, 2010 6:12 pm

Hi Gilbert, hi James,

getting the same or similar problem with RestoreState() in FWH 1010, my app crashes when refreshing:

Code: Select all  Expand view  RUN
METHOD RestoreState( cState ) CLASS TXBrowse

   local aState

   if Left( cState, 4 ) == 'XSS:'
      aState      := ARead( HB_HexToStr( SubStr( cState, 5 ) ) )
      AltD()
      AEval( aState, { |a| OSend( Self, a[ 1 ], a[ 2 ] ) } )
   else
      ::OldRestoreState( cState )
   endif

   ::GetDisplayCols()
   ::Refresh()

return nil
 


Error occurred at: 03.11.2010, 18:49:02
Error description: Error BASE/1004 Class: 'NIL' has no exported method: EVAL
Args:
[ 1] = U

Stack Calls
===========
Called from: => EVAL(0)
Called from: xbrowse.prg => (b)TXBROWSE:TXBROWSE(385)
Called from: => CLTXBROWSE:KEYCOUNT(0)
Called from: xbrowse.prg => CLTXBROWSE:REFRESH(1131)
Called from: xbrowse.prg => CLTXBROWSE:RESTORESTATE(5447)
Called from: my_txbrowse.prg => MY_RESTORESTATE(2440)
Called from: my_txbrowse.prg => MY_TXBROWSE(634)
Called from: my_browse.prg => MY_BROWSE(116)
Called from: C:\xHarbour\SewIS-PPS\my_application.prg => (b)BUILDMENU(1405)
Called from: .\source\classes\MENU.PRG => TMENU:COMMAND(437)
Called from: .\source\classes\WINDOW.PRG => TWINDOW:COMMAND(1029)
Called from: .\source\classes\MDIFRAME.PRG => TMDIFRAME:COMMAND(243)
Called from: => TMDIFRAME:HANDLEEVENT(0)
Called from: .\source\classes\WINDOW.PRG => _FWH(3394)
Called from: => WINRUN(0)
Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE(978)
Called from: C:\xHarbour\SewIS-PPS\my_application.prg => MAIN(571)


I've invoked the original xbrowse.prg for debugging purposes and to examine the array 'aState', but havn't found anything what can cause the crash.

Unfortunately the function State() in the sample testxbrw.prg is working, so it must be something in coherence with my browse datas!

Here the content of cState before the crash: "XSS:41E70006004123000200430D005265417272616E6765436F6C73410E0003004E0100314E0100324E0100334115000200430B005F6E526F774865696768744E02003138412E0002004308005F6E576964746873411E0003004E06003932332E30384E06003130372E36394E0700313932332E303841230002004307005F6C"

Hope we can solve this soon and many thanks in advance
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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 89 guests