Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
fff3309e
Commit
fff3309e
authored
Nov 15, 2010
by
dt
Browse files
ProjectExplorer: Add expensive asserts to FlatModel
Should help in debugging QTCREATORBUG-2821
parent
c6d3f085
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/projectexplorer/projectmodels.cpp
View file @
fff3309e
...
@@ -512,6 +512,16 @@ bool FlatModel::filter(Node *node) const
...
@@ -512,6 +512,16 @@ bool FlatModel::filter(Node *node) const
return
isHidden
;
return
isHidden
;
}
}
bool
isSorted
(
const
QList
<
Node
*>
&
nodes
)
{
int
size
=
nodes
.
size
();
for
(
int
i
=
0
;
i
<
size
-
1
;
++
i
)
{
if
(
!
sortNodes
(
nodes
.
at
(
i
),
nodes
.
at
(
i
+
1
)))
return
false
;
}
return
true
;
}
/// slots and all the fun
/// slots and all the fun
void
FlatModel
::
added
(
FolderNode
*
parentNode
,
const
QList
<
Node
*>
&
newNodeList
)
void
FlatModel
::
added
(
FolderNode
*
parentNode
,
const
QList
<
Node
*>
&
newNodeList
)
{
{
...
@@ -526,6 +536,21 @@ void FlatModel::added(FolderNode* parentNode, const QList<Node*> &newNodeList)
...
@@ -526,6 +536,21 @@ void FlatModel::added(FolderNode* parentNode, const QList<Node*> &newNodeList)
QList
<
Node
*>::
const_iterator
oldIter
=
oldNodeList
.
constBegin
();
QList
<
Node
*>::
const_iterator
oldIter
=
oldNodeList
.
constBegin
();
QList
<
Node
*>::
const_iterator
newIter
=
newNodeList
.
constBegin
();
QList
<
Node
*>::
const_iterator
newIter
=
newNodeList
.
constBegin
();
Q_ASSERT
(
isSorted
(
oldNodeList
));
Q_ASSERT
(
isSorted
(
newNodeList
));
QSet
<
Node
*>
emptyDifference
;
emptyDifference
=
oldNodeList
.
toSet
();
emptyDifference
.
subtract
(
newNodeList
.
toSet
());
if
(
!
emptyDifference
.
isEmpty
())
{
// This should not happen...
qDebug
()
<<
"FlatModel::added, old Node list should be subset of newNode list, found files in old list which were not part of new list"
;
foreach
(
Node
*
n
,
emptyDifference
)
{
qDebug
()
<<
n
->
path
();
}
Q_ASSERT
(
false
);
}
// optimization, check for old list is empty
// optimization, check for old list is empty
if
(
oldIter
==
oldNodeList
.
constEnd
())
{
if
(
oldIter
==
oldNodeList
.
constEnd
())
{
// New Node List is empty, nothing added which intrest us
// New Node List is empty, nothing added which intrest us
...
@@ -591,11 +616,27 @@ void FlatModel::removed(FolderNode* parentNode, const QList<Node*> &newNodeList)
...
@@ -591,11 +616,27 @@ void FlatModel::removed(FolderNode* parentNode, const QList<Node*> &newNodeList)
QHash
<
FolderNode
*
,
QList
<
Node
*>
>::
const_iterator
it
=
m_childNodes
.
constFind
(
parentNode
);
QHash
<
FolderNode
*
,
QList
<
Node
*>
>::
const_iterator
it
=
m_childNodes
.
constFind
(
parentNode
);
if
(
it
==
m_childNodes
.
constEnd
())
if
(
it
==
m_childNodes
.
constEnd
())
return
;
return
;
QList
<
Node
*>
oldNodeList
=
it
.
value
();
QList
<
Node
*>
oldNodeList
=
it
.
value
();
// Compare lists and emit signals, and modify m_childNodes on the fly
// Compare lists and emit signals, and modify m_childNodes on the fly
QList
<
Node
*>::
const_iterator
oldIter
=
oldNodeList
.
constBegin
();
QList
<
Node
*>::
const_iterator
oldIter
=
oldNodeList
.
constBegin
();
QList
<
Node
*>::
const_iterator
newIter
=
newNodeList
.
constBegin
();
QList
<
Node
*>::
const_iterator
newIter
=
newNodeList
.
constBegin
();
Q_ASSERT
(
isSorted
(
oldNodeList
));
Q_ASSERT
(
isSorted
(
newNodeList
));
QSet
<
Node
*>
emptyDifference
;
emptyDifference
=
newNodeList
.
toSet
();
emptyDifference
.
subtract
(
oldNodeList
.
toSet
());
if
(
!
emptyDifference
.
isEmpty
())
{
// This should not happen...
qDebug
()
<<
"FlatModel::removed, new Node list should be subset of oldNode list, found files in new list which were not part of old list"
;
foreach
(
Node
*
n
,
emptyDifference
)
{
qDebug
()
<<
n
->
path
();
}
Q_ASSERT
(
false
);
}
// optimization, check for new list is empty
// optimization, check for new list is empty
if
(
newIter
==
newNodeList
.
constEnd
())
{
if
(
newIter
==
newNodeList
.
constEnd
())
{
// New Node List is empty, everything removed
// New Node List is empty, everything removed
...
...
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