Skip to content

Commit d300dd9

Browse files
Fix running from installed file and installer
Installer missed out profiles/ also ensure that if profiles is missing an error message is displayed
1 parent 8674986 commit d300dd9

File tree

3 files changed

+41
-27
lines changed

3 files changed

+41
-27
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
/libEDSsharp/bin/Release
1111
/.vs/EDSTest/v14/*.suo
1212
/.vs/EDSEditor/v14/*.suo
13+
edseditor-Setup.exe

EDSTest/Form1.cs

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -61,42 +61,50 @@ private void loadprofiles()
6161
// load user profiles from the My Documents\.edseditor\profiles\ folder
6262
// Personal is my documents in windows and ~ in mono
6363

64-
List<string> profilelist = Directory.GetFiles(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + "Profiles").ToList();
65-
string homepath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".edseditor");
66-
homepath = Path.Combine(homepath, "profiles");
67-
68-
if (Directory.Exists(homepath))
64+
try
6965
{
70-
profilelist.AddRange(Directory.GetFiles(homepath).ToList());
71-
}
7266

73-
int count = 0;
74-
//some attempt to validate files
67+
List<string> profilelist = Directory.GetFiles(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + "Profiles").ToList();
68+
string homepath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".edseditor");
69+
homepath = Path.Combine(homepath, "profiles");
7570

76-
foreach (string file in profilelist)
77-
{
78-
if (Path.GetExtension(file) == ".xml")
79-
count++;
80-
}
71+
if (Directory.Exists(homepath))
72+
{
73+
profilelist.AddRange(Directory.GetFiles(homepath).ToList());
74+
}
75+
76+
int count = 0;
77+
//some attempt to validate files
78+
79+
foreach (string file in profilelist)
80+
{
81+
if (Path.GetExtension(file) == ".xml")
82+
count++;
83+
}
8184

8285

83-
ToolStripMenuItem[] items = new ToolStripMenuItem[count];
86+
ToolStripMenuItem[] items = new ToolStripMenuItem[count];
8487

85-
int x = 0;
86-
foreach(string file in profilelist)
87-
{
88-
if (Path.GetExtension(file) == ".xml")
88+
int x = 0;
89+
foreach (string file in profilelist)
8990
{
90-
ToolStripMenuItem i = new ToolStripMenuItem();
91-
i.Name = Path.GetFileName(file);
92-
i.Text = Path.GetFileName(file);
93-
i.Click += ProfileAddClick;
94-
i.Image = Properties.Resources.InsertColumn_5626;
95-
items[x++] = i;
91+
if (Path.GetExtension(file) == ".xml")
92+
{
93+
ToolStripMenuItem i = new ToolStripMenuItem();
94+
i.Name = Path.GetFileName(file);
95+
i.Text = Path.GetFileName(file);
96+
i.Click += ProfileAddClick;
97+
i.Image = Properties.Resources.InsertColumn_5626;
98+
items[x++] = i;
99+
}
96100
}
97-
}
98101

99-
insertToolStripMenuItem.DropDownItems.AddRange(items);
102+
insertToolStripMenuItem.DropDownItems.AddRange(items);
103+
}
104+
catch (Exception e)
105+
{
106+
MessageBox.Show("Loading profiles has failed for the following reason :\n" + e.ToString());
107+
}
100108

101109
}
102110

setup.nsi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ Section "OpenEdsEditor" Secopeneds ;No components page, name is not important
6363
File EDSTest\bin\Release\style.css
6464
File Index_8287_16x.ico
6565
File License-GPLv3.txt
66+
67+
SetOutPath $INSTDIR\Profiles
68+
File EDSTest\Profiles\*
6669

6770
SetShellVarContext all
6871
CreateDirectory "$SMPROGRAMS\OpenEDSEditor"
@@ -102,6 +105,8 @@ Section "Uninstall"
102105
;ADD YOUR OWN FILES HERE...
103106

104107
Delete "$INSTDIR\*"
108+
Delete "$INSTDIR\Profiles\*"
109+
RMDir "$INSTDIR\Profiles"
105110
RMDir "$INSTDIR"
106111

107112
SetShellVarContext all

0 commit comments

Comments
 (0)