From d92b2c373b907348a30220b2a43750943a0dce3e Mon Sep 17 00:00:00 2001 From: Maximus5 Date: Mon, 11 Nov 2013 02:21:55 +0400 Subject: [PATCH] Polishing. 131107 --- src/ConEmu/ConEmu.cpp | 1 + src/ConEmu/ConEmu11.vcxproj | 1 + src/ConEmu/FrameHolder.cpp | 4 +-- src/ConEmu/Macro.cpp | 5 +-- src/ConEmu/Options.cpp | 9 +++-- src/ConEmu/OptionsClass.cpp | 1 + src/ConEmu/RealConsole.cpp | 4 ++- src/ConEmu/Update.cpp | 38 ++++++++++++++------- src/ConEmu/VConGroup.cpp | 26 ++++++++------- src/ConEmu/VirtualConsole.cpp | 27 +++++++-------- src/ConEmu/conemu.gcc.manifest | 60 ++++++++++++++++++---------------- src/ConEmu/conemu.manifest | 31 +++++++++++------- src/ConEmu/version.h | 2 +- 13 files changed, 120 insertions(+), 89 deletions(-) diff --git a/src/ConEmu/ConEmu.cpp b/src/ConEmu/ConEmu.cpp index dfd1a32a32..41cadb9045 100644 --- a/src/ConEmu/ConEmu.cpp +++ b/src/ConEmu/ConEmu.cpp @@ -3150,6 +3150,7 @@ void CConEmuMain::Destroy() CConEmuMain::~CConEmuMain() { _ASSERTE(ghWnd==NULL || !IsWindow(ghWnd)); + MCHKHEAP; //ghWnd = NULL; SafeDelete(mp_DefTrm); diff --git a/src/ConEmu/ConEmu11.vcxproj b/src/ConEmu/ConEmu11.vcxproj index 1d3b0b754e..b5641dd106 100644 --- a/src/ConEmu/ConEmu11.vcxproj +++ b/src/ConEmu/ConEmu11.vcxproj @@ -955,6 +955,7 @@ + diff --git a/src/ConEmu/FrameHolder.cpp b/src/ConEmu/FrameHolder.cpp index 788500323e..6664fc29b1 100644 --- a/src/ConEmu/FrameHolder.cpp +++ b/src/ConEmu/FrameHolder.cpp @@ -1162,8 +1162,8 @@ LRESULT CFrameHolder::OnNcCalcSize(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l #if 0 if (!bAllowPreserveClient) { - pParm->rgrc[1] = MakeRect(0,0,0,0); - pParm->rgrc[2] = MakeRect(0,0,0,0); + pParm->rgrc[1] = MakeRect(rcClient.left, rcClient.top, rcClient.left, rcClient.top); + pParm->rgrc[2] = MakeRect(r[2].left, r[2].top, r[2].left, r[2].top); } else #endif diff --git a/src/ConEmu/Macro.cpp b/src/ConEmu/Macro.cpp index 0206a703cb..bb473b53d2 100644 --- a/src/ConEmu/Macro.cpp +++ b/src/ConEmu/Macro.cpp @@ -2036,7 +2036,7 @@ LPWSTR CConEmuMacro::Tab(GuiMacro* p, CRealConsole* apRCon) LPWSTR CConEmuMacro::Task(GuiMacro* p, CRealConsole* apRCon) { LPCWSTR pszResult = NULL; - LPCWSTR pszName = NULL, pszDir = NULL; + LPCWSTR pszName = NULL; wchar_t* pszBuf = NULL; int nTaskIndex = 0; @@ -2082,7 +2082,8 @@ LPWSTR CConEmuMacro::Task(GuiMacro* p, CRealConsole* apRCon) RConStartArgs *pArgs = new RConStartArgs; pArgs->pszSpecialCmd = lstrdup(pszName); - if (pszDir) + LPWSTR pszDir = NULL; + if (p->GetStrArg(1, pszDir) && pszDir && *pszDir) pArgs->pszStartupDir = lstrdup(pszDir); gpConEmu->PostCreateCon(pArgs); diff --git a/src/ConEmu/Options.cpp b/src/ConEmu/Options.cpp index c27d214248..7183369f16 100644 --- a/src/ConEmu/Options.cpp +++ b/src/ConEmu/Options.cpp @@ -4627,9 +4627,12 @@ const Settings::CommandTasks* Settings::CmdTaskGet(int anIndex) if (!CmdTasks || (anIndex < 0) || (anIndex >= CmdTaskCount)) return NULL; - CmdTasks[anIndex]->HotKey.HkType = chk_Task; - CmdTasks[anIndex]->HotKey.SetTaskIndex(anIndex); - CmdTasks[anIndex]->HotKey.fkey = CConEmuCtrl::key_RunTask; + if (CmdTasks[anIndex]) + { + CmdTasks[anIndex]->HotKey.HkType = chk_Task; + CmdTasks[anIndex]->HotKey.SetTaskIndex(anIndex); + CmdTasks[anIndex]->HotKey.fkey = CConEmuCtrl::key_RunTask; + } return (CmdTasks[anIndex]); } diff --git a/src/ConEmu/OptionsClass.cpp b/src/ConEmu/OptionsClass.cpp index 96bd010757..7a67a550d0 100644 --- a/src/ConEmu/OptionsClass.cpp +++ b/src/ConEmu/OptionsClass.cpp @@ -12302,6 +12302,7 @@ void CSettings::SetArgBufferHeight(int anBufferHeight) void CSettings::SetDefaultCmd(LPCWSTR asCmd) { + // !!! gpConEmu may be NULL due starting time !!! if (gpConEmu && gpConEmu->isMingwMode() && gpConEmu->isMSysStartup()) { wchar_t szSearch[MAX_PATH+32], *pszFile; diff --git a/src/ConEmu/RealConsole.cpp b/src/ConEmu/RealConsole.cpp index 32c10829a6..8558ddb568 100644 --- a/src/ConEmu/RealConsole.cpp +++ b/src/ConEmu/RealConsole.cpp @@ -141,6 +141,7 @@ CRealConsole::CRealConsole() bool CRealConsole::Construct(CVirtualConsole* apVCon, RConStartArgs *args) { Assert(apVCon && args); + MCHKHEAP; mp_VCon = apVCon; mp_Log = NULL; @@ -350,6 +351,7 @@ bool CRealConsole::Construct(CVirtualConsole* apVCon, RConStartArgs *args) CRealConsole::~CRealConsole() { + MCHKHEAP; DEBUGSTRCON(L"CRealConsole::~CRealConsole()\n"); if (!gpConEmu->isMainThread()) @@ -421,6 +423,7 @@ CRealConsole::~CRealConsole() // delete mp_Rgn; // mp_Rgn = NULL; //} + MCHKHEAP; } CVirtualConsole* CRealConsole::VCon() @@ -3235,7 +3238,6 @@ BOOL CRealConsole::StartProcess() { _ASSERTE(nStep==1 || nStep==2); MCHKHEAP; - MCHKHEAP; // Do actual process creation lbRc = StartProcessInt(lpszCmd, psCurCmd, lpszWorkDir, bNeedConHostSearch, hSetForeground, diff --git a/src/ConEmu/Update.cpp b/src/ConEmu/Update.cpp index ad4d497e63..d0562df634 100644 --- a/src/ConEmu/Update.cpp +++ b/src/ConEmu/Update.cpp @@ -335,8 +335,11 @@ void CConEmuUpdate::StartCheckProcedure(BOOL abShowMessages) // Already in update procedure if (m_UpdateStep == us_ExitAndUpdate) { - // Повторно? - gpConEmu->RequestExitUpdate(); + if (gpConEmu) + { + // Повторно? + gpConEmu->RequestExitUpdate(); + } } else if (abShowMessages) { @@ -455,7 +458,7 @@ bool CConEmuUpdate::ShowConfirmation() bool lbConfirm = false; // May be null, if update package was dropped on ConEmu icon - if (ghWnd) + if (gpConEmu && ghWnd) { gpConEmu->UpdateProgress(); } @@ -487,7 +490,7 @@ bool CConEmuUpdate::ShowConfirmation() { mb_RequestTerminate = true; // May be null, if update package was dropped on ConEmu icon - if (ghWnd) + if (gpConEmu && ghWnd) { gpConEmu->UpdateProgress(); } @@ -514,7 +517,7 @@ DWORD CConEmuUpdate::CheckThreadProc(LPVOID lpParameter) pUpdate->mb_InCheckProcedure = FALSE; // May be null, if update package was dropped on ConEmu icon - if (ghWnd) + if (gpConEmu && ghWnd) { gpConEmu->UpdateProgress(); } @@ -620,7 +623,7 @@ bool CConEmuUpdate::StartLocalUpdate(LPCWSTR asDownloadedPackage) LPCWSTR pszSetupPref = L"conemusetup."; size_t lnSetupPref = _tcslen(pszSetupPref); - _ASSERTE(gpConEmu->isMainThread()); + _ASSERTE(gpConEmu && gpConEmu->isMainThread()); if (InUpdate() != us_NotStarted) { @@ -759,7 +762,8 @@ bool CConEmuUpdate::StartLocalUpdate(LPCWSTR asDownloadedPackage) mpsz_PendingBatchFile = pszBatchFile; pszBatchFile = NULL; m_UpdateStep = us_ExitAndUpdate; - gpConEmu->RequestExitUpdate(); + if (gpConEmu) + gpConEmu->RequestExitUpdate(); lbExecuteRc = TRUE; wrap: @@ -964,7 +968,7 @@ DWORD CConEmuUpdate::CheckProcInt() mn_InternetContentReady = mn_InternetContentLen = 0; m_UpdateStep = us_Downloading; // May be null, if update package was dropped on ConEmu icon - if (ghWnd) + if (gpConEmu && ghWnd) { gpConEmu->UpdateProgress(); } @@ -1043,7 +1047,8 @@ DWORD CConEmuUpdate::CheckProcInt() mpsz_PendingBatchFile = pszBatchFile; pszBatchFile = NULL; m_UpdateStep = us_ExitAndUpdate; - gpConEmu->RequestExitUpdate(); + if (gpConEmu) + gpConEmu->RequestExitUpdate(); lbExecuteRc = TRUE; wrap: @@ -1109,6 +1114,11 @@ wchar_t* CConEmuUpdate::CreateBatchFile(LPCWSTR asPackage) wchar_t szPID[16]; _wsprintf(szPID, SKIPLEN(countof(szPID)) L"%u", GetCurrentProcessId()); wchar_t szCPU[4]; wcscpy_c(szCPU, WIN3264TEST(L"x86",L"x64")); WARNING("Битность установщика? Если ставим в ProgramFiles64 на Win64"); + + if (!gpConEmu) + { + ReportError(L"CreateBatchFile failed, gpConEmu==NULL", 0); goto wrap; + } pszBatch = CreateTempFile(mp_Set->szUpdateDownloadPath, L"ConEmuUpdate.cmd", hBatch); if (!pszBatch) @@ -1823,7 +1833,7 @@ BOOL CConEmuUpdate::DownloadFile(LPCWSTR asSource, LPCWSTR asTarget, HANDLE hDst mn_InternetContentReady += nRead; // May be null, if update package was dropped on ConEmu icon - if (ghWnd) + if (gpConEmu && ghWnd) { gpConEmu->UpdateProgress(); } @@ -1942,7 +1952,8 @@ void CConEmuUpdate::ReportErrorInt(wchar_t* asErrorInfo) ms_LastErrorInfo = asErrorInfo; SC.Unlock(); - gpConEmu->ReportUpdateError(); + if (gpConEmu) + gpConEmu->ReportUpdateError(); } void CConEmuUpdate::ReportError(LPCWSTR asFormat, DWORD nErrCode) @@ -1989,6 +2000,9 @@ void CConEmuUpdate::ReportError(LPCWSTR asFormat, LPCWSTR asArg1, LPCWSTR asArg2 bool CConEmuUpdate::NeedRunElevation() { + if (!gpConEmu) + return false; + //TODO: В каких случаях нужен "runas" //TODO: Vista+: (если сейчас НЕ "Admin") && (установка в %ProgramFiles%) //TODO: WinXP-: (установка в %ProgramFiles%) && (нет доступа в %ProgramFiles%) @@ -2166,7 +2180,7 @@ bool CConEmuUpdate::QueryConfirmation(CConEmuUpdate::UpdateStep step, LPCWSTR as bool CConEmuUpdate::QueryConfirmationInt(LPCWSTR asConfirmInfo) { - if (mb_InShowLastError) + if (mb_InShowLastError || !gpConEmu) return false; // Если отображается ошибк - не звать bool lbConfirm; diff --git a/src/ConEmu/VConGroup.cpp b/src/ConEmu/VConGroup.cpp index 67c4984b9e..5ada11c4ef 100644 --- a/src/ConEmu/VConGroup.cpp +++ b/src/ConEmu/VConGroup.cpp @@ -326,9 +326,11 @@ CVConGroup::CVConGroup(CVConGroup *apParent) void CVConGroup::FinalRelease() { + MCHKHEAP; _ASSERTE(gpConEmu->isMainThread()); CVConGroup* pGroup = (CVConGroup*)this; delete pGroup; + MCHKHEAP; }; CVConGroup::~CVConGroup() @@ -630,6 +632,7 @@ void CVConGroup::LogInput(UINT uMsg, WPARAM wParam, LPARAM lParam, LPCWSTR pszTr void CVConGroup::StopSignalAll() { + MCHKHEAP; for (size_t i = 0; i < countof(gp_VCon); i++) { if (gp_VCon[i]) @@ -641,6 +644,7 @@ void CVConGroup::StopSignalAll() void CVConGroup::DestroyAllVCon() { + MCHKHEAP; for (size_t i = countof(gp_VCon); i--;) { if (gp_VCon[i]) @@ -650,6 +654,7 @@ void CVConGroup::DestroyAllVCon() p->Release(); } } + MCHKHEAP; } void CVConGroup::OnDestroyConEmu() @@ -3391,6 +3396,7 @@ CVirtualConsole* CVConGroup::CreateCon(RConStartArgs *args, bool abAllowScripts MBoxAssert(gpConEmu->isMainThread()); return NULL; } + MCHKHEAP; CVirtualConsole* pVCon = NULL; @@ -3460,6 +3466,7 @@ CVirtualConsole* CVConGroup::CreateCon(RConStartArgs *args, bool abAllowScripts pVCon = gpConEmu->CreateConGroup(pszDataW, args->bRunAsAdministrator, NULL/*ignored when 'args' specified*/, args); SafeFree(pszDataW); + MCHKHEAP; return pVCon; } @@ -3490,6 +3497,8 @@ CVirtualConsole* CVConGroup::CreateCon(RConStartArgs *args, bool abAllowScripts // 130826 - "-new_console:sVb" - "b" was ignored! BOOL lbInBackground = args->bBackgroundTab && (pOldActive != NULL); // && !args->eSplit; + // 131106 - "cmd -new_console:bsV" fails, split was left invisible + BOOL lbShowSplit = (args->eSplit != RConStartArgs::eSplitNone); if (pVCon) { @@ -3516,18 +3525,11 @@ CVirtualConsole* CVConGroup::CreateCon(RConStartArgs *args, bool abAllowScripts { pVCon->RCon()->OnActivate(i, ActiveConNum()); - //mn_ActiveCon = i; - //Update(true); - ShowActiveGroup(pOldActive); - //TODO("DoubleView: показать на неактивной?"); - //// Теперь можно показать активную - //gp_VActive->ShowView(SW_SHOW); - ////ShowWindow(gp_VActive->GetView(), SW_SHOW); - //// и спрятать деактивированную - //if (pOldActive && (pOldActive != gp_VActive) && !pOldActive->isVisible()) - // pOldActive->ShowView(SW_HIDE); - // //ShowWindow(pOldActive->GetView(), SW_HIDE); + } + else if (lbShowSplit) + { + ShowActiveGroup(NULL); } // Если была смена конфигурации окна (появились табы) @@ -4076,6 +4078,8 @@ void CVConGroup::SetAllConsoleWindowsSize(RECT rcWnd, enum ConEmuRect tFrom /*= SetRedraw(TRUE); Redraw(); } + + MCHKHEAP; } void CVConGroup::SyncAllConsoles2Window(RECT rcWnd, enum ConEmuRect tFrom /*= CER_MAIN*/, bool bSetRedraw /*= false*/) diff --git a/src/ConEmu/VirtualConsole.cpp b/src/ConEmu/VirtualConsole.cpp index c22e770cf4..d77ad5225d 100644 --- a/src/ConEmu/VirtualConsole.cpp +++ b/src/ConEmu/VirtualConsole.cpp @@ -115,7 +115,7 @@ FEFF ZERO WIDTH NO-BREAK SPACE #ifdef _DEBUG //#undef HEAPVAL -#define HEAPVAL //HeapValidate(mh_Heap, 0, NULL); +#define HEAPVAL HeapValidate(mh_Heap, 0, NULL); #define CURSOR_ALWAYS_VISIBLE #else #define HEAPVAL @@ -633,9 +633,8 @@ void CVirtualConsole::PointersFree() bool CVirtualConsole::PointersAlloc() { mb_PointersAllocated = false; -#ifdef _DEBUG - HeapValidate(mh_Heap, 0, NULL); -#endif + HEAPVAL; + uint nWidthHeight = (nMaxTextWidth * nMaxTextHeight); #ifdef AllocArray #undef AllocArray @@ -4009,14 +4008,12 @@ void CVirtualConsole::UpdateCursor(bool& lRes) LPVOID CVirtualConsole::Alloc(size_t nCount, size_t nSize) { -#ifdef _DEBUG - //HeapValidate(mh_Heap, 0, NULL); -#endif + HEAPVAL; + size_t nWhole = nCount * nSize; LPVOID ptr = HeapAlloc(mh_Heap, HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY, nWhole); -#ifdef _DEBUG - //HeapValidate(mh_Heap, 0, NULL); -#endif + + //HEAPVAL; return ptr; } @@ -4024,13 +4021,11 @@ void CVirtualConsole::Free(LPVOID ptr) { if (ptr && mh_Heap) { -#ifdef _DEBUG - //HeapValidate(mh_Heap, 0, NULL); -#endif + HEAPVAL; + HeapFree(mh_Heap, 0, ptr); -#ifdef _DEBUG - //HeapValidate(mh_Heap, 0, NULL); -#endif + + //HEAPVAL; } } diff --git a/src/ConEmu/conemu.gcc.manifest b/src/ConEmu/conemu.gcc.manifest index d89a36157a..d7075d33c3 100644 --- a/src/ConEmu/conemu.gcc.manifest +++ b/src/ConEmu/conemu.gcc.manifest @@ -1,33 +1,35 @@ - ConEmu - - - - - - - - - - - - - - - - - - - - + ConEmu + + + + + + + + + + + + + + + + + + + + + + - - - - true - - + + + + true + + diff --git a/src/ConEmu/conemu.manifest b/src/ConEmu/conemu.manifest index 780df1db29..652741d725 100644 --- a/src/ConEmu/conemu.manifest +++ b/src/ConEmu/conemu.manifest @@ -1,15 +1,22 @@ - - - - - + + + + + + + + + + + + + + + + + diff --git a/src/ConEmu/version.h b/src/ConEmu/version.h index 4316a3d795..938333900d 100644 --- a/src/ConEmu/version.h +++ b/src/ConEmu/version.h @@ -1,7 +1,7 @@ #define MVV_1 13 #define MVV_2 11 -#define MVV_3 5 +#define MVV_3 7 #define MVV_4 0 #define MVV_4a ""