使用 Qt 的静态版本编译时文件对话框崩溃
File dialogs crash when compiling with static version of Qt
我有一个带有 C++ Qt 前端的 Rust 项目。我用静态版本的 Qt 在 Mint 19 上编译了 Linux 版本。 Qt 安装程序通知我 (https://github.com/spieglt/Cloaker/issues/2) that the file dialog crashes when selecting Computer
in the left sidebar or typing /
as a path. I found that the file dialog I see when using the static version of Qt (https://imgur.com/a/4grBpVY) is different from the one I see when compiling with the standard, dynamically linked version (https://imgur.com/a/lzhOnkA)。
用户机器上的输出是:
./Cloaker.run
QApplication: invalid style override passed, ignoring it.
Available styles: Windows, Fusion
Case insensitive sorting unsupported in the posix collation implementation
Numeric mode unsupported in the posix collation implementation
Case insensitive sorting unsupported in the posix collation implementation
Numeric mode unsupported in the posix collation implementation
Case insensitive sorting unsupported in the posix collation implementation
Numeric mode unsupported in the posix collation implementation
Segmentation fault (core dumped)
我尝试在 Ubuntu 上使用 Qt 的静态版本进行编译。当我这样做时,出现损坏的文件对话框时程序不会崩溃,但是 Computer
是侧面和顶部栏中唯一没有变灰的项目,输出是
QPixmap::scaleWidth: Pixmap is a null pixmap
QPixmap::scaleWidth: Pixmap is a null pixmap
QPixmap::scaleWidth: Pixmap is a null pixmap
QPixmap::scaleWidth: Pixmap is a null pixmap
Case insensitive sorting unsupported in the posix collation implementation
Numeric mode unsupported in the posix collation implementation
QPixmap::scaleWidth: Pixmap is a null pixmap
QPixmap::scaleWidth: Pixmap is a null pixmap
QPixmap::scaleWidth: Pixmap is a null pixmap
Case insensitive sorting unsupported in the posix collation implementation
Numeric mode unsupported in the posix collation implementation
Case insensitive sorting unsupported in the posix collation implementation
Numeric mode unsupported in the posix collation implementation
Empty filename passed to function
QPainter::begin: Paint device returned engine == 0, type: 3
QPainter::setCompositionMode: Painter not active
QPainter::end: Painter not active, aborted
Case insensitive sorting unsupported in the posix collation implementation
Numeric mode unsupported in the posix collation implementation
原始Mint配置命令:
~/Qt/5.12.3/Src/configure -prefix ~/qt-static/5.12.3 -static -release -opensource -confirm-license -skip multimedia -no-compile-examples -nomake examples -no-openssl -no-libpng -skip wayland -qt-xcb
Ubuntu 配置命令:
~/Qt/5.13.0/Src/configure -static -release -prefix ~/qt-static/install -opensource -confirm-license -no-compile-examples -nomake examples -no-openssl -no-libpng -fontconfig
文件对话框代码:
if (mode == Encrypt) { // encrypt, append extension
inFile += QString::fromUtf8(FILE_EXTENSION);
return QFileDialog::getSaveFileName(nullptr, "Save encrypted file", inFile, "", nullptr, QFileDialog::DontConfirmOverwrite);
} else { // decrypt, chop off extension if there, otherwise prepend decrypted.
if (inFile.endsWith(FILE_EXTENSION, Qt::CaseInsensitive)) {
inFile = inFile.left(inFile.length() - strlen(FILE_EXTENSION));
} else {
inFile += QString::fromUtf8("_decrypted");
}
// save as dialog, return path
return QFileDialog::getSaveFileName(nullptr, "Save decrypted file", inFile, "", nullptr, QFileDialog::DontConfirmOverwrite);
}
如果可能的话,我想在静态链接 Qt 时获得正常的 GNOME 文件对话框。如果这不可能,AppImage 会不会有同样的问题?
原来我刚刚错误地构建了 Qt 的静态版本。要在 Mint 上使用工作文件对话框(Qt Widgets,QFileDialog-style;不是 GTK-style)构建静态 Qt:
$ mkdir ~/qt-static && cd ~/qt-static
$ mkdir build install; cd build
$ ~/Qt/5.12.3/Src/configure -prefix ~/qt-static/install -static -release -opensource -confirm-license -skip multimedia -skip webengine -skip wayland -no-compile-examples -nomake examples -no-openssl -ico -gtk -gif -qt-xcb
$ make -j8
Ubuntu 除了没有 -qt-xcb
和有 -fontconfig
.
之外是一样的
我有一个带有 C++ Qt 前端的 Rust 项目。我用静态版本的 Qt 在 Mint 19 上编译了 Linux 版本。 Qt 安装程序通知我 (https://github.com/spieglt/Cloaker/issues/2) that the file dialog crashes when selecting Computer
in the left sidebar or typing /
as a path. I found that the file dialog I see when using the static version of Qt (https://imgur.com/a/4grBpVY) is different from the one I see when compiling with the standard, dynamically linked version (https://imgur.com/a/lzhOnkA)。
用户机器上的输出是:
./Cloaker.run
QApplication: invalid style override passed, ignoring it.
Available styles: Windows, Fusion
Case insensitive sorting unsupported in the posix collation implementation
Numeric mode unsupported in the posix collation implementation
Case insensitive sorting unsupported in the posix collation implementation
Numeric mode unsupported in the posix collation implementation
Case insensitive sorting unsupported in the posix collation implementation
Numeric mode unsupported in the posix collation implementation
Segmentation fault (core dumped)
我尝试在 Ubuntu 上使用 Qt 的静态版本进行编译。当我这样做时,出现损坏的文件对话框时程序不会崩溃,但是 Computer
是侧面和顶部栏中唯一没有变灰的项目,输出是
QPixmap::scaleWidth: Pixmap is a null pixmap
QPixmap::scaleWidth: Pixmap is a null pixmap
QPixmap::scaleWidth: Pixmap is a null pixmap
QPixmap::scaleWidth: Pixmap is a null pixmap
Case insensitive sorting unsupported in the posix collation implementation
Numeric mode unsupported in the posix collation implementation
QPixmap::scaleWidth: Pixmap is a null pixmap
QPixmap::scaleWidth: Pixmap is a null pixmap
QPixmap::scaleWidth: Pixmap is a null pixmap
Case insensitive sorting unsupported in the posix collation implementation
Numeric mode unsupported in the posix collation implementation
Case insensitive sorting unsupported in the posix collation implementation
Numeric mode unsupported in the posix collation implementation
Empty filename passed to function
QPainter::begin: Paint device returned engine == 0, type: 3
QPainter::setCompositionMode: Painter not active
QPainter::end: Painter not active, aborted
Case insensitive sorting unsupported in the posix collation implementation
Numeric mode unsupported in the posix collation implementation
原始Mint配置命令:
~/Qt/5.12.3/Src/configure -prefix ~/qt-static/5.12.3 -static -release -opensource -confirm-license -skip multimedia -no-compile-examples -nomake examples -no-openssl -no-libpng -skip wayland -qt-xcb
Ubuntu 配置命令:
~/Qt/5.13.0/Src/configure -static -release -prefix ~/qt-static/install -opensource -confirm-license -no-compile-examples -nomake examples -no-openssl -no-libpng -fontconfig
文件对话框代码:
if (mode == Encrypt) { // encrypt, append extension
inFile += QString::fromUtf8(FILE_EXTENSION);
return QFileDialog::getSaveFileName(nullptr, "Save encrypted file", inFile, "", nullptr, QFileDialog::DontConfirmOverwrite);
} else { // decrypt, chop off extension if there, otherwise prepend decrypted.
if (inFile.endsWith(FILE_EXTENSION, Qt::CaseInsensitive)) {
inFile = inFile.left(inFile.length() - strlen(FILE_EXTENSION));
} else {
inFile += QString::fromUtf8("_decrypted");
}
// save as dialog, return path
return QFileDialog::getSaveFileName(nullptr, "Save decrypted file", inFile, "", nullptr, QFileDialog::DontConfirmOverwrite);
}
如果可能的话,我想在静态链接 Qt 时获得正常的 GNOME 文件对话框。如果这不可能,AppImage 会不会有同样的问题?
原来我刚刚错误地构建了 Qt 的静态版本。要在 Mint 上使用工作文件对话框(Qt Widgets,QFileDialog-style;不是 GTK-style)构建静态 Qt:
$ mkdir ~/qt-static && cd ~/qt-static
$ mkdir build install; cd build
$ ~/Qt/5.12.3/Src/configure -prefix ~/qt-static/install -static -release -opensource -confirm-license -skip multimedia -skip webengine -skip wayland -no-compile-examples -nomake examples -no-openssl -ico -gtk -gif -qt-xcb
$ make -j8
Ubuntu 除了没有 -qt-xcb
和有 -fontconfig
.