if !danmu_win_running {return false}
el := keep_list.Front()
if el != nil && time.Now().After(el.Value.(gtk_item_source).time) {
- if i,e := grid1.GetChildAt(0,0); e != nil{i.(*gtk.Widget).Destroy()}
- if i,e := grid1.GetChildAt(1,0); e != nil{i.(*gtk.Widget).Destroy()}
- grid1.RemoveRow(0)
+ if grid1.Container.GetChildren().Length() > 0 {
+ if i,e := grid1.GetChildAt(0,0); e == nil{
+ i.ToWidget().Destroy()
+ }
+ if i,e := grid1.GetChildAt(1,0); e == nil{
+ i.ToWidget().Destroy()
+ }
+ grid1.RemoveRow(0)
+ }
show(el.Value.(gtk_item_source).text,el.Value.(gtk_item_source).img, 0)
keep_list.Remove(el)
el = el.Next()
old_cu != cu {//上一次滚动有移动
return true
}
-
+
+ loc := int(grid0.Container.GetChildren().Length())/2
step := (max - cu) / 30
- if step > 20 || max > 5 * float64(h){//太长或太快
- if i,e := grid0.GetChildAt(0,0); e != nil{i.(*gtk.Widget).Destroy()}
- if i,e := grid0.GetChildAt(1,0); e != nil{i.(*gtk.Widget).Destroy()}
+ if loc > 0 && step > 20 || max > 5 * float64(h){//太长或太快
+ if i,e := grid0.GetChildAt(0,0); e == nil{
+ i.ToWidget().Destroy()
+ }
+ if i,e := grid0.GetChildAt(1,0); e == nil{
+ i.ToWidget().Destroy()
+ }
grid0.RemoveRow(0)
} else if step > 0.5 {
if step > 5{step = 5}
} else {
in_smooth_roll = false
tmp.SetValue(max)
- loc := int(grid0.Container.GetChildren().Length())/2
- if v,ok := K_v[`gtk_保留弹幕数量`].(int);ok {
- loc -= v
+ if v,ok := K_v[`gtk_保留弹幕数量`].(float64);ok {
+ loc -= int(v)
} else {
loc -= 25
}
for loc > 0 {
- if i,e := grid0.GetChildAt(0,0); e != nil{i.(*gtk.Widget).Destroy()}
- if i,e := grid0.GetChildAt(1,0); e != nil{i.(*gtk.Widget).Destroy()}
+ if i,e := grid0.GetChildAt(0,0); e == nil{
+ i.ToWidget().Destroy()
+ }
+ if i,e := grid0.GetChildAt(1,0); e == nil{
+ i.ToWidget().Destroy()
+ }
grid0.RemoveRow(0)
loc -= 1
}
loc = Gtk_img_path + `/` + uid
return
}
- if v,ok := K_v[`gtk_头像获取等待最大数量`].(int);ok && len(gtkGetList) > v {return}
+ if v,ok := K_v[`gtk_头像获取等待最大数量`].(float64);ok && len(gtkGetList) > int(v) {return}
select{
case gtkGetList <- uid:
default:
}
func show(s,img_src string,to_grid ...int){
-
+ if s == `` || img_src == `` {return}
glib.TimeoutAdd(uint(1),func()(r bool){
r = false
var item danmu_item
- item.text,_ = gtk.TextViewNew();
+ item.text,_ = gtk.TextViewNew()
{
item.text.SetMarginStart(5)
item.text.SetEditable(false)
sty.AddClass("highlight")
}
}
- item.handle,_ = item.text.Connect("size-allocate", func(_ interface{},_ interface{},item *danmu_item){
- if item == nil {return}
- // item.text.HandlerDisconnect(item.handle)
+ item.handle,_ = item.text.Connect("size-allocate", func(_,_ interface{},item *danmu_item){
+ if item == nil || (*item).text == nil {return}
b,e := (*item).text.GetBuffer()
if e != nil {log.Println(e);return}
b.SetText(s)
pixbuf,e = gdk.PixbufNewFromFileAtSize(img_src, 40, 40);
if e == nil {
imgbuf.Lock()
- if v,ok := K_v[`gtk_内存头像数量`].(int);ok && len(imgbuf.b) > v {
- for k,_ := range imgbuf.b {delete(imgbuf.b,k);break}
+ if v,ok := K_v[`gtk_内存头像数量`].(float64);ok && len(imgbuf.b) > int(v) + 10 {
+ for k,_ := range imgbuf.b {
+ delete(imgbuf.b,k)
+ if len(imgbuf.b) <= int(v) {break}
+ }
}
imgbuf.b[img_src],e = gdk.PixbufCopy(pixbuf)
imgbuf.Unlock()
import (
"time"
- "runtime"
+ // "runtime"
// "runtime/pprof"
"os"
// "log"
- "net/http"
+ // "net/http"
"fmt"
- _ "net/http/pprof"
+ // _ "net/http/pprof"
"runtime/debug"
// "github.com/skratchdot/open-golang/open"
q "github.com/qydysky/bili_danmu"
)
func main() {
- go func() {
- http.ListenAndServe("0.0.0.0:8899", nil)
- }()
+ // go func() {
+ // http.ListenAndServe("0.0.0.0:8899", nil)
+ // }()
// defer func(){
// open.Run("http://127.0.0.1:8899/debug/pprof/goroutine?debug=2")
// time.Sleep(time.Duration(3)*time.Second)
}
func View(){
- var memStats runtime.MemStats
- runtime.ReadMemStats(&memStats)
+ // var memStats runtime.MemStats
+ // runtime.ReadMemStats(&memStats)
fmt.Printf("=====\n")
fmt.Printf("PID:%d\n",os.Getpid())
- fmt.Printf("总内存:%v MB\n",memStats.Alloc/1024e2/8)
- fmt.Printf("GC次数:%v \n",memStats.NumGC)
- fmt.Printf("堆 :%v %v MB\n",memStats.HeapInuse/1024e2/8,(memStats.HeapIdle - memStats.HeapReleased)/1024e2/8)
+ // fmt.Printf("总内存:%v MB\n",memStats.Alloc/1024e2/8)
+ // fmt.Printf("GC次数:%v \n",memStats.NumGC)
+ // fmt.Printf("堆 :%v %v MB\n",memStats.HeapInuse/1024e2/8,(memStats.HeapIdle - memStats.HeapReleased)/1024e2/8)
fmt.Printf("=====\n")
}
\ No newline at end of file