RedimDataWindow

Deutschsprachiges X#-Forum – German language forum

Moderator: wriedmann

lagraf
Posts: 442
Joined: Thu Jan 18, 2018 9:03 am
Location: A

RedimDataWindow

Post by lagraf »

Hallo Karl-Heinz,
die Klasse RedimDataWindow ist nicht von mir, habe ich vor langer Zeit irgendwo mal bekommen. Das Array _aControls wird in RedimDataWindow:PostInit() befüllt:

Code: Select all

SELF:_aC	:= SELF:GetControls( )	// Alle Textcontrols nach SELF:_aC laden
nLen		:= ALen( SELF:_aC )
IF nLen == 0
	ErrorBox{SELF, "Keine Controls gefunden"}:Show()
	RETURN NIL
ENDIF
_aControls	:= ArrayNew( nLen )
FOR nI := 1 UPTO nLen
	_aControls[nI] := { SELF:_aC[nI]:NameSym,;
				 Point{ SELF:_aC[nI]:Origin:X, SELF:_aC[nI]:Origin:Y }, ;
				Dimension{ SELF:_aC[nI]:Size:Width, SELF:_aC[nI]:Size:Height } }
NEXT
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

RedimDataWindow

Post by Karl-Heinz »

Hallo Franz,

Ich habe einem MultiHB mal einen Font zugewiesen. Danach knallt es mal, mal nicht.
Anhand der exception ( siehe Anhang ) sieht man aber klar wo das Problem liegt, und zwar im HoverButton Dispatch():

Code: Select all

	CASE oE:Message == WM_SETFONT
		DeleteObject(SELF:lpHBInfo.hFont)
		SELF:lpHBInfo.hFont	:= PTR(_CAST, oE:wParam)  // <------------

Offenbar kommt da ab und an ein Float an, was dann zu dem "Conversion Error USUAL (FLOAT) to PTR" führt.
Da stellt sich die Frage wie so etwas zustande kommt ...

Gruß
Karl-Heinz
Attachments
Exception.png
Exception.png (75.68 KiB) Viewed 364 times
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

RedimDataWindow

Post by Karl-Heinz »

Hallo Franz,

Probier es mal mit diesen 3 Änderungen in der HoverButton Dispatch()

Code: Select all

METHOD Dispatch( oEvent )   // <------------------  Änderung oEvent anstatt oE
	LOCAL lpRect		IS _WINRECT
	LOCAL lpPoint		IS _WINPOINT
	LOCAL dwMouse		AS DWORD
	LOCAL hParent		AS PTR 
	LOCAL oE AS Event  // <--------------------  neu
	
	oE := oEvent  // <-------------- neu
...


Gruß
Karl-Heinz
lagraf
Posts: 442
Joined: Thu Jan 18, 2018 9:03 am
Location: A

RedimDataWindow

Post by lagraf »

Hallo Karl-Heinz,
sieht gut aus, ich hab den Absturz mit den Änderungen nicht mehr zusammengebracht!
Könnte das ein Bug im X# sein?
User avatar
wriedmann
Posts: 3700
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

RedimDataWindow

Post by wriedmann »

Hallo Franz,
prinzipiell hast Du recht, dass sich da X# teilweise anders verhält - und da handelt es sich immer um nicht typisierte Variablen.
Die Event-Parameter von Event-Methoden zu typisieren ist eigentlich immer eine gute Idee - auch in VO selber.
Und wenn ich irgendwo im bestehenden Code eine solche Methode ohne typisiertes Objekt sehe, passe ich das immer an.
Gerade bei Events bringt das Geschwindigkeit.

Wolfgang

P.S. das RedimDataWindow stammt ursprünglich mal von mir
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

RedimDataWindow

Post by Karl-Heinz »

Hallo Franz,
Könnte das ein Bug im X# sein?
Ich kann absolut nicht einschätzen in wieweit man dem X# compiler all das beibringen kann was der VO compiler so treibt. In dem Fall hat man halt das "Pech", dass die Exception erst dann auftritt wenn ein anderer Font zugewiesen wird. Wenn Du allerdings zu Beginn den stack trace gezeigt hättest wäre das Problem sicherlich schneller zu beheben gewesen.

Gruß
Karl-Heinz
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

RedimDataWindow

Post by Karl-Heinz »

und wie Wolfgang erwähnt hat, sollte die Lehre sein, spätestens nach einem Export alle vorhandenen Dispatcher wie beschrieben zu typisieren !
User avatar
robert
Posts: 4388
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

RedimDataWindow

Post by robert »

Karl-Heinz,

>>SELF:lpHBInfo.hFont := PTR(_CAST, oE:wParam) // <------------

Any _CAST in the code should be reviewed.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
lagraf
Posts: 442
Joined: Thu Jan 18, 2018 9:03 am
Location: A

RedimDataWindow

Post by lagraf »

Hallo Karl-Heinz,
hast du den Stack Trace aus dem Error Objekt -> Stack oder ist dein Testprogramm mit dem Stack Trace direkt ausgestiegen? Ich habe immer nur uError:Description betrachtet und das zeigt ja nicht den Ort des Geschehens.

Die Dispatch Methode ist doch eine Callback Methode, wird also von VO bzw. X# aufgerufen. Wenn dabei ein fehlerhaftes oEvent mitkommt:
-> Ist das dann nicht ein Fehler in der Sprache / im Compiler?
-> Wenn ich LOCAL oE := oEvent AS Event zuordne und wParam ist falsch, sollte dann nicht dieses Statement auch abstürzen?
User avatar
robert
Posts: 4388
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

RedimDataWindow

Post by robert »

Franz,

The problem is in the code that says:
SELF:lpHBInfo.hFont := PTR(_CAST, oE:wParam)

the PTR(_CAST tells the compiler:
I know what I am doing. Even though you think that wParam is numeric you should treat it as a pointer and assign it to the hFont field of lpHBInfo
As a result there may be a problem that is not properly handled by the compiler.
If you see a _CAST in your code you may want to revise that code.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply