Skip to content

Commit

Permalink
Fix crash QsciAPIs is destroyed while worker running
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Jul 6, 2021
1 parent e1a8ef5 commit 9adbdfa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions python/gui/auto_generated/codeeditors/qgscodeeditorsql.sip.in
Expand Up @@ -31,6 +31,9 @@ code autocompletion.
Constructor for QgsCodeEditorSQL
%End


virtual ~QgsCodeEditorSQL();

void setFields( const QgsFields &fields );
%Docstring
Set field names to be added to the lexer API.
Expand Down
8 changes: 8 additions & 0 deletions src/gui/codeeditors/qgscodeeditorsql.cpp
Expand Up @@ -34,6 +34,14 @@ QgsCodeEditorSQL::QgsCodeEditorSQL( QWidget *parent )
QgsCodeEditorSQL::initializeLexer(); // avoid cppcheck warning by explicitly specifying namespace
}

QgsCodeEditorSQL::~QgsCodeEditorSQL()
{
if ( mApis )
{
mApis->cancelPreparation( );
}
}

void QgsCodeEditorSQL::initializeLexer()
{
QFont font = lexerFont();
Expand Down
3 changes: 3 additions & 0 deletions src/gui/codeeditors/qgscodeeditorsql.h
Expand Up @@ -39,6 +39,9 @@ class GUI_EXPORT QgsCodeEditorSQL : public QgsCodeEditor
//! Constructor for QgsCodeEditorSQL
QgsCodeEditorSQL( QWidget *parent SIP_TRANSFERTHIS = nullptr );


virtual ~QgsCodeEditorSQL();

/**
* Set field names to be added to the lexer API.
*
Expand Down
2 changes: 0 additions & 2 deletions tests/src/gui/testqgsqueryresultwidget.cpp
Expand Up @@ -105,8 +105,6 @@ void TestQgsQueryResultWidget::testWidgetCrash()
QTimer::singleShot( 1, d.get(), [ & ] { exited = true; } );
while ( ! exited )
QgsApplication::processEvents();
// This prevents a crash in Qsci internal thread
std::this_thread::sleep_for( std::chrono::seconds( 1 ) );
}


Expand Down

0 comments on commit 9adbdfa

Please sign in to comment.