summaryrefslogtreecommitdiff
path: root/fluid/panels/widget_panel.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'fluid/panels/widget_panel.cxx')
-rw-r--r--fluid/panels/widget_panel.cxx40
1 files changed, 32 insertions, 8 deletions
diff --git a/fluid/panels/widget_panel.cxx b/fluid/panels/widget_panel.cxx
index 5bbde2fec..5556a19fa 100644
--- a/fluid/panels/widget_panel.cxx
+++ b/fluid/panels/widget_panel.cxx
@@ -31,6 +31,7 @@
#include <FL/fl_ask.H>
#include <FL/Fl_Menu_Item.H>
#include <FL/Fl_File_Chooser.H>
+#include <ctype.h>
#define ZERO_ENTRY 1000
extern const char* when_symbol_name(int n);
extern void set_whenmenu(int n);
@@ -2636,11 +2637,10 @@ static void cb_Attribute(Fl_Input* o, void* v) {
Class_Node* nd = (Class_Node*)current_node;
if (v == LOAD) {
- o->value( nd->prefix() );
+ o->value( nd->prefix().c_str() );
} else {
- const char *nn = nd->prefix();
- if ( ( nn && (strcmp(nn, o->value()) != 0))
- || (!nn && (strcmp("", o->value()) != 0)) )
+ auto nn = nd->prefix();
+ if (nn != o->value())
{
nd->prefix( o->value() );
Fluid.proj.set_modflag(1);
@@ -2657,13 +2657,37 @@ static void cb_Class(Fl_Input* o, void* v) {
o->value( nd->name() );
} else {
const char *nn = nd->name();
- if ( ( nn && (strcmp(nn, o->value()) != 0))
- || (!nn && (strcmp("", o->value()) != 0)) )
+ char *nv = strdup( o->value() );
+ // There is an inconsistency in the project file reader, so this string
+ // must not coantain anything but alphanumeric and underscore characters.
+ char *s = (char*)nv;
+ char *d = (char*)nv;
+ while (*s) {
+ if (isalnum((unsigned char)*s) || *s == '_') {
+ *d++ = *s;
+ }
+ s++;
+ }
+ *d = 0;
+ // The class name must not be empty either
+ if (*nv == 0) {
+ free((void*)nv);
+ nv = strdup("MyClass");
+ }
+ // The class name may have changed, so update the widget
+ o->value( nv );
+ // Now copy the new name into the node if it changed
+ if ( ( nn && (strcmp(nn, nv) != 0))
+ || (!nn && (strcmp("", nv) != 0)) )
{
- nd->name( o->value() );
+ nd->name( nv );
Fluid.proj.set_modflag(1);
redraw_browser();
}
+ // Don't forget to clean up
+ if (nv) {
+ free((void*)nv);
+ }
}
}
@@ -3239,6 +3263,7 @@ Fl_Double_Window* make_widget_panel() {
widget_tabs->labelcolor(FL_BACKGROUND2_COLOR);
widget_tabs->callback((Fl_Callback*)cb_widget_tabs);
widget_tabs->when(FL_WHEN_NEVER);
+ widget_tabs->hide();
{ wp_gui_tab = new Fl_Group(10, 30, 400, 330, "GUI");
wp_gui_tab->labelsize(11);
wp_gui_tab->callback((Fl_Callback*)propagate_load);
@@ -4326,7 +4351,6 @@ Fl_Double_Window* make_widget_panel() {
class_tabs->labelsize(11);
class_tabs->labelcolor(FL_WHITE);
class_tabs->callback((Fl_Callback*)cb_class_tabs);
- class_tabs->hide();
{ class_tabs_main = new Fl_Group(10, 30, 400, 330, "Class");
class_tabs_main->labelsize(11);
class_tabs_main->callback((Fl_Callback*)propagate_load);