mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-28 13:04:07 +08:00
修复程序退出时访问NoticeCenter单例可能崩溃的bug
This commit is contained in:
@@ -623,10 +623,11 @@ PythonInvoker::PythonInvoker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
_notice_center = NoticeCenter::Instance().shared_from_this();
|
||||||
}
|
}
|
||||||
|
|
||||||
PythonInvoker::~PythonInvoker() {
|
PythonInvoker::~PythonInvoker() {
|
||||||
NoticeCenter::Instance().delListener(this, Broadcast::kBroadcastReloadConfig);
|
_notice_center->delListener(this, Broadcast::kBroadcastReloadConfig);
|
||||||
{
|
{
|
||||||
py::gil_scoped_acquire gil; // 加锁
|
py::gil_scoped_acquire gil; // 加锁
|
||||||
if (_on_exit) {
|
if (_on_exit) {
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <pybind11/embed.h>
|
#include <pybind11/embed.h>
|
||||||
#include <pybind11/numpy.h>
|
#include <pybind11/numpy.h>
|
||||||
|
#include <pybind11/stl.h> // ⭐ 必须
|
||||||
|
#include <pybind11/functional.h> // ⭐ 必须
|
||||||
|
#include <pybind11/numpy.h>
|
||||||
#include "Util/logger.h"
|
#include "Util/logger.h"
|
||||||
#include "Common/config.h"
|
#include "Common/config.h"
|
||||||
#include "Common/MediaSource.h"
|
#include "Common/MediaSource.h"
|
||||||
@@ -46,6 +49,7 @@ private:
|
|||||||
PythonInvoker();
|
PythonInvoker();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
toolkit::NoticeCenter::Ptr _notice_center;
|
||||||
py::gil_scoped_release *_rel;
|
py::gil_scoped_release *_rel;
|
||||||
py::scoped_interpreter *_interpreter;
|
py::scoped_interpreter *_interpreter;
|
||||||
std::shared_ptr<toolkit::Logger> _logger;
|
std::shared_ptr<toolkit::Logger> _logger;
|
||||||
|
|||||||
Reference in New Issue
Block a user