* ChangeUI should warn when it cannot find a dialog.
* CDialogTemplate::Save needs to free the template with the correct function. git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6535 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
b7630502dc
commit
fd6400d44d
7 changed files with 21 additions and 30 deletions
|
@ -281,17 +281,12 @@ int CDialogTemplate::RemoveItem(WORD wId) {
|
|||
|
||||
// Sets the font of the dialog
|
||||
void CDialogTemplate::SetFont(TCHAR* szFaceName, WORD wFontSize) {
|
||||
if (_tcscmp(szFaceName, _T("MS Shell Dlg"))) {
|
||||
// not MS Shell Dlg
|
||||
m_dwStyle &= ~DS_SHELLFONT;
|
||||
}
|
||||
else {
|
||||
// MS Shell Dlg
|
||||
m_dwStyle &= ~DS_SHELLFONT;
|
||||
if (!_tcscmp(szFaceName, _T("MS Shell Dlg"))) // TODO: "MS Shell Dlg 2"?
|
||||
m_dwStyle |= DS_SHELLFONT;
|
||||
}
|
||||
m_bCharset = DEFAULT_CHARSET;
|
||||
m_dwStyle |= DS_SETFONT;
|
||||
if (m_szFont) free(m_szFont);
|
||||
m_bCharset = DEFAULT_CHARSET;
|
||||
free(m_szFont);
|
||||
m_szFont = WinWStrDupFromTChar(szFaceName, m_uCodePage);
|
||||
m_sFontSize = wFontSize;
|
||||
}
|
||||
|
@ -334,7 +329,7 @@ HWND CDialogTemplate::CreateDummyDialog() {
|
|||
DWORD dwTemp;
|
||||
BYTE* pbDlg = Save(dwTemp);
|
||||
HWND hDlg = CreateDialogIndirect(GetModuleHandle(0), (DLGTEMPLATE*)pbDlg, 0, 0);
|
||||
delete [] pbDlg;
|
||||
FreeSavedTemplate(pbDlg);
|
||||
if (!hDlg)
|
||||
throw runtime_error("Can't create dialog from template!");
|
||||
|
||||
|
|
|
@ -134,6 +134,7 @@ public:
|
|||
#endif
|
||||
void ConvertToRTL();
|
||||
BYTE* Save(DWORD& dwSize);
|
||||
static void FreeSavedTemplate(BYTE*pDT) { delete [] pDT; }
|
||||
DWORD GetSize();
|
||||
|
||||
private:
|
||||
|
|
|
@ -271,9 +271,7 @@ BYTE* CResourceEditor::GetResourceW(const WINWCHAR* szType, WINWCHAR* szName, LA
|
|||
i = nameDir->Find(szName);
|
||||
if (i > -1) {
|
||||
langDir = nameDir->GetEntry(i)->GetSubDirectory();
|
||||
i = 0;
|
||||
if (wLanguage)
|
||||
i = langDir->Find(wLanguage);
|
||||
i = wLanguage ? langDir->Find(wLanguage) : 0;
|
||||
if (i > -1) {
|
||||
data = langDir->GetEntry(i)->GetDataEntry();
|
||||
}
|
||||
|
@ -313,9 +311,7 @@ int CResourceEditor::GetResourceSizeW(const WINWCHAR* szType, WINWCHAR* szName,
|
|||
i = nameDir->Find(szName);
|
||||
if (i > -1) {
|
||||
langDir = nameDir->GetEntry(i)->GetSubDirectory();
|
||||
i = 0;
|
||||
if (wLanguage)
|
||||
i = langDir->Find(wLanguage);
|
||||
i = wLanguage ? langDir->Find(wLanguage) : 0;
|
||||
if (i > -1) {
|
||||
data = langDir->GetEntry(i)->GetDataEntry();
|
||||
}
|
||||
|
@ -352,9 +348,7 @@ DWORD CResourceEditor::GetResourceOffsetW(const WINWCHAR* szType, WINWCHAR* szNa
|
|||
i = nameDir->Find(szName);
|
||||
if (i > -1) {
|
||||
langDir = nameDir->GetEntry(i)->GetSubDirectory();
|
||||
i = 0;
|
||||
if (wLanguage)
|
||||
i = langDir->Find(wLanguage);
|
||||
i = wLanguage ? langDir->Find(wLanguage) : 0;
|
||||
if (i > -1) {
|
||||
data = langDir->GetEntry(i)->GetDataEntry();
|
||||
}
|
||||
|
@ -565,7 +559,7 @@ bool CResourceEditor::SetPESectionVirtualSize(const char* pszSectionName, DWORD
|
|||
// Private Methods
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This function scans a give resource directory and return a CResourceDirectory object
|
||||
// This function scans a given resource directory and returns a CResourceDirectory object
|
||||
// rdRoot must point to the root directory of the resource section
|
||||
CResourceDirectory* CResourceEditor::ScanDirectory(PRESOURCE_DIRECTORY rdRoot, PRESOURCE_DIRECTORY rdToScan) {
|
||||
// Create CResourceDirectory from rdToScan
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
CPPUNIT_ASSERT_EQUAL( (DWORD) sizeof(original_dialog), dwSize );
|
||||
CPPUNIT_ASSERT_EQUAL( 0, memcmp(saved_dialog, original_dialog, dwSize) );
|
||||
|
||||
delete [] saved_dialog;
|
||||
dt.FreeSavedTemplate(saved_dialog);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -2199,7 +2199,7 @@ again:
|
|||
DWORD dwSize; \
|
||||
dlg = dt.Save(dwSize); \
|
||||
res_editor->UpdateResource(RT_DIALOG, id, NSIS_DEFAULT_LANG, dlg, dwSize); \
|
||||
delete [] dlg; \
|
||||
dt.FreeSavedTemplate(dlg); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
|
|
@ -718,7 +718,7 @@ int CEXEBuild::GenerateLangTables() {
|
|||
DWORD dwSize; \
|
||||
dlg = td.Save(dwSize); \
|
||||
res_editor->UpdateResource(RT_DIALOG, id, NSIS_DEFAULT_LANG, dlg, dwSize); \
|
||||
res_editor->FreeResource(dlg); \
|
||||
td.FreeSavedTemplate(dlg); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
@ -788,7 +788,7 @@ int CEXEBuild::GenerateLangTables() {
|
|||
DWORD dwSize; \
|
||||
dlg = td.Save(dwSize); \
|
||||
res_editor->UpdateResource(RT_DIALOG, id+cur_offset, NSIS_DEFAULT_LANG, dlg, dwSize); \
|
||||
res_editor->FreeResource(dlg); \
|
||||
td.FreeSavedTemplate(dlg); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
|
|
@ -2320,7 +2320,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
DWORD dwSize;
|
||||
dlg = dt.Save(dwSize);
|
||||
res_editor->UpdateResource(RT_DIALOG, IDD_INSTFILES, NSIS_DEFAULT_LANG, dlg, dwSize);
|
||||
delete [] dlg;
|
||||
dt.FreeSavedTemplate(dlg);
|
||||
}
|
||||
catch (exception& err) {
|
||||
ERROR_MSG(_T("Error setting smooth progress bar: %") NPRIs _T("\n"), CtoTStrParam(err.what()));
|
||||
|
@ -2589,9 +2589,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
init_res_editor();
|
||||
|
||||
// Search for required items
|
||||
#define GET(x) dlg = uire->GetResource(RT_DIALOG, x, 0); if (!dlg) return PS_ERROR; CDialogTemplate UIDlg(dlg, build_unicode, uDefCodePage);
|
||||
#define SEARCH(x) if (!UIDlg.GetItem(x)) {ERROR_MSG(_T("Error: Can't find %") NPRIs _T(" (%u) in the custom UI!\n"), _T(#x), x);uire->FreeResource(dlg);delete uire;return PS_ERROR;}
|
||||
#define SAVE(x) uire->FreeResource(dlg); dlg = UIDlg.Save(dwSize); res_editor->UpdateResource(RT_DIALOG, x, NSIS_DEFAULT_LANG, dlg, dwSize); uire->FreeResource(dlg);
|
||||
#define CUISEARCHERR(n,v) ERROR_MSG(_T("Error: Can't find %") NPRIs _T(" (%u) in the custom UI!\n"), n, v);
|
||||
#define GET(x) if (!(dlg = uire->GetResource(RT_DIALOG, x, 0))) { CUISEARCHERR(_T(#x), x); return PS_ERROR; } CDialogTemplate UIDlg(dlg, build_unicode, uDefCodePage);
|
||||
#define SEARCH(x) if (!UIDlg.GetItem(x)) { CUISEARCHERR(_T(#x), x); uire->FreeResource(dlg); delete uire; return PS_ERROR; }
|
||||
#define SAVE(x) uire->FreeResource(dlg); dlg = UIDlg.Save(dwSize); res_editor->UpdateResource(RT_DIALOG, x, NSIS_DEFAULT_LANG, dlg, dwSize); UIDlg.FreeSavedTemplate(dlg);
|
||||
|
||||
LPBYTE dlg = NULL;
|
||||
|
||||
|
@ -2749,7 +2750,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
DWORD dwDlgSize;
|
||||
dlg = dt.Save(dwDlgSize);
|
||||
res_editor->UpdateResource(RT_DIALOG, IDD_INST, NSIS_DEFAULT_LANG, dlg, dwDlgSize);
|
||||
res_editor->FreeResource(dlg);
|
||||
dt.FreeSavedTemplate(dlg);
|
||||
|
||||
dt.DlgUnitsToPixels(brandingCtl.sWidth, brandingCtl.sHeight);
|
||||
SCRIPT_MSG(_T("AddBrandingImage: %") NPRIs _T(" %ux%u\n"), line.gettoken_str(1), brandingCtl.sWidth, brandingCtl.sHeight);
|
||||
|
@ -3825,7 +3826,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
DWORD dwSize;
|
||||
dlg = td.Save(dwSize);
|
||||
res_editor->UpdateResource(RT_DIALOG, IDD_INST, NSIS_DEFAULT_LANG, dlg, dwSize);
|
||||
res_editor->FreeResource(dlg);
|
||||
td.FreeSavedTemplate(dlg);
|
||||
}
|
||||
catch (exception& err) {
|
||||
ERROR_MSG(_T("Error while triming branding text control: %") NPRIs _T("\n"), CtoTStrParam(err.what()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue