Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qsymbolsresolveutils.cpp
Go to the documentation of this file.
1
// Copyright (C) 2024 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:critical reason:execute-external-code
4
5
#
include
"qsymbolsresolveutils_p.h"
6
7
#
include
<
qdebug
.
h
>
8
#
include
<
qloggingcategory
.
h
>
9
10
QT_BEGIN_NAMESPACE
11
12
Q_STATIC_LOGGING_CATEGORY
(qLcSymbolsResolver,
"qt.multimedia.symbolsresolver"
);
13
14
bool
SymbolsResolver::isLazyLoadEnabled()
15
{
16
static
const
bool
lazyLoad =
17
!
static_cast
<
bool
>(qEnvironmentVariableIntValue(
"QT_INSTANT_LOAD_FFMPEG_STUBS"
));
18
return
lazyLoad;
19
}
20
21
SymbolsResolver::SymbolsResolver(
const
char
*libLoggingName, LibraryLoader loader)
22
: m_libLoggingName(libLoggingName)
23
{
24
Q_ASSERT(libLoggingName);
25
Q_ASSERT(loader);
26
27
auto
library = loader();
28
if
(library && library->isLoaded())
29
m_library = std::move(library);
30
else
31
qCWarning
(qLcSymbolsResolver) <<
"Couldn't load"
<< m_libLoggingName <<
"library"
;
32
}
33
34
SymbolsResolver::SymbolsResolver(
const
char
*libName,
const
char
*version,
35
const
char
*libLoggingName)
36
: m_libLoggingName(libLoggingName ? libLoggingName : libName)
37
{
38
Q_ASSERT(libName);
39
Q_ASSERT(version);
40
41
auto
library = std::make_unique<QLibrary>(QString::fromLocal8Bit(libName),
42
QString::fromLocal8Bit(version));
43
if
(library->load())
44
m_library = std::move(library);
45
else
46
qCWarning
(qLcSymbolsResolver) <<
"Couldn't load"
<< m_libLoggingName <<
"library"
;
47
}
48
49
SymbolsResolver::~SymbolsResolver()
50
{
51
if
(m_library)
52
m_library->unload();
53
}
54
55
QFunctionPointer SymbolsResolver::initOptionalFunction(
const
char
*funcName)
56
{
57
return
m_library ? m_library->resolve(funcName) :
nullptr
;
58
}
59
60
QFunctionPointer SymbolsResolver::initFunction(
const
char
*funcName)
61
{
62
QFunctionPointer func = initOptionalFunction(funcName);
63
64
if
(!func && m_library)
65
{
66
qCWarning
(qLcSymbolsResolver) <<
"Couldn't resolve"
<< m_libLoggingName <<
"symbol"
<< funcName;
67
m_library->unload();
68
m_library.reset();
69
}
70
71
return
func;
72
}
73
74
void
SymbolsResolver::checkLibrariesLoaded(SymbolsMarker *begin, SymbolsMarker *end)
75
{
76
if
(m_library) {
77
qCDebug
(qLcSymbolsResolver) << m_libLoggingName <<
"symbols resolved"
;
78
}
else
{
79
const
auto
size =
reinterpret_cast
<
char
*>(end) -
reinterpret_cast
<
char
*>(begin);
80
memset(begin, 0, size);
81
qCWarning
(qLcSymbolsResolver) <<
"Couldn't resolve"
<< m_libLoggingName <<
"symbols"
;
82
}
83
}
84
85
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qCWarning
#define qCWarning(category,...)
Definition
qloggingcategory.h:164
qCDebug
#define qCDebug(category,...)
Definition
qloggingcategory.h:162
Q_STATIC_LOGGING_CATEGORY
#define Q_STATIC_LOGGING_CATEGORY(name,...)
Definition
qloggingcategory.h:154
qtmultimedia
src
multimedia
qsymbolsresolveutils.cpp
Generated on
for Qt by
1.18.0