Files
haikuports/dev-qt/qt5/patches/qtbase-5.15.16.patchset
Máximo Castañeda 88df714922 Qt5: support for variable fonts (#11621)
* Qt5: support for variable fonts

* qthaikuplugins: bump version
2025-04-26 15:34:39 -04:00

1873 lines
58 KiB
Plaintext

From 7e6551df2576d0ad18d4dffee19c14eca4c80f77 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Mon, 11 Feb 2019 15:53:49 +1000
Subject: Make sure libs are searched in the develop/ dir by CMake
Static libs at least are not in the lib[/x86] dirs...
diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
index 64639f1..42ad698 100644
--- a/mkspecs/features/create_cmake.prf
+++ b/mkspecs/features/create_cmake.prf
@@ -112,6 +112,9 @@ win32:!static:!staticlib {
CMAKE_DLL_DIR = $$[QT_INSTALL_BINS]/
CMAKE_DLL_DIR_IS_ABSOLUTE = True
}
+} else:haiku {
+ CMAKE_DLL_DIR = develop/$$CMAKE_LIB_DIR
+ CMAKE_DLL_DIR_IS_ABSOLUTE = $$CMAKE_LIB_DIR_IS_ABSOLUTE
} else {
CMAKE_DLL_DIR = $$CMAKE_LIB_DIR
CMAKE_DLL_DIR_IS_ABSOLUTE = $$CMAKE_LIB_DIR_IS_ABSOLUTE
--
2.45.2
From 050fd9d8f0b42a1bbea702aba4eb9c6a9ce86733 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 11 Feb 2019 15:55:08 +1000
Subject: Disable built-in haiku QPA plugin
diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro
index 23f838a..8ef1812 100644
--- a/src/plugins/platforms/platforms.pro
+++ b/src/plugins/platforms/platforms.pro
@@ -42,10 +42,6 @@ freebsd {
SUBDIRS += bsdfb
}
-haiku {
- SUBDIRS += haiku
-}
-
wasm: SUBDIRS += wasm
qtConfig(integrityfb): SUBDIRS += integrity
--
2.45.2
From ed94085d15b55d33760d439b8ce37f72fe588461 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 11 Feb 2019 15:56:12 +1000
Subject: Fix QStandartPaths for Haiku
diff --git a/src/corelib/io/qstandardpaths_haiku.cpp b/src/corelib/io/qstandardpaths_haiku.cpp
index 044d69f..1f255a9 100644
--- a/src/corelib/io/qstandardpaths_haiku.cpp
+++ b/src/corelib/io/qstandardpaths_haiku.cpp
@@ -145,22 +145,22 @@ QString QStandardPaths::writableLocation(StandardLocation type)
return haikuStandardPath(B_USER_NONPACKAGED_BIN_DIRECTORY);
case TempLocation:
return haikuStandardPath(B_SYSTEM_TEMP_DIRECTORY);
- case AppDataLocation: // fall through
+ case AppDataLocation:
+ return haikuAppStandardPath(B_SYSTEM_CACHE_DIRECTORY);
case AppLocalDataLocation:
- return haikuAppStandardPath(B_USER_NONPACKAGED_DATA_DIRECTORY);
+ return haikuAppStandardPath(B_USER_CACHE_DIRECTORY);
case GenericDataLocation:
- return haikuStandardPath(B_USER_NONPACKAGED_DATA_DIRECTORY);
+ return haikuAppStandardPath(B_SYSTEM_CACHE_DIRECTORY);
case CacheLocation:
return haikuAppStandardPath(B_USER_CACHE_DIRECTORY);
case GenericCacheLocation:
- return haikuStandardPath(B_USER_CACHE_DIRECTORY);
- case ConfigLocation: // fall through
+ return haikuStandardPath(B_SYSTEM_CACHE_DIRECTORY);
+ case ConfigLocation:
case AppConfigLocation:
- return haikuAppStandardPath(B_USER_SETTINGS_DIRECTORY);
case GenericConfigLocation:
- return haikuStandardPath(B_USER_SETTINGS_DIRECTORY);
+ return haikuAppStandardPath(B_USER_SETTINGS_DIRECTORY);
default:
- return QString();
+ return haikuAppStandardPath(B_USER_SETTINGS_DIRECTORY);
}
}
@@ -179,7 +179,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
case MoviesLocation:
case DownloadLocation:
case HomeLocation:
- paths += haikuStandardPath(B_USER_NONPACKAGED_DIRECTORY);
+ paths += haikuStandardPath(B_USER_DIRECTORY);
break;
case FontsLocation:
paths += haikuStandardPaths(B_FIND_PATH_FONTS_DIRECTORY);
@@ -203,7 +203,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
break;
case ConfigLocation: // fall through
case AppConfigLocation:
- paths += haikuAppStandardPath(B_SYSTEM_SETTINGS_DIRECTORY);
+ paths += haikuAppStandardPath(B_USER_SETTINGS_DIRECTORY);
break;
case GenericConfigLocation:
paths += haikuStandardPath(B_SYSTEM_SETTINGS_DIRECTORY);
--
2.45.2
From 23ef7e631daeca831cd42b60a830fa063a5c2609 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 11 Feb 2019 15:56:39 +1000
Subject: QSslSocketPrivate::unixRootCertDirectories(): add ssl path for Haiku.
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index 2a0b3a4..e0a1d6f 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -2963,6 +2963,7 @@ QList<QByteArray> QSslSocketPrivate::unixRootCertDirectories()
<< "/usr/local/ssl/certs/" // Solaris
<< "/etc/openssl/certs/" // BlackBerry
<< "/opt/openssl/certs/" // HP-UX
+ << "/system/data/ssl/" // Haiku
<< "/etc/ssl/"; // OpenBSD
}
--
2.45.2
From f90f3c207147152ea4421c7f2368f97b7ab059f2 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 11 Feb 2019 15:56:59 +1000
Subject: Fix build for Haiku platform
diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf
index c70f279..15e5ad5 100644
--- a/mkspecs/features/toolchain.prf
+++ b/mkspecs/features/toolchain.prf
@@ -263,7 +263,7 @@ isEmpty($${target_prefix}.INCDIRS) {
}
}
}
- if(!darwin:clang)|intel_icc {
+ if(!darwin:clang)|haiku|intel_icc {
# Clang on a non-Apple system (that is, a system without ld64 -- say, with GNU ld
# or gold under Linux) will not print any library search path. Need to use another
# invocation with different options (which in turn doesn't print include search
--
2.45.2
From 347cbf52d1f6b3f730b24a25693043c7be415b40 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 11 Feb 2019 15:57:54 +1000
Subject: Fix endian detection
diff --git a/src/3rdparty/sha3/brg_endian.h b/src/3rdparty/sha3/brg_endian.h
index 9bb306e..9f0ea58 100644
--- a/src/3rdparty/sha3/brg_endian.h
+++ b/src/3rdparty/sha3/brg_endian.h
@@ -39,10 +39,10 @@ Changes for ARM 9/9/2010 [Downstream relative to Gladman's GitHub, upstream to Q
#elif defined( BSD ) && ( BSD >= 199103 ) || defined( __APPLE__ ) || \
defined( __CYGWIN32__ ) || defined( __DJGPP__ ) || defined( __osf__ )
# include <machine/endian.h>
-#elif defined( __linux__ ) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
+#elif defined( __linux__ ) || defined( __HAIKU__ ) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
# if !defined( __MINGW32__ ) && !defined( _AIX ) && !defined(Q_OS_QNX)
# include <endian.h>
-# if !defined( __BEOS__ ) && !defined(Q_OS_RTEMS)
+# if !defined( __BEOS__ ) && !defined( __HAIKU__ ) && !defined(Q_OS_RTEMS)
# include <byteswap.h>
# endif
# endif
--
2.45.2
From a106f9e82c6675a326f17926affa5e98b730df86 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sat, 27 Apr 2019 17:47:23 +1000
Subject: Add dnslookup query function for Haiku
diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri
index 7282e20..d2faef3 100644
--- a/src/network/kernel/kernel.pri
+++ b/src/network/kernel/kernel.pri
@@ -54,6 +54,11 @@ android:qtConfig(dnslookup) {
SOURCES += kernel/qdnslookup_android.cpp
}
+haiku:qtConfig(dnslookup) {
+ SOURCES -= kernel/qdnslookup_unix.cpp
+ SOURCES += kernel/qdnslookup_haiku.cpp
+}
+
win32: {
SOURCES += kernel/qhostinfo_win.cpp
diff --git a/src/network/kernel/qdnslookup_haiku.cpp b/src/network/kernel/qdnslookup_haiku.cpp
new file mode 100644
index 0000000..0b387df
--- /dev/null
+++ b/src/network/kernel/qdnslookup_haiku.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Gerasim Troeglazov <3dEyes@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdnslookup_p.h"
+
+QT_BEGIN_NAMESPACE
+
+void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, const QHostAddress &nameserver, QDnsLookupReply *reply)
+{
+ Q_UNUSED(requestType);
+ Q_UNUSED(requestName);
+ Q_UNUSED(nameserver);
+ Q_UNUSED(reply);
+ qWarning("Not yet supported on Haiku");
+ reply->error = QDnsLookup::ResolverError;
+ reply->errorString = tr("Not yet supported on Haiku");
+ return;
+}
+
+QT_END_NAMESPACE
--
2.45.2
From d7412e7ed6c3fe5e7724a1318f1232d321826d26 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 27 May 2020 19:54:30 +1000
Subject: Disable LibResolv for Haiku
diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index 73679c9..73ce64c 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -87,7 +87,7 @@ typedef void (*res_nclose_proto)(res_state_ptr);
static res_nclose_proto local_res_nclose = nullptr;
static res_state_ptr local_res = nullptr;
-#if QT_CONFIG(library) && !defined(Q_OS_QNX)
+#if QT_CONFIG(library) && !defined(Q_OS_QNX) && !defined(Q_OS_HAIKU)
namespace {
struct LibResolv
{
--
2.45.2
From fc735f0e89c28fb13e605345c78b8b3b9c0c183d Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 8 Sep 2019 00:17:19 +1000
Subject: Don't use ifaddrs for Haiku
diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp
index e7889b6..1036ead 100644
--- a/src/network/kernel/qnetworkinterface_unix.cpp
+++ b/src/network/kernel/qnetworkinterface_unix.cpp
@@ -51,7 +51,7 @@
# include "qdatetime.h"
#endif
-#if defined(QT_LINUXBASE)
+#if defined(QT_LINUXBASE) || defined(Q_OS_HAIKU)
# define QT_NO_GETIFADDRS
#endif
--
2.45.2
From 53679486a79d43ecd5921c661463a25b2b26b86e Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 8 Sep 2019 18:32:05 +1000
Subject: Add platform plugins installer
diff --git a/src/gui/gui.pro b/src/gui/gui.pro
index 20372d9..803e9b7 100644
--- a/src/gui/gui.pro
+++ b/src/gui/gui.pro
@@ -35,6 +35,7 @@ testcocoon {
osx: LIBS_PRIVATE += -framework AppKit
darwin: LIBS_PRIVATE += -framework CoreGraphics
+haiku: LIBS_PRIVATE += -lbe
CONFIG += simd optimize_full
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index c7ff2a6..4d83bdc 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -116,6 +116,11 @@
# include <QtCore/QLibraryInfo>
#endif // Q_OS_WIN
+#if defined(Q_OS_HAIKU)
+#include <Application.h>
+#include <Alert.h>
+#endif
+
#ifdef Q_OS_WASM
#include <emscripten.h>
#endif
@@ -1245,6 +1250,27 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString
if (!availablePlugins.isEmpty())
fatalMessage += QStringLiteral("\nAvailable platform plugins are: %1.\n").arg(availablePlugins.join(QLatin1String(", ")));
+#if defined(Q_OS_HAIKU)
+ BApplication bApp("application/x-vnd.qt5-qtbase");
+ QString errorMessage = QStringLiteral("Qt platform plugins package is required but not installed.\n\n"
+ "Do you want to install it now?");
+ int32 index = (new BAlert("Error", errorMessage.toUtf8().constData(),
+ "Install", "Cancel", NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go();
+ if (index == 0) {
+#if defined(__INTEL__) && defined(__i386__) && !defined(__x86_64__)
+ int ret = system ("pkgman install qthaikuplugins_x86 -y");
+#else
+ int ret = system ("pkgman install qthaikuplugins -y");
+#endif
+ if (ret == 0)
+ (new BAlert("Information", "Platform plugins has been succesfully installed.\nTry running this application again.",
+ "Ok", NULL, NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT))->Go();
+ else
+ (new BAlert("Error", "Platform plugins is not installed.", "Close", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go();
+ }
+ exit(-1);
+#endif // Q_OS_HAIKU
+
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
// Windows: Display message box unless it is a console application
// or debug build showing an assert box.
--
2.45.2
From 502881f3ee60c5d396a8ccb19b320553701a5bc0 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 27 May 2020 19:54:58 +1000
Subject: Disable sharedmemory feature for bootstrap
diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro
index 24862a0..0d6df52 100644
--- a/src/tools/bootstrap/bootstrap.pro
+++ b/src/tools/bootstrap/bootstrap.pro
@@ -11,7 +11,8 @@ MODULE_DEFINES = \
QT_VERSION_MINOR=$$QT_MINOR_VERSION \
QT_VERSION_PATCH=$$QT_PATCH_VERSION \
QT_BOOTSTRAPPED \
- QT_NO_CAST_TO_ASCII
+ QT_NO_CAST_TO_ASCII \
+ QT_NO_SHAREDMEMORY
MODULE_CONFIG = gc_binaries
DEFINES += \
--
2.45.2
From cb38eeef587d95ca1ec83aeeacfcb4c363814e0b Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 29 Dec 2019 18:13:19 +1000
Subject: Fix build for x86_gcc2
diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c
index b663b8a..5ad2b12 100644
--- a/src/3rdparty/forkfd/forkfd.c
+++ b/src/3rdparty/forkfd/forkfd.c
@@ -719,7 +719,7 @@ int forkfd(int flags, pid_t *ppid)
/* parent process */
info->deathPipe = death_pipe[1];
fd = death_pipe[0];
- ffd_atomic_store(&info->pid, pid, FFD_ATOMIC_RELEASE);
+ ffd_atomic_store(&info->pid, (int32_t)pid, FFD_ATOMIC_RELEASE);
/* release the child */
#ifdef HAVE_EVENTFD
--
2.45.2
From b1b25397ddd0322ca3b720d9180dc093f2503551 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Thu, 4 Jun 2020 23:11:17 +1000
Subject: Implement QFilesystemWatcher for Haiku
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index a33ffe7..91190d4 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -96,6 +96,9 @@ qtConfig(filesystemwatcher) {
} else:macos {
OBJECTIVE_SOURCES += io/qfilesystemwatcher_fsevents.mm
HEADERS += io/qfilesystemwatcher_fsevents_p.h
+ } else:haiku {
+ SOURCES += io/qfilesystemwatcher_haiku.cpp
+ HEADERS += io/qfilesystemwatcher_haiku_p.h
} else:qtConfig(inotify) {
SOURCES += io/qfilesystemwatcher_inotify.cpp
HEADERS += io/qfilesystemwatcher_inotify_p.h
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index 96d9210..f6147de 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -54,6 +54,8 @@
#include "qfilesystemwatcher_polling_p.h"
#if defined(Q_OS_WIN)
# include "qfilesystemwatcher_win_p.h"
+#elif defined(Q_OS_HAIKU)
+# include "qfilesystemwatcher_haiku_p.h"
#elif defined(USE_INOTIFY)
# include "qfilesystemwatcher_inotify_p.h"
#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(QT_PLATFORM_UIKIT)
@@ -73,6 +75,8 @@ QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject
{
#if defined(Q_OS_WIN)
return new QWindowsFileSystemWatcherEngine(parent);
+#elif defined(Q_OS_HAIKU)
+ return new QHaikuFileSystemWatcherEngine(parent);
#elif defined(USE_INOTIFY)
// there is a chance that inotify may fail on Linux pre-2.6.13 (August
// 2005), so we can't just new inotify directly.
diff --git a/src/corelib/io/qfilesystemwatcher_haiku.cpp b/src/corelib/io/qfilesystemwatcher_haiku.cpp
new file mode 100644
index 0000000..8355ca8
--- /dev/null
+++ b/src/corelib/io/qfilesystemwatcher_haiku.cpp
@@ -0,0 +1,254 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2015-2020 Gerasim Troeglazov,
+** Contact: 3dEyes@gmail.com
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "qfilesystemwatcher_haiku_p.h"
+#include <QtCore/qscopeguard.h>
+#include <QtCore/qtimer.h>
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+QHaikuFileWatcher::QHaikuFileWatcher() : QObject(), BLooper() {};
+QHaikuDirWatcher::QHaikuDirWatcher() : QObject(), BLooper() {};
+
+QHaikuFileSystemWatcherEngine::QHaikuFileSystemWatcherEngine(QObject *parent)
+ : QFileSystemWatcherEngine(parent)
+{
+ fileLooper = new QHaikuFileWatcher();
+ connect(fileLooper, SIGNAL(fileChanged(const QString &, bool)), SLOT(bfsFileChanged(const QString &, bool)));
+ fileLooper->Run();
+
+ dirLooper = new QHaikuDirWatcher();
+ connect(dirLooper, SIGNAL(directoryChanged(const QString &, bool)), SLOT(bfsDirectoryChanged(const QString &, bool)));
+ dirLooper->Run();
+}
+
+QHaikuFileSystemWatcherEngine::~QHaikuFileSystemWatcherEngine()
+{
+ stop_watching(fileLooper);
+ if (fileLooper->Lock())
+ fileLooper->Quit();
+
+ stop_watching(dirLooper);
+ if (dirLooper->Lock())
+ dirLooper->Quit();
+}
+
+QStringList QHaikuFileSystemWatcherEngine::addPaths(const QStringList &paths,
+ QStringList *files,
+ QStringList *directories)
+{
+ QStringList unhandled;
+ for (const QString &path : paths) {
+ QFileInfo fi(path);
+ bool isDir = fi.isDir();
+ auto sg = qScopeGuard([&]{ unhandled.push_back(path); });
+ if (isDir) {
+ if (directories->contains(path))
+ continue;
+ } else {
+ if (files->contains(path))
+ continue;
+ }
+
+ BEntry entry(path.toUtf8().constData());
+ if (!entry.Exists())
+ continue;
+
+ node_ref nref;
+ entry.GetNodeRef(&nref);
+ status_t status = isDir ?
+ watch_node(&nref, (B_WATCH_NAME | B_WATCH_ATTR | B_WATCH_STAT | B_WATCH_DIRECTORY), dirLooper):
+ watch_node(&nref, (B_WATCH_NAME | B_WATCH_ATTR | B_WATCH_STAT), fileLooper);
+
+ if (status != B_OK) {
+ qWarning("watch_node(%ls) failed:", path.constData());
+ continue;
+ }
+
+ sg.dismiss();
+
+ if (isDir)
+ directories->append(path);
+ else
+ files->append(path);
+ }
+ return unhandled;
+}
+
+QStringList QHaikuFileSystemWatcherEngine::removePaths(const QStringList &paths,
+ QStringList *files,
+ QStringList *directories)
+{
+ QStringList unhandled;
+ for (const QString &path : paths) {
+ auto sg = qScopeGuard([&]{ unhandled.push_back(path); });
+
+ BEntry entry(path.toUtf8().constData());
+ node_ref nref;
+ entry.GetNodeRef(&nref);
+
+ if (directories->contains(path)) {
+ directories->removeAll(path);
+ status_t status = watch_node(&nref, B_STOP_WATCHING, dirLooper);
+ } else if (files->contains(path)) {
+ files->removeAll(path);
+ status_t status = watch_node(&nref, B_STOP_WATCHING, fileLooper);
+ } else {
+ continue;
+ }
+
+ sg.dismiss();
+ }
+
+ return unhandled;
+}
+
+void
+QHaikuDirWatcher::MessageReceived(BMessage* message)
+{
+ if (message->what == B_NODE_MONITOR) {
+ int32 opcode;
+
+ if (message->FindInt32("opcode", &opcode) != B_OK)
+ return;
+
+ switch (opcode) {
+ case B_ENTRY_MOVED:
+ {
+ int32 device = 0;
+ int64 srcFolder = 0;
+ int64 dstFolder = 0;
+ const char* name = NULL;
+ if (message->FindInt32("device", &device) != B_OK
+ || message->FindInt64("to directory", &dstFolder) != B_OK
+ || message->FindInt64("from directory", &srcFolder) != B_OK
+ || message->FindString("name", &name) != B_OK)
+ break;
+
+ entry_ref ref(device, srcFolder, name);
+ BEntry entry(&ref);
+
+ BEntry dirEntry;
+ entry.GetParent(&dirEntry);
+
+ BPath path;
+ dirEntry.GetPath(&path);
+
+ QString qpath = QString::fromUtf8(path.Path());
+
+ emit directoryChanged(qpath, false);
+ }
+ break;
+ case B_ENTRY_CREATED:
+ case B_ENTRY_REMOVED:
+ {
+ int64 directory;
+ int32 device;
+ int64 node;
+ const char *name;
+ if (message->FindInt64("directory", &directory) != B_OK
+ || message->FindInt32("device", &device) != B_OK
+ || message->FindInt64("node", &node) != B_OK
+ || message->FindString("name", &name) != B_OK)
+ break;
+
+ entry_ref ref(device, directory, name);
+ BEntry entry(&ref);
+ BEntry dirEntry;
+ entry.GetParent(&dirEntry);
+
+ BPath path;
+ dirEntry.GetPath(&path);
+
+ QString qpath = QString::fromUtf8(path.Path());
+ emit directoryChanged(qpath, opcode == B_ENTRY_REMOVED);
+ }
+ break;
+ }
+ }
+}
+
+void
+QHaikuFileWatcher::MessageReceived(BMessage* message)
+{
+ if (message->what == B_NODE_MONITOR) {
+ int32 opcode;
+ node_ref nref;
+ const char *name;
+
+ if (message->FindInt32("opcode", &opcode) != B_OK)
+ return;
+
+ switch (opcode) {
+ case B_ENTRY_MOVED:
+ {
+ int32 device = 0;
+ int64 srcFolder = 0;
+ int64 dstFolder = 0;
+ const char* name = NULL;
+ if (message->FindInt32("device", &device) != B_OK
+ || message->FindInt64("to directory", &dstFolder) != B_OK
+ || message->FindInt64("from directory", &srcFolder) != B_OK
+ || message->FindString("name", &name) != B_OK)
+ break;
+
+ entry_ref ref(device, srcFolder, name);
+ BEntry entry(&ref);
+
+ BPath path;
+ entry.GetPath(&path);
+
+ QString qpath = QString::fromUtf8(path.Path());
+
+ emit fileChanged(qpath, false);
+ }
+ break;
+ case B_STAT_CHANGED:
+ case B_ATTR_CHANGED:
+ BString path;
+ if (message->FindString("path", &path) == B_OK) {
+ QString qpath = QString::fromUtf8(path.String());
+
+ QFileInfo fi(qpath);
+ if (!fi.exists())
+ emit fileChanged(qpath, true);
+ else
+ emit fileChanged(qpath, false);
+ }
+ break;
+ }
+ }
+}
+
+void
+QHaikuFileSystemWatcherEngine::bfsDirectoryChanged(const QString &path, bool removed)
+{
+ emit directoryChanged(path, removed);
+}
+
+void
+QHaikuFileSystemWatcherEngine::bfsFileChanged(const QString &path, bool removed)
+{
+ emit fileChanged(path, removed);
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qfilesystemwatcher_haiku_p.cpp"
diff --git a/src/corelib/io/qfilesystemwatcher_haiku_p.h b/src/corelib/io/qfilesystemwatcher_haiku_p.h
new file mode 100644
index 0000000..8a8d75a
--- /dev/null
+++ b/src/corelib/io/qfilesystemwatcher_haiku_p.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2015-2020 Gerasim Troeglazov,
+** Contact: 3dEyes@gmail.com
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#ifndef QFILESYSTEMWATCHER_HAIKU_P_H
+#define QFILESYSTEMWATCHER_HAIKU_P_H
+
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qdatetime.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qtimer.h>
+#include <QtCore/qhash.h>
+
+#include <Application.h>
+#include <NodeMonitor.h>
+#include <Looper.h>
+#include <String.h>
+#include <Autolock.h>
+#include <Handler.h>
+#include <Entry.h>
+#include <Path.h>
+
+#include "qfilesystemwatcher_p.h"
+
+QT_REQUIRE_CONFIG(filesystemwatcher);
+QT_BEGIN_NAMESPACE
+
+class QHaikuDirWatcher : public QObject, public BLooper {
+ Q_OBJECT
+public:
+ QHaikuDirWatcher();
+ virtual void MessageReceived(BMessage* msg);
+Q_SIGNALS:
+ void directoryChanged(const QString &path, bool removed);
+};
+
+class QHaikuFileWatcher : public QObject, public BLooper {
+ Q_OBJECT
+public:
+ QHaikuFileWatcher();
+ virtual void MessageReceived(BMessage* msg);
+Q_SIGNALS:
+ void fileChanged(const QString &path, bool removed);
+};
+
+class QHaikuFileSystemWatcherEngine : public QFileSystemWatcherEngine
+{
+ Q_OBJECT
+
+public:
+ QHaikuFileSystemWatcherEngine(QObject *parent);
+ ~QHaikuFileSystemWatcherEngine();
+
+ QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories) override;
+ QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories) override;
+
+private:
+ QHaikuDirWatcher *dirLooper;
+ QHaikuFileWatcher *fileLooper;
+
+private Q_SLOTS:
+ void bfsDirectoryChanged(const QString &path, bool removed);
+ void bfsFileChanged(const QString &path, bool removed);
+};
+
+QT_END_NAMESPACE
+#endif // QFILESYSTEMWATCHER_HAIKU_P_H
+
--
2.45.2
From 2da1bcd3c3c8ae1d81c63982b27f61b021416664 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Tue, 16 Jun 2020 18:06:57 +1000
Subject: Don't use AF_INET6 for new sockets
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index feb102b..07b65cc 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -266,8 +266,12 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc
}
int protocol = 0;
#endif // QT_NO_SCTP
+#ifdef Q_OS_HAIKU
+ int domain = AF_INET;
+#else
int domain = (socketProtocol == QAbstractSocket::IPv6Protocol
|| socketProtocol == QAbstractSocket::AnyIPProtocol) ? AF_INET6 : AF_INET;
+#endif
int type = (socketType == QAbstractSocket::UdpSocket) ? SOCK_DGRAM : SOCK_STREAM;
int socket = qt_safe_socket(domain, type, protocol, O_NONBLOCK);
--
2.45.2
From fb28a35125704dde2f9d39baca82b48a36485b43 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 5 Oct 2020 19:40:40 +1000
Subject: Disable Haswell CPU feature for plugins
diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp
index 5cd21b6..2de224d 100644
--- a/src/corelib/plugin/qlibrary_unix.cpp
+++ b/src/corelib/plugin/qlibrary_unix.cpp
@@ -191,7 +191,7 @@ bool QLibraryPrivate::load_sys()
prefixes.append(QString());
}
-#if defined(Q_PROCESSOR_X86) && !defined(Q_OS_DARWIN)
+#if defined(Q_PROCESSOR_X86) && !defined(Q_OS_DARWIN) && !defined(Q_OS_HAIKU)
if (qCpuHasFeature(ArchHaswell)) {
auto transform = [](QStringList &list, void (*f)(QString *)) {
QStringList tmp;
--
2.45.2
From 5ed247c0afbb169a6b372b02d1090e518b059bec Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sat, 9 Oct 2021 18:33:27 +1000
Subject: QSharedMemory implementation for Haiku
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 749672c..e9bb3e9 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -167,13 +167,18 @@ unix|integrity {
qtConfig(clock-gettime): QMAKE_USE_PRIVATE += librt
- !android {
+ !android:!haiku {
SOURCES += kernel/qsharedmemory_posix.cpp \
kernel/qsharedmemory_systemv.cpp \
kernel/qsharedmemory_unix.cpp \
kernel/qsystemsemaphore_posix.cpp \
kernel/qsystemsemaphore_systemv.cpp \
kernel/qsystemsemaphore_unix.cpp
+ } else:haiku {
+ SOURCES += kernel/qsharedmemory_haiku.cpp \
+ kernel/qsystemsemaphore_posix.cpp \
+ kernel/qsystemsemaphore_systemv.cpp \
+ kernel/qsystemsemaphore_unix.cpp
} else {
SOURCES += kernel/qsharedmemory_android.cpp \
kernel/qsystemsemaphore_android.cpp
diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp
index 2d65e0b..8fd63d1 100644
--- a/src/corelib/kernel/qsharedmemory.cpp
+++ b/src/corelib/kernel/qsharedmemory.cpp
@@ -46,6 +46,9 @@
#ifdef Q_OS_WIN
# include <qt_windows.h>
#endif
+#ifdef Q_OS_HAIKU
+# include <OS.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -77,6 +80,14 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key,
result.append(QLatin1String(hex));
#ifdef Q_OS_WIN
return result;
+#elif defined(Q_OS_HAIKU)
+ if (key.length() < B_OS_NAME_LENGTH)
+ return key;
+
+ result = key;
+ result.truncate(B_OS_NAME_LENGTH - 4);
+ quint16 summ = qChecksum(key.toLatin1().constData(), key.length());
+ return result + QLatin1Char('_') + QString::number(summ, 16);
#elif defined(QT_POSIX_IPC)
return QLatin1Char('/') + result;
#else
diff --git a/src/corelib/kernel/qsharedmemory_haiku.cpp b/src/corelib/kernel/qsharedmemory_haiku.cpp
new file mode 100644
index 0000000..b404b8b
--- /dev/null
+++ b/src/corelib/kernel/qsharedmemory_haiku.cpp
@@ -0,0 +1,183 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2021 Gerasim Troeglazov,
+** Contact: 3dEyes@gmail.com
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "qsharedmemory.h"
+#include "qsharedmemory_p.h"
+#include <qdebug.h>
+
+#include <OS.h>
+
+#ifndef QT_NO_SHAREDMEMORY
+QT_BEGIN_NAMESPACE
+
+QSharedMemoryPrivate::QSharedMemoryPrivate()
+ : QObjectPrivate(), memory(0), size(0), error(QSharedMemory::NoError),
+#ifndef QT_NO_SYSTEMSEMAPHORE
+ systemSemaphore(QString()), lockedByMe(false),
+#endif
+ hand(-1)
+{
+}
+
+void QSharedMemoryPrivate::setErrorString(QLatin1String function)
+{
+ Q_UNUSED(function);
+}
+
+key_t QSharedMemoryPrivate::handle()
+{
+ const QString safeKey = makePlatformSafeKey(key);
+ if (safeKey.isEmpty()) {
+ errorString = QSharedMemory::tr("%1: key is empty").arg(QLatin1String("QSharedMemory::handle"));
+ error = QSharedMemory::KeyError;
+ return 0;
+ }
+
+ return 1;
+}
+
+#endif // QT_NO_SHAREDMEMORY
+
+#if !(defined(QT_NO_SHAREDMEMORY) && defined(QT_NO_SYSTEMSEMAPHORE))
+int QSharedMemoryPrivate::createUnixKeyFile(const QString &fileName)
+{
+ Q_UNUSED(fileName);
+ return 0;
+}
+#endif // QT_NO_SHAREDMEMORY && QT_NO_SYSTEMSEMAPHORE
+
+#ifndef QT_NO_SHAREDMEMORY
+
+bool QSharedMemoryPrivate::cleanHandle()
+{
+ if (hand > 0)
+ delete_area(hand);
+
+ hand = -1;
+
+ return true;
+}
+
+bool QSharedMemoryPrivate::create(int size)
+{
+ if (!handle())
+ return false;
+
+ const QLatin1String function("QSharedMemory::create");
+
+ const QString areaName = makePlatformSafeKey(key);
+
+ if (find_area(areaName.toUtf8().constData()) > 0) {
+ errorString = QSharedMemory::tr("%1: already exists").arg(function);
+ error = QSharedMemory::AlreadyExists;
+ return false;
+ }
+
+ hand = create_area(areaName.toUtf8().constData(), &memory, B_ANY_ADDRESS, size,
+ B_NO_LOCK, B_READ_AREA | B_WRITE_AREA | B_CLONEABLE_AREA);
+
+ if (hand <= B_ERROR) {
+ switch (hand) {
+ case B_NO_MEMORY:
+ errorString = QSharedMemory::tr("%1: not enough memory").arg(function);
+ error = QSharedMemory::OutOfResources;
+ break;
+ case B_BAD_VALUE:
+ errorString = QSharedMemory::tr("%1: bad area name").arg(function);
+ error = QSharedMemory::KeyError;
+ break;
+ default:
+ errorString = QSharedMemory::tr("%1: unknown error").arg(function);
+ error = QSharedMemory::UnknownError;
+ break;
+ }
+ return false;
+ }
+
+ return true;
+}
+
+bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
+{
+ const QLatin1String function("QSharedMemory::attach");
+
+ const QString areaName = makePlatformSafeKey(key);
+
+ uint32 permissions = mode == QSharedMemory::ReadOnly ? B_READ_AREA : B_READ_AREA | B_WRITE_AREA;
+
+ if (hand <= B_ERROR) {
+ area_id baseArea = find_area(areaName.toUtf8().constData());
+ if (baseArea <= B_ERROR) {
+ error = QSharedMemory::NotFound;
+ errorString = QSharedMemory::tr("%1: doesn't exist").arg(function);
+ cleanHandle();
+ return false;
+ }
+
+ hand = clone_area(areaName.toUtf8().constData(), &memory, B_ANY_ADDRESS, permissions, baseArea);
+ if (hand <= B_ERROR) {
+ error = QSharedMemory::UnknownError;
+ errorString = QSharedMemory::tr("%1: clone_area failed").arg(function);
+ cleanHandle();
+ return false;
+ }
+ }
+
+ area_info info;
+ if (get_area_info(hand, &info) != B_OK) {
+ error = QSharedMemory::UnknownError;
+ errorString = QSharedMemory::tr("%1: size query failed").arg(function);
+ cleanHandle();
+ return false;
+ }
+
+ size = info.size;
+ memory = info.address;
+
+ return true;
+}
+
+bool QSharedMemoryPrivate::detach()
+{
+ const QLatin1String function("QSharedMemory::detach");
+
+ area_id id = area_for(memory);
+
+ if (id == B_ERROR) {
+ error = QSharedMemory::NotFound;
+ errorString = QSharedMemory::tr("%1: doesn't exist").arg(function);
+ return false;
+ }
+
+ if (delete_area(id) != B_OK) {
+ error = QSharedMemory::UnknownError;
+ errorString = QSharedMemory::tr("%1: delete_area failed").arg(function);
+ return false;
+ }
+
+ memory = 0;
+ size = 0;
+
+ return cleanHandle();
+}
+
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_SHAREDMEMORY
diff --git a/src/corelib/kernel/qsharedmemory_p.h b/src/corelib/kernel/qsharedmemory_p.h
index 0c13375..172ca95 100644
--- a/src/corelib/kernel/qsharedmemory_p.h
+++ b/src/corelib/kernel/qsharedmemory_p.h
@@ -78,10 +78,14 @@ QT_END_NAMESPACE
# include "private/qobject_p.h"
#endif
-#if !defined(Q_OS_WIN) && !defined(Q_OS_ANDROID) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_RTEMS)
+#if !defined(Q_OS_WIN) && !defined(Q_OS_ANDROID) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_RTEMS) && !defined(Q_OS_HAIKU)
# include <sys/sem.h>
#endif
+#if defined(Q_OS_HAIKU)
+# include <OS.h>
+#endif
+
QT_BEGIN_NAMESPACE
#ifndef QT_NO_SYSTEMSEMAPHORE
@@ -144,6 +148,8 @@ public:
const QString &prefix = QLatin1String("qipc_sharedmemory_"));
#ifdef Q_OS_WIN
Qt::HANDLE handle();
+#elif defined(Q_OS_HAIKU)
+ area_id handle();
#elif defined(QT_POSIX_IPC)
int handle();
#else
@@ -171,6 +177,8 @@ public:
private:
#ifdef Q_OS_WIN
Qt::HANDLE hand;
+#elif defined(Q_OS_HAIKU)
+ area_id hand;
#elif defined(QT_POSIX_IPC)
int hand;
#else
--
2.45.2
From 71e858b38a5fa2855e3a98ad467638bb957fd9d7 Mon Sep 17 00:00:00 2001
From: PulkoMandy <pulkomandy@pulkomandy.tk>
Date: Sat, 10 Aug 2024 17:05:17 +0200
Subject: Fix build on Haiku R1/beta5
diff --git a/src/corelib/io/forkfd_qt.cpp b/src/corelib/io/forkfd_qt.cpp
index cf44874..8a0938d 100644
--- a/src/corelib/io/forkfd_qt.cpp
+++ b/src/corelib/io/forkfd_qt.cpp
@@ -44,5 +44,9 @@
# define NDEBUG
#endif
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
#include <forkfd.h>
#include "../../3rdparty/forkfd/forkfd.c"
diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp
index 0159636..7ca58a4 100644
--- a/src/network/kernel/qhostinfo.cpp
+++ b/src/network/kernel/qhostinfo.cpp
@@ -39,6 +39,8 @@
//#define QHOSTINFO_DEBUG
+#define _DEFAULT_SOURCE // for NI_MAXHOST
+
#include "qhostinfo.h"
#include "qhostinfo_p.h"
#include <qplatformdefs.h>
--
2.45.2
From fc67058ddb32f07b95e76fb84ade05e29173e6be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A1ximo=20Casta=C3=B1eda?= <antiswen@yahoo.es>
Date: Fri, 23 Aug 2024 20:30:08 +0200
Subject: SSL: try opening with OPENSSL_SHLIB_VERSION version number
Version 3 removed SHLIB_VERSION_NUMBER and now has OPENSSL_SHLIB_VERSION.
diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp
index 6a9a3ef..6a24bfc 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
+++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
@@ -767,6 +767,18 @@ static LoadedOpenSsl loadOpenSsl()
libcrypto->unload();
}
#endif
+#if defined(OPENSSL_SHLIB_VERSION) && !defined(Q_OS_QNX) // on QNX, the libs are always libssl.so and libcrypto.so
+ // still first attempt: version 3 removed SHLIB_VERSION_NUMBER and has OPENSSL_SHLIB_VERSION
+ libssl->setFileNameAndVersion(QLatin1String("ssl"), OPENSSL_SHLIB_VERSION);
+ libcrypto->setFileNameAndVersion(QLatin1String("crypto"), OPENSSL_SHLIB_VERSION);
+ if (libcrypto->load() && libssl->load()) {
+ // libssl.so.<OPENSSL_SHLIB_VERSION> and libcrypto.so.<OPENSSL_SHLIB_VERSION> found
+ return result;
+ } else {
+ libssl->unload();
+ libcrypto->unload();
+ }
+#endif
#ifndef Q_OS_DARWIN
// second attempt: find the development files libssl.so and libcrypto.so
--
2.45.2
From 5a9bcfd0481521a31ff298092d84da9dcdf5a534 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A1ximo=20Casta=C3=B1eda?= <antiswen@yahoo.es>
Date: Wed, 28 Aug 2024 19:05:51 +0200
Subject: Font db: improve support outside RBI space
Searching may use a previous font with a style name and change another
property. If we select on style name coincidence, we get the old one.
Using the style name just like any other property allows to use, say,
all different weights of Noto Sans in Calligra Words, instead of just
their projection on Regular/Bold/Italic space.
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 7aa6228..0b7f021 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -1060,12 +1060,6 @@ static QtFontStyle *bestStyle(QtFontFoundry *foundry, const QtFontStyle::Key &st
for ( int i = 0; i < foundry->count; i++ ) {
QtFontStyle *style = foundry->styles[i];
- if (!styleName.isEmpty() && styleName == style->styleName) {
- dist = 0;
- best = i;
- break;
- }
-
int d = qAbs( styleKey.weight - style->key.weight );
if ( styleKey.stretch != 0 && style->key.stretch != 0 ) {
@@ -1080,9 +1074,16 @@ static QtFontStyle *bestStyle(QtFontFoundry *foundry, const QtFontStyle::Key &st
d += 0x1000;
}
+ d *= 2;
+ if (!styleName.isEmpty() && styleName != style->styleName) {
+ d += 0x0001;
+ }
+
if ( d < dist ) {
best = i;
dist = d;
+ if ( d == 0 )
+ break;
}
}
--
2.45.2
From 1d2624892474544ebe8514b15e38cb14cfc15396 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A1ximo=20Casta=C3=B1eda?= <antiswen@yahoo.es>
Date: Thu, 3 Oct 2024 16:33:09 +0200
Subject: Font db: improve weight detection from style name
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 0b7f021..151c386 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -115,14 +115,22 @@ static int getFontWeight(const QString &weightString)
// Next up, let's see if contains() matches: slightly more expensive, but
// still fast enough.
if (s.contains(QLatin1String("bold"))) {
- if (s.contains(QLatin1String("demi")))
+ if (s.contains(QLatin1String("semibold")) || s.contains(QLatin1String("semi bold"))
+ || s.contains(QLatin1String("demibold")) || s.contains(QLatin1String("demi bold")))
return QFont::DemiBold;
+ if (s.contains(QLatin1String("extrabold")) || s.contains(QLatin1String("extra bold"))
+ || s.contains(QLatin1String("ultrabold")) || s.contains(QLatin1String("ultra bold")))
+ return QFont::ExtraBold;
return QFont::Bold;
}
if (s.contains(QLatin1String("thin")))
return QFont::Thin;
- if (s.contains(QLatin1String("light")))
+ if (s.contains(QLatin1String("light"))) {
+ if (s.contains(QLatin1String("extralight")) || s.contains(QLatin1String("extra light"))
+ || s.contains(QLatin1String("ultralight")) || s.contains(QLatin1String("ultra light")))
+ return QFont::ExtraLight;
return QFont::Light;
+ }
if (s.contains(QLatin1String("black")))
return QFont::Black;
--
2.45.2
From 06aed265773ab24fd7e9c5a6ff611c613833ea51 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A1ximo=20Casta=C3=B1eda?= <antiswen@yahoo.es>
Date: Thu, 3 Oct 2024 16:40:13 +0200
Subject: Font db: include best style score in foundry's one
Instead of always assigning the same StyleMismatch penalty
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 151c386..ab87fb6 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -1060,15 +1060,15 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
}
static QtFontStyle *bestStyle(QtFontFoundry *foundry, const QtFontStyle::Key &styleKey,
- const QString &styleName = QString())
+ const QString &styleName = QString(), unsigned int* score = nullptr)
{
int best = 0;
- int dist = 0xffff;
+ unsigned int dist = 0xffff;
for ( int i = 0; i < foundry->count; i++ ) {
QtFontStyle *style = foundry->styles[i];
- int d = qAbs( styleKey.weight - style->key.weight );
+ unsigned int d = qAbs( styleKey.weight - style->key.weight );
if ( styleKey.stretch != 0 && style->key.stretch != 0 ) {
d += qAbs( styleKey.stretch - style->key.stretch );
@@ -1079,7 +1079,7 @@ static QtFontStyle *bestStyle(QtFontFoundry *foundry, const QtFontStyle::Key &st
// one is italic, the other oblique
d += 0x0001;
else
- d += 0x1000;
+ d += 0x0100;
}
d *= 2;
@@ -1095,6 +1095,9 @@ static QtFontStyle *bestStyle(QtFontFoundry *foundry, const QtFontStyle::Key &st
}
}
+ if (score != nullptr)
+ *score = dist;
+
qCDebug(lcFontMatch, " best style has distance 0x%x", dist );
return foundry->styles[best];
}
@@ -1124,7 +1127,8 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
qCDebug(lcFontMatch, " looking for matching style in foundry '%s' %d",
foundry->name.isEmpty() ? "-- none --" : foundry->name.toLatin1().constData(), foundry->count);
- QtFontStyle *style = bestStyle(foundry, styleKey, styleName);
+ unsigned int this_score = 0x0000;
+ QtFontStyle *style = bestStyle(foundry, styleKey, styleName, &this_score);
if (!style->smoothScalable && (styleStrategy & QFont::ForceOutline)) {
qCDebug(lcFontMatch, " ForceOutline set, but not smoothly scalable");
@@ -1201,7 +1205,6 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
}
- unsigned int this_score = 0x0000;
enum {
PitchMismatch = 0x4000,
StyleMismatch = 0x2000,
@@ -1212,8 +1215,6 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
|| (pitch == 'p' && family->fixedPitch))
this_score += PitchMismatch;
}
- if (styleKey != style->key)
- this_score += StyleMismatch;
if (!style->smoothScalable && px != size->pixelSize) // bitmap scaled
this_score += BitmapScaledPenalty;
if (px != pixelSize) // close, but not exact, size match
--
2.45.2
From 85910a62f15af32e9df0deb7e94da3b50b5cbf09 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A1ximo=20Casta=C3=B1eda?= <antiswen@yahoo.es>
Date: Thu, 3 Oct 2024 16:50:04 +0200
Subject: FT Font db: load named styles of variable fonts
As the system doesn't seem to consider anything out of the weight/slant
space, we are abusing the foundry property (empty at least for the
FreeType backend) to classify styles with other axis.
Width seems to need to be unstretched to correctly draw different width
variations, so that is also included in the fake foundry.
diff --git a/src/platformsupport/fontdatabases/freetype/qfreetypefontdatabase.cpp b/src/platformsupport/fontdatabases/freetype/qfreetypefontdatabase.cpp
index 56dcc61..0505da0 100644
--- a/src/platformsupport/fontdatabases/freetype/qfreetypefontdatabase.cpp
+++ b/src/platformsupport/fontdatabases/freetype/qfreetypefontdatabase.cpp
@@ -45,13 +45,18 @@
#include <QtCore/QFile>
#include <QtCore/QLibraryInfo>
#include <QtCore/QDir>
+#include <QtCore/QDataStream>
+#include <QtCore/QTextCodec>
#include <QtCore/QtEndian>
#undef QT_NO_FREETYPE
#include <QtFontDatabaseSupport/private/qfontengine_ft_p.h>
#include <ft2build.h>
+#include FT_TRUETYPE_IDS_H
#include FT_TRUETYPE_TABLES_H
+#include FT_MULTIPLE_MASTERS_H
+#include FT_SFNT_NAMES_H
#include FT_ERRORS_H
QT_BEGIN_NAMESPACE
@@ -111,6 +116,306 @@ void QFreeTypeFontDatabase::releaseHandle(void *handle)
extern FT_Library qt_getFreetype();
+static FT_Error loadFace(FT_Library library, const QByteArray &fontData, const QByteArray &file, int index, FT_Face *face)
+{
+ FT_Error error;
+
+ if (!fontData.isEmpty()) {
+ error = FT_New_Memory_Face(library, (const FT_Byte *)fontData.constData(), fontData.size(), index, face);
+ } else {
+ error = FT_New_Face(library, file.constData(), index, face);
+ }
+
+ if (error != FT_Err_Ok) {
+ qDebug() << "FT_New_Face failed with index" << index << ':' << Qt::hex << error;
+ }
+ return error;
+}
+
+static float fixedToFloat(FT_Fixed value)
+{
+ return value / (float) 0x10000;
+}
+
+static QString getSfntName(FT_Face face, FT_UInt id)
+{
+ FT_Byte* buffer;
+ FT_UInt length = 0;
+ FT_UInt count = FT_Get_Sfnt_Name_Count(face);
+
+ for (FT_UInt i = 0; i < count; i++) {
+ FT_SfntName name;
+
+ if (FT_Get_Sfnt_Name(face, i, &name) != FT_Err_Ok || name.name_id != id
+ || name.platform_id != TT_PLATFORM_MICROSOFT
+ || name.encoding_id != TT_MS_ID_UNICODE_CS)
+ continue;
+
+ if (length == 0 || name.language_id == TT_MS_LANGID_ENGLISH_UNITED_STATES) {
+ buffer = name.string;
+ length = name.string_len;
+ }
+
+ if (name.language_id == TT_MS_LANGID_ENGLISH_UNITED_STATES)
+ break;
+ }
+
+ if (length > 0) {
+ QTextCodec* decoder = QTextCodec::codecForName("UTF-16BE");
+ return decoder->toUnicode((char*)buffer, length);
+ }
+
+ return QString();
+}
+
+struct STAT_Header
+{
+ STAT_Header(const char* src)
+ {
+ QByteArray ba = QByteArray::fromRawData(src, sizeof(STAT_Header));
+ QDataStream ds(ba);
+ ds.setByteOrder(QDataStream::BigEndian);
+ ds >> majorVersion;
+ if (majorVersion != 1)
+ return;
+ ds
+ >> minorVersion
+ >> designAxisSize
+ >> designAxisCount
+ >> designAxesOffset
+ >> axisValueCount
+ >> axisValueOffsetsOffset;
+ if (minorVersion >= 1)
+ ds >> elidedFallbackNameID;
+ else
+ elidedFallbackNameID = 0xffff;
+ }
+
+ quint16 majorVersion;
+ quint16 minorVersion;
+ quint16 designAxisSize;
+ quint16 designAxisCount;
+ quint32 designAxesOffset;
+ quint16 axisValueCount;
+ quint32 axisValueOffsetsOffset;
+ quint16 elidedFallbackNameID;
+};
+
+struct STAT_Value
+{
+ STAT_Value(const char* src)
+ {
+ QByteArray ba = QByteArray::fromRawData(src, sizeof(STAT_Value));
+ QDataStream ds(ba);
+ ds.setByteOrder(QDataStream::BigEndian);
+ ds >> format;
+ if (format > 3)
+ return;
+ ds
+ >> index
+ >> flags
+ >> nameID
+ >> value;
+ if (format == 2) {
+ ds >> min >> max;
+ } else {
+ min = max = value;
+ }
+ }
+
+ quint16 format;
+ quint16 index;
+ quint16 flags;
+ quint16 nameID;
+ qint32 value;
+ qint32 min;
+ qint32 max;
+};
+
+class AxisData
+{
+
+ struct Span
+ {
+ qint32 min;
+ qint32 max;
+ QString name;
+ };
+
+ class Axis
+ {
+ public:
+ Axis() : tag(0) {};
+
+ void Insert(const STAT_Value& value, QString name)
+ {
+ if (value.format > 3)
+ return;
+
+ if (value.flags & 0x0002)
+ def = value.value;
+
+ Span current;
+ current.min = value.min;
+ current.max = value.max;
+ current.name = name;
+ span.push_back(current);
+ }
+
+ QString Name(FT_Fixed value)
+ {
+ if (tag != 'wdth' && (value == def || min == max))
+ return QString();
+
+
+ for (unsigned int i = 0; i < span.size(); i++) {
+ if (span[i].min <= value && span[i].max >= value)
+ return span[i].name;
+ }
+
+ float pct;
+ if (tag == 'wdth')
+ pct = fixedToFloat(value);
+ else
+ pct = 100 * (fixedToFloat(value) - min) / (max - min);
+ QString name = axisName + QLatin1String(": ")
+ + QString::number((int)pct)
+ + QLatin1String("%");
+ return name;
+ }
+
+ public:
+ QString axisName;
+ quint32 tag;
+ FT_Fixed def;
+ float min;
+ float max;
+ std::vector<Span> span;
+ };
+
+public:
+ AxisData(FT_Face face) : count(0), axis(nullptr), fake(false)
+ {
+ FT_MM_Var* mm;
+ if (FT_Get_MM_Var(face, &mm) != 0)
+ return;
+
+ count = mm->num_axis;
+ if (count == 0) {
+ FT_Done_MM_Var(qt_getFreetype(), mm);
+ return;
+ }
+ axis = new Axis[count];
+
+ for (FT_UInt i = 0; i < count; i++) {
+ FT_Var_Axis* mm_axis = mm->axis + i;
+ axis[i].tag = mm_axis->tag;
+ axis[i].def = mm_axis->def;
+ axis[i].min = fixedToFloat(mm_axis->minimum);
+ axis[i].max = fixedToFloat(mm_axis->maximum);
+ axis[i].axisName = getSfntName(face, mm_axis->strid);
+ if (mm_axis->tag != tagWeight
+ && mm_axis->tag != tagItalics && mm_axis->tag != tagSlant){
+ fake = true;
+ }
+ }
+
+ FT_Done_MM_Var(qt_getFreetype(), mm);
+
+ FT_ULong length = 0;
+ if (FT_Load_Sfnt_Table(face, 'STAT', 0, (FT_Byte*)NULL, &length) != FT_Err_Ok)
+ return;
+
+ char* buffer = (char*)malloc(length);
+ if (buffer == NULL)
+ return;
+ if (FT_Load_Sfnt_Table(face, 'STAT', 0, (FT_Byte*)buffer, &length) != FT_Err_Ok) {
+ free(buffer);
+ return;
+ }
+
+ STAT_Header header{buffer};
+ if (header.majorVersion != 1 || header.designAxisCount == 0 || header.axisValueCount == 0) {
+ free(buffer);
+ return;
+ }
+
+ unsigned int map[(unsigned int)header.designAxisCount];
+
+ for (unsigned int i = 0; i < header.designAxisCount; i++) {
+ quint32 tag = qFromBigEndian(*(quint32*)(buffer + header.designAxesOffset + i * header.designAxisSize));
+ unsigned int j;
+ for (j = 0; j < count; j++) {
+ if (axis[j].tag == tag) {
+ map[i] = j;
+ break;
+ }
+ }
+ }
+
+ quint16_be* offsets = (quint16_be*)(buffer + header.axisValueOffsetsOffset);
+ for (int i = 0; i < header.axisValueCount; i++) {
+ int offset = header.axisValueOffsetsOffset + offsets[i];
+ STAT_Value value{buffer + offset};
+ if (value.format > 3 || value.index >= count)
+ continue;
+ axis[map[value.index]].Insert(value, getSfntName(face, value.nameID));
+ }
+
+ regularName = getSfntName(face, header.elidedFallbackNameID);
+ if (regularName.isEmpty())
+ regularName = QString::fromLatin1("Regular");
+
+ free(buffer);
+ }
+
+ ~AxisData() {
+ delete[] axis;
+ }
+
+ QString Coordinates(FT_Face face, QFont::Weight& weight, QFont::Style& style) {
+ QString fakeFoundry;
+ if (count == 0)
+ return fakeFoundry;
+
+ FT_Fixed coords[count];
+ FT_Get_Var_Design_Coordinates(face, count, coords);
+ for (unsigned int i = 0; i < count; i++) {
+ if (axis[i].tag == tagWeight) {
+ weight = QPlatformFontDatabase::weightFromInteger(coords[i] >> 16);
+ } else if (axis[i].tag == tagItalics) {
+ if (coords[i] > 0x8000)
+ style = QFont::StyleItalic;
+ else
+ style = QFont::StyleNormal;
+ } else if (axis[i].tag == tagSlant) {
+ if (coords[i] == 0)
+ style = QFont::StyleNormal;
+ else
+ style = QFont::StyleOblique;
+ } else {
+ if (!fakeFoundry.isEmpty())
+ fakeFoundry += QChar::fromLatin1(' ');
+ fakeFoundry += axis[i].Name(coords[i]);
+ }
+ }
+
+ if (fake && fakeFoundry.isEmpty())
+ fakeFoundry = regularName;
+ return fakeFoundry;
+ }
+
+public:
+ static const int tagWeight = 'wght';
+ static const int tagItalics = 'ital';
+ static const int tagSlant = 'slnt';
+
+ unsigned int count;
+ Axis* axis;
+ bool fake;
+ QString regularName;
+};
+
QStringList QFreeTypeFontDatabase::addTTFile(const QByteArray &fontData, const QByteArray &file)
{
FT_Library library = qt_getFreetype();
@@ -118,19 +423,29 @@ QStringList QFreeTypeFontDatabase::addTTFile(const QByteArray &fontData, const Q
int index = 0;
int numFaces = 0;
QStringList families;
+
+ FT_Face face;
+ if (loadFace(library, fontData, file, -1, &face) != FT_Err_Ok) {
+ return families;
+ }
+ numFaces = face->num_faces;
+ FT_Done_Face(face);
+
do {
- FT_Face face;
- FT_Error error;
- if (!fontData.isEmpty()) {
- error = FT_New_Memory_Face(library, (const FT_Byte *)fontData.constData(), fontData.size(), index, &face);
- } else {
- error = FT_New_Face(library, file.constData(), index, &face);
- }
- if (error != FT_Err_Ok) {
- qDebug() << "FT_New_Face failed with index" << index << ':' << Qt::hex << error;
+ if (loadFace(library, fontData, file, index, &face) != FT_Err_Ok) {
+ break;
+ }
+
+ AxisData variableData(face);
+ int variableCount = (face->style_flags & 0x7fff0000) >> 16;
+ FT_Done_Face(face);
+
+ int namedStyle = variableCount == 0 ? 0 : 1;
+ do {
+ int faceIndex = index | (namedStyle << 16);
+ if (loadFace(library, fontData, file, faceIndex, &face) != FT_Err_Ok) {
break;
}
- numFaces = face->num_faces;
QFont::Weight weight = QFont::Normal;
@@ -153,7 +468,6 @@ QStringList QFreeTypeFontDatabase::addTTFile(const QByteArray &fontData, const Q
}
}
- QFont::Stretch stretch = QFont::Unstretched;
TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(face, ft_sfnt_os2);
if (os2) {
quint32 unicodeRange[4] = {
@@ -192,50 +506,55 @@ QStringList QFreeTypeFontDatabase::addTTFile(const QByteArray &fontData, const Q
else if (w <= 10)
weight = QFont::Black;
}
+ }
+ QString family = QString::fromLatin1(face->family_name);
+ QString fakeFoundry;
+ if (namedStyle > 0) {
+ fakeFoundry = variableData.Coordinates(face, weight, style);
+ } else if (os2) {
switch (os2->usWidthClass) {
case 1:
- stretch = QFont::UltraCondensed;
+ fakeFoundry = QString::fromLatin1("UltraCondensed");
break;
case 2:
- stretch = QFont::ExtraCondensed;
+ fakeFoundry = QString::fromLatin1("ExtraCondensed");
break;
case 3:
- stretch = QFont::Condensed;
+ fakeFoundry = QString::fromLatin1("Condensed");
break;
case 4:
- stretch = QFont::SemiCondensed;
- break;
- case 5:
- stretch = QFont::Unstretched;
+ fakeFoundry = QString::fromLatin1("SemiCondensed");
break;
case 6:
- stretch = QFont::SemiExpanded;
+ fakeFoundry = QString::fromLatin1("SemiExpanded");
break;
case 7:
- stretch = QFont::Expanded;
+ fakeFoundry = QString::fromLatin1("Expanded");
break;
case 8:
- stretch = QFont::ExtraExpanded;
+ fakeFoundry = QString::fromLatin1("ExtraExpanded");
break;
case 9:
- stretch = QFont::UltraExpanded;
+ fakeFoundry = QString::fromLatin1("UltraExpanded");
break;
+ default:
+ fakeFoundry = QString::fromLatin1("Medium");
}
}
-
- QString family = QString::fromLatin1(face->family_name);
FontFile *fontFile = new FontFile;
fontFile->fileName = QFile::decodeName(file);
- fontFile->indexValue = index;
+ fontFile->indexValue = faceIndex;
- registerFont(family,QString::fromLatin1(face->style_name),QString(),weight,style,stretch,true,true,0,fixedPitch,writingSystems,fontFile);
+ registerFont(family,QString::fromLatin1(face->style_name),fakeFoundry,weight,style,QFont::Unstretched,true,true,0,fixedPitch,writingSystems,fontFile);
families.append(family);
FT_Done_Face(face);
- ++index;
+ ++namedStyle;
+ } while (namedStyle <= variableCount);
+ ++index;
} while (index < numFaces);
return families;
}
--
2.45.2