Autoclose a FILE* if we open it

Task-number: QTBUG-105736
Change-Id: I2bc10b54b77436cad914ec21fd85678c54de4305
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit f7559904d0e8f7966e726fd04801cb58a1bd4a2d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Ville Voutilainen 2022-12-19 13:36:47 +02:00 committed by Qt Cherry-pick Bot
parent 1ae9caec79
commit 5bed8322eb

View File

@ -2627,7 +2627,7 @@ static void unixPipe_helper(int pipes[2])
QFile f;
if (useStdio) {
FILE *fh = fdopen(pipes[0], "rb");
QVERIFY(f.open(fh, QIODevice::ReadOnly | QIODevice::Unbuffered));
QVERIFY(f.open(fh, QIODevice::ReadOnly | QIODevice::Unbuffered, QFileDevice::AutoCloseHandle));
} else {
QVERIFY(f.open(pipes[0], QIODevice::ReadOnly | QIODevice::Unbuffered));
}
@ -2651,10 +2651,6 @@ void tst_QFile::unixPipe_data()
void tst_QFile::unixPipe()
{
#ifdef Q_OS_ANDROID
if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
QSKIP("Crashes on Android 12 (QTBUG-105736)");
#endif
int pipes[2] = { -1, -1 };
QVERIFY2(pipe(pipes) == 0, qPrintable(qt_error_string()));
unixPipe_helper(pipes);
@ -2664,10 +2660,6 @@ void tst_QFile::unixPipe()
void tst_QFile::socketPair()
{
#ifdef Q_OS_ANDROID
if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
QSKIP("Crashes on Android 12 (QTBUG-105736)");
#endif
int pipes[2] = { -1, -1 };
QVERIFY2(socketpair(AF_UNIX, SOCK_STREAM, 0, pipes) == 0, qPrintable(qt_error_string()));
unixPipe_helper(pipes);