fix crash bug when stopping scene #10
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "Cursor.h"
|
||||
#include "Debug.h"
|
||||
#include "MonitorManager.h"
|
||||
#include "Monitor.h"
|
||||
#include "Duplicator.h"
|
||||
|
||||
@@ -32,11 +31,6 @@ void Cursor::UpdateBuffer(Duplicator* duplicator)
|
||||
}
|
||||
|
||||
isVisible_ = frameInfo.PointerPosition.Visible != 0;
|
||||
if (isVisible_)
|
||||
{
|
||||
GetMonitorManager()->SetCursorMonitorId(monitor->GetId());
|
||||
}
|
||||
|
||||
x_ = frameInfo.PointerPosition.Position.x;
|
||||
y_ = frameInfo.PointerPosition.Position.y;
|
||||
timestamp_ = frameInfo.LastMouseUpdateTime;
|
||||
|
||||
@@ -307,16 +307,7 @@ bool Duplicator::Duplicate()
|
||||
}
|
||||
|
||||
UpdateMetadata();
|
||||
|
||||
if (frameInfo.PointerPosition.Visible)
|
||||
{
|
||||
GetMonitorManager()->SetCursorMonitorId(monitor_->GetId());
|
||||
}
|
||||
|
||||
if (GetMonitorManager()->GetCursorMonitorId() == monitor_->GetId())
|
||||
{
|
||||
UpdateCursor();
|
||||
}
|
||||
UpdateCursor();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -324,9 +315,20 @@ bool Duplicator::Duplicate()
|
||||
|
||||
void Duplicator::UpdateCursor()
|
||||
{
|
||||
auto cursor = GetMonitorManager()->GetCursor();
|
||||
cursor->UpdateBuffer(this);
|
||||
cursor->Draw(this);
|
||||
auto& manager = GetMonitorManager();
|
||||
if (!manager) return;
|
||||
|
||||
if (lastFrame_.info.PointerPosition.Visible)
|
||||
{
|
||||
manager->SetCursorMonitorId(monitor_->GetId());
|
||||
}
|
||||
|
||||
if (monitor_->GetId() == manager->GetCursorMonitorId())
|
||||
{
|
||||
auto cursor = GetMonitorManager()->GetCursor();
|
||||
cursor->UpdateBuffer(this);
|
||||
cursor->Draw(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ Monitor::Monitor(int id)
|
||||
|
||||
Monitor::~Monitor()
|
||||
{
|
||||
duplicator_->Stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +66,12 @@ void Monitor::Initialize(
|
||||
}
|
||||
|
||||
|
||||
void Monitor::Finalize()
|
||||
{
|
||||
duplicator_->Stop();
|
||||
}
|
||||
|
||||
|
||||
void Monitor::Render()
|
||||
{
|
||||
const auto& frame = duplicator_->GetFrame();
|
||||
|
||||
@@ -22,6 +22,7 @@ public:
|
||||
void Initialize(
|
||||
const Microsoft::WRL::ComPtr<struct IDXGIAdapter> &adapter,
|
||||
const Microsoft::WRL::ComPtr<struct IDXGIOutput> &output);
|
||||
void Finalize();
|
||||
void Render();
|
||||
|
||||
public:
|
||||
|
||||
@@ -63,6 +63,11 @@ void MonitorManager::Initialize()
|
||||
|
||||
void MonitorManager::Finalize()
|
||||
{
|
||||
for (const auto& monitor : monitors_)
|
||||
{
|
||||
monitor->Finalize();
|
||||
}
|
||||
|
||||
monitors_.clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user