Fix crash on invalid Editor.geometry (#1897)

alut-include-path
Lukas Werling 2017-03-10 22:02:32 +01:00
parent 10ab981b6f
commit 2c3a770415
1 changed files with 14 additions and 6 deletions

View File

@ -172,12 +172,20 @@ void C4ConsoleQtMainWindow::LoadGeometry()
StdBuf ws_contents;
if (ws_contents.LoadFromFile(Config.AtUserDataPath(C4CFN_EditorGeometry)))
{
EditorWindowState ws;
CompileFromBuf<StdCompilerBinRead>(ws, ws_contents);
QByteArray geometry(static_cast<const char *>(ws.geometry.getData()), ws.geometry.getSize()),
window_state(static_cast<const char *>(ws.window_state.getData()), ws.window_state.getSize());
restoreGeometry(geometry);
restoreState(window_state);
try
{
EditorWindowState ws;
CompileFromBuf<StdCompilerBinRead>(ws, ws_contents);
QByteArray geometry(static_cast<const char *>(ws.geometry.getData()), ws.geometry.getSize()),
window_state(static_cast<const char *>(ws.window_state.getData()), ws.window_state.getSize());
restoreGeometry(geometry);
restoreState(window_state);
}
catch (StdCompiler::Exception *e)
{
Log("Editor: Could not restore window settings");
delete e;
}
}
}