Can you please provide more information (e.g., GCC output, Qt version)?
createIndex() has two possible signatures, one with the third parameter being a void pointer and one with this parameter as an integer. I don;t understand why the current code fails to compile.
Thanks,
--Elad
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
[spot@velociraptor ~]$ /usr/bin/moc-qt4 -v
Qt Meta Object Compiler version 59 (Qt 4.4.3)
Looking at QtCore/qabstractitemmodel.h, I see the different defines for createIndex(). If I change the call in locationlistmodel.cpp like this:
return createIndex(row, column, NULL);
return createIndex(row, column, 0);
It compiles as expected. Alternately, casting the NULL as an (int) compiles (what my original patch did). I'm guessing that the compiler thinks that without a cast (or a defined int), it can't figure out which codepath to do down with NULL as the third param.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
compilation fix
Can you please provide more information (e.g., GCC output, Qt version)?
createIndex() has two possible signatures, one with the third parameter being a void pointer and one with this parameter as an integer. I don;t understand why the current code fails to compile.
Thanks,
--Elad
Without the patch, I get this failure:
g++ -c -m64 -pipe -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG_OUTPUT -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib64/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/QtCore -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include/QtGui -I/usr/include/QtXml -I/usr/include/QtXml -I/usr/include -Irelease -I. -o release/locationlistmodel.o locationlistmodel.cpp
locationlistmodel.cpp: In member function 'virtual QModelIndex KScope::Core::LocationListModel::index(int, int, const QModelIndex&) const':
locationlistmodel.cpp:204: error: call of overloaded 'createIndex(int&, int&, NULL)' is ambiguous
/usr/include/QtCore/qabstractitemmodel.h:288: note: candidates are: QModelIndex QAbstractItemModel::createIndex(int, int, void*) const
/usr/include/QtCore/qabstractitemmodel.h:290: note: QModelIndex QAbstractItemModel::createIndex(int, int, int) const
/usr/include/QtCore/qabstractitemmodel.h:299: note: QModelIndex QAbstractItemModel::createIndex(int, int, quint32) const
make[3]: [release/locationlistmodel.o] Error 1
make[3]: Leaving directory
/home/spot/cvs/kscope/devel/kscope-1.9.1/core' make[2]: *** [release-install] Error 2 make[2]: Leaving directory
/home/spot/cvs/kscope/devel/kscope-1.9.1/core'make[1]: [sub-core-install_subtargets] Error 2
make[1]: Leaving directory `/home/spot/cvs/kscope/devel/kscope-1.9.1'
error: Bad exit status from /var/tmp/rpm-tmp.KhCU1e (%install)
This is on an x86_64 system, Fedora 11 (Rawhide).
[spot@velociraptor ~]$ gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-cpu=generic --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.3.2 20081105 (Red Hat 4.3.2-7) (GCC)
[spot@velociraptor ~]$ /usr/bin/moc-qt4 -v
Qt Meta Object Compiler version 59 (Qt 4.4.3)
Looking at QtCore/qabstractitemmodel.h, I see the different defines for createIndex(). If I change the call in locationlistmodel.cpp like this:
It compiles as expected. Alternately, casting the NULL as an (int) compiles (what my original patch did). I'm guessing that the compiler thinks that without a cast (or a defined int), it can't figure out which codepath to do down with NULL as the third param.
This is still broken in 1.9.2. Fedora 11 has updated qt and gcc, with no change:
[spot@velociraptor devel]$ gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog=/builddir/build/BUILD/gcc-4.4.0-20090216/cloog-ppl/inst/usr --with-tune=generic --with-arch_32=i586 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.0 20090216 (Red Hat 4.4.0-0.19) (GCC)
[spot@velociraptor devel]$ moc-qt4 -v
Qt Meta Object Compiler version 61 (Qt 4.5.0-rc1)