remarkable_tool/main.cpp
King_DuckZ 6b9556e711 Crash fix
Two fixes really:
1. fix some parent pointers being wrong
2. fix notebooks being destroyed while node tree is still valid
2021-03-29 14:48:48 +02:00

61 lines
2 KiB
C++

/* Copyright 2021, Michele Santullo
* This file is part of remarkable_tool.
*
* remarkable_tool is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Remarkable_tool is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with remarkable_tool. If not, see <http://www.gnu.org/licenses/>.
*/
#include "main_window.hpp"
#include "notebook_tree.hpp"
#include <QApplication>
#include <iostream>
#include <string_view>
#include <vector>
#include <utility>
namespace {
#define BASE_PATH "/run/media/duckz/Sabrent/deleme/remarkable_20210324/xochitl/"
//#define BASE_PATH "/home/duckz/dev/code/cpp/remarkable_tool/lib/lines-are-beautiful/share/rmlab/examples/"
void print_tree (const duck::Node& tree, std::string_view desc={}, std::string indent={}) {
std::cout << indent << desc << " (\"" << tree.name << "\")";
if (tree.info && tree.info->isolated)
std::cout << " ISOLATED";
else if (tree.info and tree.info->deleted)
std::cout << " DELETED";
std::cout << '\n';
for (const auto& child : tree.children) {
print_tree(child, child.info->visible_name, indent + "\t");
}
}
} //unnamed namespace
int main (int argc, char* argv[]) {
using std::string_view;
QApplication app(argc, argv);
duck::Notebooks notebooks(BASE_PATH);
std::vector<duck::Node> roots = notebooks.build_tree();
std::vector<const duck::NotebookInfo*> dele_list = duck::make_list_of_deleted(roots);
duck::MainWindow win(&roots.back());
win.show();
for (const duck::NotebookInfo* nb : dele_list) {
for (const auto& f : nb->files) {
std::cout << "/home/root/.local/share/remarkable/xochitl/" << f << '\n';
}
}
return app.exec();
}