Bug report #20388

QgsCompoundColorWidget instance crash when QgsApplication::colorSchemeRegistry() is empty

Added by Vincent Cloarec over 5 years ago. Updated about 5 years ago.

Status:Open
Priority:Normal
Assignee:-
Category:Unknown
Affected QGIS version:3.5(master) Regression?:No
Operating System:windows/linux Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:Yes Copied to github as #:28208

Description

When QgsApplication is not instanciate and the member mColorSchemeRegistry is empty, a crash appear when calling schemelist.at() (line 78 in qgscompoundcolorwidget.cpp). A way to avoid the crash is to add a color scheme to the registry before instantiate QgsCompoundColorWidget, but may be it would be nicer to avoid the crash even the registry is empty.

History

#1 Updated by Vincent Cloarec over 5 years ago

May be, add a test before the line 78 in the qgscompoundcolorwidget.cpp and add the default color scheme if there is no scheme in the list
if (schemeList.empty()) {
QgsApplication::colorSchemeRegistry()->addDefaultSchemes();
schemeList=QgsApplication::colorSchemeRegistry()->schemes( QgsColorScheme::ShowInColorDialog );
}

Vincent Cloarec wrote:

When QgsApplication is not instanciate and the member mColorSchemeRegistry is empty, a crash appear when calling schemelist.at() (line 78 in qgscompoundcolorwidget.cpp). A way to avoid the crash is to add a color scheme to the registry before instantiate QgsCompoundColorWidget, but may be it would be nicer to avoid the crash even the registry is empty.

#2 Updated by Peter Petrik about 5 years ago

Hi, do you try to use QgsCompoundColorWidget from plugin or how can I replicate the issue?

#3 Updated by Giovanni Manghi about 5 years ago

  • Status changed from Open to Feedback

#4 Updated by Vincent Cloarec about 5 years ago

Peter Petrik wrote:

Hi, do you try to use QgsCompoundColorWidget from plugin or how can I replicate the issue?

Hello,

I am developing a standalone application which is using QGis API. I have a dialog which is using the QgsRendererPropertiesDialog class. In this widget, when the QgsCompoundColorWidget class is construct, the program crash unless if i had a color scheme to the registry before instantiate QgsCompoundColorWidget class :

QgsApplication::colorSchemeRegistry()->addDefaultSchemes();

A simple example, in a context with QgsApplication is not instantiate :

QgsApplication::colorSchemeRegistry()->addDefaultSchemes(); <-- Whith this line, the QgsCompoundColorWidget class is instantiate and works, without this line, there is a crash.
QgsCompoundColorWidget* w=new QgsCompoundColorWidget();
w->show();

#5 Updated by Giovanni Manghi about 5 years ago

  • Status changed from Feedback to Open

Also available in: Atom PDF