diff options
author | Monroe Linden <monroe@lindenlab.com> | 2010-08-09 17:40:17 -0700 |
---|---|---|
committer | Monroe Linden <monroe@lindenlab.com> | 2010-08-09 17:40:17 -0700 |
commit | 879d15903608b26f6b10f499d150bb72a65fa966 (patch) | |
tree | 1d2d718e288cef115064cec1dee3fcb7d02acc8d | |
parent | 235afd7836d74305292067cd6c29fe0192d6201d (diff) |
Limit the number of media browser windows the viewer will open at once.
The limit is controlled by the debug setting MediaBrowserWindowLimit.
When opening a new window would take us over the limit, the least recently opened window will be closed first.
-rw-r--r-- | indra/newview/app_settings/settings.xml | 11 | ||||
-rw-r--r-- | indra/newview/llfloatermediabrowser.cpp | 26 | ||||
-rw-r--r-- | indra/newview/llfloatermediabrowser.h | 1 |
3 files changed, 37 insertions, 1 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 4c52fb015f..3326319e2d 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -6425,6 +6425,17 @@ <key>Value</key> <real>1.0</real> </map> + <key>MediaBrowserWindowLimit</key> + <map> + <key>Comment</key> + <string>Maximum number of media brower windows that can be open at once (0 for no limit)</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>S32</string> + <key>Value</key> + <integer>5</integer> + </map> <key>MediaRollOffRate</key> <map> <key>Comment</key> diff --git a/indra/newview/llfloatermediabrowser.cpp b/indra/newview/llfloatermediabrowser.cpp index 268a0e0b93..2fc5bd72de 100644 --- a/indra/newview/llfloatermediabrowser.cpp +++ b/indra/newview/llfloatermediabrowser.cpp @@ -76,8 +76,32 @@ void LLFloaterMediaBrowser::create(const std::string &url, const std::string& ta tag = id.asString(); } - // TODO: Figure out whether we need to close an existing instance and/or warn the user about the number of instances they have open + S32 browser_window_limit = gSavedSettings.getS32("MediaBrowserWindowLimit"); + if(LLFloaterReg::findInstance("media_browser", tag) != NULL) + { + // There's already a media browser for this tag, so we won't be opening a new window. + } + else if(browser_window_limit != 0) + { + // showInstance will open a new window. Figure out how many media browsers are already open, + // and close the least recently opened one if this will put us over the limit. + + LLFloaterReg::const_instance_list_t &instances = LLFloaterReg::getFloaterList("media_browser"); + lldebugs << "total instance count is " << instances.size() << llendl; + + for(LLFloaterReg::const_instance_list_t::const_iterator iter = instances.begin(); iter != instances.end(); iter++) + { + lldebugs << " " << (*iter)->getKey() << llendl; + } + + if(instances.size() >= browser_window_limit) + { + // Destroy the least recently opened instance + (*instances.begin())->closeFloater(); + } + } + LLFloaterMediaBrowser *browser = dynamic_cast<LLFloaterMediaBrowser*> (LLFloaterReg::showInstance("media_browser", tag)); llassert(browser); if(browser) diff --git a/indra/newview/llfloatermediabrowser.h b/indra/newview/llfloatermediabrowser.h index 1645ed4613..4255d814c0 100644 --- a/indra/newview/llfloatermediabrowser.h +++ b/indra/newview/llfloatermediabrowser.h @@ -45,6 +45,7 @@ class LLFloaterMediaBrowser : public LLViewerMediaObserver { public: + LOG_CLASS(LLFloaterMediaBrowser); LLFloaterMediaBrowser(const LLSD& key); static void create(const std::string &url, const std::string& target); |