Coverity Scan based fixes

Fixes some issues from Coverity report, fixed Travis Coverity support.
presentation
MarPiRK 10 years ago
parent c85753c328
commit 7ea1a69feb
  1. 12
      .travis.yml
  2. 110
      src/control/ToolHandler.cpp
  3. 6
      src/gui/TextEditor.cpp
  4. 29
      src/gui/toolbarMenubar/model/ToolbarModel.cpp
  5. 4
      src/gui/toolbarMenubar/model/ToolbarModel.h
  6. 1
      src/model/LinkDestination.cpp
  7. 2
      src/pdf/popplerdirect/PdfExport.cpp

@ -5,20 +5,19 @@ language:
# clang is not supported for poppler
compiler: gcc
cache:
- ccache
os: linux
sudo: false
cache:
- ccache
env:
global:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: "DxwzqXcJV/9qPwUCi7DQrqzeU73ACRhS0i8suV9tYpUDJ7ZuwwSK/GMVt2jMTNjZbJwKFv8ELLu0MIdTfX3UvG+++lfxLx4yldEwl4CtjPJaClB2rTou2SAiZPMBMyX6eHKfx0XB4xtsqwtKRIvF47tB9i3w+aPcb8C4DE6hXmU="
addons:
apt:
packages:
@ -46,7 +45,7 @@ addons:
name: "MarPiRK/xournalpp"
description: "Notetaking software designed around a tablet."
notification_email: marek@pikula.co
build_command_prepend: "mkdir build && cd build && cmake .. -DBUILD_POPPLER=ON -DEXT_GLIBMM=ON -DENABLE_MATHTEX=ON -DENABLE_OS=ON -DENABLE_CPPUNIT=ON -DUNSTABLE_LAYERS_SIDEBAR=ON"
build_command_prepend: "cmake .. -DBUILD_POPPLER=ON -DEXT_GLIBMM=ON -DENABLE_MATHTEX=ON -DENABLE_OS=ON -DENABLE_CPPUNIT=ON -DUNSTABLE_LAYERS_SIDEBAR=ON"
build_command: "make"
branch_pattern: coverity_scan
@ -60,7 +59,6 @@ script:
- "ctest"
notifications:
slack: xournalpp:D5mvotdm0Rnn0ejvZf0FIxgV
webhooks:
urls:
- https://webhooks.gitter.im/e/4879506130dac18d2f63

@ -568,74 +568,74 @@ void ToolHandler::loadSettings()
SElement& s = settings->getCustomElement("tools");
string selectedTool;
s.getString("current", selectedTool);
ArrayIterator<Tool*> it = iterator();
for (; it.hasNext();)
if (s.getString("current", selectedTool))
{
Tool* t = it.next();
SElement& st = s.child(t->getName());
ArrayIterator<Tool*> it = iterator();
if (selectedTool == t->getName())
for (; it.hasNext();)
{
this->current = t;
}
Tool* t = it.next();
SElement& st = s.child(t->getName());
int color = 0;
if (t->isEnableColor() && st.getInt("color", color))
{
t->setColor(color);
}
if (selectedTool == t->getName())
{
this->current = t;
}
bool enabled = false;
if (t->isEnableRuler() && st.getBool("ruler", enabled))
{
t->setRuler(enabled);
}
if (t->isEnableRectangle() && st.getBool("rectangle", enabled))
{
t->setRectangle(enabled);
}
if (t->isEnableCircle() && st.getBool("circle", enabled))
{
t->setCircle(enabled);
}
if (t->isEnableArrow() && st.getBool("arrow", enabled))
{
t->setArrow(enabled);
}
if (t->isEnableShapeRecognizer() && st.getBool("shapeRecognizer", enabled))
{
t->setShapeRecognizer(enabled);
}
int color = 0;
if (t->isEnableColor() && st.getInt("color", color))
{
t->setColor(color);
}
string value;
bool enabled = false;
if (t->isEnableRuler() && st.getBool("ruler", enabled))
{
t->setRuler(enabled);
}
if (t->isEnableRectangle() && st.getBool("rectangle", enabled))
{
t->setRectangle(enabled);
}
if (t->isEnableCircle() && st.getBool("circle", enabled))
{
t->setCircle(enabled);
}
if (t->isEnableArrow() && st.getBool("arrow", enabled))
{
t->setArrow(enabled);
}
if (t->isEnableShapeRecognizer() && st.getBool("shapeRecognizer", enabled))
{
t->setShapeRecognizer(enabled);
}
if (t->isEnableSize() && st.getString("size", value))
{
if (value == "VERY_THIN") t->setSize(TOOL_SIZE_VERY_FINE);
else if (value == "THIN") t->setSize(TOOL_SIZE_FINE);
else if (value == "MEDIUM") t->setSize(TOOL_SIZE_MEDIUM);
else if (value == "BIG") t->setSize(TOOL_SIZE_THICK);
else if (value == "VERY_BIG") t->setSize(TOOL_SIZE_VERY_THICK);
else g_warning("Settings::Unknown tool size: %s\n", value.c_str());
}
string value;
if (t->type == TOOL_ERASER)
{
string type;
if (t->isEnableSize() && st.getString("size", value))
{
if (value == "VERY_THIN") t->setSize(TOOL_SIZE_VERY_FINE);
else if (value == "THIN") t->setSize(TOOL_SIZE_FINE);
else if (value == "MEDIUM") t->setSize(TOOL_SIZE_MEDIUM);
else if (value == "BIG") t->setSize(TOOL_SIZE_THICK);
else if (value == "VERY_BIG") t->setSize(TOOL_SIZE_VERY_THICK);
else g_warning("Settings::Unknown tool size: %s\n", value.c_str());
}
if (st.getString("type", type))
if (t->type == TOOL_ERASER)
{
if (type == "deleteStroke") setEraserType(ERASER_TYPE_DELETE_STROKE);
else if (type == "whiteout") setEraserType(ERASER_TYPE_WHITEOUT);
else setEraserType(ERASER_TYPE_DEFAULT);
eraserTypeChanged();
string type;
if (st.getString("type", type))
{
if (type == "deleteStroke") setEraserType(ERASER_TYPE_DELETE_STROKE);
else if (type == "whiteout") setEraserType(ERASER_TYPE_WHITEOUT);
else setEraserType(ERASER_TYPE_DEFAULT);
eraserTypeChanged();
}
}
}
}
}
void ToolHandler::copyCurrentConfig()

@ -733,7 +733,7 @@ void TextEditor::deleteFromCursor(GtkDeleteType type, int count)
XOJ_CHECK_TYPE(TextEditor);
GtkTextIter insert;
bool leave_one = false;
//gboolean leave_one = false; // not needed
this->resetImContext();
@ -854,10 +854,10 @@ void TextEditor::deleteFromCursor(GtkDeleteType type, int count)
if (gtk_text_buffer_delete_interactive(this->buffer, &start, &end, true))
{
if (leave_one)
/*if (leave_one) // leave_one is statically false
{
gtk_text_buffer_insert_interactive_at_cursor(this->buffer, " ", 1, true);
}
}*/
}
else
{

@ -2,7 +2,7 @@
#include "ToolbarData.h"
#include <string.h>
#include <fstream>
ToolbarModel::ToolbarModel()
{
@ -35,17 +35,7 @@ void ToolbarModel::parseGroup(GKeyFile* config, const char* group, bool predefin
ToolbarData* data = new ToolbarData(predefined);
string name;
if (predefined)
{
name = "predef_";
}
else
{
name = "custom_";
}
data->name = name;
data->name = (predefined ? "predef_" : "custom_");
data->id = group;
data->load(config, group);
@ -57,7 +47,7 @@ void ToolbarModel::remove(ToolbarData* data)
{
XOJ_CHECK_TYPE(ToolbarModel);
for (unsigned int i = 0; i < this->toolbars.size(); i++)
for (size_t i = 0; i < this->toolbars.size(); i++)
{
if (this->toolbars[i] == data)
{
@ -74,13 +64,13 @@ void ToolbarModel::add(ToolbarData* data)
this->toolbars.push_back(data);
}
bool ToolbarModel::parse(const char* file, bool predefined)
bool ToolbarModel::parse(string filename, bool predefined)
{
XOJ_CHECK_TYPE(ToolbarModel);
GKeyFile* config = g_key_file_new();
g_key_file_set_list_separator(config, ',');
if (!g_key_file_load_from_file(config, file, G_KEY_FILE_NONE, NULL))
if (!g_key_file_load_from_file(config, filename.c_str(), G_KEY_FILE_NONE, NULL))
{
g_key_file_free(config);
return false;
@ -139,7 +129,7 @@ const char* TOOLBAR_INI_HEADER =
" LAYER: The layer dropdown menu\n"
"\n";
void ToolbarModel::save(const char* filename)
void ToolbarModel::save(string filename)
{
GKeyFile* config = g_key_file_new();
g_key_file_set_list_separator(config, ',');
@ -157,8 +147,9 @@ void ToolbarModel::save(const char* filename)
gsize len = 0;
char* data = g_key_file_to_data(config, &len, NULL);
FILE* fp = fopen(filename, "w");
fwrite(data, 1, len, fp);
fclose(fp);
std::ofstream f(filename);
f.write(data, len);
f.close();
g_free(data);
}

@ -25,10 +25,10 @@ public:
public:
ToolbarDataVector* getToolbars();
bool parse(const char* file, bool predefined);
bool parse(string filename, bool predefined);
void add(ToolbarData* data);
void remove(ToolbarData* data);
void save(const char* filename);
void save(string filename);
bool existsId(string id);
private:

@ -57,6 +57,7 @@ LinkDestination::LinkDestination()
this->zoom = 0;
this->left = 0;
this->top = 0;
this->expand = false;
}
LinkDestination::~LinkDestination()

@ -306,7 +306,7 @@ void PdfExport::writeGzStream(Stream* str, GList* replacementList)
string text = GzHelper::gzuncompress(string(buffer, length));
writeStream(text.c_str(), text.length(), replacementList);
delete buffer;
delete[] buffer;
str->reset();
}

Loading…
Cancel
Save