diff --git a/tools/oven/src/BakerCLI.cpp b/tools/oven/src/BakerCLI.cpp index b76e00269f..7bdd221514 100644 --- a/tools/oven/src/BakerCLI.cpp +++ b/tools/oven/src/BakerCLI.cpp @@ -40,30 +40,25 @@ void BakerCLI::bakeFile(QUrl inputUrl, const QString outputPath) { } // create our appropiate baker - Baker* baker; - if (isFBX) { - baker = new FBXBaker(inputUrl, outputPath, []() -> QThread* { - return qApp->getNextWorkerThread(); - }); - baker->moveToThread(qApp->getFBXBakerThread()); + _baker = std::unique_ptr { new FBXBaker(inputUrl, outputPath, []() -> QThread* { return qApp->getNextWorkerThread(); }) }; + _baker->moveToThread(qApp->getFBXBakerThread()); } else if (isSupportedImage) { - baker = new TextureBaker(inputUrl, image::TextureUsage::CUBE_TEXTURE, outputPath); - baker->moveToThread(qApp->getNextWorkerThread()); + _baker = std::unique_ptr { new TextureBaker(inputUrl, image::TextureUsage::CUBE_TEXTURE, outputPath) }; + _baker->moveToThread(qApp->getNextWorkerThread()); } else { qCDebug(model_baking) << "Failed to determine baker type for file" << inputUrl; return; } // invoke the bake method on the baker thread - QMetaObject::invokeMethod(baker, "bake"); + QMetaObject::invokeMethod(_baker.get(), "bake"); // make sure we hear about the results of this baker when it is done - connect(baker, &Baker::finished, this, &BakerCLI::handleFinishedBaker); + connect(_baker.get(), &Baker::finished, this, &BakerCLI::handleFinishedBaker); } void BakerCLI::handleFinishedBaker() { qCDebug(model_baking) << "Finished baking file."; - sender()->deleteLater(); QApplication::quit(); } \ No newline at end of file diff --git a/tools/oven/src/BakerCLI.h b/tools/oven/src/BakerCLI.h index 5935151bb5..cb2b908059 100644 --- a/tools/oven/src/BakerCLI.h +++ b/tools/oven/src/BakerCLI.h @@ -14,6 +14,7 @@ #include +#include "Baker.h" #include "Oven.h" class BakerCLI : public QObject { @@ -24,8 +25,10 @@ public: void bakeFile(QUrl inputUrl, const QString outputPath); private slots: - void handleFinishedBaker(); + void handleFinishedBaker(); +private: + std::unique_ptr _baker; }; #endif // hifi_BakerCLI_h \ No newline at end of file