瀏覽代碼

Fix: incorrect layout exception when debugging is disabled

MarcinZiabek 2 年之前
父節點
當前提交
cedeaaef7a
共有 2 個文件被更改,包括 5 次插入1 次删除
  1. 1 0
      Source/QuestPDF.Examples/DebuggingTesting.cs
  2. 4 1
      Source/QuestPDF/Drawing/Proxy/DebuggingState.cs

+ 1 - 0
Source/QuestPDF.Examples/DebuggingTesting.cs

@@ -60,6 +60,7 @@ namespace QuestPDF.Examples
                 RenderingTest
                     .Create()
                     .PageSize(500, 360)
+                    .EnableDebugging()
                     .Render(container =>
                     {
                         container

+ 4 - 1
Source/QuestPDF/Drawing/Proxy/DebuggingState.cs

@@ -11,7 +11,7 @@ namespace QuestPDF.Drawing.Proxy
 {
     internal class DebuggingState
     {
-        private DebugStackItem Root { get; set; }
+        private DebugStackItem? Root { get; set; }
         private Stack<DebugStackItem> Stack { get; set; }
 
         public DebuggingState()
@@ -59,6 +59,9 @@ namespace QuestPDF.Drawing.Proxy
         
         public string BuildTrace()
         {
+            if (Root == null)
+                return null;
+            
             var builder = new StringBuilder();
             var nestingLevel = 0;