Hi!

I've noticed that the parent window for the "CProgressDlg" [1] may be set
incorrectly when using the Blame command.

The "Blame" [2] class is used in the following cases:
1. The "Blame..." command in the Windows Explorer context menu.
2. The "Blame..." command in the "Log Messages" dialog context menu.
3. The "Blame..." command in the "Repository Browser" dialog context menu.

In all these cases, the "Blame" class uses GetExplorerHwnd() [3] as the 
parent
window for the progress dialog. This is incorrect for cases 2 and 3, because
the parent windows are the dialogs.

For comparison, the "Show changes" command behaves correctly:
1. It uses GetExplorerHwnd() [4] in the case of the Windows Explorer context
menu.
2. It uses the dialog's m_hWnd [5] in the case of the "Log Messages" context
menu.

For example, this causes some problems with disabling the parent
window, when TortoiseProc.exe is called with the /hwnd parameter.

Here is a patch in attachments.

[1] 
https://sourceforge.net/p/tortoisesvn/code/29768/tree/trunk/src/Utils/MiscUI/ProgressDlg.h#l30
[2] 
https://sourceforge.net/p/tortoisesvn/code/29768/tree/trunk/src/TortoiseProc/Blame.h#l32
[3] 
https://sourceforge.net/p/tortoisesvn/code/29768/tree/trunk/src/TortoiseProc/Blame.cpp#l217
[4] 
https://sourceforge.net/p/tortoisesvn/code/29768/tree/trunk/src/TortoiseProc/Commands/DiffCommand.cpp#l36
[5] 
https://sourceforge.net/p/tortoisesvn/code/29768/tree/trunk/src/TortoiseProc/LogDialog/LogDlg.cpp#l3000

-- 
You received this message because you are subscribed to the Google Groups 
"TortoiseSVN-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/tortoisesvn-dev/160955c6-4328-4759-991e-8d01cdba6526n%40googlegroups.com.
Blame: fix incorrect parent windows for the progress dialog

Previously, Blame always used GetExplorerHwnd() [1] as the parent window for
the progress dialog. This is incorrect when Blame is invoked from the
"Log Messages" or "Repository Browser" dialogs, where the dialogs themselves
should be the parent windows.

[1] 
https://sourceforge.net/p/tortoisesvn/code/29768/tree/trunk/src/TortoiseProc/Blame.cpp#l217

Index: src/TortoiseProc/Blame.cpp
===================================================================
--- src/TortoiseProc/Blame.cpp  (revision 29768)
+++ src/TortoiseProc/Blame.cpp  (working copy)
@@ -181,7 +181,8 @@
     return m_bCancelled;
 }
 
-CString CBlame::BlameToTempFile(const CTSVNPath& path, const SVNRev& startRev, 
const SVNRev& endRev, SVNRev pegRev,
+CString CBlame::BlameToTempFile(HWND hParent,
+                                const CTSVNPath& path, const SVNRev& startRev, 
const SVNRev& endRev, SVNRev pegRev,
                                 const CString& options, BOOL includeMerge,
                                 BOOL showProgress, BOOL ignoreMimeType)
 {
@@ -214,7 +215,7 @@
     m_progressDlg.SetShowProgressBar(TRUE);
     if (showProgress)
     {
-        m_progressDlg.ShowModeless(CWnd::FromHandle(GetExplorerHWND()));
+        m_progressDlg.ShowModeless(CWnd::FromHandle(hParent));
     }
     m_progressDlg.FormatNonPathLine(1, IDS_BLAME_PROGRESSINFO);
     m_progressDlg.FormatNonPathLine(2, IDS_BLAME_PROGRESSINFOSTART);
Index: src/TortoiseProc/Blame.h
===================================================================
--- src/TortoiseProc/Blame.h    (revision 29768)
+++ src/TortoiseProc/Blame.h    (working copy)
@@ -49,7 +49,7 @@
      * \param path the path to the file to determine the required information
      * \return The path to the temporary file or an empty string in case of an 
error.
      */
-    CString BlameToTempFile(const CTSVNPath& path, const SVNRev& startRev, 
const SVNRev& endRev, SVNRev pegRev, const CString& options, BOOL includeMerge, 
BOOL showProgress, BOOL ignoreMimeType);
+    CString BlameToTempFile(HWND hParent, const CTSVNPath& path, const SVNRev& 
startRev, const SVNRev& endRev, SVNRev pegRev, const CString& options, BOOL 
includeMerge, BOOL showProgress, BOOL ignoreMimeType);
 
     bool BlameToFile(const CTSVNPath& path, const SVNRev& startRev, const 
SVNRev& endRev, SVNRev peg, const CTSVNPath& toFile, const CString& options, 
BOOL ignoreMimeType, BOOL includeMerge);
     void SetAndClearProgressInfo(CProgressDlg* pProgressDlg, int infoLine, 
bool bShowProgressBar = false)
Index: src/TortoiseProc/Commands/BlameCommand.cpp
===================================================================
--- src/TortoiseProc/Commands/BlameCommand.cpp  (revision 29768)
+++ src/TortoiseProc/Commands/BlameCommand.cpp  (working copy)
@@ -70,7 +70,8 @@
             if (bShowDialog)
                 options = SVN::GetOptionsString(!!dlg.m_bIgnoreEOL, 
dlg.m_ignoreSpaces);
 
-            tempFile = blame.BlameToTempFile(cmdLinePath, dlg.m_startRev, 
dlg.m_endRev,
+            tempFile = blame.BlameToTempFile(GetExplorerHWND(),
+                                             cmdLinePath, dlg.m_startRev, 
dlg.m_endRev,
                                              cmdLinePath.IsUrl() ? SVNRev() : 
SVNRev::REV_WC,
                                              options, dlg.m_bIncludeMerge, 
TRUE, TRUE);
             if (tempFile.IsEmpty())
Index: src/TortoiseProc/LogDialog/LogDlg.cpp
===================================================================
--- src/TortoiseProc/LogDialog/LogDlg.cpp       (revision 29768)
+++ src/TortoiseProc/LogDialog/LogDlg.cpp       (working copy)
@@ -6223,8 +6223,9 @@
             OnOutOfScope(this->EnableWindow(TRUE); this->SetFocus());
 
             CBlame  blame;
-            CString tempFile = blame.BlameToTempFile(m_path, startRev, endRev, 
m_pegRev,
-                                                                   options, 
includeMerge, TRUE, TRUE);
+            CString tempFile = blame.BlameToTempFile(m_hWnd,
+                                                     m_path, startRev, endRev, 
m_pegRev,
+                                                     options, includeMerge, 
TRUE, TRUE);
             if (!tempFile.IsEmpty())
             {
                 if (textViewer)
@@ -7878,8 +7879,9 @@
             this->EnableWindow(FALSE);
             OnOutOfScope(this->EnableWindow(TRUE); this->SetFocus());
             CBlame  blame;
-            CString tempFile = blame.BlameToTempFile(CTSVNPath(pCmi->fileUrl), 
startRev,
-                                                                   endRev, 
pegRev, options, includeMerge, TRUE, TRUE);
+            CString tempFile = blame.BlameToTempFile(m_hWnd,
+                                                     CTSVNPath(pCmi->fileUrl), 
startRev,
+                                                     endRev, pegRev, options, 
includeMerge, TRUE, TRUE);
             if (!tempFile.IsEmpty())
             {
                 if (textView)
Index: src/TortoiseProc/RepositoryBrowser.cpp
===================================================================
--- src/TortoiseProc/RepositoryBrowser.cpp      (revision 29768)
+++ src/TortoiseProc/RepositoryBrowser.cpp      (working copy)
@@ -4292,7 +4292,7 @@
                     CString          tempfile;
                     const CTSVNPath& path = selection.GetURLEscaped(0, 0);
 
-                    tempfile = blame.BlameToTempFile(path, dlg.m_startRev, 
dlg.m_endRev, dlg.m_pegRev, SVN::GetOptionsString(!!dlg.m_bIgnoreEOL, 
dlg.m_ignoreSpaces), dlg.m_bIncludeMerge, TRUE, TRUE);
+                    tempfile = blame.BlameToTempFile(m_hWnd, path, 
dlg.m_startRev, dlg.m_endRev, dlg.m_pegRev, 
SVN::GetOptionsString(!!dlg.m_bIgnoreEOL, dlg.m_ignoreSpaces), 
dlg.m_bIncludeMerge, TRUE, TRUE);
                     if (!tempfile.IsEmpty())
                     {
                         if (dlg.m_bTextView)

Reply via email to