From 4124153d3e294483f734829cf575a7e8f1e96108 Mon Sep 17 00:00:00 2001 From: Filippo Cucchetto Date: Thu, 25 Feb 2016 23:36:22 +0100 Subject: [PATCH] Made QModelIndex safer by always coping values --- src/private/dotherside.nim | 2 ++ src/private/qmodelindex.nim | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/private/dotherside.nim b/src/private/dotherside.nim index 0ee0a05..94ab3d1 100644 --- a/src/private/dotherside.nim +++ b/src/private/dotherside.nim @@ -159,6 +159,7 @@ proc dos_qhash_int_qbytearray_value(qHash: DosQHashIntByteArray, key: int, value # QModelIndex proc dos_qmodelindex_create(modelIndex: var DosQModelIndex) {.cdecl, importc.} +proc dos_qmodelindex_create_qmodelindex(modelIndex: var DosQModelIndex, other: DosQModelIndex) {.cdecl, importc.} proc dos_qmodelindex_delete(modelIndex: DosQModelIndex) {.cdecl, importc.} proc dos_qmodelindex_row(modelIndex: DosQModelIndex, row: var cint) {.cdecl, importc.} proc dos_qmodelindex_column(modelIndex: DosQModelIndex, column: var cint) {.cdecl, importc.} @@ -167,6 +168,7 @@ proc dos_qmodelindex_data(modelIndex: DosQModelIndex, role: cint, data: DosQVari proc dos_qmodelindex_parent(modelIndex: DosQModelIndex, parent: DosQModelIndex) {.cdecl, importc.} proc dos_qmodelindex_child(modelIndex: DosQModelIndex, row: cint, column: cint, parent: DosQModelIndex) {.cdecl, importc.} proc dos_qmodelindex_sibling(modelIndex: DosQModelIndex, row: cint, column: cint, sibling: DosQModelIndex) {.cdecl, importc.} +proc dos_qmodelindex_assign(leftSide: DosQModelIndex, rightSide: DosQModelIndex) {.cdecl, importc.} # QAbstractListModel proc dos_qabstractlistmodel_create(model: var DosQAbstractListModel, diff --git a/src/private/qmodelindex.nim b/src/private/qmodelindex.nim index c6b6f4f..1239cea 100644 --- a/src/private/qmodelindex.nim +++ b/src/private/qmodelindex.nim @@ -4,7 +4,7 @@ proc setup*(self: QModelIndex) = proc setup(self: QModelIndex, vptr: DosQModelIndex) = ## Setup a new QModelIndex - self.vptr = vptr + dos_qmodelindex_create_qmodelindex(self.vptr, vptr) proc delete*(self: QModelIndex) = ## Delete the given QModelIndex