Trace/Debug

* Disable text widget update if respective dialog not visible
  * Clear Fl_Text_Display buffer when buffer length exceeds 100000
    This will prevent excessive use of memory and possibility of
    segmentation fault caused by the text display widget.
This commit is contained in:
David Freese 2020-12-13 07:48:29 -06:00
parent 690e74bde6
commit 6379d97fe4
3 changed files with 14 additions and 10 deletions

View file

@ -300,19 +300,13 @@ void startup(void*)
if (EXPAND_CONTROLS && selrig->has_extras) return;
btn_show_controls->label("@-22->");
btn_show_controls->redraw_label();
// grpTABS->hide();
// mainwindow->resizable(grpTABS);
// int nuH = mainwindow->h();// - grpTABS->h();
// mainwindow->size(progStatus.mainW, nuH);//WIDE_MAINH);
// mainwindow->size_range(735, nuH, 0, 0);//nuH);
mainwindow->redraw();
}
case small_ui :
default :
// if (EXPAND_CONTROLS && selrig->has_extras)
// show_controls();
break;
break;
}
start_server(xmlport);
}
void rotate_log(std::string filename)
@ -468,7 +462,7 @@ extern FILE *serlog;
exit(EXIT_FAILURE);
}
start_server(xmlport);
// start_server(xmlport);
if (start_cwio_thread() != 0)
return 1;
@ -539,7 +533,7 @@ extern FILE *serlog;
btn_show_controls->redraw_label();
}
Fl::add_timeout(0.5, startup);
Fl::add_timeout(0, startup);//0.5, startup);
return Fl::run();

View file

@ -186,6 +186,9 @@ void debug::show(void)
void debug::sync_text(void* arg)
{
if (!window->visible())
return;
guard_lock dlock(&debug_mutex);
if (inst == 0 || btext == 0) return;

View file

@ -73,6 +73,7 @@ static void make_trace_window() {
tracebuffer = new Fl_Text_Buffer;
tracedisplay->buffer(tracebuffer);
tracedisplay->textfont(FL_SCREEN);
tracedisplay->wrap_mode(Fl_Text_Display::WRAP_NONE, 100);
btn_cleartrace = new Fl_Button(515, 275, 80, 20, _("Clear"));
btn_cleartrace->callback((Fl_Callback *)cb_cleartrace);
tracewindow->resizable(tracedisplay);
@ -80,7 +81,13 @@ static void make_trace_window() {
static void update_tracetext(void *)
{
if (!tracewindow->visible()) {
tracestrings.clear();
return;
}
guard_lock tt(&mutex_trace);
if (tracedisplay->buffer()->length() > 100000)
tracedisplay->buffer()->text("");
for (size_t n = 0; n < tracestrings.size(); n++)
tracedisplay->insert(tracestrings[n].c_str());
tracestrings.clear();