Add support for flushing messages from plugin to viewer.
Actually flush messages before terminating a plugin (upon the shutdown message) and flush messages in the file- and dirpicker before opening the blocking dialog. Flush debug messages too (deeper into the code, just prior to the actual blocking call). Also, fix the context folder map to be a thread-safe singleton and *attempt* to add support for default folders to windows and Mac. The latter might even not compile yet and definitely have to be tested (and fixed): Opening a DirPicker in preferences --> Network and Set the directory location of the cache. It should open a Dialog window where you are already in the folder that is the current cache directory setting (you can click Cancel after verifying that this worked). And, start to upload an image, select a file is some directory (other than what it starts in). You can omit the actual upload by clicking cancel in the preview. Then upload again and now it should start in the same folder as that you were just in. Possibly you need to first open a file picker elsewhere with a different context though, or windows might choose to open in the last folder anyway while the code doesn't really work. Uploading a sound before the second texture upload should do the trick.
This commit is contained in:
@@ -64,31 +64,41 @@ AIFilePicker::AIFilePicker(void) : mPluginManager(NULL), mCanceled(false)
|
||||
{
|
||||
}
|
||||
|
||||
// static
|
||||
AITHREADSAFESIMPLE(AIFilePicker::context_map_type, AIFilePicker::sContextMap, );
|
||||
|
||||
// static
|
||||
void AIFilePicker::store_folder(std::string const& context, std::string const& folder)
|
||||
{
|
||||
if (!folder.empty())
|
||||
{
|
||||
mContextMap[context] = folder;
|
||||
LL_DEBUGS("Plugin") << "AIFilePicker::mContextMap[\"" << context << "\"] = \"" << folder << '"' << LL_ENDL;
|
||||
AIAccess<context_map_type>(sContextMap)->operator[](context) = folder;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
std::string AIFilePicker::get_folder(std::string const& default_path, std::string const& context)
|
||||
{
|
||||
context_map_type::iterator iter = mContextMap.find(context);
|
||||
if (iter != mContextMap.end())
|
||||
AIAccess<context_map_type> wContextMap(sContextMap);
|
||||
context_map_type::iterator iter = wContextMap->find(context);
|
||||
if (iter != wContextMap->end())
|
||||
{
|
||||
return iter->second;
|
||||
}
|
||||
else if (!default_path.empty())
|
||||
{
|
||||
LL_DEBUGS("Plugin") << "context \"" << context << "\" not found. Returning default_path \"" << default_path << "\"." << LL_ENDL;
|
||||
return default_path;
|
||||
}
|
||||
else if ((iter = mContextMap.find("savefile")) != mContextMap.end())
|
||||
else if ((iter = wContextMap->find("savefile")) != wContextMap->end())
|
||||
{
|
||||
LL_DEBUGS("Plugin") << "context \"" << context << "\" not found and default_path empty. Returning context \"savefile\": \"" << iter->second << "\"." << LL_ENDL;
|
||||
return iter->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_DEBUGS("Plugin") << "context \"" << context << "\" not found, default_path empty and context \"savefile\" not found. Returning \"$HOME\"." << LL_ENDL;
|
||||
// This is the last resort when all else failed. Open the file chooser in directory 'home'.
|
||||
char const* home = NULL;
|
||||
#if LL_WINDOWS
|
||||
@@ -103,7 +113,7 @@ std::string AIFilePicker::get_folder(std::string const& default_path, std::strin
|
||||
void AIFilePicker::open(ELoadFilter filter, std::string const& default_path, std::string const& context, bool multiple)
|
||||
{
|
||||
mContext = context;
|
||||
mFolder = get_folder(default_path, context);
|
||||
mFolder = AIFilePicker::get_folder(default_path, context);
|
||||
mOpenType = multiple ? load_multiple : load;
|
||||
switch(filter)
|
||||
{
|
||||
@@ -152,7 +162,7 @@ void AIFilePicker::open(std::string const& filename, ESaveFilter filter, std::st
|
||||
{
|
||||
mFilename = filename;
|
||||
mContext = context;
|
||||
mFolder = get_folder(default_path, context);
|
||||
mFolder = AIFilePicker::get_folder(default_path, context);
|
||||
mOpenType = save;
|
||||
switch(filter)
|
||||
{
|
||||
@@ -372,7 +382,7 @@ void AIFilePicker::multiplex_impl(void)
|
||||
case AIFilePicker_done:
|
||||
{
|
||||
// Store folder of first filename as context.
|
||||
store_folder(mContext, getFolder());
|
||||
AIFilePicker::store_folder(mContext, getFolder());
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,9 +176,8 @@ public:
|
||||
|
||||
private:
|
||||
LLPointer<LLViewerPluginManager> mPluginManager; //!< Pointer to the plugin manager.
|
||||
// AIFIXME: this should be a separate, thread-safe singleton.
|
||||
typedef std::map<std::string, std::string> context_map_type; //!< Type of mContextMap.
|
||||
context_map_type mContextMap; //!< Map context (ie, "snapshot" or "image") to last used folder.
|
||||
static AIThreadSafeSimple<context_map_type> sContextMap; //!< Map context (ie, "snapshot" or "image") to last used folder.
|
||||
std::string mContext; //!< Some key to indicate the context (remembers the folder per key).
|
||||
|
||||
// Input variables (cache variable between call to open and run).
|
||||
@@ -191,9 +190,9 @@ private:
|
||||
std::vector<std::string> mFilenames; //!< Filesnames.
|
||||
|
||||
// Store a folder for the given context.
|
||||
void store_folder(std::string const& context, std::string const& folder);
|
||||
static void store_folder(std::string const& context, std::string const& folder);
|
||||
// Return the last folder stored for 'context', or default_path if none, or context "savefile" if empty, or $HOME if none.
|
||||
std::string get_folder(std::string const& default_path, std::string const& context);
|
||||
static std::string get_folder(std::string const& default_path, std::string const& context);
|
||||
|
||||
protected:
|
||||
// Call finish() (or abort()), not delete.
|
||||
|
||||
Reference in New Issue
Block a user