mirror of
https://github.com/KLayout/klayout.git
synced 2026-09-06 01:07:36 +02:00
Rework needed for LayoutView management
The application got unstable on exit under various conditions (e.g. LayoutView created in script). Reason was the ownership management of LayoutView which interfered with Qt widget lifetime management. The solution now is based on a clean widget/view hierarchy and a consistent plugin parent/child relationship. In addition, a new class is enabled which allows creating a true QWidget (rather QFrame) for a LayoutView again.
This commit is contained in:
@@ -39,8 +39,8 @@ class BooleanOperationsPlugin
|
||||
: public lay::Plugin
|
||||
{
|
||||
public:
|
||||
BooleanOperationsPlugin (Plugin *parent, lay::LayoutViewBase *view)
|
||||
: lay::Plugin (parent), mp_view (view)
|
||||
BooleanOperationsPlugin (lay::LayoutViewBase *view)
|
||||
: lay::Plugin (view), mp_view (view)
|
||||
{
|
||||
m_boolean_cva = -1;
|
||||
m_boolean_cvb = -1;
|
||||
@@ -494,9 +494,9 @@ public:
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const
|
||||
lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *, lay::LayoutViewBase *view) const
|
||||
{
|
||||
return new BooleanOperationsPlugin (root, view);
|
||||
return new BooleanOperationsPlugin (view);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "layLayoutViewBase.h"
|
||||
#include "layUtils.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
namespace lay
|
||||
{
|
||||
|
||||
@@ -34,20 +36,19 @@ class DiffPlugin
|
||||
: public lay::Plugin
|
||||
{
|
||||
public:
|
||||
DiffPlugin (Plugin *parent, lay::LayoutViewBase *view)
|
||||
: lay::Plugin (parent), mp_view (view)
|
||||
DiffPlugin (lay::LayoutViewBase *view)
|
||||
: lay::Plugin (view), mp_view (view)
|
||||
{
|
||||
if (lay::has_gui ()) {
|
||||
mp_dialog = new lay::DiffToolDialog (0);
|
||||
} else {
|
||||
mp_dialog = 0;
|
||||
}
|
||||
}
|
||||
|
||||
~DiffPlugin ()
|
||||
{
|
||||
delete mp_dialog;
|
||||
mp_dialog = 0;
|
||||
if (mp_dialog) {
|
||||
delete mp_dialog.data ();
|
||||
}
|
||||
}
|
||||
|
||||
void menu_activated (const std::string &symbol)
|
||||
@@ -65,7 +66,7 @@ public:
|
||||
|
||||
private:
|
||||
lay::LayoutViewBase *mp_view;
|
||||
lay::DiffToolDialog *mp_dialog;
|
||||
QPointer<lay::DiffToolDialog> mp_dialog;
|
||||
};
|
||||
|
||||
class DiffPluginDeclaration
|
||||
@@ -108,9 +109,9 @@ public:
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const
|
||||
lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *, lay::LayoutViewBase *view) const
|
||||
{
|
||||
return new DiffPlugin (root, view);
|
||||
return new DiffPlugin (view);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace lay
|
||||
|
||||
const double initial_elevation = 15.0;
|
||||
|
||||
D25View::D25View (lay::Dispatcher *root, LayoutViewBase *view)
|
||||
D25View::D25View (Dispatcher *root, LayoutViewBase *view)
|
||||
: lay::Browser (root, view, "d25_view"),
|
||||
dm_rerun_macro (this, &D25View::rerun_macro),
|
||||
dm_fit (this, &D25View::fit)
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include "layLayoutView.h"
|
||||
#include "layUtils.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
namespace lay
|
||||
{
|
||||
|
||||
@@ -36,20 +38,19 @@ class XORPlugin
|
||||
: public lay::Plugin
|
||||
{
|
||||
public:
|
||||
XORPlugin (Plugin *parent, lay::LayoutViewBase *view)
|
||||
: lay::Plugin (parent), mp_view (view)
|
||||
XORPlugin (lay::LayoutViewBase *view)
|
||||
: lay::Plugin (view), mp_view (view)
|
||||
{
|
||||
if (lay::has_gui ()) {
|
||||
mp_dialog = new lay::XORToolDialog (0);
|
||||
} else {
|
||||
mp_dialog = 0;
|
||||
}
|
||||
}
|
||||
|
||||
~XORPlugin ()
|
||||
{
|
||||
delete mp_dialog;
|
||||
mp_dialog = 0;
|
||||
if (mp_dialog) {
|
||||
delete mp_dialog.data ();
|
||||
}
|
||||
}
|
||||
|
||||
void menu_activated (const std::string &symbol)
|
||||
@@ -67,7 +68,7 @@ public:
|
||||
|
||||
private:
|
||||
lay::LayoutViewBase *mp_view;
|
||||
lay::XORToolDialog *mp_dialog;
|
||||
QPointer<lay::XORToolDialog> mp_dialog;
|
||||
};
|
||||
|
||||
class XORPluginDeclaration
|
||||
@@ -116,9 +117,9 @@ public:
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const
|
||||
lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *, lay::LayoutViewBase *view) const
|
||||
{
|
||||
return new XORPlugin (root, view);
|
||||
return new XORPlugin (view);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user