![]() |
Analyse : object locked error
Liste der Anhänge anzeigen (Anzahl: 1)
der Demo-code funktioniert fehlerfrei ....
allerdings wenn ich die Funktion DoPaintTest(var PaintBMP: TBitmap); in eine andere Klasse kopiere liefert diese Funktione den object locked error .... (siehe screen dump) wie kann das sein, es gibt doch überhaupt keine Interaction mit der Klasse ??????
Delphi-Quellcode:
type TPaintLayout2 = class
procedure DoPaintTest(var PaintBMP: TBitmap); end; procedure TPaintLayout2.DoPaintTest(var PaintBMP: TBitmap); var p1, p2: TPointF; i, j: Integer; Brush: TStrokeBrush; begin PaintBMP.Width := 1000; PaintBMP.Height := 1000; for i := 1 to 100 do begin Brush := TStrokeBrush.Create(TBrushKind.Solid, randomColor); Brush.Thickness := 2; // Brush.Kind := Solid; p1 := TPointF.Create(2, 2); p2 := TPointF.Create(Random(400), Random(400)); PaintBMP.Canvas.BeginScene; // draw lines on the canvas PaintBMP.Canvas.DrawLine(p1, p2, 1, Brush); PaintBMP.Canvas.EndScene; // in dieser Zeile kommt es zum Object lock error Brush.Free; end end; /// /// somewhere inside the main app /// ....... var aPaintLayoutCTRL: TPaintLayout2; aBMP: TBitmap; begin aBMP := TBitmap.Create; aPaintLayoutCTRL := TPaintLayout2.Create; try aPaintLayoutCTRL.DoPaintTest(aBMP); imgviewer_layout.Bitmap.Assign(aBMP) ; finally aPaintLayoutCTRL.Free; aBMP.Free; end; |
AW: Analyse : object locked error
:glaskugel:
Die Glaskugel sagt: "Es fehlt das gezippte und in sich vollständige Minimal-Beispiel-Projekt." |
AW: Analyse : object locked error
minimal Projekt wäre der code oben ... funktioniert ja einwandfrei :-),
die echte Klasse kann ich leider nicht "public posten" , aber der test code - die Funktion
Delphi-Quellcode:
; ist identisch in beiden Klassen.
DoPaintTest(aBMP)
Es gibt keine Variable die auf etwas in der Klasse zugreift . Wie kann ich diesen Fehler verstehen oder debuggen ?? Was ich hierzu gefunden habe ![]() |
AW: Analyse : object locked error
Zitat:
Was sind deine Schlüsse und Maßnahmen daraus? Debuggst du mit Debug-DCUs? So dass du im Falle von object locked error einfach mal auf Break klicken kannst und anhand des Callstacks siehst, wer oder was unberechtigterweise auf das gelockte TMonitor-Objekt zugreift? Hast du dir mal die Threads ausgeloggt, die darauf zugreifen? Ich nehme mal an, du bist unter Linux? Unter Windows würde ich jetzt ganz simpel in die erste Zeile von DoPaintTest sowas schreiben
Delphi-Quellcode:
OutputDebugString(PChar(TThread.Current.ThreadID.ToHexString));
Da musst du dir mal das Gegenstück für Linux suchen. Ansonsten ist dein Code halt suboptimal, probiere es doch mal so:
Delphi-Quellcode:
procedure TPaintLayout2.DoPaintTest(var PaintBMP: TBitmap);
var p1, p2: TPointF; i, j: Integer; Brush: TStrokeBrush; begin PaintBMP.Width := 1000; PaintBMP.Height := 1000; Brush := TStrokeBrush.Create(TBrushKind.Solid, randomColor); try Brush.Thickness := 2; p1 := TPointF.Create(2, 2); if PaintBMP.Canvas.BeginScene then begin for i := 1 to 100 do begin Brush.Color := randomColor; p2 := TPointF.Create(Random(400), Random(400)); PaintBMP.Canvas.DrawLine(p1, p2, 1, Brush); end; PaintBMP.Canvas.EndScene; end; finally Brush.Free; end; end; |
AW: Analyse : object locked error
In FMX gibt's in FMX.Types log.d('Meine Meldung') zum Ausgeben von Logmeldungen.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:18 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz