浏览代码

Deactivate tempProfile when currentProfile is not includable. Fix #141.

FelisCatus 10 年之前
父节点
当前提交
0316041745
共有 1 个文件被更改,包括 10 次插入4 次删除
  1. 10 4
      omega-target/src/options.coffee

+ 10 - 4
omega-target/src/options.coffee

@@ -23,6 +23,7 @@ class Options
   _revertToProfileName: null
   _revertToProfileName: null
   _watchingProfiles: {}
   _watchingProfiles: {}
   _tempProfile: null
   _tempProfile: null
+  _tempProfileActive: false
   fallbackProfileName: 'system'
   fallbackProfileName: 'system'
   _isSystem: false
   _isSystem: false
   debugStr: 'Options'
   debugStr: 'Options'
@@ -519,7 +520,9 @@ class Options
     @currentProfileChanged(options?.reason)
     @currentProfileChanged(options?.reason)
     if options? and options.proxy == false
     if options? and options.proxy == false
       return Promise.resolve()
       return Promise.resolve()
-    if @_tempProfile?
+    @_tempProfileActive = false
+    if @_tempProfile? and OmegaPac.Profiles.isIncludable(profile)
+      @_tempProfileActive = true
       if @_tempProfile.defaultProfileName != profile.name
       if @_tempProfile.defaultProfileName != profile.name
         @_tempProfile.defaultProfileName = profile.name
         @_tempProfile.defaultProfileName = profile.name
         @_tempProfile.color = profile.color
         @_tempProfile.color = profile.color
@@ -614,7 +617,7 @@ class Options
   ###
   ###
   isCurrentProfileStatic: ->
   isCurrentProfileStatic: ->
     return true if not @_currentProfileName
     return true if not @_currentProfileName
-    return false if @_tempProfile
+    return false if @_tempProfileActive
     currentProfile = @currentProfile()
     currentProfile = @currentProfile()
     return false if OmegaPac.Profiles.isInclusive(currentProfile)
     return false if OmegaPac.Profiles.isInclusive(currentProfile)
     return true
     return true
@@ -898,8 +901,11 @@ class Options
     if not @_currentProfileName
     if not @_currentProfileName
       return Promise.resolve({profile: @_externalProfile, results: []})
       return Promise.resolve({profile: @_externalProfile, results: []})
     results = []
     results = []
-    profile = @_tempProfile
-    profile ?= OmegaPac.Profiles.byName(@_currentProfileName, @_options)
+    profile =
+      if @_tempProfileActive
+        @_tempProfile
+      else
+        OmegaPac.Profiles.byName(@_currentProfileName, @_options)
     while profile
     while profile
       lastProfile = profile
       lastProfile = profile
       result = OmegaPac.Profiles.match(profile, request)
       result = OmegaPac.Profiles.match(profile, request)