Skip to content

Commit

Permalink
- [internal] attempt at fix text repainting problems reported by seve…
Browse files Browse the repository at this point in the history
…ral users

git-svn-id: svn://localhost/private/Console2/trunk@945 8ae08d04-e83e-804b-908e-3db21359c104
  • Loading branch information
bozho committed Dec 9, 2007
1 parent 373dbb2 commit 3b7a336
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 20 deletions.
8 changes: 4 additions & 4 deletions Console/Console.rc
Expand Up @@ -766,8 +766,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,135
PRODUCTVERSION 2,0,0,135
FILEVERSION 2,0,0,136
PRODUCTVERSION 2,0,0,136
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -785,13 +785,13 @@ BEGIN
VALUE "Comments", "Tabbed cool console window (THIS IS NOT A SHELL :-)"
VALUE "CompanyName", "Ingenuity Unlimited Ltd."
VALUE "FileDescription", "Main Console module"
VALUE "FileVersion", "2.00, Build 135 2007.11.26"
VALUE "FileVersion", "2.00, Build 136 2007.12.09"
VALUE "InternalName", "Console"
VALUE "LegalCopyright", "Copyright � 2001-2007 Marko Bozikovic"
VALUE "LegalTrademarks", "Copyright � 2001-2007 Marko Bozikovic"
VALUE "OriginalFilename", "Console.exe"
VALUE "ProductName", "Console"
VALUE "ProductVersion", "2.00.00.135"
VALUE "ProductVersion", "2.00.00.136"
END
END
BLOCK "VarFileInfo"
Expand Down
20 changes: 13 additions & 7 deletions Console/ConsoleView.cpp
Expand Up @@ -57,7 +57,8 @@ ConsoleView::ConsoleView(MainFrame& mainFrame, DWORD dwTabIndex, const wstring&
, m_cursor()
, m_selectionHandler()
, m_mouseCommand(MouseSettings::cmdNone)
, m_activeCritSec()
, m_repaintMutex(NULL, FALSE, NULL)
, m_activeMutex(NULL, FALSE, NULL)
, m_bFlashTimerRunning(false)
, m_dwFlashes(0)
{
Expand Down Expand Up @@ -254,7 +255,7 @@ LRESULT ConsoleView::OnEraseBkgnd(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPa
LRESULT ConsoleView::OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
{
CriticalSectionLock lock(m_activeCritSec);
MutexLock activeLock(m_activeMutex);
if (!m_bActive) return 0;
}

Expand Down Expand Up @@ -656,7 +657,7 @@ LRESULT ConsoleView::OnTimer(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BO
if (wParam == FLASH_TAB_TIMER)
{
{
CriticalSectionLock lock(m_activeCritSec);
MutexLock activeLock(m_activeMutex);
// if we got activated, kill timer
if (m_bActive)
{
Expand All @@ -683,7 +684,7 @@ LRESULT ConsoleView::OnTimer(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BO
}

{
CriticalSectionLock lock(m_activeCritSec);
MutexLock activeLock(m_activeMutex);
if (!m_bActive) return 0;
}

Expand Down Expand Up @@ -987,7 +988,7 @@ void ConsoleView::RepaintView()
void ConsoleView::SetActive(bool bActive)
{
{
CriticalSectionLock lock(m_activeCritSec);
MutexLock activeLock(m_activeMutex);
m_bActive = bActive;
if (!m_bActive) return;
}
Expand Down Expand Up @@ -1178,7 +1179,7 @@ void ConsoleView::OnConsoleChange(bool bResize)
InitializeScrollbars();

{
CriticalSectionLock lock(m_activeCritSec);
MutexLock activeLock(m_activeMutex);
if (m_bActive) RecreateOffscreenBuffers();
}

Expand All @@ -1195,7 +1196,7 @@ void ConsoleView::OnConsoleChange(bool bResize)

// if the view is not visible, don't repaint
{
CriticalSectionLock lock(m_activeCritSec);
MutexLock activeLock(m_activeMutex);
if (!m_bActive)
{
if ((g_settingsHandler->GetBehaviorSettings().tabHighlightSettings.dwFlashes > 0) && (!m_bFlashTimerRunning))
Expand Down Expand Up @@ -1267,6 +1268,8 @@ void ConsoleView::OnConsoleClose()

void ConsoleView::CreateOffscreenBuffers()
{
MutexLock repaintLock(m_repaintMutex);

CWindowDC dcWindow(m_hWnd);
CRect rectWindowMax;
// CRect rectWindow;
Expand Down Expand Up @@ -1663,6 +1666,8 @@ void ConsoleView::RepaintText()
sizeof(CHAR_INFO) * consoleParams->dwRows * consoleParams->dwColumns);
}

MutexLock repaintLock(m_repaintMutex);

for (DWORD i = 0; i < consoleParams->dwRows; ++i)
{
dwX = stylesSettings.dwInsideBorder;
Expand Down Expand Up @@ -1793,6 +1798,7 @@ void ConsoleView::RepaintTextChanges()

SharedMemory<CHAR_INFO>& consoleBuffer = m_consoleHandler.GetConsoleBuffer();
SharedMemoryLock memLock(consoleBuffer);
MutexLock repaintLock(m_repaintMutex);

for (DWORD i = 0; i < m_consoleHandler.GetConsoleParams()->dwRows; ++i)
{
Expand Down
6 changes: 2 additions & 4 deletions Console/ConsoleView.h
Expand Up @@ -114,9 +114,6 @@ class ConsoleView
void ClearSelection();
void Paste();


CriticalSection& GetActiveCS() { return m_activeCritSec; }

void DumpBuffer();

private:
Expand Down Expand Up @@ -196,7 +193,8 @@ class ConsoleView

MouseSettings::Command m_mouseCommand;

CriticalSection m_activeCritSec;
Mutex m_repaintMutex;
Mutex m_activeMutex;

bool m_bFlashTimerRunning;
DWORD m_dwFlashes;
Expand Down
50 changes: 50 additions & 0 deletions Console/Helpers.h
Expand Up @@ -91,4 +91,54 @@ class CriticalSectionLock
CriticalSection& m_critSection;
};

//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////

class Mutex
{
public:
Mutex(SECURITY_ATTRIBUTES* pSecAttribs, BOOL bInitialOwner, LPCTSTR pszName)
: m_mutex(::CreateMutex(pSecAttribs, bInitialOwner, pszName), ::CloseHandle)
{
}

HANDLE get()
{
return static_cast<HANDLE>(m_mutex.get());
}

private:

shared_ptr<void> m_mutex;
};

//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////

class MutexLock
{
public:

explicit MutexLock(Mutex& mutex)
: m_mutex(mutex)
{
::WaitForSingleObject(m_mutex.get(), INFINITE);
}

~MutexLock()
{
::ReleaseMutex(m_mutex.get());
}

private:

Mutex& m_mutex;
};



//////////////////////////////////////////////////////////////////////////////
2 changes: 1 addition & 1 deletion Console/stdafx.h
Expand Up @@ -102,7 +102,7 @@ using namespace boost::multi_index;

#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_BUILD 135
#define VERSION_BUILD 136

//////////////////////////////////////////////////////////////////////////////

Expand Down
8 changes: 4 additions & 4 deletions ConsoleHook/ConsoleHook.rc
Expand Up @@ -53,8 +53,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,135
PRODUCTVERSION 2,0,0,135
FILEVERSION 2,0,0,136
PRODUCTVERSION 2,0,0,136
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -72,13 +72,13 @@ BEGIN
VALUE "Comments", "Tabbed cool console window (THIS IS NOT A SHELL :-)"
VALUE "CompanyName", "Ingenuity Unlimited Ltd."
VALUE "FileDescription", "Console process hook module"
VALUE "FileVersion", "2.00, Build 135 2007.11.26"
VALUE "FileVersion", "2.00, Build 136 2007.12.09"
VALUE "InternalName", "Console"
VALUE "LegalCopyright", "Copyright � 2001-2007 Marko Bozikovic"
VALUE "LegalTrademarks", "Copyright � 2001-2007 Marko Bozikovic"
VALUE "OriginalFilename", "Console.exe"
VALUE "ProductName", "Console"
VALUE "ProductVersion", "2.00.00.135"
VALUE "ProductVersion", "2.00.00.136"
END
END
BLOCK "VarFileInfo"
Expand Down
6 changes: 6 additions & 0 deletions devel_changes.txt
@@ -1,6 +1,12 @@
v2.00
=====

Build 136
---------

- [internal] attempt at fix text repainting problems reported by several users


Build 135
---------

Expand Down

0 comments on commit 3b7a336

Please sign in to comment.