From f1ca27d3e0208f5f2616f7d93ce61fecfc2d4ea3 Mon Sep 17 00:00:00 2001 From: Sergey Kalinin Date: Thu, 5 Jul 2018 08:41:18 +0300 Subject: [PATCH] Fixed error if file was not select --- errors | 0 lib/imgviewer.tcl | 19 +++++++++++-------- lib/main.tcl | 1 + lib/projects.tcl | 2 ++ lib/settings.tcl | 1 + projman.tcl | 2 ++ 6 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 errors diff --git a/errors b/errors new file mode 100644 index 0000000..e69de29 diff --git a/lib/imgviewer.tcl b/lib/imgviewer.tcl index 458d321..16fc1b4 100644 --- a/lib/imgviewer.tcl +++ b/lib/imgviewer.tcl @@ -53,20 +53,23 @@ proc scale {w {n 1} node} { proc ImageBase64Encode {text} { global env set types { + {"PNG" {.png}} {"GIF" {.gif}} {"JPEG" {.jpg}} - {"PNG" {.png}} {"BMP" {.bmp}} {"All files" *} } set img [tk_getOpenFile -initialdir $env(HOME) -filetypes $types -parent .] - set f [open $img] - fconfigure $f -translation binary - set data [base64::encode [read $f]] - close $f - # base name on root name of the image file - set name [file root [file tail $img]] - $text insert [Position] "image create photo $name -data {\n$data\n}" + if {$img ne ""} { + set f [open $img] + fconfigure $f -translation binary + set data [base64::encode [read $f]] + close $f + # base name on root name of the image file + set name [file root [file tail $img]] + $text insert [Position] "image create photo $name -data {\n$data\n}" + } } + diff --git a/lib/main.tcl b/lib/main.tcl index e30cd6c..746bc9f 100644 --- a/lib/main.tcl +++ b/lib/main.tcl @@ -381,3 +381,4 @@ if {[info exists workingProject]} { + diff --git a/lib/projects.tcl b/lib/projects.tcl index 305b55d..161b408 100644 --- a/lib/projects.tcl +++ b/lib/projects.tcl @@ -1012,3 +1012,5 @@ proc InsertTitle {newFile type} { + + diff --git a/lib/settings.tcl b/lib/settings.tcl index b5116b7..0ce09b5 100644 --- a/lib/settings.tcl +++ b/lib/settings.tcl @@ -669,3 +669,4 @@ proc Settings {nBook} { # Read a config file # LoadSettings } + diff --git a/projman.tcl b/projman.tcl index ffa5ab6..f2dc268 100755 --- a/projman.tcl +++ b/projman.tcl @@ -176,3 +176,5 @@ option add *Dialog.msg.background $editor(bg) + +