Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rel3.5working #3777

Merged
merged 5 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/EngineMupdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1505,9 +1505,6 @@ EngineMupdf::EngineMupdf() {
EngineMupdf::~EngineMupdf() {
EnterCriticalSection(&pagesAccess);

// TODO: remove this lock and see what happens
EnterCriticalSection(ctxAccess);

for (FzPageInfo* pi : pages) {
DeleteVecMembers(pi->links);
DeleteVecMembers(pi->autoLinks);
Expand Down Expand Up @@ -1541,7 +1538,6 @@ EngineMupdf::~EngineMupdf() {
DeleteVecMembers(pages);

for (size_t i = 0; i < dimof(mutexes); i++) {
LeaveCriticalSection(&mutexes[i]);
DeleteCriticalSection(&mutexes[i]);
}
LeaveCriticalSection(&pagesAccess);
Expand Down
10 changes: 9 additions & 1 deletion src/ExternalViewers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "ExternalViewers.h"
#include "Commands.h"

#include "utils/Log.h"

struct ExternalViewerInfo {
const char* name; // shown to the user
int cmd;
Expand Down Expand Up @@ -300,6 +302,7 @@ bool CanViewWithKnownExternalViewer(WindowTab* tab, int cmd) {
}
ExternalViewerInfo* ev = FindExternalViewerInfoByCmd(cmd);
if (!ev || ev->exeFullPath == nullptr) {
logfa("CanViewWithKnownExternalViewer cmd: %d, !ev || ev->exeFullPath == nullptr\n", cmd);
return false;
}
// must match file extension
Expand All @@ -309,13 +312,16 @@ bool CanViewWithKnownExternalViewer(WindowTab* tab, int cmd) {
char* ext = path::GetExtTemp(filePath);
const char* pos = str::FindI(ev->exts, ext);
if (!pos) {
logfa("CanViewWithKnownExternalViewer cmd: %d, !pos\n", cmd);
return false;
}
}
Kind engineKind = tab->GetEngineType();
if (engineKind != nullptr) {
if (ev->engineKind != nullptr) {
if (ev->engineKind != engineKind) {
logfa("CanViewWithKnownExternalViewer cmd: %d, ev->engineKind '%s' != engineKind '%s'\n", cmd,
ev->engineKind, engineKind);
return false;
}
}
Expand Down Expand Up @@ -363,8 +369,10 @@ static TempStr FormatParamsTemp(const char* cmdLine, WindowTab* tab) {

bool ViewWithKnownExternalViewer(WindowTab* tab, int cmd) {
bool canView = CanViewWithKnownExternalViewer(tab, cmd);
ReportIf(!canView); // TODO: with command palette can send un-enforcable command
if (!canView) {
// TODO: with command palette can send un-enforcable command
logfa("ViewWithKnownExternalViewer cmd: %d\n", cmd);
ReportIf(!canView);
return false;
}
ExternalViewerInfo* ev = FindExternalViewerInfoByCmd(cmd);
Expand Down
15 changes: 8 additions & 7 deletions src/StressTesting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class TestFileProvider {
virtual ~TestFileProvider() {
}
// returns path of the next file to test or nullptr if done (caller needs to free() the result)
virtual char* NextFile() = 0;
virtual TempStr NextFile() = 0;
// start the iteration from the beginning
virtual void Restart() = 0;
virtual int GetFilesCount() = 0;
Expand Down Expand Up @@ -339,11 +339,12 @@ class FilesProvider : public TestFileProvider {
~FilesProvider() override {
}

char* NextFile() override {
TempStr NextFile() override {
if (provided >= files.size()) {
return nullptr;
}
return str::Dup(files.at(provided++));
TempStr res = files.at(provided++);
return res;
}

void Restart() override {
Expand All @@ -364,7 +365,7 @@ class DirFileProvider : public TestFileProvider {
public:
DirFileProvider(const char* path, const char* filter);
~DirFileProvider() override;
char* NextFile() override;
TempStr NextFile() override;
void Restart() override;
int GetFilesCount() override;
};
Expand All @@ -386,13 +387,13 @@ bool DirFileProvider::OpenDir(const char* dirPath) {
bool hasFiles = CollectStressTestSupportedFilesFromDirectory(dirPath, fileFilter, filesToOpen);
filesToOpen.SortNatural();

AutoFreeStr pattern(str::Format("%s\\*", dirPath));
TempStr pattern = str::FormatTemp("%s\\*", dirPath);
bool hasSubDirs = CollectPathsFromDirectory(pattern, dirsToVisit, true);

return hasFiles || hasSubDirs;
}

char* DirFileProvider::NextFile() {
TempStr DirFileProvider::NextFile() {
if (filesToOpen.size() > 0) {
return filesToOpen.PopAt(0);
}
Expand Down Expand Up @@ -695,7 +696,7 @@ static void RandomizeViewingState(StressTest* st) {

static bool GoToNextFile(StressTest* st) {
for (;;) {
AutoFreeStr nextFile(st->fileProvider->NextFile());
TempStr nextFile = st->fileProvider->NextFile();
if (nextFile) {
if (!IsInRange(st->fileRanges, ++st->fileIndex)) {
continue;
Expand Down
5 changes: 5 additions & 0 deletions src/utils/WinUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2910,3 +2910,8 @@ void AddPathToRecentDocs(const char* path) {
WCHAR* pathW = ToWstrTemp(path);
SHAddToRecentDocs(SHARD_PATH, pathW);
}

int GetGdiObjectsCount() {
DWORD n = GetGuiResources(GetCurrentProcess(), GR_GDIOBJECTS);
return (int)n;
}
10 changes: 10 additions & 0 deletions src/utils/WinUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,13 @@ void TbGetRect(HWND hwnd, int buttonId, RECT* rc);

void TreeViewExpandRecursively(HWND hTree, HTREEITEM hItem, uint flag, bool subtree);
void AddPathToRecentDocs(const char*);

int GetGdiObjectsCount();

struct CheckGdiLeaks {
int initialCount = GetGdiObjectsCount();
~CheckGdiLeaks() {
int currCount = GetGdiObjectsCount();
CrashIf(currCount > initialCount);
}
};
5 changes: 4 additions & 1 deletion translations/translations.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AppTranslator: SumatraPDF
79bc16efa4d3423f883b991ead7ed7b5e5c5cb1b
30e97d6fd71649751fcbdfff5968eeb9971e7e60
:%s annotation. Ctrl+click to edit.
am:%s մեկնաբանություն: Ctrl+քլիք՝ խմբագրելու համար:
az:Qeyd %s. Düzəliş etmək üçün Ctrl+düyməyə basın.
Expand Down Expand Up @@ -1438,6 +1438,7 @@ uk:Виділити
vn:&Nổi Bật
:&Keyboard Shortcuts
br:Atalhos do Teclado
de:Tasten&kombinationen
fr:&Raccourcis clavier
it:&Tasti rapidi
pl:Skróty &klawiaturowe
Expand Down Expand Up @@ -5842,6 +5843,7 @@ vn:Đã dọn lịch sử của %d tập tin, đã xóa hình thu nhỏ.
am:Պատմության մաքրում...
az:Tarixçə silinir...
br:Limpando o histórico...
by:Ачыстка гісторыі…
ca:S'està esborrant l'historial...
cn:正在清除历史记录…
cy:Yn clirio hanes...
Expand Down Expand Up @@ -14204,6 +14206,7 @@ vn:Mở PDF Đã Nhúng
am:Բացել նոր պատուհանում
az:Yeni pəncərədə aç
br:Abrir em Nova Janela
by:Адкрыць у новым акне
ca:Obre en una finestra nova
cn:在新窗口中打开
cy:Agor Mewn Ffenestr Newydd
Expand Down
Loading