summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2002-08-05 17:50:25 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2002-08-05 17:50:25 +0000
commita11a31ff78af62e73735b5e012849523a612e26a (patch)
tree539acb40340746b970e5f151def2ae9105b8821d /src
parent685100b1222821dedec2e0b22f55ca18027a99df (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Bitmap.cxx13
-rw-r--r--src/Fl_File_Chooser.cxx2
-rw-r--r--src/Fl_File_Chooser.fl2
-rw-r--r--src/Fl_File_Chooser2.cxx6
-rw-r--r--src/Fl_Image.cxx42
-rw-r--r--src/Fl_PNG_Image.cxx8
-rw-r--r--src/Fl_Pixmap.cxx39
-rw-r--r--src/Fl_Text_Buffer.cxx9
-rw-r--r--src/Fl_Window.cxx8
-rw-r--r--src/fl_cursor.cxx7
10 files changed, 73 insertions, 63 deletions
diff --git a/src/Fl_Bitmap.cxx b/src/Fl_Bitmap.cxx
index f7a254dd7..2355cd91a 100644
--- a/src/Fl_Bitmap.cxx
+++ b/src/Fl_Bitmap.cxx
@@ -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 $".
//
diff --git a/src/Fl_File_Chooser.cxx b/src/Fl_File_Chooser.cxx
index 7dfdd88ef..8ca8c9e21 100644
--- a/src/Fl_File_Chooser.cxx
+++ b/src/Fl_File_Chooser.cxx
@@ -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);
diff --git a/src/Fl_File_Chooser.fl b/src/Fl_File_Chooser.fl
index 12d9e5bca..4211ebb3a 100644
--- a/src/Fl_File_Chooser.fl
+++ b/src/Fl_File_Chooser.fl
@@ -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);
diff --git a/src/Fl_File_Chooser2.cxx b/src/Fl_File_Chooser2.cxx
index 20fcd5b05..f14684c5e 100644
--- a/src/Fl_File_Chooser2.cxx
+++ b/src/Fl_File_Chooser2.cxx
@@ -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 $".
//
diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx
index cb3478423..b66a01fe7 100644
--- a/src/Fl_Image.cxx
+++ b/src/Fl_Image.cxx
@@ -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 $".
//
diff --git a/src/Fl_PNG_Image.cxx b/src/Fl_PNG_Image.cxx
index 01de9f705..aa3f3638b 100644
--- a/src/Fl_PNG_Image.cxx
+++ b/src/Fl_PNG_Image.cxx
@@ -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 $".
//
diff --git a/src/Fl_Pixmap.cxx b/src/Fl_Pixmap.cxx
index ab7308e75..889b1ecc8 100644
--- a/src/Fl_Pixmap.cxx
+++ b/src/Fl_Pixmap.cxx
@@ -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 $".
//
diff --git a/src/Fl_Text_Buffer.cxx b/src/Fl_Text_Buffer.cxx
index 5b65f82b3..d1707a98f 100644
--- a/src/Fl_Text_Buffer.cxx
+++ b/src/Fl_Text_Buffer.cxx
@@ -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 $".
//
diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx
index e3cbb37e5..4d79741c5 100644
--- a/src/Fl_Window.cxx
+++ b/src/Fl_Window.cxx
@@ -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 $".
//
diff --git a/src/fl_cursor.cxx b/src/fl_cursor.cxx
index 026429122..9f3bbb1ff 100644
--- a/src/fl_cursor.cxx
+++ b/src/fl_cursor.cxx
@@ -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 $".
//