FLUID: Fixes file reading bug, introduces two weeks ago: #1078

This commit is contained in:
Matthias Melcher 2024-10-06 17:33:04 +02:00
parent 3431c9d21a
commit 9eb5f11c39
2 changed files with 31 additions and 27 deletions

View File

@ -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()) { // <prefix> <name>
((Fl_Class_Type*)t)->prefix(t->name());
t->name(c);
c = read_word(1);
if (strcmp(c,"{") && t->is_class()) { // <prefix> <name>
((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;
}

View File

@ -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.