Forum > CustomDrawn
[SOLVED] Patch for fixing a bug at TCDWidgetSet.SaveDC
lagprogramming:
According to the comments found all over the interfaces, the function should return the index assigned to OR 0 if DC is not valid. The problem is that the original code returns the index of TLazCanvas.SaveState, which can be zero. This makes a valid TLazCanvas.SaveState zero index to be interpreted as if DC is not valid.
The patch mimics the solution found in function TCocoaContext.SaveDC: Integer; The function result is the index in the list + 1. This means that the first SaveDC will be one, not zero.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---diff --git a/lcl/interfaces/customdrawn/customdrawnwinapi.inc b/lcl/interfaces/customdrawn/customdrawnwinapi.incindex 0a12ac2d82..dbdcb15667 100644--- a/lcl/interfaces/customdrawn/customdrawnwinapi.inc+++ b/lcl/interfaces/customdrawn/customdrawnwinapi.inc@@ -5033,10 +5033,13 @@ begin {$ifdef VerboseQTWinAPI} WriteLn('Trace:> [WinAPI RestoreDC] DC=', dbghex(DC),' SavedDC=',SavedDC); {$Endif}- Result := False;- if not IsValidDC(DC) then Exit;+ if (SavedDC=0) or (not IsValidDC(DC)) then Exit(False);++ if SavedDC>0 then+ LazDC.RestoreState(SavedDC-1)+ else+ LazDC.RestoreState(SavedDC); - LazDC.RestoreState(SavedDC); Result := True; {$ifdef VerboseQTWinAPI} WriteLn('Trace:< [WinAPI RestoreDC]');@@ -5079,7 +5082,7 @@ begin exit; end; - Result := LazDC.SaveState();+ Result := LazDC.SaveState()+1; {$ifdef VerboseQTWinAPI} WriteLn('Trace:< [WinAPI SaveDC] result=', Result);
Bart:
Please post patches in the appropriate place: the bugtracker.
Also notice that the current state of CustomDrawn widgetset makes it impossible to test (at least on Windows) the changes you made.
Bart
wp:
I absolutely agree with Bart: Please post the bug to the bug tracker so that it is well-documented and some knowledgable developer can take care of it. I will not apply this one because it is not self-evident (like the others) and we have no means to test it.
lagprogramming:
I don't have a problem with the fact that a patch presented by me is not included in the official source code.
Also, I find hard to believe that somebody would continue the development of customdrawn without reading the forum posts in the customdrawn subcategory. Or the customdrawn mailing list.
PascalDragon:
--- Quote from: lagprogramming on April 04, 2023, 01:08:49 pm ---Also, I find hard to believe that somebody would continue the development of customdrawn without reading the forum posts in the customdrawn subcategory. Or the customdrawn mailing list.
--- End quote ---
There are people that don't frequent the forum. This includes even some core developers. And not many people are subscribed to the customdrown mailing list (I hadn't even remembered that there is one).
Navigation
[0] Message Index
[#] Next page