implemented BarTeamInfo copy constructor and used it in TBarApp::Subscribe(). Also cleaned up a bit the code in TBarApp destructor.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27596 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+15
-10
@@ -148,11 +148,7 @@ TBarApp::~TBarApp()
|
|||||||
int32 teamCount = sBarTeamInfoList.CountItems();
|
int32 teamCount = sBarTeamInfoList.CountItems();
|
||||||
for (int32 i = 0; i < teamCount; i++) {
|
for (int32 i = 0; i < teamCount; i++) {
|
||||||
BarTeamInfo *barInfo = (BarTeamInfo *)sBarTeamInfoList.ItemAt(i);
|
BarTeamInfo *barInfo = (BarTeamInfo *)sBarTeamInfoList.ItemAt(i);
|
||||||
delete barInfo->teams;
|
delete barInfo;
|
||||||
free(barInfo->sig);
|
|
||||||
delete barInfo->icon;
|
|
||||||
free(barInfo->name);
|
|
||||||
free(barInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 subsCount = sSubscribers.CountItems();
|
int32 subsCount = sSubscribers.CountItems();
|
||||||
@@ -551,11 +547,10 @@ TBarApp::Subscribe(const BMessenger &subscriber, BList *list)
|
|||||||
|
|
||||||
int32 numTeams = sBarTeamInfoList.CountItems();
|
int32 numTeams = sBarTeamInfoList.CountItems();
|
||||||
for (int32 i = 0; i < numTeams; i++) {
|
for (int32 i = 0; i < numTeams; i++) {
|
||||||
BarTeamInfo *barInfo = (BarTeamInfo *)sBarTeamInfoList.ItemAt(i);
|
BarTeamInfo *barInfo = (BarTeamInfo *)sBarTeamInfoList.ItemAt(i);
|
||||||
BList *tList = new BList(*(barInfo->teams));
|
BarTeamInfo *newBarInfo = new (std::nothrow) BarTeamInfo(*barInfo);
|
||||||
BBitmap *icon = new BBitmap(barInfo->icon);
|
if (newBarInfo != NULL)
|
||||||
ASSERT(icon);
|
list->AddItem(newBarInfo);
|
||||||
list->AddItem(new BarTeamInfo(tList, barInfo->flags, strdup(barInfo->sig), icon, strdup(barInfo->name)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 subsCount = sSubscribers.CountItems();
|
int32 subsCount = sSubscribers.CountItems();
|
||||||
@@ -734,6 +729,16 @@ BarTeamInfo::BarTeamInfo(BList *teams, uint32 flags, char *sig, BBitmap *icon, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BarTeamInfo::BarTeamInfo(const BarTeamInfo &info)
|
||||||
|
: teams(new BList(*info.teams)),
|
||||||
|
flags(info.flags),
|
||||||
|
sig(strdup(info.sig)),
|
||||||
|
icon(new BBitmap(*info.icon)),
|
||||||
|
name(strdup(info.name))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BarTeamInfo::~BarTeamInfo()
|
BarTeamInfo::~BarTeamInfo()
|
||||||
{
|
{
|
||||||
delete teams;
|
delete teams;
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ class BarTeamInfo {
|
|||||||
public:
|
public:
|
||||||
BarTeamInfo(BList *teams, uint32 flags, char *sig, BBitmap *icon,
|
BarTeamInfo(BList *teams, uint32 flags, char *sig, BBitmap *icon,
|
||||||
char *name);
|
char *name);
|
||||||
|
BarTeamInfo(const BarTeamInfo &info);
|
||||||
~BarTeamInfo();
|
~BarTeamInfo();
|
||||||
|
|
||||||
BList *teams;
|
BList *teams;
|
||||||
|
|||||||
Reference in New Issue
Block a user