Skip to content

Commit 3f102e5

Browse files
committed
dnn: protobuf shutdown
1 parent aad6d28 commit 3f102e5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

modules/dnn/src/init.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
#include "precomp.hpp"
4343
#include <opencv2/dnn/layer.details.hpp>
4444

45+
#include <google/protobuf/stubs/common.h>
46+
4547
namespace cv {
4648
namespace dnn {
4749
CV__DNN_EXPERIMENTAL_NS_BEGIN
@@ -56,11 +58,26 @@ Mutex& getInitializationMutex()
5658
// force initialization (single-threaded environment)
5759
Mutex* __initialization_mutex_initializer = &getInitializationMutex();
5860

61+
namespace {
62+
using namespace google::protobuf;
63+
class ProtobufShutdown {
64+
public:
65+
bool initialized;
66+
ProtobufShutdown() : initialized(true) {}
67+
~ProtobufShutdown()
68+
{
69+
initialized = false;
70+
google::protobuf::ShutdownProtobufLibrary();
71+
}
72+
};
73+
} // namespace
5974

6075
void initializeLayerFactory()
6176
{
6277
CV_TRACE_FUNCTION();
6378

79+
static ProtobufShutdown protobufShutdown; (void)protobufShutdown;
80+
6481
CV_DNN_REGISTER_LAYER_CLASS(Slice, SliceLayer);
6582
CV_DNN_REGISTER_LAYER_CLASS(Split, SplitLayer);
6683
CV_DNN_REGISTER_LAYER_CLASS(Concat, ConcatLayer);

0 commit comments

Comments
 (0)