Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
bsdutils
bsdisks
Commits
dad60a4a115f
Commit
1ac33a13
authored
Oct 28, 2020
by
Gleb Popov
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the m_managedObjects cache and compute it on every GetManagedObjects() call.
Reported by: tijl
parent
f1891d942806
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
10 deletions
+43
-10
objectmanager.cpp
objectmanager.cpp
+43
-8
objectmanager.h
objectmanager.h
+0
-2
No files found.
objectmanager.cpp
View file @
dad60a4a
...
...
@@ -10,7 +10,48 @@
DBUSManagerStruct
ObjectManager
::
GetManagedObjects
()
{
return
m_managedObjects
;
DBUSManagerStruct
ret
;
QList
<
std
::
pair
<
QObject
*
,
QDBusObjectPath
>>
objects
;
std
::
transform
(
m_driveObjects
.
begin
(),
m_driveObjects
.
end
(),
std
::
back_inserter
(
objects
),
[](
Drive
*
d
)
{
return
std
::
make_pair
(
static_cast
<
QObject
*>
(
d
),
d
->
dbusPath
);
}
);
std
::
transform
(
m_blockObjects
.
begin
(),
m_blockObjects
.
end
(),
std
::
back_inserter
(
objects
),
[](
Block
*
b
)
{
return
std
::
make_pair
(
static_cast
<
QObject
*>
(
b
),
b
->
dbusPath
);
}
);
for
(
auto
&
objectPair
:
objects
)
{
QObject
*
o
=
objectPair
.
first
;
auto
dbusPath
=
objectPair
.
second
;
QVariantMapMap
interfaces
;
for
(
QObject
*
child
:
o
->
children
())
{
QDBusAbstractAdaptor
*
adaptor
=
qobject_cast
<
QDBusAbstractAdaptor
*>
(
child
);
if
(
!
adaptor
)
continue
;
const
QString
&
iface
=
adaptor
->
metaObject
()
->
classInfo
(
adaptor
->
metaObject
()
->
indexOfClassInfo
(
"D-Bus Interface"
)).
value
();
QVariantMap
properties
;
for
(
int
i
=
adaptor
->
metaObject
()
->
propertyOffset
();
i
<
adaptor
->
metaObject
()
->
propertyCount
();
++
i
)
{
auto
propertyName
=
adaptor
->
metaObject
()
->
property
(
i
).
name
();
properties
.
insert
(
QString
::
fromLatin1
(
propertyName
),
adaptor
->
property
(
propertyName
));
}
interfaces
[
iface
]
=
properties
;
}
ret
[
dbusPath
]
=
interfaces
;
}
return
ret
;
}
...
...
@@ -452,7 +493,7 @@ void ObjectManager::addPartition(Block* b, const QString& tableBlockName, const
void
ObjectManager
::
addInterfaces
(
QDBusObjectPath
path
,
QList
<
std
::
pair
<
QString
,
QDBusAbstractAdaptor
*>>
newInterfaces
)
{
QVariantMapMap
&
interfaces
=
m_managedObjects
[
path
]
;
QVariantMapMap
interfaces
;
for
(
auto
pair
:
newInterfaces
)
{
...
...
@@ -475,11 +516,5 @@ void ObjectManager::addInterfaces(QDBusObjectPath path, QList<std::pair<QString,
void
ObjectManager
::
removeInterfaces
(
QDBusObjectPath
path
,
QStringList
ifaces
)
{
QVariantMapMap
&
interfaces
=
m_managedObjects
[
path
];
for
(
auto
iface
:
ifaces
)
interfaces
.
remove
(
iface
);
emit
InterfacesRemoved
(
path
,
ifaces
);
if
(
interfaces
.
empty
())
m_managedObjects
.
remove
(
path
);
}
objectmanager.h
View file @
dad60a4a
...
...
@@ -71,8 +71,6 @@ private:
void
addInterfaces
(
QDBusObjectPath
path
,
QList
<
std
::
pair
<
QString
,
QDBusAbstractAdaptor
*>>
newInterfaces
);
void
removeInterfaces
(
QDBusObjectPath
path
,
QStringList
ifaces
);
DBUSManagerStruct
m_managedObjects
;
bool
initialProbeDone
;
QHash
<
QString
,
Block
*>
m_blockObjects
;
QHash
<
QString
,
Drive
*>
m_driveObjects
;
...
...
Gleb Popov
@arrowd
mentioned in commit
b5ce432851d6
·
Oct 28, 2020
mentioned in commit
b5ce432851d6
mentioned in commit 93d3439348ba00ae972e146c5bf28cb42949e24f
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment