View Full Version : QVector push_back error
Eleasar
16th April 2014, 14:26
Hello,
I have a class that has QVector<QPoint> cameraPoints (private) vector. I try to push back this vector in a method of this class, but program unexpectedly finishes.
when i define a qvector inside of method, it works well.
How can i use push_back on private vector?
anda_skoa
16th April 2014, 15:31
There is not enough information on the problem.
The operation should succeed on the private member vector as well.
Check or post the backtrace of the crash.
Cheers,
_
Eleasar
16th April 2014, 15:36
void Route::SetCameraPositions(QVector<QPoint> *cam)
{
QVector<QPoint> bla;
QPoint t;
int x,y;
for(int i=0; i<cam->size(); i++) {
x = cam->at(i).x();
y = cam->at(i).y();
t.setX(x);
t.setY(y);
bla.push_back(t) //Works
cameraPoints.push_back(t); //Doesn't work
}
}
private:
QVector<QPoint> cameraPoints;
anda_skoa
16th April 2014, 16:36
Should I repeat my previous comment?
Cheers,
_
stampede
17th April 2014, 08:33
Maybe the object on which you are trying to call this method is invalid (empty or invalid pointer). Show us relevant code or crash backtrace.
Eleasar
17th April 2014, 08:39
==3024==
==3024== Process terminating with default action of signal 11 (SIGSEGV)
==3024== General Protection Fault
==3024== at 0x410CA5: QBasicAtomicInt::operator!=(int) const (qbasicatomic.h:75)
==3024== by 0x417AEA: QVector<QPoint>::append(QPoint const&) (qvector.h:575)
==3024== by 0x4171C2: QVector<QPoint>::push_back(QPoint const&) (qvector.h:281)
==3024== by 0x420DF0: Route::SetCameraPositions(QVector<QPoint>*) (cRoute.cpp:46)
==3024== by 0x4107DA: MainWindow::SetCameraLocations() (mainwindow.cpp:678)
==3024== by 0x40C577: MainWindow::SetupModel() (mainwindow.cpp:141)
==3024== by 0x40B6CB: MainWindow::MainWindow(QWidget*) (mainwindow.cpp:48)
==3024== by 0x40B3BF: main (main.cpp:18)
==3024==
==3024== Events : Ir
==3024== Collected : 172003489
==3024==
==3024== I refs: 172,003,489
** Process crashed **
EDIT: I've solved problem. It's in mainwindow file, not in the code i wrote here.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.