Fixed a few memory faults found by Valgrind (yes, I finally got my Linux
machine up and running again) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4723 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
10fae2dd8a
commit
d3db965083
@ -305,14 +305,17 @@ void CodeEditor::style_update(int pos, int nInserted, int nDeleted,
|
||||
end = editor->mBuffer->line_end(pos + nInserted);
|
||||
text = editor->mBuffer->text_range(start, end);
|
||||
style = editor->mStyleBuffer->text_range(start, end);
|
||||
last = style[end - start - 1];
|
||||
if (start==end)
|
||||
last = 0;
|
||||
else
|
||||
last = style[end - start - 1];
|
||||
|
||||
style_parse(text, style, end - start);
|
||||
|
||||
editor->mStyleBuffer->replace(start, end, style);
|
||||
editor->redisplay_range(start, end);
|
||||
|
||||
if (last != style[end - start - 1]) {
|
||||
if (start==end || last != style[end - start - 1]) {
|
||||
// The last character on the line changed styles, so reparse the
|
||||
// remainder of the buffer...
|
||||
free(text);
|
||||
|
@ -1332,6 +1332,7 @@ void min_w_cb(Fl_Value_Input* i, void* v) {
|
||||
|
||||
void min_h_cb(Fl_Value_Input* i, void* v) {
|
||||
if (v == LOAD) {
|
||||
if (!current_widget->is_window()) return;
|
||||
i->value(((Fl_Window_Type*)current_widget)->sr_min_h);
|
||||
} else {
|
||||
int mod = 0;
|
||||
@ -1348,6 +1349,7 @@ void min_h_cb(Fl_Value_Input* i, void* v) {
|
||||
|
||||
void max_w_cb(Fl_Value_Input* i, void* v) {
|
||||
if (v == LOAD) {
|
||||
if (!current_widget->is_window()) return;
|
||||
i->value(((Fl_Window_Type*)current_widget)->sr_max_w);
|
||||
} else {
|
||||
int mod = 0;
|
||||
@ -1364,6 +1366,7 @@ void max_w_cb(Fl_Value_Input* i, void* v) {
|
||||
|
||||
void max_h_cb(Fl_Value_Input* i, void* v) {
|
||||
if (v == LOAD) {
|
||||
if (!current_widget->is_window()) return;
|
||||
i->value(((Fl_Window_Type*)current_widget)->sr_max_h);
|
||||
} else {
|
||||
int mod = 0;
|
||||
|
@ -359,7 +359,7 @@ const char * Fl_File_Chooser::label() {
|
||||
|
||||
void Fl_File_Chooser::ok_label(const char *l) {
|
||||
okButton->label(l);
|
||||
int w, h;
|
||||
int w=0, h=0;
|
||||
okButton->measure_label(w, h);
|
||||
okButton->resize(cancelButton->x() - 50 - w, cancelButton->y(),
|
||||
w + 40, 25);
|
||||
|
@ -283,7 +283,7 @@ showChoiceCB();} {}
|
||||
Function {ok_label(const char *l)} {return_type void
|
||||
} {
|
||||
code {okButton->label(l);
|
||||
int w, h;
|
||||
int w=0, h=0;
|
||||
okButton->measure_label(w, h);
|
||||
okButton->resize(cancelButton->x() - 50 - w, cancelButton->y(),
|
||||
w + 40, 25);
|
||||
|
@ -38,6 +38,7 @@ Fl_Valuator::Fl_Valuator(int X, int Y, int W, int H, const char* L)
|
||||
align(FL_ALIGN_BOTTOM);
|
||||
when(FL_WHEN_CHANGED);
|
||||
value_ = 0;
|
||||
previous_value_ = 1;
|
||||
min = 0;
|
||||
max = 1;
|
||||
A = 0.0;
|
||||
|
@ -263,15 +263,16 @@ int fl_draw_pixmap(const char*const* di, int x, int y, Fl_Color bg) {
|
||||
for (int Y = 0; Y < d.h; Y++) {
|
||||
const uchar* p = data[Y];
|
||||
if (chars_per_pixel <= 1) {
|
||||
int dw = d.w;
|
||||
for (int X = 0; X < W; X++) {
|
||||
uchar b = (*p++ != transparent_index);
|
||||
if (*p++ != transparent_index) b |= 2;
|
||||
if (*p++ != transparent_index) b |= 4;
|
||||
if (*p++ != transparent_index) b |= 8;
|
||||
if (*p++ != transparent_index) b |= 16;
|
||||
if (*p++ != transparent_index) b |= 32;
|
||||
if (*p++ != transparent_index) b |= 64;
|
||||
if (*p++ != transparent_index) b |= 128;
|
||||
uchar b = (dw-->0 && *p++ != transparent_index);
|
||||
if (dw-->0 && *p++ != transparent_index) b |= 2;
|
||||
if (dw-->0 && *p++ != transparent_index) b |= 4;
|
||||
if (dw-->0 && *p++ != transparent_index) b |= 8;
|
||||
if (dw-->0 && *p++ != transparent_index) b |= 16;
|
||||
if (dw-->0 && *p++ != transparent_index) b |= 32;
|
||||
if (dw-->0 && *p++ != transparent_index) b |= 64;
|
||||
if (dw-->0 && *p++ != transparent_index) b |= 128;
|
||||
*bitmap++ = b;
|
||||
}
|
||||
} else {
|
||||
|
@ -182,7 +182,8 @@ void push_menu(const char* nnn)
|
||||
if (menus[men].icommand[i][0] != '@') but[bn]->tooltip(menus[men].icommand[i]);
|
||||
else but[bn]->tooltip(0);
|
||||
}
|
||||
strcpy(stack[stsize],nnn);
|
||||
if (stack[stsize]!=nnn)
|
||||
strcpy(stack[stsize],nnn);
|
||||
stsize++;
|
||||
}
|
||||
|
||||
@ -255,8 +256,8 @@ void dobut(Fl_Widget *, long arg)
|
||||
CreateProcess(NULL, command, NULL, NULL, FALSE,
|
||||
NORMAL_PRIORITY_CLASS, NULL, NULL, &suInfo, &prInfo);
|
||||
|
||||
delete command;
|
||||
delete copy_of_icommand;
|
||||
delete[] command;
|
||||
delete[] copy_of_icommand;
|
||||
|
||||
#else // NON WIN32 systems.
|
||||
|
||||
@ -266,7 +267,7 @@ void dobut(Fl_Widget *, long arg)
|
||||
sprintf(command, "./%s &", menus[men].icommand[bn]);
|
||||
system(command);
|
||||
|
||||
delete command;
|
||||
delete[] command;
|
||||
#endif // WIN32
|
||||
}
|
||||
}
|
||||
@ -336,7 +337,8 @@ int main(int argc, char **argv) {
|
||||
if (i < argc) fname = argv[i];
|
||||
|
||||
if (!load_the_menu(fname)) Fl::fatal("Can't open %s",fname);
|
||||
strcpy(buf,fname);
|
||||
if (buf!=fname)
|
||||
strcpy(buf,fname);
|
||||
const char *c = fl_filename_name(buf);
|
||||
if (c > buf) {buf[c-buf] = 0; chdir(buf);}
|
||||
push_menu("@main");
|
||||
|
@ -379,20 +379,26 @@ style_update(int pos, // I - Position of update
|
||||
end = textbuf->line_end(pos + nInserted);
|
||||
text = textbuf->text_range(start, end);
|
||||
style = stylebuf->text_range(start, end);
|
||||
last = style[end - start - 1];
|
||||
if (start==end)
|
||||
last = 0;
|
||||
else
|
||||
last = style[end - start - 1];
|
||||
|
||||
// printf("start = %d, end = %d, text = \"%s\", style = \"%s\"...\n",
|
||||
// start, end, text, style);
|
||||
// printf("start = %d, end = %d, text = \"%s\", style = \"%s\", last='%c'...\n",
|
||||
// start, end, text, style, last);
|
||||
|
||||
style_parse(text, style, end - start);
|
||||
|
||||
// printf("new style = \"%s\"...\n", style);
|
||||
// printf("new style = \"%s\", new last='%c'...\n",
|
||||
// style, style[end - start - 1]);
|
||||
|
||||
stylebuf->replace(start, end, style);
|
||||
((Fl_Text_Editor *)cbArg)->redisplay_range(start, end);
|
||||
|
||||
if (last != style[end - start - 1]) {
|
||||
// The last character on the line changed styles, so reparse the
|
||||
if (start==end || last != style[end - start - 1]) {
|
||||
// printf("Recalculate the rest of the buffer style\n");
|
||||
// Either the user deleted some text, or the last character
|
||||
// on the line changed styles, so reparse the
|
||||
// remainder of the buffer...
|
||||
free(text);
|
||||
free(style);
|
||||
|
Loading…
Reference in New Issue
Block a user