Comments (6)
The log doesn't show any errors, which leads me to believe this is a Linux specific issue with the GUI (when the log reaches "Application exited gracefully" the GUI is supposed to already be closed entirely).
I recently got a new computer and haven't set up my Linux VM yet to test this, but I will as soon as I find the time to.
If you want to help me debug this (which would be greatly appreciated) try using Visual Studio Code with the C# plugin, that's what I'm using and getting it to compile should be fairly straightforward.
from modmyfactory2.
I had the same problem on my Windows.
The sync version of UnloadProgramAsync() worked fine on my Windows.
Also, without buffering, modpacks.json got corrupted when the file size exceeded 32KB in debug build. But, release build still corrupted.
This is my patch.
diff --git a/ModMyFactory.Export/Exporter.cs b/ModMyFactory.Export/Exporter.cs
index 720bf3f..f8a4db0 100644
--- a/ModMyFactory.Export/Exporter.cs
+++ b/ModMyFactory.Export/Exporter.cs
@@ -43,9 +43,9 @@ namespace ModMyFactory.Export
private async Task ExportPackageAsync(FileInfo file)
{
string json = JsonConvert.SerializeObject(Package, Formatting.Indented);
- using var stream = file.Open(FileMode.Create, FileAccess.Write);
- using var writer = new StreamWriter(stream);
- await writer.WriteAsync(json);
+ using var stream = new FileStream(file.FullName, FileMode.Create, FileAccess.Write, FileShare.None, 8192, true);
+ var bytes = Encoding.UTF8.GetBytes(json);
+ await stream.WriteAsync(bytes, 0, bytes.Length);
}
private Task ExportArchiveAsync(FileInfo file)
diff --git a/ModMyFactoryGUI/Program.cs b/ModMyFactoryGUI/Program.cs
index 9cbcd68..47c5dcc 100644
--- a/ModMyFactoryGUI/Program.cs
+++ b/ModMyFactoryGUI/Program.cs
@@ -250,11 +250,11 @@ namespace ModMyFactoryGUI
_modpacks = await LoadModpacksAsync();
}
- private static async Task UnloadProgramAsync()
+ private static void UnloadProgram()
{
Log.Information("Saving settings...");
Settings.Save();
- await SaveModpacksAsync();
+ SaveModpacks();
Log.Information("Shutting down");
Log.CloseAndFlush();
}
@@ -357,7 +357,7 @@ namespace ModMyFactoryGUI
finally
{
SyncContext.EndListen();
- await UnloadProgramAsync();
+ UnloadProgram();
}
}
else
@@ -508,25 +508,10 @@ namespace ModMyFactoryGUI
code = ErrorCode.GameStart_General;
}
- await UnloadProgramAsync();
+ UnloadProgram();
return code;
}
- // This has not yet been implemented in the latest stable release of CommandLineParser so we have to paste it into here
- private static Task<TResult> MapResultAsync<T1, T2, TResult>(ParserResult<object> result,
- Func<T1, Task<TResult>> parsedFunc1,
- Func<T2, Task<TResult>> parsedFunc2,
- Func<IEnumerable<Error>, Task<TResult>> notParsedFunc)
- {
- if (result is Parsed<object> parsed)
- {
- if (parsed.Value is T1) return parsedFunc1((T1)parsed.Value);
- if (parsed.Value is T2) return parsedFunc2((T2)parsed.Value);
- throw new InvalidOperationException();
- }
- return notParsedFunc(((NotParsed<object>)result).Errors);
- }
-
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
@@ -541,7 +526,7 @@ namespace ModMyFactoryGUI
});
var parsedOptions = parser.ParseArguments<RunOptions, StartGameOptions>(args);
- var code = await MapResultAsync(parsedOptions,
+ var code = await parsedOptions.MapResult(
(RunOptions opts) => StartAppAsync(args, opts),
(StartGameOptions opts) => StartGameAsync(opts),
errors => Task.FromResult(ErrorCodeFactory.FromCommandLineErrors(errors)));
from modmyfactory2.
@shelaf Thank you for providing the code. Unfortunately, that did not work on my Linux machine. After playing with it for a little while I did find that this was all I had to change to get the window to close:
diff --git a/ModMyFactoryGUI/Program.cs b/ModMyFactoryGUI/Program.cs
index 9cbcd68..f09ee67 100644
--- a/ModMyFactoryGUI/Program.cs
+++ b/ModMyFactoryGUI/Program.cs
@@ -254,7 +254,7 @@ namespace ModMyFactoryGUI
{
Log.Information("Saving settings...");
Settings.Save();
- await SaveModpacksAsync();
+ SaveModpacksAsync();
Log.Information("Shutting down");
Log.CloseAndFlush();
}
I also had issue with the modpacks.json file, and your code changes there fixed that issue.
from modmyfactory2.
Everyone who had this issue, please try version 2.2.2
from modmyfactory2.
Seems to be working fine on my Windows. Thanks!
from modmyfactory2.
@Artentus This does seem to be working for my machine.
from modmyfactory2.
Related Issues (20)
- Issue when using a Steam Library on a separate disk to install games in HOT 3
- App crashes on launch if it loads a managed Factorio instance or modpacks.json MacOS 12.1 HOT 1
- Modpack Import Howto HOT 1
- Application not opening GUI HOT 2
- Can't select steam version HOT 1
- Selection of "Installation directory" and "Custom directory" options do not work HOT 1
- Updating mods crashes HOT 1
- Few enhancement idea HOT 1
- Crashes with "outdated" mods in wrong version folder
- Where does the program store mod config? HOT 1
- Mods Not Added to Modpack HOT 1
- Help Installing, MacOS HOT 1
- Unable to drag-and-drop mods into modpack in MMF2 v4.3.4.42-beta for Linux HOT 1
- Mod Depedencies not being installed
- [Crash] Empty modpack name
- [Request] Add button to collapse/expand all modpacks
- [Request] Automatically handle dependencies
- [Crash] "Updater" URL faulty
- Cannot Remove Mods Unless They Are Checked
- Uh its not detecting my install and when i set the location it just deletes everything
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modmyfactory2.