From: Christophe CURIS <christophe.cu...@free.fr>

If the user modifies the string returned by the new function 'WMGetButtonText'
the widget will not see that and may lead to incorrect display (or worse,
crash if the user happens to 'free' it, as it is usual for most of the
other API functions).

By adding the 'const' attribute, we will force the user to think about what
he is doing: compiler will issue a warning if trying to 'free' it; and user
may think about properly calling 'WMSetButtonText' if he actually wants to
change the displayed text.

(merge with f01852f079c402b54180d1d08e96d95d4b3f5049)
---
 WINGs/WINGs/WINGs.h | 2 +-
 WINGs/wbutton.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/WINGs/WINGs/WINGs.h b/WINGs/WINGs/WINGs.h
index 48ffa42..8cb0144 100644
--- a/WINGs/WINGs/WINGs.h
+++ b/WINGs/WINGs/WINGs.h
@@ -1069,7 +1069,7 @@ void WMSetButtonTextAlignment(WMButton *bPtr, WMAlignment 
alignment);
 
 void WMSetButtonText(WMButton *bPtr, const char *text);
 
-char* WMGetButtonText(WMButton *bPtr);
+/* Returns direct pointer to internal data, do not modify! */
+const char *WMGetButtonText(WMButton *bPtr);
 
 void WMSetButtonAltText(WMButton *bPtr, const char *text);
 
diff --git a/WINGs/wbutton.c b/WINGs/wbutton.c
index 33a9095..c217edd 100644
--- a/WINGs/wbutton.c
+++ b/WINGs/wbutton.c
@@ -325,7 +325,7 @@ void WMSetButtonText(WMButton * bPtr, const char *text)
        }
 }
 
-char *WMGetButtonText(WMButton *bPtr)
+const char *WMGetButtonText(WMButton *bPtr)
 {
        return bPtr->caption;
 }
-- 
2.1.1


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to