Skip to content

Commit e36ef50

Browse files
committed
Fix hanging commandline tests.
1 parent 29f7914 commit e36ef50

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

SerialPrograms/Source/CommonFramework/Main.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,24 @@ void set_working_directory(){
5757
}
5858

5959

60+
class ScopeExit{
61+
ScopeExit(const ScopeExit&) = delete;
62+
void operator=(const ScopeExit&) = delete;
63+
64+
public:
65+
template <typename Lambda>
66+
ScopeExit(Lambda&& lambda)
67+
: m_lambda(std::move(lambda))
68+
{}
69+
~ScopeExit(){
70+
m_lambda();
71+
}
72+
73+
private:
74+
std::function<void()> m_lambda;
75+
};
76+
77+
6078
int run_program(int argc, char *argv[]){
6179
QApplication application(argc, argv);
6280

@@ -88,6 +106,7 @@ int run_program(int argc, char *argv[]){
88106
QDir().mkpath(QString::fromStdString(SCREENSHOTS_PATH()));
89107

90108
// Preload all the cameras now so we don't hang the UI later on.
109+
ScopeExit cameras([]{ GlobalMediaServices::instance().stop(); });
91110
get_all_cameras();
92111

93112
// Several novice developers struggled to build and run the program due to missing Resources folder.
@@ -163,11 +182,7 @@ int run_program(int argc, char *argv[]){
163182
w.raise(); // bring the window to front on macOS
164183
set_permissions(w);
165184

166-
int ret = application.exec();
167-
168-
GlobalMediaServices::instance().stop();
169-
170-
return ret;
185+
return application.exec();
171186
}
172187

173188

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,12 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
517517

518518

519519

520+
PokemonLA::EventDialogDetector detector(logger, overlay, true);
521+
522+
auto snapshot = feed.snapshot();
523+
detector.process_frame(snapshot, current_time());
524+
525+
520526
#if 0
521527
UpdateMenuWatcher update_menu(console, COLOR_PURPLE);
522528
CheckOnlineWatcher check_online(COLOR_CYAN);

0 commit comments

Comments
 (0)