Split plugin classes and derive AIFilePicker from BasicPluginBase (part 4).

Add back fixes that were in Singularity (in indra/media_plugins) but not
in imprudence.

Also:

Add "shutdown" plugin message and terminate file picker plugins cleanly.

The DSO (libbasic_plugin_filepicker.so) now tells the child process /
plugin loader (SLPlugin) to terminate (using the 'shutdown' message),
and AIFilePicker::finish_impl destroys the plugin object on the viewer
side when it's ... finished thus.

Also added a large comment that gives an overview of all classes
involved on the viewer side.

Additional fixes for filepicker.

Plugin refactor bug fix: mDeleteMe was uninitialized in AIPluginFilePicker.
This commit is contained in:
Aleric Inglewood
2011-05-06 16:29:43 +02:00
parent 16cd4c5c4b
commit c46c86ca4b
21 changed files with 129 additions and 55 deletions

View File

@@ -4031,7 +4031,7 @@ void LLViewerWindow::saveImageNumbered(LLPointer<LLImageFormatted> image)
void LLViewerWindow::saveImageNumbered_filepicker_callback(LLPointer<LLImageFormatted> image, std::string const& extension, AIFilePicker* filepicker, bool success)
{
llassert((bool)*filepicker == success);
if (success)
if (success && !filepicker->isCanceled())
{
// Copy the directory + file name
std::string filepath = filepicker->getFilename();
@@ -4041,7 +4041,7 @@ void LLViewerWindow::saveImageNumbered_filepicker_callback(LLPointer<LLImageForm
saveImageNumbered_continued(image, extension);
}
delete filepicker;
filepicker->deleteMe();
}
void LLViewerWindow::saveImageNumbered_continued(LLPointer<LLImageFormatted> image, std::string const& extension)

View File

@@ -314,7 +314,11 @@ void AIFilePicker::abort_impl(void)
void AIFilePicker::finish_impl(void)
{
mPluginManager = NULL; // This deletes the plugin, since mPluginManager is a LLPointer.
if (mPluginManager)
{
mPluginManager->destroyPlugin();
mPluginManager = NULL;
}
mFilter.clear(); // Check that open is called before calling run (again).
}

View File

@@ -67,6 +67,56 @@ enum ESaveFilter
FFSAVE_LSL
};
/*
AIFilePicker is an AIStateMachine, that has a LLViewerPluginManager (mPluginManager)
to manage a plugin that runs the actual filepicker in a separate process.
The relationship with the plugin is as follows:
new AIFilePicker
AIFilePicker::mPluginManager = new LLViewerPluginManager
LLPluginProcessParentOwner LLPluginMessagePipeOwner
| | LLPluginMessagePipeOwner::mOwner = LLPluginProcessParentOwner
| | LLPluginMessagePipeOwner::mMessagePipe = LLPluginMessagePipe
| | LLPluginMessagePipeOwner::receiveMessageRaw calls
v | LLPluginProcessParent::receiveMessageRaw
LLPluginClassBasic v
| LLPluginClassBasic::mPlugin = new LLPluginProcessParent ---> new LLPluginMessagePipe
| LLPluginProcessParent::mOwner = (LLPluginProcessParentOwner*)LLPluginClassBasic
| LLPluginProcessParent::sendMessage calls
| LLPluginMessagePipeOwner::writeMessageRaw calls
| mMessagePipe->LLPluginMessagePipe::addMessage
| LLPluginProcessParent::receiveMessageRaw calls
| LLPluginProcessParent::receiveMessage calls
| LLPluginProcessParentOwner::receivePluginMessage == AIPluginFilePicker::receivePluginMessage
|
| LLPluginClassBasic::sendMessage calls mPlugin->LLPluginProcessParent::sendMessage
|
v
LLViewerPluginManager::mPluginBase = new AIPluginFilePicker
AIPluginFilePicker::receivePluginMessage calls
AIFilePicker::receivePluginMessage
AIPluginFilePicker::mStateMachine = AIFilePicker
Where the entry point to send messages to the plugin is LLPluginClassBasic::sendMessage,
and the end point for messages received from the plugin is AIFilePicker::receivePluginMessage.
Termination happens by receiving the "canceled" or "done" message,
which sets the state to AIFilePicker_canceled or AIFilePicker_done
respectively, causing a call to AIStateMachine::finish(), which calls
AIFilePicker::finish_impl which destroys the plugin (mPluginBase)
and the plugin manager (mPluginManager).
AIStateMachine::finish() also calls the registered callback function,
which should call AIStateMachine::deleteMe(), causing the AIFilePicker
to be deleted.
*/
// A file picker state machine.
//
// Before calling run(), call open() to pass needed parameters.
@@ -151,7 +201,8 @@ public:
static std::string launcher_name(void) { return gDirUtilp->getLLPluginLauncher(); }
static char const* plugin_basename(void) { return "basic_plugin_filepicker"; }
/*virtual*/ void receivePluginMessage(LLPluginMessage const& message) { mStateMachine->receivePluginMessage(message); }
/*virtual*/ void receivePluginMessage(LLPluginMessage const& message) { mStateMachine->receivePluginMessage(message); }
/*virtual*/ void receivedShutdown(void) { /* Nothing -- we terminate on deletion (from AIStateMachine::mainloop) */ }
private:
AIFilePicker* mStateMachine;