diff --git a/gb.qt4/src/CMessage.cpp b/gb.qt4/src/CMessage.cpp index 5714fb3f4..397f8d6d0 100644 --- a/gb.qt4/src/CMessage.cpp +++ b/gb.qt4/src/CMessage.cpp @@ -127,6 +127,9 @@ static int make_message(int type, int nbmax, void *_param) int i, n; QMessageBox *mb; + if (MAIN_CHECK_INIT()) + return 0; + if (MAIN_in_message_box) { GB.Error("Message box already displayed"); diff --git a/gb.qt4/src/CWidget.cpp b/gb.qt4/src/CWidget.cpp index c1839dd59..99fb5fd04 100644 --- a/gb.qt4/src/CWidget.cpp +++ b/gb.qt4/src/CWidget.cpp @@ -803,6 +803,12 @@ bool CWIDGET_is_design(CWIDGET *_object) //--------------------------------------------------------------------------- +BEGIN_METHOD_VOID(Control_new) + + MAIN_CHECK_INIT(); + +END_METHOD + BEGIN_PROPERTY(Control_X) if (READ_PROPERTY) @@ -3159,6 +3165,7 @@ GB_DESC CControlDesc[] = GB_HOOK_CHECK(CWIDGET_check), + GB_METHOD("_new", NULL, Control_new, NULL), GB_METHOD("_free", NULL, Control_Delete, NULL), GB_METHOD("Move", NULL, Control_Move, "(X)i(Y)i[(Width)i(Height)i]"), diff --git a/gb.qt4/src/cprinter.cpp b/gb.qt4/src/cprinter.cpp index 39b3a43d7..1598afdc9 100644 --- a/gb.qt4/src/cprinter.cpp +++ b/gb.qt4/src/cprinter.cpp @@ -164,6 +164,9 @@ static void update_duplex(CPRINTER *_object) BEGIN_METHOD_VOID(Printer_new) + if (MAIN_CHECK_INIT()) + return; + THIS->printer = new QPrinter(QPrinter::HighResolution); THIS->page_count = 1; diff --git a/gb.qt4/src/main.cpp b/gb.qt4/src/main.cpp index 79ab38ae2..314320d62 100644 --- a/gb.qt4/src/main.cpp +++ b/gb.qt4/src/main.cpp @@ -120,8 +120,8 @@ int MAIN_scale = 6; #ifndef NO_X_WINDOW int MAIN_x11_last_key_code = 0; #endif - bool MAIN_debug_busy = false; +bool MAIN_init = false; GB_CLASS CLASS_Control; GB_CLASS CLASS_Container; @@ -319,6 +319,11 @@ void MAIN_process_events(void) _no_destroy--; } +void MAIN_init_error() +{ + GB.Error("GUI is not initialized"); +} + /** MyApplication **********************************************************/ bool MyApplication::_tooltip_disable = false; @@ -809,12 +814,14 @@ static void hook_main(int *argc, char ***argv) XInitThreads(); new MyApplication(*argc, *argv); - + QT_Init(); init_lang(GB.System.Language(), GB.System.IsRightToLeft()); - + + MAIN_init = true; + //_old_handler = XSetErrorHandler(X11_error_handler); - + CALL_HOOK_MAIN(_old_hook_main, argc, argv); } diff --git a/gb.qt4/src/main.h b/gb.qt4/src/main.h index 24496b7b7..81a91ef4e 100644 --- a/gb.qt4/src/main.h +++ b/gb.qt4/src/main.h @@ -44,6 +44,7 @@ extern int MAIN_in_message_box; extern int MAIN_loop_level; extern int MAIN_scale; extern bool MAIN_debug_busy; +extern bool MAIN_init; #ifndef NO_X_WINDOW extern int MAIN_x11_last_key_code; #endif @@ -140,6 +141,9 @@ private: void MAIN_check_quit(void); void MAIN_update_scale(void); void MAIN_process_events(void); +void MAIN_init_error(void); + +#define MAIN_CHECK_INIT() (MAIN_init ? 0 : (MAIN_init_error(), 1)) const char *QT_ToUTF8(const QString &str); void QT_RegisterAction(void *object, const char *key, int on);