mirror of https://github.com/odrling/Aegisub
Logic changes to installer:
* Protect more code with try/except blocks, hoping to crash less in some strange circumstances we haven't been able to reproduce, including the KIS 8 problem. (Updates #925. ON ERROR RESUME NEXT) * Instead of deleting an old Aegisub.exe, rename it to aegisub32.exe to teach Windows Distributed Link Tracking thingy that it's in fact the same thing, just with a new name. Originally committed to SVN as r3738.
This commit is contained in:
parent
9682009b24
commit
3849ab0ebd
|
@ -310,10 +310,15 @@ begin
|
||||||
// Check for uninstall entry for runtimes, don't bother installing if it can be uninstalled now
|
// Check for uninstall entry for runtimes, don't bother installing if it can be uninstalled now
|
||||||
// HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9A25302D-30C0-39D9-BD6F-21E6EC160475}
|
// HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9A25302D-30C0-39D9-BD6F-21E6EC160475}
|
||||||
// Check: DisplayVersion = "9.0.30729"
|
// Check: DisplayVersion = "9.0.30729"
|
||||||
DisplayVersion := '';
|
try
|
||||||
Result := RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9A25302D-30C0-39D9-BD6F-21E6EC160475}',
|
DisplayVersion := '';
|
||||||
'DisplayVersion', DisplayVersion);
|
Result := RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9A25302D-30C0-39D9-BD6F-21E6EC160475}',
|
||||||
Result := Result and (DisplayVersion = '9.0.30729');
|
'DisplayVersion', DisplayVersion);
|
||||||
|
Result := Result and (DisplayVersion = '9.0.30729');
|
||||||
|
except
|
||||||
|
// If the check fails take the safe route
|
||||||
|
Result := False;
|
||||||
|
end;
|
||||||
|
|
||||||
Result := not Result;
|
Result := not Result;
|
||||||
end;
|
end;
|
||||||
|
@ -333,27 +338,27 @@ begin
|
||||||
// Thanks to ender for the following snippets
|
// Thanks to ender for the following snippets
|
||||||
|
|
||||||
// Fix bitmaps for small/large fonts
|
// Fix bitmaps for small/large fonts
|
||||||
if WizardForm.WizardBitmapImage.Height < 386 then //use smaller image when not using Large Fonts
|
if WizardForm.WizardBitmapImage.Height < 386 then //use smaller image when not using Large Fonts
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
ExtractTemporaryFile('welcome.bmp');
|
ExtractTemporaryFile('welcome.bmp');
|
||||||
SmallBitmap := TFileStream.Create(ExpandConstant('{tmp}\welcome.bmp'),fmOpenRead);
|
SmallBitmap := TFileStream.Create(ExpandConstant('{tmp}\welcome.bmp'),fmOpenRead);
|
||||||
WizardForm.WizardBitmapImage.Bitmap.LoadFromStream(SmallBitmap);
|
WizardForm.WizardBitmapImage.Bitmap.LoadFromStream(SmallBitmap);
|
||||||
WizardForm.WizardBitmapImage2.Bitmap := WizardForm.WizardBitmapImage.Bitmap;
|
WizardForm.WizardBitmapImage2.Bitmap := WizardForm.WizardBitmapImage.Bitmap;
|
||||||
SmallBitmap.Free;
|
SmallBitmap.Free;
|
||||||
|
|
||||||
ExtractTemporaryFile('aegisub.bmp');
|
ExtractTemporaryFile('aegisub.bmp');
|
||||||
SmallBitmap := TFileStream.Create(ExpandConstant('{tmp}\aegisub.bmp'),fmOpenRead);
|
SmallBitmap := TFileStream.Create(ExpandConstant('{tmp}\aegisub.bmp'),fmOpenRead);
|
||||||
WizardForm.WizardSmallBitmapImage.Bitmap.LoadFromStream(SmallBitmap);
|
WizardForm.WizardSmallBitmapImage.Bitmap.LoadFromStream(SmallBitmap);
|
||||||
except
|
except
|
||||||
Log('Error loading bitmaps: ' + GetExceptionMessage);
|
Log('Error loading bitmaps: ' + GetExceptionMessage);
|
||||||
finally
|
finally
|
||||||
SmallBitmap.Free;
|
SmallBitmap.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Endow install dir edit box with autocomplete
|
// Endow install dir edit box with autocomplete
|
||||||
try
|
try
|
||||||
SHAutoComplete(WizardForm.DirEdit.Handle, SHACF_FILESYSTEM);
|
SHAutoComplete(WizardForm.DirEdit.Handle, SHACF_FILESYSTEM);
|
||||||
except
|
except
|
||||||
Log('Could not add autocomplete to dir edit box');
|
Log('Could not add autocomplete to dir edit box');
|
||||||
|
@ -369,20 +374,26 @@ end;
|
||||||
|
|
||||||
function InitializeSetup: Boolean;
|
function InitializeSetup: Boolean;
|
||||||
begin
|
begin
|
||||||
HasLegacyVersion := RegValueExists(HKLM, 'SOFTWARE\Aegisub\info', 'InstVer');
|
|
||||||
Log(Format('Legacy version found: %s', [BoolToStr(HasLegacyVersion)]));
|
|
||||||
|
|
||||||
LegacyStartMenuFolder := 'Aegisub';
|
LegacyStartMenuFolder := 'Aegisub';
|
||||||
if RegQueryStringValue(HKLM, 'SOFTWARE\Aegisub\info', 'StartMenuDir', LegacyStartMenuFolder) then
|
|
||||||
LegacyStartMenuFolder := ExpandConstant('{userprograms}\') + LegacyStartMenuFolder;
|
|
||||||
Log(Format('Legacy version Start menu folder: %s', [LegacyStartMenuFolder]));
|
|
||||||
|
|
||||||
LegacyInstallFolder := ExpandConstant('{pf}\Aegisub');
|
LegacyInstallFolder := ExpandConstant('{pf}\Aegisub');
|
||||||
RegQueryStringValue(HKLM, 'SOFTWARE\Aegisub\info', 'InstallDir', LegacyInstallFolder);
|
|
||||||
Log(Format('Legacy version install folder: %s', [LegacyInstallFolder]));
|
|
||||||
|
|
||||||
LegacyVersionNumber := '1.x';
|
LegacyVersionNumber := '1.x';
|
||||||
RegQueryStringValue(HKLM, 'SOFTWARE\Aegisub\info', 'InstVer', LegacyVersionNumber);
|
|
||||||
|
try
|
||||||
|
HasLegacyVersion := RegValueExists(HKLM, 'SOFTWARE\Aegisub\info', 'InstVer');
|
||||||
|
Log(Format('Legacy version found: %s', [BoolToStr(HasLegacyVersion)]));
|
||||||
|
|
||||||
|
if RegQueryStringValue(HKLM, 'SOFTWARE\Aegisub\info', 'StartMenuDir', LegacyStartMenuFolder) then
|
||||||
|
LegacyStartMenuFolder := ExpandConstant('{userprograms}\') + LegacyStartMenuFolder;
|
||||||
|
Log(Format('Legacy version Start menu folder: %s', [LegacyStartMenuFolder]));
|
||||||
|
|
||||||
|
RegQueryStringValue(HKLM, 'SOFTWARE\Aegisub\info', 'InstallDir', LegacyInstallFolder);
|
||||||
|
Log(Format('Legacy version install folder: %s', [LegacyInstallFolder]));
|
||||||
|
|
||||||
|
RegQueryStringValue(HKLM, 'SOFTWARE\Aegisub\info', 'InstVer', LegacyVersionNumber);
|
||||||
|
except
|
||||||
|
Log('An exception occurred while trying to detect a legacy installation of Aegisub. Assuming there isn''t one.');
|
||||||
|
HasLegacyVersion := False;
|
||||||
|
end;
|
||||||
|
|
||||||
Result := True;
|
Result := True;
|
||||||
if HasLegacyVersion then
|
if HasLegacyVersion then
|
||||||
|
@ -396,33 +407,37 @@ var
|
||||||
NewCatalogDir: string;
|
NewCatalogDir: string;
|
||||||
search: TFindRec;
|
search: TFindRec;
|
||||||
begin
|
begin
|
||||||
// Upgrade an 1.x style-catalog by moving it to {appdata}
|
try
|
||||||
OldCatalogDir := OldInstallFolder('') + '\Catalog\';
|
// Upgrade an 1.x style-catalog by moving it to {appdata}
|
||||||
Log('-- Migrate style catalogs --');
|
OldCatalogDir := OldInstallFolder('') + '\Catalog\';
|
||||||
if DirExists(OldCatalogDir) then
|
Log('-- Migrate style catalogs --');
|
||||||
begin
|
if DirExists(OldCatalogDir) then
|
||||||
NewCatalogDir := ExpandConstant('{userappdata}\Aegisub\catalog\');
|
begin
|
||||||
ForceDirectories(NewCatalogDir);
|
NewCatalogDir := ExpandConstant('{userappdata}\Aegisub\catalog\');
|
||||||
Log('Old style catalog dir: ' + OldCatalogDir);
|
ForceDirectories(NewCatalogDir);
|
||||||
Log('New catalog dir: ' + NewCatalogDir);
|
Log('Old style catalog dir: ' + OldCatalogDir);
|
||||||
if FindFirst(OldCatalogDir + '*', search) then
|
Log('New catalog dir: ' + NewCatalogDir);
|
||||||
try
|
if FindFirst(OldCatalogDir + '*', search) then
|
||||||
repeat
|
try
|
||||||
Log('Found style catalog: ' + OldCatalogDir + search.Name);
|
repeat
|
||||||
if FileCopy(OldCatalogDir+search.Name, NewCatalogDir+search.Name, True) then
|
Log('Found style catalog: ' + OldCatalogDir + search.Name);
|
||||||
begin
|
if FileCopy(OldCatalogDir+search.Name, NewCatalogDir+search.Name, True) then
|
||||||
Log('Copied catalog to: ' + NewCatalogDir+search.Name);
|
begin
|
||||||
DeleteFile(OldCatalogDir+search.Name);
|
Log('Copied catalog to: ' + NewCatalogDir+search.Name);
|
||||||
end;
|
DeleteFile(OldCatalogDir+search.Name);
|
||||||
until not FindNext(search);
|
end;
|
||||||
finally
|
until not FindNext(search);
|
||||||
FindClose(search);
|
finally
|
||||||
Log('Done migrating styles');
|
FindClose(search);
|
||||||
end;
|
Log('Done migrating styles');
|
||||||
RemoveDir(OldCatalogDir);
|
end;
|
||||||
end
|
RemoveDir(OldCatalogDir);
|
||||||
else
|
end
|
||||||
Log('No existing style catalog collection found');
|
else
|
||||||
|
Log('No existing style catalog collection found');
|
||||||
|
except
|
||||||
|
Log('An exception occurred while trying to migrate style catalogues.');
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -520,6 +535,9 @@ begin
|
||||||
page.SetText('Uninstallation complete', '');
|
page.SetText('Uninstallation complete', '');
|
||||||
page.SetProgress(totalitems, totalitems);
|
page.SetProgress(totalitems, totalitems);
|
||||||
|
|
||||||
|
except
|
||||||
|
Log('An exception occurred while trying to uninstall a legacy version');
|
||||||
|
|
||||||
finally
|
finally
|
||||||
shortcut_list.Free;
|
shortcut_list.Free;
|
||||||
file_list.Free;
|
file_list.Free;
|
||||||
|
@ -565,8 +583,10 @@ begin
|
||||||
dir_list := TStringList.Create;
|
dir_list := TStringList.Create;
|
||||||
dir_list.LoadFromFile(ExpandConstant('{tmp}\old_dirlist.txt'));
|
dir_list.LoadFromFile(ExpandConstant('{tmp}\old_dirlist.txt'));
|
||||||
itemsdone := 0;
|
itemsdone := 0;
|
||||||
totalitems := file_list.Count + dir_list.Count + shortcut_list.Count + locale_list.Count + 1;
|
totalitems := file_list.Count + dir_list.Count + shortcut_list.Count + locale_list.Count + 2;
|
||||||
// One extra for the start menu folder
|
// Two extra:
|
||||||
|
// - Start menu folder
|
||||||
|
// - Renaming Aegisub.exe to aegiub32.exe
|
||||||
|
|
||||||
StartMenuFolder := ExpandConstant('{commonprograms}\Aegisub\');
|
StartMenuFolder := ExpandConstant('{commonprograms}\Aegisub\');
|
||||||
for i := 0 to shortcut_list.Count-1 do
|
for i := 0 to shortcut_list.Count-1 do
|
||||||
|
@ -595,6 +615,13 @@ begin
|
||||||
if not DeleteFile(curname) then Log('* Deletion failed');
|
if not DeleteFile(curname) then Log('* Deletion failed');
|
||||||
itemsdone := itemsdone + 1;
|
itemsdone := itemsdone + 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// This moving is done to help Windows' link tracking code be able to fix shortcuts
|
||||||
|
page.SetText('Moving EXE file to new name', 'Aegisub.exe');
|
||||||
|
page.SetProgress(itemsdone, totalitems);
|
||||||
|
Log('Rename Aegisub.exe to aegisub32.exe');
|
||||||
|
RenameFile(InstallFolder+'Aegisub.exe', InstallFolder+'aegisub32.exe');
|
||||||
|
itemsdone := itemsdone + 1;
|
||||||
|
|
||||||
for i := 0 to locale_list.Count-1 do
|
for i := 0 to locale_list.Count-1 do
|
||||||
begin
|
begin
|
||||||
|
@ -619,6 +646,9 @@ begin
|
||||||
page.SetText('Uninstallation complete', '');
|
page.SetText('Uninstallation complete', '');
|
||||||
page.SetProgress(totalitems, totalitems);
|
page.SetProgress(totalitems, totalitems);
|
||||||
|
|
||||||
|
except
|
||||||
|
Log('An exception occurred while trying to clean up an older version');
|
||||||
|
|
||||||
finally
|
finally
|
||||||
shortcut_list.Free;
|
shortcut_list.Free;
|
||||||
file_list.Free;
|
file_list.Free;
|
||||||
|
@ -631,14 +661,14 @@ end;
|
||||||
|
|
||||||
procedure CurStepChanged(CurStep: TSetupStep);
|
procedure CurStepChanged(CurStep: TSetupStep);
|
||||||
begin
|
begin
|
||||||
if CurStep = ssInstall then
|
if CurStep = ssInstall then
|
||||||
begin
|
begin
|
||||||
if HasLegacyVersion then
|
if HasLegacyVersion then
|
||||||
begin
|
begin
|
||||||
MigrateStyleCatalogs;
|
MigrateStyleCatalogs;
|
||||||
UninstallLegacyVersion;
|
UninstallLegacyVersion;
|
||||||
end
|
end;
|
||||||
CleanUpOldVersion;
|
CleanUpOldVersion;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
Aegisub.exe
|
|
||||||
Aegisub.pdb
|
Aegisub.pdb
|
||||||
aegisub32.exe
|
aegisub32.exe
|
||||||
aegisub32.pdb
|
aegisub32.pdb
|
||||||
|
|
Loading…
Reference in New Issue