[GB.QT4]
* NEW: When creating a Control, a Printer or displaying a MessageBox, check that the GUI has been initialized, and raise an error if not, instead of letting Qt abort the application. git-svn-id: svn://localhost/gambas/trunk@6886 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
d9ae32a6fd
commit
42791d1c51
@ -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");
|
||||
|
@ -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]"),
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user