Bug#367793: Further Info: Any constraint violation in combination with a form with certain macros results in hang
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
It appears that the bug appears when a database-level constraint is
violated (e.g. an unique index constraint is violated by adding a
record with index fields that are the same as an existing record), and
macros are active on save. E.g. the "Before commencing" event of my
save button points to the following macro (I'm also including the
associated functions), at least with an embedded HSQL database.
This macro is necessary due to a bug in the subform code that doesn't
copy the master field value to the slave field on the subform, when
adding a new record in the subform (viewing works fine).
Sub CopyItemTypeOnNewItemSave
Dim oControlModel as Object
Dim oControlModel2 as Object
if fnFindControlModel( thisComponent.DrawPage.forms, "HiddenItemItemTypeTextBox", oControlModel2 ) then
if fnFindControlModel( thisComponent.DrawPage.forms, "HiddenItemTypeTextBox", oControlModel ) then
oControlModel2.Text = oControlModel.Text
oControlModel2.commit
else
MsgBox( "No Control with the name '" & "HiddenItemTypeNumberTextBox" & "' found" , 16, GetProductName())
endif
else
MsgBox( "No Control with the name '" & "HiddenItemItemTypeTextBox" & "' found" , 16, GetProductName())
end if
End Sub
'
' fnFindControlModel
'
' inForm - dataform to be traversed looking for
' a control named Cname
'
' CName - the name of the control to search for
'
' outControl - If the control is found this will hold the
' model of the control
' If not found outControl will be unchanged
'
' returns - True if found else False
'
function fnFindControlModel( inForm as Object,_
CName as String, _
outControl as variant) as Boolean
dim aControl as object
static amDone as boolean
for i = 0 to inForm.Count -1
if amDone then
' be sure to pass back our boolan check value
' else it will be reset to false
' if we are more then one level deep for the
' search
fnFindControlModel = amDone
exit function
endif
aControl = inForm.GetByIndex( i )
' I am not sure if using serviceName is
' considered good coding practice in OOoBasic or not
' but here I used it
if aControl.ServiceName = "stardiv.one.form.component.Form" then
amDone = fnFindControlModel( aControl, CName, outControl )
endif
Next i
if not amDone then
amDone = fnFormHasControl( inForm , cName, aControl)
if amDone then
outControl = aControl
fnFindControlModel = amDone
exit function
end if '
end if ' not amDone
' and we need to pass this back one last time
' just in case we have more then one DataForm at the top level
fnFindControlModel = amDone
' finally the last one out needs to turn off the lights
' or we will not know to start next time
' we get called from outside ourself
amDone = False
end function
'
' fnFormHasControl
' Routine called by fnFindControlModel to check for
' a control on THIS form
'
' oForm - dataform to check
'
' CName - the name of the control to search for
'
' outControl - If the control is found this will be the
' model of the control
' If not found outControl will be unchanged
'
' returns - True if found else False
'
function fnFormHasControl( oForm as object, _
cName as String,_
oControl as Object) as Boolean
if oForm.HasByName(CName) then
oControl = oForm.GetByName(CName )
fnFormHasControl = True
exit function
endif
fnFormHasControl = False
end function
Sub CopyCategoryOnNewItemTypeSave
Dim oControlModel as Object
Dim oControlModel2 as Object
if fnFindControlModel( thisComponent.DrawPage.forms, "HiddenItemTypeCategoryTextBox", oControlModel2 ) then
if fnFindControlModel( thisComponent.DrawPage.forms, "HiddenCategoryNumberTextBox", oControlModel ) then
oControlModel2.Text = oControlModel.Text
oControlModel2.commit
else
MsgBox( "No Control with the name '" & "HiddenCategoryNumberTextBox" & "' found" , 16, GetProductName())
endif
else
MsgBox( "No Control with the name '" & "HiddenItemTypeCategoryTextBox" & "' found" , 16, GetProductName())
end if
End Sub
- --
And that's my crabbing done for the day. Got it out of the way early,
now I have the rest of the afternoon to sniff fragrant tea-roses or
strangle cute bunnies or something. -- Michael Devore
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD4DBQFEbOWUhvWBpdQuHxwRAst4AJja++ek/qjWvp5DW0NirD3fYlUPAJ9mSbI/
gsmiJGUyjhVne7i0BZcnlg==
=bYeD
-----END PGP SIGNATURE-----
Reply to: