]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlCommand.C
fix crash due to invalidated iterator
[lyx.git] / src / frontends / controllers / ControlCommand.C
index 5c632825c230719b6ed5281a0cd807133ef99943..0fa8df22f8f6c62e0e8c3ab2cb899d2d1428ecb0 100644 (file)
@@ -5,43 +5,52 @@
  *
  * \author Angus Leeming
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
 #include "ControlCommand.h"
-#include "Kernel.h"
 
 #include "funcrequest.h"
 #include "insets/insetcommand.h"
 
 
-ControlCommand::ControlCommand(Dialog & dialog, kb_action ac)
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+ControlCommand::ControlCommand(Dialog & dialog, string const & lfun_name)
        : Dialog::Controller(dialog),
-         action_(ac)
+         lfun_name_(lfun_name)
 {}
 
 
-void ControlCommand::initialiseParams(string const & data)
+bool ControlCommand::initialiseParams(string const & data)
 {
-       InsetCommandMailer::string2params(data, params_);
+       // The name passed with LFUN_INSET_APPLY is also the name
+       // used to identify the mailer.
+       InsetCommandMailer::string2params(lfun_name_, data, params_);
+       return true;
 }
 
 
 void ControlCommand::clearParams()
 {
-       params_.setCmdName(string());
-       params_.setOptions(string());
-       params_.setContents(string());
+       params_ = InsetCommandParams();
 }
 
 
 void ControlCommand::dispatchParams()
 {
-       if (action_ == LFUN_NOACTION)
+       if (lfun_name_.empty())
                return;
 
-       FuncRequest fr(action_, InsetCommandMailer::params2string(params_));
-       kernel().dispatch(fr);
+       string const lfun = InsetCommandMailer::params2string(lfun_name_,
+                                                             params_);
+       kernel().dispatch(FuncRequest(getLfun(), lfun));
 }
+
+} // namespace frontend
+} // namespace lyx