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:
Stefano Ceccherini
2008-09-17 14:38:12 +00:00
parent 8ade1bf7a6
commit b0a63e7a2a
2 changed files with 16 additions and 10 deletions
+15 -10
View File
@@ -148,11 +148,7 @@ TBarApp::~TBarApp()
int32 teamCount = sBarTeamInfoList.CountItems();
for (int32 i = 0; i < teamCount; i++) {
BarTeamInfo *barInfo = (BarTeamInfo *)sBarTeamInfoList.ItemAt(i);
delete barInfo->teams;
free(barInfo->sig);
delete barInfo->icon;
free(barInfo->name);
free(barInfo);
delete barInfo;
}
int32 subsCount = sSubscribers.CountItems();
@@ -551,11 +547,10 @@ TBarApp::Subscribe(const BMessenger &subscriber, BList *list)
int32 numTeams = sBarTeamInfoList.CountItems();
for (int32 i = 0; i < numTeams; i++) {
BarTeamInfo *barInfo = (BarTeamInfo *)sBarTeamInfoList.ItemAt(i);
BList *tList = new BList(*(barInfo->teams));
BBitmap *icon = new BBitmap(barInfo->icon);
ASSERT(icon);
list->AddItem(new BarTeamInfo(tList, barInfo->flags, strdup(barInfo->sig), icon, strdup(barInfo->name)));
BarTeamInfo *barInfo = (BarTeamInfo *)sBarTeamInfoList.ItemAt(i);
BarTeamInfo *newBarInfo = new (std::nothrow) BarTeamInfo(*barInfo);
if (newBarInfo != NULL)
list->AddItem(newBarInfo);
}
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()
{
delete teams;
+1
View File
@@ -52,6 +52,7 @@ class BarTeamInfo {
public:
BarTeamInfo(BList *teams, uint32 flags, char *sig, BBitmap *icon,
char *name);
BarTeamInfo(const BarTeamInfo &info);
~BarTeamInfo();
BList *teams;