forked from qt-creator/qt-creator
TextEditor: warm up fallback font cache on windows
Loading this fallback font cache takes around 300 ms the first time an editor is opened. Calling QFontMetrics::horizontalAdvance and passing 0x21B5 in another thread fills this cache before an editor get's opened and removes this delay for the first editor. Change-Id: I48c0e9b4e2466f37d064dbf854df5553b0e97ad4 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -48,6 +48,7 @@
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
#include <utils/async.h>
|
||||
#include <utils/fancylineedit.h>
|
||||
#include <utils/macroexpander.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -140,6 +141,14 @@ void TextEditorPlugin::initialize()
|
||||
#endif
|
||||
|
||||
Utils::Text::setCodeHighlighter(HighlighterHelper::highlightCode);
|
||||
|
||||
if (Utils::HostOsInfo::isWindowsHost()) {
|
||||
// warm up the fallback font cache on windows this reduces the startup time of the first
|
||||
// editor by around 300 ms
|
||||
Utils::asyncRun([font = QPlainTextEdit().font()]() {
|
||||
QFontMetrics(font).horizontalAdvance(QChar(0x21B5));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void TextEditorPlugin::extensionsInitialized()
|
||||
|
Reference in New Issue
Block a user