[✓][BUG][ED] "Could not read editor options" error

Started by roltemurto, April 01, 2026, 07:22:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

roltemurto

Quote from: WillLem on April 01, 2026, 01:38:24 AMGlad to hear it worked, thanks for reporting back quickly! I'll get a hotfix release out soon :)

Great news. Since you're still polishing it, I like to report another thing you may wanna look at;

I get the "Warning: Could not read editor options from SLXEditorSettings.ini. Editor uses the default settings."

This happens even though the folders and files are NOT read-only and the exe runs as administrator. I am not sure if it's related to my locale again, but I keep having to customize my settings each time.
This is what my updated ini file looks like;
# SLXEditor settings
 EditorMode          Auto
 DefaultAuthorName      E
 DefaultTemplate       
 ValidateWhenSaving     True
 Autosave               2
 AutosaveLimit          5
 PieceBrowserMode       ShowData
 AutoPinOGStyles        True
 PreferObjectName       False
 InfiniteScrolling      False
 ShowRandomButton       False
 UseAutostart           True
 GridSize               1
 GridColor              MidnightBlue
 TriggerAreaColor       Pink
 CustomMove             64
 Button_Tooltip         3

 Form_Maximized         True
 Form_Width             872
 Form_Height            469

 ShowAboutAtStartup     True
 ShowControlHints       True
 AllTabsExpanded        False
 HighlightGroups        False
 HighlightErasers       False

 LevelArrangerOpen      False
 LevelArrangerMaximized False
 LevelArrangerLocation  301,71
 LevelArrangerSize      2126,1089

 PieceBrowserOpen       False
 PieceBrowserMaximized  False
 PieceBrowserLocation   643,381
 PieceBrowserSize       1425,148

 Display                Triggers
 Display                Rulers
 Display                ScreenStart
 Display                Background

WillLem

Quote from: roltemurto on April 01, 2026, 07:22:13 PMI get the "Warning: Could not read editor options from SLXEditorSettings.ini. Editor uses the default settings."

There should be an "ErrorLog.txt" in the root folder where SLXEditor lives.

Can you make the error happen, then post the resulting ErrorLog.txt here so I can figure out what's going wrong. Or, let me know if the file isn't being generated.

Thanks.

roltemurto

I took a while for me to realize that you moved this under a separate topic, I thought I hallucinated reporting it  :) . Sorry about that.

My ErrorLog.txt file is above 10MBs ... Repeating multiple same errors "multiple" times. So I used Notepad++'s "remove duplicate lines feature. Here are the original unique lines from that file;

System.ArgumentException: Parametre geçerli değil.
   konum: System.Drawing.Bitmap..ctor(String filename)
   konum: SLXEditor.Utility.CreateBitmapFromFile(String filePath)
   konum: SLXEditor.LoadStylesFromFile.Image(String imageKey)
System.Exception: 'System.Exception' türünde özel durum oluşturuldu.
   konum: SLXEditor.LoadStylesFromFile.CreateNewTerrainInfo(String filePath)
   konum: SLXEditor.LoadStylesFromFile.ImageInfo(String imageName)
   konum: SLXEditor.ImageLibrary.AddNewImage(String imageKey)
System.NullReferenceException: Nesne başvurusu bir nesnenin örneğine ayarlanmadı.
   konum: SLXEditor.SLXEditForm.ReadLevelInfoFromForm(Boolean allowWriteBack)
   konum: SLXEditor.SLXEditForm.textbox_Leave(Object sender, EventArgs e)
   konum: SLXEditor.SLXEditForm.chk_Lvl_AutoStart_Leave(Object sender, EventArgs e)
   konum: System.Windows.Forms.CheckBox.OnCheckedChanged(EventArgs e)
   konum: System.Windows.Forms.CheckBox.set_CheckState(CheckState value)
   konum: System.Windows.Forms.CheckBox.set_Checked(Boolean value)
   konum: SLXEditor.Settings.ReadSettingsFromFile()
   konum: SLXEditor.LoadStylesFromFile.CreateCompositeImage(String filePath, List`1 anims, LoadStyleAnimData primaryAnim, Int32& marginLeft, Int32& marginTop, Int32& marginRight, Int32& marginBottom, Boolean forceOriginalSize)
   konum: SLXEditor.LoadStylesFromFile.CreateNewObjectInfo(String filePath)
   konum: SLXEditor.SLXEditForm.CommitLevelChanges()
   konum: System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
   konum: System.Drawing.Bitmap..ctor(Int32 width, Int32 height)
System.DivideByZeroException: Sıfırla bölme girişiminde bulunuldu.

And here's the translated version;

System.ArgumentException: Parameter is not valid.
   at System.Drawing.Bitmap..ctor(String filename)
   at SLXEditor.Utility.CreateBitmapFromFile(String filePath)
   at SLXEditor.LoadStylesFromFile.Image(String imageKey)
System.Exception: Exception of type 'System.Exception' was thrown.
   at SLXEditor.LoadStylesFromFile.CreateNewTerrainInfo(String filePath)
   at SLXEditor.LoadStylesFromFile.ImageInfo(String imageName)
   at SLXEditor.ImageLibrary.AddNewImage(String imageKey)
System.NullReferenceException: Object reference not set to an instance of an object.
   at SLXEditor.SLXEditForm.ReadLevelInfoFromForm(Boolean allowWriteBack)
   at SLXEditor.SLXEditForm.textbox_Leave(Object sender, EventArgs e)
   at SLXEditor.SLXEditForm.chk_Lvl_AutoStart_Leave(Object sender, EventArgs e)
   at System.Windows.Forms.CheckBox.OnCheckedChanged(EventArgs e)
   at System.Windows.Forms.CheckBox.set_CheckState(CheckState value)
   at System.Windows.Forms.CheckBox.set_Checked(Boolean value)
   at SLXEditor.Settings.ReadSettingsFromFile()
   at SLXEditor.LoadStylesFromFile.CreateCompositeImage(String filePath, List`1 anims, LoadStyleAnimData primaryAnim, Int32& marginLeft, Int32& marginTop, Int32& marginRight, Int32& marginBottom, Boolean forceOriginalSize)
   at SLXEditor.LoadStylesFromFile.CreateNewObjectInfo(String filePath)
   at SLXEditor.SLXEditForm.CommitLevelChanges()
   at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
   at System.Drawing.Bitmap..ctor(Int32 width, Int32 height)
System.DivideByZeroException: Attempted to divide by zero.

I'm not sure why is it throwing too many errors and produced 184146 lines of errors between 20260330140005 - 20260402061859 but I'm deleting the file now to see what new errors it'll fill up with.


WillLem

Quote from: roltemurto on April 02, 2026, 03:49:02 AMI took a while for me to realize that you moved this under a separate topic, I thought I hallucinated reporting it  :) . Sorry about that.

Haha! Apologies, it's just easier to keep track of these things when they have separate topics.

Quote from: roltemurto on April 02, 2026, 03:49:02 AMI'm deleting the file now to see what new errors it'll fill up with.

Thanks for posting the full Error logs, some of those will no doubt be from before the previous "ToUpperInvariant" fix.

It would be helpful if you could clear the logs, then generate the settings error, and post just what comes up from that error.

From what you posted above, it seems to be a null reference exception when attempting to read settings. However, this doesn't tell us why the error occurred. Your settings file is clearly there, and the Editor is now locale-aware (although, there may be more that needs to be done in this regard).

So, let's see what comes up in the log from only the settings error. And, something to check in the meantime: is your settings file being saved to the "settings" folder in your SLX directory when it gets regenerated?

If nothing useful comes up in the log, I'll expand the error reporting to try and pinpoint exactly what's causing the null reference. But, let's completely exhaust the existing system first.

roltemurto

Quote from: WillLem on April 02, 2026, 05:50:51 AMHaha! Apologies, it's just easier to keep track of these things when they have separate topics.
Of course! No need to apologize.

Quote from: WillLem on April 02, 2026, 05:50:51 AMThanks for posting the full Error logs, some of those will no doubt be from before the previous "ToUpperInvariant" fix...
...
...But, let's completely exhaust the existing system first.
But I do need to apologize myself; because I have not been able to regenerate the error since the last time.
I can't remember if the last one I received  was from your RC version or v3.0.2, but I am beginning to suspect that it was also related to the "İ" problem.
If it ever comes back, I will make sure to report and let you know under this topic.

Thanks for taking such an interest in fixing and making your releases better which each version.
Greatly appreciated,
Cheers!

WillLem

I imagine that this error probably is fixed by the RC, in which case I'll mark this as resolved but will keep the topic open in case it does come up again.

roltemurto

Hello again WillLem,

BAD NEWS: I can confirm the "Could not read editor options" error has returned, even with RC version that I'm using right now.
GOOD NEWS: I think I found what causes it and may have a possible solution.

I believe it may be related to crashed exits and it is most probably connected to the monitor-off crash I reported in the other topic (BUG: Editor crashes when monitor turned off).

Here is my new error log entry, translated to English:

System.NullReferenceException: Object reference not set to an instance of an object.
  at SLXEditor.SLXEditForm.ReadLevelInfoFromForm(Boolean allowWriteBack)
  at SLXEditor.SLXEditForm.CommitLevelChanges()
  at SLXEditor.SLXEditForm.textbox_Leave(Object sender, EventArgs e)
  at SLXEditor.SLXEditForm.chk_Lvl_AutoStart_Leave(Object sender, EventArgs e)
  at System.Windows.Forms.CheckBox.OnCheckedChanged(EventArgs e)
  at System.Windows.Forms.CheckBox.set_CheckState(CheckState value)
  at System.Windows.Forms.CheckBox.set_Checked(Boolean value)
  at SLXEditor.Settings.ReadSettingsFromFile()

The previous crash (Bitmap region already locked / form resize on monitor wake-up) was an abnormal termination. The editor was killed mid-operation without going through its normal shutdown sequence, which means the settings file was almost certainly either left incomplete or not updated at all with the session's final state.

When I launched the editor first time since that crash, ReadSettingsFromFile() attempted to load that potentially corrupt or incomplete SLXEditorSettings.ini. I suspect that when it hits the UseAutostart = True line, it sets chk_Lvl_AutoStart.Checked = true, which fires the OnCheckedChanged > chk_Lvl_AutoStart_Leave > textbox_Leave > ReadLevelInfoFromForm event chain at a point where the form is not yet fully initialized, causing the NullReferenceException.

While the origin of the initial error may still have ties to the "İ" problem, the error seems intermittent because it manifested again after an abnormal shutdown leaves the settings file in a bad state.
So far, under normal operation (clean close and reopen), the settings load fine.

You already solved the other topic by implementing a proper lock guard so the editor does not die mid-operation and leave files in an inconsistent state.
But any future abnormal termination (power cut, OS crash, etc.) can still trigger the same settings-read failure.

So perhaps you may wanna take a look at this;
  • The settings reader ReadSettingsFromFile() should suppress checkbox event handlers while loading, to prevent UI events from firing before the form is ready. Standard WinForms pattern:

chk_Lvl_AutoStart.CheckedChanged -= chk_Lvl_AutoStart_Leave;
chk_Lvl_AutoStart.Checked = value;
chk_Lvl_AutoStart.CheckedChanged += chk_Lvl_AutoStart_Leave;

Hope this helps narrow it down. Happy to provide any further info.

WillLem

Quote from: roltemurto on April 08, 2026, 11:09:50 PMThe settings reader ReadSettingsFromFile() should suppress checkbox event handlers while loading, to prevent UI events from firing before the form is ready. Standard WinForms pattern:

chk_Lvl_AutoStart...

Your investigation helped pin down the cause. ReadSettingsFromFile() shouldn't touch form controls (checkboxes or otherwise), but this particular setting (UseAutoStart) was being directly written to / read from the checkbox state rather than an actual Setting object, hence the null object reference (my bad, it was one of the first things I did when I began work on the Editor and I didn't have the experience to realise that this might be an issue).

I've now fixed this!

Fixed in SLXEditor commit 6106fd8.