Skip to content

Commit

Permalink
ui/initApp(): remove temporary QApplication object (commaai#32011)
Browse files Browse the repository at this point in the history
remove temporary QApplication object
  • Loading branch information
deanlee authored Mar 27, 2024
1 parent fad9edf commit bd7b72e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions selfdrive/ui/qt/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,21 @@ void initApp(int argc, char *argv[], bool disable_hidpi) {
std::signal(SIGINT, sigTermHandler);
std::signal(SIGTERM, sigTermHandler);

if (disable_hidpi) {
QString app_dir;
#ifdef __APPLE__
// Get the devicePixelRatio, and scale accordingly to maintain 1:1 rendering
QApplication tmp(argc, argv);
qputenv("QT_SCALE_FACTOR", QString::number(1.0 / tmp.devicePixelRatio() ).toLocal8Bit());
#endif
// Get the devicePixelRatio, and scale accordingly to maintain 1:1 rendering
QApplication tmp(argc, argv);
app_dir = QCoreApplication::applicationDirPath();
if (disable_hidpi) {
qputenv("QT_SCALE_FACTOR", QString::number(1.0 / tmp.devicePixelRatio()).toLocal8Bit());
}
#else
app_dir = QFileInfo(util::readlink("/proc/self/exe").c_str()).path();
#endif

qputenv("QT_DBL_CLICK_DIST", QByteArray::number(150));

// ensure the current dir matches the exectuable's directory
QApplication tmp(argc, argv);
QString appDir = QCoreApplication::applicationDirPath();
QDir::setCurrent(appDir);
QDir::setCurrent(app_dir);

setQtSurfaceFormat();
}
Expand Down

0 comments on commit bd7b72e

Please sign in to comment.