OSDN Git Service

Fix an assertion failure when generating Folder Compare Report with "Copy to Clipboar...
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Mon, 10 Jun 2019 13:33:40 +0000 (22:33 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Mon, 10 Jun 2019 13:33:40 +0000 (22:33 +0900)
Src/DirCmpReport.cpp
Src/DirCmpReport.h
Src/DirDoc.cpp

index 9918738..e5923ca 100644 (file)
@@ -150,8 +150,7 @@ bool DirCmpReport::GenerateReport(String &errStr)
        assert(m_pList != nullptr);
        assert(m_pFile == nullptr);
        bool bRet = false;
-
-       if (!m_sReportFile.empty()) try
+       try
        {
                if (m_bCopyToClipboard)
                {
@@ -161,6 +160,8 @@ bool DirCmpReport::GenerateReport(String &errStr)
                                return false;
                        CSharedFile file(GMEM_DDESHARE|GMEM_MOVEABLE|GMEM_ZEROINIT);
                        m_pFile = &file;
+                       bool savedIncludeFileCmpReport = m_bIncludeFileCmpReport;
+                       m_bIncludeFileCmpReport = false;
                        GenerateReport(m_nReportType);
                        HGLOBAL hMem = file.Detach();
                        SetClipboardData(CF_UNICODETEXT, ConvertToUTF16ForClipboard(hMem, m_bOutputUTF8 ? CP_UTF8 : CP_THREAD_ACP));
@@ -198,6 +199,7 @@ bool DirCmpReport::GenerateReport(String &errStr)
                                SetClipboardData(CF_HTML, GlobalReAlloc(file.Detach(), size, 0));
                        }
                        CloseClipboard();
+                       m_bIncludeFileCmpReport = savedIncludeFileCmpReport;
                }
                if (!m_sReportFile.empty())
                {
@@ -538,8 +540,6 @@ void DirCmpReport::GenerateXmlHtmlContent(bool xml)
        }
        if (!xml)
                WriteString(_T("</table>\n"));
-       if (m_myStruct)
-               m_myStruct->context->m_pCompareStats->SetCompareState(CompareStats::STATE_IDLE);
 }
 
 /**
index f28970f..ae208f3 100644 (file)
@@ -40,11 +40,15 @@ public:
        void SetList(IListCtrl *pList);
        void SetRootPaths(const PathContext &paths);
        void SetReportType(REPORT_TYPE nReportType) { m_nReportType = nReportType;  }
+       REPORT_TYPE GetReportType() const { return m_nReportType;  }
        void SetReportFile(const String& sReportFile) { m_sReportFile = sReportFile; }
+       String GetReportFile() const { return m_sReportFile; }
        void SetColumns(int columns);
        void SetFileCmpReport(IFileCmpReport *pFileCmpReport);
        void SetCopyToClipboard(bool bCopyToClipbard) { m_bCopyToClipboard = bCopyToClipbard;  }
+       bool GetCopyToClipboard() const { return m_bCopyToClipboard;  }
        void SetIncludeFileCmpReport(bool bIncludeFileCmpReport) { m_bIncludeFileCmpReport = bIncludeFileCmpReport; }
+       bool GetIncludeFileCmpReport() const { return m_bIncludeFileCmpReport; }
        void SetDiffFuncStruct(DiffFuncStruct* myStruct) { m_myStruct = myStruct; }
        bool GenerateReport(String &errStr);
 
index 56f87bc..613d410 100644 (file)
@@ -297,8 +297,17 @@ void CDirDoc::Rescan()
        if (m_bGeneratingReport)
        {
                m_diffThread.SetCollectFunction([&](DiffFuncStruct* myStruct) {
+                       int m = 0;
+                       if (m_pReport->GetCopyToClipboard())
+                       {
+                               ++m;
+                               if (m_pReport->GetReportType() == REPORT_TYPE_SIMPLEHTML)
+                                       ++m;
+                       }
+                       if (!m_pReport->GetReportFile().empty())
+                               ++m;
                        myStruct->context->m_pCompareStats->IncreaseTotalItems(
-                               m_pDirView->GetListCtrl().GetItemCount() - (myStruct->context->m_bRecursive ? 0 : 1));
+                               (m_pDirView->GetListCtrl().GetItemCount() - (myStruct->context->m_bRecursive ? 0 : 1)) * m);
                });
                m_diffThread.SetCompareFunction([&](DiffFuncStruct* myStruct) {
                        m_pReport->SetDiffFuncStruct(myStruct);