From 67b9603177032babbd52f925cb5cd27c9950e71e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Mon, 2 Aug 2010 20:39:28 +0000 Subject: [PATCH] [GB.QT4] * BUG: Make the component compile correctly. * BUG: Does not crash anymore when closing a window during the _new() method, or inside the Open event handler. git-svn-id: svn://localhost/gambas/trunk@3089 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- gb.qt4/src/CTrayIcon.cpp | 8 +++++--- gb.qt4/src/CWindow.cpp | 19 ++++++++++++++----- gb.qt4/src/CWindow.h | 4 ++++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/gb.qt4/src/CTrayIcon.cpp b/gb.qt4/src/CTrayIcon.cpp index 8f1ae50dc..68efe880c 100644 --- a/gb.qt4/src/CTrayIcon.cpp +++ b/gb.qt4/src/CTrayIcon.cpp @@ -37,11 +37,13 @@ #include "gambas.h" #include "main.h" -#include "x11.h" #include "CMouse.h" #define DO_NOT_DECLARE_EVENTS #include "CWidget.h" +#include "CMenu.h" +#include "CWindow.h" +#include "x11.h" #include "CTrayIcon.h" DECLARE_METHOD(Control_ScreenX); @@ -531,9 +533,9 @@ bool CTrayIcon::eventFilter(QObject *widget, QEvent *event) if (THIS->popup) { void *parent = GB.Parent(THIS); - if (parent && GB.Is(parent, Class_Control)) + if (parent && GB.Is(parent, CLASS_Control)) { - CWINDOW *window = CWidget::getWindow(parent); + CWINDOW *window = CWidget::getWindow((CWIDGET *)parent); CMENU *menu = CWindow::findMenu(window, THIS->popup); if (menu) CMENU_popup(menu, QCursor::pos()); diff --git a/gb.qt4/src/CWindow.cpp b/gb.qt4/src/CWindow.cpp index 683c23794..6a0e1de85 100644 --- a/gb.qt4/src/CWindow.cpp +++ b/gb.qt4/src/CWindow.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include "main.h" @@ -1591,6 +1592,7 @@ void MyMainWindow::showEvent(QShowEvent *e) if (_activate) { + qDebug("showEvent: activate: %s", THIS->widget.name); raise(); //setFocus(); activateWindow(); @@ -1624,6 +1626,11 @@ void MyMainWindow::afterShow() } } +void MyMainWindow::activateLater() +{ + activateWindow(); +} + void MyMainWindow::showActivate(QWidget *transient) { CWIDGET *_object = CWidget::get(this); @@ -1702,9 +1709,13 @@ void MyMainWindow::showActivate(QWidget *transient) {*/ if (hasBorder()) { - MAIN_process_events(); - usleep(50000); - activateWindow(); + //MAIN_process_events(); + //usleep(50000); + //_activate = TRUE; + if (isToolbar()) + QTimer::singleShot(50, this, SLOT(activateLater())); + else + activateWindow(); } } else @@ -2566,8 +2577,6 @@ bool CWindow::eventFilter(QObject *o, QEvent *e) { if (THIS->toplevel) { - //qDebug("Activate: ob = %p", THIS); - CWINDOW_activate((CWIDGET *)(CWINDOW_LastActive ? CWINDOW_LastActive : THIS)); //GB.Unref(POINTER(&CWINDOW_LastActive)); CWINDOW_LastActive = 0; diff --git a/gb.qt4/src/CWindow.h b/gb.qt4/src/CWindow.h index d7510d695..987ef3003 100644 --- a/gb.qt4/src/CWindow.h +++ b/gb.qt4/src/CWindow.h @@ -177,6 +177,10 @@ protected: //bool eventFilter(QObject *, QEvent *); +public slots: + + void activateLater(); + public: enum { BorderNone = 0, BorderFixed = 1, BorderResizable = 2 };