Skip to content

Commit

Permalink
Fixes a bug loading a recent pcap after a clear operation
Browse files Browse the repository at this point in the history
Reproduce like this:
- run termshark via termshark -r foo.pcap
- select clear from the menu to reset the UI
- select foo.pcap from the recents menu

Prior to this fix, the pcap would not load.
  • Loading branch information
gcla committed Sep 11, 2020
1 parent 78cf195 commit a77ccd8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pcap/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ func (c *Scheduler) RequestLoadPcap(pcap string, displayFilter string, cb interf
// the loader is currently reading from a file, the loading *stops*.
func (c *Loader) doClearPcapOperation(cb interface{}, fn RunFn) {
if c.State() == 0 {
c.clearSource()
c.resetData()

handleClear(cb)
Expand Down Expand Up @@ -827,6 +828,14 @@ func (c *Loader) startLoadNewFilter(displayFilter string, cb interface{}) {
c.startLoadPsml(cb)
}

func (c *Loader) clearSource() {
c.psrcs = make([]IPacketSource, 0)
c.ifaceFile = ""
c.PcapPsml = ""
c.PcapPdml = ""
c.PcapPcap = ""
}

func (c *Loader) startLoadNewFile(pcap string, displayFilter string, cb interface{}) {
c.psrcs = []IPacketSource{FileSource{Filename: pcap}}
c.ifaceFile = ""
Expand Down

0 comments on commit a77ccd8

Please sign in to comment.