Commit c71ffbcb authored by Alexander Semke's avatar Alexander Semke
Browse files

Don't try to modify the worksheet when it's currently being destroyed.

BUG: 428611
FIXED-IN: 21.04
parent 445a475f
Pipeline #50940 passed with stage
in 25 minutes and 42 seconds
......@@ -134,7 +134,8 @@ CantorPart::CantorPart( QWidget *parentWidget, QObject *parent, const QVariantLi
if (!backendName.isEmpty())
{
b = Cantor::Backend::getBackend(backendName);
qDebug()<<"Backend "<<b->name()<<" offers extensions: "<<b->extensions();
if (b)
qDebug()<<"Backend "<<b->name()<<" offers extensions: "<<b->extensions();
}
//central widget
......@@ -655,7 +656,8 @@ void CantorPart::worksheetStatusChanged(Cantor::Session::Status status)
{
qDebug()<<"wsStatusChange"<<status;
unsigned int count = ++m_sessionStatusCounter;
if(status == Cantor::Session::Running)
switch (status) {
case Cantor::Session::Running:
{
// Useless add a interrupt action without delay, because user physically can't interrupt fast commands
QTimer::singleShot(100, this, [this, count] () {
......@@ -667,13 +669,19 @@ void CantorPart::worksheetStatusChanged(Cantor::Session::Status status)
setStatusMessage(i18n("Calculating..."));
}
});
}else if (status == Cantor::Session::Done)
break;
}
case Cantor::Session::Done:
{
m_evaluate->setText(i18n("Evaluate Worksheet"));
m_evaluate->setShortcut(Qt::CTRL+Qt::Key_E);
m_evaluate->setIcon(QIcon::fromTheme(QLatin1String("system-run")));
setStatusMessage(i18n("Ready"));
break;
}
case Cantor::Session::Disable:
setStatusMessage(QString()); //clean the status bar to remove the potential "Calculating...", etc. after the session was closed
}
}
......
......@@ -111,17 +111,13 @@ Worksheet::Worksheet(Cantor::Backend* backend, QWidget* parent, bool useDeafultW
Worksheet::~Worksheet()
{
m_isClosing = true;
// This is necessary, because a SearchBar might access firstEntry()
// while the scene is deleted. Maybe there is a better solution to
// this problem, but I can't seem to find it.
m_firstEntry = nullptr;
//disconnect from everything, no need to react on session status changes
//in the logout() when deleting the worksheet
disconnect(m_session, nullptr, nullptr, nullptr);
if (m_session && m_session->status() != Cantor::Session::Disable)
m_session->logout();
if (m_session)
{
disconnect(m_session, nullptr, nullptr, nullptr);
......@@ -129,6 +125,7 @@ Worksheet::~Worksheet()
m_session->logout();
m_session->deleteLater();
}
if (m_jupyterMetadata)
delete m_jupyterMetadata;
}
......@@ -455,6 +452,9 @@ WorksheetView* Worksheet::worksheetView()
void Worksheet::setModified()
{
if (m_isClosing)
return;
if (!m_isLoadingFromFile)
emit modified();
}
......
......@@ -378,6 +378,7 @@ class Worksheet : public QGraphicsScene
bool m_isPrinting{false};
bool m_isLoadingFromFile{false};
bool m_isClosing{false};
bool m_readOnly{false};
Type m_type = CantorWorksheet;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment