- avoid upper/lowercase issue for #include <windowsx.h>
- casts to avoid warning: conversion from ‘int’ to ‘UCHAR’ {aka ‘unsigned char’} may change value [-Wconversion]
- cast to avoid warning: conversion from ‘int’ to ‘BYTE’ {aka ‘unsigned char’} may change value [-Wconversion]
- avoid warning : delete called on non-final 'FileDialogEventHandler' that has virtual functions but non-virtual destructor [-Wdelete-non-abstract-non-virtual-dtor]
- avoid warning : warning: extra ';' [-Wpedantic] in BabyGrid.cpp
Close#14950
Previously there was the 4096 MB max limit, so when e.g. user set this 4GB threshold and then tried to open any 2GB+ file, the Scintilla CellBuffer::Allocate method throwed a std::runtime_error because currently the Notepad++ does not use the SC_DOCUMENTOPTION_TEXT_LARGE in such a case.
The function "addHotSpot" can become very slow when the screen contains certain sequences of characters that look like URLs but are not valid, due to a form of backtracking. This change eliminates the possibility of backtracking.
This commit does two things:
First, it tightens the requirements for “looks like a URL” by checking the scheme earlier in the process. That is necessary to keep the next step from skipping valid URLs in reasonable contexts.
Second, once the beginning of a potential URL passes the tighter initial scanning and the end of the URL is found, we “commit” to that portion of the line. If the potential URL fails InternetCrackUrl validation, we restart scanning from the end of of the string that looked like a URL but wasn’t, rather than from just after the scheme.
Fix#13916, close#14900
The crash occurs because the thread terminates the task prematurely due to PostMessage’s nature. As a result, FileManager::backupCurrentBuffer() is always executed by the main thread, leading to a deadlock ( due to "std::lock_guard<std::mutex> lock(backup_mutex);") on the 2nd main thread’s entry and causing the crash. Here the explanation:
"If lock is called by a thread that already owns the mutex, the behavior is undefined: for example, the program may deadlock."
ref: https://en.cppreference.com/w/cpp/thread/mutex/lock
Using SendMessage instead of PostMessage ensures that the thread executes the task from the beginning to the end and keeps the mutex until the entire operation is terminated. Therefore, the race condition is prevented by the mutex lock while the 2nd thread tries to access the same code/zone.
Fix#14906, close#14917
Fix possible session backup swapping when no session.xml file.
The ReplaceFile WINAPI failed when the session.xml file replaced did not exist.
This commit follows the commit aa3777786dClose#14887
Fix memory overwriting bug by BabyGrid:
BabyGrid code was overwriting foreign memory on its initialization and deinitialization. At that time (WM_NCCREATE, WM_NCCALCSIZE, WM_CREATE and WM_NCDESTROY) the relevant FindGrid func returns -1, which was used as an index pointing to a memory area before the whole BGHS object (BGHS[-1]...)!
This was a long-standing hidden bug that only started to manifest itself probably when the app memory layout shifted somehow and important objects/data started to be overwritten, resulting in the visible app crashes.
Fix https://github.com/notepad-plus-plus/notepad-plus-plus/pull/14855#issuecomment-2001066992 , https://github.com/notepad-plus-plus/notepad-plus-plus/pull/14871#issuecomment-2002485089
=========
Sernario:
=========
When a user modifies a file in Notepad++, and the time of periodic backup (defaulted to 7 seconds) is reached, the backup of the modified file is being written. However, if a power outage occurs during this precise moment while the file is being written, file corruption may occur.
=======
Remedy:
=======
The goal is to maintain a non-corrupted file sample even during power outages. Here are the steps:
0. Begin
1. Write the file A as A.temp
2. Replace A by A.temp
3. End
During these steps, the cutoff can happen at any moment, but the user will always have a non-corrupted file sample (either A or A.temp).
=====
Note:
=====
The solution is only applied to "new #" files, since these files are generally small in length and do not have a second "physical" file existing on the hard drive.
ref: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/6133#issuecomment-1987037043Fix#6133, close#14860
In case of "session.xml" being corrupted after the power outrages, "session.xml.inCaseOfCorruption.bak" will replace "session.xml" on the next Notepad++ startup.
Fix#14781, close#14858