app crash after oBrw:Refresh( .T. )

app crash after oBrw:Refresh( .T. )

Postby frose » Mon Jun 04, 2012 7:28 am

in some of my browse the user can switch the column sets from 1, 2, ... n, to show different, predefined columns of the same table by clicking the K_CTRL_RIGHT/_LEFT keys. The program then calls a function 'RedesignBrowse()', which deletes all existing columns before it builts the new view with 'oBrw:AddCol()'.

This works well for the last months without any crashes or other problems.

Now, if I define one or more columns for inline editing, the functions crashes without any error when switching the column set.

Here is a sample to show the problem:
Code: Select all  Expand view
#include "FiveWin.ch"
#include "XBrowse.ch"

STATIC oWnd, oBrw, oCol

FUNCTION Main()

   USE Customer

   DEFINE WINDOW oWnd MENU BuildMenu()
     
   @ 0, 0 XBROWSE oBrw OF oWnd ALIAS "Customer"
   
   oBrw:lFastEdit := .T.
       
   oCol := oBrw:AddCol()
   oCol:bStrData    := { || Customer->First }
   oCol:cHeader     := "First"
   oCol:nEditType   := EDIT_GET
   oCol:bOnPostEdit := { | oCol, xVal, nKey | If( RecCount() == 0, ( DbAppend(), oBrw:Refresh() ),), If( nKey == VK_RETURN, Customer->First := xVal,) }

   oCol := oBrw:AddCol()
   oCol:bStrData    := { || Customer->Last }
   oCol:cHeader     := "Last"
   oCol:nEditType   := EDIT_GET
   oCol:bOnPostEdit := { | oCol, xVal, nKey | If( RecCount() == 0, DbAppend(),), If( nKey == VK_RETURN, ( Customer->Last := xVal, DbAppend(), oBrw:Refresh() ),) }
   
   oBrw:CreateFromCode()
   
   oWnd:oClient := oBrw

   ACTIVATE WINDOW oWnd
   
RETURN NIL

FUNCTION BuildMenu()

   LOCAL oMenu

   MENU oMenu
      MenuItem "Redesign browse" ACTION RedesignBrowse()
   ENDMENU

RETURN oMenu

FUNCTION RedesignBrowse()

   DO WHILE .T.
       IF Len( oBrw:aCols ) == 0
         EXIT
      ELSE
         oBrw:DelCol( 1 )
      ENDIF
   ENDDO
   
   oCol := oBrw:AddCol()
   oCol:bStrData    := { || Customer->First }
   oCol:cHeader     := "First"
   oCol:nEditType   := EDIT_GET
   oCol:bOnPostEdit := { | oCol, xVal, nKey | If( RecCount() == 0, ( DbAppend(), oBrw:Refresh() ),), If( nKey == VK_RETURN, Customer->First := xVal,) }
    
   oCol := oBrw:AddCol()
   oCol:bStrData    := { || Customer->Last }
   oCol:cHeader     := "Last"
   oCol:nEditType   := EDIT_GET
   oCol:bOnPostEdit := { | oCol, xVal, nKey | If( RecCount() == 0, DbAppend(),), If( nKey == VK_RETURN, ( Customer->Last := xVal, DbAppend(), oBrw:Refresh() ),) }
   
   oCol := oBrw:AddCol()
   oCol:bStrData    := { || Customer->Street }
   oCol:cHeader     := "Street"
   
   oCol := oBrw:AddCol()
   oCol:bStrData    := { || "test" }
   oCol:cHeader     := "test"
   
   oBrw:Refresh( .T. )
   
RETURN NIL
 

What is wrong?
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

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 113 guests