mirror of https://github.com/fltk/fltk
Adds some possible NULL references and small fixes
This commit is contained in:
parent
ccc21d381a
commit
96730f80cb
|
@ -187,7 +187,11 @@ Fl_Grid::Cell* Fl_Grid_Proxy::transient_widget(Fl_Widget *wi, int row, int col,
|
|||
int mw, mh;
|
||||
old_cell->minimum_size(&mw, &mh);
|
||||
new_cell->minimum_size(mw, mh);
|
||||
::free(old_cell);
|
||||
if (remove_old_cell) {
|
||||
remove_cell(old_cell->row(), old_cell->col());
|
||||
} else {
|
||||
delete old_cell;
|
||||
}
|
||||
}
|
||||
if (i == num_transient_) {
|
||||
transient_make_room_(num_transient_ + 1);
|
||||
|
@ -195,9 +199,6 @@ Fl_Grid::Cell* Fl_Grid_Proxy::transient_widget(Fl_Widget *wi, int row, int col,
|
|||
num_transient_++;
|
||||
}
|
||||
transient_[i].cell = new_cell;
|
||||
if (remove_old_cell) {
|
||||
remove_cell(old_cell->row(), old_cell->col());
|
||||
}
|
||||
return new_cell;
|
||||
}
|
||||
|
||||
|
@ -911,12 +912,12 @@ void grid_align_horizontal_cb(Fl_Choice* i, void* v) {
|
|||
Fl_Grid::Cell *cell = g->cell(current_widget->o);
|
||||
if (cell) {
|
||||
old_v = cell->align() & mask;
|
||||
}
|
||||
if (old_v != v) {
|
||||
cell->align((Fl_Grid_Align)(v | (cell->align() & ~mask)));
|
||||
g->need_layout(true);
|
||||
g->redraw();
|
||||
set_modflag(1);
|
||||
if (old_v != v) {
|
||||
cell->align((Fl_Grid_Align)(v | (cell->align() & ~mask)));
|
||||
g->need_layout(true);
|
||||
g->redraw();
|
||||
set_modflag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -946,12 +947,12 @@ void grid_align_vertical_cb(Fl_Choice* i, void* v) {
|
|||
Fl_Grid::Cell *cell = g->cell(current_widget->o);
|
||||
if (cell) {
|
||||
old_v = cell->align() & mask;
|
||||
}
|
||||
if (old_v != v) {
|
||||
cell->align((Fl_Grid_Align)(v | (cell->align() & ~mask)));
|
||||
g->need_layout(true);
|
||||
g->redraw();
|
||||
set_modflag(1);
|
||||
if (old_v != v) {
|
||||
cell->align((Fl_Grid_Align)(v | (cell->align() & ~mask)));
|
||||
g->need_layout(true);
|
||||
g->redraw();
|
||||
set_modflag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3659,9 +3659,9 @@ void Fl_Widget_Type::copy_properties() {
|
|||
if (!live_widget)
|
||||
return;
|
||||
|
||||
Fl_Font ff;
|
||||
int fs;
|
||||
Fl_Color fc;
|
||||
Fl_Font ff = 0;
|
||||
int fs = 0;
|
||||
Fl_Color fc = 0;
|
||||
textstuff(0, ff, fs, fc);
|
||||
|
||||
// copy all attributes common to all widget types
|
||||
|
|
|
@ -1243,7 +1243,8 @@ Fl_Type *add_new_widget_from_user(Fl_Type *inPrototype, Strategy strategy) {
|
|||
if (changed && t->is_a(ID_Menu_Item)) {
|
||||
Fl_Type * tt = t->parent;
|
||||
while (tt && !tt->is_a(ID_Menu_Manager_)) tt = tt->parent;
|
||||
((Fl_Menu_Manager_Type*)tt)->build_menu();
|
||||
if (tt)
|
||||
((Fl_Menu_Manager_Type*)tt)->build_menu();
|
||||
}
|
||||
}
|
||||
if (t->is_true_widget() && !t->is_a(ID_Window)) {
|
||||
|
|
|
@ -795,7 +795,7 @@ void Fd_Shell_Command_List::write(Fd_Project_Writer *out) {
|
|||
void Fd_Shell_Command_List::add(Fd_Shell_Command *cmd) {
|
||||
if (list_size == list_capacity) {
|
||||
list_capacity += 16;
|
||||
list = (Fd_Shell_Command**)::realloc(list, list_capacity * sizeof(Fd_Shell_Command**));
|
||||
list = (Fd_Shell_Command**)::realloc(list, list_capacity * sizeof(Fd_Shell_Command*));
|
||||
}
|
||||
list[list_size++] = cmd;
|
||||
}
|
||||
|
@ -809,7 +809,7 @@ void Fd_Shell_Command_List::add(Fd_Shell_Command *cmd) {
|
|||
void Fd_Shell_Command_List::insert(int index, Fd_Shell_Command *cmd) {
|
||||
if (list_size == list_capacity) {
|
||||
list_capacity += 16;
|
||||
list = (Fd_Shell_Command**)::realloc(list, list_capacity * sizeof(Fd_Shell_Command**));
|
||||
list = (Fd_Shell_Command**)::realloc(list, list_capacity * sizeof(Fd_Shell_Command*));
|
||||
}
|
||||
::memmove(list+index+1, list+index, (list_size-index)*sizeof(Fd_Shell_Command**));
|
||||
list_size++;
|
||||
|
|
|
@ -137,7 +137,8 @@ Fl_String &Fl_String::replace_(int at, int n_del, const char *ins, int n_ins) {
|
|||
::memmove(buffer_+at, ins, n_ins);
|
||||
}
|
||||
size_ = new_size;
|
||||
buffer_[size_] = 0;
|
||||
if (buffer_)
|
||||
buffer_[size_] = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -1406,11 +1406,11 @@ int Fl_Text_Buffer::insert_(int pos, const char *text, int insertedLength)
|
|||
/*
|
||||
Remove a string from the buffer.
|
||||
Unicode safe. Start and end must be at a character boundary.
|
||||
Start must be less than end.
|
||||
*/
|
||||
void Fl_Text_Buffer::remove_(int start, int end)
|
||||
{
|
||||
/* if the gap is not contiguous to the area to remove, move it there */
|
||||
|
||||
if (start >= end) return;
|
||||
if (mCanUndo) {
|
||||
if (mUndo->undoat == end && mUndo->undocut) {
|
||||
// continue to remove text at the same cursor position
|
||||
|
|
Loading…
Reference in New Issue