mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
bddabad3d9
When attempting to open a file that doesnt exist or has permission problems, the application would end after hitting OK on the message box instead of starting up to an empty editor. I believe this has something to do with the dialog event loop interfering with the application event loop, or possibly the fact that the window creation code is in the show() method. To work around this I now call the open_file() method after the show() method.
28 lines
781 B
C++
28 lines
781 B
C++
#include "HexEditorWidget.h"
|
|
#include <LibDraw/PNGLoader.h>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
GApplication app(argc, argv);
|
|
|
|
auto window = GWindow::construct();
|
|
window->set_title("Hex Editor");
|
|
window->set_rect(20, 200, 640, 400);
|
|
|
|
auto hex_editor_widget = HexEditorWidget::construct();
|
|
window->set_main_widget(hex_editor_widget);
|
|
|
|
window->on_close_request = [&]() -> GWindow::CloseRequestDecision {
|
|
if (hex_editor_widget->request_close())
|
|
return GWindow::CloseRequestDecision::Close;
|
|
return GWindow::CloseRequestDecision::StayOpen;
|
|
};
|
|
|
|
window->show();
|
|
window->set_icon(load_png("/res/icons/16x16/app-hexeditor.png"));
|
|
|
|
if (argc >= 2)
|
|
hex_editor_widget->open_file(argv[1]);
|
|
|
|
return app.exec();
|
|
}
|