Fix possible crash, mostly occurring on notification flood.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
check_cxx_source_compiles("
#include \"qglobal.h\"
- #if defined QT_NO_OPENSSL || defined QT_NO_SSL
+ #if defined QT_NO_SSL
# error \"No SSL support\"
#endif
int main() {}"
case Qt::EditRole:
{
QString newName = value.toString();
+
+ // Sanity check - buffer names must not contain newlines!
+ int nlpos = newName.indexOf('\n');
+ if (nlpos >= 0)
+ newName = newName.left(nlpos);
+
if (!newName.isEmpty()) {
Client::renameBuffer(bufferId(), newName);
return true;
++iter;
}
_changeCurrentEnabled = true;
+
+ // Trigger a dataChanged() signal from the base model to update all proxy models (e.g. filters).
+ // Since signals are protected, we have to use invokeMethod for faking signal emission.
+ if (previous.isValid()) {
+ QMetaObject::invokeMethod(model(), "dataChanged", Qt::DirectConnection,
+ Q_ARG(QModelIndex, previous), Q_ARG(QModelIndex, previous));
+ }
}
while (!expandedCommands.isEmpty()) {
QString command;
- if (expandedCommands[0].trimmed().toLower().startsWith("/wait")) {
+ if (expandedCommands[0].trimmed().toLower().startsWith("/wait ")) {
command = expandedCommands.join("; ");
expandedCommands.clear();
}
}
-// Note that we need to use a fixed-size integer instead of uintptr_t, in order
-// to avoid issues with different architectures for client and core.
-// In practice, we'll never really have to restore the real value of a PeerPtr from
-// a QVariant.
+// PeerPtr is used in RPC signatures for enabling receivers to send replies
+// to a particular peer rather than broadcast to all connected ones.
+// To enable this, the SignalProxy transparently replaces the bogus value
+// received over the network with the actual address of the local Peer
+// instance. Because the actual value isn't needed on the wire, it is
+// serialized as null.
QDataStream &operator<<(QDataStream &out, PeerPtr ptr)
{
- out << reinterpret_cast<quint64>(ptr);
+ Q_UNUSED(ptr);
+ out << static_cast<quint64>(0); // 64 bit for historic reasons
return out;
}
QDataStream &operator>>(QDataStream &in, PeerPtr &ptr)
{
+ ptr = nullptr;
quint64 value;
in >> value;
- ptr = reinterpret_cast<PeerPtr>(value);
return in;
}
QKeySequence Action::shortcut(ShortcutTypes type) const
{
Q_ASSERT(type);
- if (type == DefaultShortcut)
+ if (type == DefaultShortcut) {
+#if QT_VERSION < 0x050000
return property("defaultShortcut").value<QKeySequence>();
+#else
+ auto sequence = property("defaultShortcuts").value<QList<QKeySequence>>();
+ return sequence.isEmpty() ? QKeySequence() : sequence.first();
+#endif
+ }
- if (shortcuts().count()) return shortcuts().value(0);
- return QKeySequence();
+ return shortcuts().isEmpty() ? QKeySequence() : shortcuts().first();
}
{
Q_ASSERT(type);
- if (type & DefaultShortcut)
+ if (type & DefaultShortcut) {
+#if QT_VERSION < 0x050000
setProperty("defaultShortcut", key);
-
+#else
+ setProperty("defaultShortcuts", QVariant::fromValue(QList<QKeySequence>() << key));
+#endif
+ }
if (type & ActiveShortcut)
QAction::setShortcut(key);
}
}
-void BufferView::setSelectionModel(QItemSelectionModel *selectionModel)
-{
- if (QTreeView::selectionModel())
- disconnect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
- model(), SIGNAL(checkPreviousCurrentForRemoval(QModelIndex, QModelIndex)));
-
- QTreeView::setSelectionModel(selectionModel);
- BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
- if (filter) {
- connect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
- filter, SLOT(checkPreviousCurrentForRemoval(QModelIndex, QModelIndex)));
- }
-}
-
-
void BufferView::setConfig(BufferViewConfig *config)
{
if (_config == config)
void setModel(QAbstractItemModel *model);
void setFilteredModel(QAbstractItemModel *model, BufferViewConfig *config);
- virtual void setSelectionModel(QItemSelectionModel *selectionModel);
void setConfig(BufferViewConfig *config);
inline BufferViewConfig *config() { return _config; }
#include "networkmodel.h"
#include "uistyle.h"
-class CheckRemovalEvent : public QEvent
-{
-public:
- CheckRemovalEvent(const QModelIndex &source_index) : QEvent(QEvent::User), index(source_index) {};
- QPersistentModelIndex index;
-};
-
/*****************************************
* The Filter for the Tree View
setDynamicSortFilter(true);
- connect(this, SIGNAL(_dataChanged(const QModelIndex &, const QModelIndex &)),
- this, SLOT(_q_sourceDataChanged(QModelIndex, QModelIndex)));
-
_enableEditMode.setCheckable(true);
_enableEditMode.setChecked(_editMode);
connect(&_enableEditMode, SIGNAL(toggled(bool)), this, SLOT(enableEditMode(bool)));
}
-void BufferViewFilter::checkPreviousCurrentForRemoval(const QModelIndex ¤t, const QModelIndex &previous)
-{
- Q_UNUSED(current);
- if (previous.isValid())
- QCoreApplication::postEvent(this, new CheckRemovalEvent(previous));
-}
-
-
-void BufferViewFilter::customEvent(QEvent *event)
-{
- if (event->type() != QEvent::User)
- return;
-
- CheckRemovalEvent *removalEvent = static_cast<CheckRemovalEvent *>(event);
- checkItemForRemoval(removalEvent->index);
-
- event->accept();
-}
-
-
-void BufferViewFilter::checkItemsForRemoval(const QModelIndex &topLeft, const QModelIndex &bottomRight)
-{
- QModelIndex source_topLeft = mapToSource(topLeft);
- QModelIndex source_bottomRight = mapToSource(bottomRight);
- emit _dataChanged(source_topLeft, source_bottomRight);
-}
-
-
bool BufferViewFilter::bufferIdLessThan(const BufferId &left, const BufferId &right)
{
Q_CHECK_PTR(Client::networkModel());
QList<QAction *> actions(const QModelIndex &index);
-public slots:
- void checkPreviousCurrentForRemoval(const QModelIndex ¤t, const QModelIndex &previous);
- void checkItemForRemoval(const QModelIndex &index) { checkItemsForRemoval(index, index); }
- void checkItemsForRemoval(const QModelIndex &topLeft, const QModelIndex &bottomRight);
-
protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
bool bufferLessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
bool networkLessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
- virtual void customEvent(QEvent *event);
signals:
- void _dataChanged(const QModelIndex &source_topLeft, const QModelIndex &source_bottomRight);
void configChanged();
private slots: