Range check Fl_Text_Buffer::search_forward().

Don't use png_read_destroy() - it doesn't free all memory.

Add uncache() method to image classes.

Memory/initialization bugs in Fl_File_Chooser (valgrind)

Make sure both Fl_Window constructors have default cursor initialization
code...


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2562 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2002-08-05 17:50:25 +00:00
parent 685100b122
commit a11a31ff78
19 changed files with 108 additions and 82 deletions

View File

@ -1,7 +1,14 @@
CHANGES IN FLTK 1.1.0
- Documentation updates.
- Added image() methods() to Fl_Menu_Item.
- Fixed some memory/initialization bugs in
Fl_File_Chooser that valgrind caught.
- The PNG library png_read_destroy() is deprecated and
does not free all of the memory allocated by
png_create_read_struct(). This caused a memory leak in
FLTK apps that loaded PNG images.
- Added uncache() method to Fl_Image and friends.
- Added image() methods to Fl_Menu_Item.
- Added default_cursor() method and data to Fl_Window.
- Fl_Group would send FL_ENTER events before FL_LEAVE
events, causing problems with adjacent widgets.

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Bitmap.H,v 1.5.2.3.2.7 2002/01/01 15:11:27 easysw Exp $"
// "$Id: Fl_Bitmap.H,v 1.5.2.3.2.8 2002/08/05 17:50:22 easysw Exp $"
//
// Bitmap header file for the Fast Light Tool Kit (FLTK).
//
@ -48,10 +48,11 @@ class FL_EXPORT Fl_Bitmap : public Fl_Image {
void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
virtual void label(Fl_Widget*w);
virtual void label(Fl_Menu_Item*m);
virtual void uncache();
};
#endif
//
// End of "$Id: Fl_Bitmap.H,v 1.5.2.3.2.7 2002/01/01 15:11:27 easysw Exp $".
// End of "$Id: Fl_Bitmap.H,v 1.5.2.3.2.8 2002/08/05 17:50:22 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Image.H,v 1.5.2.3.2.13 2002/07/14 21:25:39 easysw Exp $"
// "$Id: Fl_Image.H,v 1.5.2.3.2.14 2002/08/05 17:50:23 easysw Exp $"
//
// Image header file for the Fast Light Tool Kit (FLTK).
//
@ -71,6 +71,7 @@ class FL_EXPORT Fl_Image {
virtual void label(Fl_Menu_Item*m);
virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
virtual void uncache();
};
class FL_EXPORT Fl_RGB_Image : public Fl_Image {
@ -93,10 +94,11 @@ class FL_EXPORT Fl_RGB_Image : public Fl_Image {
void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
virtual void label(Fl_Widget*w);
virtual void label(Fl_Menu_Item*m);
virtual void uncache();
};
#endif
//
// End of "$Id: Fl_Image.H,v 1.5.2.3.2.13 2002/07/14 21:25:39 easysw Exp $".
// End of "$Id: Fl_Image.H,v 1.5.2.3.2.14 2002/08/05 17:50:23 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Pixmap.H,v 1.6.2.8.2.7 2002/01/01 15:11:28 easysw Exp $"
// "$Id: Fl_Pixmap.H,v 1.6.2.8.2.8 2002/08/05 17:50:23 easysw Exp $"
//
// Pixmap header file for the Fast Light Tool Kit (FLTK).
//
@ -63,10 +63,11 @@ class FL_EXPORT Fl_Pixmap : public Fl_Image {
void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
virtual void label(Fl_Widget*w);
virtual void label(Fl_Menu_Item*m);
virtual void uncache();
};
#endif
//
// End of "$Id: Fl_Pixmap.H,v 1.6.2.8.2.7 2002/01/01 15:11:28 easysw Exp $".
// End of "$Id: Fl_Pixmap.H,v 1.6.2.8.2.8 2002/08/05 17:50:23 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
/*
* "$Id: configh.in,v 1.11.2.11.2.12 2002/05/16 12:47:42 easysw Exp $"
* "$Id: configh.in,v 1.11.2.11.2.13 2002/08/05 17:50:21 easysw Exp $"
*
* Configuration file for the Fast Light Tool Kit (FLTK).
* @configure_input@
@ -210,7 +210,6 @@
#undef HAVE_PNG_GET_VALID
#undef HAVE_PNG_SET_TRNS_TO_ALPHA
#undef HAVE_PNG_READ_DESTROY
/*
* Do we have POSIX threading?
@ -221,5 +220,5 @@
/*
* End of "$Id: configh.in,v 1.11.2.11.2.12 2002/05/16 12:47:42 easysw Exp $".
* End of "$Id: configh.in,v 1.11.2.11.2.13 2002/08/05 17:50:21 easysw Exp $".
*/

View File

@ -1,7 +1,7 @@
dnl -*- sh -*-
dnl the "configure" script is made from this by running GNU "autoconf"
dnl
dnl "$Id: configure.in,v 1.33.2.31.2.81 2002/07/20 23:39:08 easysw Exp $"
dnl "$Id: configure.in,v 1.33.2.31.2.82 2002/08/05 17:50:21 easysw Exp $"
dnl
dnl Configuration script for the Fast Light Tool Kit (FLTK).
dnl
@ -331,7 +331,7 @@ if test x$ac_cv_header_png_h = xyes -o x$ac_cv_header_libpng_png_h = xyes; then
AC_DEFINE(HAVE_LIBPNG)
IMAGELIBS="-lpng $IMAGELIBS"
LIBS="-lpng $LIBS"
AC_CHECK_FUNCS(png_get_valid png_set_tRNS_to_alpha png_read_destroy))
AC_CHECK_FUNCS(png_get_valid png_set_tRNS_to_alpha))
fi
dnl Restore original LIBS settings...
@ -782,5 +782,5 @@ dnl Make sure the fltk-config script is executable...
chmod +x fltk-config
dnl
dnl End of "$Id: configure.in,v 1.33.2.31.2.81 2002/07/20 23:39:08 easysw Exp $".
dnl End of "$Id: configure.in,v 1.33.2.31.2.82 2002/08/05 17:50:21 easysw Exp $".
dnl

View File

@ -69,6 +69,8 @@ a box with an X in it being drawn instead.</P>
<LI><A href="#Fl_Image.ld">ld</A></LI>
<LI><A href="#Fl_Image.uncache">uncache</A></LI>
<LI><A href="#Fl_Image.w">w</A></LI>
</UL>
@ -186,6 +188,12 @@ after each line of color image data and is normally not present.</P>
<P>The second form is a protected method that sets the current
line data size in bytes.</P>
<H4><A NAME="Fl_Image.uncache">void uncache();</A></H4>
<P>If the image has been cached for display, delete the cache
data. This allows you to change the data used for the image and
then redraw it without recreating an image object.
<H4><A NAME="Fl_Image.w">int w();<BR>
protected void w(int W);</A></H4>

View File

@ -1,5 +1,5 @@
/*
* "$Id: config.mingw,v 1.1.2.3.2.8 2002/07/09 17:41:24 easysw Exp $"
* "$Id: config.mingw,v 1.1.2.3.2.9 2002/08/05 17:50:24 easysw Exp $"
*
* Configuration file for the Fast Light Tool Kit (FLTK).
*
@ -205,7 +205,6 @@
/* #undef HAVE_PNG_GET_VALID */
/* #undef HAVE_PNG_SET_TRNS_TO_ALPHA */
/* #undef HAVE_PNG_READ_DESTROY */
/*
* Do we have POSIX threading?
@ -216,5 +215,5 @@
/*
* End of "$Id: config.mingw,v 1.1.2.3.2.8 2002/07/09 17:41:24 easysw Exp $".
* End of "$Id: config.mingw,v 1.1.2.3.2.9 2002/08/05 17:50:24 easysw Exp $".
*/

View File

@ -1,6 +1,6 @@
/* config.h. Generated automatically by configure. */
/*
* "$Id: config.os2x,v 1.1.2.4.2.10 2002/07/09 17:41:24 easysw Exp $"
* "$Id: config.os2x,v 1.1.2.4.2.11 2002/08/05 17:50:24 easysw Exp $"
*
* Configuration file for the Fast Light Tool Kit (FLTK).
*
@ -210,7 +210,6 @@
#define HAVE_PNG_GET_VALID 1
/* #undef HAVE_PNG_SET_TRNS_TO_ALPHA */
#define HAVE_PNG_READ_DESTROY 1
/*
* Do we have POSIX threading?
@ -221,5 +220,5 @@
/*
* End of "$Id: config.os2x,v 1.1.2.4.2.10 2002/07/09 17:41:24 easysw Exp $".
* End of "$Id: config.os2x,v 1.1.2.4.2.11 2002/08/05 17:50:24 easysw Exp $".
*/

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.15 2002/04/26 11:32:37 easysw Exp $"
// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.16 2002/08/05 17:50:24 easysw Exp $"
//
// Bitmap drawing routines for the Fast Light Tool Kit (FLTK).
//
@ -384,10 +384,17 @@ void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
}
Fl_Bitmap::~Fl_Bitmap() {
if (id) fl_delete_bitmask(id);
uncache();
if (alloc_array) delete[] (uchar *)array;
}
void Fl_Bitmap::uncache() {
if (id) {
fl_delete_bitmask(id);
id = 0;
}
}
void Fl_Bitmap::label(Fl_Widget* w) {
w->image(this);
}
@ -466,5 +473,5 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) {
//
// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.15 2002/04/26 11:32:37 easysw Exp $".
// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.16 2002/08/05 17:50:24 easysw Exp $".
//

View File

@ -246,7 +246,9 @@ Fl_File_Chooser::Fl_File_Chooser(const char *d, const char *p, int t, const char
}
callback_ = 0;
data_ = 0;
directory_[0] = '\0';
window->size_range(window->w(), window->h(), Fl::w(), Fl::h());
type(t);
filter(p);
update_favorites();
value(d);

View File

@ -166,7 +166,9 @@ window->hide();}
}
code {callback_ = 0;
data_ = 0;
directory_[0] = '\0';
window->size_range(window->w(), window->h(), Fl::w(), Fl::h());
type(t);
filter(p);
update_favorites();
value(d);

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_File_Chooser2.cxx,v 1.1.2.21 2002/07/30 18:33:49 easysw Exp $"
// "$Id: Fl_File_Chooser2.cxx,v 1.1.2.22 2002/08/05 17:50:25 easysw Exp $"
//
// More Fl_File_Chooser routines.
//
@ -783,7 +783,7 @@ Fl_File_Chooser::rescan()
// Clear the current filename
strlcpy(pathname, directory_, sizeof(pathname));
if (pathname[strlen(pathname) - 1] != '/') {
if (pathname[0] && pathname[strlen(pathname) - 1] != '/') {
strlcat(pathname, "/", sizeof(pathname));
}
fileName->value(pathname);
@ -1143,5 +1143,5 @@ unquote_pathname(char *dst, // O - Destination string
//
// End of "$Id: Fl_File_Chooser2.cxx,v 1.1.2.21 2002/07/30 18:33:49 easysw Exp $".
// End of "$Id: Fl_File_Chooser2.cxx,v 1.1.2.22 2002/08/05 17:50:25 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Image.cxx,v 1.5.2.3.2.21 2002/05/24 14:19:19 easysw Exp $"
// "$Id: Fl_Image.cxx,v 1.5.2.3.2.22 2002/08/05 17:50:25 easysw Exp $"
//
// Image drawing code for the Fast Light Tool Kit (FLTK).
//
@ -41,6 +41,9 @@ void fl_restore_clip(); // from fl_rect.cxx
Fl_Image::~Fl_Image() {
}
void Fl_Image::uncache() {
}
void Fl_Image::draw(int XP, int YP, int, int, int, int) {
draw_empty(XP, YP);
}
@ -116,11 +119,22 @@ Fl_Image::measure(const Fl_Label *lo, // I - Label
//
Fl_RGB_Image::~Fl_RGB_Image() {
if (id) fl_delete_offscreen((Fl_Offscreen)id);
if (mask) fl_delete_bitmask(mask);
uncache();
if (alloc_array) delete[] (uchar *)array;
}
void Fl_RGB_Image::uncache() {
if (id) {
fl_delete_offscreen(id);
id = 0;
}
if (mask) {
fl_delete_bitmask(mask);
mask = 0;
}
}
Fl_Image *Fl_RGB_Image::copy(int W, int H) {
// Optimize the simple copy where the width and height are the same,
// or when we are copying an empty image...
@ -185,15 +199,7 @@ void Fl_RGB_Image::color_average(Fl_Color c, float i) {
if (!w() || !h() || !d() || !array) return;
// Delete any existing pixmap/mask objects...
if (id) {
fl_delete_offscreen(id);
id = 0;
}
if (mask) {
fl_delete_bitmask(mask);
mask = 0;
}
uncache();
// Allocate memory as needed...
uchar *new_array,
@ -254,15 +260,7 @@ void Fl_RGB_Image::desaturate() {
if (d() < 3) return;
// Delete any existing pixmap/mask objects...
if (id) {
fl_delete_offscreen(id);
id = 0;
}
if (mask) {
fl_delete_bitmask(mask);
mask = 0;
}
uncache();
// Allocate memory for a grayscale image...
uchar *new_array,
@ -393,5 +391,5 @@ void Fl_RGB_Image::label(Fl_Menu_Item* m) {
//
// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.21 2002/05/24 14:19:19 easysw Exp $".
// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.22 2002/08/05 17:50:25 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_PNG_Image.cxx,v 1.1.2.7 2002/05/25 02:56:59 easysw Exp $"
// "$Id: Fl_PNG_Image.cxx,v 1.1.2.8 2002/08/05 17:50:25 easysw Exp $"
//
// Fl_PNG_Image routines.
//
@ -124,11 +124,7 @@ Fl_PNG_Image::Fl_PNG_Image(const char *png) // I - File to read
delete[] rows;
png_read_end(pp, info);
# ifdef HAVE_PNG_READ_DESTROY
png_read_destroy(pp, info, NULL);
# else
png_destroy_read_struct(&pp, &info, NULL);
# endif // HAVE_PNG_READ_DESTROY
fclose(fp);
#endif // HAVE_LIBPNG && HAVE_LIBZ
@ -136,5 +132,5 @@ Fl_PNG_Image::Fl_PNG_Image(const char *png) // I - File to read
//
// End of "$Id: Fl_PNG_Image.cxx,v 1.1.2.7 2002/05/25 02:56:59 easysw Exp $".
// End of "$Id: Fl_PNG_Image.cxx,v 1.1.2.8 2002/08/05 17:50:25 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.19 2002/06/29 00:10:04 matthiaswm Exp $"
// "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.20 2002/08/05 17:50:25 easysw Exp $"
//
// Pixmap drawing code for the Fast Light Tool Kit (FLTK).
//
@ -146,11 +146,22 @@ void Fl_Pixmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
}
Fl_Pixmap::~Fl_Pixmap() {
if (id) fl_delete_offscreen(id);
if (mask) fl_delete_bitmask(mask);
uncache();
delete_data();
}
void Fl_Pixmap::uncache() {
if (id) {
fl_delete_offscreen(id);
id = 0;
}
if (mask) {
fl_delete_bitmask(mask);
mask = 0;
}
}
void Fl_Pixmap::label(Fl_Widget* w) {
w->image(this);
}
@ -302,15 +313,7 @@ Fl_Image *Fl_Pixmap::copy(int W, int H) {
void Fl_Pixmap::color_average(Fl_Color c, float i) {
// Delete any existing pixmap/mask objects...
if (id) {
fl_delete_offscreen(id);
id = 0;
}
if (mask) {
fl_delete_bitmask(mask);
mask = 0;
}
uncache();
// Allocate memory as needed...
copy_data();
@ -402,15 +405,7 @@ void Fl_Pixmap::set_data(const char * const * p) {
void Fl_Pixmap::desaturate() {
// Delete any existing pixmap/mask objects...
if (id) {
fl_delete_offscreen(id);
id = 0;
}
if (mask) {
fl_delete_bitmask(mask);
mask = 0;
}
uncache();
// Allocate memory as needed...
copy_data();
@ -465,5 +460,5 @@ void Fl_Pixmap::desaturate() {
}
//
// End of "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.19 2002/06/29 00:10:04 matthiaswm Exp $".
// End of "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.20 2002/08/05 17:50:25 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Text_Buffer.cxx,v 1.9.2.8 2002/06/10 21:04:19 easysw Exp $"
// "$Id: Fl_Text_Buffer.cxx,v 1.9.2.9 2002/08/05 17:50:25 easysw Exp $"
//
// Copyright 2001-2002 by Bill Spitzak and others.
// Original code Copyright Mark Edel. Permission to distribute under
@ -1967,6 +1967,11 @@ int Fl_Text_Buffer::findchar_forward( int startPos, char searchChar,
int *foundPos ) {
int pos, gapLen = mGapEnd - mGapStart;
if (pos < 0 || pos >= mLength) {
*foundPos = mLength;
return 0;
}
pos = startPos;
while ( pos < mGapStart ) {
if ( mBuf[ pos ] == searchChar ) {
@ -2284,5 +2289,5 @@ Fl_Text_Buffer::outputfile(const char *file, int start, int end, int buflen) {
//
// End of "$Id: Fl_Text_Buffer.cxx,v 1.9.2.8 2002/06/10 21:04:19 easysw Exp $".
// End of "$Id: Fl_Text_Buffer.cxx,v 1.9.2.9 2002/08/05 17:50:25 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Window.cxx,v 1.6.2.3.2.8 2002/08/01 02:15:43 easysw Exp $"
// "$Id: Fl_Window.cxx,v 1.6.2.3.2.9 2002/08/05 17:50:25 easysw Exp $"
//
// Window widget class for the Fast Light Tool Kit (FLTK).
//
@ -64,6 +64,10 @@ Fl_Window::Fl_Window(int X,int Y,int W, int H, const char *l)
Fl_Window::Fl_Window(int W, int H, const char *l)
// fix common user error of a missing end() with current(0):
: Fl_Group((Fl_Group::current(0),0), 0, W, H, l) {
cursor_default = FL_CURSOR_DEFAULT;
cursor_fg = FL_BLACK;
cursor_bg = FL_WHITE;
_Fl_Window();
clear_visible();
}
@ -123,5 +127,5 @@ Fl_Window *Fl_Window::current() {
//
// End of "$Id: Fl_Window.cxx,v 1.6.2.3.2.8 2002/08/01 02:15:43 easysw Exp $".
// End of "$Id: Fl_Window.cxx,v 1.6.2.3.2.9 2002/08/05 17:50:25 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: fl_cursor.cxx,v 1.6.2.6.2.5 2002/08/01 02:15:43 easysw Exp $"
// "$Id: fl_cursor.cxx,v 1.6.2.6.2.6 2002/08/05 17:50:25 easysw Exp $"
//
// Mouse cursor support for the Fast Light Tool Kit (FLTK).
//
@ -42,7 +42,7 @@ void fl_cursor(Fl_Cursor c, Fl_Color fg, Fl_Color bg) {
}
void Fl_Window::default_cursor(Fl_Cursor c, Fl_Color fg, Fl_Color bg) {
if (c == FL_CURSOR_DEFAULT) c = FL_CURSOR_ARROW;
// if (c == FL_CURSOR_DEFAULT) c = FL_CURSOR_ARROW;
cursor_default = c;
cursor_fg = fg;
@ -272,6 +272,7 @@ void Fl_Window::cursor(Fl_Cursor c, Fl_Color fg, Fl_Color bg) {
fg = cursor_fg;
bg = cursor_bg;
}
if (!c) {
cursor = None;
} else {
@ -311,5 +312,5 @@ void Fl_Window::cursor(Fl_Cursor c, Fl_Color fg, Fl_Color bg) {
#endif
//
// End of "$Id: fl_cursor.cxx,v 1.6.2.6.2.5 2002/08/01 02:15:43 easysw Exp $".
// End of "$Id: fl_cursor.cxx,v 1.6.2.6.2.6 2002/08/05 17:50:25 easysw Exp $".
//