Author: AlbrechtS
Date: 2012-05-05 06:36:47 -0700 (Sat, 05 May 2012)
New Revision: 9443
Log:
Fix STR #2836: copy_label() with old label() value failed.


Modified:
   branches/branch-1.3/CHANGES
   branches/branch-1.3/src/Fl_Widget.cxx
   branches/branch-1.3/src/Fl_Window.cxx

Modified: branches/branch-1.3/CHANGES
===================================================================
--- branches/branch-1.3/CHANGES 2012-05-03 11:53:16 UTC (rev 9442)
+++ branches/branch-1.3/CHANGES 2012-05-05 13:36:47 UTC (rev 9443)
@@ -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)

Modified: branches/branch-1.3/src/Fl_Widget.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Widget.cxx       2012-05-03 11:53:16 UTC (rev 
9442)
+++ branches/branch-1.3/src/Fl_Widget.cxx       2012-05-05 13:36:47 UTC (rev 
9443)
@@ -303,13 +303,14 @@
 
 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();
 }

Modified: branches/branch-1.3/src/Fl_Window.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Window.cxx       2012-05-03 11:53:16 UTC (rev 
9442)
+++ branches/branch-1.3/src/Fl_Window.cxx       2012-05-05 13:36:47 UTC (rev 
9443)
@@ -139,22 +139,16 @@
 }
 
 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

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to