Commit 247a97b3 authored by Joris Guisson's avatar Joris Guisson
Browse files

Backported fix for 160935


svn path=/branches/ktorrent/3.0/; revision=799338
parent 89429100
......@@ -16,6 +16,7 @@ Changes in 3.0.2 :
- Sort and merge block list before writing to level1.dat file
- Clear time to next tracker update in tracker tab, when torrent is not
running (160972)
- Fix occasional crash at startup (160935)
Changes in 3.0.1 :
- Fix sessionTTL not being able to be bigger then 99
......
......@@ -203,6 +203,9 @@ namespace kt
GroupViewItem* GroupView::addGroup(Group* g,QTreeWidgetItem* parent)
{
if (!g)
return 0;
GroupViewItem* li = 0;
if (parent)
{
......
......@@ -50,51 +50,37 @@ namespace kt
GroupManager::GroupManager()
{
setAutoDelete(true);
default_groups.setAutoDelete(true);
Group* g = new AllGroup();
default_groups.insert(g->groupName(),g);
g = new UploadGroup();
default_groups.insert(g->groupName(),g);
g = new DownloadGroup();
default_groups.insert(g->groupName(),g);
g = new QueuedDownloadsGroup();
default_groups.insert(g->groupName(),g);
g = new QueuedUploadsGroup();
default_groups.insert(g->groupName(),g);
g = new UserDownloadsGroup();
default_groups.insert(g->groupName(),g);
g = new UserUploadsGroup();
default_groups.insert(g->groupName(),g);
g = new ActiveGroup();
default_groups.insert(g->groupName(),g);
g = new ActiveUploadsGroup();
default_groups.insert(g->groupName(),g);
g = new ActiveDownloadsGroup();
default_groups.insert(g->groupName(),g);
g = new InactiveGroup();
default_groups.insert(g->groupName(),g);
g = new InactiveUploadsGroup();
default_groups.insert(g->groupName(),g);
g = new InactiveDownloadsGroup();
default_groups.insert(g->groupName(),g);
all = new AllGroup();
upload = new UploadGroup();
download = new DownloadGroup();
queued_downloads = new QueuedDownloadsGroup();
queued_uploads = new QueuedUploadsGroup();
user_downloads = new UserDownloadsGroup();
user_uploads = new UserUploadsGroup();
active = new ActiveGroup();
active_uploads = new ActiveUploadsGroup();
active_downloads = new ActiveDownloadsGroup();
inactive = new InactiveGroup();
inactive_uploads = new InactiveUploadsGroup();
inactive_downloads = new InactiveDownloadsGroup();
}
GroupManager::~GroupManager()
{
delete all;
delete download;
delete upload;
delete queued_downloads;
delete queued_uploads;
delete user_downloads;
delete user_uploads;
delete inactive;
delete inactive_downloads;
delete inactive_uploads;
delete active;
delete active_downloads;
delete active_uploads;
}
......@@ -110,9 +96,23 @@ namespace kt
bool GroupManager::canRemove(const Group* g) const
{
return default_groups.find(g->groupName()) == 0;
return find(g->groupName()) != 0;
}
Group* GroupManager::findDefault(const QString & name)
{
QList<Group*> def;
def << all << download << upload << queued_downloads << queued_uploads << user_downloads
<< user_uploads << inactive << inactive_downloads << inactive_uploads << active
<< active_downloads << active_uploads;
foreach (Group* g,def)
{
if (g->groupName() == name)
return g;
}
return 0;
}
void GroupManager::saveGroups()
{
......@@ -217,9 +217,4 @@ namespace kt
setAutoDelete(true);
saveGroups();
}
Group* GroupManager::findDefault(const QString & name)
{
return default_groups.find(name);
}
}
......@@ -41,8 +41,19 @@ namespace kt
*/
class KTCORE_EXPORT GroupManager : public bt::PtrMap<QString,Group>
{
bt::PtrMap<QString,Group> default_groups;
Group* all;
Group* download;
Group* upload;
Group* queued_downloads;
Group* queued_uploads;
Group* user_downloads;
Group* user_uploads;
Group* inactive;
Group* inactive_downloads;
Group* inactive_uploads;
Group* active;
Group* active_downloads;
Group* active_uploads;
public:
GroupManager();
virtual ~GroupManager();
......@@ -55,45 +66,45 @@ namespace kt
Group* newGroup(const QString & name);
/// Get the group off all torrents
Group* allGroup() {return findDefault(i18n("All Torrents"));}
Group* allGroup() {return all;}
/// Get the group of downloads
Group* downloadGroup() {return findDefault(i18n("Downloads"));}
Group* downloadGroup() {return download;}
/// Get the group of seeds
Group* uploadGroup() {return findDefault(i18n("Uploads"));}
Group* uploadGroup() {return upload;}
/// Get the group of queued downloads
Group* queuedDownloadsGroup() { return findDefault(i18n("Queued downloads")); }
Group* queuedDownloadsGroup() { return queued_downloads; }
/// Get the group of queued seeds
Group* queuedUploadsGroup() { return findDefault(i18n("Queued uploads")); }
Group* queuedUploadsGroup() { return queued_uploads; }
/// Get the group of user controlled downloads
Group* userDownloadsGroup() { return findDefault(i18n("User downloads")); }
Group* userDownloadsGroup() { return user_downloads; }
/// Get the group of user controlled seeds
Group* userUploadsGroup() { return findDefault(i18n("User uploads")); }
Group* userUploadsGroup() { return user_uploads; }
/// Get the group of inactive torrents
Group* inactiveGroup() { return findDefault(i18n("Inactive torrents")); }
Group* inactiveGroup() { return inactive; }
/// Get the group of inactive downloads
Group* inactiveDownloadsGroup() { return findDefault(i18n("Inactive downloads")); }
Group* inactiveDownloadsGroup() { return inactive_downloads; }
/// Get the group of inactive uploads
Group* inactiveUploadsGroup() { return findDefault(i18n("Inactive uploads")); }
Group* inactiveUploadsGroup() { return inactive_uploads; }
/// Get the group of inactive torrents
Group* activeGroup() { return findDefault(i18n("Active torrents")); }
Group* activeGroup() { return active; }
/// Get the group of inactive downloads
Group* activeDownloadsGroup() { return findDefault(i18n("Active downloads")); }
Group* activeDownloadsGroup() { return active_downloads; }
/// Get the group of inactive uploads
Group* activeUploadsGroup() { return findDefault(i18n("Active uploads")); }
Group* activeUploadsGroup() { return active_uploads; }
/// Find a default group by the given name
/// Find a default Group given a name
Group* findDefault(const QString & name);
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment