Skip to content

Commit

Permalink
workaround for Qt bug in contentsChange signal params, see https://bu…
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Oct 27, 2015
1 parent 8f6be1c commit ad21781
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
12 changes: 6 additions & 6 deletions MSVC.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ or download in ZIP and extract to **D:\TBuild\**, rename **tdesktop-master** to

####OpenSSL

Open **VS2015 x86 Native Tools Command Prompt.bat** (should be in **\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\Shortcuts\\** folder), go to **D:\\TBuild\\Libraries** and run
Open **VS2015 x86 Native Tools Command Prompt.bat** (should be in **Start Menu > Programs > Visual Studio 2015** menu folder), go to **D:\\TBuild\\Libraries** and run

git clone https://github.com/openssl/openssl.git
cd openssl
Expand Down Expand Up @@ -89,7 +89,7 @@ or download in ZIP and extract to **D:\TBuild\Libraries\**, rename **libexif-0.6

####OpenAL Soft, slightly patched

Open **VS2015 x86 Native Tools Command Prompt.bat** (should be in **\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\Shortcuts\\** folder), go to **D:\\TBuild\\Libraries** and run
Open **VS2015 x86 Native Tools Command Prompt.bat** (should be in **Start Menu > Programs > Visual Studio 2015** menu folder), go to **D:\\TBuild\\Libraries** and run

git clone git://repo.or.cz/openal-soft.git
git checkout 90349b38
Expand All @@ -98,7 +98,7 @@ Open **VS2015 x86 Native Tools Command Prompt.bat** (should be in **\\Program Fi
#####Building library

* Install [CMake](http://www.cmake.org/)
* Open **VS2015 x86 Native Tools Command Prompt.bat** (should be in **\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\Shortcuts\\** folder), go to **D:\TBuild\Libraries\openal-soft\build\** and run
* Open **VS2015 x86 Native Tools Command Prompt.bat** (should be in **Start Menu > Programs > Visual Studio 2015** menu folder), go to **D:\TBuild\Libraries\openal-soft\build\** and run

cmake -G "Visual Studio 14 2015" -D LIBTYPE:STRING=STATIC -D FORCE_STATIC_VCRT:STRING=ON ..

Expand All @@ -120,7 +120,7 @@ to have **D:\TBuild\Libraries\opus\win32**

####FFmpeg

Open **VS2015 x86 Native Tools Command Prompt.bat** (should be in **\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\Shortcuts\\** folder) and run
Open **VS2015 x86 Native Tools Command Prompt.bat** (should be in **Start Menu > Programs > Visual Studio 2015** menu folder) and run

git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg
cd ffmpeg
Expand All @@ -132,7 +132,7 @@ http://msys2.github.io/ > Download [msys2-x86_64-20150512.exe](http://sourceforg

Download [yasm for Win64](http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win64.exe) from http://yasm.tortall.net/Download.html, rename **yasm-1.3.0-win64.exe** to **yasm.exe** and place it to your Visual C++ **bin** directory, like **\\Program Files (x86)\\Microsoft Visual Studio 14\\VC\\bin\\**

Open **VS2015 x86 Native Tools Command Prompt.bat** (should be in **\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\Shortcuts\\** folder), go to **D:\\msys64\\** and launch **msys2_shell.bat**, there run
Open **VS2015 x86 Native Tools Command Prompt.bat** (should be in **Start Menu > Programs > Visual Studio 2015** menu folder), go to **D:\\msys64\\** and launch **msys2_shell.bat**, there run

PATH="/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/BIN:$PATH"

Expand All @@ -153,7 +153,7 @@ Open **VS2015 x86 Native Tools Command Prompt.bat** (should be in **\\Program Fi
####Qt 5.5.1, slightly patched

* Install Python 3.3.2 from https://www.python.org/download/releases/3.3.2 > [**Windows x86 MSI Installer (3.3.2)**](https://www.python.org/ftp/python/3.3.2/python-3.3.2.msi)
* Open **VS2015 x86 Native Tools Command Prompt.bat** (should be in **\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\Shortcuts\\** folder)
* Open **VS2015 x86 Native Tools Command Prompt.bat** (should be in **Start Menu > Programs > Visual Studio 2015** menu folder)

There go to Libraries directory

Expand Down
28 changes: 22 additions & 6 deletions Telegram/SourceFiles/gui/flatinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,9 +970,17 @@ void InputArea::onDocumentContentsChange(int position, int charsRemoved, int cha
QString oldtext(_oldtext);
QTextCursor(_inner.document()->docHandle(), 0).joinPreviousEditBlock();

QTextCursor c(_inner.document()->docHandle(), 0);
c.movePosition(QTextCursor::End);
int pos = c.position();
if (!position) { // Qt bug workaround https://bugreports.qt.io/browse/QTBUG-49062
QTextCursor c(_inner.document()->docHandle(), 0);
c.movePosition(QTextCursor::End);
if (position + charsAdded > c.position()) {
int32 toSubstract = position + charsAdded - c.position();
if (charsRemoved >= toSubstract) {
charsAdded -= toSubstract;
charsRemoved -= toSubstract;
}
}
}

_correcting = true;
if (_maxLength >= 0) {
Expand Down Expand Up @@ -1645,9 +1653,17 @@ void InputField::onDocumentContentsChange(int position, int charsRemoved, int ch
QString oldtext(_oldtext);
QTextCursor(_inner.document()->docHandle(), 0).joinPreviousEditBlock();

QTextCursor c(_inner.document()->docHandle(), 0);
c.movePosition(QTextCursor::End);
int pos = c.position();
if (!position) { // Qt bug workaround https://bugreports.qt.io/browse/QTBUG-49062
QTextCursor c(_inner.document()->docHandle(), 0);
c.movePosition(QTextCursor::End);
if (position + charsAdded > c.position()) {
int32 toSubstract = position + charsAdded - c.position();
if (charsRemoved >= toSubstract) {
charsAdded -= toSubstract;
charsRemoved -= toSubstract;
}
}
}

_correcting = true;
if (_maxLength >= 0) {
Expand Down

0 comments on commit ad21781

Please sign in to comment.