Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CameraServer] destroy VideoListener first #7686

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ struct Instance {
wpi::DenseMap<CS_Source, SourcePublisher> m_publishers;
std::shared_ptr<nt::NetworkTable> m_publishTable{
nt::NetworkTableInstance::GetDefault().GetTable(kPublishName)};
cs::VideoListener m_videoListener;
std::vector<std::string> m_addresses;
int m_tableListener;
int m_nextPort{CameraServer::kBasePort};
std::vector<std::string> m_addresses;
// Listener callback will capture [this], so let's make sure the callback is
// removed before anything else is destroyed.
cs::VideoListener m_videoListener;
};

} // namespace
Expand Down
14 changes: 12 additions & 2 deletions cameraserver/src/test/native/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

int main() {
return 0;
#include <gtest/gtest.h>

#include "cameraserver/CameraServer.h"

TEST(CameraServerTest, Listener) {
cs::CvSource cvSource = frc::CameraServer::PutVideo("foobar", 320, 240);
}

int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
int ret = RUN_ALL_TESTS();
return ret;
}
Loading