AIFilePicker related bug fixes.

Bug fix in LLPreviewAnim::gotAssetForSave_continued: the if()
that tests if the result from the filepicker can be used was
accidently negated, mostly causing a crash when cancelling an
animation preview download (open animation, File -> Save Texture As..),
and canceling the save when a filename is picked.

The lifetime of AIFileUpload is actually till the very end
of the main(), causing it's member mPicker to be reused.
This leads to problems. When someone tries to open a file picker
for a file upload of the same time before the previous filepicker
called the callback function (ie, when two filepickers are
opened at the same time, or when the plugin crashes).
With this fix it is possible to open any number of file pickers.

Finally, for linux, LLFastTimers was using assembly with gives
rather random results on multicore machines. Since AIStateMachine
is using this for wait timing, it had a negative effect on
how well the file picker worked (the last message wasn't flushed
for several seconds).
This commit is contained in:
Aleric Inglewood
2011-06-21 02:49:34 +02:00
parent 839418991e
commit b852a77a79
5 changed files with 20 additions and 188 deletions

View File

@@ -400,7 +400,7 @@ void LLPreviewAnim::gotAssetForSave(LLVFS *vfs,
// static
void LLPreviewAnim::gotAssetForSave_continued(char* buffer, S32 size, AIFilePicker* filepicker)
{
if (!filepicker->hasFilename())
if (filepicker->hasFilename())
{
std::string filename = filepicker->getFilename();
std::ofstream export_file(filename.c_str(), std::ofstream::binary);

View File

@@ -154,16 +154,13 @@ std::string build_extensions_string(ELoadFilter filter)
}
class AIFileUpload {
protected:
AIFilePicker* mPicker;
public:
AIFileUpload(void) : mPicker(NULL) { }
virtual ~AIFileUpload() { llassert(!mPicker); if (mPicker) { mPicker->abort(); mPicker = NULL; } }
AIFileUpload(void) { }
virtual ~AIFileUpload() { }
public:
bool is_valid(std::string const& filename, ELoadFilter type);
void filepicker_callback(ELoadFilter type);
void filepicker_callback(ELoadFilter type, AIFilePicker* picker);
void start_filepicker(ELoadFilter type, char const* context);
protected:
@@ -179,21 +176,22 @@ void AIFileUpload::start_filepicker(ELoadFilter filter, char const* context)
// display();
}
llassert(!mPicker);
mPicker = AIFilePicker::create();
mPicker->open(filter, "", context);
mPicker->run(boost::bind(&AIFileUpload::filepicker_callback, this, filter));
AIFilePicker* picker = AIFilePicker::create();
picker->open(filter, "", context);
// Note that when the call back is called then we're still in the main loop of
// the viewer and therefore the AIFileUpload still exists, since that is only
// destructed at the end of main when exiting the viewer.
picker->run(boost::bind(&AIFileUpload::filepicker_callback, this, filter, picker));
}
void AIFileUpload::filepicker_callback(ELoadFilter type)
void AIFileUpload::filepicker_callback(ELoadFilter type, AIFilePicker* picker)
{
if (mPicker->hasFilename())
if (picker->hasFilename())
{
std::string filename = mPicker->getFilename();
std::string filename = picker->getFilename();
if (is_valid(filename, type))
handle_event(filename);
}
mPicker = NULL;
}
bool AIFileUpload::is_valid(std::string const& filename, ELoadFilter type)

View File

@@ -79,7 +79,7 @@ AITHREADSAFESIMPLE(U64, AIStateMachine::sMaxCount, );
void AIStateMachine::updateSettings(void)
{
Dout(dc::statemachine, "Initializing AIStateMachine::sMaxCount");
*AIAccess<U64>(sMaxCount) = LLFastTimer::countsPerSecond() * gSavedSettings.getU32("StateMachineMaxTime") / 1000;
*AIAccess<U64>(sMaxCount) = LLFastTimer::sClockResolution * gSavedSettings.getU32("StateMachineMaxTime") / 1000;
}
//----------------------------------------------------------------------------
@@ -319,7 +319,7 @@ void AIStateMachine::mainloop(void*)
if (total_clocks >= max_count)
{
#ifndef LL_RELEASE_FOR_DOWNLOAD
llwarns << "AIStateMachine::mainloop did run for " << (total_clocks * 1000 / LLFastTimer::countsPerSecond()) << " ms." << llendl;
llwarns << "AIStateMachine::mainloop did run for " << (total_clocks * 1000 / LLFastTimer::sClockResolution) << " ms." << llendl;
#endif
std::sort(active_statemachines.begin(), active_statemachines.end(), QueueElementComp());
break;