Skip to content

Commit

Permalink
Добавлена проверка в put_Owner().
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksoid1978 committed Sep 10, 2024
1 parent 06097d7 commit 7235ba2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Source/VideoRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ HRESULT CMpcVideoRenderer::Init(const bool bCreateWindow/* = false*/)
// IVideoWindow
STDMETHODIMP CMpcVideoRenderer::put_Owner(OAHWND Owner)
{
if (m_hWndParent != (HWND)Owner) {
if (Owner && m_hWndParent != (HWND)Owner) {
m_hWndParent = (HWND)Owner;
return Init(true);
}
Expand Down

8 comments on commit 7235ba2

@v0lt
Copy link
Collaborator

@v0lt v0lt commented on 7235ba2 Sep 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В этом случае у нас игнорируется нулевой "OAHWND Owner" и ничего не произойдет.
https://learn.microsoft.com/en-us/windows/win32/api/control/nf-control-ivideowindow-put_owner

[in] Owner
A handle to the parent window, as an OAHWND value, or NULL to remove the existing parent.

Remarks
Reset the owner to NULL before releasing the Filter Graph Manager. Otherwise, messages will continue to be sent to this window and errors will likely occur when the application is terminated.

@Aleksoid1978
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А ничего и не надо делать.

@v0lt
Copy link
Collaborator

@v0lt v0lt commented on 7235ba2 Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ИМХО, m_hWndParent должен быть обнулен и мы должны перестать использовать указанное окно.

@Aleksoid1978
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну тогда надо просто останавливать все и уничтожать рендерер.

@v0lt
Copy link
Collaborator

@v0lt v0lt commented on 7235ba2 Sep 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

уничтожать рендерер.

Весь рендерер не надо :-)

@clsid2
Copy link
Contributor

@clsid2 clsid2 commented on 7235ba2 Sep 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to move nullptr check from put_Owner to CMpcVideoRenderer::Init and return early there.

			RemoveParentWndProc(m_hWndParentMain);
		}

-		m_hWndParentMain = hwnd;
+		if (hwnd == nullptr) {
+			ASSERT(m_filterState == State_Stopped);
+			return S_OK;
+		} else {
+			m_hWndParentMain = hwnd;
+		}

@Aleksoid1978
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

@clsid2
Copy link
Contributor

@clsid2 clsid2 commented on 7235ba2 Sep 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To stop using previous window handle

Please sign in to comment.