From 9eb5f11c394090a06a200709aedc4de54680e51f Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sun, 6 Oct 2024 17:33:04 +0200 Subject: [PATCH] FLUID: Fixes file reading bug, introduces two weeks ago: #1078 --- fluid/file.cxx | 52 +++++++++++++++++++++++++------------------------- fluid/undo.cxx | 6 +++++- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/fluid/file.cxx b/fluid/file.cxx index d06283670..2365630c2 100644 --- a/fluid/file.cxx +++ b/fluid/file.cxx @@ -354,38 +354,37 @@ Fl_Type *Fd_Project_Reader::read_children(Fl_Type *p, int merge, Strategy strate goto CONTINUE; } } - { - t = add_new_widget_from_file(c, strategy); - if (!t) { - read_error("Unknown word \"%s\"", c); - continue; - } - last_child_read = t; - // After reading the first widget, we no longer need to look for options - skip_options = 1; + t = add_new_widget_from_file(c, strategy); + if (!t) { + read_error("Unknown word \"%s\"", c); + continue; + } + last_child_read = t; + // After reading the first widget, we no longer need to look for options + skip_options = 1; - t->name(read_word()); + t->name(read_word()); + c = read_word(1); + if (strcmp(c,"{") && t->is_class()) { // + ((Fl_Class_Type*)t)->prefix(t->name()); + t->name(c); c = read_word(1); - if (strcmp(c,"{") && t->is_class()) { // - ((Fl_Class_Type*)t)->prefix(t->name()); - t->name(c); - c = read_word(1); - } + } - if (strcmp(c,"{")) { - read_error("Missing property list for %s\n",t->title()); - goto REUSE_C; - } + if (strcmp(c,"{")) { + read_error("Missing property list for %s\n",t->title()); + goto REUSE_C; + } - t->folded_ = 1; - for (;;) { - const char *cc = read_word(); - if (!cc || !strcmp(cc,"}")) break; - t->read_property(*this, cc); - } + t->folded_ = 1; + for (;;) { + const char *cc = read_word(); + if (!cc || !strcmp(cc,"}")) break; + t->read_property(*this, cc); + } - if (!t->can_have_children()) continue; + if (t->can_have_children()) { c = read_word(1); if (strcmp(c,"{")) { read_error("Missing child list for %s\n",t->title()); @@ -406,6 +405,7 @@ Fl_Type *Fd_Project_Reader::read_children(Fl_Type *p, int merge, Strategy strate t->layout_widget(); } + if (strategy == kAddAsFirstChild) { strategy = kAddAfterCurrent; } diff --git a/fluid/undo.cxx b/fluid/undo.cxx index 31b412878..67c800baa 100644 --- a/fluid/undo.cxx +++ b/fluid/undo.cxx @@ -136,19 +136,23 @@ void undo_cb(Fl_Widget *, void *) { undo_suspend(); // Undo first deletes all widgets which resets the widget_tree browser. // Save the current scroll position, so we don't scroll back to 0 at undo. + // TODO: make the scroll position part of the .fl project file if (widget_browser) widget_browser->save_scroll_position(); int reload_panel = (the_panel && the_panel->visible()); if (!read_file(undo_filename(undo_current - 1), 0)) { // Unable to read checkpoint file, don't undo... widget_browser->rebuild(); g_project.update_settings_dialog(); + set_modflag(0, 0); undo_resume(); return; } if (reload_panel) { for (Fl_Type *t = Fl_Type::first; t; t=t->next) { - if (t->is_widget() && t->selected) + if (t->is_widget() && t->selected) { t->open(); + break; + } } } // Restore old browser position.