Skip to content

Commit

Permalink
Уходим от CAutoPtr (OpenMediaData).
Browse files Browse the repository at this point in the history
  • Loading branch information
v0lt committed Jul 3, 2022
1 parent 05d08e9 commit 9df1692
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
16 changes: 7 additions & 9 deletions src/apps/mplayerc/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3185,7 +3185,7 @@ LRESULT CMainFrame::OnGraphNotify(WPARAM wParam, LPARAM lParam)
case EC_DVD_DOMAIN_CHANGE:
if (m_pDVDC) {
m_iDVDDomain = (DVD_DOMAIN)evParam1;
OpenDVDData* pDVDData = dynamic_cast<OpenDVDData*>(m_lastOMD.m_p);
OpenDVDData* pDVDData = dynamic_cast<OpenDVDData*>(m_lastOMD.get());
ASSERT(pDVDData);

CString Domain('-');
Expand Down Expand Up @@ -3550,8 +3550,7 @@ LRESULT CMainFrame::OnResetDevice(WPARAM wParam, LPARAM lParam)

LRESULT CMainFrame::OnPostOpen(WPARAM wParam, LPARAM lParam)
{
CAutoPtr<OpenMediaData> pOMD;
pOMD.Attach((OpenMediaData*)wParam);
std::unique_ptr<OpenMediaData> pOMD((OpenMediaData*)wParam);

const auto& s = AfxGetAppSettings();

Expand All @@ -3568,7 +3567,7 @@ LRESULT CMainFrame::OnPostOpen(WPARAM wParam, LPARAM lParam)

if (m_closingmsg != aborted) {

if (OpenFileData *pFileData = dynamic_cast<OpenFileData*>(pOMD.m_p)) {
if (OpenFileData *pFileData = dynamic_cast<OpenFileData*>(pOMD.get())) {
m_wndPlaylistBar.SetCurValid(false);

if (GetAsyncKeyState(VK_ESCAPE)) {
Expand Down Expand Up @@ -4335,7 +4334,7 @@ void CMainFrame::OnUpdatePlayerStatus(CCmdUI* pCmdUI)
pCmdUI->SetText(UpdatePlayerStatus());
}

void CMainFrame::OnFilePostOpenMedia(CAutoPtr<OpenMediaData> pOMD)
void CMainFrame::OnFilePostOpenMedia(std::unique_ptr<OpenMediaData>& pOMD)
{
ASSERT(m_eMediaLoadState == MLS_LOADING);
SetLoadState(MLS_LOADED);
Expand All @@ -4347,8 +4346,7 @@ void CMainFrame::OnFilePostOpenMedia(CAutoPtr<OpenMediaData> pOMD)
}

// remember OpenMediaData for later use
m_lastOMD.Free();
m_lastOMD.Attach(pOMD.Detach());
m_lastOMD = std::move(pOMD);

if (m_bIsBDPlay == FALSE) {
m_BDPlaylists.clear();
Expand All @@ -4372,7 +4370,7 @@ void CMainFrame::OnFilePostOpenMedia(CAutoPtr<OpenMediaData> pOMD)

rs.bStereo3DSwapLR = s.bStereo3DSwapLR;

if (OpenDeviceData *pDeviceData = dynamic_cast<OpenDeviceData*>(m_lastOMD.m_p)) {
if (OpenDeviceData *pDeviceData = dynamic_cast<OpenDeviceData*>(m_lastOMD.get())) {
m_wndCaptureBar.m_capdlg.SetVideoInput(pDeviceData->vinput);
m_wndCaptureBar.m_capdlg.SetVideoChannel(pDeviceData->vchannel);
m_wndCaptureBar.m_capdlg.SetAudioInput(pDeviceData->ainput);
Expand Down Expand Up @@ -5943,7 +5941,7 @@ void CMainFrame::OnFileSaveAs()
if (SUCCEEDED(hr)) {
save_dlg.DoModal();
if (save_dlg.IsCompleteOk() && !m_youtubeFields.fname.IsEmpty()) {
const auto pFileData = dynamic_cast<OpenFileData*>(m_lastOMD.m_p);
const auto pFileData = dynamic_cast<OpenFileData*>(m_lastOMD.get());
if (pFileData && pFileData->fns.size() == 2) {
CString fileName(savedFileName);

Expand Down
4 changes: 2 additions & 2 deletions src/apps/mplayerc/MainFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ class CMainFrame : public CFrameWnd, public CDropTarget, public CDPI
BOOL m_bNextIsOpened = FALSE;

CString m_LastOpenFile;
CAutoPtr<OpenMediaData> m_lastOMD;
std::unique_ptr<OpenMediaData> m_lastOMD;

CString m_LastOpenBDPath, m_BDLabel;
HMONITOR m_LastWindow_HM;
Expand Down Expand Up @@ -1220,7 +1220,7 @@ class CMainFrame : public CFrameWnd, public CDropTarget, public CDPI

CString UpdatePlayerStatus();

void OnFilePostOpenMedia(CAutoPtr<OpenMediaData> pOMD);
void OnFilePostOpenMedia(std::unique_ptr<OpenMediaData>& pOMD);
void OnFilePostCloseMedia();

// Main Window
Expand Down

0 comments on commit 9df1692

Please sign in to comment.