TranslationTask weak_ptr fixup
@@ -65,7 +65,11 @@ static void Translate(translation_request_t const& request, boost::shared_ptr<Co
boost::shared_ptr<Moses::InputType> source(new Sentence(opts, 0, request.sourceSent));
boost::shared_ptr<Moses::IOWrapper> ioWrapperNone;
- Manager manager(TranslationTask::create(source, ioWrapperNone, scope));
+ boost::shared_ptr<TranslationTask> ttask = TranslationTask::create(source, ioWrapperNone, scope);
+
+ // note: ~Manager() must run while we still own TranslationTask (because it only has a weak_ptr)
+ {
+ Manager manager(ttask);
manager.Decode();
result.text = manager.GetBestTranslation();
@@ -74,6 +78,7 @@ static void Translate(translation_request_t const& request, boost::shared_ptr<Co
if (manager.GetSource().options()->nbest.nbest_size)
manager.OutputNBest(result.hypotheses);
}
+}
void
NativeTranslationRequest::
