stepan-mitkin / drakon_editor

DRAKON Editor
352 stars 57 forks source link

1.27 Error while trying to export to PNG (or to PDF) #23

Open Brun0oO opened 7 years ago

Brun0oO commented 7 years ago

Hi,

I got a large diagram and I want to save it as a png file. I got an error "Expected integer but go "3405.333333333333", here the traceback :

expected integer but got "3405.333333333333"
expected integer but got "3405.333333333333"
    while executing
"incr cy $line_height"
    (procedure "hl::render_text" line 132)
    invoked from within
"hl::render_text $surface $coords $text $font $fill $anchor "
    (procedure "add_prim_to_canvas" line 6)
    invoked from within
"add_prim_to_canvas $surface $type $coords $text $fore $fill "center" "
    (procedure "add_to_canvas" line 6)
    invoked from within
"add_to_canvas $surface $type $coords $text $fore $fill"
    ("foreach" body line 3)
    invoked from within
"foreach icon $icons {
    lassign $icon role type coords text fore fill
    add_to_canvas $surface $type $coords $text $fore $fill
    }"
    invoked from within
"$base eval { 
    select text, text2, color, x, y, w, h, a, b, type
    from items
    where item_id = :item_id } {

    set lines [ $type.lines  $x..."
    (procedure "render_item" line 3)
    invoked from within
"render_item $surface $item_id"
    invoked from within
"$base eval {
        select item_id
        from items
        where diagram_id = :diagram_id 
    and type != 'vertical' and type != 'horizontal' and type != 'parallel..."
    (procedure "mv::render_to" line 14)
    invoked from within
"mv::render_to export_pdf::p.db_render $diagram "
    (procedure "export_pdf::prepare_export" line 17)
    invoked from within
"export_pdf::prepare_export "
    (procedure "export_png::export" line 9)
    invoked from within
"export_png::export"
    (menu invoke)

I got the same error, if i try to use the "export to pdf" command. If I use the command "View/See all", I don't have this error...

I've tried to replace all "incr cx $var" in "scripts/highlight.tcl" file by "set cx [ expr { int($var) + 1 } ]"(same correction for "incr cy $var" code) but without success :o( I got a bad png where texts are badly located). My tcl knowledges are very limited. Can anyone help me ? Thanks. Brun0oO

Brun0oO commented 7 years ago

I did a mistake with "set cy [ expr { int($line_height) + 1 } ]", so... I replaced only "incr cy $line_height" (the thrown exception in the traceback) with "set cy [ expr { $cy + int($line_height) } ]" (my correction). I can launch the png export but the exported png (21300 px x 4100 px) is bad : the stiching is erroneus.... Any idea ?

Serenacula commented 7 years ago

A short-term recommendation would be to take a print screen of the diagrams... xD Windows has a Snipping tool, which may help in that regard.

In terms of actually fixing the problem, isn't it weird to be getting a decimal number, not an integer? It looks like that's referring to a height co-ordinate, so it may be worth going through the callback to find out where that number came from and why it isn't an integer.

Brun0oO commented 7 years ago

Well, it seems that actually my correction is enough. I exported again the diagram and the result was good (!?) (I don't understand why my previous attempt was wrong..). Thanks Serenacula ! As I said, my tcl knowledges are very very low, I don't know how to trace the callback, so i'm going to use my "fix" as it is... But this project is very useful ! I love it !

ylluminarious commented 6 years ago

@stepan-mitkin I'm having the same problem, even in the most recent version of DRAKON. By "most recent version," I mean that I downloaded the source repository via:

git clone https://github.com/stepan-mitkin/drakon_editor.git

I get this backtrace when I try to export to PNG:

objc[13378]: Class FIFinderSyncExtensionHost is implemented in both /System/Library/PrivateFrameworks/FinderKit.framework/Versions/A/FinderKit (0x7fff9e11fa70) and /System/Library/PrivateFrameworks/FileProvider.framework/OverrideBundles/FinderSyncCollaborationFileProviderOverride.bundle/Contents/MacOS/FinderSyncCollaborationFileProviderOverride (0x10ca99cd8). One of the two will be used. Which one is undefined.
tclsh8.6(13378,0x7fffa14cd340) malloc: *** error for object 0x10f80b000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
[1]    13378 abort      ./drakon_editor.tcl

And I get this backtrace when I try to export to PDF:

objc[13433]: Invalid or prematurely-freed autorelease pool 0x7ff196802050.
[1]    13433 abort      ./drakon_editor.tcl

@Brun0oO Would you mind sharing a patch which has your changes that made DRAKON work properly again? Maybe @stepan-mitkin can merge your changes into the master branch and this issue will be fixed for everyone.

techieshark commented 6 years ago

I think I saw the same error, but in Russian.

image

I tried zooming out and the export worked (but it was too small to read...)

For me it was fixed by changing these lines: https://github.com/stepan-mitkin/drakon_editor/blob/master/scripts/highlight.tcl#L374 https://github.com/stepan-mitkin/drakon_editor/blob/master/scripts/highlight.tcl#L410

replacing this:

                        incr cy [expr int($line_height)]

with this:

                        set cy [expr {$cy + int($line_height)}] 

because cy is not necessarily an integer so you can't use incr on it:

If $i is a non-integral real number, [incr] could not be used, but [set] could: set i [expr {$i + 1}] docs