Fixed favorite servers updating crash when nothing was selected on Servers tab.
This commit is contained in:
parent
3fc873ff2b
commit
ac57e6376c
@ -429,15 +429,17 @@ func (m *MainWindow) loadAllServers() {
|
|||||||
iter = server.AllServersIter
|
iter = server.AllServersIter
|
||||||
}
|
}
|
||||||
|
|
||||||
if !server.AllServersIterInList {
|
if m.all_servers_hide_offline.GetActive() && server.Server.Players == "" && server.Server.Maxplayers == "" {
|
||||||
m.all_servers_store.Append(iter)
|
if server.AllServersIterInList {
|
||||||
server.AllServersIterInList = true
|
m.all_servers_store.Remove(iter)
|
||||||
|
server.AllServersIterInList = false
|
||||||
|
}
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.all_servers_hide_offline.GetActive() && server.Server.Players == "" && server.Server.Maxplayers == "" && server.AllServersIterInList {
|
if !server.AllServersIterInList && server.AllServersIterSet {
|
||||||
m.all_servers_store.Remove(iter)
|
m.all_servers_store.Append(iter)
|
||||||
server.AllServersIterInList = false
|
server.AllServersIterInList = true
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if server.Server.Name == "" && server.Server.Players == "" && server.Server.Maxplayers == "" {
|
if server.Server.Name == "" && server.Server.Players == "" && server.Server.Maxplayers == "" {
|
||||||
@ -465,15 +467,6 @@ func (m *MainWindow) loadAllServers() {
|
|||||||
func (m *MainWindow) loadFavoriteServers() {
|
func (m *MainWindow) loadFavoriteServers() {
|
||||||
fmt.Println("Loading favorite servers...")
|
fmt.Println("Loading favorite servers...")
|
||||||
for _, server := range ctx.Cache.Servers {
|
for _, server := range ctx.Cache.Servers {
|
||||||
if server.Server.Favorite != "1" && server.FavServersIterSet && server.FavServersIterInList {
|
|
||||||
m.fav_servers_store.Remove(server.FavServersIter)
|
|
||||||
server.FavServersIterInList = false
|
|
||||||
}
|
|
||||||
|
|
||||||
if server.Server.Favorite != "1" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
iter := new(gtk.TreeIter)
|
iter := new(gtk.TreeIter)
|
||||||
|
|
||||||
if !server.FavServersIterSet {
|
if !server.FavServersIterSet {
|
||||||
@ -483,17 +476,32 @@ func (m *MainWindow) loadFavoriteServers() {
|
|||||||
iter = server.FavServersIter
|
iter = server.FavServersIter
|
||||||
}
|
}
|
||||||
|
|
||||||
if !server.FavServersIterInList {
|
if m.fav_servers_hide_offline.GetActive() && server.Server.Players == "" && server.Server.Maxplayers == "" {
|
||||||
m.fav_servers_store.Append(iter)
|
if server.FavServersIterInList {
|
||||||
server.FavServersIterInList = true
|
m.fav_servers_store.Remove(iter)
|
||||||
|
server.FavServersIterInList = false
|
||||||
|
}
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.fav_servers_hide_offline.GetActive() && server.Server.Players == "" && server.Server.Maxplayers == "" && server.FavServersIterInList {
|
// If server on favorites widget, but not favorited (e.g. just
|
||||||
m.fav_servers_store.Remove(iter)
|
// removed from favorites) - remove it from list.
|
||||||
|
if server.Server.Favorite != "1" && server.FavServersIterSet && server.FavServersIterInList {
|
||||||
|
m.fav_servers_store.Remove(server.FavServersIter)
|
||||||
server.FavServersIterInList = false
|
server.FavServersIterInList = false
|
||||||
|
server.FavServersIterSet = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Server isn't in favorites and wasn't previously added to widget.
|
||||||
|
if server.Server.Favorite != "1" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !server.FavServersIterInList && server.FavServersIterSet {
|
||||||
|
m.fav_servers_store.Append(iter)
|
||||||
|
server.FavServersIterInList = true
|
||||||
|
}
|
||||||
|
|
||||||
if server.Server.Name == "" && server.Server.Players == "" {
|
if server.Server.Name == "" && server.Server.Players == "" {
|
||||||
m.fav_servers_store.SetValue(iter, 0, m.server_offline_pic.GPixbuf)
|
m.fav_servers_store.SetValue(iter, 0, m.server_offline_pic.GPixbuf)
|
||||||
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"]["IP"], server.Server.Ip + ":" + server.Server.Port)
|
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"]["IP"], server.Server.Ip + ":" + server.Server.Port)
|
||||||
|
@ -21,22 +21,24 @@ func (m *MainWindow) getGameModeName(name string) string {
|
|||||||
|
|
||||||
func (m *MainWindow) getIpFromServersList(current_tab string) string {
|
func (m *MainWindow) getIpFromServersList(current_tab string) string {
|
||||||
// Getting server's address from list.
|
// Getting server's address from list.
|
||||||
|
// Assuming that we're on "Servers" tab by default.
|
||||||
sel := m.all_servers.GetSelection()
|
sel := m.all_servers.GetSelection()
|
||||||
model := m.all_servers.GetModel()
|
model := m.all_servers.GetModel()
|
||||||
|
if strings.Contains(current_tab, "Favorites") {
|
||||||
|
sel = m.fav_servers.GetSelection()
|
||||||
|
model = m.fav_servers.GetModel()
|
||||||
|
}
|
||||||
|
|
||||||
iter := new(gtk.TreeIter)
|
iter := new(gtk.TreeIter)
|
||||||
_ = sel.GetSelected(iter)
|
_ = sel.GetSelected(iter)
|
||||||
|
|
||||||
// Getting server address.
|
// Getting server address.
|
||||||
var srv_addr string
|
var srv_addr string
|
||||||
srv_addr_gval := glib.ValueFromNative(srv_addr)
|
srv_addr_gval := glib.ValueFromNative(srv_addr)
|
||||||
model.GetValue(iter, m.column_pos["Servers"]["IP"], srv_addr_gval)
|
|
||||||
|
|
||||||
if strings.Contains(current_tab, "Favorites") {
|
if strings.Contains(current_tab, "Servers") {
|
||||||
// Getting server's address from list.
|
model.GetValue(iter, m.column_pos["Servers"]["IP"], srv_addr_gval)
|
||||||
sel = m.fav_servers.GetSelection()
|
} else if strings.Contains(current_tab, "Favorites") {
|
||||||
model = m.fav_servers.GetModel()
|
|
||||||
iter := new(gtk.TreeIter)
|
|
||||||
_ = sel.GetSelected(iter)
|
|
||||||
model.GetValue(iter, m.column_pos["Favorites"]["IP"], srv_addr_gval)
|
model.GetValue(iter, m.column_pos["Favorites"]["IP"], srv_addr_gval)
|
||||||
}
|
}
|
||||||
server_address := srv_addr_gval.GetString()
|
server_address := srv_addr_gval.GetString()
|
||||||
|
Reference in New Issue
Block a user