diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-03-20 08:09:34 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-03-20 08:09:34 +0100 |
| commit | f5628aa66de0173f4fc145586a8c83e66e32f160 (patch) | |
| tree | 9378c61789b0ac3f85cd9ff5854540b02321ebce /src/Fl_System_Driver.cxx | |
| parent | 733ffed6308a63c5f7975bf2e5807b29faf2c77a (diff) | |
Fix issue #413: Commit 29d9e31 creates memory handling problem under macOS.
Diffstat (limited to 'src/Fl_System_Driver.cxx')
| -rw-r--r-- | src/Fl_System_Driver.cxx | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/Fl_System_Driver.cxx b/src/Fl_System_Driver.cxx index 45927ae2b..f207ed8b8 100644 --- a/src/Fl_System_Driver.cxx +++ b/src/Fl_System_Driver.cxx @@ -1,7 +1,7 @@ // // A base class for platform specific system calls. // -// Copyright 1998-2016 by Bill Spitzak and others. +// Copyright 1998-2022 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -22,6 +22,7 @@ #include "Fl_System_Driver.H" #include <FL/Fl.H> +#include "Fl_Timeout.h" #include <FL/Fl_File_Icon.H> #include <FL/fl_utf8.h> #include <stdlib.h> @@ -503,6 +504,43 @@ void Fl_System_Driver::gettime(time_t *sec, int *usec) { } /** + Execute platform independent parts of Fl::wait(double). + + Platform drivers \b MUST override this virtual method to do + their own stuff and call this base class method to run + the platform independent wait functions. + + Overriden methods will typically call this method early and perform + platform-specific operations after that in order to work with the + \p time_to_wait value possibly modified by this method. + However, some platform drivers may need to do extra stuff before + calling this method, for instance setting up a memory pool on macOS. + + \param[in] time_to_wait max time to wait + + \return new (max) time to wait after elapsing timeouts +*/ +double Fl_System_Driver::wait(double time_to_wait) { + + // delete all widgets that were listed during callbacks + Fl::do_widget_deletion(); + + Fl_Timeout::do_timeouts(); + Fl::run_checks(); + Fl::run_idle(); + + // the idle function may turn off idle, we can then wait, + // or it leaves Fl::idle active and we set time_to_wait to 0 + if (Fl::idle) { + time_to_wait = 0.0; + } else { + // limit time by next timer interval + time_to_wait = Fl_Timeout::time_to_wait(time_to_wait); + } + return time_to_wait; +} + +/** \} \endcond */ |
