Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
c8b62432
Kaydet (Commit)
c8b62432
authored
Ara 21, 2013
tarafından
Jan Holesovsky
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Don't call EndListening() on already destructed listeners.
Change-Id: I9bda35f2246de9d37077dda33c710b89ee008e5a
üst
5527a867
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
16 deletions
+40
-16
broadcast.hxx
include/svl/broadcast.hxx
+6
-1
broadcast.cxx
svl/source/notify/broadcast.cxx
+34
-15
No files found.
include/svl/broadcast.hxx
Dosyayı görüntüle @
c8b62432
...
...
@@ -70,10 +70,15 @@ public:
* themselves from the broadcaster - the broadcaster will not broadcast
* anything after the PrepareForDesctruction() call anyway.
*/
void
PrepareForDestruction
()
{
mbAboutToDie
=
true
;
}
void
PrepareForDestruction
()
;
private
:
ListenersType
maListeners
;
/// When the broadcaster is about to die, collect listeners that asked for removal.
ListenersType
maDestructedListeners
;
/// Indicate that this broadcaster will be destructed (we indicate this on all ScColumn's broadcasters during the ScTable destruction, eg.)
bool
mbAboutToDie
:
1
;
bool
mbDisposing
:
1
;
bool
mbNormalized
:
1
;
...
...
svl/source/notify/broadcast.cxx
Dosyayı görüntüle @
c8b62432
...
...
@@ -35,18 +35,6 @@ public:
}
};
class
EndListeningHandler
:
std
::
unary_function
<
SvtListener
*
,
void
>
{
SvtBroadcaster
&
mrBC
;
public
:
EndListeningHandler
(
SvtBroadcaster
&
rBC
)
:
mrBC
(
rBC
)
{}
void
operator
()
(
SvtListener
*
p
)
{
p
->
EndListening
(
mrBC
);
}
};
class
NotifyHandler
:
std
::
unary_function
<
SvtListener
*
,
void
>
{
SvtBroadcaster
&
mrBC
;
...
...
@@ -81,9 +69,15 @@ void SvtBroadcaster::Add( SvtListener* p )
void
SvtBroadcaster
::
Remove
(
SvtListener
*
p
)
{
if
(
mb
AboutToDie
||
mb
Disposing
)
if
(
mbDisposing
)
return
;
if
(
mbAboutToDie
)
{
maDestructedListeners
.
push_back
(
p
);
return
;
}
Normalize
();
std
::
pair
<
ListenersType
::
iterator
,
ListenersType
::
iterator
>
r
=
std
::
equal_range
(
maListeners
.
begin
(),
maListeners
.
end
(),
p
);
...
...
@@ -107,8 +101,27 @@ SvtBroadcaster::~SvtBroadcaster()
mbDisposing
=
true
;
Broadcast
(
SfxSimpleHint
(
SFX_HINT_DYING
)
);
// unregister all listeners.
std
::
for_each
(
maListeners
.
begin
(),
maListeners
.
end
(),
EndListeningHandler
(
*
this
));
// normalize the list of listeners than already asked for destruction
std
::
sort
(
maDestructedListeners
.
begin
(),
maDestructedListeners
.
end
());
ListenersType
::
iterator
itUniqueEnd
=
std
::
unique
(
maDestructedListeners
.
begin
(),
maDestructedListeners
.
end
());
maDestructedListeners
.
erase
(
itUniqueEnd
,
maDestructedListeners
.
end
());
// and the list of registered listeners too
Normalize
();
// now when both lists are sorted, we can linearly unregister all
// listeners, with the exception of those that already asked to be removed
// during their own destruction
ListenersType
::
iterator
dest
(
maDestructedListeners
.
begin
());
for
(
ListenersType
::
iterator
it
(
maListeners
.
begin
());
it
<
maListeners
.
end
();
++
it
)
{
// skip the destructed ones
while
(
dest
!=
maDestructedListeners
.
end
()
&&
(
*
dest
<
*
it
))
++
dest
;
if
(
dest
==
maDestructedListeners
.
end
()
||
*
dest
!=
*
it
)
(
*
it
)
->
EndListening
(
*
this
);
}
}
void
SvtBroadcaster
::
Broadcast
(
const
SfxHint
&
rHint
)
...
...
@@ -133,4 +146,10 @@ bool SvtBroadcaster::HasListeners() const
return
!
maListeners
.
empty
();
}
void
SvtBroadcaster
::
PrepareForDestruction
()
{
mbAboutToDie
=
true
;
maDestructedListeners
.
reserve
(
maListeners
.
size
());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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