mirror of https://github.com/KLayout/klayout.git
Provide a proper solution for the bridge object
The bridge object (between QObject and gsi::ObjectBase) needs to have Q_OBJECT. Otherwise findChild<T> won't work for it.
This commit is contained in:
parent
92fd33744d
commit
15babda953
|
|
@ -117,39 +117,6 @@ AbstractMethodCalledException::AbstractMethodCalledException (const char *method
|
||||||
// .. nothing yet ..
|
// .. nothing yet ..
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// QtNativeClass implementation
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @brief A tiny watcher object linking QObject and gsi::ObjectBase
|
|
||||||
* This object is hooked into the watched object's child list to watch it's lifetime.
|
|
||||||
*/
|
|
||||||
class QtWatcherObject
|
|
||||||
: public QObject, public gsi::ObjectBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QtWatcherObject (QObject *parent)
|
|
||||||
: QObject (parent), gsi::ObjectBase ()
|
|
||||||
{
|
|
||||||
// .. nothing yet ..
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Attaches a watcher object to a native QObject
|
|
||||||
*/
|
|
||||||
gsi::ObjectBase *get_watcher_object (QObject *qobject, bool required)
|
|
||||||
{
|
|
||||||
QtWatcherObject *watcher = qobject->findChild<QtWatcherObject *> ();
|
|
||||||
if (! watcher && required) {
|
|
||||||
watcher = new QtWatcherObject (qobject);
|
|
||||||
}
|
|
||||||
return watcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// QtObjectBase implementation
|
// QtObjectBase implementation
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
KLayout Layout Viewer
|
||||||
|
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gsiQtHelper.h"
|
||||||
|
|
||||||
|
namespace qt_gsi
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Attaches a watcher object to a native QObject
|
||||||
|
*/
|
||||||
|
gsi::ObjectBase *get_watcher_object (QObject *qobject, bool required)
|
||||||
|
{
|
||||||
|
QtWatcherObject *watcher = qobject->findChild<QtWatcherObject *> ();
|
||||||
|
if (! watcher && required) {
|
||||||
|
watcher = new QtWatcherObject (qobject);
|
||||||
|
}
|
||||||
|
return watcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
KLayout Layout Viewer
|
||||||
|
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(HDR_gsiQtHelper_h)
|
||||||
|
# define HDR_gsiQtHelper_h
|
||||||
|
|
||||||
|
#include "gsiDecl.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
namespace qt_gsi
|
||||||
|
{
|
||||||
|
|
||||||
|
gsi::ObjectBase *get_watcher_object (QObject *qobject, bool required);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A tiny watcher object linking QObject and gsi::ObjectBase
|
||||||
|
* This object is hooked into the watched object's child list to watch it's lifetime.
|
||||||
|
*/
|
||||||
|
class QtWatcherObject
|
||||||
|
: public QObject, public gsi::ObjectBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QtWatcherObject (QObject *parent)
|
||||||
|
: QObject (parent), gsi::ObjectBase ()
|
||||||
|
{
|
||||||
|
// .. nothing yet ..
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -11,10 +11,12 @@ TEMPLATE = lib
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
gsiQt.cc \
|
gsiQt.cc \
|
||||||
gsiDeclQtBasic.cc \
|
gsiDeclQtBasic.cc \
|
||||||
|
gsiQtHelper.cc
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
gsiQt.h \
|
gsiQt.h \
|
||||||
gsiQtCommon.h
|
gsiQtCommon.h \
|
||||||
|
gsiQtHelper.h
|
||||||
|
|
||||||
# NOTE: db is required since some bridges to db are provided (i.e db::Polygon)
|
# NOTE: db is required since some bridges to db are provided (i.e db::Polygon)
|
||||||
INCLUDEPATH += ../tl ../gsi ../db
|
INCLUDEPATH += ../tl ../gsi ../db
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue