Problem 1650 - OpenGLQtViewer creates QPixmap objects before QApplication, Qt aborts job
Summary: OpenGLQtViewer creates QPixmap objects before QApplication, Qt aborts job
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: visualization/OpenGL (show other problems)
Version: 10.0
Hardware: All All
: P5 major
Assignee: John.Allison
URL:
Depends on:
Blocks:
 
Reported: 2014-06-30 23:47 CEST by Michael Kelsey
Modified: 2014-07-01 04:19 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description Michael Kelsey 2014-06-30 23:47:44 CEST
Many user applications are written to run either interactively, or as a "batch" object, taking the name of a macro file from the command line arguments.  In this mode, no user GUI (such as Qt) is instantiated, but the graphics drawing functionality should still work.

In 10.0, running a user "batch" application built with Qt causes an abort at the line "/vis/viewer/open OGL", with the message

	QPixmap: Must construct a QApplication before a QPaintDevice

This crash occurs at line 241 of G4OpenGLQtViewer.cc, which is at the end of the constructor initializer list, _before_ the constructor code is executed.  The problem is that in 10.0, two new data objects were added to G4OpenGLQtViewer.hh (lines 322ff):

	// icons
	QPixmap fTreeIconOpen;
	QPixmap fTreeIconClosed;

These objects get instantiated as part of the constructor initializers (via the QPixmap default constructor), before the viewer's constructor code creates the required QApplication (G4Qt) object.

To resolve this bug, the two objects above should be replaced by pointers, which are instantiated in the viewer's constructor code.  References to the objects should be changed elsewhere in the class (lines 2497, 4243 and 4245) to be derefernced pointers.  The pointers should finally be deleted in the viewer's destructor.
Comment 1 Michael Kelsey 2014-07-01 04:19:53 CEST
With Laurent's permission I made the changes described above and verified that they both resolve my problem, and don't affect the interactive Qt-based GUI.  The fix has been committed to the GEANT4 code repository.