Skip to content

Commit

Permalink
Avoid runtime errors by following symlinks into some Exist() statements
Browse files Browse the repository at this point in the history
  • Loading branch information
kokoko3k committed Jan 4, 2017
1 parent e3c53ee commit 77f0012
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 25 deletions.
1 change: 1 addition & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Component=gb.desktop
Component=gb.eval
Component=gb.settings
Component=gb.gui.trayicon
Component=gb.inotify
Component=gb.net
Component=gb.util
Component=gb.web
Expand Down
12 changes: 7 additions & 5 deletions .settings
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ Geometry=[1497,374,443,280]
Geometry=[1495,518,224,280]

[DebugWindow/rResults[0]]
Geometry=[1336,497,525,280]
Geometry=[1509,532,224,280]

[DebugWindow/rResults[1]]
Geometry=[889,568,224,280]
Expand Down Expand Up @@ -493,9 +493,9 @@ Path="/tmp/higgins.gambas"

[OpenFile]
File[1]="higgins.desktop:16.7"
Active=7
Active=17
File[2]=".src/MySettings.module:27.14"
Count=19
Count=21
File[3]=".src/plugins/plugin_apps_gui.form"
File[4]=".src/plugins/plugin_indexer_gui.form"
File[5]=".src/plugins/plugin_015_recent.class:0.19"
Expand All @@ -507,12 +507,14 @@ File[10]=".src/MyDesktop.class:1.46"
File[11]=".src/XbindKeys.class:0.82"
File[12]=".src/hSettings.form"
File[13]=".src/StartClass.class:18.3"
File[14]=".src/plugins/plugin_020_apps.class:0.63"
File[14]=".src/plugins/plugin_020_apps.class:11.83"
File[15]=".src/DesktopApps.class:3.107"
File[16]=".src/gstyle.module:16.143"
File[17]=".src/plugins/plugin_090_indexer.class:25.288"
File[17]=".src/plugins/plugin_090_indexer.class:0.36"
File[18]=".src/plugins/bridge.class:6.119"
File[19]="appicon.png"
File[20]=".src/plugins/plugin_010_calculator.class:33.143"
File[21]=".src/plugins/plugin_indexer_gui.class:2.115"

[Watches]
Count=0
Expand Down
14 changes: 7 additions & 7 deletions .src/DesktopApps.class
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Static Public Sub MakeAppList()
$aApps = New String[]

For Each sPath In GetDataDir()
If Not Exist(sPath &/ "applications") Then Continue
If Not Exist(sPath &/ "applications", True) Then Continue
AddFile(sPath &/ "applications")
Next

Expand Down Expand Up @@ -207,7 +207,7 @@ Static Public Function _get(AppName As String) As DesktopApps
If $cApps.Exist(AppName) Then Return $cApps[AppName]
'For Each sPath In GetDataDir()
sAppPath = $cAppsPath[AppName]
If Exist(sAppPath) Then
If Exist(sAppPath, True) Then
hDApps = New DesktopApps
hDApps._$Path = sAppPath

Expand Down Expand Up @@ -327,7 +327,7 @@ Public Sub GetIcon(Optional Size As Integer = 16) As Image
Dim s As String

If $hImage Then Return $hImage
If Exist(_$IconName) Then
If Exist(_$IconName, True) Then
If _$IconName Ends ".svg" Then
hSvg = SvgImage.Load(_$IconName)
hImage = New Image(Size, Size, Color.Transparent)
Expand All @@ -346,12 +346,12 @@ Public Sub GetIcon(Optional Size As Integer = 16) As Image
'For Each sSize In [CStr(Size), "128", "64", "32"]
For Each sSize In [CStr(Size), "256", "128", "64", "48", "32" "22", "16", "8"]
sPath = Subst(sDir &/ "hicolor/&1x&1/apps/&2.png", sSize, _$IconName)
If Exist(sPath) Then
If Exist(sPath, True) Then
Try hImage = Image.Load(sPath)
If hImage Then Break
Endif
sPath = Subst(sDir &/ "hicolor/&1x&1/apps/&2.xpm", sSize, _$IconName)
If Exist(sPath) Then
If Exist(sPath, True) Then
Try hImage = Image.Load(sPath)
If hImage Then Break
Endif
Expand All @@ -360,12 +360,12 @@ Public Sub GetIcon(Optional Size As Integer = 16) As Image
Next
If Not hImage Then
sPath = Subst("/usr/share/pixmaps/&1.png", _$IconName)
If Exist(sPath) Then Try hImage = Image.Load(sPath)
If Exist(sPath, True) Then Try hImage = Image.Load(sPath)
Endif

If Not hImage Then
sPath = Subst("/usr/share/pixmaps/&1.xpm", _$IconName)
If Exist(sPath) Then Try hImage = Image.Load(sPath)
If Exist(sPath, True) Then Try hImage = Image.Load(sPath)
Endif

Endif
Expand Down
6 changes: 3 additions & 3 deletions .src/FMain.class
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ Public Sub start_item(i As Integer)
add_history(p)
Case "GUESS"

If Exist(p) Then
If Exist(p, True) Then

'desktop files with full path
'If Lower(p) Ends ".desktop" Then
Expand Down Expand Up @@ -519,7 +519,7 @@ Public Function is_executable(fPath As String) As Boolean
Endif

'has to exist
If Not Exist(exe) Then Return False
If Not Exist(exe, True) Then Return False
'has to be a file
If Stat(exe, True).type <> gb.File Then Return False
'needs executable permissions
Expand Down Expand Up @@ -1234,7 +1234,7 @@ Public Sub first_init()
MySettings.load()


If Not Exist(xb_rcpath) Then
If Not Exist(xb_rcpath, True) Then
msg = "No shortcut defined to hide/show the main window,"
msg &= "it is advised to define one in the options window."
Message.Optional(msg, "Ok", "dontshow_message_xbindKeys", "warning")
Expand Down
18 changes: 9 additions & 9 deletions .src/MyDesktop.class
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Static Public Sub GetIcon(dIconName As String, Optional Size As Integer = 16) As
Dim hSvg As SvgImage
Dim s As String

If Exist(dIconName) Then
If Exist(dIconName, True) Then
If dIconName Ends ".svg" Then
hSvg = SvgImage.Load(dIconName)
hImage = New Image(Size, Size, Color.transparent)
Expand All @@ -124,12 +124,12 @@ Static Public Sub GetIcon(dIconName As String, Optional Size As Integer = 16) As
'For Each sSize In [CStr(Size), "128", "64", "32"]
For Each sSize In [CStr(Size), "256", "128", "64", "48", "32" "22", "16", "8"]
sPath = Subst(sDir &/ "hicolor/&1x&1/apps/&2.png", sSize, dIconName)
If Exist(sPath) Then
If Exist(sPath, True) Then
Try hImage = Image.Load(sPath)
If hImage Then Break
Endif
sPath = Subst(sDir &/ "hicolor/&1x&1/apps/&2.xpm", sSize, dIconName)
If Exist(sPath) Then
If Exist(sPath, True) Then
Try hImage = Image.Load(sPath)
If hImage Then Break
Endif
Expand All @@ -139,12 +139,12 @@ Static Public Sub GetIcon(dIconName As String, Optional Size As Integer = 16) As

If Not hImage Then
sPath = Subst("/usr/share/pixmaps/&1.png", dIconName)
If Exist(sPath) Then Try hImage = Image.Load(sPath)
If Exist(sPath, True) Then Try hImage = Image.Load(sPath)
Endif

If Not hImage Then
sPath = Subst("/usr/share/pixmaps/&1.xpm", dIconName)
If Exist(sPath) Then Try hImage = Image.Load(sPath)
If Exist(sPath, True) Then Try hImage = Image.Load(sPath)
Endif

Endif
Expand Down Expand Up @@ -224,7 +224,7 @@ Static Public Sub Get_file_Icon(dIconName As String, Optional Size As Integer =
Dim s As String
Dim out As String

If Exist(dIconName) Then Return dIconName
If Exist(dIconName, True) Then Return dIconName

If ((dIconName Ends ".png") Or (dIconName Ends ".xpm")) Then dIconName = File.BaseName(dIconName)

Expand All @@ -233,7 +233,7 @@ Static Public Sub Get_file_Icon(dIconName As String, Optional Size As Integer =
For Each sSize In [CStr(Size), "256", "128", "64", "48", "32" "22", "16", "8"]

sPath = Subst(sDir &/ "hicolor/&1x&1/apps/&2.png", sSize, dIconName)
If Exist(sPath) Then
If Exist(sPath, True) Then
Try hImage = Image.Load(sPath)
If hImage Then
out = sPath
Expand All @@ -242,7 +242,7 @@ Static Public Sub Get_file_Icon(dIconName As String, Optional Size As Integer =
Endif

sPath = Subst(sDir &/ "hicolor/&1x&1/apps/&2.xpm", sSize, dIconName)
If Exist(sPath) Then
If Exist(sPath, True) Then
Try hImage = Image.Load(sPath)
If hImage Then
out = sPath
Expand All @@ -256,7 +256,7 @@ Static Public Sub Get_file_Icon(dIconName As String, Optional Size As Integer =
Next 'sDir

For Each sPath In [Subst("/usr/share/pixmaps/&1.png", dIconName), Subst("/usr/share/pixmaps/&1.xpm", dIconName)]
If Exist(sPath) Then
If Exist(sPath, True) Then
Try hImage = Image.Load(sPath)
If hImage Then
out = sPath
Expand Down
2 changes: 1 addition & 1 deletion .src/plugins/plugin_030_executable.class
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Public Sub find(textcontrol As Object) As RItemT[]

If Not trigged(textcontrol.text) Then Return

If Exist(current_search) Then
If Exist(current_search, True) Then
If Stat(current_search, True).type = gb.Directory Then Return
Endif

Expand Down
1 change: 1 addition & 0 deletions .startup
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gb.desktop
gb.eval
gb.settings
gb.gui.trayicon
gb.inotify
gb.net
gb.util
gb.web
Expand Down

0 comments on commit 77f0012

Please sign in to comment.