Closed Bug 554008 Opened 14 years ago Closed 14 years ago

QApplication init must be initialized in ContentProcessChild, not in TabChild

Categories

(Core :: IPC, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: romaxa, Assigned: romaxa)

Details

Attachments

(2 files, 2 obsolete files)

TabChilds can be created and destroyed in the same process, and we should not create and destroy QApplication every time when it happens.
Attachment #433909 - Flags: review?(Olli.Pettay)
Why not create QApplication already in ContentProcessChild ctor?
And actually, since ContentProcessChild is a singleton, it could have QApplication
as a member variable. That would look a bit nicer.
I wonder if the member variable could be even
nsAutoPtr<QApplication> mQApp;
Then ContentProcessChild dtor should automatically delete the object.
Attached patch Updated version with autoptr (obsolete) — Splinter Review
Assignee: nobody → romaxa
Attachment #433909 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #433916 - Flags: review?(Olli.Pettay)
Attachment #433909 - Flags: review?(Olli.Pettay)
Attachment #433916 - Attachment is obsolete: true
Attachment #433917 - Flags: review?(Olli.Pettay)
Attachment #433916 - Flags: review?(Olli.Pettay)
Comment on attachment 433917 [details] [diff] [review]
QApp init moved to ctor

>diff -r 12cce72d1dd7 dom/ipc/ContentProcessChild.cpp
>--- a/dom/ipc/ContentProcessChild.cpp	Mon Mar 22 15:36:54 2010 +0200
>+++ b/dom/ipc/ContentProcessChild.cpp	Mon Mar 22 16:00:30 2010 +0200
> ContentProcessChild::ContentProcessChild()
>     : mQuit(PR_FALSE)
> {
>+#ifdef MOZ_WIDGET_QT
>+    NS_ASSERTION(!qApp, "QApplication created too early?");
>+    mQApp = new QApplication(gArgc, (char**)gArgv);
Not sure why you need (char**)
Attachment #433917 - Flags: review?(Olli.Pettay) → review+
Ah, perhaps QApplication has overloaded ctors.
Pushed
http://hg.mozilla.org/projects/electrolysis/rev/c4e431fb18d0
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
I think we should redo this patch, because ContentProcessChild ctor created not in main thread, and as result we have problems like:
***********************
QPixmap: It is not safe to use pixmaps outside the GUI thread                                           
QObject: Cannot create children for a parent that is in a different thread.                             
(Parent is QApplication(0x14220), parent's thread is QThread(0x1b3a0), current thread is QThread(0x499f2
8)                                                                                                      
QObject::startTimer: QTimer can only be used with threads started with QThread                          
QObject::setParent: Cannot set parent, new parent is in a different thread                              
QObject::startTimer: QTimer can only be used with threads started with QThread                          
[TabChild] MOVE to (x,y)=(0d, 0d), (w,h)= (0d, 0d)                                                      
###################################### frame-content loaded                                             
loading about:blank, 1                                                                                  
QObject::startTimer: QTimer can only be used with threads started with QThread                          
QObject::startTimer: QTimer can only be used with threads started with QThread     
***********************
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attachment #434480 - Flags: review?(Olli.Pettay) → review?(dougt)
Attachment #434480 - Flags: review?(dougt) → review+
Additional fix pushed in:
http://hg.mozilla.org/projects/electrolysis/rev/c732df81ad85
Status: REOPENED → RESOLVED
Closed: 14 years ago14 years ago
Resolution: --- → FIXED
Uh, I didn't know the ctor is run in different thread than init.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: