Increased global receiver maximun slots support.
Fixes bug #312. Reviewer: Hugo Parente Lima <hugo.pl@gmail.com> Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
parent
149646c766
commit
42f9176669
2 changed files with 41 additions and 9 deletions
|
|
@ -36,6 +36,11 @@
|
||||||
#define MAX_SIGNALS_COUNT 50
|
#define MAX_SIGNALS_COUNT 50
|
||||||
#define MAX_SLOTS_COUNT 50
|
#define MAX_SLOTS_COUNT 50
|
||||||
|
|
||||||
|
#define MAX_GLOBAL_SIGNALS_COUNT 500
|
||||||
|
#define MAX_GLOBAL_SLOTS_COUNT 500
|
||||||
|
|
||||||
|
#define GLOBAL_RECEIVER_CLASS_NAME "__GlobalReceiver__"
|
||||||
|
|
||||||
using namespace PySide;
|
using namespace PySide;
|
||||||
|
|
||||||
enum PropertyFlags {
|
enum PropertyFlags {
|
||||||
|
|
@ -110,6 +115,27 @@ static bool isQRealType(const char *type)
|
||||||
return strcmp(type, "qreal") == 0;
|
return strcmp(type, "qreal") == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Avoid API break keep this on cpp
|
||||||
|
*/
|
||||||
|
static int maxSlotsCount(const QString& className)
|
||||||
|
{
|
||||||
|
int maxSlots = MAX_SLOTS_COUNT;
|
||||||
|
if (className == GLOBAL_RECEIVER_CLASS_NAME)
|
||||||
|
maxSlots = MAX_GLOBAL_SIGNALS_COUNT;
|
||||||
|
return maxSlots;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int maxSignalsCount(const QString& className)
|
||||||
|
{
|
||||||
|
int maxSignals = MAX_SIGNALS_COUNT;
|
||||||
|
if (className == GLOBAL_RECEIVER_CLASS_NAME)
|
||||||
|
maxSignals = MAX_GLOBAL_SIGNALS_COUNT;
|
||||||
|
return maxSignals;
|
||||||
|
}
|
||||||
|
|
||||||
uint PropertyData::flags() const
|
uint PropertyData::flags() const
|
||||||
{
|
{
|
||||||
const char* typeName = type().data();
|
const char* typeName = type().data();
|
||||||
|
|
@ -271,8 +297,9 @@ void DynamicQMetaObject::addSignal(const char* signal, const char* type)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_signals.size() >= MAX_SIGNALS_COUNT) {
|
int maxSignals = maxSignalsCount(m_className);
|
||||||
qWarning() << "Fail to add dynamic signal to QObject. PySide support at most" << MAX_SIGNALS_COUNT << "dynamic signals.";
|
if (m_signals.size() >= maxSignals) {
|
||||||
|
qWarning() << "Fail to add dynamic signal to QObject. PySide support at most" << maxSignals << "dynamic signals.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -286,8 +313,9 @@ void DynamicQMetaObject::addSlot(const char* slot, const char* type)
|
||||||
if (i != m_slots.end())
|
if (i != m_slots.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_slots.size() >= MAX_SLOTS_COUNT) {
|
int maxSlots = maxSlotsCount(m_className);
|
||||||
qWarning() << "Fail to add dynamic slot to QObject. PySide support at most" << MAX_SLOTS_COUNT << "dynamic slots.";
|
if (m_slots.size() >= maxSlots) {
|
||||||
|
qWarning() << "Fail to add dynamic slot to QObject. PySide support at most" << maxSlots << "dynamic slots.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -439,8 +467,11 @@ void DynamicQMetaObject::updateMetaObject()
|
||||||
MethodScriptable = 0x40
|
MethodScriptable = 0x40
|
||||||
};
|
};
|
||||||
|
|
||||||
uint n_signals = MAX_SIGNALS_COUNT;
|
int maxSignals = maxSignalsCount(m_className);
|
||||||
uint n_methods = n_signals + MAX_SLOTS_COUNT;
|
int maxSlots = maxSlotsCount(m_className);
|
||||||
|
|
||||||
|
uint n_signals = maxSignals;
|
||||||
|
uint n_methods = n_signals + maxSlots;
|
||||||
uint n_properties = m_properties.size();
|
uint n_properties = m_properties.size();
|
||||||
int header[] = {5, // revision
|
int header[] = {5, // revision
|
||||||
0, // class name index in m_metadata
|
0, // class name index in m_metadata
|
||||||
|
|
@ -465,10 +496,10 @@ void DynamicQMetaObject::updateMetaObject()
|
||||||
int index = HEADER_LENGHT;
|
int index = HEADER_LENGHT;
|
||||||
|
|
||||||
//write signals
|
//write signals
|
||||||
writeMethodsData(m_signals, &data, &strings, &index, MAX_SIGNALS_COUNT, NULL_INDEX, AccessPublic | MethodSignal);
|
writeMethodsData(m_signals, &data, &strings, &index, maxSignals, NULL_INDEX, AccessPublic | MethodSignal);
|
||||||
|
|
||||||
//write slots
|
//write slots
|
||||||
writeMethodsData(m_slots, &data, &strings, &index, MAX_SLOTS_COUNT, NULL_INDEX, AccessPublic | MethodSlot);
|
writeMethodsData(m_slots, &data, &strings, &index, maxSlots, NULL_INDEX, AccessPublic | MethodSlot);
|
||||||
|
|
||||||
if (m_properties.size())
|
if (m_properties.size())
|
||||||
data[7] = index;
|
data[7] = index;
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@
|
||||||
#include "signalmanager.h"
|
#include "signalmanager.h"
|
||||||
|
|
||||||
#define RECEIVER_DESTROYED_SLOT_NAME "__receiverDestroyed__(QObject*)"
|
#define RECEIVER_DESTROYED_SLOT_NAME "__receiverDestroyed__(QObject*)"
|
||||||
|
#define GLOBAL_RECEIVER_CLASS_NAME "__GlobalReceiver__"
|
||||||
|
|
||||||
namespace PySide
|
namespace PySide
|
||||||
{
|
{
|
||||||
|
|
@ -108,7 +109,7 @@ DynamicSlotData::~DynamicSlotData()
|
||||||
|
|
||||||
|
|
||||||
GlobalReceiver::GlobalReceiver()
|
GlobalReceiver::GlobalReceiver()
|
||||||
: m_metaObject("GlobalReceiver", &QObject::staticMetaObject)
|
: m_metaObject(GLOBAL_RECEIVER_CLASS_NAME, &QObject::staticMetaObject)
|
||||||
{
|
{
|
||||||
//slot used to be notifyed of object destrouction
|
//slot used to be notifyed of object destrouction
|
||||||
m_metaObject.addSlot(RECEIVER_DESTROYED_SLOT_NAME);
|
m_metaObject.addSlot(RECEIVER_DESTROYED_SLOT_NAME);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue