Fix STR #2836: copy_label() with old label() value failed.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9443 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Albrecht Schlosser 2012-05-05 13:36:47 +00:00
parent 93fd842a5b
commit 66cea4322f
3 changed files with 12 additions and 14 deletions

View File

@ -1,5 +1,8 @@
CHANGES IN FLTK 1.3.2
- Fixed Fl_Widget::copy_label() and Fl_Window::copy_label() when
called with the old label() (STR #2836)
1.3.2 ABI FEATURES
(To enable the following ABI features, put: #define FLTK_ABI_VERSION 10302
at the top of your FL/Enumerations.H and rebuild FLTK and your app)

View File

@ -303,13 +303,14 @@ Fl_Widget::label(const char *a) {
void
Fl_Widget::copy_label(const char *a) {
if (flags() & COPIED_LABEL) free((void *)(label_.value));
// reassigning a copied label remains the same copied label
if ((flags() & COPIED_LABEL) && (label_.value == a))
return;
if (a) {
label(strdup(a));
set_flag(COPIED_LABEL);
label_.value=strdup(a);
} else {
clear_flag(COPIED_LABEL);
label_.value=(char *)0;
label(0);
}
redraw_label();
}

View File

@ -139,22 +139,16 @@ void Fl_Window::draw() {
}
void Fl_Window::label(const char *name) {
label(name, iconlabel());
label(name, iconlabel()); // platform dependent
}
void Fl_Window::copy_label(const char *a) {
if (flags() & COPIED_LABEL) {
free((void *)label());
clear_flag(COPIED_LABEL);
}
if (a) a = strdup(a);
label(a, iconlabel());
set_flag(COPIED_LABEL);
Fl_Widget::copy_label(a);
label(label(), iconlabel()); // platform dependent
}
void Fl_Window::iconlabel(const char *iname) {
label(label(), iname);
label(label(), iname); // platform dependent
}
// the Fl::atclose pointer is provided for back compatibility. You