summaryrefslogtreecommitdiff
path: root/indra/newview/llviewermedia.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewermedia.cpp')
-rw-r--r--indra/newview/llviewermedia.cpp75
1 files changed, 42 insertions, 33 deletions
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 75108b3ef0..4334cbfda3 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -55,6 +55,7 @@
#include "llversioninfo.h"
#include "llviewermediafocus.h"
#include "llviewercontrol.h"
+#include "llviewermenufile.h" // LLFilePickerThread
#include "llviewernetwork.h"
#include "llviewerparcelmedia.h"
#include "llviewerparcelmgr.h"
@@ -82,6 +83,43 @@
/*static*/ const char* LLViewerMedia::SHOW_MEDIA_OUTSIDE_PARCEL_SETTING = "MediaShowOutsideParcel";
+class LLMediaFilePicker : public LLFilePickerThread // deletes itself when done
+{
+public:
+ LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ELoadFilter filter, bool get_multiple)
+ : LLFilePickerThread(filter, get_multiple),
+ mPlugin(plugin->getSharedPrt())
+ {
+ }
+
+ LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ESaveFilter filter, const std::string &proposed_name)
+ : LLFilePickerThread(filter, proposed_name),
+ mPlugin(plugin->getSharedPrt())
+ {
+ }
+
+ virtual void notify(const std::vector<std::string>& filenames)
+ {
+ mPlugin->sendPickFileResponse(mResponses);
+ mPlugin = NULL;
+ }
+
+private:
+ boost::shared_ptr<LLPluginClassMedia> mPlugin;
+};
+
+void init_threaded_picker_load_dialog(LLPluginClassMedia* plugin, LLFilePicker::ELoadFilter filter, bool get_multiple)
+{
+ (new LLMediaFilePicker(plugin, filter, get_multiple))->getFile(); // will delete itself
+}
+
+void init_threaded_picker_save_dialog(LLPluginClassMedia* plugin, LLFilePicker::ESaveFilter filter, std::string &proposed_name)
+{
+ (new LLMediaFilePicker(plugin, filter, proposed_name))->getFile(); // will delete itself
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
// Move this to its own file.
LLViewerMediaEventEmitter::~LLViewerMediaEventEmitter()
@@ -1647,8 +1685,7 @@ void LLViewerMediaImpl::destroyMediaSource()
if(mMediaSource)
{
mMediaSource->setDeleteOK(true) ;
- delete mMediaSource;
- mMediaSource = NULL;
+ mMediaSource = NULL; // shared pointer
}
}
@@ -1840,7 +1877,7 @@ bool LLViewerMediaImpl::initializePlugin(const std::string& media_type)
media_source->clear_cache();
}
- mMediaSource = media_source;
+ mMediaSource.reset(media_source);
mMediaSource->setDeleteOK(false) ;
updateVolume();
@@ -3274,37 +3311,9 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla
case LLViewerMediaObserver::MEDIA_EVENT_PICK_FILE_REQUEST:
{
- LLFilePicker& picker = LLFilePicker::instance();
- std::vector<std::string> responses;
-
- bool pick_multiple_files = plugin->getIsMultipleFilePick();
- if (pick_multiple_files == false)
- {
- picker.getOpenFile(LLFilePicker::FFLOAD_ALL);
-
- std::string filename = picker.getFirstFile();
- responses.push_back(filename);
- }
- else
- {
- if (picker.getMultipleOpenFiles())
- {
- std::string filename = picker.getFirstFile();
-
- responses.push_back(filename);
-
- while (!filename.empty())
- {
- filename = picker.getNextFile();
+ LL_DEBUGS("Media") << "Media event - file pick requested." << LL_ENDL;
- if (!filename.empty())
- {
- responses.push_back(filename);
- }
- }
- }
- }
- plugin->sendPickFileResponse(responses);
+ init_threaded_picker_load_dialog(plugin, LLFilePicker::FFLOAD_ALL, plugin->getIsMultipleFilePick());
}
break;