Skip to content

Commit 61ff5ce

Browse files
committed
FLTK: recent path duplicate entries
1 parent 5b54f11 commit 61ff5ce

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/platform/fltk/FileWidget.cxx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,19 @@ const char *FileWidget::splitPath(const char *filename, char *path) {
147147
if (!result) {
148148
result = filename;
149149
} else {
150-
result++; // skip slash
150+
// skip slash
151+
result++;
151152
}
152153

153154
if (path) {
154155
// return the path component
155156
int len = result - filename - 1;
156157
if (len > 0) {
157158
strncpy(path, filename, len);
159+
// snip any double slashes
160+
while (len > 0 && path[len - 1] == '/') {
161+
len--;
162+
}
158163
path[len] = 0;
159164
} else {
160165
path[0] = 0;

src/platform/fltk/MainWindow.cxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@
2525
#include "EditorWidget.h"
2626
#include "HelpWidget.h"
2727
#include "FileWidget.h"
28-
#include "common/sbapp.h"
2928
#include "platform/common/StringLib.h"
30-
29+
#include "common/sbapp.h"
3130
#include "common/sys.h"
3231
#include "common/fs_socket_client.h"
3332

@@ -1325,7 +1324,7 @@ void MainWindow::open_file(fltk::Widget *w, void *eventData) {
13251324
for (int i = 0; i < NUM_RECENT_ITEMS; i++) {
13261325
char nextPath[MAX_PATH];
13271326
FileWidget::splitPath(recentPath[i].toString(), nextPath);
1328-
if (!paths->exists(nextPath)) {
1327+
if (nextPath[0] && !paths->exists(nextPath)) {
13291328
paths->add(nextPath);
13301329
}
13311330
}

0 commit comments

Comments
 (0)