OSDN Git Service

Attempt to fix the issue #100 (bitbucket)
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Mon, 16 Jul 2018 07:22:38 +0000 (16:22 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Mon, 16 Jul 2018 07:22:38 +0000 (16:22 +0900)
Src/HexMergeView.cpp
Src/HexMergeView.h
Src/ImgMergeFrm.cpp
Src/ImgMergeFrm.h
Src/MainFrm.cpp
Src/Test.cpp
Testing/selftests/.gitattributes [new file with mode: 0644]
Translations/WinMerge/English.pot

index 2c343a2..08f0486 100644 (file)
@@ -117,9 +117,9 @@ void CHexMergeView::OnDraw(CDC *)
 }
 
 /**
- * @brief Load heksedit.dll and setup window class name
+ * @brief returns true if heksedit.dll is loadable
  */
-BOOL CHexMergeView::PreCreateWindow(CREATESTRUCT& cs)
+bool CHexMergeView::IsLoadable()
 {
        static void *pv = NULL;
        if (pv == NULL)
@@ -129,10 +129,18 @@ BOOL CHexMergeView::PreCreateWindow(CREATESTRUCT& cs)
                if (FAILED(::CoGetClassObject(clsid, CLSCTX_INPROC_SERVER, NULL, IID_IUnknown, &pv)))
                {
                        pv = LoadLibrary(_T("Frhed\\hekseditU.dll"));
-                       if (!pv)
-                               LangMessageBox(IDS_FRHED_NOTINSTALLED, MB_OK);
                }
        }
+       return pv != nullptr;
+}
+
+/**
+ * @brief Load heksedit.dll and setup window class name
+ */
+BOOL CHexMergeView::PreCreateWindow(CREATESTRUCT& cs)
+{
+       if (!IsLoadable())
+               LangMessageBox(IDS_FRHED_NOTINSTALLED, MB_OK);
        cs.lpszClass = _T("heksedit");
        cs.style |= WS_HSCROLL | WS_VSCROLL;
        return TRUE;
index 0d17a7a..41c128a 100644 (file)
@@ -59,6 +59,7 @@ public:
        void ZoomText(int amount);
        static void CopySel(const CHexMergeView *src, CHexMergeView *dst);
        static void CopyAll(const CHexMergeView *src, CHexMergeView *dst);
+       static bool IsLoadable();
        // Overrides
 protected:
        virtual void OnDraw(CDC*);
index 6124bf7..6cb993b 100644 (file)
@@ -175,7 +175,7 @@ CImgMergeFrame::~CImgMergeFrame()
                m_pDirDoc = NULL;
        }
 
-       HMODULE hModule = GetModuleHandle(_T("WinIMergeLib.dll"));
+       HMODULE hModule = GetModuleHandleW(L"WinIMergeLib.dll");
        if (hModule)
        {
                bool (*WinIMerge_DestroyWindow)(IImgMergeWindow *) = 
@@ -388,12 +388,30 @@ void CImgMergeFrame::OnChildPaneEvent(const IImgMergeWindow::Event& evt)
 }
 
 /**
+ * @brief returns true if WinIMergeLib.dll is loadable
+ */
+bool CImgMergeFrame::IsLoadable()
+{
+       static HMODULE hModule;
+       if (!hModule)
+       {
+               hModule = LoadLibraryW(L"WinIMerge\\WinIMergeLib.dll");
+               if (!hModule)
+                       return false;
+       }
+       return true;
+}
+
+/**
  * @brief Create the splitter, the filename bar, the status bar, and the two views
  */
 BOOL CImgMergeFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
        CCreateContext* pContext)
 {
-       HMODULE hModule = LoadLibraryW(L"WinIMerge\\WinIMergeLib.dll");
+       if (!IsLoadable())
+               return FALSE;
+
+       HMODULE hModule = GetModuleHandleW(L"WinIMergeLib.dll");
        if (!hModule)
                return FALSE;
 
index f1efeb5..73f503f 100644 (file)
@@ -75,6 +75,7 @@ public:
        bool IsFileChangedOnDisk(int pane) const;
        void CheckFileChanged(void);
        String GetDescription(int pane) const { return m_strDesc[pane]; }
+       static bool IsLoadable();
 
 // Attributes
 protected:
index d190507..7809ffa 100644 (file)
@@ -44,6 +44,7 @@
 #include "MergeDoc.h"
 #include "MergeEditView.h"
 #include "HexMergeDoc.h"
+#include "HexMergeView.h"
 #include "ImgMergeFrm.h"
 #include "LineFiltersList.h"
 #include "ConflictFileParser.h"
@@ -619,9 +620,9 @@ bool CMainFrame::ShowAutoMergeDoc(CDirDoc * pDirDoc,
        filterBin.SetMask(GetOptionsMgr()->GetString(OPT_CMP_BIN_FILEPATTERNS));
        for (pane = 0; pane < nFiles; ++pane)
        {
-               if (filterImg.includeFile(ifileloc[pane].filepath))
+               if (filterImg.includeFile(ifileloc[pane].filepath) && CImgMergeFrame::IsLoadable())
                        return ShowImgMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags, strDesc, sReportFile, infoUnpacker);
-               else if (filterBin.includeFile(ifileloc[pane].filepath))
+               else if (filterBin.includeFile(ifileloc[pane].filepath) && CHexMergeView::IsLoadable())
                        return ShowHexMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags, strDesc, sReportFile, infoUnpacker);
        }
        return ShowMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags, strDesc, sReportFile, infoUnpacker);
index 935350f..e551751 100644 (file)
@@ -240,6 +240,9 @@ TEST(CommandLineTest, Desc4)
 \r
 TEST(ImageCompareTest, Open)\r
 {\r
+       if (!CImgMergeFrame::IsLoadable())\r
+               return;\r
+\r
        String projectRoot = getProjectRoot();\r
        PathContext files = {\r
                paths::ConcatPath(projectRoot, L"Src/res/right_to_middle.bmp"),\r
@@ -254,7 +257,6 @@ TEST(ImageCompareTest, Open)
 \r
        pFrame->PostMessage(WM_CLOSE);\r
        dlg.SetFormerResult(nPrevFormerResult);\r
-\r
 }\r
 \r
 #endif
\ No newline at end of file
diff --git a/Testing/selftests/.gitattributes b/Testing/selftests/.gitattributes
new file mode 100644 (file)
index 0000000..77b6404
--- /dev/null
@@ -0,0 +1 @@
+**/*.txt -text\r
index 3717e14..89fb716 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: WinMerge\n"
 "Report-Msgid-Bugs-To: http://bugs.winmerge.org/\n"
-"POT-Creation-Date: 2018-06-03 10:30+0000\n"
+"POT-Creation-Date: 2018-06-17 03:35+0000\n"
 "PO-Revision-Date: \n"
 "Last-Translator: \n"
 "Language-Team: English <winmerge-translate@lists.sourceforge.net>\n"