From e57956833581dea917ca461ffb8a88fc7addd95d Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 29 Jun 2006 15:35:17 +0000 Subject: [PATCH] Patch level : 4.0 Files correlati : xvaga,dll Ricompilazione Demo : [ ] Commento : Migliorata gestione stampanti con driver troppo pretenziosi: se hanno piu' di 4096 bytes di parametri extra, questi vengono ignorati. Tale sotterfugio serve per impedire di nuocere alla stampante Konica del CRPA git-svn-id: svn://10.65.10.50/trunk@14134 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- xvaga/agasys.cpp | 4 ++-- xvaga/oswin32.cpp | 39 +++++++++++++++++++++++++++------------ xvaga/xvaga.cpp | 11 +++++------ 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/xvaga/agasys.cpp b/xvaga/agasys.cpp index 6495c5a44..b7b6ac9fa 100755 --- a/xvaga/agasys.cpp +++ b/xvaga/agasys.cpp @@ -31,7 +31,7 @@ static unsigned int aga_getziplist(const char* zipfile, wxArrayString& aFiles) return aFiles.GetCount(); } -int aga_find_slash(const wxString& path, int from) +static int aga_find_slash(const wxString& path, int from) { for (int i = from; path[i]; i++) if (wxIsPathSeparator(path[i])) @@ -40,7 +40,7 @@ int aga_find_slash(const wxString& path, int from) return -1; } -void aga_create_dir(wxString strPath) +static void aga_create_dir(wxString strPath) { if (!wxEndsWithPathSeparator(strPath)) strPath += wxFILE_SEP_PATH; diff --git a/xvaga/oswin32.cpp b/xvaga/oswin32.cpp index 7635522ad..283694950 100755 --- a/xvaga/oswin32.cpp +++ b/xvaga/oswin32.cpp @@ -39,24 +39,39 @@ static void TestPaper(PDEVMODE dm) } } +static void adjust_extra(WORD& w) +{ + if (w > 4096) + w = 0; +} + void* OsWin32_ConvertFromNativePrinterInfo(void* hGlobal, unsigned int& nDataSize) { - PDEVMODE dm = (PDEVMODE)::GlobalLock(hGlobal); - nDataSize = dm->dmSize+dm->dmDriverExtra; - void* buff = new char[nDataSize]; - TestPaper(dm); - memcpy(buff, dm, nDataSize); - ::GlobalUnlock(hGlobal); + void* buff = NULL; + if (hGlobal != NULL) + { + PDEVMODE dm = (PDEVMODE)::GlobalLock(hGlobal); + adjust_extra(dm->dmDriverExtra); + nDataSize = dm->dmSize+dm->dmDriverExtra; + buff = new char[nDataSize]; + TestPaper(dm); + memcpy(buff, dm, nDataSize); + ::GlobalUnlock(hGlobal); + } return buff; } void* OsWin32_ConvertToNativePrinterInfo(void* data, unsigned int nDataSize) { - HGLOBAL hGlobal = ::GlobalAlloc(GHND, nDataSize); - PDEVMODE dm = (PDEVMODE)::GlobalLock(hGlobal); - memcpy(dm, data, nDataSize); - TestPaper(dm); - ::GlobalUnlock(hGlobal); + HGLOBAL hGlobal = ::GlobalAlloc(GHND, nDataSize); // Alloco lo spazio necessario + if (hGlobal != NULL) + { + PDEVMODE dm = (PDEVMODE)::GlobalLock(hGlobal); // Trasformo l'handle in puntatore + memcpy(dm, data, nDataSize); // Ricopio i dati della stampante + adjust_extra(dm->dmDriverExtra); + TestPaper(dm); // Controllo il formato della carta + ::GlobalUnlock(hGlobal); // Libero il lock sull'handle + } return hGlobal; } @@ -163,7 +178,7 @@ void* OsWin32_GetPrinterInfo(int& size, const char* printer) if (comma) *comma = '\0'; } else - strcpy(name, printer); + strncpy(name, printer, sizeof(name)); LPDEVMODE pdm = NULL; HANDLE hPrinter; diff --git a/xvaga/xvaga.cpp b/xvaga/xvaga.cpp index 5106f0338..3a35fff08 100755 --- a/xvaga/xvaga.cpp +++ b/xvaga/xvaga.cpp @@ -4449,14 +4449,13 @@ void xvt_vobj_destroy(WINDOW win) if (_nice_windows.Get(win) != NULL) { - CAST_TWIN(win, w); - w.Close(true); + if (win != TASK_WIN) + { + CAST_TWIN(win, w); + w.Close(true); + } GetTDCMapper().DestroyTDC(win); } -#ifdef DBG - else - XVT_ASSERT(FALSE); // Happens to list box windows -#endif } GetTDCMapper().DestroyTDC(win); }