From f2cd7790669ec3867977293f5c83bdec235b81b5 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sat, 16 Jan 2016 13:00:39 +0100 Subject: [PATCH] Fix crash issue due to the bad fix of touchscreen hanging issue This crash issue is a regression due to 6f4140a281f87316911776e7375f6c86dc4f5bdc which was intended to fix a touchscreen hanging bug. The crash issue is fixed in this commit, as well the touchscreen hanging issue thanks to the answer from StackOverflow: http://stackoverflow.com/questions/34816597/messagebox-not-responsing-in-wm-activateapp-on-touchscreen/34825851#34825851 --- PowerEditor/src/Notepad_plus.h | 9 --------- PowerEditor/src/NppBigSwitch.cpp | 26 +++++++++++++------------- PowerEditor/src/resource.h | 2 +- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index abf2c148..ef8e1682 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -383,16 +383,7 @@ private: //For Dynamic selection highlight CharacterRange _prevSelectedRange; - struct ActivateAppInfo final - { - bool _isActivated = false; - int _x = 0; - int _y = 0; - } - _activeAppInf; - //Synchronized Scolling - struct SyncInfo final { int _line = 0; diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index d4bbd78f..1b99d904 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1347,24 +1347,24 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return notify(notification); } - case NPPM_INTERNAL_CHECKDOCSTATUS: case WM_ACTIVATEAPP: { if (wParam == TRUE) // if npp is about to be activated { - const NppGUI & nppgui = pNppParam->getNppGUI(); - if (LOWORD(wParam) && (nppgui._fileAutoDetection != cdDisabled)) - { - _activeAppInf._isActivated = true; - - //checkModifiedDocument(); - // Make checkModifiedDocument as thread to avoid Notepad++ hanging while user uses touch screen to activate Notepad++ windows - HANDLE hThread = CreateThread(NULL, 0, &CheckModifiedDocumentThread, NULL, 0, NULL); - ::CloseHandle(hThread); - return FALSE; - } + ::PostMessage(hwnd, NPPM_INTERNAL_CHECKDOCSTATUS, 0, 0); } - break; + return FALSE; + } + + case NPPM_INTERNAL_CHECKDOCSTATUS: + { + const NppGUI & nppgui = pNppParam->getNppGUI(); + if (nppgui._fileAutoDetection != cdDisabled) + { + checkModifiedDocument(); + return TRUE; + } + return FALSE; } case NPPM_INTERNAL_GETCHECKDOCOPT: diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 79f28b8a..2379c947 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -407,7 +407,7 @@ // Used by Doc Monitor plugin // #define NPPM_INTERNAL_CHECKDOCSTATUS (NPPMSG + 53) - // VOID NPPM_CHECKDOCSTATUS(BOOL, 0) + // VOID NPPM_CHECKDOCSTATUS(0, 0) // check all opened documents status. // If files are modified, then reloaod (with or without prompt, it depends on settings). // if files are deleted, then prompt user to close the documents