From 0a2f05a2fe2898ee1407319a6764018fdf54e562 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Tue, 26 Sep 2023 00:29:14 +0200 Subject: [PATCH] FLUID: Fixes regression #777 Wrote wrong path in #inlude statement under certain conditions. Also removed 'snap' tag if not needed. --- fluid/Fd_Snap_Action.cxx | 8 ++++++++ fluid/about_panel.fl | 5 ----- fluid/alignment_panel.fl | 2 +- fluid/code.cxx | 2 +- fluid/fluid.cxx | 22 ++++++++++++++-------- fluid/function_panel.fl | 5 ----- fluid/print_panel.fl | 5 ----- fluid/sourceview_panel.fl | 12 +++--------- fluid/template_panel.fl | 5 ----- fluid/widget_panel.fl | 5 ----- src/Fl_File_Chooser.fl | 2 +- test/CubeViewUI.fl | 5 ----- test/checkers_pieces.fl | 5 ----- test/fast_slow.fl | 5 ----- test/inactive.fl | 5 ----- test/keyboard_ui.fl | 5 ----- test/mandelbrot_ui.fl | 5 ----- test/preferences.fl | 5 ----- test/radio.fl | 5 ----- test/resize.fl | 5 ----- test/tabs.fl | 5 ----- test/tree.fl | 5 ----- test/valuators.fl | 5 ----- 23 files changed, 28 insertions(+), 105 deletions(-) diff --git a/fluid/Fd_Snap_Action.cxx b/fluid/Fd_Snap_Action.cxx index c1ac3982b..3f52907ad 100644 --- a/fluid/Fd_Snap_Action.cxx +++ b/fluid/Fd_Snap_Action.cxx @@ -714,6 +714,14 @@ void Fd_Layout_List::read(Fl_Preferences &prefs, int storage) { Write Suite and Layout selection and project layout data to an .fl project file. */ void Fd_Layout_List::write(Fd_Project_Writer *out) { + // Don't write the Snap field if no custom layout was used + if ((current_suite()==0) && (current_preset()==0)) { + int nSuite = 0; + for (int i=0; iwrite_string("\nsnap {\n ver 1\n"); out->write_string(" current_suite "); out->write_word(list_[current_suite()].name_); out->write_string("\n"); out->write_string(" current_preset %d\n", current_preset()); diff --git a/fluid/about_panel.fl b/fluid/about_panel.fl index 8c524a5dd..c39d839c2 100644 --- a/fluid/about_panel.fl +++ b/fluid/about_panel.fl @@ -2,11 +2,6 @@ version 1.0400 header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 1 -} comment {// // About dialog for the Fast Light Tool Kit (FLTK). // diff --git a/fluid/alignment_panel.fl b/fluid/alignment_panel.fl index 845d7b7f6..da80df3a4 100644 --- a/fluid/alignment_panel.fl +++ b/fluid/alignment_panel.fl @@ -5,7 +5,7 @@ code_name {.cxx} snap { ver 1 current_suite FLTK - current_preset 1 + current_preset 0 suite { name {FLUID (based on FLTK)} preset { 1 diff --git a/fluid/code.cxx b/fluid/code.cxx index 561d6fca7..1a66895a6 100644 --- a/fluid/code.cxx +++ b/fluid/code.cxx @@ -771,7 +771,7 @@ int Fd_Code_Writer::write_code(const char *s, const char *t, bool to_sourceview) } else if (g_project.header_file_name[0] == '.' && strchr(g_project.header_file_name.c_str(), '/') == NULL) { write_c("#include \"%s\"\n", fl_filename_name(t)); } else { - write_c("#include \"%s\"\n", t); + write_c("#include \"%s\"\n", g_project.header_file_name.c_str()); } } Fl_String loc_include, loc_conditional; diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx index 2a95cfd0b..7fc5b3add 100644 --- a/fluid/fluid.cxx +++ b/fluid/fluid.cxx @@ -311,6 +311,10 @@ void Fluid_Project::reset() { code_file_set = 0; header_file_name = ".h"; code_file_name = ".cxx"; + + g_layout_list.remove_all(FD_STORE_PROJECT); + g_layout_list.current_suite(0); + g_layout_list.current_preset(0); } void Fluid_Project::update_settings_dialog() { @@ -1127,29 +1131,31 @@ int write_code_files() // -- write the code and header files if (!batch_mode) enter_project_dir(); int x = f.write_code(code_filename.c_str(), header_filename.c_str()); + Fl_String code_filename_rel = fl_filename_relative(code_filename); + Fl_String header_filename_rel = fl_filename_relative(header_filename); if (!batch_mode) leave_project_dir(); // -- print error message in batch mode or pop up an error or confirmation dialog box if (batch_mode) { if (!x) { fprintf(stderr, "%s and %s: %s\n", - code_filename.c_str(), - header_filename.c_str(), + code_filename_rel.c_str(), + header_filename_rel.c_str(), strerror(errno)); exit(1); } } else { if (!x) { - fl_message("Can't write %s and %s: %s", - code_filename.c_str(), - header_filename.c_str(), + fl_message("Can't write %s or %s: %s", + code_filename_rel.c_str(), + header_filename_rel.c_str(), strerror(errno)); } else { set_modflag(-1, 0); if (completion_button->value()) { fl_message("Wrote %s and %s", - g_project.codefile_name().c_str(), - g_project.headerfile_name().c_str()); + code_filename_rel.c_str(), + header_filename_rel.c_str()); } } } @@ -2080,7 +2086,7 @@ int main(int argc,char **argv) { exit(0); } - // don't lock up if silly command line arguments were given + // don't lock up if inconsistent command line arguments were given if (batch_mode) exit(0); diff --git a/fluid/function_panel.fl b/fluid/function_panel.fl index bb29b403d..d4974b3c4 100644 --- a/fluid/function_panel.fl +++ b/fluid/function_panel.fl @@ -2,11 +2,6 @@ version 1.0400 header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 1 -} comment {// // Code dialogs for the Fast Light Tool Kit (FLTK). // diff --git a/fluid/print_panel.fl b/fluid/print_panel.fl index 47ce530d7..98d09a641 100644 --- a/fluid/print_panel.fl +++ b/fluid/print_panel.fl @@ -2,11 +2,6 @@ version 1.0400 header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 1 -} comment {// // FLUID print panel for the Fast Light Tool Kit (FLTK). // diff --git a/fluid/sourceview_panel.fl b/fluid/sourceview_panel.fl index 37c38d2fb..e78224677 100644 --- a/fluid/sourceview_panel.fl +++ b/fluid/sourceview_panel.fl @@ -2,11 +2,6 @@ version 1.0400 header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 1 -} comment {// // Code dialogs for the Fast Light Tool Kit (FLTK). // @@ -31,7 +26,7 @@ decl {\#include "fluid.h"} {private local decl {\#include "file.h"} {private local } -decl {\#include "../src/flstring.h"} {selected private local +decl {\#include "../src/flstring.h"} {private local } decl {\#include } {private local @@ -136,8 +131,6 @@ and load those into the Code Viewer widgets.} open return_type void sv_strings->buffer()->loadfile(fn); sv_strings->scroll(top, 0); } else if (sv_source->visible_r() || sv_header->visible_r()) { - g_project.basename = fl_filename_name(sv_source_filename); - g_project.basename = fl_filename_setext(g_project.basename, ""); Fl_String code_file_name_bak = g_project.code_file_name; g_project.code_file_name = sv_source_filename; Fl_String header_file_name_bak = g_project.header_file_name; @@ -162,7 +155,8 @@ and load those into the Code Viewer widgets.} open return_type void g_project.code_file_name = code_file_name_bak; g_project.header_file_name = header_file_name_bak; - }} {} + }} {selected + } } Function {update_sourceview_timer(void*)} { diff --git a/fluid/template_panel.fl b/fluid/template_panel.fl index 0ac6d3363..3d30be846 100644 --- a/fluid/template_panel.fl +++ b/fluid/template_panel.fl @@ -2,11 +2,6 @@ version 1.0400 header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 1 -} comment {// // FLUID template support for the Fast Light Tool Kit (FLTK). // diff --git a/fluid/widget_panel.fl b/fluid/widget_panel.fl index 139dbe716..a3fc6fc25 100644 --- a/fluid/widget_panel.fl +++ b/fluid/widget_panel.fl @@ -2,11 +2,6 @@ version 1.0400 header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 1 -} comment {// // Widget panel for the Fast Light Tool Kit (FLTK). // diff --git a/src/Fl_File_Chooser.fl b/src/Fl_File_Chooser.fl index 4d4d1107c..e70ad8427 100644 --- a/src/Fl_File_Chooser.fl +++ b/src/Fl_File_Chooser.fl @@ -98,7 +98,7 @@ window->hide();} open } {} Fl_Button newButton { callback {newdir();} - image {new.xbm} xywh {455 10 25 25} labelsize 8 + image {new.xbm} compress_image 0 xywh {455 10 25 25} labelsize 8 code0 {\#include } code1 {o->tooltip(new_directory_tooltip);} } diff --git a/test/CubeViewUI.fl b/test/CubeViewUI.fl index 29730c674..d07451cc7 100644 --- a/test/CubeViewUI.fl +++ b/test/CubeViewUI.fl @@ -2,11 +2,6 @@ version 1.0400 header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 1 -} class CubeViewUI {open } { Function {CubeViewUI()} {open diff --git a/test/checkers_pieces.fl b/test/checkers_pieces.fl index abe2184ff..8cd09e9b5 100644 --- a/test/checkers_pieces.fl +++ b/test/checkers_pieces.fl @@ -2,11 +2,6 @@ version 1.0400 header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 0 -} comment {// // Checkers images for the Fast Light Tool Kit (FLTK). // diff --git a/test/fast_slow.fl b/test/fast_slow.fl index b78cd4b94..fb40f050e 100644 --- a/test/fast_slow.fl +++ b/test/fast_slow.fl @@ -2,11 +2,6 @@ version 1.0400 header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 1 -} Function {} {open } { Fl_Window {} {open selected diff --git a/test/inactive.fl b/test/inactive.fl index c19b50a20..824a713bd 100644 --- a/test/inactive.fl +++ b/test/inactive.fl @@ -2,11 +2,6 @@ version 1.0400 header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 1 -} Function {} {open } { Fl_Window {} {open diff --git a/test/keyboard_ui.fl b/test/keyboard_ui.fl index 425b05f4b..c0d29f3fd 100644 --- a/test/keyboard_ui.fl +++ b/test/keyboard_ui.fl @@ -2,11 +2,6 @@ version 1.0400 header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 1 -} Function {make_window()} {open } { Fl_Window my_window {open diff --git a/test/mandelbrot_ui.fl b/test/mandelbrot_ui.fl index 180a6fcb0..0c289e6f6 100644 --- a/test/mandelbrot_ui.fl +++ b/test/mandelbrot_ui.fl @@ -2,11 +2,6 @@ version 1.0400 header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 0 -} decl {\#include "mandelbrot.h"} {public local } diff --git a/test/preferences.fl b/test/preferences.fl index e4fb3c5ca..d61c580d8 100644 --- a/test/preferences.fl +++ b/test/preferences.fl @@ -7,11 +7,6 @@ i18n_gnu_function gettext i18n_gnu_static_function gettext_noop header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 0 -} comment {About test/preferences: The preferences app shows two features of FLTK and FLUID. diff --git a/test/radio.fl b/test/radio.fl index a30df6821..13ef9bfd0 100644 --- a/test/radio.fl +++ b/test/radio.fl @@ -2,11 +2,6 @@ version 1.0400 header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 1 -} Function {button_cb(Fl_Button *b, void *)} { comment {Buttons test callback} open private return_type void } { diff --git a/test/resize.fl b/test/resize.fl index 0b93d2c0a..818277786 100644 --- a/test/resize.fl +++ b/test/resize.fl @@ -2,11 +2,6 @@ version 1.0400 header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 1 -} Function {} {open } { Fl_Window {} {open selected diff --git a/test/tabs.fl b/test/tabs.fl index 56aec468b..25a610b9d 100644 --- a/test/tabs.fl +++ b/test/tabs.fl @@ -2,11 +2,6 @@ version 1.0400 header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 0 -} Function {} {open } { Fl_Window foo_window { diff --git a/test/tree.fl b/test/tree.fl index 02f22474e..a48be0284 100644 --- a/test/tree.fl +++ b/test/tree.fl @@ -2,11 +2,6 @@ version 1.0400 header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 1 -} decl {\#include } {public global } diff --git a/test/valuators.fl b/test/valuators.fl index c9b8bce58..a8dcff87f 100644 --- a/test/valuators.fl +++ b/test/valuators.fl @@ -2,11 +2,6 @@ version 1.0400 header_name {.h} code_name {.cxx} -snap { - ver 1 - current_suite FLTK - current_preset 0 -} decl {\#include } {public global }