QApplication init must be initialized in ContentProcessChild, not in TabChild

RESOLVED FIXED

Status

()

RESOLVED FIXED
9 years ago
9 years ago

People

(Reporter: romaxa, Assigned: romaxa)

Tracking

Trunk
x86
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 2 obsolete attachments)

(Assignee)

Description

9 years ago
Created attachment 433909 [details] [diff] [review]
Qapplication -> ContentProcessChild

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.
(Assignee)

Comment 3

9 years ago
Created attachment 433916 [details] [diff] [review]
Updated version with autoptr
Assignee: nobody → romaxa
Attachment #433909 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #433916 - Flags: review?(Olli.Pettay)
Attachment #433909 - Flags: review?(Olli.Pettay)
(Assignee)

Comment 4

9 years ago
Created attachment 433917 [details] [diff] [review]
QApp init moved to ctor
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.
(Assignee)

Comment 7

9 years ago
Pushed
http://hg.mozilla.org/projects/electrolysis/rev/c4e431fb18d0
Status: ASSIGNED → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → FIXED
(Assignee)

Comment 8

9 years ago
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 → ---
(Assignee)

Comment 9

9 years ago
Created attachment 434480 [details] [diff] [review]
QApp init must be in ::Init function, that is called from main thread
Attachment #434480 - Flags: review?(Olli.Pettay)
(Assignee)

Updated

9 years ago
Attachment #434480 - Flags: review?(Olli.Pettay) → review?(dougt)
Attachment #434480 - Flags: review?(dougt) → review+
(Assignee)

Comment 10

9 years ago
Additional fix pushed in:
http://hg.mozilla.org/projects/electrolysis/rev/c732df81ad85
Status: REOPENED → RESOLVED
Last Resolved: 9 years ago9 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.