I am getting such a weird violation error by using the getAt() method.
I use the method in this order:
OdDbBlockTablePtr w_kOdBlockTablePtr ;
bool lbCreateDefaults = false;
OdDb::MeasurementValue lkMeasurement = OdDb::kEnglish;
OdDbDatabasePtr pDb;
// Datenbank initialisieren
pDb = g_ExSystemServices.createDatabase(lbCreateDefaults,
lkMeasurement);
// TABLE - Hold Ptr
w_kOdBlockTablePtr = pDb->getBlockTableId().openObject(OdDb::kForWrite);
const wchar_t AcadBlockModelSpace[] = L "*MODEL_SPACE";
wstring lsModelSpace(AcadBlockModelSpace);
w_kOdModelSpaceBlockRecPtr = GetTableRecordIdFromName(lsModelSpace, (OdDbSymbolTablePtr&)w_kOdBlockTablePtr).safeOpenObject(OdDb::kForWrite);
OdDbObjectId K_TeighaClass::GetTableRecordIdFromName(wstring& psName, OdDbSymbolTablePtr& pkTablePtr)
{
OdDbObjectId lkId;
try {
OdString lsOdName = psName.c_str();
lkId = pkTablePtr->getAt(lsOdName);
}
catch (OdError& err)
{
DoOdError(err, NULL, NULL);
}
return lkId;
}
I would really appreciate if someone could help me.
Thanks in advance
That's not weird at all. If you hover your mouse over pkTablePtr, you will almost certainly find that it is nullptr (or the debugger might report this as 0).
There's not enough information in your question to say why this might be, but since you are already running under the debugger you can walk through your code and find out.
try ... catch won't catch a hard error like this, by the way. For that, you need __try ... __except (supported on Windows only).
I'm writing tests with Googletest in Eclipse Oxygen 4.7.0 and I'm using Value-Parameterization. There is some weird behavior going on that I cannot explain so I hoped someone here might know what is going on.
The fixture class for value-parameterization should create 256 tests for each TEST_P. However, upon running the test for the first time after booting my computer, at least one TEST_P creates less tests than it should. Sometimes it is only 40, sometimes it is 180 or any number just not 256. The tests that do run pass and I don't get an error message. When I hit run again, all tests run as they should.
Here is what the fixture, one TEST_P and the instantiation look like:
typedef struct mystruct
{
mystruct()
{
myparam = new FooStruct;
bool1 = true;
bool2 = true;
bool3 = false;
bool4 = true;
bool5 = true;
bool6 = true;
uint8_t1 = 0;
uint8_t2 = 2;
uint8_t3 = 2;
int32_t1 = 0;
int32_t2 = 0;
int32_t3 = 0;
int32_t4 = 0;
}
~mystruct()
{
delete myparam;
myparam = NULL;
}
void setInt32_t(int32_t newint1, int32_t newint2, int32_t newint3, int32_t newint4)
{
int32_t1 = newint1;
int32_t2 = newint2;
int32_t3 = newint3;
int32_t4 = newint4;
}
FooStruct *myparam;
bool bool1, bool2, bool3, bool4, bool5, bool6;
uint8_t uint8_t1, uint8_t2, uint8_t3;
int32_t int32_t1, int32_t2, int32_t3, int32_t4;
}MYSTRUCT_T;
class MyTest : public testing::TestWithParam
< ::std::tr1::tuple<uint8_t, uint8_t, uint8_t, bool, bool, bool, bool> >
{
public:
MYSTRUCT_T *testparams;
protected:
virtual void SetUp()
{
_Initializer();
testparams = new mystruct();
testparams->uint8_t1 = ::std::tr1::get<0>(GetParam());
testparams->uint8_t2 = ::std::tr1::get<1>(GetParam());
testparams->uint8_t3 = ::std::tr1::get<2>(GetParam());
testparams->bool1 = ::std::tr1::get<3>(GetParam());
testparams->bool2 = ::std::tr1::get<4>(GetParam());
testparams->bool3 = ::std::tr1::get<5>(GetParam());
testparams->bool4 = ::std::tr1::get<6>(GetParam());
//bool5 and bool6 are unused here
}
virtual void TearDown()
{
delete testparams;
}
};
TEST_P(MyTest, NameOfTheTest)
{
testparams->bool1
? (testparams->uint8_t3 == 2)
? testparams->setInt32_t(0, 0, 0, 0)
: testparams->limits(1, 1, 1, 1)
: (testparams->uint8_t3 == 2)
? testparams->setInt32_t(2, 2, 2, 2)
: testparams->setInt32_t(3, 3, 3, 3);
int bar = 0;
_SetParam(testparams);
if(!_CheckAndSetParam(testparams, bar))
{
FAIL();
return;
}
_DoSomething(bar);
EXPECT_EQ(0, Global_Var[bar].status());
int32_t baz = 1;
_DoMore(bar, baz, testparams->bool2);
EXPECT_EQ(1, Global_Var[bar].status());
}
using testing::Bool;
using testing::Values;
using testing::Range;
INSTANTIATE_TEST_CASE_P(InstantiationName, MyTest,
::testing::Combine(Range((uint8_t)0, (uint8_t) 4), Range((uint8_t)0, (uint8_t)2), Range((uint8_t)2, (uint8_t)4), Bool(), Bool(), Bool(), Bool()));
I am utterly clueless as to why this keeps happening. A colleague just cloned the repository and on his machine the tests ran without a problem first try.
If any further detail or more information about my computer is needed, I am happy to provide it.
EDIT: I now noticed that there is an error that is being displayed when this behaviour occurs. Above the Console there is a small status bar (I don't know what it is called or how to best describe it) that continuously shows which test is currently running. When the tests get interrupted it says there: "I/O error: Pipe closed". Unfortunately, I couldn't find anything so far regarding that output. So the question is still unanswered
Another Edit : Coming back because the issue has arisen again when I thought it was already solved. I haven't read too much about pipe usage in the GoogleTest Documentation but will do now as I remember seeing it being mentioned at some point. Maybe that will lead me to a clue. The reason, however, I am editing this question again is to describe what I see when the error occurs.
Only one thing is constant among the crashes: the error type which is
I/O Error: : Pipe closed
Here is how I can invoke it: I edit something in the .cpp where the tests sit and start a run/debug. If there were changes and a build is made, there will likely be a crash.
The crash will after any amount of tests run which seems random. Usually, it happens after around 1800-2600 tests (out of ~2800). With an increasing amount of tests, there seems to be an increased chance in the run crashing. So I assume there will be a point where I can't run the tests anymore because this error will definitely happen.
In the C/C++ Unit view I see all the tests that ran. All of them have the green check even the last one that seems to make the run crash- at least most of the time. Sometimes it shows the blue "play"-button as if the test were still running, yet in the debug view it states "terminated".
That is about everything I know so far and have observed so any help is greatly appreciated.
I'm using Visual Studio 2013, programming in C++ and have a base class with the following attribute:
ref class AI
{
...
protected:
/// <summary>
/// Exit found flag. False if exit is yet to be found, true if it already was.
/// </summary>
bool exitFound;
...
}
Within the derived class I have the following code:
void AI_II::analyze(void)
{
...
this->exitFound = true;
if (this->exitFound)
{
if (this->distFront->lastTile == EXIT){...}
else if (this->distDown->lastTile == EXIT){...}
else if (this->distBack->lastTile == EXIT){...}
else if (this->distUp->lastTile == EXIT){...}
}
...
}
And I don't know how, but when running or debugging, the if (this->exitFound) statement is always skipped. When debugging I get the "The breakpoint will not currently be hit..." message.
I already tried to clean the solution, but no success so far. Anyone can help me find what is wrong?
Select in Visual Studio [Properties] - [Build] tab and check [Define DEBUG constant] and [Define TRACE constant] are checked. Also check [Debug Info] is set to [full] in [Advanced] tab.
I am using C++ Qt Library and following code is working perfectly on Windows but not working on CentOS :
if(line.startsWith("[", Qt::CaseInsensitive))
{
int index = line.indexOf(']', 0, Qt::CaseInsensitive);
QString subLine = line.mid(index+1);
subLine = subLine.trimmed();
tokenList = subLine.split("\t");
}
else
{
tokenList = line.split("\t");
}
I have a line [ x.x.x.x ] something ../dir/file.extension and I want to ignore the [x.x.x.x] part while breaking line into tokens. I am using VC9 on windows to debug and its working fine.
Edit: i have removed mid() and used right() still same problem persists, working on windows but not on CentOS.
Edit: after debugging on linux using QMessageBox i have concluded that control is never going inside if block, i tried using if(line.data()[0] == '[') but same results.
Your code can be simplified.
line.remove(QRegExp("\\[\\s+\\d+\\.\\d+\\.\\d+\\.\\d+\\s+\\]"));
tokenList = line.split("\t");
I'm using pocketshpinx for speech recognition in a custom C++ application. I noticed that sometimes the hypothesis string returned by the ps_get_hyp() method is an empty string.
Question: Is this an expected behaviour? If so, is there a way to tell pocketsphinx to not give the empty string as a hypothesis?
Following is a snippet of the relevant portion of my code:
do { ReadAudioBuffer(); } while (!in_speech);
while (in_speech) { ReadAudioBuffer(); }
ps_end_utt(ps);
hyp = ps_get_hyp(ps, NULL);
The ReadAudioBuffer() method:
void SpeechRecognizer::ReadAudioBuffer()
{
if ((k = ad_read(ad, adbuf, 2048)) < 0)
{
UE_LOG(LogTemp, Warning, TEXT("Failed to read audio\n"));
return;
}
ps_process_raw(ps, adbuf, k, FALSE, FALSE);
in_speech = ps_get_in_speech(ps);
FPlatformProcess::Sleep(0.005);
}
Question: Is this an expected behaviour?
There is nothing wrong with it
If so, is there a way to tell pocketsphinx to not give the empty string as a hypothesis?
If you said nothing what should be returned then?
FPlatformProcess::Sleep(0.005);
Sleep is not really needed here