diff options
author | Oz Linden <oz@lindenlab.com> | 2011-08-26 10:02:23 -0400 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2011-08-26 10:02:23 -0400 |
commit | 6f009080b9f8c9b5211288f6fe29cb326ac8bf23 (patch) | |
tree | 8d66118491b7f7e221737dc720c5d4fa468992ce /indra/newview/llappviewer.cpp | |
parent | 4057afd29161ad9cb69674ee608e48bc9e46a559 (diff) | |
parent | a4f132f1b88b151db1e834069bc6e9b49f9c5a17 (diff) |
merge changes for storm-1543
Diffstat (limited to 'indra/newview/llappviewer.cpp')
-rw-r--r-- | indra/newview/llappviewer.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index ea6859f0c6..6a808b5daf 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -322,6 +322,41 @@ static std::string gLaunchFileOnQuit; // Used on Win32 for other apps to identify our window (eg, win_setup) const char* const VIEWER_WINDOW_CLASSNAME = "Second Life"; +//-- LLDeferredTaskList ------------------------------------------------------ + +/** + * A list of deferred tasks. + * + * We sometimes need to defer execution of some code until the viewer gets idle, + * e.g. removing an inventory item from within notifyObservers() may not work out. + * + * Tasks added to this list will be executed in the next LLAppViewer::idle() iteration. + * All tasks are executed only once. + */ +class LLDeferredTaskList: public LLSingleton<LLDeferredTaskList> +{ + LOG_CLASS(LLDeferredTaskList); + + friend class LLAppViewer; + typedef boost::signals2::signal<void()> signal_t; + + void addTask(const signal_t::slot_type& cb) + { + mSignal.connect(cb); + } + + void run() + { + if (!mSignal.empty()) + { + mSignal(); + mSignal.disconnect_all_slots(); + } + } + + signal_t mSignal; +}; + //---------------------------------------------------------------------------- // List of entries from strings.xml to always replace @@ -3829,6 +3864,11 @@ bool LLAppViewer::initCache() } } +void LLAppViewer::addOnIdleCallback(const boost::function<void()>& cb) +{ + LLDeferredTaskList::instance().addTask(cb); +} + void LLAppViewer::purgeCache() { LL_INFOS("AppCache") << "Purging Cache and Texture Cache..." << LL_ENDL; @@ -4422,6 +4462,9 @@ void LLAppViewer::idle() gAudiop->idle(max_audio_decode_time); } } + + // Execute deferred tasks. + LLDeferredTaskList::instance().run(); // Handle shutdown process, for example, // wait for floaters to close, send quit message, |