From d089a60bf7c22eb28d562de1786577c799b7d5ab Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Sun, 5 Jul 2020 15:22:50 +0200 Subject: [PATCH] Fix executing selected SQL text when there are multi-byte characters Fix executing the selected SQL statement(s) when there are multi-byte characters before the selection. Because QScintilla gives us the start position of the selection in bytes and we used the value for counting characters, the executed part of the text was off by a few characters. See issue #2311. --- src/MainWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index a997d221..f57d2c16 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -1115,7 +1115,7 @@ void MainWindow::executeQuery() // no chance to execute any further. QString sql = sqlWidget->getSql(); if(mode == Selection) - sql = sql.left(execute_to_position); + sql = sql.toUtf8().left(execute_to_position); // We have to convert to a QByteArray here because QScintilla gives us the position in bytes, not in characters. // Prepare the SQL worker to run the query. We set the context of each signal-slot connection to the current SQL execution area. // This means that if the tab is closed all these signals are automatically disconnected so the lambdas won't be called for a not