Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BUG: VFP bombs with autosizing labels
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
BUG: VFP bombs with autosizing labels
Divers
Thread ID:
00824989
Message ID:
00824989
Vues:
66
The following code demonstrates a problem that causes intermittent C00000FD errors (if you're lucky enough to see any error message at all before VFP evaporates). To run the test, copy the following code into a PRG and run it from VFP command level. The fastest way to reproduce the problem is to position the cursor at the end of the textbox and hold down a key, i.e. to auto-repeat for 10 or 20 chars. Then hold down the backspace key and delete about that many chars. Do this a few times, and poof! I've seen this problem under all versions of Windows and VFP that I've tested, including VFP6 SP5 and VFP 7 SP1, with Windows 9X, 2K, and XP.

If anyone would care to confirm this bug, I'd appreciate it. I don't know what the story is with VFP8. Here's the code to run the test form:
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form
	Top = 0
	Left = 0
	DoCreate = .T.
	Caption = "Label Autosize and Wordwrap Test"
	Name = "Form1"

	ADD OBJECT label1 AS label WITH ;
		AutoSize = .T., ;
		WordWrap = .T., ;
		Caption = "Here is Label1, a nice little test for you.", ;
		Height = 92, ;
		Left = 60, ;
		Top = 144, ;
		Width = 43, ;
		TabIndex = 11, ;
		Name = "Label1"

	ADD OBJECT label2 AS label WITH ;
		AutoSize = .T., ;
		Caption = "Label Width:", ;
		Height = 17, ;
		Left = 12, ;
		Top = 72, ;
		Width = 70, ;
		TabIndex = 4, ;
		Name = "Label2"

	ADD OBJECT spinner1 AS spinner WITH ;
		Height = 24, ;
		Left = 84, ;
		TabIndex = 5, ;
		Top = 72, ;
		Width = 124, ;
		ControlSource = "thisform.label1.width", ;
		Name = "Spinner1"

	ADD OBJECT label3 AS label WITH ;
		AutoSize = .T., ;
		Caption = "Label Height:", ;
		Height = 17, ;
		Left = 5, ;
		Top = 108, ;
		Width = 75, ;
		TabIndex = 7, ;
		Name = "Label3"

	ADD OBJECT spinner2 AS spinner WITH ;
		Height = 24, ;
		Left = 84, ;
		TabIndex = 8, ;
		Top = 108, ;
		Width = 124, ;
		ControlSource = "thisform.label1.height", ;
		Name = "Spinner2"

	ADD OBJECT check1 AS checkbox WITH ;
		Top = 72, ;
		Left = 228, ;
		Height = 17, ;
		Width = 79, ;
		AutoSize = .T., ;
		Caption = "Word Wrap", ;
		ControlSource = "thisform.label1.wordwrap", ;
		TabIndex = 6, ;
		Name = "Check1"

	ADD OBJECT label4 AS label WITH ;
		AutoSize = .T., ;
		Caption = "Enter text:", ;
		Height = 17, ;
		Left = 12, ;
		Top = 12, ;
		Width = 55, ;
		TabIndex = 1, ;
		Name = "Label4"


	ADD OBJECT text1 AS textbox WITH ;
		ControlSource = "thisform.label1.caption", ;
		Height = 48, ;
		Left = 72, ;
		TabIndex = 2, ;
		Top = 12, ;
		Width = 288, ;
		Name = "Text1"

	ADD OBJECT check2 AS checkbox WITH ;
		Top = 108, ;
		Left = 228, ;
		Height = 17, ;
		Width = 68, ;
		AutoSize = .T., ;
		Caption = "Auto-size", ;
		ControlSource = "thisform.label1.autosize", ;
		TabIndex = 9, ;
		Name = "Check2"

	ADD OBJECT label5 AS label WITH ;
		Caption = "Label:", ;
		Height = 17, ;
		Left = 12, ;
		Top = 144, ;
		Width = 40, ;
		TabIndex = 10, ;
		Name = "Label5"

	PROCEDURE text1.InteractiveChange
		* note that trim() masks the problem, unless multiple consecutive blanks are imbedded within the label
		store this.value to (this.controlsource)	&& update label immediately, without waiting to lose focus
		thisform.spinner1.refresh					&& display resulting label width
		thisform.spinner2.refresh					&& display resulting label height 
	ENDPROC

ENDDEFINE
Note that the problem only seems to occur when the label has autosize and wordwrap turned ON, and when there are multiple consecutive blanks contained in the label caption. Adding a trim() in the interactive change assignment, i.e. changing the line to this:
		store trim(this.value) to (this.controlsource)
removes the non-obvious trailing blanks, ameliorating the problem somewhat. However, if you position the cursor to somewhere in the middle of the text and insert/backspace repeatedly over a series of blanks, you'll quickly see the same sort of intermittent crashing behavior.
Montage

"Free at last..."
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform