Skip to content

Commit

Permalink
hls-cache stuff has been removed
Browse files Browse the repository at this point in the history
  • Loading branch information
psemiletov committed May 28, 2018
1 parent 3b6029d commit 0334d28
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 50 deletions.
7 changes: 5 additions & 2 deletions document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,11 @@ CDocument* document_holder::open_file_triplex (const QString &triplex)
return NULL;

CDocument *d = open_file (sl[0], sl[1]);
if (d)
d->goto_pos (sl[2].toInt());
if (! d)
return NULL;

//if (d)
d->goto_pos (sl[2].toInt());

if (sl.size() >= 4)
{
Expand Down
86 changes: 51 additions & 35 deletions rvln.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,11 +723,12 @@ rvln::rvln()

update_stylesheet (fname_stylesheet);
documents->apply_settings();


documents->todo.load_dayfile();

update_hls();
//update_hls();
update_hls_noncached();

update_view_hls();

#ifdef SPELLCHECK_ENABLE
Expand All @@ -748,8 +749,6 @@ rvln::rvln()
createManual();

updateFonts();

//update_stylesheet (fname_stylesheet);

dir_last = settings->value ("dir_last", QDir::homePath()).toString();
b_preview = settings->value ("b_preview", false).toBool();
Expand All @@ -771,7 +770,7 @@ rvln::rvln()
QString vn = settings->value ("VERSION_NUMBER", "").toString();
if (vn.isEmpty() || vn != QString (VERSION_NUMBER))
{
update_hls (true);
//update_hls (true);
help_show_news();
}

Expand All @@ -790,12 +789,9 @@ rvln::rvln()

QClipboard *clipboard = QApplication::clipboard();
connect (clipboard , SIGNAL(dataChanged()), this, SLOT(clipboard_dataChanged()));


#ifdef USE_QML_STUFF

plugins_init();

#endif

setAcceptDrops (true);
Expand Down Expand Up @@ -5781,16 +5777,56 @@ void rvln::update_palettes()
}


void rvln::update_hls_noncached()
{
qDebug() << "update_hls_noncached()";

QTime tm;
tm.start();

documents->hls.clear();

QStringList l1 = read_dir_entries (":/hls"); //read built-in hls modiles
l1 << read_dir_entries (dir_hls); //read custom hls modules

for (int i = 0; i < l1.size(); i++)
{
QString fname = ":/hls/" + l1[i];

//check is fname built-in or not

if (! file_exists (fname))
fname = dir_hls + "/" + l1[i];

QString buffer = qstring_load (fname);
QString exts = string_between (buffer, "exts=\"", "\"");

if (! exts.isEmpty())
{
QStringList l = exts.split (";");
for (int i = 0; i < l.size(); i++)
documents->hls.insert (l[i], fname);
}
}

qDebug("Time elapsed: %d ms", tm.elapsed());
}


//весь этот механизм отключен и требует изучения
/*
void rvln::update_hls (bool force)
{
QTime tm;
tm.start();
documents->hls.clear();
QStringList l1 = read_dir_entries (":/hls"); //read built-in hls modiles
l1 << read_dir_entries (dir_hls); //read custom hls modules
QString newlist = l1.join("\n").trimmed();
QString fname_hls_flist (dir_config);
fname_hls_flist.append ("/fname_hls_flist");
QString fname_hls_flist = dir_config + "/fname_hls_flist";
if (force)
{
Expand Down Expand Up @@ -5842,8 +5878,10 @@ void rvln::update_hls (bool force)
}
else
documents->hls = hash_load_keyval (fname_hls_cache);
qDebug("Time elapsed: %d ms", tm.elapsed());
}

*/

void rvln::mrkup_preview_color()
{
Expand Down Expand Up @@ -8807,12 +8845,12 @@ void rvln::file_notes()

void rvln::update_stylesheet (const QString &f)
{
qDebug() << "update_stylesheet";
// qDebug() << "update_stylesheet";

//Update paletted

int darker_val = settings->value ("darker_val", 100).toInt();


QFontInfo fi = QFontInfo (qApp->font());

QString fontsize = "font-size:" + settings->value ("app_font_size", fi.pointSize()).toString() + "pt;";
Expand Down Expand Up @@ -8881,34 +8919,26 @@ qDebug() << "update_stylesheet";

stylesheet += css_fif;


//Update themed


QString cssfile = qstring_load (f);

QString css_path = get_file_path (f) + "/";
//theme_dir = css_path;


cssfile = cssfile.replace ("./", css_path);

cssfile += stylesheet;


qApp->setStyleSheet ("");
qApp->setStyleSheet (cssfile);

//qDebug() << "css_path " << css_path;

}


QIcon rvln::get_theme_icon (const QString &name)
{
//if (file_get_ext (fname) == "svg")


QString fname = theme_dir + "icons/" + name;

if (file_exists (fname))
Expand Down Expand Up @@ -8999,26 +9029,12 @@ void create_menu_from_themes (QObject *handler,
}
}
}

}


void rvln::update_themes()
{
menu_view_themes->clear();

/*
menu_view_palettes->clear();
QStringList l1 = read_dir_entries (dir_palettes);
QStringList l2 = read_dir_entries (":/palettes");
l1 += l2;
create_menu_from_list (this, menu_view_palettes,
l1,
SLOT (file_use_palette()));
*/

create_menu_from_themes (this,
menu_view_themes,
Expand Down
3 changes: 2 additions & 1 deletion rvln.h
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,8 @@ prefs window widgets



void update_hls (bool force = false);
//void update_hls (bool force = false);
void update_hls_noncached();

void update_tables();
void update_scripts();
Expand Down
26 changes: 15 additions & 11 deletions single_application_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CSingleApplicationShared::CSingleApplicationShared(int &argc, char *argv[], cons

sharedMemory.setKey(uniqueKey);

// when can create it only if it doesn't exist
// when can create it only if it doesn't exist
if (sharedMemory.create(5000))
{
sharedMemory.lock();
Expand All @@ -37,10 +37,12 @@ CSingleApplicationShared::CSingleApplicationShared(int &argc, char *argv[], cons
connect(timer, SIGNAL(timeout()), this, SLOT(checkForMessage()));
timer->start(200);
}

// it exits, so we can attach it?!
else if (sharedMemory.attach()){
bAlreadyExists = true;
}
else if (sharedMemory.attach())
{
bAlreadyExists = true;
}
else{
// error
}
Expand Down Expand Up @@ -84,25 +86,27 @@ bool CSingleApplicationShared::sendMessage(const QString &message)
#ifndef Q_OS_OS2

//we cannot send mess if we are master process!
if (isMasterApp()){
return false;
}
if (isMasterApp())
return false;

QByteArray byteArray;

byteArray.append(char(message.size()));
byteArray.append(message.toUtf8());
byteArray.append('\0');

sharedMemory.lock();
char *to = (char*)sharedMemory.data();
while(*to != '\0'){
int sizeToRead = int(*to);
to += sizeToRead + 1;
}
while (*to != '\0')
{
int sizeToRead = int(*to);
to += sizeToRead + 1;
}

const char *from = byteArray.data();
memcpy(to, from, qMin(sharedMemory.size(), byteArray.size()));
sharedMemory.unlock();

#endif
return true;
}
2 changes: 1 addition & 1 deletion single_application_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CSingleApplicationShared: public QApplication
bool alreadyExists() const
{
return bAlreadyExists;
}
}

bool isMasterApp() const
{
Expand Down

0 comments on commit 0334d28

Please sign in to comment.