Skip to content

Commit

Permalink
Fix prepareView condition bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianfrasineanu committed Nov 21, 2016
1 parent 4bb718d commit 7da1238
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
1 change: 1 addition & 0 deletions app/Bootstrap.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Console.h"
#include <vld>

using namespace std;

Expand Down
12 changes: 5 additions & 7 deletions app/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ void Controller::justShow()

void Controller::prepareView()
{
// Preserve the original one
string copyChunk = this->viewChunk;

if (this->hasInput(copyChunk))
Expand All @@ -32,12 +31,12 @@ void Controller::prepareView()
{
this->chopChunkAndGetAlias(copyChunk);
}
if (!this->hasInput(copyChunk))
else if (!this->hasInput(copyChunk))
{
// Gather all the required variables from the model and replace them in chunk at once (no need to wait for input), thus discarding the dummy chunk
// this->bringAllDataInChunk()
// To avoid the type issue, let the model to the outputting via a method,
// same way as getting the input, chopping the chunk.
}
else
else if (this->hasInput(copyChunk) || this->hasOutput(copyChunk))
{
if (copyChunk.find(Controller::viewInputFormat) < copyChunk.find(Controller::viewOutputFormat))
{
Expand Down Expand Up @@ -83,7 +82,7 @@ Controller::Controller(char *viewName, string &viewChunk, string &ViewExtension)
string controllerName = viewName;
controllerName.erase(controllerName.find(ViewExtension), ViewExtension.size()).append("Controller");

this->controllerName = new char[strlen(controllerName.c_str()) + 1];
this->controllerName = new char[controllerName.size() + 1];
strcpy(this->controllerName, controllerName.c_str());
this->viewChunk = viewChunk;
this->controllerAttributions = {};
Expand Down Expand Up @@ -138,6 +137,5 @@ bool Controller::hasOutput(string &raw)

Controller::~Controller()
{
log(this->userInputs, "userInput", "destroying the controller");
delete[] this->controllerName;
}
3 changes: 1 addition & 2 deletions app/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
#include <conio.h>
#include <Windows.h>

// Define include guard as function templates always comes along with non-template
// code that's called multiple times during run-time, hence this file.
// Define include guard as function templates will get a redefined error.
#pragma once

using namespace std;
Expand Down
2 changes: 1 addition & 1 deletion app/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ View::View()

View::View(string &viewName, map<char, string> &availableOptions)
{
this->viewName = new char[strlen(viewName.c_str()) + 1];
this->viewName = new char[viewName.size() + 1];
strcpy(this->viewName, viewName.c_str());
this->availableOptions = availableOptions;
}
Expand Down

0 comments on commit 7da1238

Please sign in to comment.