Skip to content

Commit

Permalink
Polishing. 131107
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximus5 committed Nov 10, 2013
1 parent 6ff4bee commit d92b2c3
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 89 deletions.
1 change: 1 addition & 0 deletions src/ConEmu/ConEmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3150,6 +3150,7 @@ void CConEmuMain::Destroy()
CConEmuMain::~CConEmuMain()
{
_ASSERTE(ghWnd==NULL || !IsWindow(ghWnd));
MCHKHEAP;
//ghWnd = NULL;

SafeDelete(mp_DefTrm);
Expand Down
1 change: 1 addition & 0 deletions src/ConEmu/ConEmu11.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,7 @@
<ItemGroup>
<ClInclude Include="..\common\CmdLine.h" />
<ClInclude Include="..\common\DefTermHooker.h" />
<ClInclude Include="..\common\MAssert.h" />
<ClInclude Include="..\common\SetEnvVar.h" />
<ClInclude Include="..\ConEmuCD\ConsoleHelp.h" />
<ClInclude Include="About.h" />
Expand Down
4 changes: 2 additions & 2 deletions src/ConEmu/FrameHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/ConEmu/Macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
9 changes: 6 additions & 3 deletions src/ConEmu/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
1 change: 1 addition & 0 deletions src/ConEmu/OptionsClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/ConEmu/RealConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ CRealConsole::CRealConsole()
bool CRealConsole::Construct(CVirtualConsole* apVCon, RConStartArgs *args)
{
Assert(apVCon && args);
MCHKHEAP;

mp_VCon = apVCon;
mp_Log = NULL;
Expand Down Expand Up @@ -350,6 +351,7 @@ bool CRealConsole::Construct(CVirtualConsole* apVCon, RConStartArgs *args)

CRealConsole::~CRealConsole()
{
MCHKHEAP;
DEBUGSTRCON(L"CRealConsole::~CRealConsole()\n");

if (!gpConEmu->isMainThread())
Expand Down Expand Up @@ -421,6 +423,7 @@ CRealConsole::~CRealConsole()
// delete mp_Rgn;
// mp_Rgn = NULL;
//}
MCHKHEAP;
}

CVirtualConsole* CRealConsole::VCon()
Expand Down Expand Up @@ -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,
Expand Down
38 changes: 26 additions & 12 deletions src/ConEmu/Update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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%)
Expand Down Expand Up @@ -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;
Expand Down
26 changes: 15 additions & 11 deletions src/ConEmu/VConGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,11 @@ CVConGroup::CVConGroup(CVConGroup *apParent)

void CVConGroup::FinalRelease()
{
MCHKHEAP;
_ASSERTE(gpConEmu->isMainThread());
CVConGroup* pGroup = (CVConGroup*)this;
delete pGroup;
MCHKHEAP;
};

CVConGroup::~CVConGroup()
Expand Down Expand Up @@ -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])
Expand All @@ -641,6 +644,7 @@ void CVConGroup::StopSignalAll()

void CVConGroup::DestroyAllVCon()
{
MCHKHEAP;
for (size_t i = countof(gp_VCon); i--;)
{
if (gp_VCon[i])
Expand All @@ -650,6 +654,7 @@ void CVConGroup::DestroyAllVCon()
p->Release();
}
}
MCHKHEAP;
}

void CVConGroup::OnDestroyConEmu()
Expand Down Expand Up @@ -3391,6 +3396,7 @@ CVirtualConsole* CVConGroup::CreateCon(RConStartArgs *args, bool abAllowScripts
MBoxAssert(gpConEmu->isMainThread());
return NULL;
}
MCHKHEAP;

CVirtualConsole* pVCon = NULL;

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
{
Expand All @@ -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);
}

// ���� ���� ����� ������������ ���� (��������� ����)
Expand Down Expand Up @@ -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*/)
Expand Down
27 changes: 11 additions & 16 deletions src/ConEmu/VirtualConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -4009,28 +4008,24 @@ 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;
}

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;
}
}

Expand Down
Loading

0 comments on commit d92b2c3

Please sign in to comment.